Skip to content

Commit 6354036

Browse files
svelderrainruizGitHub Copilot
andauthored
Refine offline corpus evaluation reports (#896) (#900)
* Refine offline corpus evaluation reports (#896) * Harden corpus evaluator drift test (#896) --------- Co-authored-by: GitHub Copilot <copilot@users.noreply.github.com>
1 parent 46b526b commit 6354036

7 files changed

Lines changed: 840 additions & 9 deletions

docs/knowledgebase/Offline-RealHistory-Corpus.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ Normalization refresh entry point:
7272
node tools/npm/run-script.mjs history:corpus:normalize
7373
```
7474

75+
Offline evaluation entry point:
76+
77+
```powershell
78+
node tools/npm/run-script.mjs history:corpus:evaluate
79+
```
80+
7581
The harness:
7682

7783
1. Loads the checked-in target catalog.
@@ -123,6 +129,19 @@ The normalizer does not run LabVIEW or Docker. It rebuilds the checked-in
123129
normalized subset from the catalog's `seedFixture.historySuitePath` entries and
124130
any checked-in capture JSON summaries found under the referenced fixture roots.
125131

132+
The evaluator also stays offline. It re-renders the current
133+
`Render-VIHistoryReport.ps1` output from the checked-in suite manifests and
134+
fails if the report or step summary stops surfacing the interpretation labels
135+
the normalized corpus already proved relevant:
136+
137+
- `Coverage Class`
138+
- `Mode Sensitivity`
139+
- `Outcome Labels`
140+
141+
That contract is the first corpus-backed report refinement added in `#896`:
142+
operators no longer need to infer partial requested-mode coverage only from the
143+
raw requested/executed mode lists.
144+
126145
## Storage boundary
127146

128147
- Commit:

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"history:dispatch": "pwsh -NoLogo -NoProfile -File scripts/Dispatch-VIHistoryWorkflow.ps1",
3636
"history:bundle:verify": "tsc -p tsconfig.cli.json && node dist/tools/cli/verify-history-bundle-certification.js",
3737
"history:corpus:offline": "pwsh -NoLogo -NoProfile -File tools/Invoke-OfflineRealHistoryCorpus.ps1",
38+
"history:corpus:evaluate": "pwsh -NoLogo -NoProfile -File tools/Invoke-OfflineRealHistoryCorpusEvaluation.ps1",
3839
"history:corpus:normalize": "pwsh -NoLogo -NoProfile -File tools/Normalize-OfflineRealHistoryCorpus.ps1",
3940
"history:run": "pwsh -NoLogo -NoProfile -File scripts/Run-VIHistory.ps1",
4041
"hooks:multi": "node tools/hooks/core/run-multi.mjs",

tests/CompareVI.History.Tests.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,8 @@ exit 0
11081108
$summaryContent = Get-Content -LiteralPath $summaryPath -Raw
11091109
$summaryContent | Should -Match 'VI history report'
11101110
$summaryContent | Should -Match 'history-report.md'
1111+
$summaryContent | Should -Match '## Observed interpretation'
1112+
$summaryContent | Should -Match '\| Coverage Class \| `catalog-aligned` \|'
11111113
$summaryContent | Should -Match '## Mode overview'
11121114
$summaryContent | Should -Match '\| Mode \| Processed \| Diffs \| Signal \| Collapsed Noise \| Missing \| Categories \| Buckets \| Flags \|'
11131115
$summaryContent | Should -Match '\| default \| 1 \| 0 \| 0 \| 0 \|'
@@ -1140,15 +1142,20 @@ exit 0
11401142
$historyMd | Should -Match 'Executed Modes: `default`'
11411143
$historyMd | Should -Match '\| Metric \| Value \|'
11421144
$historyMd | Should -Match '\| Signal Diffs \|'
1145+
$historyMd | Should -Match '## Observed interpretation'
1146+
$historyMd | Should -Match '\| Coverage Class \| `catalog-aligned` \|'
11431147
$historyMd | Should -Match '## Mode overview'
11441148
$historyMd | Should -Match '\| Mode \| Processed \| Diffs \| Signal \| Collapsed Noise \| Missing \| Categories \| Buckets \| Flags \|'
11451149
$historyMd | Should -Match '## Attribute coverage'
11461150
$historyMd | Should -Match 'History manifest:'
11471151

11481152
$historyHtml = Get-Content -LiteralPath (Join-Path $rd 'history-report.html') -Raw
11491153
$historyHtml | Should -Match '<h1>VI History Report</h1>'
1154+
$historyHtml | Should -Match 'Observed interpretation'
11501155
$historyHtml | Should -Match 'Requested modes'
11511156
$historyHtml | Should -Match 'Executed modes'
1157+
$historyHtml | Should -Match 'Coverage Class'
1158+
$historyHtml | Should -Match 'catalog-aligned'
11521159
$historyHtml | Should -Match '<h2>Summary</h2>'
11531160
$historyHtml | Should -Match '<th>Signal</th>'
11541161
$historyHtml | Should -Match '<th>Collapsed Noise</th>'
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
Set-StrictMode -Version Latest
2+
$ErrorActionPreference = 'Stop'
3+
4+
Describe 'Invoke-OfflineRealHistoryCorpusEvaluation.ps1' -Tag 'Unit' {
5+
BeforeAll {
6+
$script:RepoRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
7+
$script:EvaluateScript = Join-Path $script:RepoRoot 'tools' 'Invoke-OfflineRealHistoryCorpusEvaluation.ps1'
8+
if (-not (Test-Path -LiteralPath $script:EvaluateScript -PathType Leaf)) {
9+
throw "Invoke-OfflineRealHistoryCorpusEvaluation.ps1 not found at $script:EvaluateScript"
10+
}
11+
12+
$script:CorpusPath = Join-Path $script:RepoRoot 'fixtures' 'real-history' 'offline-corpus.normalized.json'
13+
$script:ResolveEvaluationOutputPath = {
14+
param([Parameter(Mandatory)][string]$PathValue)
15+
16+
if ([System.IO.Path]::IsPathRooted($PathValue)) {
17+
return $PathValue
18+
}
19+
20+
return (Join-Path $script:RepoRoot ($PathValue -replace '/', '\'))
21+
}
22+
}
23+
24+
It 'passes against the checked-in corpus and records report coverage checks' {
25+
$resultsRoot = Join-Path $TestDrive 'offline-corpus-eval'
26+
$runOutput = & pwsh -NoLogo -NoProfile -File $script:EvaluateScript `
27+
-ResultsRoot $resultsRoot 2>&1
28+
$LASTEXITCODE | Should -Be 0 -Because (($runOutput | ForEach-Object { [string]$_ }) -join [Environment]::NewLine)
29+
30+
$reportPath = Join-Path $resultsRoot 'offline-real-history-corpus-evaluation.json'
31+
$reportPath | Should -Exist
32+
33+
$report = Get-Content -LiteralPath $reportPath -Raw | ConvertFrom-Json -Depth 12
34+
$report.schema | Should -Be 'vi-history/offline-real-history-corpus-evaluation@v1'
35+
$report.overallStatus | Should -Be 'ok'
36+
37+
$target = @($report.targets | Where-Object { [string]$_.id -eq 'icon-editor-settings-init' } | Select-Object -First 1)
38+
$target | Should -Not -BeNullOrEmpty
39+
$target.status | Should -Be 'ok'
40+
$target.expected.coverageClass | Should -Be 'catalog-partial'
41+
$target.expected.modeSensitivity | Should -Be 'single-mode-observed'
42+
@($target.expected.outcomeLabels) | Should -Be @('clean', 'signal-diff')
43+
44+
$target.observed.markdown.coverageClass | Should -BeTrue
45+
$target.observed.markdown.modeSensitivity | Should -BeTrue
46+
$target.observed.markdown.outcomeLabels | Should -BeTrue
47+
$target.observed.html.coverageClass | Should -BeTrue
48+
$target.observed.html.modeSensitivity | Should -BeTrue
49+
$target.observed.html.outcomeLabels | Should -BeTrue
50+
$target.observed.stepSummary.coverageClass | Should -BeTrue
51+
$target.observed.stepSummary.modeSensitivity | Should -BeTrue
52+
$target.observed.stepSummary.outcomeLabels | Should -BeTrue
53+
54+
$markdownPath = & $script:ResolveEvaluationOutputPath ([string]$target.outputs.markdownPath)
55+
$htmlPath = & $script:ResolveEvaluationOutputPath ([string]$target.outputs.htmlPath)
56+
$stepSummaryPath = & $script:ResolveEvaluationOutputPath ([string]$target.outputs.stepSummaryPath)
57+
$markdownPath | Should -Exist
58+
$htmlPath | Should -Exist
59+
$stepSummaryPath | Should -Exist
60+
61+
$markdown = Get-Content -LiteralPath $markdownPath -Raw
62+
$markdown | Should -Match '## Observed interpretation'
63+
$markdown | Should -Match '\| Coverage Class \| `catalog-partial` \|'
64+
$markdown | Should -Match '\| Mode Sensitivity \| `single-mode-observed` \|'
65+
$markdown | Should -Match '\| Outcome Labels \| `clean`, `signal-diff` \|'
66+
}
67+
68+
It 'detects drift when corpus expectations no longer match the rendered report' {
69+
$corpus = Get-Content -LiteralPath $script:CorpusPath -Raw | ConvertFrom-Json -Depth 20
70+
$corpusTarget = @($corpus.targets | Where-Object { [string]$_.id -eq 'icon-editor-settings-init' } | Select-Object -First 1)
71+
$corpusTarget | Should -Not -BeNullOrEmpty
72+
$corpusTarget.annotations.coverageClass = 'catalog-aligned'
73+
$driftCorpusPath = Join-Path $TestDrive 'offline-corpus.drift.json'
74+
$corpus | ConvertTo-Json -Depth 20 | Set-Content -LiteralPath $driftCorpusPath -Encoding utf8
75+
76+
$resultsRoot = Join-Path $TestDrive 'offline-corpus-drift'
77+
$runOutput = & pwsh -NoLogo -NoProfile -File $script:EvaluateScript `
78+
-CorpusPath $driftCorpusPath `
79+
-ResultsRoot $resultsRoot `
80+
-SkipSchemaValidation 2>&1
81+
$LASTEXITCODE | Should -Not -Be 0
82+
83+
$outputText = ($runOutput | ForEach-Object { [string]$_ }) -join [Environment]::NewLine
84+
$outputText | Should -Match 'detected report drift'
85+
86+
$reportPath = Join-Path $resultsRoot 'offline-real-history-corpus-evaluation.json'
87+
$reportPath | Should -Exist
88+
$report = Get-Content -LiteralPath $reportPath -Raw | ConvertFrom-Json -Depth 12
89+
$report.overallStatus | Should -Be 'drift'
90+
91+
$target = @($report.targets | Where-Object { [string]$_.id -eq 'icon-editor-settings-init' } | Select-Object -First 1)
92+
$target | Should -Not -BeNullOrEmpty
93+
$target.status | Should -Be 'drift'
94+
$target.observed.markdown.coverageClass | Should -BeFalse
95+
((@($target.notes)) -join [Environment]::NewLine) | Should -Match 'coverageClass'
96+
}
97+
}

tests/Render-VIHistoryReport.Tests.ps1

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Describe 'Render-VIHistoryReport.ps1' -Tag 'Unit' {
2929
startRef = 'HEAD'
3030
maxPairs = 2
3131
resultsDir = $resultsRoot
32-
requestedModes = @('default')
32+
requestedModes = @('default', 'attributes')
3333
executedModes = @('default')
3434
status = 'ok'
3535
modes = @(
@@ -95,6 +95,40 @@ Describe 'Render-VIHistoryReport.ps1' -Tag 'Unit' {
9595
[ordered]@{
9696
mode = 'default'
9797
index = 1
98+
base = @{
99+
full = 'aaa111111111'
100+
short = 'aaa1111'
101+
subject= 'Clean base commit'
102+
}
103+
head = @{
104+
full = 'bbb222222222'
105+
short = 'bbb2222'
106+
subject= 'Clean head commit'
107+
}
108+
lineage = [ordered]@{
109+
type = 'mainline'
110+
parentIndex = 1
111+
parentCount = 1
112+
mergeCommit = $null
113+
branchHead = $null
114+
depth = 0
115+
}
116+
lineageLabel = 'Mainline'
117+
result = [ordered]@{
118+
diff = $false
119+
duration_s = 0.45
120+
status = 'completed'
121+
reportPath = $reportPath
122+
categories = @()
123+
categoryDetails = @()
124+
categoryBuckets = @()
125+
categoryBucketDetails = @()
126+
}
127+
highlights = @()
128+
}
129+
[ordered]@{
130+
mode = 'default'
131+
index = 2
98132
base = @{
99133
full = 'abc123456789'
100134
short = 'abc1234'
@@ -160,19 +194,30 @@ Describe 'Render-VIHistoryReport.ps1' -Tag 'Unit' {
160194
Test-Path -LiteralPath $stepSummaryPath | Should -BeTrue
161195

162196
$markdown = Get-Content -LiteralPath $markdownPath -Raw
163-
$markdown | Should -Match 'Requested Modes: `default`'
197+
$markdown | Should -Match 'Requested Modes: `default, attributes`'
164198
$markdown | Should -Match 'Executed Modes: `default`'
165199
$markdown | Should -Match '\| Metric \| Value \|'
166200
$markdown | Should -Match '\| Signal Diffs \|'
167201
$markdown | Should -Match '\| Buckets \|'
168202
$markdown | Should -Match 'Functional behavior'
169203
$markdown | Should -Match 'Metadata'
204+
$markdown | Should -Match '## Observed interpretation'
205+
$markdown | Should -Match '\| Coverage Class \| `catalog-partial` \|'
206+
$markdown | Should -Match '\| Mode Sensitivity \| `single-mode-observed` \|'
207+
$markdown | Should -Match '\| Outcome Labels \| `clean`, `signal-diff` \|'
170208
$markdown | Should -Match '\| Mode \| Processed \| Diffs \| Signal \| Collapsed Noise \| Missing \| Categories \| Buckets \| Flags \|'
171209
$markdown | Should -Match '\| Mode \| Pair \| Lineage \| Base \| Head \| Diff \| Duration \(s\) \| Categories \| Buckets \| Report \| Highlights \|'
172210

173211
$html = Get-Content -LiteralPath $htmlPath -Raw
212+
$html | Should -Match 'Observed interpretation'
174213
$html | Should -Match 'Requested modes'
175214
$html | Should -Match 'Executed modes'
215+
$html | Should -Match 'Coverage Class'
216+
$html | Should -Match 'catalog-partial'
217+
$html | Should -Match 'Mode Sensitivity'
218+
$html | Should -Match 'single-mode-observed'
219+
$html | Should -Match 'Outcome Labels'
220+
$html | Should -Match '<code>clean</code>, <code>signal-diff</code>'
176221
$html | Should -Match '<th>Signal</th>'
177222
$html | Should -Match '<th>Collapsed Noise</th>'
178223
$html | Should -Match '<th>Lineage</th>'
@@ -182,6 +227,10 @@ Describe 'Render-VIHistoryReport.ps1' -Tag 'Unit' {
182227
$html | Should -Match 'Functional behavior \(1\)'
183228

184229
$stepSummary = Get-Content -LiteralPath $stepSummaryPath -Raw
230+
$stepSummary | Should -Match '## Observed interpretation'
231+
$stepSummary | Should -Match '\| Coverage Class \| `catalog-partial` \|'
232+
$stepSummary | Should -Match '\| Mode Sensitivity \| `single-mode-observed` \|'
233+
$stepSummary | Should -Match '\| Outcome Labels \| `clean`, `signal-diff` \|'
185234
$stepSummary | Should -Match '## Mode overview'
186235
$stepSummary | Should -Match '\| Mode \| Processed \| Diffs \| Signal \| Collapsed Noise \| Missing \| Categories \| Buckets \| Flags \|'
187236
$stepSummary | Should -Match 'Functional behavior \(1\)'

0 commit comments

Comments
 (0)