@deftai/directive 0.62.0 → 0.64.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/{branch-parity.d.ts → branch-fixtures.d.ts} +1 -3
  2. package/dist/{branch-parity.js → branch-fixtures.js} +3 -110
  3. package/dist/dispatch.d.ts +1 -1
  4. package/dist/dispatch.js +3 -1
  5. package/dist/orchestration-cli/coverage-map.js +1 -1
  6. package/dist/{policy-parity.d.ts → policy-fixtures.d.ts} +1 -3
  7. package/dist/{policy-parity.js → policy-fixtures.js} +4 -100
  8. package/dist/{release-e2e-parity.d.ts → release-e2e-fixtures.d.ts} +1 -3
  9. package/dist/release-e2e-fixtures.js +38 -0
  10. package/dist/{story-ready-parity.d.ts → story-ready-fixtures.d.ts} +1 -3
  11. package/dist/{story-ready-parity.js → story-ready-fixtures.js} +4 -121
  12. package/dist/{triage-aux-a-parity.d.ts → triage-aux-a-fixtures.d.ts} +1 -3
  13. package/dist/{triage-aux-a-parity.js → triage-aux-a-fixtures.js} +3 -73
  14. package/dist/{triage-aux-b-parity.d.ts → triage-aux-b-fixtures.d.ts} +1 -3
  15. package/dist/triage-aux-b-fixtures.js +167 -0
  16. package/dist/{triage-bootstrap-parity.d.ts → triage-bootstrap-fixtures.d.ts} +1 -3
  17. package/dist/{triage-bootstrap-parity.js → triage-bootstrap-fixtures.js} +4 -91
  18. package/dist/{triage-classify-parity.d.ts → triage-classify-fixtures.d.ts} +1 -3
  19. package/dist/{triage-classify-parity.js → triage-classify-fixtures.js} +4 -94
  20. package/dist/{triage-queue-parity.d.ts → triage-queue-fixtures.d.ts} +1 -3
  21. package/dist/{triage-queue-parity.js → triage-queue-fixtures.js} +4 -86
  22. package/dist/{triage-scope-parity.d.ts → triage-scope-fixtures.d.ts} +1 -3
  23. package/dist/{triage-scope-parity.js → triage-scope-fixtures.js} +4 -91
  24. package/dist/{vbrief-preflight-parity.d.ts → vbrief-preflight-fixtures.d.ts} +1 -3
  25. package/dist/vbrief-preflight-fixtures.js +79 -0
  26. package/dist/verify-source-cli/verify-cursor-tier1.d.ts +12 -0
  27. package/dist/verify-source-cli/verify-cursor-tier1.js +51 -0
  28. package/dist/{wip-cap-parity.d.ts → wip-cap-fixtures.d.ts} +1 -3
  29. package/dist/{wip-cap-parity.js → wip-cap-fixtures.js} +4 -91
  30. package/package.json +4 -15
  31. package/dist/cache-parity.d.ts +0 -36
  32. package/dist/cache-parity.js +0 -165
  33. package/dist/codebase-parity.d.ts +0 -31
  34. package/dist/codebase-parity.js +0 -303
  35. package/dist/doc-cli-parity.d.ts +0 -29
  36. package/dist/doc-cli-parity.js +0 -159
  37. package/dist/doctor-parity.d.ts +0 -42
  38. package/dist/doctor-parity.js +0 -157
  39. package/dist/intake-parity.d.ts +0 -30
  40. package/dist/intake-parity.js +0 -203
  41. package/dist/lifecycle-packs-parity.d.ts +0 -30
  42. package/dist/lifecycle-packs-parity.js +0 -377
  43. package/dist/orchestration-parity.d.ts +0 -38
  44. package/dist/orchestration-parity.js +0 -364
  45. package/dist/parity.d.ts +0 -36
  46. package/dist/parity.js +0 -176
  47. package/dist/platform-parity.d.ts +0 -26
  48. package/dist/platform-parity.js +0 -309
  49. package/dist/pr-closing-keywords-parity.d.ts +0 -45
  50. package/dist/pr-closing-keywords-parity.js +0 -259
  51. package/dist/pr-merge-readiness-parity.d.ts +0 -44
  52. package/dist/pr-merge-readiness-parity.js +0 -296
  53. package/dist/pr-monitor-parity.d.ts +0 -44
  54. package/dist/pr-monitor-parity.js +0 -283
  55. package/dist/pr-protected-issues-parity.d.ts +0 -41
  56. package/dist/pr-protected-issues-parity.js +0 -220
  57. package/dist/pr-wait-mergeable-parity.d.ts +0 -45
  58. package/dist/pr-wait-mergeable-parity.js +0 -340
  59. package/dist/release-e2e-parity.js +0 -114
  60. package/dist/release-parity.d.ts +0 -40
  61. package/dist/release-parity.js +0 -226
  62. package/dist/release-publish-parity.d.ts +0 -36
  63. package/dist/release-publish-parity.js +0 -138
  64. package/dist/release-rollback-parity.d.ts +0 -37
  65. package/dist/release-rollback-parity.js +0 -161
  66. package/dist/render-parity.d.ts +0 -36
  67. package/dist/render-parity.js +0 -385
  68. package/dist/scm-parity.d.ts +0 -39
  69. package/dist/scm-parity.js +0 -181
  70. package/dist/scope-lifecycle-parity.d.ts +0 -35
  71. package/dist/scope-lifecycle-parity.js +0 -177
  72. package/dist/session-parity.d.ts +0 -39
  73. package/dist/session-parity.js +0 -262
  74. package/dist/slice-parity.d.ts +0 -36
  75. package/dist/slice-parity.js +0 -304
  76. package/dist/swarm-parity.d.ts +0 -28
  77. package/dist/swarm-parity.js +0 -327
  78. package/dist/triage-actions-parity.d.ts +0 -36
  79. package/dist/triage-actions-parity.js +0 -357
  80. package/dist/triage-aux-b-parity.js +0 -308
  81. package/dist/triage-summary-parity.d.ts +0 -50
  82. package/dist/triage-summary-parity.js +0 -306
  83. package/dist/validate-content-parity.d.ts +0 -33
  84. package/dist/validate-content-parity.js +0 -356
  85. package/dist/vbrief-activate-parity.d.ts +0 -39
  86. package/dist/vbrief-activate-parity.js +0 -216
  87. package/dist/vbrief-build-parity.d.ts +0 -28
  88. package/dist/vbrief-build-parity.js +0 -399
  89. package/dist/vbrief-preflight-parity.js +0 -163
  90. package/dist/vbrief-reconcile-parity.d.ts +0 -23
  91. package/dist/vbrief-reconcile-parity.js +0 -609
  92. package/dist/vbrief-validate-parity.d.ts +0 -27
  93. package/dist/vbrief-validate-parity.js +0 -122
  94. package/dist/vbrief-validation-parity.d.ts +0 -28
  95. package/dist/vbrief-validation-parity.js +0 -645
  96. package/dist/verify-env-parity.d.ts +0 -28
  97. package/dist/verify-env-parity.js +0 -272
  98. package/dist/verify-source-parity.d.ts +0 -26
  99. package/dist/verify-source-parity.js +0 -178
@@ -1,161 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Golden-output parity harness (#1729): runs BOTH the Python oracle
4
- * (`scripts/release_rollback.py`) and the ported TS release:rollback CLI
5
- * with identical argv, then diffs exit codes and normalised stderr/stdout.
6
- *
7
- * Exit codes: 0 parity / 1 divergence / 2 harness setup error.
8
- */
9
- import { spawnSync } from "node:child_process";
10
- import { dirname, join, resolve } from "node:path";
11
- import { fileURLToPath } from "node:url";
12
- export const PARITY_SCENARIOS = [
13
- { name: "invalid-version", argv: ["not-a-version"] },
14
- {
15
- name: "negative-allow-low-downloads",
16
- argv: ["0.21.0", "--allow-low-downloads", "-1"],
17
- },
18
- {
19
- name: "dry-run-absent",
20
- argv: ["0.99.0", "--dry-run", "--repo", "deftai/directive"],
21
- },
22
- {
23
- name: "allow-low-downloads-missing-value",
24
- argv: ["0.21.0", "--allow-low-downloads", "--dry-run"],
25
- },
26
- { name: "help", argv: ["--help"], compareStdout: true },
27
- ];
28
- function runCapture(cmd, args, cwd, env = {}) {
29
- const merged = {
30
- ...process.env,
31
- ...env,
32
- DEFT_CACHE_DISABLE: "1",
33
- PYTHONUTF8: "1",
34
- };
35
- for (const key of Object.keys(merged)) {
36
- if (merged[key] === undefined)
37
- delete merged[key];
38
- }
39
- try {
40
- const result = spawnSync(cmd, args, {
41
- cwd,
42
- encoding: "utf8",
43
- env: merged,
44
- stdio: ["ignore", "pipe", "pipe"],
45
- });
46
- return {
47
- status: result.status ?? 2,
48
- stdout: typeof result.stdout === "string" ? result.stdout : "",
49
- stderr: typeof result.stderr === "string" ? result.stderr : "",
50
- };
51
- }
52
- catch (err) {
53
- const e = err;
54
- return {
55
- status: typeof e.status === "number" ? e.status : 2,
56
- stdout: typeof e.stdout === "string" ? e.stdout : "",
57
- stderr: typeof e.stderr === "string" ? e.stderr : "",
58
- };
59
- }
60
- }
61
- function resolveDeftRoot() {
62
- if (process.env.DEFT_ROOT !== undefined && process.env.DEFT_ROOT.length > 0) {
63
- return resolve(process.env.DEFT_ROOT);
64
- }
65
- return resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "..");
66
- }
67
- export function normaliseStderr(text) {
68
- return text.replace(/\d{4}-\d{2}-\d{2}/g, "YYYY-MM-DD");
69
- }
70
- export function pickOutput(result, stream) {
71
- return stream === "stdout" ? result.stdout : result.stderr;
72
- }
73
- function runScenario(deftRoot, scenario) {
74
- const argv = [...scenario.argv];
75
- const pyArgs = ["run", "python", join(deftRoot, "scripts", "release_rollback.py"), ...argv];
76
- const tsArgs = [join(deftRoot, "packages", "cli", "dist", "release-rollback.js"), ...argv];
77
- const py = runCapture("uv", pyArgs, deftRoot);
78
- const ts = runCapture("node", tsArgs, deftRoot);
79
- return {
80
- python: {
81
- name: scenario.name,
82
- exitCode: py.status,
83
- stdout: py.stdout,
84
- stderr: py.stderr,
85
- },
86
- ts: {
87
- name: scenario.name,
88
- exitCode: ts.status,
89
- stdout: ts.stdout,
90
- stderr: ts.stderr,
91
- },
92
- };
93
- }
94
- export function diffParity(python, ts, stream) {
95
- let pythonOutput = pickOutput(python, stream);
96
- let tsOutput = pickOutput(ts, stream);
97
- if (stream === "stderr") {
98
- pythonOutput = normaliseStderr(pythonOutput);
99
- tsOutput = normaliseStderr(tsOutput);
100
- }
101
- return {
102
- exitMismatch: python.exitCode !== ts.exitCode,
103
- outputMismatch: pythonOutput !== tsOutput,
104
- pythonOutput,
105
- tsOutput,
106
- };
107
- }
108
- export function runParity() {
109
- const deftRoot = resolveDeftRoot();
110
- const scenarios = [];
111
- for (const scenario of PARITY_SCENARIOS) {
112
- const ran = runScenario(deftRoot, scenario);
113
- const stream = scenario.compareStdout ? "stdout" : "stderr";
114
- scenarios.push({
115
- name: scenario.name,
116
- pythonExit: ran.python.exitCode,
117
- tsExit: ran.ts.exitCode,
118
- stream,
119
- ...diffParity(ran.python, ran.ts, stream),
120
- });
121
- }
122
- const ok = scenarios.every((s) => !s.exitMismatch && !s.outputMismatch);
123
- return { ok, scenarios };
124
- }
125
- export function renderReport(result) {
126
- if (result.ok) {
127
- return `release-rollback parity: CLEAN -- Python and TS agree on ${result.scenarios.length} scenario(s).`;
128
- }
129
- const lines = ["release-rollback parity: DIVERGENCE"];
130
- for (const s of result.scenarios) {
131
- if (s.exitMismatch || s.outputMismatch) {
132
- lines.push(` scenario: ${s.name}`);
133
- if (s.exitMismatch) {
134
- lines.push(` exit mismatch: python=${s.pythonExit} ts=${s.tsExit}`);
135
- }
136
- if (s.outputMismatch) {
137
- lines.push(` stream: ${s.stream}`);
138
- lines.push(` python (${s.pythonOutput.length} bytes)`);
139
- lines.push(` ts (${s.tsOutput.length} bytes)`);
140
- }
141
- }
142
- }
143
- return lines.join("\n");
144
- }
145
- if (process.argv[1] !== undefined && fileURLToPath(import.meta.url) === process.argv[1]) {
146
- try {
147
- const result = runParity();
148
- if (result.ok) {
149
- process.stdout.write(`${renderReport(result)}\n`);
150
- process.exit(0);
151
- }
152
- process.stderr.write(`${renderReport(result)}\n`);
153
- process.exit(1);
154
- }
155
- catch (err) {
156
- const msg = String(err).replace(/\r?\n/g, " ");
157
- process.stderr.write(`release-rollback parity: harness error -- ${msg}\n`);
158
- process.exit(2);
159
- }
160
- }
161
- //# sourceMappingURL=release-rollback-parity.js.map
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env node
2
- export interface CommandCapture {
3
- readonly exitCode: number;
4
- readonly stdout: string;
5
- readonly stderr: string;
6
- readonly bytes?: Buffer;
7
- }
8
- export interface ParityCase {
9
- readonly gate: "spec-validate" | "spec-render" | "prd-render" | "project-render" | "roadmap-render" | "framework-commands";
10
- readonly name: string;
11
- readonly setup: (root: string) => {
12
- specPath?: string;
13
- outPath?: string;
14
- extra?: Record<string, string>;
15
- };
16
- }
17
- export interface ParityDiff {
18
- readonly gate: string;
19
- readonly caseName: string;
20
- readonly exitMismatch: boolean;
21
- readonly stdoutMismatch: boolean;
22
- readonly stderrMismatch: boolean;
23
- readonly bytesMismatch: boolean;
24
- readonly pythonExit: number;
25
- readonly tsExit: number;
26
- }
27
- export interface ParityResult {
28
- readonly ok: boolean;
29
- readonly diffs: ParityDiff[];
30
- }
31
- export declare const PARITY_CASES: readonly ParityCase[];
32
- export declare function normalizeMessage(text: string): string;
33
- export declare function diffCase(python: CommandCapture, ts: CommandCapture, gate: string, caseName: string): ParityDiff;
34
- export declare function runParity(): ParityResult;
35
- export declare function renderReport(result: ParityResult): string;
36
- //# sourceMappingURL=render-parity.d.ts.map
@@ -1,385 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Golden-output parity harness (#1785): runs BOTH the Python oracles
4
- * (frozen render/spec modules) and the ported TS render family over shared
5
- * fixtures, then diffs exit codes + rendered bytes / stdout/stderr (cache-off).
6
- *
7
- * Exit codes: 0 parity / 1 divergence / 2 harness setup error.
8
- */
9
- import { execFileSync } from "node:child_process";
10
- import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
11
- import { tmpdir } from "node:os";
12
- import { dirname, join, resolve } from "node:path";
13
- import { fileURLToPath } from "node:url";
14
- import { renderPrd, renderProjectDefinition, renderRoadmap, renderSpec, runFrameworkCommand, validateSpec, } from "@deftai/directive-core/render";
15
- const MINIMAL_SPEC = {
16
- vBRIEFInfo: { version: "0.6" },
17
- plan: {
18
- title: "Parity Spec",
19
- status: "approved",
20
- narratives: {
21
- Overview: "Parity overview.",
22
- Goals: "Ship byte-identical renders.",
23
- },
24
- items: [
25
- {
26
- id: "T1",
27
- title: "First task",
28
- status: "pending",
29
- narrative: { Description: "Do the thing.", Acceptance: "- Done when green" },
30
- },
31
- ],
32
- },
33
- };
34
- const FIXED_NOW = "2026-06-04T12:00:00Z";
35
- function resolveDeftRoot() {
36
- if (process.env.DEFT_ROOT !== undefined && process.env.DEFT_ROOT.length > 0) {
37
- return resolve(process.env.DEFT_ROOT);
38
- }
39
- return resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "..");
40
- }
41
- function runPython(code, deftRoot) {
42
- try {
43
- const stdout = execFileSync("uv", ["run", "python", "-c", code], {
44
- cwd: deftRoot,
45
- encoding: "utf8",
46
- env: { ...process.env, DEFT_CACHE_DISABLE: "1", PYTHONUTF8: "1" },
47
- });
48
- return { exitCode: 0, stdout: typeof stdout === "string" ? stdout : "", stderr: "" };
49
- }
50
- catch (err) {
51
- const e = err;
52
- return {
53
- exitCode: e.status ?? 2,
54
- stdout: typeof e.stdout === "string" ? e.stdout : "",
55
- stderr: typeof e.stderr === "string" ? e.stderr : "",
56
- };
57
- }
58
- }
59
- function scriptsPrefix(deftRoot) {
60
- const scriptsDir = join(deftRoot, "scripts").replace(/\\/g, "/");
61
- return `import sys; sys.path.insert(0, ${JSON.stringify(scriptsDir)})`;
62
- }
63
- export const PARITY_CASES = [
64
- {
65
- gate: "spec-validate",
66
- name: "valid-spec",
67
- setup: (root) => {
68
- const specPath = join(root, "spec.json");
69
- writeFileSync(specPath, JSON.stringify(MINIMAL_SPEC), "utf8");
70
- return { specPath };
71
- },
72
- },
73
- {
74
- gate: "spec-validate",
75
- name: "missing-spec",
76
- setup: (root) => ({ specPath: join(root, "missing.json") }),
77
- },
78
- {
79
- gate: "spec-render",
80
- name: "approved-spec",
81
- setup: (root) => {
82
- mkdirSync(join(root, "vbrief"), { recursive: true });
83
- const specPath = join(root, "vbrief", "specification.vbrief.json");
84
- const outPath = join(root, "SPECIFICATION.md");
85
- writeFileSync(specPath, JSON.stringify(MINIMAL_SPEC), "utf8");
86
- return { specPath, outPath };
87
- },
88
- },
89
- {
90
- gate: "prd-render",
91
- name: "basic-prd",
92
- setup: (root) => {
93
- const specPath = join(root, "spec.json");
94
- const outPath = join(root, "PRD.md");
95
- writeFileSync(specPath, JSON.stringify(MINIMAL_SPEC), "utf8");
96
- return { specPath, outPath };
97
- },
98
- },
99
- {
100
- gate: "project-render",
101
- name: "skeleton-projdef",
102
- setup: (root) => {
103
- const vbrief = join(root, "vbrief");
104
- for (const f of ["proposed", "pending", "active", "completed", "cancelled"]) {
105
- mkdirSync(join(vbrief, f), { recursive: true });
106
- }
107
- return { extra: { vbriefDir: vbrief } };
108
- },
109
- },
110
- {
111
- gate: "roadmap-render",
112
- name: "phase-grouped",
113
- setup: (root) => {
114
- const pending = join(root, "vbrief", "pending");
115
- mkdirSync(pending, { recursive: true });
116
- writeFileSync(join(pending, "2026-01-01-a.vbrief.json"), JSON.stringify({
117
- vBRIEFInfo: { version: "0.6" },
118
- plan: {
119
- title: "Story A",
120
- status: "pending",
121
- metadata: { "x-migrator": { Phase: "Phase 2", PhaseDescription: "Wave 6" } },
122
- references: [{ uri: "https://github.com/deftai/directive/issues/1785" }],
123
- },
124
- }), "utf8");
125
- const outPath = join(root, "ROADMAP.md");
126
- return { outPath, extra: { pendingDir: pending } };
127
- },
128
- },
129
- {
130
- gate: "framework-commands",
131
- name: "unknown-command",
132
- setup: () => ({}),
133
- },
134
- ];
135
- function runPythonGate(deftRoot, testCase, paths, repoRoot) {
136
- const scripts = scriptsPrefix(deftRoot);
137
- if (testCase.gate === "spec-validate") {
138
- const code = [
139
- scripts,
140
- "from spec_validate import validate_spec",
141
- `ok, msg = validate_spec(${JSON.stringify(paths.specPath ?? "")})`,
142
- "import sys",
143
- "stream = sys.stdout if ok else sys.stderr",
144
- "stream.write(msg + '\\n')",
145
- "sys.exit(0 if ok else 1)",
146
- ].join("\n");
147
- return runPython(code, deftRoot);
148
- }
149
- if (testCase.gate === "spec-render") {
150
- const code = [
151
- scripts,
152
- "from spec_render import render_spec",
153
- `ok, msg = render_spec(${JSON.stringify(paths.specPath ?? "")}, ${JSON.stringify(paths.outPath ?? "")}, include_scopes=False)`,
154
- "import sys",
155
- "print(msg)",
156
- "sys.exit(0 if ok else 1)",
157
- ].join("\n");
158
- const cap = runPython(code, deftRoot);
159
- if (cap.exitCode === 0 && paths.outPath && existsSync(paths.outPath)) {
160
- return { ...cap, bytes: readFileSync(paths.outPath) };
161
- }
162
- return cap;
163
- }
164
- if (testCase.gate === "prd-render") {
165
- const code = [
166
- scripts,
167
- "from pathlib import Path",
168
- "from prd_render import render_prd",
169
- `render_prd(Path(${JSON.stringify(paths.specPath ?? "")}), Path(${JSON.stringify(paths.outPath ?? "")}))`,
170
- ].join("\n");
171
- const cap = runPython(code, deftRoot);
172
- if (paths.outPath && existsSync(paths.outPath)) {
173
- return { ...cap, bytes: readFileSync(paths.outPath) };
174
- }
175
- return cap;
176
- }
177
- if (testCase.gate === "project-render") {
178
- const vbriefDir = paths.extra?.vbriefDir ?? join(repoRoot, "vbrief");
179
- const code = [
180
- scripts,
181
- "from project_render import render_project_definition",
182
- `ok, msg = render_project_definition(${JSON.stringify(vbriefDir)})`,
183
- "import sys",
184
- "print(msg)",
185
- "sys.exit(0 if ok else 1)",
186
- ].join("\n");
187
- const cap = runPython(code, deftRoot);
188
- const full = join(vbriefDir, "PROJECT-DEFINITION.vbrief.json");
189
- if (existsSync(full))
190
- return { ...cap, bytes: readFileSync(full) };
191
- return cap;
192
- }
193
- if (testCase.gate === "roadmap-render") {
194
- const pendingDir = paths.extra?.pendingDir ?? join(repoRoot, "vbrief", "pending");
195
- const outPath = paths.outPath ?? join(repoRoot, "ROADMAP.md");
196
- const code = [
197
- scripts,
198
- "from roadmap_render import render_roadmap",
199
- `ok, msg = render_roadmap(${JSON.stringify(pendingDir)}, ${JSON.stringify(outPath)})`,
200
- "import sys",
201
- "print(msg)",
202
- "sys.exit(0 if ok else 1)",
203
- ].join("\n");
204
- const cap = runPython(code, deftRoot);
205
- if (existsSync(outPath))
206
- return { ...cap, bytes: readFileSync(outPath) };
207
- return cap;
208
- }
209
- const code = [
210
- scripts,
211
- "from framework_commands import run_framework_command",
212
- "result = run_framework_command('__missing__', capture=True)",
213
- "import sys",
214
- "if result.stdout: sys.stdout.write(result.stdout)",
215
- "if result.stderr: sys.stderr.write(result.stderr)",
216
- "sys.exit(result.code)",
217
- ].join("\n");
218
- return runPython(code, deftRoot);
219
- }
220
- function runTsGate(testCase, paths, repoRoot) {
221
- if (testCase.gate === "spec-validate") {
222
- const [ok, msg] = validateSpec(paths.specPath ?? "");
223
- return {
224
- exitCode: ok ? 0 : 1,
225
- stdout: ok ? `${msg}\n` : "",
226
- stderr: ok ? "" : `${msg}\n`,
227
- };
228
- }
229
- if (testCase.gate === "spec-render") {
230
- const [ok, msg] = renderSpec(paths.specPath ?? "", paths.outPath ?? "", {
231
- includeScopes: false,
232
- });
233
- const cap = {
234
- exitCode: ok ? 0 : 1,
235
- stdout: `${msg}\n`,
236
- stderr: "",
237
- };
238
- if (ok && paths.outPath && existsSync(paths.outPath)) {
239
- return { ...cap, bytes: readFileSync(paths.outPath) };
240
- }
241
- return cap;
242
- }
243
- if (testCase.gate === "prd-render") {
244
- const chunks = { out: "", err: "" };
245
- const prevOut = process.stdout.write.bind(process.stdout);
246
- const prevErr = process.stderr.write.bind(process.stderr);
247
- process.stdout.write = (c) => {
248
- chunks.out += String(c);
249
- return true;
250
- };
251
- process.stderr.write = (c) => {
252
- chunks.err += String(c);
253
- return true;
254
- };
255
- let exitCode = 0;
256
- try {
257
- renderPrd(paths.specPath ?? "", paths.outPath ?? "");
258
- }
259
- catch {
260
- exitCode = 1;
261
- }
262
- finally {
263
- process.stdout.write = prevOut;
264
- process.stderr.write = prevErr;
265
- }
266
- const cap = { exitCode, stdout: chunks.out, stderr: chunks.err };
267
- if (paths.outPath && existsSync(paths.outPath)) {
268
- return { ...cap, bytes: readFileSync(paths.outPath) };
269
- }
270
- return cap;
271
- }
272
- if (testCase.gate === "project-render") {
273
- const vbriefDir = paths.extra?.vbriefDir ?? join(repoRoot, "vbrief");
274
- const [ok, msg] = renderProjectDefinition(vbriefDir, { now: new Date(FIXED_NOW) });
275
- const full = join(vbriefDir, "PROJECT-DEFINITION.vbrief.json");
276
- const cap = { exitCode: ok ? 0 : 1, stdout: `${msg}\n`, stderr: "" };
277
- if (ok && existsSync(full))
278
- return { ...cap, bytes: readFileSync(full) };
279
- return cap;
280
- }
281
- if (testCase.gate === "roadmap-render") {
282
- const pendingDir = paths.extra?.pendingDir ?? join(repoRoot, "vbrief", "pending");
283
- const outPath = paths.outPath ?? join(repoRoot, "ROADMAP.md");
284
- const [ok, msg] = renderRoadmap(pendingDir, outPath);
285
- const cap = { exitCode: ok ? 0 : 1, stdout: `${msg}\n`, stderr: "" };
286
- if (ok && existsSync(outPath))
287
- return { ...cap, bytes: readFileSync(outPath) };
288
- return cap;
289
- }
290
- const result = runFrameworkCommand("__missing__", [], { capture: true, projectRoot: repoRoot });
291
- return { exitCode: result.code, stdout: result.stdout, stderr: result.stderr };
292
- }
293
- function normalizeProjectBytes(bytes) {
294
- let text = bytes.toString("utf8");
295
- text = text.replace(/"updated": "[^"]+"/g, '"updated": "<TS>"');
296
- text = text.replace(/"created": "[^"]+"/g, '"created": "<TS>"');
297
- return Buffer.from(text, "utf8");
298
- }
299
- export function normalizeMessage(text) {
300
- return text
301
- .replace(/(?:\/private)?\/var\/folders\/[^\s"')]+\/deft-render-parity-(py|ts)-[^/\s"')]+/g, "<TMP>")
302
- .replace(/\/tmp\/deft-render-parity-(py|ts)-[^/\s"')]+/g, "<TMP>");
303
- }
304
- export function diffCase(python, ts, gate, caseName) {
305
- let bytesMismatch = false;
306
- if (python.bytes !== undefined && ts.bytes !== undefined) {
307
- const pyBytes = gate === "project-render" ? normalizeProjectBytes(python.bytes) : python.bytes;
308
- const tsBytes = gate === "project-render" ? normalizeProjectBytes(ts.bytes) : ts.bytes;
309
- bytesMismatch = !pyBytes.equals(tsBytes);
310
- }
311
- else if (python.bytes !== undefined || ts.bytes !== undefined) {
312
- bytesMismatch = true;
313
- }
314
- const pyStdout = normalizeMessage(python.stdout);
315
- const tsStdout = normalizeMessage(ts.stdout);
316
- const pyStderr = normalizeMessage(python.stderr);
317
- const tsStderr = normalizeMessage(ts.stderr);
318
- return {
319
- gate,
320
- caseName,
321
- exitMismatch: python.exitCode !== ts.exitCode,
322
- stdoutMismatch: pyStdout !== tsStdout,
323
- stderrMismatch: pyStderr !== tsStderr,
324
- bytesMismatch,
325
- pythonExit: python.exitCode,
326
- tsExit: ts.exitCode,
327
- };
328
- }
329
- export function runParity() {
330
- const deftRoot = resolveDeftRoot();
331
- const diffs = [];
332
- for (const testCase of PARITY_CASES) {
333
- const pyRepo = mkdtempSync(join(tmpdir(), "deft-render-parity-py-"));
334
- const tsRepo = mkdtempSync(join(tmpdir(), "deft-render-parity-ts-"));
335
- try {
336
- const pyPaths = testCase.setup(pyRepo);
337
- const tsPaths = testCase.setup(tsRepo);
338
- const python = runPythonGate(deftRoot, testCase, pyPaths, pyRepo);
339
- const ts = runTsGate(testCase, tsPaths, tsRepo);
340
- diffs.push(diffCase(python, ts, testCase.gate, testCase.name));
341
- }
342
- finally {
343
- rmSync(pyRepo, { recursive: true, force: true });
344
- rmSync(tsRepo, { recursive: true, force: true });
345
- }
346
- }
347
- const ok = diffs.every((d) => !d.exitMismatch && !d.stdoutMismatch && !d.stderrMismatch && !d.bytesMismatch);
348
- return { ok, diffs };
349
- }
350
- export function renderReport(result) {
351
- if (result.ok) {
352
- return `render parity: CLEAN -- Python and TS agree on ${PARITY_CASES.length} cases.`;
353
- }
354
- const lines = ["render parity: DIVERGENCE"];
355
- for (const d of result.diffs) {
356
- if (d.exitMismatch || d.stdoutMismatch || d.stderrMismatch || d.bytesMismatch) {
357
- lines.push(` gate: ${d.gate} case: ${d.caseName}`);
358
- if (d.exitMismatch)
359
- lines.push(` exit: python=${d.pythonExit} ts=${d.tsExit}`);
360
- if (d.stdoutMismatch)
361
- lines.push(" stdout mismatch");
362
- if (d.stderrMismatch)
363
- lines.push(" stderr mismatch");
364
- if (d.bytesMismatch)
365
- lines.push(" rendered bytes mismatch");
366
- }
367
- }
368
- return lines.join("\n");
369
- }
370
- if (process.argv[1] !== undefined && fileURLToPath(import.meta.url) === process.argv[1]) {
371
- try {
372
- const result = runParity();
373
- if (result.ok) {
374
- process.stdout.write(`${renderReport(result)}\n`);
375
- process.exit(0);
376
- }
377
- process.stderr.write(`${renderReport(result)}\n`);
378
- process.exit(1);
379
- }
380
- catch (err) {
381
- process.stderr.write(`render parity: harness error -- ${String(err)}\n`);
382
- process.exit(2);
383
- }
384
- }
385
- //# sourceMappingURL=render-parity.js.map
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env node
2
- export interface ScenarioResult {
3
- readonly name: string;
4
- readonly exitCode: number;
5
- readonly stdout: string;
6
- readonly stderr: string;
7
- }
8
- export interface ParityScenario {
9
- readonly name: string;
10
- readonly argv: readonly string[];
11
- }
12
- export interface ParityResult {
13
- readonly ok: boolean;
14
- readonly scenarios: Array<{
15
- readonly name: string;
16
- readonly exitMismatch: boolean;
17
- readonly pythonExit: number;
18
- readonly tsExit: number;
19
- readonly messageMismatch: boolean;
20
- readonly pythonMessage: string;
21
- readonly tsMessage: string;
22
- }>;
23
- }
24
- /** Validation-only scenarios (no live gh network). */
25
- export declare const PARITY_SCENARIOS: readonly ParityScenario[];
26
- /** Normalise gate output for comparison. */
27
- export declare function normaliseMessage(stdout: string, stderr: string, exitCode: number): string;
28
- /** Diff python vs TS outputs for one scenario. */
29
- export declare function diffParity(python: ScenarioResult, ts: ScenarioResult): {
30
- exitMismatch: boolean;
31
- messageMismatch: boolean;
32
- pythonMessage: string;
33
- tsMessage: string;
34
- };
35
- /** Run all parity scenarios and return a structured result. */
36
- export declare function runParity(): ParityResult;
37
- /** Render a human-readable parity report. */
38
- export declare function renderReport(result: ParityResult): string;
39
- //# sourceMappingURL=scm-parity.d.ts.map