Skip to content

Commit 75b15cf

Browse files
authored
fix(release): deterministically classify platform-conditional skips in release reconciliation (preview.2) (#2305)
* fix(release): classify platform-conditional skips Make the MCP root migration tests self-describe their platform gates and teach release reconciliation the two exact skip identities. Keep truly unexplained skips release-blocking with focused coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 995eea17-c356-4912-90ea-5e5b144e7ba9 * fix(release): verify platform-specific skips Make release reconciliation platform-aware and fail closed when a platform-specific test skips where it must execute. Add hosted Windows evidence that requires the Windows-only drive-hash test to pass. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 995eea17-c356-4912-90ea-5e5b144e7ba9 * fix(ci): build packages before Windows release test The targeted Windows suite imports the workspace SDK package, so build both workspaces after npm ci before collecting the hosted Windows evidence. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 995eea17-c356-4912-90ea-5e5b144e7ba9 --------- Co-authored-by: B'Elanna (Squad) <tamirdresher@users.noreply.github.com> Copilot-Session: 995eea17-c356-4912-90ea-5e5b144e7ba9
1 parent 1f0910f commit 75b15cf

6 files changed

Lines changed: 278 additions & 13 deletions

File tree

‎.github/workflows/squad-release-verify.yml‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,55 @@ concurrency:
6464
cancel-in-progress: false
6565

6666
jobs:
67+
verify-windows-platform:
68+
name: Verify Windows-only release tests
69+
runs-on: windows-latest
70+
timeout-minutes: 20
71+
env:
72+
SOURCE_SHA: ${{ inputs.source_sha || github.event.pull_request.head.sha }}
73+
EVIDENCE_DIR: ${{ github.workspace }}\evidence-windows
74+
steps:
75+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7
76+
with:
77+
ref: ${{ inputs.source_sha || github.event.pull_request.head.sha }}
78+
fetch-depth: 0
79+
80+
- name: Assert checkout is exactly the requested SHA
81+
shell: pwsh
82+
run: |
83+
if ($env:SOURCE_SHA -notmatch '^[0-9a-f]{40}$') { throw "source_sha must be a full lowercase 40-hex SHA, got '$env:SOURCE_SHA'" }
84+
$head = git rev-parse HEAD
85+
if ($head -ne $env:SOURCE_SHA) { throw "checkout HEAD $head != requested $env:SOURCE_SHA" }
86+
New-Item -ItemType Directory -Force -Path $env:EVIDENCE_DIR | Out-Null
87+
88+
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 #v6
89+
with:
90+
node-version: 22
91+
92+
- name: Install dependencies
93+
run: npm ci
94+
95+
- name: Build workspace packages
96+
env:
97+
SKIP_BUILD_BUMP: '1'
98+
run: npm run build
99+
100+
- name: Run Windows platform suite with JSON report
101+
run: npx vitest run test/mcp-root-write.test.ts --reporter=default --reporter=json --outputFile="$env:EVIDENCE_DIR\vitest-report.json"
102+
103+
- name: Require the Windows-only test to execute
104+
if: always()
105+
run: node scripts/release/test-reconciliation.mjs --report "$env:EVIDENCE_DIR\vitest-report.json" --out "$env:EVIDENCE_DIR" --platform win32 --require-platform-executions --fail-on-unexplained
106+
107+
- name: Upload Windows platform evidence
108+
if: always()
109+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 #v7
110+
with:
111+
name: release-windows-platform-evidence-${{ env.SOURCE_SHA }}
112+
path: evidence-windows/
113+
retention-days: 90
114+
if-no-files-found: warn
115+
67116
verify:
68117
name: Verify exact SHA and build evidence
69118
runs-on: ubuntu-latest

‎scripts/release/build-manifest.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export function buildManifest(opts) {
158158
},
159159
packages: { '@bradygaster/squad-sdk': pkgEntry(sdk, '@bradygaster/squad-sdk'), '@bradygaster/squad-cli': pkgEntry(cli, '@bradygaster/squad-cli') },
160160
lockfiles: { files: lockReport.files.length, registryEntries: lockReport.entries, violations: lockReport.violations.length, deniedPatterns: lockReport.deniedPatterns, ok: lockReport.ok, externalNpmCi: npmCi },
161-
tests: recon ? { source: 'vitest JSON report of this run (scripts/release/test-reconciliation.mjs)', numTotalTests: recon.summary.numTotalTests, byStatus: recon.summary.byStatus, byCategory: recon.summary.byCategory, countsSum: recon.summary.countsSum, unlistedTests: recon.summary.unlistedTests, skippedFiles: recon.summary.skippedFiles, reconciliationFile: 'test-reconciliation.json' }
161+
tests: recon ? { source: 'vitest JSON report of this run (scripts/release/test-reconciliation.mjs)', platform: recon.summary.platform, numTotalTests: recon.summary.numTotalTests, byStatus: recon.summary.byStatus, byCategory: recon.summary.byCategory, countsSum: recon.summary.countsSum, unlistedTests: recon.summary.unlistedTests, skippedFiles: recon.summary.skippedFiles, reconciliationFile: 'test-reconciliation.json' }
162162
: { source: `console summary of cited CI run ${citedRun.id} (no vitest JSON report available to this generator)`, numTotalTests: citedRun.consoleSummary.testsTotal, byStatus: { passed: citedRun.consoleSummary.testsPassed, xfail: citedRun.consoleSummary.expectedFailures, skipped: citedRun.consoleSummary.testsSkipped, todo: citedRun.consoleSummary.todos }, byCategory: {}, countsSum: citedRun.consoleSummary.testsPassed + citedRun.consoleSummary.expectedFailures + citedRun.consoleSummary.testsSkipped + citedRun.consoleSummary.todos === citedRun.consoleSummary.testsTotal, unlistedTests: citedRun.consoleSummary.testsTotal - (citedRun.consoleSummary.testsPassed + citedRun.consoleSummary.expectedFailures + citedRun.consoleSummary.testsSkipped + citedRun.consoleSummary.todos), skippedFiles: [], reconciliationFile: null },
163163
closure,
164164
behavioralEvidence: {

‎scripts/release/manifest.schema.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
},
4949
"tests": {
5050
"type": "object", "additionalProperties": false, "required": ["source", "numTotalTests", "byStatus", "byCategory", "countsSum", "unlistedTests", "skippedFiles"],
51-
"properties": { "source": { "type": "string" }, "numTotalTests": { "type": "integer" }, "byStatus": { "type": "object" }, "byCategory": { "type": "object" }, "countsSum": { "type": "boolean" }, "unlistedTests": { "type": "integer" }, "skippedFiles": { "type": "array", "items": { "type": "string" } }, "reconciliationFile": { "type": ["string", "null"] } }
51+
"properties": { "source": { "type": "string" }, "platform": { "type": "string" }, "numTotalTests": { "type": "integer" }, "byStatus": { "type": "object" }, "byCategory": { "type": "object" }, "countsSum": { "type": "boolean" }, "unlistedTests": { "type": "integer" }, "skippedFiles": { "type": "array", "items": { "type": "string" } }, "reconciliationFile": { "type": ["string", "null"] } }
5252
},
5353
"closure": {
5454
"type": "object", "additionalProperties": false,

‎scripts/release/test-reconciliation.mjs‎

Lines changed: 76 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* unexplained anything else, including tests with no terminal state
2121
*
2222
* node scripts/release/test-reconciliation.mjs --report vitest.json --out evidence [--baseline prior.json]
23-
* [--fail-on-unexplained]
23+
* [--platform <process.platform>] [--require-platform-executions] [--fail-on-unexplained]
2424
*/
2525
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2626
import path from 'node:path';
@@ -37,6 +37,20 @@ export const CATEGORY_RULES = Object.freeze([
3737
{ category: 'env-gated', file: /squad-20-real-clients-stdio\.e2e\.test\.ts$/, reason: 'SQUAD_REAL_CLI_TESTS=1 not set / host CLI binaries absent' },
3838
{ category: 'env-gated', file: /squad-20-host-feature-matrix\.test\.ts$/, reason: 'live host evidence requires the real CLI binaries' },
3939
{ category: 'env-gated', file: /mcp-spec-init\.test\.ts$/, title: /squad\.exe/, reason: 'it.runIf(win32): Windows-only PATH/.exe resolution' },
40+
{
41+
category: 'env-gated',
42+
file: 'test/mcp-root-write.test.ts',
43+
title: '[platform: win32] removes the legacy raw uppercase Windows drive hash while preserving unrelated entries',
44+
runsOn: 'win32',
45+
reason: "it.runIf(process.platform === 'win32'): Windows-only legacy drive-hash reconciliation",
46+
},
47+
{
48+
category: 'env-gated',
49+
file: 'test/mcp-root-write.test.ts',
50+
title: '[platform: non-win32] removes the legacy raw POSIX symlink hash while preserving unrelated entries',
51+
runsOn: 'non-win32',
52+
reason: "it.runIf(process.platform !== 'win32'): POSIX-only legacy symlink-hash reconciliation",
53+
},
4054
{ category: 'env-gated', file: /profile-boundary\.test\.ts$/, reason: 'host lacks 8.3 short names or symlink/junction privilege' },
4155
{ category: 'env-gated', file: /state-backend\.test\.ts$/, reason: 'platform-gated state backend case' },
4256
{ category: 'env-gated', file: /docs-build\.test\.ts$/, reason: 'docs dependencies not installed' },
@@ -58,7 +72,26 @@ function relFile(name) {
5872
return i >= 0 ? norm.slice(i + 1) : norm;
5973
}
6074

61-
export function reconcile(report, { baseline } = {}) {
75+
function matches(value, expected) {
76+
return typeof expected === 'string' ? value === expected : expected.test(value);
77+
}
78+
79+
function runsOnPlatform(rule, platform) {
80+
return rule.runsOn === 'win32' ? platform === 'win32' : rule.runsOn === 'non-win32' ? platform !== 'win32' : true;
81+
}
82+
83+
export function resolvePlatform(claimedPlatform, actualPlatform = process.platform) {
84+
const platform = claimedPlatform ?? actualPlatform;
85+
if (!['aix', 'darwin', 'freebsd', 'linux', 'openbsd', 'sunos', 'win32'].includes(platform)) {
86+
throw new Error(`unsupported reconciliation platform '${platform}'`);
87+
}
88+
if (claimedPlatform && claimedPlatform !== actualPlatform) {
89+
throw new Error(`claimed reconciliation platform '${claimedPlatform}' does not match execution platform '${actualPlatform}'`);
90+
}
91+
return platform;
92+
}
93+
94+
export function reconcile(report, { baseline, platform = process.platform, requirePlatformExecutions = false } = {}) {
6295
const tests = [];
6396
const files = { total: report.testResults.length, byStatus: {} };
6497
for (const tr of report.testResults) {
@@ -84,10 +117,14 @@ export function reconcile(report, { baseline } = {}) {
84117
} else if (t.status === 'todo') { category = TODO_BLOCKERS.includes(t.title) ? 'todo-blocking' : 'todo'; reason = 'it.todo placeholder'; }
85118
else {
86119
for (const rule of CATEGORY_RULES) {
87-
if (!rule.file.test(t.file)) continue;
120+
if (!matches(t.file, rule.file)) continue;
88121
if (rule.status && rule.status !== t.status) continue;
89-
if (rule.title && !rule.title.test(t.fullName) && !rule.title.test(t.title)) continue;
122+
if (rule.title && !matches(t.title, rule.title) && !matches(t.fullName, rule.title)) continue;
90123
if (!rule.status && t.status === 'xfail') continue;
124+
if (rule.runsOn && runsOnPlatform(rule, platform)) {
125+
reason = `expected to execute on ${rule.runsOn}, but report status was '${t.status}'`;
126+
break;
127+
}
91128
category = rule.category; reason = rule.reason; break;
92129
}
93130
if (t.status === 'failed') { category = 'failed'; reason = t.failureMessages[0]?.split('\n')[0] ?? 'failed'; }
@@ -100,13 +137,26 @@ export function reconcile(report, { baseline } = {}) {
100137
const bucketSum = Object.values(byStatus).reduce((a, b) => a + b, 0);
101138
const listed = tests.length;
102139
const unexplainedTotal = report.numTotalTests - listed;
140+
const requiredExecutions = requirePlatformExecutions
141+
? CATEGORY_RULES.filter((rule) => rule.runsOn && runsOnPlatform(rule, platform)).map((rule) => {
142+
const test = tests.find((candidate) => matches(candidate.file, rule.file) && matches(candidate.title, rule.title));
143+
return {
144+
file: rule.file,
145+
title: rule.title,
146+
platform: rule.runsOn,
147+
status: test?.status ?? 'missing',
148+
ok: test?.status === 'passed',
149+
};
150+
})
151+
: [];
103152
const summary = {
104-
numTotalTests: report.numTotalTests, listed, bucketSum, byStatus, byCategory,
153+
platform, numTotalTests: report.numTotalTests, listed, bucketSum, byStatus, byCategory,
105154
countsSum: bucketSum === listed && listed === report.numTotalTests,
106155
unlistedTests: unexplainedTotal,
156+
requiredExecutions,
107157
files,
108158
skippedFiles: report.testResults.filter((tr) => tr.assertionResults.length > 0 && tr.assertionResults.every((a) => a.status === 'skipped' || a.status === 'todo')).map((tr) => relFile(tr.name)),
109-
ok: report.numFailedTests === 0 && (byCategory.unexplained ?? 0) === 0 && (byCategory['todo-blocking'] ?? 0) === 0 && unexplainedTotal === 0 && bucketSum === report.numTotalTests,
159+
ok: report.numFailedTests === 0 && (byCategory.unexplained ?? 0) === 0 && (byCategory['todo-blocking'] ?? 0) === 0 && unexplainedTotal === 0 && bucketSum === report.numTotalTests && requiredExecutions.every((entry) => entry.ok),
110160
};
111161
let diff = null;
112162
if (baseline) {
@@ -118,20 +168,37 @@ export function reconcile(report, { baseline } = {}) {
118168
return { generatedAt: new Date().toISOString(), summary, nonPassing: categorized.sort((a, b) => a.file.localeCompare(b.file) || a.fullName.localeCompare(b.fullName)), diffVsBaseline: diff };
119169
}
120170

171+
export function shouldFail(result, { failOnUnexplained = false } = {}) {
172+
const s = result.summary;
173+
return failOnUnexplained ? !s.ok : (s.numTotalTests > 0 && (s.byStatus.failed ?? 0) > 0);
174+
}
175+
121176
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
122177
const arg = (k) => { const i = process.argv.indexOf(k); return i >= 0 ? process.argv[i + 1] : undefined; };
123178
const reportPath = path.resolve(arg('--report') ?? 'vitest-report.json');
124179
if (!existsSync(reportPath)) { console.error(`::error::vitest JSON report not found: ${reportPath}`); process.exit(2); }
125180
const outDir = path.resolve(arg('--out') ?? 'evidence');
126181
mkdirSync(outDir, { recursive: true });
127182
const baseline = arg('--baseline') ? JSON.parse(readFileSync(path.resolve(arg('--baseline')), 'utf8')) : undefined;
128-
const result = reconcile(JSON.parse(readFileSync(reportPath, 'utf8')), { baseline });
183+
let platform;
184+
try {
185+
platform = resolvePlatform(arg('--platform'));
186+
} catch (error) {
187+
console.error(`::error::${error.message}`);
188+
process.exit(2);
189+
}
190+
const result = reconcile(JSON.parse(readFileSync(reportPath, 'utf8')), {
191+
baseline,
192+
platform,
193+
requirePlatformExecutions: process.argv.includes('--require-platform-executions'),
194+
});
129195
writeFileSync(path.join(outDir, 'test-reconciliation.json'), JSON.stringify(result, null, 2) + '\n');
130196
const s = result.summary;
131-
console.log(`tests=${s.numTotalTests} listed=${s.listed} byStatus=${JSON.stringify(s.byStatus)} byCategory=${JSON.stringify(s.byCategory)} unlisted=${s.unlistedTests} skippedFiles=${s.skippedFiles.join(',') || '-'}`);
197+
console.log(`platform=${s.platform} tests=${s.numTotalTests} listed=${s.listed} byStatus=${JSON.stringify(s.byStatus)} byCategory=${JSON.stringify(s.byCategory)} unlisted=${s.unlistedTests} skippedFiles=${s.skippedFiles.join(',') || '-'}`);
132198
for (const t of result.nonPassing.filter((t) => t.category === 'unexplained' || t.category === 'failed' || t.category === 'todo-blocking')) console.error(`::warning::${t.category}: ${t.file} :: ${t.fullName} [${t.status}]`);
199+
for (const required of s.requiredExecutions.filter((entry) => !entry.ok)) console.error(`::error::required platform test did not pass: ${required.file} :: ${required.title} [${required.status}]`);
133200
if (!s.countsSum || s.unlistedTests !== 0) console.error(`::error::${s.unlistedTests} test(s) are counted in numTotalTests but have no listed result (never reached a terminal state); see ${path.join(outDir, 'test-reconciliation.json')}`);
134-
const fail = process.argv.includes('--fail-on-unexplained') ? !s.ok : (s.numTotalTests > 0 && (s.byStatus.failed ?? 0) > 0);
201+
const fail = shouldFail(result, { failOnUnexplained: process.argv.includes('--fail-on-unexplained') });
135202
console.log(`${s.ok ? '✅' : '⚠️'} reconciliation written to ${outDir}`);
136203
process.exit(fail ? 1 : 0);
137204
}

‎test/mcp-root-write.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ describe('iter-8 mcp-root: repo-root .mcp.json writer + project tombstone', () =
327327
});
328328

329329
it.runIf(process.platform === 'win32')(
330-
'removes the legacy raw uppercase Windows drive hash while preserving unrelated entries',
330+
'[platform: win32] removes the legacy raw uppercase Windows drive hash while preserving unrelated entries',
331331
() => {
332332
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'squad-home-win-legacy-'));
333333
try {
@@ -363,7 +363,7 @@ describe('iter-8 mcp-root: repo-root .mcp.json writer + project tombstone', () =
363363
);
364364

365365
it.runIf(process.platform !== 'win32')(
366-
'removes the legacy raw POSIX symlink hash while preserving unrelated entries',
366+
'[platform: non-win32] removes the legacy raw POSIX symlink hash while preserving unrelated entries',
367367
() => {
368368
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'squad-home-posix-legacy-'));
369369
const links = fs.mkdtempSync(path.join(os.tmpdir(), 'squad-links-posix-legacy-'));

0 commit comments

Comments
 (0)