rungate 0.2.0 → 0.2.1

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 (164) hide show
  1. package/package.json +14 -3
  2. package/.claude/agents/aditi.md +0 -47
  3. package/.claude/agents/marcus.md +0 -50
  4. package/.claude/agents/quinn.md +0 -58
  5. package/.claude/agents/rook.md +0 -47
  6. package/.claude/agents/serena.md +0 -46
  7. package/.claude/rungate.json +0 -11
  8. package/.fallowrc.json +0 -28
  9. package/.github/copilot-instructions.md +0 -20
  10. package/.rungate/conformity-findings.json +0 -648
  11. package/AGENTS.md +0 -106
  12. package/CODE-MAP.md +0 -50
  13. package/HARNESS.md +0 -88
  14. package/bun.lock +0 -26
  15. package/bunfig.toml +0 -2
  16. package/config/brief-policies.json +0 -28
  17. package/config/ceremony-profiles.json +0 -212
  18. package/config/consumer-cascade-map.json +0 -24
  19. package/config/doc-cascade-map.json +0 -24
  20. package/config/eval.json +0 -84
  21. package/config/profiles/account-plan.yaml +0 -36
  22. package/config/profiles/campaign.yaml +0 -94
  23. package/config/prove-evidence.schema.json +0 -65
  24. package/config/spec-policies.json +0 -36
  25. package/config/workflow-schema.json +0 -281
  26. package/gates/SCHEMA-GUIDE.md +0 -121
  27. package/gates/ac-quality.test.ts +0 -106
  28. package/gates/adversarial.test.ts +0 -274
  29. package/gates/brief-assembler.test.ts +0 -429
  30. package/gates/brief-assembler.ts +0 -334
  31. package/gates/bunfig.toml +0 -2
  32. package/gates/chain.test.ts +0 -91
  33. package/gates/e2e-smoke.test.ts +0 -234
  34. package/gates/error-classifier.test.ts +0 -249
  35. package/gates/error-classifier.ts +0 -89
  36. package/gates/orchestrator.test.ts +0 -950
  37. package/gates/orchestrator.ts +0 -569
  38. package/gates/preload.ts +0 -77
  39. package/gates/prompts/ac-adversary.md +0 -20
  40. package/gates/prompts/evidence-validator.md +0 -22
  41. package/gates/prompts/prove-reproducer.md +0 -53
  42. package/gates/prove.test.ts +0 -164
  43. package/gates/run-gate.ts +0 -936
  44. package/gates/schema-parity.test.ts +0 -197
  45. package/gates/schema.ts +0 -362
  46. package/gates/self-heal.test.ts +0 -511
  47. package/gates/self-heal.ts +0 -121
  48. package/gates/ship-orchestrator.test.ts +0 -379
  49. package/gates/ship-orchestrator.ts +0 -363
  50. package/gates/test-fixtures/broken-no-environments.json +0 -60
  51. package/gates/test-fixtures/valid-standard.json +0 -54
  52. package/gates/test-utils.ts +0 -43
  53. package/gates/witness.ts +0 -220
  54. package/gates/workflow.test.ts +0 -1053
  55. package/hooks/AgentBriefGuard.hook.ts +0 -586
  56. package/hooks/AgentVerdictCapture.hook.ts +0 -134
  57. package/hooks/AutoVerifyGate.hook.ts +0 -76
  58. package/hooks/GateEnforcement.hook.ts +0 -273
  59. package/hooks/IssueCloseGuard.hook.ts +0 -116
  60. package/hooks/MergeGuard.hook.ts +0 -55
  61. package/hooks/StaleTTLCleanup.hook.ts +0 -133
  62. package/hooks/VerifyPhaseLock.hook.ts +0 -81
  63. package/hooks/WorkflowStateGuard.hook.ts +0 -37
  64. package/hooks/lib/agentDetection.ts +0 -70
  65. package/hooks/lib/findWorkflow.ts +0 -101
  66. package/hooks/lib/parseStdin.ts +0 -37
  67. package/hooks/lib/paths.ts +0 -111
  68. package/hooks/lib/utils.ts +0 -81
  69. package/reference/migration-manifest.json +0 -554
  70. package/reference/prompts/agent-aditi.md +0 -38
  71. package/reference/prompts/agent-marcus.md +0 -38
  72. package/reference/prompts/agent-quinn.md +0 -38
  73. package/reference/prompts/agent-rook.md +0 -37
  74. package/reference/prompts/agent-serena.md +0 -37
  75. package/reference/prompts/council-skill.md +0 -170
  76. package/reference/prompts/goal-skill.md +0 -235
  77. package/reference/prompts/prove-skill.md +0 -283
  78. package/reference/prompts/quinn-standard.md +0 -246
  79. package/reference/prompts/ship-convergence.md +0 -65
  80. package/reference/prompts/ship-escalation.md +0 -43
  81. package/reference/prompts/ship-iteration.md +0 -382
  82. package/reference/prompts/ship-pending-patches.md +0 -246
  83. package/reference/prompts/ship-reference.md +0 -250
  84. package/reference/prompts/ship-skill.md +0 -347
  85. package/reference/prompts/ship-templates.md +0 -215
  86. package/reference/scripts/batch-status.sh +0 -68
  87. package/reference/scripts/chain-compat-check.sh +0 -67
  88. package/reference/scripts/context-audit.sh +0 -314
  89. package/reference/scripts/dead-export-check.sh +0 -61
  90. package/reference/scripts/generate-qc-tables.sh +0 -92
  91. package/reference/scripts/harness-init.sh +0 -111
  92. package/reference/scripts/pai-054-baseline-check.sh +0 -40
  93. package/reference/scripts/prove-smoke-test.sh +0 -112
  94. package/reference/scripts/setup-keychain-salt.sh +0 -12
  95. package/reference/scripts/skill-optimizer-friday.sh +0 -88
  96. package/reference/scripts/skill-qc-test.sh +0 -351
  97. package/reference/scripts/skill-synthesize-tonight.sh +0 -66
  98. package/reference/specs/HARNESS-EXTRACTION-SPEC.md +0 -263
  99. package/reference/specs/harness-v3-bash-deletion-plan.md +0 -65
  100. package/reference/specs/harness-v3-migration-plan.md +0 -188
  101. package/scripts/decision-reconcile.sh +0 -74
  102. package/scripts/decision-reconcile.ts +0 -152
  103. package/scripts/git-hooks/pre-commit +0 -76
  104. package/scripts/git-hooks/pre-push +0 -271
  105. package/scripts/harness-skill-check.sh +0 -52
  106. package/scripts/lib/gap-emit.sh +0 -65
  107. package/scripts/lib/jq-update.sh +0 -30
  108. package/scripts/lib/resolve-slug.sh +0 -30
  109. package/scripts/lib/verify-spec-compliance.sh +0 -102
  110. package/scripts/prove-backfill.sh +0 -87
  111. package/scripts/scaffold-rungate-config.ts +0 -91
  112. package/scripts/self-containment-check.sh +0 -109
  113. package/scripts/skill-qc-validator.sh +0 -402
  114. package/scripts/slug-resolver.sh +0 -14
  115. package/specs/BOOTSTRAP-DATA-FLOW-SPEC.md +0 -2493
  116. package/specs/BOOTSTRAP-TEST-PLAN.md +0 -571
  117. package/specs/HARNESS-GATES.md +0 -256
  118. package/specs/HARNESS-SKILL-CHAIN.md +0 -286
  119. package/specs/HARNESS-SKILL-CONTRACT.md +0 -93
  120. package/specs/HARNESS-STANDARD.md +0 -488
  121. package/specs/SPEC-TEMPLATE.md +0 -53
  122. package/specs/bootstrap-data-flow.png +0 -0
  123. package/specs/harness-automation-matrix.md +0 -314
  124. package/specs/harness-automation-matrix.rules.json +0 -64
  125. package/test/anti.test.ts +0 -80
  126. package/test/contract-negative.test.ts +0 -86
  127. package/test/contract.test.ts +0 -158
  128. package/test/external-deps.test.ts +0 -48
  129. package/test/fixtures/golden-project/.env.example +0 -3
  130. package/test/fixtures/golden-project/Makefile +0 -7
  131. package/test/fixtures/golden-project/docs/adr/ADR-001-framework.md +0 -23
  132. package/test/fixtures/golden-project/docs/setup-guide.md +0 -10
  133. package/test/fixtures/golden-project/package.json +0 -10
  134. package/test/fixtures/golden-project/specs/api-spec.md +0 -20
  135. package/test/fixtures/golden-project/src/auth.ts +0 -8
  136. package/test/fixtures/golden-project/src/db.ts +0 -11
  137. package/test/fixtures/golden-project/src/index.ts +0 -19
  138. package/test/fixtures/golden-project/src/utils/format.ts +0 -3
  139. package/test/fixtures/golden-project/test/auth.test.ts +0 -15
  140. package/test/fixtures/golden-project/tsconfig.json +0 -12
  141. package/test/meta-sc-coverage.test.ts +0 -159
  142. package/test/phase-0.test.ts +0 -846
  143. package/test/phase-1.test.ts +0 -617
  144. package/test/phase-2.test.ts +0 -620
  145. package/test/phase-3.test.ts +0 -99
  146. package/test/scaffold-conformity.test.ts +0 -8
  147. package/test/schema-canary.test.ts +0 -51
  148. package/test/spec-compliance-auto.test.ts +0 -64
  149. package/test/spec-compliance.test.ts +0 -295
  150. package/test/spec-discovery.test.ts +0 -68
  151. package/test/spec-drift.test.ts +0 -5
  152. package/test/structure.test.ts +0 -165
  153. package/test/unit/agent-brief-guard-ship.test.ts +0 -293
  154. package/test/unit/extract-constraints.test.ts +0 -145
  155. package/test/unit/issue-close-guard.test.ts +0 -204
  156. package/test/unit/scaffold-project.test.ts +0 -417
  157. package/test/unit/skill-cooccurrence.test.ts +0 -177
  158. package/test/unit/skill-sequence-logger.test.ts +0 -244
  159. package/test/unit/workflow-state-guard.test.ts +0 -95
  160. package/workflows/batch-ship.js +0 -295
  161. package/workflows/council.js +0 -481
  162. package/workflows/prove.js +0 -560
  163. package/workflows/ship.js +0 -789
  164. package/workflows/verify.js +0 -236
@@ -1,620 +0,0 @@
1
- import { test, expect, describe, beforeAll } from "bun:test";
2
- import { existsSync, readFileSync, mkdirSync, writeFileSync } from "fs";
3
- import { execSync } from "child_process";
4
- import { join } from "path";
5
-
6
- const HARNESS = join(import.meta.dir, "..");
7
- const GATES = join(HARNESS, "gates");
8
- const PROMPTS = join(HARNESS, "prompts");
9
-
10
- // Phase 2 tests gate enforcement, brief assembly, evidence validation,
11
- // and ship-cycle behavior. Most of these test code in gates/ and lib/.
12
-
13
- describe("Phase 2: Gate Enforcement + Ship Behavior", () => {
14
-
15
- // SC-7: Container-rebuild agent NOT spawned when prod.rebuild is null
16
- describe("SC-7: null prod.rebuild skips container", () => {
17
- test("ship orchestrator skips container rebuild when prod.rebuild is null", () => {
18
- const orchestrator = join(GATES, "ship-orchestrator.ts");
19
- if (existsSync(orchestrator)) {
20
- const content = readFileSync(orchestrator, "utf-8");
21
- expect(content).toMatch(/prod\.rebuild|rebuild.*null|skip.*rebuild/i);
22
- } else {
23
- expect(existsSync(orchestrator)).toBe(true);
24
- }
25
- });
26
- });
27
-
28
- // SC-9: rungate-schema.ts includes test fields
29
- describe("SC-9: schema test fields", () => {
30
- test("schema has test section fields", () => {
31
- const schema = readFileSync(join(HARNESS, "lib/rungate-schema.ts"), "utf-8");
32
- expect(schema).toContain("TestSchema");
33
- expect(schema).toMatch(/start.*optional|apiBase/);
34
- });
35
- });
36
-
37
- // SC-10: Schema fields read by at least one workflow
38
- describe("SC-10: schema fields consumed", () => {
39
- test("dev.typeCheck referenced in workflow code", () => {
40
- const files = ["gates/run-gate.ts", "gates/ship-orchestrator.ts", "gates/orchestrator.ts"]
41
- .map(f => join(HARNESS, f))
42
- .filter(f => existsSync(f));
43
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
44
- expect(content).toMatch(/typeCheck|tsc/);
45
- });
46
- });
47
-
48
- // SC-28: Scope gate runs conformity tests — FAIL blocks scope
49
- describe("SC-28: scope gate conformity", () => {
50
- test("run-gate.ts runs conformity at scope", () => {
51
- const gateRunner = join(GATES, "run-gate.ts");
52
- if (existsSync(gateRunner)) {
53
- const content = readFileSync(gateRunner, "utf-8");
54
- expect(content).toMatch(/scope|conformity|bun test/i);
55
- } else {
56
- expect(existsSync(gateRunner)).toBe(true);
57
- }
58
- });
59
- });
60
-
61
- // SC-29: Verify gate runs conformity tests — FAIL blocks verify
62
- describe("SC-29: verify gate conformity", () => {
63
- test("run-gate.ts runs conformity at verify", () => {
64
- const gateRunner = join(GATES, "run-gate.ts");
65
- if (existsSync(gateRunner)) {
66
- const content = readFileSync(gateRunner, "utf-8");
67
- expect(content).toMatch(/verify|conformity/i);
68
- } else {
69
- expect(existsSync(gateRunner)).toBe(true);
70
- }
71
- });
72
- });
73
-
74
- // SC-31: Scope gate captures test baseline
75
- describe("SC-31: test baseline capture", () => {
76
- test("schema supports testBaseline field", () => {
77
- const schema = readFileSync(join(GATES, "schema.ts"), "utf-8");
78
- expect(schema).toContain("testBaseline");
79
- });
80
- });
81
-
82
- // SC-32: Verify gate compares test count — fail increase = regression
83
- describe("SC-32: test count regression check", () => {
84
- test("gate logic compares test counts", () => {
85
- const files = ["gates/run-gate.ts", "gates/workflow.test.ts", "gates/orchestrator.ts"]
86
- .map(f => join(HARNESS, f))
87
- .filter(f => existsSync(f));
88
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
89
- expect(content).toMatch(/baseline|regression|fail.*count|test.*count/i);
90
- });
91
- });
92
-
93
- // SC-33: Pre-existing test failures auto-filed as GitHub issues
94
- describe("SC-33: pre-existing failure filing", () => {
95
- test("gate or orchestrator handles pre-existing failures", () => {
96
- const files = ["gates/run-gate.ts", "gates/orchestrator.ts", "gates/ship-orchestrator.ts"]
97
- .map(f => join(HARNESS, f))
98
- .filter(f => existsSync(f));
99
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
100
- expect(content).toMatch(/pre.existing|existing.*fail|baseline.*fail/i);
101
- });
102
- });
103
-
104
- // SC-34: Found issues either fixed, filed, or scoped out
105
- describe("SC-34: fix-on-find tracking", () => {
106
- test("workflow state tracks found issues disposition", () => {
107
- const schema = readFileSync(join(GATES, "schema.ts"), "utf-8");
108
- expect(schema).toMatch(/found|issue|filed|scoped/i);
109
- });
110
- });
111
-
112
- // SC-35: create-spec creates spec with frontmatter
113
- describe("SC-35: create-spec command", () => {
114
- test("create-spec script or function exists", () => {
115
- const hasScript = existsSync(join(HARNESS, "scripts/create-spec.ts"));
116
- const scaffoldHasIt = readFileSync(join(HARNESS, "scripts/scaffold-project.ts"), "utf-8").includes("create-spec");
117
- expect(hasScript || scaffoldHasIt).toBe(true);
118
- });
119
- });
120
-
121
- // SC-36: create-adr with auto-incremented number
122
- describe("SC-36: create-adr command", () => {
123
- test("create-adr script or function exists", () => {
124
- const hasScript = existsSync(join(HARNESS, "scripts/create-adr.ts"));
125
- const scaffoldHasIt = readFileSync(join(HARNESS, "scripts/scaffold-project.ts"), "utf-8").includes("create-adr");
126
- expect(hasScript || scaffoldHasIt).toBe(true);
127
- });
128
- });
129
-
130
- // SC-38: Ship cycle runs scaffold after verify PASS
131
- describe("SC-38: post-verify scaffold refresh", () => {
132
- test("ship orchestrator calls scaffold after verify", () => {
133
- const orchestrator = join(GATES, "ship-orchestrator.ts");
134
- if (existsSync(orchestrator)) {
135
- const content = readFileSync(orchestrator, "utf-8");
136
- expect(content).toMatch(/scaffold|refresh|code.map/i);
137
- } else {
138
- expect(existsSync(orchestrator)).toBe(true);
139
- }
140
- });
141
- });
142
-
143
- // SC-41: Secret scan in conformity (HYGIENE-12)
144
- describe("SC-41: HYGIENE-12 secret scan", () => {
145
- test("conformity or gate checks for secret patterns", () => {
146
- const conformity = readFileSync(join(HARNESS, "lib/conformity.ts"), "utf-8");
147
- const gatesYml = existsSync(join(HARNESS, "scripts/scaffold-project.ts"))
148
- ? readFileSync(join(HARNESS, "scripts/scaffold-project.ts"), "utf-8") : "";
149
- const combined = conformity + gatesYml;
150
- expect(combined).toMatch(/AKIA|sk-|ghp_|secret|credential|password/i);
151
- });
152
- });
153
-
154
- // SC-42: Completed slugs auto-archived after 24h
155
- describe("SC-42: slug auto-archive", () => {
156
- test("orchestrator or gate handles slug archival", () => {
157
- const files = ["gates/orchestrator.ts", "gates/run-gate.ts"]
158
- .map(f => join(HARNESS, f))
159
- .filter(f => existsSync(f));
160
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
161
- expect(content).toMatch(/archive|DONE|slug.*clean/i);
162
- });
163
- });
164
-
165
- // SC-43: Archived slugs deleted after 30 days
166
- describe("SC-43: stale slug cleanup", () => {
167
- test("cleanup mechanism for old slugs", () => {
168
- const files = ["gates/orchestrator.ts", "gates/run-gate.ts"]
169
- .map(f => join(HARNESS, f))
170
- .filter(f => existsSync(f));
171
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
172
- expect(content).toMatch(/delete|cleanup|30.*day|stale.*slug/i);
173
- });
174
- });
175
-
176
- // SC-44: Ship checks for existing slug before creating new
177
- describe("SC-44: duplicate slug prevention", () => {
178
- test("orchestrator checks for existing slug", () => {
179
- const files = ["gates/orchestrator.ts", "gates/ship-orchestrator.ts"]
180
- .map(f => join(HARNESS, f))
181
- .filter(f => existsSync(f));
182
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
183
- expect(content).toMatch(/existing.*slug|slug.*exist|slugExists|duplicate/i);
184
- });
185
- });
186
-
187
- // SC-48: ACs use Given/When/Then format
188
- describe("SC-48: AC format validation", () => {
189
- test("AC schema or quality test validates format", () => {
190
- const files = ["gates/ac-quality.test.ts", "gates/schema.ts"]
191
- .map(f => join(HARNESS, f))
192
- .filter(f => existsSync(f));
193
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
194
- expect(content).toMatch(/trigger|verify.*command|exclusion|Given|When|Then/i);
195
- });
196
- });
197
-
198
- // SC-49: Every AC has executable verification command
199
- describe("SC-49: AC verification command", () => {
200
- test("schema requires verification command or evidenceMethod", () => {
201
- const schema = readFileSync(join(GATES, "schema.ts"), "utf-8");
202
- expect(schema).toMatch(/evidenceMethod|command/);
203
- });
204
- });
205
-
206
- // SC-50: Evidence hierarchy enforced per AC
207
- describe("SC-50: evidence tier enforcement", () => {
208
- test("evidence types are enumerated in schema", () => {
209
- const schema = readFileSync(join(GATES, "schema.ts"), "utf-8");
210
- expect(schema).toMatch(/file-citation|grep-output|api-response|screenshot|test-output|command-output|manual-attestation/);
211
- });
212
- });
213
-
214
- // SC-51: Self-attestation (tier F) = automatic FAIL
215
- describe("SC-51: self-attestation FAIL", () => {
216
- test("manual-attestation type exists in schema", () => {
217
- const schema = readFileSync(join(GATES, "schema.ts"), "utf-8");
218
- expect(schema).toContain("manual-attestation");
219
- });
220
- });
221
-
222
- // SC-52: Garbage test applied to every AC
223
- describe("SC-52: AC garbage test", () => {
224
- test("ac-quality test checks for garbage-passable ACs", () => {
225
- const acQuality = join(GATES, "ac-quality.test.ts");
226
- if (existsSync(acQuality)) {
227
- const content = readFileSync(acQuality, "utf-8");
228
- expect(content).toMatch(/garbage|weak|vague|behavioral/i);
229
- } else {
230
- expect(existsSync(acQuality)).toBe(true);
231
- }
232
- });
233
- });
234
-
235
- // SC-53: RCA section in Marcus brief for bug-fix issues
236
- describe("SC-53: RCA in bug-fix briefs", () => {
237
- test("brief-assembler includes RCA for bug-fix type", () => {
238
- const assembler = join(GATES, "brief-assembler.ts");
239
- if (existsSync(assembler)) {
240
- const content = readFileSync(assembler, "utf-8");
241
- expect(content).toMatch(/rca|rootCause|root.cause|bug.fix/i);
242
- } else {
243
- expect(existsSync(assembler)).toBe(true);
244
- }
245
- });
246
- });
247
-
248
- // SC-54: Gate checks RCA fields on bug-fix issues
249
- describe("SC-54: RCA gate check", () => {
250
- test("gate validates RCA fields", () => {
251
- const files = ["gates/run-gate.ts", "gates/workflow.test.ts"]
252
- .map(f => join(HARNESS, f))
253
- .filter(f => existsSync(f));
254
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
255
- expect(content).toMatch(/rootCause|rca|root.*cause/i);
256
- });
257
- });
258
-
259
- // SC-55: Quinn briefs use typed journey format
260
- describe("SC-55: Quinn journey format", () => {
261
- test("schema or brief-assembler defines journey structure", () => {
262
- const files = ["gates/schema.ts", "gates/brief-assembler.ts"]
263
- .map(f => join(HARNESS, f))
264
- .filter(f => existsSync(f));
265
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
266
- expect(content).toMatch(/journey|action.*wait_for|assertion.*on_fail/i);
267
- });
268
- });
269
-
270
- // SC-56: Quinn perception — browser_snapshot primary
271
- describe("SC-56: Quinn perception hierarchy", () => {
272
- test("quinn prompt or brief references snapshot perception", () => {
273
- const quinnPrompt = join(PROMPTS, "quinn.md");
274
- const quinnDecision = join(PROMPTS, "quinn-decision-tree.md");
275
- const paths = [quinnPrompt, quinnDecision].filter(f => existsSync(f));
276
- if (paths.length > 0) {
277
- const content = paths.map(f => readFileSync(f, "utf-8")).join("\n");
278
- expect(content).toMatch(/snapshot|a11y|accessibility.*tree/i);
279
- } else {
280
- expect(paths.length).toBeGreaterThan(0);
281
- }
282
- });
283
- });
284
-
285
- // SC-57: Quinn circuit breaker — 3 consecutive FAILs
286
- describe("SC-57: Quinn circuit breaker", () => {
287
- test("circuit breaker threshold defined", () => {
288
- const files = ["gates/schema.ts", "prompts/quinn-decision-tree.md"]
289
- .map(f => join(HARNESS, f))
290
- .filter(f => existsSync(f));
291
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
292
- expect(content).toMatch(/circuit.*breaker|3.*consecutive|abort.*journey/i);
293
- });
294
- });
295
-
296
- // SC-58: Proof-of-fix includes negative control
297
- describe("SC-58: negative control for S-tier", () => {
298
- test("prove gate or prompt references negative control", () => {
299
- const files = ["gates/prove.test.ts", "gates/prompts/prove-reproducer.md"]
300
- .map(f => join(HARNESS, f))
301
- .filter(f => existsSync(f));
302
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
303
- expect(content).toMatch(/negative.*control|revert.*fix|confirm.*bug.*return/i);
304
- });
305
- });
306
-
307
- // SC-59: Blast radius — filesRead ≥ filesChanged
308
- describe("SC-59: blast radius enforcement", () => {
309
- test("gate checks filesRead vs filesChanged", () => {
310
- const files = ["gates/run-gate.ts", "gates/workflow.test.ts", "gates/orchestrator.ts"]
311
- .map(f => join(HARNESS, f))
312
- .filter(f => existsSync(f));
313
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
314
- expect(content).toMatch(/filesRead|filesChanged|blast.*radius|read.*write.*ratio/i);
315
- });
316
- });
317
-
318
- // SC-60: Read-before-write ratio ≥ 3:1
319
- describe("SC-60: read-before-write ratio", () => {
320
- test("gate enforces read/write ratio", () => {
321
- const files = ["gates/run-gate.ts", "gates/workflow.test.ts"]
322
- .map(f => join(HARNESS, f))
323
- .filter(f => existsSync(f));
324
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
325
- expect(content).toMatch(/read.*write|3:1|ratio/i);
326
- });
327
- });
328
-
329
- // SC-61: Brief-assembler generates per-role templates
330
- describe("SC-61: per-role brief generation", () => {
331
- test("brief-assembler handles multiple roles", () => {
332
- const assembler = join(GATES, "brief-assembler.ts");
333
- if (existsSync(assembler)) {
334
- const content = readFileSync(assembler, "utf-8");
335
- expect(content).toMatch(/marcus|quinn|rook|role/i);
336
- } else {
337
- expect(existsSync(assembler)).toBe(true);
338
- }
339
- });
340
- });
341
-
342
- // SC-62: Templates are three-layered
343
- describe("SC-62: three-layer templates", () => {
344
- test("brief-assembler references harness + project + issue layers", () => {
345
- const assembler = join(GATES, "brief-assembler.ts");
346
- if (existsSync(assembler)) {
347
- const content = readFileSync(assembler, "utf-8");
348
- expect(content).toMatch(/harness|project.*config|issue.*specific|layer|rungate\.json|acs/i);
349
- } else {
350
- expect(existsSync(assembler)).toBe(true);
351
- }
352
- });
353
- });
354
-
355
- // SC-63: Spec content hash tracked — mismatch = FAIL
356
- describe("SC-63: spec hash tracking", () => {
357
- test("gate checks spec content hash", () => {
358
- const files = ["gates/run-gate.ts", "gates/e2e-smoke.test.ts"]
359
- .map(f => join(HARNESS, f))
360
- .filter(f => existsSync(f));
361
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
362
- expect(content).toMatch(/hash|sha|spec.*drift|content.*hash/i);
363
- });
364
- });
365
-
366
- // SC-64: Test count post ≥ pre — decrease = FAIL
367
- describe("SC-64: test deletion prevention", () => {
368
- test("gate detects test count decrease", () => {
369
- const files = ["gates/e2e-smoke.test.ts", "gates/workflow.test.ts"]
370
- .map(f => join(HARNESS, f))
371
- .filter(f => existsSync(f));
372
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
373
- expect(content).toMatch(/test.*count|deletion|removed|decrease/i);
374
- });
375
- });
376
-
377
- // SC-65: Prevention-oriented fixes
378
- describe("SC-65: prevention-oriented pattern", () => {
379
- test("prevention template exists or is referenced", () => {
380
- const prevention = join(PROMPTS, "prevention.md");
381
- const hasPrevention = existsSync(prevention);
382
- const assembler = join(GATES, "brief-assembler.ts");
383
- const refsPrevention = existsSync(assembler) && readFileSync(assembler, "utf-8").includes("prevention");
384
- expect(hasPrevention || refsPrevention).toBe(true);
385
- });
386
- });
387
-
388
- // SC-66: Writer and verifier are separate agents
389
- describe("SC-66: writer/verifier separation", () => {
390
- test("gate or schema tracks agent roles", () => {
391
- const files = ["gates/schema.ts", "gates/run-gate.ts", "gates/witness.ts"]
392
- .map(f => join(HARNESS, f))
393
- .filter(f => existsSync(f));
394
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
395
- expect(content).toMatch(/writer|verifier|author.*agent|witness|separate/i);
396
- });
397
- });
398
-
399
- // SC-67: Quinn journey steps auto-generated from UI ACs
400
- describe("SC-67: auto-generated Quinn journeys", () => {
401
- test("brief-assembler generates journey from ACs", () => {
402
- const assembler = join(GATES, "brief-assembler.ts");
403
- if (existsSync(assembler)) {
404
- const content = readFileSync(assembler, "utf-8");
405
- expect(content).toMatch(/journey|quinn|UI|step/i);
406
- } else {
407
- expect(existsSync(assembler)).toBe(true);
408
- }
409
- });
410
- });
411
-
412
- // SC-68: Evidence without assertion = tier F
413
- describe("SC-68: evidence without assertion", () => {
414
- test("schema or gate rejects evidence without assertions", () => {
415
- const schema = readFileSync(join(GATES, "schema.ts"), "utf-8");
416
- expect(schema).toContain("manual-attestation");
417
- });
418
- });
419
-
420
- // SC-79: Conformity includes runPackageValidation
421
- describe("SC-79: runPackageValidation", () => {
422
- test("conformity exports runPackageValidation", () => {
423
- const conformity = readFileSync(join(HARNESS, "lib/conformity.ts"), "utf-8");
424
- expect(conformity).toContain("runPackageValidation");
425
- });
426
- });
427
-
428
- // SC-81: Phase 0 additive — never overwrites existing content
429
- describe("SC-81: additive scaffold", () => {
430
- test("scaffold checks for existing content before writing", () => {
431
- const scaffold = readFileSync(join(HARNESS, "scripts/scaffold-project.ts"), "utf-8");
432
- expect(scaffold).toMatch(/existsSync|exists|append|merge|additive/i);
433
- });
434
- });
435
-
436
- // SC-96: rungate.json mcp section
437
- describe("SC-96: mcp config section", () => {
438
- test("schema supports mcp field", () => {
439
- const schema = readFileSync(join(HARNESS, "lib/rungate-schema.ts"), "utf-8");
440
- expect(schema).toMatch(/mcp/i);
441
- });
442
- });
443
-
444
- // SC-102: Re-scaffold auto-fixes broken refs
445
- describe("SC-102: re-scaffold auto-fix", () => {
446
- test("scaffold handles re-scaffold with fixes", () => {
447
- const scaffold = readFileSync(join(HARNESS, "scripts/scaffold-project.ts"), "utf-8");
448
- expect(scaffold).toMatch(/re.scaffold|update|existing|fix/i);
449
- });
450
- });
451
-
452
- // SC-103: Evidence-to-tier mapping in gate
453
- describe("SC-103: evidence tier mapping", () => {
454
- test("evidence types map to tiers in schema", () => {
455
- const schema = readFileSync(join(GATES, "schema.ts"), "utf-8");
456
- expect(schema).toMatch(/EVIDENCE_METHOD_TYPES|evidence.*type|tier/i);
457
- });
458
- });
459
-
460
- // SC-104: File ownership — harness-owned regenerated, co-owned preserved
461
- describe("SC-104: file ownership model", () => {
462
- test("scaffold distinguishes harness-owned from co-owned", () => {
463
- const scaffold = readFileSync(join(HARNESS, "scripts/scaffold-project.ts"), "utf-8");
464
- expect(scaffold).toMatch(/overwrite|managed|harness.owned|co.owned|preserve|skip/i);
465
- });
466
- });
467
-
468
- // SC-105: Scaffold idempotency
469
- describe("SC-105: scaffold idempotent", () => {
470
- test("scaffold handles existing project", () => {
471
- const scaffold = readFileSync(join(HARNESS, "scripts/scaffold-project.ts"), "utf-8");
472
- expect(scaffold).toMatch(/existsSync|existing|idempotent|re.run/i);
473
- });
474
- });
475
-
476
- // SC-108: Quinn journey stored in slug directory
477
- describe("SC-108: Quinn journey storage", () => {
478
- test("schema or orchestrator references quinn-journey path", () => {
479
- const files = ["gates/schema.ts", "gates/orchestrator.ts"]
480
- .map(f => join(HARNESS, f))
481
- .filter(f => existsSync(f));
482
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
483
- expect(content).toMatch(/quinn.*journey|journey.*yaml|journey.*path/i);
484
- });
485
- });
486
-
487
- // SC-109: Fix-on-find — silently dropped = FAIL
488
- describe("SC-109: fix-on-find enforcement", () => {
489
- test("gate checks for dropped issues", () => {
490
- const files = ["gates/run-gate.ts", "gates/workflow.test.ts"]
491
- .map(f => join(HARNESS, f))
492
- .filter(f => existsSync(f));
493
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
494
- expect(content).toMatch(/fix.on.find|dropped|found.*issue|silently/i);
495
- });
496
- });
497
-
498
- // SC-110: Port allocation checks for collisions
499
- describe("SC-110: port collision detection", () => {
500
- test("worktree or orchestrator checks port collisions", () => {
501
- const files = ["gates/orchestrator.ts", "gates/ship-orchestrator.ts"]
502
- .map(f => join(HARNESS, f))
503
- .filter(f => existsSync(f));
504
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
505
- expect(content).toMatch(/port.*collision|port.*alloc|port.*offset|port.*check/i);
506
- });
507
- });
508
-
509
- // SC-111: Escalation decision tree in agent briefs
510
- describe("SC-111: escalation decision tree", () => {
511
- test("escalation template exists or is referenced in briefs", () => {
512
- const escalation = join(PROMPTS, "escalation-decision-tree.md");
513
- const hasEscalation = existsSync(escalation);
514
- const scaffold = readFileSync(join(HARNESS, "scripts/scaffold-project.ts"), "utf-8");
515
- const refsEscalation = scaffold.includes("escalation");
516
- expect(hasEscalation || refsEscalation).toBe(true);
517
- });
518
- });
519
-
520
- // SC-112: Circuit breaker → research escalation
521
- describe("SC-112: research escalation at iteration 2", () => {
522
- test("gate checks research evidence before iteration 3", () => {
523
- const files = ["gates/run-gate.ts", "gates/self-heal.ts"]
524
- .map(f => join(HARNESS, f))
525
- .filter(f => existsSync(f));
526
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
527
- expect(content).toMatch(/research|iteration|escalat|circuit.*break/i);
528
- });
529
- });
530
-
531
- // SC-113: rungate.json research section
532
- describe("SC-113: research tools config", () => {
533
- test("schema supports research field", () => {
534
- const schema = readFileSync(join(HARNESS, "lib/rungate-schema.ts"), "utf-8");
535
- expect(schema).toMatch(/research/i);
536
- });
537
- });
538
-
539
- // SC-127: 3 gate prompt templates exist
540
- describe("SC-127: gate prompt templates", () => {
541
- const templates = ["ac-adversary.md", "evidence-validator.md", "prove-reproducer.md"];
542
- for (const t of templates) {
543
- test(`gates/prompts/${t} exists`, () => {
544
- expect(existsSync(join(GATES, "prompts", t))).toBe(true);
545
- });
546
- }
547
- });
548
-
549
- // SC-129: Gate WARNs on shallow modules
550
- describe("SC-129: shallow module detection", () => {
551
- test("conformity exports runModuleDepthCheck", () => {
552
- const conformity = readFileSync(join(HARNESS, "lib/conformity.ts"), "utf-8");
553
- expect(conformity).toContain("runModuleDepthCheck");
554
- expect(conformity).toMatch(/shallow|export.*internal|module.*depth/i);
555
- });
556
- });
557
-
558
- // SC-130: Gate WARNs on modules with >3 importers and no contract test
559
- describe("SC-130: contract test coverage", () => {
560
- test("conformity checks importer count vs contract tests", () => {
561
- const conformity = readFileSync(join(HARNESS, "lib/conformity.ts"), "utf-8");
562
- expect(conformity).toMatch(/importer|contract.*test|import.*count/i);
563
- });
564
- });
565
-
566
- // SC-131: Anti-criteria use absence verification
567
- describe("SC-131: absence verification for anti-criteria", () => {
568
- test("conformity exports runAbsenceValidation", () => {
569
- const conformity = readFileSync(join(HARNESS, "lib/conformity.ts"), "utf-8");
570
- expect(conformity).toContain("runAbsenceValidation");
571
- expect(conformity).toMatch(/absence|anti.*criter/i);
572
- });
573
- });
574
-
575
- // SC-132: Tier D evidence capped at 25%
576
- describe("SC-132: tier D cap", () => {
577
- test("gate checks grep evidence percentage", () => {
578
- const files = ["gates/run-gate.ts", "gates/workflow.test.ts"]
579
- .map(f => join(HARNESS, f))
580
- .filter(f => existsSync(f));
581
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
582
- expect(content).toMatch(/tier.*D|grep.*cap|25.*percent|evidence.*portfolio/i);
583
- });
584
- });
585
-
586
- // SC-133: Brief-assembler rejects Quinn journeys > 8 steps
587
- describe("SC-133: Quinn journey step cap", () => {
588
- test("brief-assembler limits journey length", () => {
589
- const assembler = join(GATES, "brief-assembler.ts");
590
- if (existsSync(assembler)) {
591
- const content = readFileSync(assembler, "utf-8");
592
- expect(content).toMatch(/8.*step|step.*limit|journey.*split|max.*step/i);
593
- } else {
594
- expect(existsSync(assembler)).toBe(true);
595
- }
596
- });
597
- });
598
-
599
- // SC-134: Files changed outside brief = WARN
600
- describe("SC-134: out-of-brief file changes", () => {
601
- test("gate detects changes outside brief scope", () => {
602
- const files = ["gates/run-gate.ts", "gates/workflow.test.ts"]
603
- .map(f => join(HARNESS, f))
604
- .filter(f => existsSync(f));
605
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
606
- expect(content).toMatch(/outside.*brief|brief.*file|unexpected.*change|file.*outside/i);
607
- });
608
- });
609
-
610
- // SC-135: Gate cross-validates proofOfFix vs prove-evidence
611
- describe("SC-135: proof cross-validation", () => {
612
- test("gate compares proofOfFix against prove-evidence.json", () => {
613
- const files = ["gates/run-gate.ts", "gates/prove.test.ts"]
614
- .map(f => join(HARNESS, f))
615
- .filter(f => existsSync(f));
616
- const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
617
- expect(content).toMatch(/proofOfFix|prove.evidence|cross.*valid|mismatch/i);
618
- });
619
- });
620
- });