Repository navigation
Send the Metrics screen's time range to every case-metrics read - #3103
Conversation
caseMetricsApi.getSummary, getByPriority, getByStatus and getAnalystPerformance took no arguments, so Total, Open, Critical, the priority and status charts and the analyst table always showed all-time numbers while MTTD and MTTR showed the chosen window. All six methods now take a required MetricsWindow, and the hook passes the same window to each. Closes #2903 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🧹 Proof at Job: #2903, a fix job in feature
Blast radius: high. Touches 4 file(s) in the ui, tests layer(s), across feature(s)
The author says it is safe because: all six routes in How each count was made, and how to rerun itSize. +76 −10 over the whole diff, as GitHub counts it. Reproduce with Callers. What the PR deletes and does not define again, searched for across the repo at Style lint. No findings in the prose the PR adds. CI at Evidence. eslint.txt · pytest-case-metrics.txt · pytest-ratchets.txt · tsc.txt · vitest-after-fix.txt · vitest-window-before-fix.txt Machine-readable{
"sha": "7cd95394df413b6aad47071d3e9ba27777b9687d",
"pr": 3103,
"job": {
"issue": 2903,
"kind": "fix",
"feature": "case-metrics",
"survey": "2026-10-22-6035439f-y8bt"
},
"blast": {
"severity": "high",
"reasons": [
{
"severity": "high",
"what": "spans 3 features: cases, case-metrics, http-client"
},
{
"severity": "medium",
"what": "touches what users see: clients/web/src/screens/metrics/MetricsScreen.window.test.tsx, clients/web/src/screens/metrics/useCaseMetrics.ts, clients/web/src/services/api.ts"
}
],
"features": [
"cases",
"case-metrics",
"http-client"
],
"layers": [
"ui",
"tests"
],
"routes": [],
"safeBecause": "all six routes in `core/api/v1/case_metrics_router.py` already accept `start_date` and `end_date` and filter `Case.created_at` through `_created_window`.",
"proofLevel": 4
},
"size": {
"additions": 76,
"deletions": 10
},
"verdicts": {
"size": "n/a",
"callers": "pass",
"lint": "pass",
"ci": "pass"
},
"callers": [],
"lint": 0,
"checks": [
{
"name": "Build Frontend",
"bucket": "pass"
},
{
"name": "Setup Path (ubuntu-latest)",
"bucket": "pass"
},
{
"name": "Backend Image",
"bucket": "pass"
},
{
"name": "Security Scan - Python",
"bucket": "pass"
},
{
"name": "Integration Tests",
"bucket": "pass"
},
{
"name": "Security Scan - NPM",
"bucket": "pass"
},
{
"name": "Unit Tests - Backend (DB-backed)",
"bucket": "pass"
},
{
"name": "Helm Install Schema",
"bucket": "pass"
},
{
"name": "MCP Runner Image",
"bucket": "pass"
},
{
"name": "Unit Tests - Backend",
"bucket": "pass"
},
{
"name": "Setup Path (macos-latest)",
"bucket": "pass"
},
{
"name": "CodeQL",
"bucket": "pass"
},
{
"name": "Unit Tests - Agent Layer",
"bucket": "pass"
},
{
"name": "Generated API Types",
"bucket": "pass"
},
{
"name": "Unit Tests - Frontend",
"bucket": "pass"
},
{
"name": "Daemon Image",
"bucket": "pass"
},
{
"name": "Lint Frontend",
"bucket": "pass"
},
{
"name": "Lint Backend",
"bucket": "pass"
},
{
"name": "Lint Dockerfiles",
"bucket": "pass"
},
{
"name": "Agent Image",
"bucket": "pass"
},
{
"name": "Analyze (python)",
"bucket": "pass"
},
{
"name": "Analyze (javascript-typescript)",
"bucket": "pass"
},
{
"name": "Analyze (actions)",
"bucket": "pass"
}
],
"evidence": [
{
"name": "eslint.txt",
"url": "https://github.com/Vigil-SOC/vigil/blob/deslop-evidence/pr-3103/eslint.txt"
},
{
"name": "pytest-case-metrics.txt",
"url": "https://github.com/Vigil-SOC/vigil/blob/deslop-evidence/pr-3103/pytest-case-metrics.txt"
},
{
"name": "pytest-ratchets.txt",
"url": "https://github.com/Vigil-SOC/vigil/blob/deslop-evidence/pr-3103/pytest-ratchets.txt"
},
{
"name": "tsc.txt",
"url": "https://github.com/Vigil-SOC/vigil/blob/deslop-evidence/pr-3103/tsc.txt"
},
{
"name": "vitest-after-fix.txt",
"url": "https://github.com/Vigil-SOC/vigil/blob/deslop-evidence/pr-3103/vitest-after-fix.txt"
},
{
"name": "vitest-window-before-fix.txt",
"url": "https://github.com/Vigil-SOC/vigil/blob/deslop-evidence/pr-3103/vitest-window-before-fix.txt"
}
]
} |
|
🏭 Advisory review (claude-haiku-5-5 + opus advisor) — merge PR #3103: merge. Head Reviewers
Ran
Did not run
Not blocking, pre-existing, not from this PR
Pushed: nothing. Scratch files removed. |
|
🧹 Asked for proof in the running app, level 5, which a high or critical blast radius needs (1 of 3): a high blast radius proven only to level 4. |
…-metrics-screen-s-time-2df8a198
|
🏭 Advisory review (claude-haiku-5-5 + opus advisor) — merge Ran (verified on
Did not run
Pushed
Not blocking, not from this PR
|
|
🏭 Factory review — merged. The time range on Case Metrics now filters every read, and the screen shows that with real cases. No code change was needed.
Ran
The page, the shell, and the analyst table have Did not run
Pushed: nothing. |
Closes #2903
The Metrics screen's 7d/30d/90d range reached only the MTTD and MTTR reads.
getSummary,getByPriority,getByStatusandgetAnalystPerformanceincaseMetricsApitook no arguments, so Total, Open, Critical, the priority bars, the status donut and the analyst table showed all-time numbers whatever range was picked.All six
caseMetricsApimethods now take a requiredMetricsWindow(start_date,end_date), so a caller that leaves out the window does not compile.useCaseMetricspasses its onedateParamsto all six.getMTTDandgetMTTRalso lose thepriorityoption, which no caller passed.Every location in the issue still held at
052a731c, at moved line numbers (api.ts:382-391,useCaseMetrics.ts:43-50). The issue's caveat about unwindowed SLA counts no longer applies, becauseget_summarynow runs one windowed query and returns no SLA counts.Callers checked
grep -rn caseMetricsApi clientsfounduseCaseMetrics.ts, the module mock inMetricsScreen.test.tsx, and the mock inSocConsole.test.tsx. Both mocks ignore arguments.grep -rn "getSummary\|getMTTD\|getMTTR\|getByPriority\|getByStatus\|getAnalystPerformance" clientsfound only those files.findingsApi.getSummaryandcasesApi.getSummaryare different objects.grep -rn "metrics/summary\|metrics/by-priority\|metrics/by-status\|analyst-performance\|metrics/mttd\|metrics/mttr"over py, ts, js, sh and md foundapi.ts, the router, the generatedschema.d.ts, and backend tests. No other client, script or infra file calls these routes.Blast radius
The web client now sends
start_dateandend_dateon four more GET requests. The routes, the response JSON and the DB are unchanged.Safe because: all six routes in
core/api/v1/case_metrics_router.pyalready acceptstart_dateandend_dateand filterCase.created_atthrough_created_window.Tried to break it: if a route ignored the window, a windowed call would return the same rows as an unwindowed one. Summary, by-priority and by-status already had window tests. Analyst-performance had none, so I added
test_analyst_performance_respects_the_window. It seeds three analysts, setsstart_dateafter day one, and expects only alice with one case at 4h. It passed, and the file printed22 passed. On the client side, ifapi.tsor the hook dropped the window, the new vitest would see a GET with no params. Against the old code it failed withTypeError: Cannot read properties of undefined (reading 'end_date'). With the fix it passes, and all six URLs carry a 7-day span after clicking 7d.Proof: 5. I ran the real app from this branch (uvicorn
services.api.main:appwithDEV_MODE=trueon a throwaway Postgres 16 migrated bypython -m core.upgrade, plus Vite on :6988). Then I opened/metricsin headless Chromium, clicked 7d, and recorded every/cases/metrics/*request and the screen text. I seeded 5 cases. Two were created 3 days ago (alice: one critical/new, one high/closed after 4h). Three were created 60 days ago (bob: two critical, open; carol: one low, closed after 10h).Before (base
052a731capi.ts+useCaseMetrics.ts, same backend):After (this branch):
Before the change, the 7d view counted the 60-day-old cases in Total, Open, Critical, the status donut and the analyst table, and only MTTD and MTTR were windowed. After it, all six reads carry the window and the screen shows only the 2 recent cases. (Timestamps are trimmed from the printed URLs.) The vitest mocks only axios, so the real
api.ts, hook and screen run, and the pytest calls the real route handlers against the test DB. That output is inpr-3103/on thedeslop-evidencebranch.Severity: low. A wrong window shows wrong counts on one read-only screen.
Risks:
clients/web/src/services/api.ts:388-398: a new caller must supply a window. Likelihood is low, and the failure is a compile error.core/api/v1/case_metrics_router.py:98: the window filters oncreated_at, so a case opened before the window and closed inside it drops out of the counts. This always happens, but the impact is low. MTTD and MTTR already worked this way, and it is what the range is meant to mean.Cleared: the
SocConsole.test.tsxmock still satisfies the shell tests (69 passed).tsc --noEmitand eslint are clean. The axios request interceptor inapi.tsadds only the CSRF header and leaves params alone.Verification
Ran
npx vitest run src/screens/metrics/MetricsScreen.window.test.tsxon the old code: 1 failed, as expected (vitest-window-before-fix.txt).npx vitest run src/screens/metrics src/shell/SocConsole.test.tsxwith the fix: 3 files, 78 passed (vitest-after-fix.txt). TheSocConsole.test.tsxshell tests (69) pass with the existing mock.npx tsc --noEmit -p .: exit 0 (tsc.txt).npx eslint src/services/api.ts src/screens/metrics: exit 0 (eslint.txt).pytest -q tests/unit/cases/test_case_metrics_aggregates.py: 22 passed (pytest-case-metrics.txt).pytest -q tests/unit/_ratchets: 260 passed, 6 skipped because helm is not installed (pytest-ratchets.txt). No count changed.priority:tsc --noEmitexit 0, and the same vitest run gives 78 passed.Ran in the app
Did not run
🤖 Generated with Claude Code