rungate 0.2.1 → 0.4.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/bin/rungate.ts +70 -0
- package/lib/aes-calculator.ts +66 -0
- package/lib/agent-audit.ts +139 -0
- package/lib/agent-brief-validation.ts +359 -0
- package/lib/agents-md-refs.ts +90 -0
- package/lib/bash-file-read.ts +197 -0
- package/lib/behavioral-cache.ts +78 -0
- package/lib/branch-cleanup.ts +234 -0
- package/lib/brief-context-parser.ts +35 -0
- package/lib/brief-precedence.ts +114 -0
- package/lib/canary.ts +117 -0
- package/lib/check-registry.ts +226 -0
- package/lib/ci-checkout.ts +426 -0
- package/lib/cli-commands.ts +137 -0
- package/lib/compliance-backfill.ts +232 -0
- package/lib/compliance-report.ts +605 -0
- package/lib/compliance.ts +361 -0
- package/lib/config-loader.ts +255 -0
- package/lib/config-readers.ts +86 -0
- package/lib/conformity.ts +2161 -137
- package/lib/container-provenance.ts +230 -0
- package/lib/create-brief.ts +150 -0
- package/lib/create-sc.ts +267 -0
- package/lib/decomposition-waves.ts +197 -0
- package/lib/deep-merge.ts +69 -0
- package/lib/dev-liveness.ts +214 -0
- package/lib/directive-extractor.ts +210 -0
- package/lib/distribution-standing.ts +113 -0
- package/lib/doc-hygiene.ts +238 -0
- package/lib/eval-criteria.ts +6 -0
- package/lib/evidence-portability.ts +123 -0
- package/lib/evidence-prevalidator.ts +390 -0
- package/lib/evidence-required.ts +150 -0
- package/lib/evidence-satisfiability.ts +288 -0
- package/lib/frontmatter.ts +163 -0
- package/lib/gap-scanner.ts +348 -0
- package/lib/gate-check-audit.ts +190 -0
- package/lib/gate-enforcement.ts +366 -0
- package/lib/generators/agent-briefs.ts +136 -0
- package/lib/generators/agents-md.ts +511 -0
- package/lib/generators/code-map.ts +60 -0
- package/lib/generators/types.ts +184 -0
- package/lib/git-ref-normalizer.ts +107 -0
- package/lib/github.ts +539 -0
- package/lib/harness-identity.ts +63 -0
- package/lib/hill-climb.ts +164 -0
- package/lib/instruction-effectiveness.ts +131 -0
- package/lib/issue-closure-audit.ts +225 -0
- package/lib/issue-create-override.ts +343 -0
- package/lib/issue-extraction.ts +368 -0
- package/lib/js-top-level-code.ts +250 -0
- package/lib/liveness-contradiction.ts +149 -0
- package/lib/organize.ts +505 -0
- package/lib/paths.ts +197 -6
- package/lib/phase2-decomposition.ts +270 -0
- package/lib/post-fix-verify.ts +157 -0
- package/lib/prior-branch.ts +512 -0
- package/lib/project-state-shape.ts +166 -0
- package/lib/promote-outputs.ts +156 -0
- package/lib/prove-label-gate.ts +128 -0
- package/lib/reachability.ts +302 -0
- package/lib/release-preflight.ts +288 -0
- package/lib/rule-health-pipeline.ts +264 -0
- package/lib/rule-health-trend.ts +161 -0
- package/lib/rule-provenance.ts +149 -0
- package/lib/rule-registry.ts +128 -0
- package/lib/rungate-schema.ts +127 -5
- package/lib/sc-claim-forms.ts +179 -0
- package/lib/sc-cover.ts +150 -0
- package/lib/sc-guard.ts +157 -0
- package/lib/sc-ids.ts +344 -0
- package/lib/scaffold/defaults.ts +165 -0
- package/lib/scaffold/managed-workflow.ts +370 -0
- package/lib/scaffold/owned-files.ts +265 -0
- package/lib/scaffold/pre-push-hook.ts +165 -0
- package/lib/scaffold/steps.ts +2621 -0
- package/lib/scanner.ts +701 -0
- package/lib/scope-denylist.ts +258 -0
- package/lib/screenshot-upload.ts +73 -0
- package/lib/secret-patterns.ts +112 -0
- package/lib/security-verdict.ts +616 -0
- package/lib/signal-phrases.ts +1 -0
- package/lib/spec-change-conformity.ts +80 -0
- package/lib/spec-files.ts +62 -0
- package/lib/spec-registry.ts +133 -0
- package/lib/spec-updater.ts +96 -0
- package/lib/stale-cleanup.ts +224 -0
- package/lib/stale-issue-scanner.ts +36 -0
- package/lib/strip-js-comments.ts +269 -0
- package/lib/suite-measurement.ts +228 -0
- package/lib/task-completion-checks.ts +224 -0
- package/lib/test-suite-lock.ts +1136 -0
- package/lib/transcript-checker.ts +1140 -0
- package/lib/typescript-project.ts +233 -0
- package/lib/validators/spec-validators.ts +171 -0
- package/lib/verdict-capture.ts +73 -0
- package/lib/verified-push.ts +535 -0
- package/lib/workflow-security.ts +174 -0
- package/lib/worktree-cleanup.ts +432 -0
- package/lib/worktree-collect.ts +283 -0
- package/lib/worktree-isolation.ts +82 -0
- package/lib/worktree-repo.ts +300 -0
- package/package.json +27 -3
- package/prompts/ac-adversary.md +14 -2
- package/prompts/aditi.md +5 -0
- package/prompts/blast-radius.md +5 -0
- package/prompts/container-verify.md +5 -0
- package/prompts/discovery.md +4 -0
- package/prompts/environment.md +5 -0
- package/prompts/evidence-hierarchy.md +5 -0
- package/prompts/evidence-validator.md +11 -0
- package/prompts/marcus.md +5 -0
- package/prompts/prevention.md +5 -0
- package/prompts/prove-reproducer.md +12 -0
- package/prompts/quinn-decision-tree.md +5 -0
- package/prompts/quinn-ui-brief.md +5 -0
- package/prompts/quinn.md +5 -0
- package/prompts/rca.md +5 -0
- package/prompts/read-before-write.md +4 -0
- package/prompts/regression.md +5 -0
- package/prompts/serena.md +5 -0
- package/scripts/audit-specs.ts +464 -0
- package/scripts/convert-spec.ts +293 -0
- package/scripts/create-sc.ts +92 -0
- package/scripts/create-spec.ts +166 -0
- package/scripts/extract-constraints.ts +4 -3
- package/scripts/generate-code-map.ts +1 -1
- package/scripts/scaffold-project.ts +138 -1426
- package/scripts/sync-spec-tests.ts +211 -126
|
@@ -13,15 +13,79 @@
|
|
|
13
13
|
* Lines containing `Quinn` + action verb → assert Quinn integration
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import { readFileSync, writeFileSync, readdirSync } from "fs";
|
|
16
|
+
import { existsSync, readFileSync, writeFileSync, readdirSync } from "fs";
|
|
17
|
+
import { collectSpecFiles } from "../lib/spec-files";
|
|
17
18
|
import { resolve, join } from "path";
|
|
19
|
+
import { harnessRootFor } from "../lib/paths";
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
21
|
+
/**
|
|
22
|
+
* Where this script reads specs and writes tests (#141).
|
|
23
|
+
*
|
|
24
|
+
* It used to compute these itself:
|
|
25
|
+
*
|
|
26
|
+
* const HARNESS_ROOT = process.env.HARNESS_ROOT || join(HOME, ".claude");
|
|
27
|
+
* const SPECS_DIR = resolve(HARNESS_ROOT, "PAI/Specs");
|
|
28
|
+
* const OUTPUT_PATH = resolve(HARNESS_ROOT, "test/spec-compliance-auto.test.ts");
|
|
29
|
+
*
|
|
30
|
+
* `HARNESS_ROOT` is never exported — no profile, CI file, hook or skill sets
|
|
31
|
+
* it; it is only ever passed as a workflow argument. So the default applied,
|
|
32
|
+
* and the generator read `~/.claude/PAI/Specs` and wrote
|
|
33
|
+
* `~/.claude/test/spec-compliance-auto.test.ts`, while `lib/paths.ts`
|
|
34
|
+
* `harnessRoot()` resolved to this checkout. Two functions, one concept, two
|
|
35
|
+
* answers — and both directories exist, so nothing ever errored.
|
|
36
|
+
*
|
|
37
|
+
* The cost: `specs/` holds 30 spec files and this generator had never read
|
|
38
|
+
* one of them. "SCs without tests are wishes" is the project's own rule, and
|
|
39
|
+
* the mechanism meant to enforce it wrote its output where the suite does not
|
|
40
|
+
* look and reported success. `gates/gate-executor.ts` runs it on every gate.
|
|
41
|
+
*
|
|
42
|
+
* Pure in `root` so the resolution is testable without a filesystem, which is
|
|
43
|
+
* the shape the issue asked for.
|
|
44
|
+
*/
|
|
45
|
+
export interface SyncPaths {
|
|
46
|
+
specsDir: string;
|
|
47
|
+
shipPath: string;
|
|
48
|
+
provePath: string;
|
|
49
|
+
outputPath: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function resolveSyncPaths(root: string): SyncPaths {
|
|
53
|
+
return {
|
|
54
|
+
specsDir: resolve(root, "specs"),
|
|
55
|
+
shipPath: resolve(root, "workflows/ship.js"),
|
|
56
|
+
provePath: resolve(root, "workflows/prove.js"),
|
|
57
|
+
outputPath: resolve(root, "test/spec-compliance-auto.test.ts"),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The tree this script WRITES to, stated rather than inherited (#190).
|
|
63
|
+
*
|
|
64
|
+
* It was `const ROOT = harnessRoot()` at module scope, which made the
|
|
65
|
+
* destination of a write depend on two things the caller never said: the
|
|
66
|
+
* `HARNESS_ROOT` environment variable, and which checkout happened to load
|
|
67
|
+
* `lib/paths.ts`. `gates/gate-executor.ts` runs this on every scope gate, so a
|
|
68
|
+
* gate whose root was resolved elsewhere regenerated a DIFFERENT checkout's
|
|
69
|
+
* `test/spec-compliance-auto.test.ts` and left its own stale — silently, since
|
|
70
|
+
* both files exist and both are real.
|
|
71
|
+
*
|
|
72
|
+
* Resolution order:
|
|
73
|
+
*
|
|
74
|
+
* 1. `argv[2]`, when a caller names the tree it means.
|
|
75
|
+
* 2. Otherwise the checkout this script file lives in.
|
|
76
|
+
*
|
|
77
|
+
* `bun <checkout>/scripts/sync-spec-tests.ts` therefore writes into
|
|
78
|
+
* `<checkout>`, whatever the cwd and whatever the environment says. Deliberately
|
|
79
|
+
* NOT `harnessRoot()`: a writer that can be aimed by an env var is how #141
|
|
80
|
+
* happened, and `HARNESS_ROOT` is set by the ship workflow for reasons that
|
|
81
|
+
* have nothing to do with where generated tests belong.
|
|
82
|
+
*/
|
|
83
|
+
export function syncRoot(argv: string[] = process.argv): string {
|
|
84
|
+
const arg = argv[2];
|
|
85
|
+
// `join(dir, "..")` because this file sits in `scripts/`; `harnessRootFor`
|
|
86
|
+
// resolves and validates the path it is handed, it does not search upward.
|
|
87
|
+
return arg ? harnessRootFor(arg) : harnessRootFor(join(import.meta.dir, ".."));
|
|
88
|
+
}
|
|
25
89
|
|
|
26
90
|
function parseTestable(content: string): boolean | null {
|
|
27
91
|
const fmMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
|
@@ -31,13 +95,36 @@ function parseTestable(content: string): boolean | null {
|
|
|
31
95
|
return testableMatch[1] === "true";
|
|
32
96
|
}
|
|
33
97
|
|
|
34
|
-
|
|
35
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Whether a spec makes claims about THIS harness's own workflows (#225).
|
|
100
|
+
*
|
|
101
|
+
* Every claim this script extracts is asserted against `workflows/ship.js` or
|
|
102
|
+
* `workflows/prove.js`, so it only means anything for a spec describing the
|
|
103
|
+
* harness. `specs/bootstrap-data-flow/template-architecture.md` describes what
|
|
104
|
+
* a SCAFFOLDED CONSUMER's files look like, and its `make dev-all` /
|
|
105
|
+
* `make test-rebuild` / `make prove-up` are examples of a consumer Makefile —
|
|
106
|
+
* turning them into "rungate's ship.js must contain this string" is a false
|
|
107
|
+
* assertion about a different project.
|
|
108
|
+
*
|
|
109
|
+
* This was always true; it only started firing when #225 made the collectors
|
|
110
|
+
* recursive and the consumer-facing specs became visible for the first time.
|
|
111
|
+
* The opt-out is frontmatter rather than a path rule so it stays explicit and
|
|
112
|
+
* reviewable, and so making a spec visible to the conformity engine and making
|
|
113
|
+
* it a source of harness claims remain two separate decisions.
|
|
114
|
+
*/
|
|
115
|
+
function parseWorkflowClaims(content: string): boolean {
|
|
116
|
+
const fm = content.match(/^---\n([\s\S]*?)\n---/);
|
|
117
|
+
if (!fm) return true;
|
|
118
|
+
return !/^workflow-claims:\s*false\s*$/m.test(fm[1]);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function discoverTestableSpecs(specsDir: string): { path: string; name: string }[] {
|
|
122
|
+
const files = collectSpecFiles(specsDir); // #225 — subdirectories too
|
|
36
123
|
const testable: { path: string; name: string }[] = [];
|
|
37
124
|
for (const f of files) {
|
|
38
|
-
const fullPath = join(
|
|
125
|
+
const fullPath = join(specsDir, f);
|
|
39
126
|
const content = readFileSync(fullPath, "utf-8");
|
|
40
|
-
if (parseTestable(content) === true) {
|
|
127
|
+
if (parseTestable(content) === true && parseWorkflowClaims(content)) {
|
|
41
128
|
testable.push({ path: fullPath, name: f });
|
|
42
129
|
}
|
|
43
130
|
}
|
|
@@ -54,116 +141,93 @@ interface Claim {
|
|
|
54
141
|
context: string;
|
|
55
142
|
}
|
|
56
143
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
spec_line: lineNum,
|
|
96
|
-
claim: `Gate: ${gateText.slice(0, 80)}`,
|
|
97
|
-
target,
|
|
98
|
-
assertion_type: "contains",
|
|
99
|
-
search_term: gateText.includes("Quinn") ? "quinn" : gateText.includes("Ship gate") ? "ship" : "gate",
|
|
100
|
-
context: line.trim().slice(0, 100),
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Port references in context of specific tools
|
|
105
|
-
const portMatch = line.match(/:(\d{4})\b/);
|
|
106
|
-
if (portMatch) {
|
|
107
|
-
const port = portMatch[1];
|
|
108
|
-
if (["7776", "7777", "7778", "5173"].includes(port)) {
|
|
109
|
-
// Determine which file should reference this port
|
|
110
|
-
const isProveSection = lines.slice(Math.max(0, i - 20), i).some(l => /Step 4.*PROVE|PROVE.*post-merge/i.test(l));
|
|
111
|
-
const target = isProveSection ? "prove" : "ship";
|
|
112
|
-
claims.push({
|
|
113
|
-
id: `AUTO-PORT-${++claimCounter}`,
|
|
114
|
-
spec_line: lineNum,
|
|
115
|
-
claim: `Port ${port} referenced in ${isProveSection ? "PROVE" : "SHIP"} context`,
|
|
116
|
-
target,
|
|
117
|
-
assertion_type: "port",
|
|
118
|
-
search_term: port,
|
|
119
|
-
context: line.trim().slice(0, 100),
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// Quinn + action verb patterns
|
|
125
|
-
const quinnMatch = line.match(/Quinn\s+(validates|captures|tests|navigates|compares|verifies)/i);
|
|
126
|
-
if (quinnMatch) {
|
|
127
|
-
const action = quinnMatch[1].toLowerCase();
|
|
128
|
-
const isProveSection = lines.slice(Math.max(0, i - 20), i).some(l => /Step 4.*PROVE|PROVE.*post-merge/i.test(l));
|
|
129
|
-
const target = isProveSection ? "prove" : "ship";
|
|
130
|
-
claims.push({
|
|
131
|
-
id: `AUTO-QUINN-${++claimCounter}`,
|
|
132
|
-
spec_line: lineNum,
|
|
133
|
-
claim: `Quinn ${action} in ${isProveSection ? "PROVE" : "SHIP"}`,
|
|
134
|
-
target,
|
|
135
|
-
assertion_type: "contains",
|
|
136
|
-
search_term: "quinn",
|
|
137
|
-
context: line.trim().slice(0, 100),
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Deduplicate by search_term + target
|
|
143
|
-
const seen = new Set<string>();
|
|
144
|
-
return claims.filter(c => {
|
|
145
|
-
const key = `${c.target}:${c.assertion_type}:${c.search_term}`;
|
|
146
|
-
if (seen.has(key)) return false;
|
|
147
|
-
seen.add(key);
|
|
148
|
-
return true;
|
|
149
|
-
});
|
|
144
|
+
/**
|
|
145
|
+
* #277/#343 — this emitted twelve assertions, every one of which was a bare
|
|
146
|
+
* substring presence check against a 4,000-line workflow file.
|
|
147
|
+
*
|
|
148
|
+
* Four claim shapes were extracted from spec prose — \`make x\`, \`**GATE:**\`,
|
|
149
|
+
* a port number, and "Quinn <verb>" — and each became
|
|
150
|
+
* \`expect(SHIP_JS.toLowerCase()).toContain(<search_term>)\` where the search
|
|
151
|
+
* term was a generic word lifted out of the sentence. Counted in ship.js:
|
|
152
|
+
*
|
|
153
|
+
* "gate" 196 occurrences
|
|
154
|
+
* "ship" 264
|
|
155
|
+
* "quinn" 94
|
|
156
|
+
* "rebuild" 17
|
|
157
|
+
* "x" 563 <- from the literal spec phrase \`make x\`
|
|
158
|
+
*
|
|
159
|
+
* None of them could fail. Not "unlikely to fail" — the terms are structural
|
|
160
|
+
* vocabulary of the file being searched, so the assertions were true before
|
|
161
|
+
* the spec sentence existed and would stay true if the behaviour were
|
|
162
|
+
* deleted. Twelve named checks, zero measurement, counted in the suite total
|
|
163
|
+
* and in every compliance report.
|
|
164
|
+
*
|
|
165
|
+
* Found because an SC line added in #343 — about REMOVING a hardcoded
|
|
166
|
+
* \`make rebuild\` — matched the \`make x\` shape and generated a thirteenth
|
|
167
|
+
* test asserting ship.js contains "rebuild". A spec sentence describing the
|
|
168
|
+
* deletion of a thing generated a test demanding its presence.
|
|
169
|
+
*
|
|
170
|
+
* Removed rather than weakened, which is what #315 did with
|
|
171
|
+
* \`evidence-target-valid\` for the same reason: a name in a report with
|
|
172
|
+
* nothing behind it is worse than an absence, because the absence is visible.
|
|
173
|
+
* Rebuilding spec-claim extraction with assertions that can fail is real
|
|
174
|
+
* work with a real design question behind it — what IS the checkable content
|
|
175
|
+
* of "Spec requires make rebuild"? — and it is not done by keeping these.
|
|
176
|
+
*
|
|
177
|
+
* \`test/spec-compliance-config.test.ts\` holds the hand-written checks that
|
|
178
|
+
* used to live in the generated file and are genuinely load-bearing.
|
|
179
|
+
*/
|
|
180
|
+
function extractClaims(_spec: string): Claim[] {
|
|
181
|
+
return [];
|
|
150
182
|
}
|
|
151
183
|
|
|
152
184
|
function generateTest(claims: Claim[]): string {
|
|
185
|
+
// No claims means no file worth importing: the header alone would read
|
|
186
|
+
// `workflows/ship.js` at module scope to populate two constants nothing
|
|
187
|
+
// uses, so a missing workflow file would fail a suite that asserts nothing.
|
|
188
|
+
if (claims.length === 0) {
|
|
189
|
+
return [
|
|
190
|
+
`// AUTO-GENERATED by scripts/sync-spec-tests.ts — do not edit manually`,
|
|
191
|
+
`// Regenerate: bun scripts/sync-spec-tests.ts`,
|
|
192
|
+
``,
|
|
193
|
+
`// No generated claims. extractClaims returns nothing on purpose — see the`,
|
|
194
|
+
`// docblock above it in scripts/sync-spec-tests.ts. The twelve assertions`,
|
|
195
|
+
`// this file used to hold were bare substring checks for words like "gate"`,
|
|
196
|
+
`// and "ship" against a file containing them 196 and 264 times.`,
|
|
197
|
+
`//`,
|
|
198
|
+
`// Hand-written spec-compliance checks live in`,
|
|
199
|
+
`// test/spec-compliance-config.test.ts and test/spec-compliance.test.ts.`,
|
|
200
|
+
``,
|
|
201
|
+
].join("\n");
|
|
202
|
+
}
|
|
203
|
+
|
|
153
204
|
const shipClaims = claims.filter(c => c.target === "ship" || c.target === "both");
|
|
154
205
|
const proveClaims = claims.filter(c => c.target === "prove" || c.target === "both");
|
|
155
206
|
|
|
156
207
|
const lines: string[] = [
|
|
157
208
|
`// AUTO-GENERATED by scripts/sync-spec-tests.ts — do not edit manually`,
|
|
158
209
|
`// Regenerate: bun scripts/sync-spec-tests.ts`,
|
|
159
|
-
`// Source:
|
|
210
|
+
`// Source: specs/ (every spec with testable: true)`,
|
|
160
211
|
`// Generated: ${new Date().toISOString().split("T")[0]}`,
|
|
161
212
|
``,
|
|
162
213
|
`import { test, expect, describe } from "bun:test";`,
|
|
163
214
|
`import { readFileSync } from "fs";`,
|
|
215
|
+
`import { join } from "path";`,
|
|
216
|
+
`import { harnessRootFor } from "../lib/paths";`,
|
|
164
217
|
``,
|
|
165
|
-
|
|
166
|
-
|
|
218
|
+
`// Resolved at run time, not baked in: an absolute path written by whoever`,
|
|
219
|
+
`// last ran the generator makes the file unrunnable anywhere else, CI`,
|
|
220
|
+
`// included.`,
|
|
221
|
+
`//`,
|
|
222
|
+
`// Resolved from THIS file's own location, not from the implicit`,
|
|
223
|
+
`// module-relative root (#190). These cases grade workflows/ship.js, and`,
|
|
224
|
+
`// the implicit root honours HARNESS_ROOT — so a run with it set read a`,
|
|
225
|
+
`// different checkout's ship.js than the one this file was generated`,
|
|
226
|
+
`// from. A generated test grading a tree it does not belong to reports`,
|
|
227
|
+
`// failures that exist in nobody's checkout.`,
|
|
228
|
+
`const HR = harnessRootFor(join(import.meta.dir, ".."));`,
|
|
229
|
+
`const SHIP_JS = readFileSync(join(HR, "workflows/ship.js"), "utf-8");`,
|
|
230
|
+
`const PROVE_JS = readFileSync(join(HR, "workflows/prove.js"), "utf-8");`,
|
|
167
231
|
``,
|
|
168
232
|
];
|
|
169
233
|
|
|
@@ -209,28 +273,49 @@ function generateTest(claims: Claim[]): string {
|
|
|
209
273
|
return lines.join("\n") + "\n";
|
|
210
274
|
}
|
|
211
275
|
|
|
212
|
-
// Main — glob scan all testable specs
|
|
213
|
-
|
|
214
|
-
|
|
276
|
+
// Main — glob scan all testable specs.
|
|
277
|
+
//
|
|
278
|
+
// Behind `import.meta.main` so importing this module for its pure path
|
|
279
|
+
// helpers does not rewrite a test file as a side effect of the import. The
|
|
280
|
+
// test that covers resolveSyncPaths does exactly that import, and without
|
|
281
|
+
// this guard it regenerated the suite's own source mid-run.
|
|
282
|
+
export function main(root: string) {
|
|
283
|
+
const { specsDir: SPECS_DIR, outputPath: OUTPUT_PATH } = resolveSyncPaths(root);
|
|
284
|
+
|
|
285
|
+
// Fail loudly on a missing spec directory. The previous version could not:
|
|
286
|
+
// `~/.claude/PAI/Specs` happened to exist, so reading the wrong tree looked
|
|
287
|
+
// exactly like reading the right one.
|
|
288
|
+
if (!existsSync(SPECS_DIR)) {
|
|
289
|
+
console.error(
|
|
290
|
+
`sync-spec-tests: no spec directory at ${SPECS_DIR}\n` +
|
|
291
|
+
` (harness root given as ${root} — pass the root as argv[2] if that is wrong)`,
|
|
292
|
+
);
|
|
293
|
+
process.exit(1);
|
|
294
|
+
}
|
|
215
295
|
|
|
216
|
-
|
|
296
|
+
const testableSpecs = discoverTestableSpecs(SPECS_DIR);
|
|
297
|
+
const allFiles = collectSpecFiles(SPECS_DIR); // #225 — subdirectories too
|
|
217
298
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
299
|
+
console.log(`Spec discovery: ${allFiles.length} specs scanned, ${testableSpecs.length} testable`);
|
|
300
|
+
|
|
301
|
+
let allClaims: Claim[] = [];
|
|
302
|
+
for (const spec of testableSpecs) {
|
|
303
|
+
const content = readFileSync(spec.path, "utf-8");
|
|
304
|
+
const claims = extractClaims(content);
|
|
305
|
+
allClaims = allClaims.concat(claims);
|
|
306
|
+
console.log(` ${spec.name}: ${claims.length} claims`);
|
|
307
|
+
}
|
|
225
308
|
|
|
226
|
-
|
|
227
|
-
writeFileSync(OUTPUT_PATH, testContent);
|
|
309
|
+
writeFileSync(OUTPUT_PATH, generateTest(allClaims));
|
|
228
310
|
|
|
229
|
-
console.log(`\nTotal: ${allClaims.length} claims extracted`);
|
|
230
|
-
console.log(` ship.js: ${allClaims.filter(c => c.target === "ship").length}`);
|
|
231
|
-
console.log(` prove.js: ${allClaims.filter(c => c.target === "prove").length}`);
|
|
232
|
-
console.log(`Written to: ${OUTPUT_PATH}`);
|
|
311
|
+
console.log(`\nTotal: ${allClaims.length} claims extracted`);
|
|
312
|
+
console.log(` ship.js: ${allClaims.filter(c => c.target === "ship").length}`);
|
|
313
|
+
console.log(` prove.js: ${allClaims.filter(c => c.target === "prove").length}`);
|
|
314
|
+
console.log(`Written to: ${OUTPUT_PATH}`);
|
|
233
315
|
|
|
234
|
-
for (const c of allClaims) {
|
|
235
|
-
|
|
316
|
+
for (const c of allClaims) {
|
|
317
|
+
console.log(` ${c.id} [${c.target}] L${c.spec_line}: ${c.claim}`);
|
|
318
|
+
}
|
|
236
319
|
}
|
|
320
|
+
|
|
321
|
+
if (import.meta.main) main(syncRoot());
|