@deftai/directive 0.61.2 → 0.63.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.
- package/dist/{branch-parity.d.ts → branch-fixtures.d.ts} +1 -3
- package/dist/{branch-parity.js → branch-fixtures.js} +3 -110
- package/dist/dispatch.d.ts +1 -1
- package/dist/dispatch.js +4 -1
- package/dist/framework-check-updates.d.ts +10 -0
- package/dist/framework-check-updates.js +68 -0
- package/dist/install-cli/coverage-map.js +3 -2
- package/dist/orchestration-cli/coverage-map.js +1 -1
- package/dist/{policy-parity.d.ts → policy-fixtures.d.ts} +1 -3
- package/dist/{policy-parity.js → policy-fixtures.js} +4 -100
- package/dist/{release-e2e-parity.d.ts → release-e2e-fixtures.d.ts} +1 -3
- package/dist/release-e2e-fixtures.js +38 -0
- package/dist/{story-ready-parity.d.ts → story-ready-fixtures.d.ts} +1 -3
- package/dist/{story-ready-parity.js → story-ready-fixtures.js} +4 -121
- package/dist/{triage-aux-a-parity.d.ts → triage-aux-a-fixtures.d.ts} +1 -3
- package/dist/{triage-aux-a-parity.js → triage-aux-a-fixtures.js} +3 -73
- package/dist/{triage-aux-b-parity.d.ts → triage-aux-b-fixtures.d.ts} +1 -3
- package/dist/triage-aux-b-fixtures.js +167 -0
- package/dist/{triage-bootstrap-parity.d.ts → triage-bootstrap-fixtures.d.ts} +1 -3
- package/dist/{triage-bootstrap-parity.js → triage-bootstrap-fixtures.js} +4 -91
- package/dist/{triage-classify-parity.d.ts → triage-classify-fixtures.d.ts} +1 -3
- package/dist/{triage-classify-parity.js → triage-classify-fixtures.js} +4 -94
- package/dist/{triage-queue-parity.d.ts → triage-queue-fixtures.d.ts} +1 -3
- package/dist/{triage-queue-parity.js → triage-queue-fixtures.js} +4 -86
- package/dist/{triage-scope-parity.d.ts → triage-scope-fixtures.d.ts} +1 -3
- package/dist/{triage-scope-parity.js → triage-scope-fixtures.js} +4 -91
- package/dist/umbrella-current-shape.d.ts +9 -0
- package/dist/umbrella-current-shape.js +56 -0
- package/dist/{vbrief-preflight-parity.d.ts → vbrief-preflight-fixtures.d.ts} +1 -3
- package/dist/vbrief-preflight-fixtures.js +79 -0
- package/dist/{wip-cap-parity.d.ts → wip-cap-fixtures.d.ts} +1 -3
- package/dist/{wip-cap-parity.js → wip-cap-fixtures.js} +4 -91
- package/package.json +4 -15
- package/dist/cache-parity.d.ts +0 -36
- package/dist/cache-parity.js +0 -165
- package/dist/codebase-parity.d.ts +0 -31
- package/dist/codebase-parity.js +0 -303
- package/dist/doc-cli-parity.d.ts +0 -29
- package/dist/doc-cli-parity.js +0 -159
- package/dist/doctor-parity.d.ts +0 -42
- package/dist/doctor-parity.js +0 -157
- package/dist/intake-parity.d.ts +0 -30
- package/dist/intake-parity.js +0 -203
- package/dist/lifecycle-packs-parity.d.ts +0 -30
- package/dist/lifecycle-packs-parity.js +0 -377
- package/dist/orchestration-parity.d.ts +0 -38
- package/dist/orchestration-parity.js +0 -364
- package/dist/parity.d.ts +0 -36
- package/dist/parity.js +0 -176
- package/dist/platform-parity.d.ts +0 -26
- package/dist/platform-parity.js +0 -309
- package/dist/pr-closing-keywords-parity.d.ts +0 -45
- package/dist/pr-closing-keywords-parity.js +0 -259
- package/dist/pr-merge-readiness-parity.d.ts +0 -44
- package/dist/pr-merge-readiness-parity.js +0 -296
- package/dist/pr-monitor-parity.d.ts +0 -44
- package/dist/pr-monitor-parity.js +0 -283
- package/dist/pr-protected-issues-parity.d.ts +0 -41
- package/dist/pr-protected-issues-parity.js +0 -220
- package/dist/pr-wait-mergeable-parity.d.ts +0 -45
- package/dist/pr-wait-mergeable-parity.js +0 -340
- package/dist/release-e2e-parity.js +0 -114
- package/dist/release-parity.d.ts +0 -40
- package/dist/release-parity.js +0 -226
- package/dist/release-publish-parity.d.ts +0 -36
- package/dist/release-publish-parity.js +0 -138
- package/dist/release-rollback-parity.d.ts +0 -37
- package/dist/release-rollback-parity.js +0 -161
- package/dist/render-parity.d.ts +0 -36
- package/dist/render-parity.js +0 -385
- package/dist/scm-parity.d.ts +0 -39
- package/dist/scm-parity.js +0 -181
- package/dist/scope-lifecycle-parity.d.ts +0 -35
- package/dist/scope-lifecycle-parity.js +0 -177
- package/dist/session-parity.d.ts +0 -39
- package/dist/session-parity.js +0 -262
- package/dist/slice-parity.d.ts +0 -36
- package/dist/slice-parity.js +0 -304
- package/dist/swarm-parity.d.ts +0 -28
- package/dist/swarm-parity.js +0 -327
- package/dist/triage-actions-parity.d.ts +0 -36
- package/dist/triage-actions-parity.js +0 -357
- package/dist/triage-aux-b-parity.js +0 -308
- package/dist/triage-summary-parity.d.ts +0 -50
- package/dist/triage-summary-parity.js +0 -306
- package/dist/validate-content-parity.d.ts +0 -33
- package/dist/validate-content-parity.js +0 -356
- package/dist/vbrief-activate-parity.d.ts +0 -39
- package/dist/vbrief-activate-parity.js +0 -216
- package/dist/vbrief-build-parity.d.ts +0 -28
- package/dist/vbrief-build-parity.js +0 -399
- package/dist/vbrief-preflight-parity.js +0 -163
- package/dist/vbrief-reconcile-parity.d.ts +0 -23
- package/dist/vbrief-reconcile-parity.js +0 -609
- package/dist/vbrief-validate-parity.d.ts +0 -27
- package/dist/vbrief-validate-parity.js +0 -122
- package/dist/vbrief-validation-parity.d.ts +0 -28
- package/dist/vbrief-validation-parity.js +0 -645
- package/dist/verify-env-parity.d.ts +0 -28
- package/dist/verify-env-parity.js +0 -272
- package/dist/verify-source-parity.d.ts +0 -26
- package/dist/verify-source-parity.js +0 -178
|
@@ -1,399 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Golden-output parity harness (#1782 s1): runs BOTH the Python oracle
|
|
4
|
-
* (frozen ``scripts/_vbrief_*.py`` helpers via an inline driver) and the
|
|
5
|
-
* ported TS vbrief-build CLI over shared fixtures, then diffs exit codes and
|
|
6
|
-
* byte-identical stdout/stderr (cache-off).
|
|
7
|
-
*
|
|
8
|
-
* Exit codes: 0 parity / 1 divergence / 2 harness setup error.
|
|
9
|
-
*/
|
|
10
|
-
import { spawnSync } from "node:child_process";
|
|
11
|
-
import { chmodSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
12
|
-
import { tmpdir } from "node:os";
|
|
13
|
-
import { dirname, join, resolve } from "node:path";
|
|
14
|
-
import { fileURLToPath } from "node:url";
|
|
15
|
-
import { PARITY_SCENARIO_NAMES } from "@deftai/directive-core/vbrief-build";
|
|
16
|
-
const PYTHON_DRIVER = String.raw `import json, os, sys
|
|
17
|
-
from pathlib import Path
|
|
18
|
-
|
|
19
|
-
ROOT = Path(os.environ["DEFT_ROOT"])
|
|
20
|
-
sys.path.insert(0, str(ROOT / "scripts"))
|
|
21
|
-
|
|
22
|
-
from _vbrief_build import create_scope_vbrief, reference_with_default_trust, slugify
|
|
23
|
-
from _vbrief_sources import (
|
|
24
|
-
derive_overview_narrative,
|
|
25
|
-
extract_tech_stack,
|
|
26
|
-
first_prose_paragraph,
|
|
27
|
-
parse_roadmap_items,
|
|
28
|
-
resolve_repo_url,
|
|
29
|
-
)
|
|
30
|
-
from _vbrief_routing import build_scope_vbrief_from_reconciled, folder_for_status, plan_status_matches_folder
|
|
31
|
-
from _vbrief_speckit import (
|
|
32
|
-
create_speckit_scope_vbrief,
|
|
33
|
-
dependencies_for_item,
|
|
34
|
-
edge_nodes,
|
|
35
|
-
migrate_speckit_plan,
|
|
36
|
-
speckit_ip_index,
|
|
37
|
-
speckit_ip_slug,
|
|
38
|
-
)
|
|
39
|
-
from _project_definition_io import (
|
|
40
|
-
atomic_write_project_definition,
|
|
41
|
-
load_project_definition_for_mutation,
|
|
42
|
-
project_definition_mutation_lock,
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
SAMPLE_ROADMAP_MD = """# Roadmap
|
|
46
|
-
|
|
47
|
-
## Phase 1 -- Foundation
|
|
48
|
-
|
|
49
|
-
- **#100** -- Add widget support
|
|
50
|
-
- **#101** -- Fix login bug
|
|
51
|
-
|
|
52
|
-
## Phase 2 -- Features
|
|
53
|
-
|
|
54
|
-
- **#200** -- Dashboard redesign
|
|
55
|
-
|
|
56
|
-
## Completed
|
|
57
|
-
|
|
58
|
-
- ~~#50 -- Initial setup~~
|
|
59
|
-
"""
|
|
60
|
-
|
|
61
|
-
SAMPLE_SPEC_VBRIEF = {
|
|
62
|
-
"vBRIEFInfo": {"version": "0.5", "description": "Test spec"},
|
|
63
|
-
"plan": {
|
|
64
|
-
"title": "Test Specification",
|
|
65
|
-
"status": "approved",
|
|
66
|
-
"narratives": {
|
|
67
|
-
"Overview": "A test project for migration.",
|
|
68
|
-
"Architecture": "Simple architecture.",
|
|
69
|
-
},
|
|
70
|
-
"items": [{"id": "t1.1", "title": "Task one", "status": "completed"}],
|
|
71
|
-
},
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
SAMPLE_PROJECT_MD = (
|
|
75
|
-
"# Test Project\n\n"
|
|
76
|
-
"## Project Configuration\n\n"
|
|
77
|
-
"**Tech Stack**: Python\n\n"
|
|
78
|
-
"**Generated by**: deft-setup skill\n"
|
|
79
|
-
"**Date**: 2026-04-01\n"
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
SAMPLE_SPEC_MD = (
|
|
83
|
-
"# Test Specification\n\n"
|
|
84
|
-
"A test specification.\n\n"
|
|
85
|
-
"**Generated by**: spec_render.py\n"
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
def reconciled_base(**overrides):
|
|
89
|
-
base = {
|
|
90
|
-
"task_id": "#99",
|
|
91
|
-
"number": "99",
|
|
92
|
-
"title": "Widget feature",
|
|
93
|
-
"description": "Add a widget.",
|
|
94
|
-
"description_source": "SPECIFICATION.md",
|
|
95
|
-
"status": "pending",
|
|
96
|
-
"status_source": "default",
|
|
97
|
-
"folder": "pending",
|
|
98
|
-
"phase": "Phase 1",
|
|
99
|
-
"phase_description": "",
|
|
100
|
-
"tier": "",
|
|
101
|
-
"spec_phase": "",
|
|
102
|
-
"roadmap_summary": "",
|
|
103
|
-
"source_conflict": "",
|
|
104
|
-
"title_source": "",
|
|
105
|
-
"override_applied": False,
|
|
106
|
-
"synthetic_id": "",
|
|
107
|
-
"original_task_id": "",
|
|
108
|
-
}
|
|
109
|
-
base.update(overrides)
|
|
110
|
-
return base
|
|
111
|
-
|
|
112
|
-
def dump(obj):
|
|
113
|
-
payload = json.dumps(obj, indent=2, ensure_ascii=False, sort_keys=False)
|
|
114
|
-
if not payload.endswith("\n"):
|
|
115
|
-
payload += "\n"
|
|
116
|
-
sys.stdout.write(payload)
|
|
117
|
-
|
|
118
|
-
def run_scenario(name, fixture_root):
|
|
119
|
-
fixture = Path(fixture_root)
|
|
120
|
-
if name == "slugify-basic":
|
|
121
|
-
return {"scenario": name, "ok": True, "payload": {
|
|
122
|
-
"hello": slugify("Hello World"),
|
|
123
|
-
"special": slugify("Add widget (v2)!"),
|
|
124
|
-
"underscores": slugify("task_id_foo"),
|
|
125
|
-
}}
|
|
126
|
-
if name == "create-scope-vbrief":
|
|
127
|
-
return {"scenario": name, "ok": True, "payload": create_scope_vbrief(
|
|
128
|
-
{"number": "99", "title": "Test feature", "phase": "Phase 1", "tier": "Tier 1"},
|
|
129
|
-
repo_url="https://github.com/owner/repo",
|
|
130
|
-
)}
|
|
131
|
-
if name == "reference-trust-levels":
|
|
132
|
-
return {"scenario": name, "ok": True, "payload": {
|
|
133
|
-
"internal": reference_with_default_trust({"type": "x-vbrief/plan", "uri": "specification.vbrief.json"}),
|
|
134
|
-
"external": reference_with_default_trust({"type": "x-vbrief/github-issue", "uri": "https://github.com/o/r/issues/1", "title": "Issue #1"}),
|
|
135
|
-
"preset": reference_with_default_trust({"type": "x-vbrief/github-issue", "uri": "https://github.com/o/r/issues/1", "title": "Issue #1", "TrustLevel": "internal"}),
|
|
136
|
-
}}
|
|
137
|
-
if name == "parse-roadmap":
|
|
138
|
-
roadmap = fixture / "ROADMAP.md"
|
|
139
|
-
roadmap.write_text(SAMPLE_ROADMAP_MD, encoding="utf-8")
|
|
140
|
-
items, phase_descs, completed = parse_roadmap_items(roadmap)
|
|
141
|
-
return {"scenario": name, "ok": True, "payload": {"items": items, "phaseDescriptions": phase_descs, "completedItems": completed}}
|
|
142
|
-
if name == "resolve-repo-url":
|
|
143
|
-
return {"scenario": name, "ok": True, "payload": {
|
|
144
|
-
"fromRepository": resolve_repo_url({"vBRIEFInfo": {"repository": "owner/repo"}}),
|
|
145
|
-
"fromRef": resolve_repo_url({"plan": {"references": [{"uri": "https://github.com/acme/widget/issues/1"}]}}),
|
|
146
|
-
"empty": resolve_repo_url(None),
|
|
147
|
-
}}
|
|
148
|
-
if name == "extract-tech-stack":
|
|
149
|
-
return {"scenario": name, "ok": True, "payload": extract_tech_stack(SAMPLE_PROJECT_MD)}
|
|
150
|
-
if name == "first-prose-paragraph":
|
|
151
|
-
return {"scenario": name, "ok": True, "payload": first_prose_paragraph(SAMPLE_SPEC_MD)}
|
|
152
|
-
if name == "derive-overview":
|
|
153
|
-
return {"scenario": name, "ok": True, "payload": {
|
|
154
|
-
"fromSpec": derive_overview_narrative(SAMPLE_SPEC_VBRIEF, None, None, 0),
|
|
155
|
-
"fromSpecMd": derive_overview_narrative(None, SAMPLE_SPEC_MD, None, 0),
|
|
156
|
-
"placeholder": derive_overview_narrative(None, None, None, 3),
|
|
157
|
-
}}
|
|
158
|
-
if name == "routing-map":
|
|
159
|
-
return {"scenario": name, "ok": True, "payload": {
|
|
160
|
-
"running": folder_for_status("running"),
|
|
161
|
-
"matches": plan_status_matches_folder("running", "active"),
|
|
162
|
-
}}
|
|
163
|
-
if name == "build-reconciled":
|
|
164
|
-
return {"scenario": name, "ok": True, "payload": build_scope_vbrief_from_reconciled(
|
|
165
|
-
reconciled_base(status="completed", folder="completed", source_section="ROADMAP Completed section"),
|
|
166
|
-
repo_url="https://github.com/acme/widget",
|
|
167
|
-
migration_timestamp="2026-04-23T00:00:00Z",
|
|
168
|
-
)}
|
|
169
|
-
if name == "speckit-edge-deps":
|
|
170
|
-
return {"scenario": name, "ok": True, "payload": {
|
|
171
|
-
"nodes": list(edge_nodes({"from": "a", "to": "b"})),
|
|
172
|
-
"legacy": list(edge_nodes({"source": "x", "target": "y"})),
|
|
173
|
-
"deps": dependencies_for_item("ip-2", [
|
|
174
|
-
{"type": "blocks", "from": "ip-1", "to": "ip-2"},
|
|
175
|
-
{"type": "blocks", "source": "ip-0", "target": "ip-2"},
|
|
176
|
-
]),
|
|
177
|
-
"slug": speckit_ip_slug("IP-1: Widget phase", "ip-1"),
|
|
178
|
-
"index": speckit_ip_index({"id": "phase-ip-3", "title": "IP 3: Build"}, 9),
|
|
179
|
-
}}
|
|
180
|
-
if name == "create-speckit-scope":
|
|
181
|
-
return {"scenario": name, "ok": True, "payload": create_speckit_scope_vbrief(
|
|
182
|
-
{"title": "IP-1: Foundation", "narrative": {"Description": "Build the foundation.", "Acceptance": "Tests pass.", "Traces": "REQ-1"}},
|
|
183
|
-
ip_index=1,
|
|
184
|
-
dependencies=["ip-0"],
|
|
185
|
-
spec_ref="../specification.vbrief.json",
|
|
186
|
-
)}
|
|
187
|
-
if name == "project-definition-roundtrip":
|
|
188
|
-
vbrief = fixture / "vbrief"
|
|
189
|
-
vbrief.mkdir(parents=True, exist_ok=True)
|
|
190
|
-
seed = {
|
|
191
|
-
"vBRIEFInfo": {"version": "0.6"},
|
|
192
|
-
"plan": {"title": "Parity project", "status": "running", "policy": {"wipCap": 10}, "items": []},
|
|
193
|
-
}
|
|
194
|
-
pd = vbrief / "PROJECT-DEFINITION.vbrief.json"
|
|
195
|
-
pd.write_text(json.dumps(seed, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
|
196
|
-
roundtrip = {}
|
|
197
|
-
with project_definition_mutation_lock(fixture):
|
|
198
|
-
data, path = load_project_definition_for_mutation(fixture)
|
|
199
|
-
data["plan"]["policy"] = {"wipCap": 12}
|
|
200
|
-
atomic_write_project_definition(path, data)
|
|
201
|
-
roundtrip = json.loads(path.read_text(encoding="utf-8"))
|
|
202
|
-
return {"scenario": name, "ok": True, "payload": roundtrip}
|
|
203
|
-
if name == "migrate-speckit-plan":
|
|
204
|
-
vbrief = fixture / "vbrief"
|
|
205
|
-
vbrief.mkdir(parents=True, exist_ok=True)
|
|
206
|
-
plan_path = vbrief / "plan.vbrief.json"
|
|
207
|
-
plan_fixture = {
|
|
208
|
-
"vBRIEFInfo": {"version": "0.5", "description": "Speckit plan"},
|
|
209
|
-
"plan": {
|
|
210
|
-
"title": "Session",
|
|
211
|
-
"items": [{"id": "ip-1", "title": "IP-1: Foundation", "narrative": {"Description": "Build it."}}],
|
|
212
|
-
"edges": [],
|
|
213
|
-
},
|
|
214
|
-
}
|
|
215
|
-
plan_path.write_text(json.dumps(plan_fixture, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
|
216
|
-
ok, actions = migrate_speckit_plan(plan_path, pending_dir=vbrief / "pending", today="2026-04-23")
|
|
217
|
-
pending_content = None
|
|
218
|
-
pending_path = vbrief / "pending" / "2026-04-23-ip001-foundation.vbrief.json"
|
|
219
|
-
if pending_path.is_file():
|
|
220
|
-
pending_content = json.loads(pending_path.read_text(encoding="utf-8"))
|
|
221
|
-
rewritten = json.loads(plan_path.read_text(encoding="utf-8"))
|
|
222
|
-
return {"scenario": name, "ok": ok, "payload": {"actions": actions, "pendingContent": pending_content, "rewrittenPlan": rewritten, "pendingFiles": ["pending"]}}
|
|
223
|
-
if name == "extract-tech-stack-eos":
|
|
224
|
-
return {"scenario": name, "ok": True, "payload": {
|
|
225
|
-
"endOfString": extract_tech_stack("## Tech Stack\nRust + TypeScript"),
|
|
226
|
-
"trailingNewline": extract_tech_stack("## Tech Stack\nRust + TypeScript\n"),
|
|
227
|
-
"followedByHeading": extract_tech_stack("## Tech Stack\nRust\n## Next\nmore"),
|
|
228
|
-
"multiLine": extract_tech_stack("## Tech Stack\nRust\nVitest\n"),
|
|
229
|
-
}}
|
|
230
|
-
if name == "speckit-ip-index-edge":
|
|
231
|
-
return {"scenario": name, "ok": True, "payload": {
|
|
232
|
-
"longDigits": speckit_ip_index({"id": "12345678901234"}, 1),
|
|
233
|
-
"trailingWhitespace": speckit_ip_index({"id": "ip-7 "}, 1),
|
|
234
|
-
"trailingNewline": speckit_ip_index({"id": "ip-8\n"}, 1),
|
|
235
|
-
"titleFallback": speckit_ip_index({"id": "phase", "title": "IP-3: Build"}, 9),
|
|
236
|
-
"noDigits": speckit_ip_index({"id": "phase-x", "title": "no ip"}, 5),
|
|
237
|
-
}}
|
|
238
|
-
if name == "repo-url-trailing-slashes":
|
|
239
|
-
return {"scenario": name, "ok": True, "payload": {
|
|
240
|
-
"single": create_scope_vbrief({"number": "5", "title": "T"}, repo_url="https://github.com/o/r/"),
|
|
241
|
-
"multiple": create_scope_vbrief({"number": "6", "title": "U"}, repo_url="https://github.com/o/r///"),
|
|
242
|
-
"spaced": create_scope_vbrief({"number": "7", "title": "V"}, repo_url=" https://github.com/o/r// "),
|
|
243
|
-
}}
|
|
244
|
-
return {"scenario": name, "ok": False, "payload": {"error": f"unknown scenario: {name}"}}
|
|
245
|
-
|
|
246
|
-
def main():
|
|
247
|
-
mode = sys.argv[1] if len(sys.argv) > 1 else ""
|
|
248
|
-
fixture_root = os.environ.get("DEFT_VBRIEF_BUILD_FIXTURE", "")
|
|
249
|
-
if mode == "--all":
|
|
250
|
-
results = [run_scenario(name, fixture_root) for name in json.loads(os.environ["DEFT_VBRIEF_BUILD_SCENARIOS"])]
|
|
251
|
-
dump(results)
|
|
252
|
-
return 0
|
|
253
|
-
if mode == "--scenario":
|
|
254
|
-
name = sys.argv[2]
|
|
255
|
-
dump(run_scenario(name, fixture_root))
|
|
256
|
-
return 0
|
|
257
|
-
sys.stderr.write("usage: driver --all | --scenario NAME\n")
|
|
258
|
-
return 2
|
|
259
|
-
|
|
260
|
-
if __name__ == "__main__":
|
|
261
|
-
raise SystemExit(main())
|
|
262
|
-
`;
|
|
263
|
-
function runCapture(cmd, args, cwd, env) {
|
|
264
|
-
const result = spawnSync(cmd, args, {
|
|
265
|
-
cwd,
|
|
266
|
-
encoding: "utf8",
|
|
267
|
-
env: { ...process.env, ...env },
|
|
268
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
269
|
-
});
|
|
270
|
-
return {
|
|
271
|
-
status: result.status ?? 2,
|
|
272
|
-
stdout: typeof result.stdout === "string" ? result.stdout : "",
|
|
273
|
-
stderr: typeof result.stderr === "string" ? result.stderr : "",
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
function resolveDeftRoot() {
|
|
277
|
-
if (process.env.DEFT_ROOT !== undefined && process.env.DEFT_ROOT.length > 0) {
|
|
278
|
-
return resolve(process.env.DEFT_ROOT);
|
|
279
|
-
}
|
|
280
|
-
return resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "..");
|
|
281
|
-
}
|
|
282
|
-
function normaliseHarnessNoise(text) {
|
|
283
|
-
return text
|
|
284
|
-
.split("\n")
|
|
285
|
-
.filter((line) => !line.startsWith("Using CPython") &&
|
|
286
|
-
!line.startsWith("Creating virtual environment") &&
|
|
287
|
-
!line.startsWith("Installed "))
|
|
288
|
-
.join("\n");
|
|
289
|
-
}
|
|
290
|
-
export function diffParity(python, ts) {
|
|
291
|
-
const pythonOutput = normaliseHarnessNoise(python.stdout);
|
|
292
|
-
const tsOutput = normaliseHarnessNoise(ts.stdout);
|
|
293
|
-
return {
|
|
294
|
-
exitMismatch: python.exitCode !== ts.exitCode,
|
|
295
|
-
outputMismatch: pythonOutput !== tsOutput,
|
|
296
|
-
pythonOutput,
|
|
297
|
-
tsOutput,
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
function installPythonDriver(_deftRoot) {
|
|
301
|
-
const dir = mkdtempSync(join(tmpdir(), "deft-vbrief-build-py-driver-"));
|
|
302
|
-
const driverPath = join(dir, "vbrief_build_parity_driver.py");
|
|
303
|
-
writeFileSync(driverPath, PYTHON_DRIVER, "utf8");
|
|
304
|
-
chmodSync(driverPath, 0o755);
|
|
305
|
-
return {
|
|
306
|
-
driverPath,
|
|
307
|
-
cleanup: () => rmSync(dir, { recursive: true, force: true }),
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
function runScenario(deftRoot, driverPath, name) {
|
|
311
|
-
const pyFixture = mkdtempSync(join(tmpdir(), "deft-vbrief-build-parity-py-"));
|
|
312
|
-
const tsFixture = mkdtempSync(join(tmpdir(), "deft-vbrief-build-parity-ts-"));
|
|
313
|
-
const envBase = {
|
|
314
|
-
DEFT_CACHE_DISABLE: "1",
|
|
315
|
-
PYTHONUTF8: "1",
|
|
316
|
-
DEFT_ROOT: deftRoot,
|
|
317
|
-
DEFT_VBRIEF_BUILD_SCENARIOS: JSON.stringify(PARITY_SCENARIO_NAMES),
|
|
318
|
-
};
|
|
319
|
-
try {
|
|
320
|
-
const py = runCapture("uv", ["run", "python", driverPath, "--scenario", name], deftRoot, {
|
|
321
|
-
...envBase,
|
|
322
|
-
DEFT_VBRIEF_BUILD_FIXTURE: pyFixture,
|
|
323
|
-
});
|
|
324
|
-
const ts = runCapture("node", [
|
|
325
|
-
join(deftRoot, "packages", "cli", "dist", "vbrief-build.js"),
|
|
326
|
-
"--scenario",
|
|
327
|
-
name,
|
|
328
|
-
"--fixture-root",
|
|
329
|
-
tsFixture,
|
|
330
|
-
], deftRoot, envBase);
|
|
331
|
-
return {
|
|
332
|
-
python: { name, exitCode: py.status, stdout: py.stdout, stderr: py.stderr },
|
|
333
|
-
ts: { name, exitCode: ts.status, stdout: ts.stdout, stderr: ts.stderr },
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
finally {
|
|
337
|
-
rmSync(pyFixture, { recursive: true, force: true });
|
|
338
|
-
rmSync(tsFixture, { recursive: true, force: true });
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
export function runParity() {
|
|
342
|
-
const deftRoot = resolveDeftRoot();
|
|
343
|
-
const driver = installPythonDriver(deftRoot);
|
|
344
|
-
const scenarios = [];
|
|
345
|
-
try {
|
|
346
|
-
for (const name of PARITY_SCENARIO_NAMES) {
|
|
347
|
-
const ran = runScenario(deftRoot, driver.driverPath, name);
|
|
348
|
-
scenarios.push({
|
|
349
|
-
name,
|
|
350
|
-
pythonExit: ran.python.exitCode,
|
|
351
|
-
tsExit: ran.ts.exitCode,
|
|
352
|
-
...diffParity(ran.python, ran.ts),
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
finally {
|
|
357
|
-
driver.cleanup();
|
|
358
|
-
}
|
|
359
|
-
const ok = scenarios.every((s) => !s.exitMismatch && !s.outputMismatch);
|
|
360
|
-
return { ok, scenarios };
|
|
361
|
-
}
|
|
362
|
-
export function renderReport(result) {
|
|
363
|
-
if (result.ok) {
|
|
364
|
-
return `vbrief_build parity: CLEAN -- Python and TS agree on ${result.scenarios.length} scenario(s).`;
|
|
365
|
-
}
|
|
366
|
-
const lines = ["vbrief_build parity: DIVERGENCE"];
|
|
367
|
-
for (const s of result.scenarios) {
|
|
368
|
-
if (s.exitMismatch || s.outputMismatch) {
|
|
369
|
-
lines.push(` scenario: ${s.name}`);
|
|
370
|
-
if (s.exitMismatch) {
|
|
371
|
-
lines.push(` exit mismatch: python=${s.pythonExit} ts=${s.tsExit}`);
|
|
372
|
-
}
|
|
373
|
-
if (s.outputMismatch) {
|
|
374
|
-
lines.push(` python (${s.pythonOutput.length} bytes):`);
|
|
375
|
-
lines.push(s.pythonOutput.slice(0, 500));
|
|
376
|
-
lines.push(` ts (${s.tsOutput.length} bytes):`);
|
|
377
|
-
lines.push(s.tsOutput.slice(0, 500));
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
return lines.join("\n");
|
|
382
|
-
}
|
|
383
|
-
if (process.argv[1] !== undefined && fileURLToPath(import.meta.url) === process.argv[1]) {
|
|
384
|
-
try {
|
|
385
|
-
const result = runParity();
|
|
386
|
-
if (result.ok) {
|
|
387
|
-
process.stdout.write(`${renderReport(result)}\n`);
|
|
388
|
-
process.exit(0);
|
|
389
|
-
}
|
|
390
|
-
process.stderr.write(`${renderReport(result)}\n`);
|
|
391
|
-
process.exit(1);
|
|
392
|
-
}
|
|
393
|
-
catch (err) {
|
|
394
|
-
const msg = String(err).replace(/\r?\n/g, " ");
|
|
395
|
-
process.stderr.write(`vbrief_build parity: harness error -- ${msg}\n`);
|
|
396
|
-
process.exit(2);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
//# sourceMappingURL=vbrief-build-parity.js.map
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Golden-output parity harness (#1721): writes temp fixture vBRIEFs, runs BOTH
|
|
4
|
-
* the Python oracle (`scripts/preflight_implementation.py`) and the ported TS
|
|
5
|
-
* gate with session-ritual bypassed, and diffs structured JSON + exit codes.
|
|
6
|
-
*
|
|
7
|
-
* Exit codes: 0 parity / 1 divergence / 2 harness setup error.
|
|
8
|
-
*/
|
|
9
|
-
import { execFileSync } from "node:child_process";
|
|
10
|
-
import { mkdirSync, mkdtempSync, 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
|
-
/** Fixture corpus: [label, folder, file content]. */
|
|
15
|
-
export const PARITY_FIXTURES = [
|
|
16
|
-
["active_running", "active", JSON.stringify({ plan: { status: "running" } })],
|
|
17
|
-
["pending", "pending", JSON.stringify({ plan: { status: "running" } })],
|
|
18
|
-
["proposed", "proposed", JSON.stringify({ plan: { status: "running" } })],
|
|
19
|
-
["malformed_json", "active", "{bad json"],
|
|
20
|
-
["wrong_status", "active", JSON.stringify({ plan: { status: "pending" } })],
|
|
21
|
-
["missing_plan_status", "active", JSON.stringify({ plan: {} })],
|
|
22
|
-
];
|
|
23
|
-
/** Parse the structured `--json` stdout payload. */
|
|
24
|
-
export function parseJsonOutput(stdout, exitCode) {
|
|
25
|
-
const trimmed = stdout.trim();
|
|
26
|
-
let payload;
|
|
27
|
-
try {
|
|
28
|
-
payload = JSON.parse(trimmed);
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
31
|
-
throw new Error(`Expected JSON output but got: ${trimmed.length > 0 ? trimmed : "(empty)"}`);
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
exitCode,
|
|
35
|
-
ready: payload.ready,
|
|
36
|
-
vbriefPath: payload.vbrief_path,
|
|
37
|
-
message: payload.message,
|
|
38
|
-
rawJson: trimmed,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
/** Diff two gate JSON outputs for one fixture case. */
|
|
42
|
-
export function diffOutputs(name, python, ts) {
|
|
43
|
-
const exitMismatch = python.exitCode !== ts.exitCode;
|
|
44
|
-
const readyMismatch = python.ready !== ts.ready;
|
|
45
|
-
const messageMismatch = python.message !== ts.message;
|
|
46
|
-
return {
|
|
47
|
-
name,
|
|
48
|
-
ok: !exitMismatch && !readyMismatch && !messageMismatch,
|
|
49
|
-
pythonExit: python.exitCode,
|
|
50
|
-
tsExit: ts.exitCode,
|
|
51
|
-
exitMismatch,
|
|
52
|
-
readyMismatch,
|
|
53
|
-
messageMismatch,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function runCapture(cmd, args, cwd, env) {
|
|
57
|
-
try {
|
|
58
|
-
const stdout = execFileSync(cmd, args, {
|
|
59
|
-
cwd,
|
|
60
|
-
encoding: "utf8",
|
|
61
|
-
env: { ...process.env, ...env },
|
|
62
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
63
|
-
});
|
|
64
|
-
return { status: 0, stdout, stderr: "" };
|
|
65
|
-
}
|
|
66
|
-
catch (err) {
|
|
67
|
-
const e = err;
|
|
68
|
-
return {
|
|
69
|
-
status: typeof e.status === "number" ? e.status : 2,
|
|
70
|
-
stdout: typeof e.stdout === "string" ? e.stdout : "",
|
|
71
|
-
stderr: typeof e.stderr === "string" ? e.stderr : "",
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
/** Build temp fixture files; returns map of label -> absolute path. */
|
|
76
|
-
export function buildFixtures(root) {
|
|
77
|
-
const paths = new Map();
|
|
78
|
-
for (const [label, folder, content] of PARITY_FIXTURES) {
|
|
79
|
-
const dir = join(root, folder);
|
|
80
|
-
mkdirSync(dir, { recursive: true });
|
|
81
|
-
const file = join(dir, `${label}.vbrief.json`);
|
|
82
|
-
writeFileSync(file, content, { encoding: "utf8" });
|
|
83
|
-
paths.set(label, file);
|
|
84
|
-
}
|
|
85
|
-
return paths;
|
|
86
|
-
}
|
|
87
|
-
function resolveDeftRoot() {
|
|
88
|
-
if (process.env.DEFT_ROOT !== undefined && process.env.DEFT_ROOT.length > 0) {
|
|
89
|
-
return resolve(process.env.DEFT_ROOT);
|
|
90
|
-
}
|
|
91
|
-
return resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "..");
|
|
92
|
-
}
|
|
93
|
-
/** Run both gates against all fixtures and diff them. */
|
|
94
|
-
export function runParity() {
|
|
95
|
-
const deftRoot = resolveDeftRoot();
|
|
96
|
-
const root = mkdtempSync(join(tmpdir(), "deft-vbrief-preflight-parity-"));
|
|
97
|
-
try {
|
|
98
|
-
const fixtures = buildFixtures(root);
|
|
99
|
-
const cases = [];
|
|
100
|
-
for (const [label] of PARITY_FIXTURES) {
|
|
101
|
-
const fixturePath = fixtures.get(label);
|
|
102
|
-
if (fixturePath === undefined) {
|
|
103
|
-
throw new Error(`missing fixture path for ${label}`);
|
|
104
|
-
}
|
|
105
|
-
const py = runCapture("uv", [
|
|
106
|
-
"run",
|
|
107
|
-
"python",
|
|
108
|
-
join(deftRoot, "scripts", "preflight_implementation.py"),
|
|
109
|
-
"--vbrief-path",
|
|
110
|
-
fixturePath,
|
|
111
|
-
"--json",
|
|
112
|
-
], deftRoot, { DEFT_SESSION_RITUAL_SKIP: "1" });
|
|
113
|
-
const ts = runCapture("node", [
|
|
114
|
-
join(deftRoot, "packages", "cli", "dist", "vbrief-preflight.js"),
|
|
115
|
-
"--vbrief-path",
|
|
116
|
-
fixturePath,
|
|
117
|
-
"--json",
|
|
118
|
-
], deftRoot);
|
|
119
|
-
cases.push(diffOutputs(label, parseJsonOutput(py.stdout, py.status), parseJsonOutput(ts.stdout, ts.status)));
|
|
120
|
-
}
|
|
121
|
-
return { ok: cases.every((c) => c.ok), cases };
|
|
122
|
-
}
|
|
123
|
-
finally {
|
|
124
|
-
rmSync(root, { recursive: true, force: true });
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
/** Render a human-readable parity report (exported for unit tests). */
|
|
128
|
-
export function renderReport(result) {
|
|
129
|
-
if (result.ok) {
|
|
130
|
-
return `vbrief_preflight parity: CLEAN -- Python and TS agree on ${result.cases.length} fixture(s).`;
|
|
131
|
-
}
|
|
132
|
-
const lines = ["vbrief_preflight parity: DIVERGENCE"];
|
|
133
|
-
for (const c of result.cases.filter((x) => !x.ok)) {
|
|
134
|
-
lines.push(` case ${c.name}:`);
|
|
135
|
-
if (c.exitMismatch) {
|
|
136
|
-
lines.push(` exit mismatch: python=${c.pythonExit} ts=${c.tsExit}`);
|
|
137
|
-
}
|
|
138
|
-
if (c.readyMismatch) {
|
|
139
|
-
lines.push(" ready mismatch");
|
|
140
|
-
}
|
|
141
|
-
if (c.messageMismatch) {
|
|
142
|
-
lines.push(" message mismatch");
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return lines.join("\n");
|
|
146
|
-
}
|
|
147
|
-
if (process.argv[1] !== undefined && fileURLToPath(import.meta.url) === process.argv[1]) {
|
|
148
|
-
try {
|
|
149
|
-
const result = runParity();
|
|
150
|
-
if (result.ok) {
|
|
151
|
-
process.stdout.write(`${renderReport(result)}\n`);
|
|
152
|
-
process.exit(0);
|
|
153
|
-
}
|
|
154
|
-
process.stderr.write(`${renderReport(result)}\n`);
|
|
155
|
-
process.exit(1);
|
|
156
|
-
}
|
|
157
|
-
catch (err) {
|
|
158
|
-
const msg = String(err).replace(/\r?\n/g, " ");
|
|
159
|
-
process.stderr.write(`vbrief_preflight parity: harness error -- ${msg}\n`);
|
|
160
|
-
process.exit(2);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
//# sourceMappingURL=vbrief-preflight-parity.js.map
|
|
@@ -1,23 +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 ParityResult {
|
|
9
|
-
readonly ok: boolean;
|
|
10
|
-
readonly scenarios: Array<{
|
|
11
|
-
readonly name: string;
|
|
12
|
-
readonly exitMismatch: boolean;
|
|
13
|
-
readonly pythonExit: number;
|
|
14
|
-
readonly tsExit: number;
|
|
15
|
-
readonly outputMismatch: boolean;
|
|
16
|
-
readonly pythonOutput: string;
|
|
17
|
-
readonly tsOutput: string;
|
|
18
|
-
}>;
|
|
19
|
-
}
|
|
20
|
-
export declare function normalizeOutput(text: string): string;
|
|
21
|
-
export declare function runParity(): ParityResult;
|
|
22
|
-
export declare function renderReport(result: ParityResult): string;
|
|
23
|
-
//# sourceMappingURL=vbrief-reconcile-parity.d.ts.map
|