From 632c557d184421f5bbc5804d71d5b6567ca89438 Mon Sep 17 00:00:00 2001 From: Codex Date: Thu, 2 Jul 2026 14:01:57 +0000 Subject: [PATCH] fix: mark missed cpu profile performance windows --- scripts/src/hwlab-node-web-observe-collect.ts | 12 +++++++++--- .../web-observe-collect-performance.test.ts | 6 ++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/src/hwlab-node-web-observe-collect.ts b/scripts/src/hwlab-node-web-observe-collect.ts index 5045a60e..07c524f2 100644 --- a/scripts/src/hwlab-node-web-observe-collect.ts +++ b/scripts/src/hwlab-node-web-observe-collect.ts @@ -798,14 +798,20 @@ function performanceEvidenceMode(perf, commandFiles){ const commands=performanceCaptureCommandStatus(commandFiles); const runner=runnerStatusForPerformance(); const pendingPerformanceCapture=commands.pendingCount>0||commands.processingCount>0; + const coveredWindowCount=Number(s.cpuProfileWindowCoveredCount??0); + const overlappedWindowCount=Number(s.cpuProfileWindowOverlappedCount??0); + const missedWindowCount=Number(s.cpuProfileWindowMissedCount??0); + const cpuProfileMissedPerformanceWindows=hasCpuProfile&&missedWindowCount>0&&coveredWindowCount===0&&overlappedWindowCount===0; const cpuProfileStatus=hasCpuProfile?String(s.cpuProfileStatus||'captured'):pendingPerformanceCapture?'pending-command-no-cpu-profile':'no-cpu-profile'; - const attributionMode=hasCpuProfile?'cpu-profile-and-performance-observer':hasPerformanceObserverEvidence?'loaf-only-no-cpu-profile':'no-frontend-performance-evidence'; + const attributionMode=cpuProfileMissedPerformanceWindows?String(s.attributionMode||'cpu-profile-missed-performance-window'):hasCpuProfile?String(s.attributionMode||'cpu-profile-and-performance-observer'):hasPerformanceObserverEvidence?'loaf-only-no-cpu-profile':'no-frontend-performance-evidence'; const statement=hasCpuProfile - ? 'CPU profile artifacts are present; hotspot rows may be used as CPU profile evidence.' + ? cpuProfileMissedPerformanceWindows + ? 'CPU profile artifacts exist but missed severe performance windows; do not cite CPU profile hotspots as same-window evidence.' + : 'CPU profile artifacts are present; hotspot rows may be used as CPU profile evidence.' : pendingPerformanceCapture ? 'LoAF-only / no CPU profile: performanceCapture is pending or processing, so CPU profile hotspots are unavailable for this run.' : 'LoAF-only / no CPU profile: no completed performanceCapture artifact is present, so do not cite CPU profile hotspots.'; - return {attributionMode,cpuProfileStatus,hasCpuProfile,noCpuProfile:!hasCpuProfile,loafOnly:!hasCpuProfile&&hasPerformanceObserverEvidence,pendingPerformanceCapture,runner,performanceCaptureCommands:commands,statement,valuesRedacted:true}; + return {attributionMode,cpuProfileStatus,hasCpuProfile,noCpuProfile:!hasCpuProfile,loafOnly:!hasCpuProfile&&hasPerformanceObserverEvidence,pendingPerformanceCapture,cpuProfileMissedPerformanceWindows,runner,performanceCaptureCommands:commands,statement,valuesRedacted:true}; } function performanceSummaryFromReport(){ const perf=report.frontendPerformance&&typeof report.frontendPerformance==='object'?report.frontendPerformance:{}; diff --git a/scripts/src/hwlab-node/web-observe-collect-performance.test.ts b/scripts/src/hwlab-node/web-observe-collect-performance.test.ts index 1d200361..03119855 100644 --- a/scripts/src/hwlab-node/web-observe-collect-performance.test.ts +++ b/scripts/src/hwlab-node/web-observe-collect-performance.test.ts @@ -250,8 +250,14 @@ test("performance-summary renders CPU profile window misses and source attributi const output = JSON.parse(result.stdout); const text = String(output.renderedText ?? ""); + const debug = JSON.stringify({ summary: output.summary, evidenceMode: output.evidenceMode, text }, null, 2); assert.equal(output.summary.cpuProfileWindowMissedCount, 1); + assert.equal(output.evidenceMode.attributionMode, "cpu-profile-missed-performance-window", debug); + assert.equal(output.evidenceMode.cpuProfileMissedPerformanceWindows, true, debug); assert.match(text, /window correlation=1 covered=0 overlapped=0 missed=1 missing=0 sourceMap=missing/u); + assert.match(text, /evidence attribution=cpu-profile-missed-performance-window/u); + assert.match(text, /CPU profile artifacts exist but missed severe performance windows; do not cite CPU profile hotspots as same-window evidence/u); + assert.doesNotMatch(text, /hotspot rows may be used as CPU profile evidence/u); assert.match(text, /cpuWindow=missed/u); assert.match(text, /nearest performanceCapture started after/u); assert.match(text, /CodeWorkbenchView\.js/u);