New specs: archer-template-library, ccp-metrics-view-restructure, compliance-list-stale-after-sidebar-edit, compliance-metric-estimated-resolution-date, compliance-remediation-display-fix, flexible-jira-ticket-creation, forecast-burndown-chart, granite-loader-export, ivanti-queue-clear-completed-fix, multi-item-jira-ticket, queue-collapsible-sections, vendor-issue-type-dropdown New steering: archer-template-gen.md Updated: migration-registration-check hook, remediation-plan-history spec, gitlab-workflow, tech, versioning steering files
17 KiB
Requirements Document
Introduction
This feature adds a per-metric forecast burndown chart to the CCP Metrics page. Unlike the existing aggregated burndown (which rolls up across all verticals by hostname), this chart focuses on individual compliance metrics (e.g., 2.3.5, 2.3.6, 5.2.5) and combines historical compliance data with forward-looking remediation projections in a single stacked bar + line chart. The chart displays actual historical data on the left side and forecasted future data on the right side, separated by a bold vertical divider. A metric selector allows users to switch between metrics. The chart reads from the same compliance_items table that the AEO Compliance page writes to, so device-level edits (resolution_date changes) dynamically feed into the forecast.
Glossary
- Forecast_Burndown_API: The backend endpoint that returns combined historical and forecast burndown data for a specific compliance metric, identified by
metric_id. - Metric_Selector: A dropdown or picker UI component that allows the user to choose which compliance metric to display in the chart.
- Historical_Data: Monthly compliance snapshots from the past 3 months plus the current month, showing actual total asset counts, non-compliant device counts, and compliance percentages as recorded at each snapshot point.
- Forecast_Data: Projected future monthly data points computed from active non-compliant devices with scheduled
resolution_datevalues, assuming total asset count remains constant and all remediation plans complete on schedule. - Compliance_Percentage: The ratio of compliant devices to total devices for a given metric, expressed as a percentage (0%–100%).
- Total_Assets: The total number of devices in scope for a given metric at a point in time.
- Non_Compliant_Count: The number of devices that are non-compliant for a given metric at a point in time.
- Divider_Line: A bold vertical line on the chart separating actual historical data (left) from forecasted future data (right).
- CCP_Metrics_Page: The page component (
CCPMetricsPage.js) where the forecast burndown chart is displayed. - Compliance_Items_Table: The
compliance_itemsPostgreSQL table that tracks non-compliant devices with fields includinghostname,metric_id,status,resolution_date,vertical, andteam.
Requirements
Requirement 1: Per-Metric Forecast Burndown API Endpoint
User Story: As a compliance analyst, I want an API endpoint that returns combined historical and forecast burndown data for a specific metric, so that the frontend can render a chart showing past compliance trends and projected future remediation.
Acceptance Criteria
- WHEN a GET request is made to
/api/compliance/vcl-multi/metric/:metricId/forecast-burndown, THE Forecast_Burndown_API SHALL return a JSON response containingmetric_id,historical,forecast, andcurrent_snapshotfields within 3 seconds. - THE Forecast_Burndown_API SHALL compute
historicalas an array of exactly 4 monthly data points (the current month plus the 3 preceding months in chronological order), where each data point containsmonth(YYYY-MM),total_assets,non_compliant, andcompliance_pct. - THE Forecast_Burndown_API SHALL derive historical
total_assetsandnon_compliantcounts from thecompliance_snapshotstable filtered by the vertical associated with the requestedmetricIdincompliance_items(determined by querying theverticalcolumn of active devices matching thatmetric_id), combined with per-metric device counts fromcompliance_itemsfor that snapshot period. - THE Forecast_Burndown_API SHALL compute
forecastas an array of projected future monthly data points, where each data point containsmonth(YYYY-MM),total_assets,non_compliant, andcompliance_pct. - THE Forecast_Burndown_API SHALL project forecast data by assuming the current
total_assetscount remains constant and that each non-compliant device with aresolution_datein a future month will become compliant in that month. - THE Forecast_Burndown_API SHALL compute
current_snapshotcontainingtotal_assets,non_compliant,compliant,compliance_pct,blockers(count of devices with no resolution_date), andwith_dates(count of devices with a resolution_date). - THE Forecast_Burndown_API SHALL require authentication via
requireAuth()middleware. - IF the
metricIdparameter does not match any active devices incompliance_items(wherestatus = 'active'andvertical IS NOT NULL), THEN THE Forecast_Burndown_API SHALL return a 200 response with emptyhistoricalandforecastarrays andcurrent_snapshotwith all numeric fields set to 0. - THE Forecast_Burndown_API SHALL return forecast data extending forward until all devices with resolution dates are projected to be remediated, or for a maximum of 12 months from the current date, whichever comes first.
- IF the database query fails or an internal error occurs while processing the request, THEN THE Forecast_Burndown_API SHALL return a 500 response with a JSON body containing an
errorfield indicating the failure reason.
Requirement 2: Available Metrics List Endpoint
User Story: As a frontend developer, I want an API endpoint that returns the list of distinct metrics with active non-compliant devices, so that the metric selector can be populated with valid options.
Acceptance Criteria
- WHEN a GET request is made to
/api/compliance/vcl-multi/metrics-list, THE Forecast_Burndown_API SHALL return a 200 response containing a JSON array of objects, each containingmetric_id(string) anddevice_count(integer representing the number of distinct hostnames with statusactivefor that metric) fields. - THE Forecast_Burndown_API SHALL include only metrics that have at least one active non-compliant device in
compliance_itemswherevertical IS NOT NULL. - THE Forecast_Burndown_API SHALL sort the returned array by
metric_idin ascending alphanumeric order. - THE Forecast_Burndown_API SHALL require authentication via
requireAuth()middleware. - IF no metrics have active non-compliant devices with a non-null vertical, THEN THE Forecast_Burndown_API SHALL return a 200 response containing an empty JSON array.
- IF the database query fails, THEN THE Forecast_Burndown_API SHALL return a 500 response with a JSON object containing an
errorfield.
Requirement 3: Forecast Computation Logic
User Story: As a developer, I want a pure helper function that computes forecast burndown data for a given metric from device records and historical snapshots, so that the computation is testable in isolation.
Acceptance Criteria
- THE
computeMetricForecastBurndownhelper function SHALL accept acurrentDevicesarray (each element containing at minimumhostnameandresolution_datefields, whereresolution_dateis either a YYYY-MM-DD string or null), atotalAssetscount (non-negative integer), and ahistoricalSnapshotsarray (each element containingmonthas YYYY-MM,total_assets,non_compliant, andcompliance_pct), and return an object withhistorical,forecast, andcurrent_snapshotfields. - FOR ALL valid inputs, THE
computeMetricForecastBurndownfunction SHALL satisfy the invariant:current_snapshot.blockers + current_snapshot.with_dates = current_snapshot.non_compliant. - FOR ALL valid inputs where
total_assets > 0, THEcomputeMetricForecastBurndownfunction SHALL computecompliance_pctasROUND((total_assets - non_compliant) / total_assets * 100, 1)for each data point. - FOR ALL forecast data points, THE
computeMetricForecastBurndownfunction SHALL produce monotonically non-increasingnon_compliantcounts (each month has equal or fewer non-compliant devices than the previous month). - FOR ALL forecast data points, THE
computeMetricForecastBurndownfunction SHALL produce monotonically non-decreasingcompliance_pctvalues. - THE
computeMetricForecastBurndownfunction SHALL holdtotal_assetsconstant across all forecast data points, using the current month's total as the baseline. - WHEN the
currentDevicesarray is empty, THEcomputeMetricForecastBurndownfunction SHALL return an emptyforecastarray andcurrent_snapshotwith all zero values excepttotal_assets. - FOR ALL forecast months, THE
computeMetricForecastBurndownfunction SHALL computenon_compliantas the count of devices whoseresolution_dateis after that month (devices not yet remediated) plusblockers(devices with no resolution_date). - THE
computeMetricForecastBurndownfunction SHALL generate forecast data points extending forward month-by-month until all devices with resolution dates are projected to be remediated, or for a maximum of 12 months from the current date, whichever comes first. - IF
totalAssetsis 0, THEN THEcomputeMetricForecastBurndownfunction SHALL returncompliance_pctof 0 for all data points inhistorical,forecast, andcurrent_snapshot. - IF
totalAssetsis less than the number of elements incurrentDevices, THEN THEcomputeMetricForecastBurndownfunction SHALL use the count ofcurrentDevicesasnon_compliantwithout clamping tototalAssets.
Requirement 4: Forecast Burndown Chart Component
User Story: As a senior leader viewing the CCP Metrics page, I want to see a combined historical and forecast burndown chart for each metric, so that I can visualize past compliance trends and projected future remediation timelines.
Acceptance Criteria
- THE Forecast_Burndown_Chart SHALL be displayed on the CCP_Metrics_Page in a dedicated section below the Metric_Selector.
- THE Forecast_Burndown_Chart SHALL render a stacked bar chart where blue bars represent Total_Assets (100% height baseline) and orange bars represent Non_Compliant_Count.
- THE Forecast_Burndown_Chart SHALL render a green line overlay showing Compliance_Percentage as a trend line with percentage labels at each data point.
- THE Forecast_Burndown_Chart SHALL display a left Y-axis scaled to the maximum Total_Assets value for device counts, and a right Y-axis scaled from 0% to 100% for Compliance_Percentage.
- THE Forecast_Burndown_Chart SHALL display the X-axis labeled with months (YYYY-MM format), showing up to 16 data points (up to 4 historical months plus up to 12 forecast months).
- THE Forecast_Burndown_Chart SHALL render a bold vertical Divider_Line separating Historical_Data (left side) from Forecast_Data (right side), positioned between the last historical data point and the first forecast data point.
- THE Forecast_Burndown_Chart SHALL render forecast bars and line segments with 50% opacity to visually distinguish projections from actuals.
- THE Forecast_Burndown_Chart SHALL display raw device count labels inside the bars (total assets count in blue bars, non-compliant count in orange bars).
- THE Forecast_Burndown_Chart SHALL display compliance percentage values as labels on the green trend line at each data point.
- WHEN the Forecast_Burndown_API returns both empty
historicaland emptyforecastarrays for a selected metric, THE Forecast_Burndown_Chart SHALL display a message indicating no data is available for that metric. - WHEN the user selects a different metric from the Metric_Selector, THE Forecast_Burndown_Chart SHALL fetch updated data from the Forecast_Burndown_API and re-render the chart with the new metric's data.
- WHILE the Forecast_Burndown_API request is in flight, THE Forecast_Burndown_Chart SHALL display a loading indicator in place of the chart content.
- IF the Forecast_Burndown_API request fails, THEN THE Forecast_Burndown_Chart SHALL display an inline error message with an AlertCircle icon and the error description, styled with a red border consistent with the existing error display pattern on the CCP_Metrics_Page.
- WHEN the Forecast_Burndown_API returns a non-empty
historicalarray but an emptyforecastarray, THE Forecast_Burndown_Chart SHALL render only the historical bars and trend line without a Divider_Line or forecast section.
Requirement 5: Metric Selector Component
User Story: As a compliance analyst, I want a metric picker that lets me choose which metric's forecast burndown to view, so that I can analyze remediation progress for individual compliance requirements.
Acceptance Criteria
- THE Metric_Selector SHALL be displayed above or adjacent to the Forecast_Burndown_Chart on the CCP_Metrics_Page.
- THE Metric_Selector SHALL populate its options by fetching the available metrics list from the metrics-list endpoint on page load.
- THE Metric_Selector SHALL display each metric option showing the
metric_idand the count of active non-compliant devices. - WHEN the user selects a metric, THE Metric_Selector SHALL trigger a data fetch for that metric's forecast burndown and update the chart.
- WHEN the Metric_Selector finishes loading the metrics list and defaults to the first metric in the sorted list, THE Metric_Selector SHALL automatically trigger a data fetch for that default metric's forecast burndown and update the chart.
- WHILE the metrics list is loading, THE Metric_Selector SHALL display a loading indicator and remain non-interactive until the fetch completes or fails.
- IF the metrics list endpoint returns an empty array, THEN THE Metric_Selector SHALL display a message indicating no metrics with active non-compliant devices exist.
- IF the metrics list endpoint request fails, THEN THE Metric_Selector SHALL display an inline error message consistent with the existing error display pattern on the CCP_Metrics_Page.
- WHILE the forecast burndown data is loading after a metric selection, THE Metric_Selector SHALL remain interactive, and if the user selects a different metric before the previous fetch completes, THE Metric_Selector SHALL discard the previous in-flight response and use only the result from the most recent selection.
Requirement 6: Dynamic Data Integration with AEO Compliance Page
User Story: As a compliance analyst, I want the forecast burndown chart to reflect device-level edits made on the AEO Compliance page in real time, so that when I update a device's resolution_date for a metric, the forecast projection updates accordingly on the next chart load.
Acceptance Criteria
- THE Forecast_Burndown_API SHALL query the
compliance_itemstable directly (not a cached copy), so that edits made via the AEO Compliance page'sPATCH /items/:hostname/metadataendpoint are reflected in the next API call made after the PATCH response completes. - WHEN a user changes a device's
resolution_dateon the AEO Compliance page for a specific metric, THE Forecast_Burndown_API SHALL include that updated date in its forecast computation on the next request for that metric. - WHEN a device's status changes from
activetoresolvedon the AEO Compliance page, THE Forecast_Burndown_API SHALL exclude that device from the non-compliant count on the next request. - IF a device's
resolution_dateis cleared (set to NULL) on the AEO Compliance page, THEN THE Forecast_Burndown_API SHALL count that device as a blocker in thecurrent_snapshot.blockerscount and exclude it from month-by-month forecast remediation projections on the next request. - IF a device's
resolution_dateis changed to a date in a month that has already passed relative to the current date, THEN THE Forecast_Burndown_API SHALL treat that device as projected to be remediated in the current month (not exclude it from non-compliant count until its status changes toresolved). - THE Forecast_Burndown_API SHALL use the current state of
compliance_itemsas the source of truth for the current snapshot and forecast projections, with no application-level caching between requests.
Requirement 7: Historical Data Derivation
User Story: As a compliance analyst, I want the chart to show actual historical compliance data for the past 3 months, so that I can see the real trend leading into the forecast.
Acceptance Criteria
- THE Forecast_Burndown_API SHALL derive historical data from the
compliance_snapshotstable, which records monthly total_devices, compliant, and non_compliant counts per vertical, for the 3 calendar months immediately preceding the current month. - THE Forecast_Burndown_API SHALL compute per-metric historical non_compliant count at each snapshot point by multiplying the vertical's snapshot non_compliant count by the ratio of the metric's non-compliant devices to the vertical's total non-compliant devices (as recorded in
compliance_itemsfor that period), rounding to the nearest integer. - IF the vertical's total non_compliant count is 0 at a historical snapshot point, THEN THE Forecast_Burndown_API SHALL set the metric's non_compliant count to 0 for that data point.
- THE Forecast_Burndown_API SHALL use the vertical's snapshot total_devices as the metric's total_assets for each historical data point.
- WHEN no historical snapshots exist for a metric's vertical, THE Forecast_Burndown_API SHALL return an empty
historicalarray. - THE Forecast_Burndown_API SHALL include the current month as the most recent historical data point, computed from live
compliance_itemsdata rather than a stored snapshot. - THE Forecast_Burndown_API SHALL return historical data points in chronological order (oldest first).