#!/usr/bin/env node // scripts/verify-phase-3.mjs // Source: Phase 3 SDOC-01..06 composite verify gate. // // Sequential orchestrator running every Phase 3 lint + tool verify subcommand + // schema-emit gate + ADR lint suite. First non-zero exit fails. // // Usage: node scripts/verify-phase-3.mjs // OR: pnpm verify:phase-3 // Exit: 0 success, 1 first-failed-step. import { spawnSync } from 'node:child_process'; const isWindows = process.platform === 'win32'; // Each entry: [label, cmd, [args]] — label printed at step start. // Step labels are stable contract — see 03-09-verify-gate-PLAN.md acceptance criteria. const steps = [ // Plan 01 — wiki/PITFALLS errata regression guard ['Plan 01: wiki errata', 'pnpm', ['lint:wiki-errata']], // Plan 02 — protocol-doc round-trip + lint ['Plan 02: protocol-doc verify', 'pnpm', ['protocol-doc:verify']], ['Plan 02: lint:protocol', 'pnpm', ['lint:protocol']], // Plan 03 — save-format-doc round-trip + lint ['Plan 03: save-format-doc verify', 'pnpm', ['save-format-doc:verify']], ['Plan 03: lint:save-formats', 'pnpm', ['lint:save-formats']], // Plan 10/11 — strict-mode TS compile of the generated TS contracts under the // project-standard broader flag set (matches tools/*/tsconfig.json strict triple: // strict + noUncheckedIndexedAccess + exactOptionalPropertyTypes; per BLOCKER-2 // Option A in 03-12-PLAN). Closes Phase 3 gap (03-VERIFICATION.md Truth #6): // catches duplicate-key and readonly-Array<> emitter regressions before Phase 4 // imports. ['Plan 10: tsc strict — protocol.ts', 'pnpm', ['-C', 'tools/protocol-doc', 'exec', 'tsc', '--noEmit', '--strict', '--noUncheckedIndexedAccess', '--exactOptionalPropertyTypes', 'output/protocol.ts']], ['Plan 11: tsc strict — save-formats.ts', 'pnpm', ['-C', 'tools/save-format-doc', 'exec', 'tsc', '--noEmit', '--strict', '--noUncheckedIndexedAccess', '--exactOptionalPropertyTypes', 'output/save-formats.ts']], // Plan 04 — subsystem MDs + asset-catalog server-tree drift ['Plan 04: catalog:verify:server', 'pnpm', ['catalog:verify:server']], ['Plan 04: lint:subsystem-mds', 'pnpm', ['lint:subsystem-mds']], // Plan 05 — parity-checklist (also logs disposition counts) ['Plan 05: lint:parity-checklist', 'pnpm', ['lint:parity-checklist']], // Plan 06 — Drizzle schema emit-check + traceability tests ['Plan 06: db:emit-check', 'pnpm', ['db:emit-check']], ['Plan 06: lint:schema-sync', 'pnpm', ['lint:schema-sync']], ['Plan 06: db:test', 'pnpm', ['db:test']], // Plan 07 + 08 — ADR lint chain (0001 Phase 2 regression + 0002 + 0003) ['Plan 07/08: lint:adrs', 'pnpm', ['lint:adrs']], ]; let failed = null; for (const [label, cmd, args] of steps) { process.stdout.write(`\n=== ${label} ===\n>>> ${cmd} ${args.join(' ')}\n`); const r = spawnSync(cmd, args, { encoding: 'utf-8', shell: isWindows, stdio: 'inherit' }); if (r.status !== 0) { failed = { label, cmd, args, status: r.status }; break; } } if (failed) { process.stderr.write( `\nverify-phase-3 FAILED at step '${failed.label}': ${failed.cmd} ${failed.args.join(' ')} (exit ${failed.status})\n` ); process.stderr.write( `Fix the failing step and re-run \`pnpm verify:phase-3\`.\n` ); process.exit(1); } process.stdout.write(`\nverify-phase-3: OK (${steps.length} steps green)\n`); process.exit(0);