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,334 +0,0 @@
1
- import { readFileSync, writeFileSync, existsSync } from "fs";
2
- import { join, basename } from "path";
3
-
4
- export interface AssembleResult {
5
- briefPath: string;
6
- acCount: number;
7
- contextFileCount: number;
8
- validated: boolean;
9
- }
10
-
11
- const BRIEF_POLICIES_PATH = join(
12
- process.env.HOME || "",
13
- ".claude",
14
- "skills",
15
- "ship",
16
- "brief-policies.json",
17
- );
18
-
19
- const REQUIRED_SECTIONS = ["Goal", "ACs", "Files", "Scope", "Verify"] as const;
20
-
21
- export async function assembleBrief(opts: {
22
- slug: string;
23
- workDir: string;
24
- projectRoot: string;
25
- }): Promise<AssembleResult> {
26
- const { slug, workDir, projectRoot } = opts;
27
-
28
- const sf = join(workDir, "workflow-state.json");
29
- if (!existsSync(sf)) {
30
- throw new Error(`workflow-state.json not found at ${sf}`);
31
- }
32
-
33
- const state = JSON.parse(readFileSync(sf, "utf-8"));
34
- const acs: any[] = state.acs || [];
35
-
36
- const contextFiles = deduplicateContextFiles(acs);
37
- const verifyCommands = extractVerifyCommands(acs);
38
- const scopeOut: string[] = state.scopeOut || [];
39
-
40
- const harness = loadProjectHarness(projectRoot);
41
- const projectContextDocs = extractContextDocs(harness);
42
- const hasAgents = existsSync(join(projectRoot, "AGENTS.md"));
43
-
44
- const sections: string[] = [];
45
-
46
- sections.push(buildContextSection(projectRoot));
47
- sections.push(buildSpecAlignment(state.governingSpec));
48
- sections.push(buildTaskSection(state.issueGoal, acs));
49
- if (state.issueType === "bug-fix" || state.issueType === "bug") {
50
- sections.push(buildRCASection(state.rca));
51
- }
52
- sections.push(buildGitProtocol(state.issue));
53
- sections.push(buildFilesSection(contextFiles));
54
- sections.push(buildScopeSection(scopeOut));
55
- sections.push(buildVerifySection(verifyCommands));
56
- sections.push(buildReportSection());
57
-
58
- const brief = sections.join("\n\n");
59
- const briefPath = join(workDir, "marcus-brief.md");
60
- writeFileSync(briefPath, brief);
61
-
62
- const validated = validateBrief(brief);
63
-
64
- const projectContextCount = projectContextDocs.length + (hasAgents ? 1 : 0);
65
-
66
- return {
67
- briefPath,
68
- acCount: acs.length,
69
- contextFileCount: contextFiles.length + projectContextCount,
70
- validated,
71
- };
72
- }
73
-
74
- function deduplicateContextFiles(acs: any[]): Array<{ path: string; reason: string }> {
75
- const seen = new Set<string>();
76
- const result: Array<{ path: string; reason: string }> = [];
77
-
78
- for (const ac of acs) {
79
- for (const cf of ac.contextFiles || []) {
80
- if (!seen.has(cf.path)) {
81
- seen.add(cf.path);
82
- result.push({ path: cf.path, reason: cf.reason || "" });
83
- }
84
- }
85
- }
86
-
87
- return result;
88
- }
89
-
90
- function extractVerifyCommands(acs: any[]): string[] {
91
- const commands: string[] = [];
92
- for (const ac of acs) {
93
- const cmd = ac.evidenceMethod?.command;
94
- if (cmd) commands.push(cmd);
95
- }
96
- return commands;
97
- }
98
-
99
- function loadProjectHarness(projectRoot: string): Record<string, any> | null {
100
- const harnessPath = join(projectRoot, ".claude", "rungate.json");
101
- if (!existsSync(harnessPath)) return null;
102
- try {
103
- return JSON.parse(readFileSync(harnessPath, "utf-8"));
104
- } catch {
105
- return null;
106
- }
107
- }
108
-
109
- function extractContextDocs(harness: Record<string, any> | null): string[] {
110
- if (!harness?.contextDocs) return [];
111
- const docs = harness.contextDocs;
112
- if (Array.isArray(docs)) return docs;
113
- if (typeof docs === "object") return Object.values(docs) as string[];
114
- return [];
115
- }
116
-
117
- function buildContextSection(projectRoot: string): string {
118
- const lines = [
119
- "## Context (read first, in order)",
120
- `1. ${projectRoot}/CLAUDE.md (if exists)`,
121
- `2. ${projectRoot}/MODEL.md (PRIMARY — system flow, three rules, troubleshooting map)`,
122
- `3. ${projectRoot}/PRINCIPLES.md (ONLY if MODEL.md doesn't exist)`,
123
- `4. ${projectRoot}/ARCHITECTURE.md (ONLY if MODEL.md doesn't exist)`,
124
- ];
125
-
126
- let idx = 5;
127
-
128
- // Include AGENTS.md from project repo when present
129
- const agentsPath = join(projectRoot, "AGENTS.md");
130
- if (existsSync(agentsPath)) {
131
- lines.push(`${idx}. ${projectRoot}/AGENTS.md (agent role definitions)`);
132
- idx++;
133
- }
134
-
135
- // Include contextDocs from rungate.json
136
- const harness = loadProjectHarness(projectRoot);
137
- const contextDocs = extractContextDocs(harness);
138
- for (const doc of contextDocs) {
139
- lines.push(`${idx}. ${projectRoot}/${doc}`);
140
- idx++;
141
- }
142
-
143
- return lines.join("\n");
144
- }
145
-
146
- function buildSpecAlignment(governingSpec?: { path: string; detectedFrom?: string }): string {
147
- if (!governingSpec) {
148
- return [
149
- "## Spec Alignment",
150
- "- **Governing spec:** None detected",
151
- "- **Verified no contradiction:** N/A",
152
- ].join("\n");
153
- }
154
-
155
- return [
156
- "## Spec Alignment (MANDATORY)",
157
- `- **Governing spec:** ${governingSpec.path}`,
158
- `- **Detected from:** ${governingSpec.detectedFrom || "unknown"}`,
159
- "- **Verified no contradiction:** DA verified before brief generation",
160
- ].join("\n");
161
- }
162
-
163
- function buildTaskSection(issueGoal: string, acs: any[]): string {
164
- const lines = ["## Task", "", `**Goal:** ${issueGoal}`, ""];
165
-
166
- lines.push("### Acceptance Criteria", "");
167
- if (acs.length === 0) {
168
- lines.push("- (no acceptance criteria defined yet)");
169
- } else {
170
- for (const ac of acs) {
171
- const threshold = ac.threshold
172
- ? ` (${ac.threshold.op} ${ac.threshold.value}${ac.threshold.unit ? " " + ac.threshold.unit : ""})`
173
- : "";
174
- lines.push(`- **${ac.id}** [${ac.type || "CODE"}]: ${ac.statement}${threshold}`);
175
- }
176
- }
177
-
178
- return lines.join("\n");
179
- }
180
-
181
- function buildGitProtocol(issue: number): string {
182
- return [
183
- "## Git protocol",
184
- `- Branch: \`${issue}-deep-modules\` (create from main if not in a worktree)`,
185
- "- Before committing, rebase onto latest main",
186
- "- Commit all changes before reporting back",
187
- "- Push with `-u` before reporting",
188
- "- Never commit to main directly, never force push",
189
- ].join("\n");
190
- }
191
-
192
- function buildFilesSection(contextFiles: Array<{ path: string; reason: string }>): string {
193
- const lines = ["## Files to read before touching anything"];
194
-
195
- if (contextFiles.length === 0) {
196
- lines.push("- (no context files specified)");
197
- } else {
198
- for (const cf of contextFiles) {
199
- lines.push(`- ${cf.path}${cf.reason ? " — " + cf.reason : ""}`);
200
- }
201
- }
202
-
203
- return lines.join("\n");
204
- }
205
-
206
- function buildScopeSection(scopeOut: string[]): string {
207
- const lines = ["## Scope — do NOT touch"];
208
-
209
- if (scopeOut.length === 0) {
210
- lines.push("- (no explicit scope boundaries — stay within task scope)");
211
- } else {
212
- for (const item of scopeOut) {
213
- lines.push(`- ${item}`);
214
- }
215
- }
216
-
217
- lines.push("- Never run `make rebuild` — DA does that");
218
-
219
- return lines.join("\n");
220
- }
221
-
222
- function buildVerifySection(commands: string[]): string {
223
- const lines = ["## Verify"];
224
-
225
- if (commands.length === 0) {
226
- lines.push("- `bunx tsc --noEmit`");
227
- } else {
228
- for (const cmd of commands) {
229
- lines.push(`- \`${cmd}\``);
230
- }
231
- lines.push("- `bunx tsc --noEmit`");
232
- }
233
-
234
- return lines.join("\n");
235
- }
236
-
237
- function buildRCASection(rca?: { rootCause?: string; prediction?: string; predictionVerified?: boolean }): string {
238
- return [
239
- "## Root Cause Analysis (bug-fix)",
240
- `- **Root cause:** ${rca?.rootCause || "(investigate and fill)"}`,
241
- `- **Prediction:** ${rca?.prediction || "(what will the fix change?)"}`,
242
- `- **Prediction verified:** ${rca?.predictionVerified ?? "(verify after fix)"}`,
243
- ].join("\n");
244
- }
245
-
246
- export interface JourneyStep {
247
- action: string;
248
- wait_for?: string;
249
- assertion?: { type: string; target?: string; expected?: string };
250
- on_fail?: string;
251
- }
252
-
253
- export const MAX_JOURNEY_STEPS = 8;
254
-
255
- export function validateJourneySteps(steps: JourneyStep[]): { valid: boolean; splitRequired: boolean } {
256
- if (steps.length <= MAX_JOURNEY_STEPS) return { valid: true, splitRequired: false };
257
- return { valid: false, splitRequired: true };
258
- }
259
-
260
- export function splitJourney(steps: JourneyStep[]): JourneyStep[][] {
261
- const chunks: JourneyStep[][] = [];
262
- for (let i = 0; i < steps.length; i += MAX_JOURNEY_STEPS) {
263
- chunks.push(steps.slice(i, i + MAX_JOURNEY_STEPS));
264
- }
265
- return chunks;
266
- }
267
-
268
- function buildReportSection(): string {
269
- return [
270
- "## Report back",
271
- "For each acceptance criterion, provide evidence:",
272
- "- AC-N: → file.ts:L## [description] (code presence)",
273
- "- AC-N: → grep: \"pattern\" returned N matches (absence/presence)",
274
- "- AC-N: → test: test-name PASS (test-verified)",
275
- "Plus: files changed (paths + line numbers), test output, scope conflicts",
276
- ].join("\n");
277
- }
278
-
279
- function validateBrief(brief: string): boolean {
280
- let policies: any = null;
281
- if (existsSync(BRIEF_POLICIES_PATH)) {
282
- try {
283
- policies = JSON.parse(readFileSync(BRIEF_POLICIES_PATH, "utf-8"));
284
- } catch {
285
- // If policies can't be read, skip validation
286
- }
287
- }
288
-
289
- if (!policies?.policies?.marcus?.requiredPatterns) {
290
- // Fallback: check for required section headers
291
- for (const section of REQUIRED_SECTIONS) {
292
- const patterns: Record<string, RegExp> = {
293
- Goal: /(?:goal|objective|task)/i,
294
- ACs: /(?:acceptance criter|AC-|success criter)/i,
295
- Files: /(?:files to|files changed|file.*read)/i,
296
- Scope: /(?:scope.*not|do not touch|out of scope)/i,
297
- Verify: /(?:verify|verification)/i,
298
- };
299
- if (!patterns[section]?.test(brief)) return false;
300
- }
301
- return true;
302
- }
303
-
304
- for (const pattern of policies.policies.marcus.requiredPatterns) {
305
- let p = pattern.pattern as string;
306
- let flags = "";
307
- if (p.startsWith("(?i)")) {
308
- p = p.slice(4);
309
- flags = "i";
310
- }
311
- const re = new RegExp(p, flags);
312
- if (!re.test(brief)) return false;
313
- }
314
-
315
- return true;
316
- }
317
-
318
- // CLI entry point
319
- if (import.meta.main) {
320
- const args = process.argv.slice(2);
321
- let slug = "", workDir = "", projectRoot = "";
322
- for (let i = 0; i < args.length; i++) {
323
- if (args[i] === "--slug" && args[i + 1]) slug = args[++i];
324
- if (args[i] === "--work-dir" && args[i + 1]) workDir = args[++i];
325
- if (args[i] === "--project-root" && args[i + 1]) projectRoot = args[++i];
326
- }
327
- if (!slug || !workDir || !projectRoot) {
328
- console.error("Usage: bun run brief-assembler.ts --slug SLUG --work-dir DIR --project-root DIR");
329
- process.exit(1);
330
- }
331
- assembleBrief({ slug, workDir, projectRoot })
332
- .then(r => console.log(`Brief written: ${r.briefPath} (${r.acCount} ACs, validated=${r.validated})`))
333
- .catch(e => { console.error(e.message); process.exit(1); });
334
- }
package/gates/bunfig.toml DELETED
@@ -1,2 +0,0 @@
1
- [test]
2
- preload = ["./preload.ts"]
@@ -1,91 +0,0 @@
1
- import { test, expect, describe } from "bun:test";
2
- import { readFileSync, existsSync } from "fs";
3
- import { GoalRecordSchema, ShipEvidenceSchema, ProveEvidenceSchema } from "./schema";
4
-
5
- const TEST_DIR = process.env.TEST_WORK_DIR || "";
6
-
7
- function tryRead(filename: string) {
8
- const path = `${TEST_DIR}/${filename}`;
9
- if (!existsSync(path)) return null;
10
- return JSON.parse(readFileSync(path, "utf-8"));
11
- }
12
-
13
- describe("chain: goal → ship → prove artifacts", () => {
14
- test("goal-record.json validates if present", () => {
15
- const data = tryRead("goal-record.json");
16
- if (!data) return;
17
- const result = GoalRecordSchema.safeParse(data);
18
- if (!result.success) {
19
- const issues = result.error.issues.map(i => `${i.path.join(".")}: ${i.message}`);
20
- expect(issues).toEqual([]);
21
- }
22
- });
23
-
24
- test("goal-record has non-empty success criteria", () => {
25
- const data = tryRead("goal-record.json");
26
- if (!data) return;
27
- expect(data.successCriteria.length).toBeGreaterThan(0);
28
- });
29
-
30
- test("goal-record SCs all have thresholds", () => {
31
- const data = tryRead("goal-record.json");
32
- if (!data) return;
33
- const missing = data.successCriteria.filter((sc: any) => !sc.threshold);
34
- expect(missing.map((sc: any) => sc.id)).toEqual([]);
35
- });
36
-
37
- test("ship-evidence.json validates if present", () => {
38
- const data = tryRead("ship-evidence.json");
39
- if (!data) return;
40
- const result = ShipEvidenceSchema.safeParse(data);
41
- if (!result.success) {
42
- const issues = result.error.issues.map(i => `${i.path.join(".")}: ${i.message}`);
43
- expect(issues).toEqual([]);
44
- }
45
- });
46
-
47
- test("ship-evidence has no FAIL results when status is PASS", () => {
48
- const data = tryRead("ship-evidence.json");
49
- if (!data || data.gateOut.status !== "PASS") return;
50
- const fails = data.gateOut.evidence.filter((e: any) => e.result === "FAIL");
51
- expect(fails.map((e: any) => e.criterion)).toEqual([]);
52
- });
53
-
54
- test("prove-evidence.json validates if present", () => {
55
- const data = tryRead("prove-evidence.json");
56
- if (!data) return;
57
- const result = ProveEvidenceSchema.safeParse(data);
58
- if (!result.success) {
59
- const issues = result.error.issues.map(i => `${i.path.join(".")}: ${i.message}`);
60
- expect(issues).toEqual([]);
61
- }
62
- });
63
-
64
- test("prove verdict consistent with before/after evidence", () => {
65
- const data = tryRead("prove-evidence.json");
66
- if (!data) return;
67
- if (data.verdict === "PROVEN") {
68
- expect(data.afterEvidence.description.length).toBeGreaterThan(0);
69
- expect(data.comparisonSummary.length).toBeGreaterThan(0);
70
- }
71
- });
72
-
73
- test("prove PROVEN has no unresolved gaps", () => {
74
- const data = tryRead("prove-evidence.json");
75
- if (!data || data.verdict !== "PROVEN") return;
76
- const unresolved = (data.gaps || []).filter((g: any) => g.status === "UNPROVEN");
77
- expect(unresolved.map((g: any) => g.ac)).toEqual([]);
78
- });
79
-
80
- test("chain consistency: issue numbers match across artifacts", () => {
81
- const goal = tryRead("goal-record.json");
82
- const ship = tryRead("ship-evidence.json");
83
- const prove = tryRead("prove-evidence.json");
84
- if (!goal || !ship) return;
85
- const goalNum = parseInt(goal.id.replace("issue-", ""));
86
- expect(ship.issueNumber).toBe(goalNum);
87
- if (prove) {
88
- expect(prove.issueNumber).toBe(goalNum);
89
- }
90
- });
91
- });
@@ -1,234 +0,0 @@
1
- import { test, expect, describe } from "bun:test";
2
- import { readFileSync, existsSync } from "fs";
3
- import { join } from "path";
4
- import { WorkflowStateSchema } from "./schema";
5
- import { SIGNAL_PHRASE_PATTERNS } from "../lib/conformity";
6
-
7
- const STANDALONE = !process.env.TEST_WORK_DIR;
8
- const TEST_DIR = process.env.TEST_WORK_DIR || "/tmp/gate-e2e-smoke";
9
- const SF = `${TEST_DIR}/workflow-state.json`;
10
-
11
- function loadState(): any | null {
12
- if (!existsSync(SF)) return null;
13
- const raw = JSON.parse(readFileSync(SF, "utf-8"));
14
- return WorkflowStateSchema.passthrough().parse(raw);
15
- }
16
-
17
- function sf(path: string): any {
18
- if (!existsSync(SF)) return undefined;
19
- const wf = JSON.parse(readFileSync(SF, "utf-8"));
20
- const parts = path.replace(/^\./, "").split(".").filter(Boolean);
21
- let val: any = wf;
22
- for (const p of parts) {
23
- if (val == null) return undefined;
24
- val = val[p];
25
- }
26
- return val;
27
- }
28
-
29
- function loadSpec(path: string, projectRoot?: string): string {
30
- const resolved = path.startsWith('/') ? path : join(projectRoot || '.', path);
31
- return readFileSync(resolved, "utf-8");
32
- }
33
-
34
- function extractSpecRules(spec: string): string[] {
35
- const rules: string[] = [];
36
- for (const p of SIGNAL_PHRASE_PATTERNS) {
37
- for (const m of spec.matchAll(new RegExp(p.source, p.flags))) {
38
- rules.push(m[0].replace(/^[-*] /, "").trim().replace(/[.;]$/, ""));
39
- }
40
- }
41
- return [...new Set(rules)];
42
- }
43
-
44
- describe("E2E: governing spec compliance", () => {
45
- if (STANDALONE || !existsSync(SF)) {
46
- test("skipped — no active workflow (standalone run)", () => {});
47
- return;
48
- }
49
- const tier = sf("sizing")?.ceremonyTier;
50
- if (tier === "LIGHT") {
51
- test("skipped — spec checks not required for LIGHT tier", () => {});
52
- return;
53
- }
54
-
55
- test("governing spec exists and is readable", () => {
56
- const wf = loadState() as any;
57
- expect(wf.sourceSpecs?.[0]?.path).toBeDefined();
58
- const specPath = wf.sourceSpecs[0].path.startsWith('/') ? wf.sourceSpecs[0].path : join(wf.projectRoot || '.', wf.sourceSpecs[0].path);
59
- expect(existsSync(specPath)).toBe(true);
60
- });
61
-
62
- test("spec has extractable rules", () => {
63
- const wf = loadState() as any;
64
- const spec = loadSpec(wf.sourceSpecs[0].path, wf.projectRoot);
65
- const rules = extractSpecRules(spec);
66
- expect(rules.length).toBeGreaterThan(0);
67
- });
68
- });
69
-
70
- describe("E2E: hardcoded values violate spec", () => {
71
- if (STANDALONE || !existsSync(SF)) {
72
- test("skipped — no active workflow (standalone run)", () => {});
73
- return;
74
- }
75
- const tier = sf("sizing")?.ceremonyTier;
76
- if (tier === "LIGHT") {
77
- test("skipped — spec checks not required for LIGHT tier", () => {});
78
- return;
79
- }
80
-
81
- test("no hardcoded paths in AC statements", () => {
82
- const wf = loadState() as any;
83
- const spec = loadSpec(wf.sourceSpecs[0].path, wf.projectRoot);
84
-
85
- if (!spec.match(/never hardcod|read from config|configurable/i)) return;
86
-
87
- const hardcodedPath = /\/usr\/|\/opt\/|\/home\/|\/tmp\/[a-z]/i;
88
- const hardcodedPort = /\bport\s+\d{4}\b/i;
89
- const hits = wf.acs.filter((ac: any) =>
90
- hardcodedPath.test(ac.statement) || hardcodedPort.test(ac.statement)
91
- );
92
-
93
- expect(hits.map((ac: any) => `${ac.id}: ${ac.statement}`)).toEqual([]);
94
- });
95
-
96
- test("no hardcoded numeric thresholds in AC statements", () => {
97
- const wf = loadState() as any;
98
- const spec = loadSpec(wf.sourceSpecs[0].path, wf.projectRoot);
99
-
100
- if (!spec.match(/configurable|environment variable|config/i)) return;
101
-
102
- const hardcodedNum = /\bhardcoded to \d+\.?\d*\b/i;
103
- const hits = wf.acs.filter((ac: any) => hardcodedNum.test(ac.statement));
104
-
105
- expect(hits.map((ac: any) => `${ac.id}: ${ac.statement}`)).toEqual([]);
106
- });
107
- });
108
-
109
- describe("E2E: behavioral language violates spec", () => {
110
- if (STANDALONE || !existsSync(SF)) {
111
- test("skipped — no active workflow (standalone run)", () => {});
112
- return;
113
- }
114
- test("no 'DA should' or behavioral delegation in ACs", () => {
115
- const wf = loadState() as any;
116
- if (!wf) return;
117
- const behavioral = /\b(DA should|remember to|make sure|don't forget)\b/i;
118
- const hits = wf.acs.filter((ac: any) => behavioral.test(ac.statement));
119
-
120
- expect(hits.map((ac: any) => `${ac.id}: ${ac.statement}`)).toEqual([]);
121
- });
122
- });
123
-
124
- describe("E2E: spec-prohibited patterns in ACs", () => {
125
- if (STANDALONE || !existsSync(SF)) {
126
- test("skipped — no active workflow (standalone run)", () => {});
127
- return;
128
- }
129
- const tier = sf("sizing")?.ceremonyTier;
130
- if (tier === "LIGHT") {
131
- test("skipped — spec checks not required for LIGHT tier", () => {});
132
- return;
133
- }
134
-
135
- test("no setTimeout when spec says use backoff", () => {
136
- const wf = loadState() as any;
137
- const spec = loadSpec(wf.sourceSpecs[0].path, wf.projectRoot);
138
-
139
- if (!spec.match(/not use setTimeout|exponential backoff/i)) return;
140
-
141
- const hits = wf.acs.filter((ac: any) =>
142
- /setTimeout/i.test(ac.statement) || /setTimeout/i.test(ac.evidenceMethod?.command || "")
143
- );
144
-
145
- expect(hits.map((ac: any) => `${ac.id}: ${ac.statement}`)).toEqual([]);
146
- });
147
-
148
- test("no stdout/console.log when spec says use logger", () => {
149
- const wf = loadState() as any;
150
- const spec = loadSpec(wf.sourceSpecs[0].path, wf.projectRoot);
151
-
152
- if (!spec.match(/not write directly to stdout|use the logger/i)) return;
153
-
154
- const hits = wf.acs.filter((ac: any) =>
155
- /console\.log|stdout|directly/i.test(ac.statement)
156
- );
157
-
158
- expect(hits.map((ac: any) => `${ac.id}: ${ac.statement}`)).toEqual([]);
159
- });
160
-
161
- test("no string error handling when spec says use typed errors", () => {
162
- const wf = loadState() as any;
163
- const spec = loadSpec(wf.sourceSpecs[0].path, wf.projectRoot);
164
-
165
- if (!spec.match(/structured error|typed error|never raw string/i)) return;
166
-
167
- const hits = wf.acs.filter((ac: any) =>
168
- /string message|raw.*throw|catch.*string/i.test(ac.statement)
169
- );
170
-
171
- expect(hits.map((ac: any) => `${ac.id}: ${ac.statement}`)).toEqual([]);
172
- });
173
- });
174
-
175
- describe("E2E: Marcus brief cites governing spec", () => {
176
- if (STANDALONE || !existsSync(SF)) {
177
- test("skipped — no active workflow (standalone run)", () => {});
178
- return;
179
- }
180
- const tier = sf("sizing")?.ceremonyTier;
181
- if (tier === "LIGHT") {
182
- test("skipped — spec checks not required for LIGHT tier", () => {});
183
- return;
184
- }
185
-
186
- test("brief references spec constraints", () => {
187
- const wf = loadState() as any;
188
- if (!wf.sourceSpecs?.[0]?.path || !wf.agents?.marcus?.brief) return;
189
-
190
- const spec = loadSpec(wf.sourceSpecs[0].path, wf.projectRoot);
191
- const rules = extractSpecRules(spec);
192
- const brief = wf.agents.marcus.brief.toLowerCase();
193
-
194
- const cited = rules.filter(r =>
195
- brief.includes(r.slice(0, 25).toLowerCase())
196
- );
197
-
198
- expect(cited.length).toBeGreaterThanOrEqual(
199
- Math.min(3, rules.length)
200
- );
201
- });
202
- });
203
-
204
- // ═══ ADR-008 MIGRATION COMPLETENESS ════════════════════════════════════
205
-
206
- describe("E2E: ADR-008 migration", () => {
207
- test("ADR-008 'What to delete' files are actually deleted", () => {
208
- const adrPath = join(process.env.HOME || "", ".claude", "PAI", "ADR", "ADR-008-harness-v3-bun-tests-migration.md");
209
- if (!existsSync(adrPath)) return;
210
- const adr = readFileSync(adrPath, "utf-8");
211
-
212
- const deletionTargets = [
213
- "skills/ship/gate-runner.sh",
214
- "skills/ship/gate-checks.sh",
215
- ];
216
-
217
- const existing = deletionTargets.filter(f =>
218
- existsSync(join(process.env.HOME || "", ".claude", f))
219
- );
220
- expect(existing).toEqual([]);
221
- });
222
-
223
- test("stop-the-bleeding: no .sh files in skills/ship/", () => {
224
- const { execSync } = require("child_process");
225
- const shipDir = join(process.env.HOME || "", ".claude", "skills", "ship");
226
- try {
227
- const result = execSync(`find "${shipDir}" -name '*.sh'`, { encoding: "utf-8", timeout: 5000 }).trim();
228
- const files = result ? result.split("\n").filter(Boolean) : [];
229
- expect(files).toEqual([]);
230
- } catch {
231
- // find command failed — skip
232
- }
233
- });
234
- });