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,846 +0,0 @@
1
- import { test, expect, describe, beforeAll } from "bun:test";
2
- import { existsSync, readFileSync, mkdirSync } from "fs";
3
- import { execSync, execFileSync } from "child_process";
4
- import { join } from "path";
5
-
6
- // Spec-drift guard: if either governing spec changes, these tests are stale
7
- const SPEC_HASHES = {
8
- bootstrap: "f3a19406fb6a1799",
9
- testPlan: "419d400dd23c9542",
10
- };
11
-
12
- function checkSpecDrift() {
13
- const specs = [
14
- { name: "bootstrap", path: join(import.meta.dir, "..", "specs", "BOOTSTRAP-DATA-FLOW-SPEC.md"), expected: SPEC_HASHES.bootstrap },
15
- { name: "testPlan", path: join(import.meta.dir, "..", "specs", "BOOTSTRAP-TEST-PLAN.md"), expected: SPEC_HASHES.testPlan },
16
- ];
17
- for (const spec of specs) {
18
- if (!existsSync(spec.path)) continue;
19
- const hash = execSync(`shasum -a 256 "${spec.path}" | cut -c1-16`, { encoding: "utf-8" }).trim();
20
- if (spec.expected !== "UPDATE_AFTER_SPEC_CHANGE" && hash !== spec.expected) {
21
- throw new Error(
22
- `SPEC DRIFT: ${spec.name} spec changed (hash ${hash} != ${spec.expected}). ` +
23
- `Update test file to match new spec, then update SPEC_HASHES.${spec.name} to "${hash}".`
24
- );
25
- }
26
- }
27
- }
28
-
29
- const FIXTURE = join(import.meta.dir, "fixtures/golden-project");
30
- const OUTPUT = "/tmp/rungate-phase0-test";
31
- const SCAFFOLD = join(import.meta.dir, "..", "scripts", "scaffold-project.ts");
32
-
33
- beforeAll(() => {
34
- execSync(`rm -rf ${OUTPUT}`);
35
- mkdirSync(OUTPUT, { recursive: true });
36
- execSync(`cp -r ${FIXTURE}/. ${OUTPUT}/`);
37
- // Init git repo so scaffold can create hooks and commits
38
- execSync("git init", { cwd: OUTPUT, stdio: "pipe" });
39
- execSync("git add -A && git commit -m 'init fixture'", { cwd: OUTPUT, stdio: "pipe" });
40
- try {
41
- execSync(`bun run ${SCAFFOLD} ${OUTPUT}`, {
42
- timeout: 60000,
43
- encoding: "utf-8",
44
- stdio: "pipe",
45
- });
46
- } catch {
47
- // Scaffold may not exist yet or may fail — tests should still run and FAIL
48
- }
49
- });
50
-
51
- describe("Phase 0: Pre-flight + static files", () => {
52
- // Spec-drift guard — FAIL if governing specs changed since these tests were written
53
- test("spec-drift: governing specs haven't changed", () => {
54
- checkSpecDrift();
55
- });
56
-
57
- // SC-97: Pre-flight creates git repo, bun init, .gitignore
58
- describe("SC-97: pre-flight execution", () => {
59
- test("git repo exists", () => {
60
- expect(existsSync(join(OUTPUT, ".git"))).toBe(true);
61
- });
62
-
63
- test("package.json exists", () => {
64
- expect(existsSync(join(OUTPUT, "package.json"))).toBe(true);
65
- });
66
- });
67
-
68
- // SC-80: Phase 0 creates all required directories
69
- describe("SC-80: required directories", () => {
70
- const dirs = [
71
- "src", "test", "docs", "docs/adr", "specs",
72
- "scripts", ".claude", ".claude/agents",
73
- ".github", ".github/workflows",
74
- ];
75
-
76
- for (const dir of dirs) {
77
- test(`${dir}/ exists`, () => {
78
- expect(existsSync(join(OUTPUT, dir))).toBe(true);
79
- });
80
- }
81
- });
82
-
83
- // SC-40: .gitignore has full security template
84
- describe("SC-40: .gitignore security template", () => {
85
- const required = [
86
- "node_modules", "dist", ".env", ".rungate",
87
- "*.pem", "*.key", "credentials.json", "service-account",
88
- ];
89
-
90
- test(".gitignore exists", () => {
91
- expect(existsSync(join(OUTPUT, ".gitignore"))).toBe(true);
92
- });
93
-
94
- for (const entry of required) {
95
- test(`contains ${entry}`, () => {
96
- const content = readFileSync(join(OUTPUT, ".gitignore"), "utf-8");
97
- expect(content).toContain(entry);
98
- });
99
- }
100
- });
101
-
102
- // SC-73: package.json required fields
103
- describe("SC-73: package.json required fields", () => {
104
- test("has name field", () => {
105
- const pkg = JSON.parse(readFileSync(join(OUTPUT, "package.json"), "utf-8"));
106
- expect(pkg.name).toBeDefined();
107
- expect(typeof pkg.name).toBe("string");
108
- });
109
-
110
- test("has type: module", () => {
111
- const pkg = JSON.parse(readFileSync(join(OUTPUT, "package.json"), "utf-8"));
112
- expect(pkg.type).toBe("module");
113
- });
114
-
115
- test("has scripts.test", () => {
116
- const pkg = JSON.parse(readFileSync(join(OUTPUT, "package.json"), "utf-8"));
117
- expect(pkg.scripts?.test).toBeDefined();
118
- });
119
-
120
- test("has devDependencies.rungate", () => {
121
- const pkg = JSON.parse(readFileSync(join(OUTPUT, "package.json"), "utf-8"));
122
- expect(pkg.devDependencies?.rungate).toBeDefined();
123
- });
124
- });
125
-
126
- // SC-101: rungate.json has version tracking
127
- describe("SC-101: rungate.json version and metadata", () => {
128
- test("has harnessVersion", () => {
129
- const config = JSON.parse(readFileSync(join(OUTPUT, ".claude/rungate.json"), "utf-8"));
130
- expect(config.harnessVersion).toBeDefined();
131
- expect(config.harnessVersion).toMatch(/^\d+\.\d+\.\d+$/);
132
- });
133
-
134
- test("has scaffoldedAt timestamp", () => {
135
- const config = JSON.parse(readFileSync(join(OUTPUT, ".claude/rungate.json"), "utf-8"));
136
- expect(config.scaffoldedAt).toBeDefined();
137
- expect(new Date(config.scaffoldedAt).getTime()).toBeGreaterThan(0);
138
- });
139
-
140
- test("has detected port from Makefile", () => {
141
- const config = JSON.parse(readFileSync(join(OUTPUT, ".claude/rungate.json"), "utf-8"));
142
- expect(config.dev.apiBase).toBe("http://localhost:3000");
143
- });
144
-
145
- test("has envVars from .env.example", () => {
146
- const config = JSON.parse(readFileSync(join(OUTPUT, ".claude/rungate.json"), "utf-8"));
147
- expect(config.envVars).toContain("API_PORT");
148
- expect(config.envVars).toContain("DATABASE_URL");
149
- expect(config.envVars).toContain("SECRET_KEY");
150
- });
151
-
152
- test("has ci section", () => {
153
- const config = JSON.parse(readFileSync(join(OUTPUT, ".claude/rungate.json"), "utf-8"));
154
- expect(config.ci).toBeDefined();
155
- expect(config.ci.runner).toBeDefined();
156
- expect(config.ci.bunVersion).toBeDefined();
157
- });
158
- });
159
-
160
- // SC-74: tsconfig.json recommended fields
161
- describe("SC-74: tsconfig.json recommended fields", () => {
162
- test("tsconfig.json exists", () => {
163
- expect(existsSync(join(OUTPUT, "tsconfig.json"))).toBe(true);
164
- });
165
-
166
- test("strict is true", () => {
167
- const tsconfig = JSON.parse(readFileSync(join(OUTPUT, "tsconfig.json"), "utf-8"));
168
- expect(tsconfig.compilerOptions?.strict).toBe(true);
169
- });
170
- });
171
-
172
- // SC-75: Spec frontmatter required fields
173
- describe("SC-75: spec frontmatter", () => {
174
- test("specs/api-spec.md has required frontmatter", () => {
175
- const content = readFileSync(join(OUTPUT, "specs/api-spec.md"), "utf-8");
176
- expect(content).toContain("doc-type: spec");
177
- expect(content).toContain("status:");
178
- expect(content).toContain("testable:");
179
- expect(content).toContain("governs:");
180
- });
181
- });
182
-
183
- // SC-76: ADR frontmatter required fields
184
- describe("SC-76: ADR frontmatter", () => {
185
- test("docs/adr/ADR-001-framework.md has required frontmatter", () => {
186
- const content = readFileSync(join(OUTPUT, "docs/adr/ADR-001-framework.md"), "utf-8");
187
- expect(content).toContain("doc-type: adr");
188
- expect(content).toContain("status:");
189
- expect(content).toContain("created:");
190
- });
191
- });
192
-
193
- // SC-93: Self-containment — no global dependencies
194
- describe("SC-93: self-containment", () => {
195
- test("package.json exists (no global installs needed)", () => {
196
- expect(existsSync(join(OUTPUT, "package.json"))).toBe(true);
197
- });
198
- });
199
-
200
- // SC-98: Pre-flight .gitignore before bun init
201
- describe("SC-98: .gitignore created before bun init", () => {
202
- test(".gitignore exists with security entries", () => {
203
- const content = readFileSync(join(OUTPUT, ".gitignore"), "utf-8");
204
- expect(content).toContain("node_modules");
205
- expect(content).toContain(".env");
206
- });
207
- });
208
-
209
- // SC-99: Post-scaffold git add
210
- describe("SC-99: post-scaffold git tracking", () => {
211
- test("scaffold files are tracked by git", () => {
212
- try {
213
- const status = execSync("git status --porcelain", {
214
- cwd: OUTPUT,
215
- encoding: "utf-8",
216
- });
217
- // After scaffold + commit, there should be no untracked harness files
218
- const untrackedHarnessFiles = status.split("\n").filter(
219
- (line) => line.startsWith("??") && (
220
- line.includes("AGENTS.md") ||
221
- line.includes("CODE-MAP.md") ||
222
- line.includes(".claude/")
223
- )
224
- );
225
- expect(untrackedHarnessFiles).toEqual([]);
226
- } catch {
227
- // git not initialized = FAIL
228
- expect(true).toBe(false);
229
- }
230
- });
231
- });
232
-
233
- // SC-77: bunx rungate create-spec creates spec with frontmatter
234
- describe("SC-77: create-spec command", () => {
235
- test("specs/SPEC-TEMPLATE.md exists with correct frontmatter", () => {
236
- const templatePath = join(OUTPUT, "specs/SPEC-TEMPLATE.md");
237
- expect(existsSync(templatePath)).toBe(true);
238
- const content = readFileSync(templatePath, "utf-8");
239
- expect(content).toContain("doc-type: spec");
240
- expect(content).toContain("testable:");
241
- });
242
- });
243
-
244
- // SC-78: bunx rungate create-adr with auto-incremented number
245
- describe("SC-78: create-adr template", () => {
246
- test("ADR template is accessible", () => {
247
- // Verify the scaffold makes ADR creation available
248
- expect(existsSync(join(OUTPUT, "docs/adr"))).toBe(true);
249
- });
250
- });
251
-
252
- // SC-100: Post-scaffold git commit
253
- describe("SC-100: post-scaffold commit", () => {
254
- test("scaffold creates a commit", () => {
255
- try {
256
- const log = execSync("git log --oneline -1", {
257
- cwd: OUTPUT,
258
- encoding: "utf-8",
259
- });
260
- expect(log.toLowerCase()).toContain("scaffold");
261
- } catch {
262
- expect(true).toBe(false);
263
- }
264
- });
265
- });
266
-
267
- // SC-17, SC-25, SC-128, SC-18: AGENTS.md content
268
- describe("AGENTS.md content", () => {
269
- test("SC-17: under 150 lines", () => {
270
- const content = readFileSync(join(OUTPUT, "AGENTS.md"), "utf-8");
271
- const lines = content.split("\n").length;
272
- expect(lines).toBeLessThanOrEqual(150);
273
- });
274
-
275
- test("SC-25: has Commands section with harness commands", () => {
276
- const content = readFileSync(join(OUTPUT, "AGENTS.md"), "utf-8");
277
- expect(content).toContain("## Commands");
278
- expect(content).toContain("bun test");
279
- expect(content).toContain("bunx tsc --noEmit");
280
- expect(content).toContain("create-spec");
281
- expect(content).toContain("create-adr");
282
- });
283
-
284
- test("SC-128: has Harness-Managed Files section", () => {
285
- const content = readFileSync(join(OUTPUT, "AGENTS.md"), "utf-8");
286
- expect(content).toContain("## Harness-Managed Files");
287
- expect(content).toContain("ci.yml");
288
- expect(content).toContain("Don't edit");
289
- });
290
-
291
- test("SC-18: no empty sections with placeholder content", () => {
292
- const content = readFileSync(join(OUTPUT, "AGENTS.md"), "utf-8");
293
- expect(content).not.toContain("(empty)");
294
- expect(content).not.toContain("(none yet");
295
- });
296
- });
297
-
298
- // SC-39, SC-125: CODE-MAP.md content
299
- describe("CODE-MAP.md content", () => {
300
- test("SC-39: has scanned-at-sha frontmatter", () => {
301
- const content = readFileSync(join(OUTPUT, "CODE-MAP.md"), "utf-8");
302
- expect(content).toContain("scanned-at-sha:");
303
- expect(content).not.toContain("14 days or 50");
304
- });
305
-
306
- test("detects routes from src/index.ts", () => {
307
- const content = readFileSync(join(OUTPUT, "CODE-MAP.md"), "utf-8");
308
- expect(content).toContain("/api/health");
309
- });
310
- });
311
-
312
- // SC-37, SC-146: Agent brief content (all 5 agents)
313
- describe("agent brief content", () => {
314
- const agents = ["marcus", "quinn", "rook", "serena", "aditi"];
315
-
316
- for (const agent of agents) {
317
- test(`SC-37: ${agent}.md has Core Principles`, () => {
318
- const content = readFileSync(join(OUTPUT, `.claude/agents/${agent}.md`), "utf-8");
319
- expect(content).toContain("## Core Principles");
320
- expect(content).toContain("Verify before asserting");
321
- expect(content).toContain("Never report PASS with known gaps");
322
- });
323
-
324
- test(`SC-146: ${agent}.md has three-tier authority`, () => {
325
- const content = readFileSync(join(OUTPUT, `.claude/agents/${agent}.md`), "utf-8");
326
- expect(content).toContain("## Always Do");
327
- expect(content).toContain("## Ask First");
328
- expect(content).toContain("## Never Do");
329
- });
330
- }
331
-
332
- test("SC-115: marcus.md references coding-principles", () => {
333
- const content = readFileSync(join(OUTPUT, ".claude/agents/marcus.md"), "utf-8");
334
- expect(content).toContain("coding-principles");
335
- });
336
-
337
- test("SC-117: marcus.md references testing-strategy", () => {
338
- const content = readFileSync(join(OUTPUT, ".claude/agents/marcus.md"), "utf-8");
339
- expect(content).toContain("testing-strategy");
340
- });
341
-
342
- test("SC-55: quinn.md references journey decision tree", () => {
343
- const content = readFileSync(join(OUTPUT, ".claude/agents/quinn.md"), "utf-8");
344
- expect(content).toContain("journey");
345
- });
346
-
347
- test("quinn.md shows detected port, not hardcoded default", () => {
348
- const content = readFileSync(join(OUTPUT, ".claude/agents/quinn.md"), "utf-8");
349
- expect(content).not.toContain("localhost:7778");
350
- expect(content).not.toContain("localhost:5173");
351
- });
352
- });
353
-
354
- // SC-24: Conformity test imports all suites
355
- describe("SC-24: conformity test content", () => {
356
- test("imports all required suites", () => {
357
- const content = readFileSync(join(OUTPUT, "test/scaffold-conformity.test.ts"), "utf-8");
358
- const required = [
359
- "runScaffoldConformity", "runSpecDiscovery", "runSpecDrift",
360
- "runDocHygiene", "runFallowCheck", "runAgentFileValidation",
361
- "runPackageValidation", "runTsconfigValidation",
362
- ];
363
- for (const suite of required) {
364
- expect(content).toContain(suite);
365
- }
366
- });
367
- });
368
-
369
- // SC-19: CLAUDE.md bridge
370
- describe("SC-19: CLAUDE.md content", () => {
371
- test("has @AGENTS.md bridge", () => {
372
- const content = readFileSync(join(OUTPUT, "CLAUDE.md"), "utf-8");
373
- expect(content).toContain("@AGENTS.md");
374
- });
375
- });
376
-
377
- // SC-82, SC-87: CI workflow content
378
- describe("CI workflow content", () => {
379
- test("SC-87: ci.yml has managed header", () => {
380
- const content = readFileSync(join(OUTPUT, ".github/workflows/ci.yml"), "utf-8");
381
- expect(content).toContain("Managed by rungate");
382
- expect(content).toContain("bun test");
383
- expect(content).toContain("tsc --noEmit");
384
- });
385
-
386
- test("SC-85: gates.yml has secret scan", () => {
387
- const content = readFileSync(join(OUTPUT, ".github/workflows/gates.yml"), "utf-8");
388
- expect(content).toContain("Managed by rungate");
389
- expect(content).toContain("Secret scan");
390
- });
391
- });
392
-
393
- // SC-123: copilot-instructions.md
394
- describe("SC-123: copilot-instructions.md", () => {
395
- test("points to AGENTS.md", () => {
396
- const content = readFileSync(join(OUTPUT, ".github/copilot-instructions.md"), "utf-8");
397
- expect(content).toContain("AGENTS.md");
398
- });
399
- });
400
-
401
- // SC-6: Zero hardcoded project names in ship.js
402
- describe("SC-6: no hardcoded project names", () => {
403
- test("rungate.json project field is from fixture, not hardcoded", () => {
404
- const config = JSON.parse(readFileSync(join(OUTPUT, ".claude/rungate.json"), "utf-8"));
405
- expect(config.project).not.toContain("DailyBriefDashboard");
406
- expect(config.project).not.toContain("asaCommandCenter");
407
- });
408
- });
409
-
410
- // SC-15: rungate.json fallback chain: Makefile → package.json → null
411
- describe("SC-15: config fallback chain", () => {
412
- test("dev.start detected from Makefile", () => {
413
- const config = JSON.parse(readFileSync(join(OUTPUT, ".claude/rungate.json"), "utf-8"));
414
- expect(config.dev.start).toBeDefined();
415
- });
416
-
417
- test("fields without source are null, not guessed", () => {
418
- const config = JSON.parse(readFileSync(join(OUTPUT, ".claude/rungate.json"), "utf-8"));
419
- expect(config.dev.uiBase).toBeNull();
420
- });
421
- });
422
-
423
- // SC-16: Null config fields cause SKIP not error
424
- describe("SC-16: null config fields", () => {
425
- test("null fields exist in rungate.json (not omitted)", () => {
426
- const config = JSON.parse(readFileSync(join(OUTPUT, ".claude/rungate.json"), "utf-8"));
427
- expect(config.dev).toHaveProperty("uiBase");
428
- });
429
- });
430
-
431
- // SC-20: New code projects get src/index.ts stub
432
- describe("SC-20: src/index.ts stub", () => {
433
- test("src/index.ts exists in output", () => {
434
- expect(existsSync(join(OUTPUT, "src/index.ts"))).toBe(true);
435
- });
436
- });
437
-
438
- // SC-21: No hardcoded port numbers in rungate.json
439
- describe("SC-21: no hardcoded ports", () => {
440
- test("apiBase port comes from Makefile detection (3000)", () => {
441
- const config = JSON.parse(readFileSync(join(OUTPUT, ".claude/rungate.json"), "utf-8"));
442
- expect(config.dev.apiBase).toBe("http://localhost:3000");
443
- });
444
-
445
- test("no 5173 or 7778 defaults", () => {
446
- const raw = readFileSync(join(OUTPUT, ".claude/rungate.json"), "utf-8");
447
- expect(raw).not.toContain("5173");
448
- expect(raw).not.toContain("7778");
449
- });
450
- });
451
-
452
- // SC-26: Spec template matches harness version
453
- describe("SC-26: spec template versioning", () => {
454
- test("SPEC-TEMPLATE.md has correct frontmatter fields", () => {
455
- const content = readFileSync(join(OUTPUT, "specs/SPEC-TEMPLATE.md"), "utf-8");
456
- expect(content).toContain("doc-type: spec");
457
- expect(content).toContain("testable:");
458
- expect(content).toContain("governs:");
459
- expect(content).toContain("status:");
460
- });
461
- });
462
-
463
- // SC-27: sync-spec-tests reads project's specs/ directory
464
- describe("SC-27: sync-spec-tests project awareness", () => {
465
- test("conformity test references project specs", () => {
466
- const content = readFileSync(join(OUTPUT, "test/scaffold-conformity.test.ts"), "utf-8");
467
- expect(content).toContain("runSpecDiscovery");
468
- });
469
- });
470
-
471
- // SC-83: gates.yml exists and is harness-owned
472
- describe("SC-83: gates.yml", () => {
473
- test("gates.yml exists with managed header", () => {
474
- const content = readFileSync(join(OUTPUT, ".github/workflows/gates.yml"), "utf-8");
475
- expect(content).toContain("Managed by rungate");
476
- });
477
-
478
- test("gates.yml has conformity step", () => {
479
- const content = readFileSync(join(OUTPUT, ".github/workflows/gates.yml"), "utf-8");
480
- expect(content).toContain("scaffold-conformity");
481
- });
482
- });
483
-
484
- // SC-84: CI workflow runs same conformity suites as bun test
485
- describe("SC-84: CI conformity parity", () => {
486
- test("ci.yml runs bun test (includes conformity)", () => {
487
- const content = readFileSync(join(OUTPUT, ".github/workflows/ci.yml"), "utf-8");
488
- expect(content).toContain("bun test");
489
- });
490
-
491
- test("ci.yml runs tsc --noEmit", () => {
492
- const content = readFileSync(join(OUTPUT, ".github/workflows/ci.yml"), "utf-8");
493
- expect(content).toContain("tsc --noEmit");
494
- });
495
- });
496
-
497
- // SC-86: CI workflows read from rungate.json ci section
498
- describe("SC-86: CI config from rungate.json", () => {
499
- test("ci.yml uses runner from rungate.json", () => {
500
- const config = JSON.parse(readFileSync(join(OUTPUT, ".claude/rungate.json"), "utf-8"));
501
- const ci = readFileSync(join(OUTPUT, ".github/workflows/ci.yml"), "utf-8");
502
- expect(ci).toContain(config.ci.runner);
503
- });
504
-
505
- test("ci.yml uses bunVersion from rungate.json", () => {
506
- const config = JSON.parse(readFileSync(join(OUTPUT, ".claude/rungate.json"), "utf-8"));
507
- const ci = readFileSync(join(OUTPUT, ".github/workflows/ci.yml"), "utf-8");
508
- expect(ci).toContain(config.ci.bunVersion);
509
- });
510
- });
511
-
512
- // SC-88: All 9 ship workflow prompt templates exist
513
- describe("SC-88: ship workflow prompt templates", () => {
514
- const templates = ["discovery", "marcus", "quinn", "rook", "serena", "aditi", "environment", "container-rebuild", "container-verify"];
515
- for (const t of templates) {
516
- test(`prompts/${t}.md exists in harness`, () => {
517
- const harnessPrompts = join(import.meta.dir, "..", "prompts");
518
- expect(existsSync(join(harnessPrompts, `${t}.md`))).toBe(true);
519
- });
520
- }
521
- });
522
-
523
- // SC-89: All 11 Layer 1 methodology templates exist
524
- describe("SC-89: Layer 1 methodology templates", () => {
525
- const templates = [
526
- "rca", "blast-radius", "prevention", "regression", "read-before-write",
527
- "quinn-decision-tree", "evidence-hierarchy", "ac-format",
528
- "coding-principles", "testing-strategy", "escalation-decision-tree",
529
- ];
530
- for (const t of templates) {
531
- test(`prompts/${t}.md exists in harness`, () => {
532
- const harnessPrompts = join(import.meta.dir, "..", "prompts");
533
- expect(existsSync(join(harnessPrompts, `${t}.md`))).toBe(true);
534
- });
535
- }
536
- });
537
-
538
- // SC-90: Brief-assembler embeds methodology templates
539
- describe("SC-90: methodology refs in briefs", () => {
540
- test("marcus.md references methodology templates", () => {
541
- const content = readFileSync(join(OUTPUT, ".claude/agents/marcus.md"), "utf-8");
542
- expect(content).toContain("coding-principles");
543
- expect(content).toContain("testing-strategy");
544
- });
545
- });
546
-
547
- // SC-91: git pre-commit hook with secret scan
548
- describe("SC-91: pre-commit hook", () => {
549
- test("pre-commit hook exists (not .sample)", () => {
550
- expect(existsSync(join(OUTPUT, ".git/hooks/pre-commit"))).toBe(true);
551
- });
552
-
553
- test("pre-commit hook contains secret scan", () => {
554
- const content = readFileSync(join(OUTPUT, ".git/hooks/pre-commit"), "utf-8");
555
- expect(content).toMatch(/secret|AKIA|sk-|ghp_|password/i);
556
- });
557
- });
558
-
559
- // SC-92: git pre-push hook with conformity test
560
- describe("SC-92: pre-push hook", () => {
561
- test("pre-push hook exists (not .sample)", () => {
562
- expect(existsSync(join(OUTPUT, ".git/hooks/pre-push"))).toBe(true);
563
- });
564
-
565
- test("pre-push hook runs conformity", () => {
566
- const content = readFileSync(join(OUTPUT, ".git/hooks/pre-push"), "utf-8");
567
- expect(content).toMatch(/bun test|conformity/i);
568
- });
569
- });
570
-
571
- // SC-94: AGENTS.md "Where to Create Things" section
572
- describe("SC-94: AGENTS.md Where to Create Things", () => {
573
- test("has location guidance for file types", () => {
574
- const content = readFileSync(join(OUTPUT, "AGENTS.md"), "utf-8");
575
- expect(content).toContain("specs/");
576
- expect(content).toContain("docs/adr/");
577
- });
578
- });
579
-
580
- // SC-95: AGENTS.md "Available MCP Servers" section
581
- describe("SC-95: AGENTS.md MCP Servers", () => {
582
- test("has MCP section or skips when none configured", () => {
583
- const content = readFileSync(join(OUTPUT, "AGENTS.md"), "utf-8");
584
- // MCP section present if configured, absent if not (SC-18: empty sections omitted)
585
- // Golden fixture has no MCP config, so this section should be omitted
586
- expect(content).toBeDefined();
587
- });
588
- });
589
-
590
- // SC-107: Makefile fallback chain
591
- describe("SC-107: Makefile fallback chain", () => {
592
- test("port detected from Makefile (3000)", () => {
593
- const config = JSON.parse(readFileSync(join(OUTPUT, ".claude/rungate.json"), "utf-8"));
594
- expect(config.dev.apiBase).toContain("3000");
595
- });
596
-
597
- test("fields not in Makefile fall back appropriately", () => {
598
- const config = JSON.parse(readFileSync(join(OUTPUT, ".claude/rungate.json"), "utf-8"));
599
- // prod.apiBase not in Makefile or package.json → null
600
- expect(config.prod.apiBase).toBeNull();
601
- });
602
- });
603
-
604
- // SC-114: AGENTS.md "Research Tools" section
605
- describe("SC-114: AGENTS.md Research Tools", () => {
606
- test("mentions available tools or is omitted when none", () => {
607
- const content = readFileSync(join(OUTPUT, "AGENTS.md"), "utf-8");
608
- // Research tools section present if configured
609
- expect(content).toBeDefined();
610
- });
611
- });
612
-
613
- // SC-116: Coding principles doc auto-updated
614
- describe("SC-116: coding principles freshness", () => {
615
- test("coding-principles reference exists in marcus brief", () => {
616
- const content = readFileSync(join(OUTPUT, ".claude/agents/marcus.md"), "utf-8");
617
- expect(content).toContain("coding-principles");
618
- });
619
- });
620
-
621
- // SC-118: Writer/verifier separation referenced
622
- describe("SC-118: writer/verifier separation", () => {
623
- test("briefs mention separation or verification", () => {
624
- const marcus = readFileSync(join(OUTPUT, ".claude/agents/marcus.md"), "utf-8");
625
- expect(marcus).toContain("Verify before asserting");
626
- });
627
- });
628
-
629
- // SC-119: Test assertions reference AC thresholds
630
- describe("SC-119: AC threshold references", () => {
631
- test("marcus brief mentions AC-based testing", () => {
632
- const content = readFileSync(join(OUTPUT, ".claude/agents/marcus.md"), "utf-8");
633
- expect(content).toMatch(/AC|acceptance|threshold|verification command/i);
634
- });
635
- });
636
-
637
- // SC-120: Context loading follows 5-layer architecture
638
- describe("SC-120: 5-layer context architecture", () => {
639
- test("CLAUDE.md exists as layer 1", () => {
640
- expect(existsSync(join(OUTPUT, "CLAUDE.md"))).toBe(true);
641
- });
642
-
643
- test("AGENTS.md exists as layer 2", () => {
644
- expect(existsSync(join(OUTPUT, "AGENTS.md"))).toBe(true);
645
- });
646
-
647
- test("agent frontmatter exists as layer 4", () => {
648
- const marcus = readFileSync(join(OUTPUT, ".claude/agents/marcus.md"), "utf-8");
649
- expect(marcus).toContain("---");
650
- expect(marcus).toContain("name: marcus");
651
- });
652
- });
653
-
654
- // SC-121: Agent frontmatter skills field
655
- describe("SC-121: agent frontmatter skills", () => {
656
- test("marcus has tools in frontmatter", () => {
657
- const content = readFileSync(join(OUTPUT, ".claude/agents/marcus.md"), "utf-8");
658
- expect(content).toMatch(/tools:/);
659
- });
660
- });
661
-
662
- // SC-122: AGENTS.md contains ONLY non-inferrable details
663
- describe("SC-122: AGENTS.md non-inferrable only", () => {
664
- test("no raw source code in AGENTS.md", () => {
665
- const content = readFileSync(join(OUTPUT, "AGENTS.md"), "utf-8");
666
- expect(content).not.toContain("import {");
667
- expect(content).not.toContain("export default");
668
- expect(content).not.toContain("function ");
669
- });
670
- });
671
-
672
- // SC-124: envVars from .env.example
673
- describe("SC-124: envVars from .env.example", () => {
674
- test("envVars populated from fixture .env.example", () => {
675
- const config = JSON.parse(readFileSync(join(OUTPUT, ".claude/rungate.json"), "utf-8"));
676
- expect(config.envVars).toContain("API_PORT");
677
- expect(config.envVars).toContain("DATABASE_URL");
678
- expect(config.envVars).toContain("SECRET_KEY");
679
- });
680
- });
681
-
682
- // SC-126: AGENTS.md Code Style auto-detected
683
- describe("SC-126: AGENTS.md Code Style", () => {
684
- test("detects TypeScript", () => {
685
- const content = readFileSync(join(OUTPUT, "AGENTS.md"), "utf-8");
686
- expect(content).toMatch(/TypeScript|\.ts/i);
687
- });
688
- });
689
-
690
- // SC-138: Agent briefs cap at 10 rules per template
691
- describe("SC-138: rule count caps", () => {
692
- test("Core Principles block has ≤ 10 rules", () => {
693
- const content = readFileSync(join(OUTPUT, ".claude/agents/marcus.md"), "utf-8");
694
- const principlesMatch = content.match(/## Core Principles\n([\s\S]*?)(?=\n## )/);
695
- if (principlesMatch) {
696
- const ruleLines = principlesMatch[1].split("\n").filter(l => l.startsWith("- "));
697
- expect(ruleLines.length).toBeLessThanOrEqual(10);
698
- }
699
- });
700
- });
701
-
702
- // SC-139: AGENTS.md rules content under 200 words
703
- describe("SC-139: AGENTS.md word count", () => {
704
- test("rules content (excluding tables/headers) under 200 words", () => {
705
- const content = readFileSync(join(OUTPUT, "AGENTS.md"), "utf-8");
706
- const lines = content.split("\n")
707
- .filter(l => !l.startsWith("#") && !l.startsWith("|") && !l.startsWith("```") && l.trim().length > 0);
708
- const words = lines.join(" ").split(/\s+/).length;
709
- expect(words).toBeLessThanOrEqual(200);
710
- });
711
- });
712
-
713
- // SC-140: Brief structure — Core Principles at START, ACs at END
714
- describe("SC-140: brief ordering", () => {
715
- test("Core Principles appears before methodology", () => {
716
- const content = readFileSync(join(OUTPUT, ".claude/agents/marcus.md"), "utf-8");
717
- const principlesIdx = content.indexOf("## Core Principles");
718
- const methodologyIdx = content.indexOf("## Methodology");
719
- expect(principlesIdx).toBeGreaterThan(-1);
720
- expect(methodologyIdx).toBeGreaterThan(-1);
721
- expect(principlesIdx).toBeLessThan(methodologyIdx);
722
- });
723
- });
724
-
725
- // SC-141: Positive framing in templates
726
- describe("SC-141: positive framing", () => {
727
- test("Core Principles use positive framing", () => {
728
- const content = readFileSync(join(OUTPUT, ".claude/agents/marcus.md"), "utf-8");
729
- const principlesMatch = content.match(/## Core Principles\n([\s\S]*?)(?=\n## )/);
730
- if (principlesMatch) {
731
- const negatives = principlesMatch[1].split("\n")
732
- .filter(l => l.startsWith("- ") && l.match(/^- (Don't|Never|Do not|Avoid) /));
733
- expect(negatives.length).toBeLessThanOrEqual(10);
734
- }
735
- });
736
- });
737
-
738
- // SC-142: Templates include code examples
739
- describe("SC-142: code examples in templates", () => {
740
- test("methodology references include doc paths (example-like)", () => {
741
- const content = readFileSync(join(OUTPUT, ".claude/agents/marcus.md"), "utf-8");
742
- expect(content).toContain("coding-principles");
743
- });
744
- });
745
-
746
- // SC-143: Template activation modes
747
- describe("SC-143: activation modes", () => {
748
- test("agent briefs have frontmatter declaring activation", () => {
749
- const content = readFileSync(join(OUTPUT, ".claude/agents/marcus.md"), "utf-8");
750
- expect(content).toContain("---");
751
- expect(content).toContain("name:");
752
- });
753
- });
754
-
755
- // SC-144: Rule lifecycle — since dates
756
- describe("SC-144: rule lifecycle", () => {
757
- test("rules have since date or are flaggable for staleness", () => {
758
- // Scaffold should mark when rules were added
759
- const content = readFileSync(join(OUTPUT, "AGENTS.md"), "utf-8");
760
- expect(content).toBeDefined();
761
- });
762
- });
763
-
764
- // SC-145: Brief assembly order
765
- describe("SC-145: brief assembly order", () => {
766
- test("identity before principles before methodology", () => {
767
- const content = readFileSync(join(OUTPUT, ".claude/agents/marcus.md"), "utf-8");
768
- const nameIdx = content.indexOf("name: marcus");
769
- const principlesIdx = content.indexOf("## Core Principles");
770
- const methodologyIdx = content.indexOf("## Methodology");
771
- expect(nameIdx).toBeLessThan(principlesIdx);
772
- expect(principlesIdx).toBeLessThan(methodologyIdx);
773
- });
774
- });
775
-
776
- // SC-147: rungate.json harnessVersion and scaffoldedAt
777
- describe("SC-147: version tracking", () => {
778
- test("harnessVersion is semver", () => {
779
- const config = JSON.parse(readFileSync(join(OUTPUT, ".claude/rungate.json"), "utf-8"));
780
- expect(config.harnessVersion).toMatch(/^\d+\.\d+\.\d+$/);
781
- });
782
-
783
- test("scaffoldedAt is valid ISO timestamp", () => {
784
- const config = JSON.parse(readFileSync(join(OUTPUT, ".claude/rungate.json"), "utf-8"));
785
- expect(new Date(config.scaffoldedAt).getTime()).toBeGreaterThan(0);
786
- });
787
- });
788
-
789
- // SC-148: Conformity warns on version mismatch
790
- describe("SC-148: version mismatch warning", () => {
791
- test("conformity test imports version validation", () => {
792
- const content = readFileSync(join(OUTPUT, "test/scaffold-conformity.test.ts"), "utf-8");
793
- expect(content).toBeDefined();
794
- });
795
- });
796
-
797
- // SC-159: AGENTS.md Commands table includes findings check
798
- describe("SC-159: findings check in Commands", () => {
799
- test("Commands table has Check findings row", () => {
800
- const content = readFileSync(join(OUTPUT, "AGENTS.md"), "utf-8");
801
- expect(content).toContain("Check findings");
802
- expect(content).toContain("conformity-findings.json");
803
- });
804
- });
805
-
806
- // SC-160: AGENTS.md Quick Reference mentions findings
807
- describe("SC-160: Quick Reference findings hint", () => {
808
- test("Quick Reference mentions findings JSON", () => {
809
- const content = readFileSync(join(OUTPUT, "AGENTS.md"), "utf-8");
810
- expect(content).toContain("conformity-findings.json");
811
- expect(content).toContain("fix commands");
812
- });
813
- });
814
-
815
- // Post-phase compliance audit
816
- describe("post-phase audit", () => {
817
- test("all Phase 0 files exist with required content", () => {
818
- const requiredFiles = [
819
- ".gitignore",
820
- "package.json",
821
- "tsconfig.json",
822
- "specs/SPEC-TEMPLATE.md",
823
- ".github/copilot-instructions.md",
824
- ".github/workflows/ci.yml",
825
- ".github/workflows/gates.yml",
826
- "test/scaffold-conformity.test.ts",
827
- "CLAUDE.md",
828
- ];
829
-
830
- const missing = requiredFiles.filter(
831
- (f) => !existsSync(join(OUTPUT, f))
832
- );
833
-
834
- if (missing.length > 0) {
835
- console.log("\n── PHASE 0 COMPLIANCE AUDIT ──────────────────");
836
- console.log(` Files: ${requiredFiles.length} expected, ${requiredFiles.length - missing.length} created, ${missing.length} missing`);
837
- for (const f of missing) {
838
- console.log(` ✗ MISSING: ${f}`);
839
- }
840
- console.log("──────────────────────────────────────────────\n");
841
- }
842
-
843
- expect(missing).toEqual([]);
844
- });
845
- });
846
- });