rungate 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/.claude/agents/aditi.md +47 -0
  2. package/.claude/agents/marcus.md +50 -0
  3. package/.claude/agents/quinn.md +58 -0
  4. package/.claude/agents/rook.md +47 -0
  5. package/.claude/agents/serena.md +46 -0
  6. package/.claude/rungate.json +11 -0
  7. package/.fallowrc.json +28 -0
  8. package/.github/copilot-instructions.md +20 -0
  9. package/.rungate/conformity-findings.json +648 -0
  10. package/AGENTS.md +106 -0
  11. package/CODE-MAP.md +50 -0
  12. package/HARNESS.md +88 -0
  13. package/bun.lock +26 -0
  14. package/bunfig.toml +2 -0
  15. package/config/brief-policies.json +28 -0
  16. package/config/ceremony-profiles.json +212 -0
  17. package/config/consumer-cascade-map.json +24 -0
  18. package/config/doc-cascade-map.json +24 -0
  19. package/config/eval.json +84 -0
  20. package/config/profiles/account-plan.yaml +36 -0
  21. package/config/profiles/campaign.yaml +94 -0
  22. package/config/prove-evidence.schema.json +65 -0
  23. package/config/spec-policies.json +36 -0
  24. package/config/workflow-schema.json +281 -0
  25. package/gates/SCHEMA-GUIDE.md +121 -0
  26. package/gates/ac-quality.test.ts +106 -0
  27. package/gates/adversarial.test.ts +274 -0
  28. package/gates/brief-assembler.test.ts +429 -0
  29. package/gates/brief-assembler.ts +334 -0
  30. package/gates/bunfig.toml +2 -0
  31. package/gates/chain.test.ts +91 -0
  32. package/gates/e2e-smoke.test.ts +234 -0
  33. package/gates/error-classifier.test.ts +249 -0
  34. package/gates/error-classifier.ts +89 -0
  35. package/gates/orchestrator.test.ts +950 -0
  36. package/gates/orchestrator.ts +569 -0
  37. package/gates/preload.ts +77 -0
  38. package/gates/prompts/ac-adversary.md +20 -0
  39. package/gates/prompts/evidence-validator.md +22 -0
  40. package/gates/prompts/prove-reproducer.md +53 -0
  41. package/gates/prove.test.ts +164 -0
  42. package/gates/run-gate.ts +936 -0
  43. package/gates/schema-parity.test.ts +197 -0
  44. package/gates/schema.ts +362 -0
  45. package/gates/self-heal.test.ts +511 -0
  46. package/gates/self-heal.ts +121 -0
  47. package/gates/ship-orchestrator.test.ts +379 -0
  48. package/gates/ship-orchestrator.ts +363 -0
  49. package/gates/test-fixtures/broken-no-environments.json +60 -0
  50. package/gates/test-fixtures/valid-standard.json +54 -0
  51. package/gates/test-utils.ts +43 -0
  52. package/gates/witness.ts +220 -0
  53. package/gates/workflow.test.ts +1053 -0
  54. package/hooks/AgentBriefGuard.hook.ts +586 -0
  55. package/hooks/AgentVerdictCapture.hook.ts +134 -0
  56. package/hooks/AutoVerifyGate.hook.ts +76 -0
  57. package/hooks/GateEnforcement.hook.ts +273 -0
  58. package/hooks/IssueCloseGuard.hook.ts +116 -0
  59. package/hooks/MergeGuard.hook.ts +55 -0
  60. package/hooks/StaleTTLCleanup.hook.ts +133 -0
  61. package/hooks/VerifyPhaseLock.hook.ts +81 -0
  62. package/hooks/WorkflowStateGuard.hook.ts +37 -0
  63. package/hooks/lib/agentDetection.ts +70 -0
  64. package/hooks/lib/findWorkflow.ts +101 -0
  65. package/hooks/lib/parseStdin.ts +37 -0
  66. package/hooks/lib/paths.ts +111 -0
  67. package/hooks/lib/utils.ts +81 -0
  68. package/lib/conformity.ts +959 -0
  69. package/lib/paths.ts +23 -0
  70. package/lib/rungate-schema.ts +60 -0
  71. package/lib/signal-phrases.ts +7 -0
  72. package/package.json +20 -0
  73. package/prompts/ac-adversary.md +20 -0
  74. package/prompts/ac-format.md +34 -0
  75. package/prompts/aditi.md +29 -0
  76. package/prompts/blast-radius.md +29 -0
  77. package/prompts/coding-principles.md +34 -0
  78. package/prompts/container-rebuild.md +29 -0
  79. package/prompts/container-verify.md +28 -0
  80. package/prompts/discovery.md +27 -0
  81. package/prompts/environment.md +28 -0
  82. package/prompts/escalation-decision-tree.md +38 -0
  83. package/prompts/evidence-hierarchy.md +31 -0
  84. package/prompts/evidence-validator.md +22 -0
  85. package/prompts/marcus.md +29 -0
  86. package/prompts/prevention.md +26 -0
  87. package/prompts/prove-reproducer.md +43 -0
  88. package/prompts/quinn-decision-tree.md +31 -0
  89. package/prompts/quinn-ui-brief.md +106 -0
  90. package/prompts/quinn.md +29 -0
  91. package/prompts/rca.md +28 -0
  92. package/prompts/read-before-write.md +30 -0
  93. package/prompts/regression.md +26 -0
  94. package/prompts/rook.md +29 -0
  95. package/prompts/serena.md +28 -0
  96. package/prompts/testing-strategy.md +34 -0
  97. package/reference/migration-manifest.json +554 -0
  98. package/reference/prompts/agent-aditi.md +38 -0
  99. package/reference/prompts/agent-marcus.md +38 -0
  100. package/reference/prompts/agent-quinn.md +38 -0
  101. package/reference/prompts/agent-rook.md +37 -0
  102. package/reference/prompts/agent-serena.md +37 -0
  103. package/reference/prompts/council-skill.md +170 -0
  104. package/reference/prompts/goal-skill.md +235 -0
  105. package/reference/prompts/prove-skill.md +283 -0
  106. package/reference/prompts/quinn-standard.md +246 -0
  107. package/reference/prompts/ship-convergence.md +65 -0
  108. package/reference/prompts/ship-escalation.md +43 -0
  109. package/reference/prompts/ship-iteration.md +382 -0
  110. package/reference/prompts/ship-pending-patches.md +246 -0
  111. package/reference/prompts/ship-reference.md +250 -0
  112. package/reference/prompts/ship-skill.md +347 -0
  113. package/reference/prompts/ship-templates.md +215 -0
  114. package/reference/scripts/batch-status.sh +68 -0
  115. package/reference/scripts/chain-compat-check.sh +67 -0
  116. package/reference/scripts/context-audit.sh +314 -0
  117. package/reference/scripts/dead-export-check.sh +61 -0
  118. package/reference/scripts/generate-qc-tables.sh +92 -0
  119. package/reference/scripts/harness-init.sh +111 -0
  120. package/reference/scripts/pai-054-baseline-check.sh +40 -0
  121. package/reference/scripts/prove-smoke-test.sh +112 -0
  122. package/reference/scripts/setup-keychain-salt.sh +12 -0
  123. package/reference/scripts/skill-optimizer-friday.sh +88 -0
  124. package/reference/scripts/skill-qc-test.sh +351 -0
  125. package/reference/scripts/skill-synthesize-tonight.sh +66 -0
  126. package/reference/specs/HARNESS-EXTRACTION-SPEC.md +263 -0
  127. package/reference/specs/harness-v3-bash-deletion-plan.md +65 -0
  128. package/reference/specs/harness-v3-migration-plan.md +188 -0
  129. package/scripts/decision-reconcile.sh +74 -0
  130. package/scripts/decision-reconcile.ts +152 -0
  131. package/scripts/extract-constraints.ts +260 -0
  132. package/scripts/generate-code-map.ts +339 -0
  133. package/scripts/git-hooks/pre-commit +76 -0
  134. package/scripts/git-hooks/pre-push +271 -0
  135. package/scripts/harness-skill-check.sh +52 -0
  136. package/scripts/lib/gap-emit.sh +65 -0
  137. package/scripts/lib/jq-update.sh +30 -0
  138. package/scripts/lib/resolve-slug.sh +30 -0
  139. package/scripts/lib/verify-spec-compliance.sh +102 -0
  140. package/scripts/prove-backfill.sh +87 -0
  141. package/scripts/scaffold-project.ts +1488 -0
  142. package/scripts/scaffold-rungate-config.ts +91 -0
  143. package/scripts/self-containment-check.sh +109 -0
  144. package/scripts/skill-qc-validator.sh +402 -0
  145. package/scripts/slug-resolver.sh +14 -0
  146. package/scripts/sync-spec-tests.ts +236 -0
  147. package/specs/BOOTSTRAP-DATA-FLOW-SPEC.md +2493 -0
  148. package/specs/BOOTSTRAP-TEST-PLAN.md +571 -0
  149. package/specs/HARNESS-GATES.md +256 -0
  150. package/specs/HARNESS-SKILL-CHAIN.md +286 -0
  151. package/specs/HARNESS-SKILL-CONTRACT.md +93 -0
  152. package/specs/HARNESS-STANDARD.md +488 -0
  153. package/specs/SPEC-TEMPLATE.md +53 -0
  154. package/specs/bootstrap-data-flow.png +0 -0
  155. package/specs/harness-automation-matrix.md +314 -0
  156. package/specs/harness-automation-matrix.rules.json +64 -0
  157. package/test/anti.test.ts +80 -0
  158. package/test/contract-negative.test.ts +86 -0
  159. package/test/contract.test.ts +158 -0
  160. package/test/external-deps.test.ts +48 -0
  161. package/test/fixtures/golden-project/.env.example +3 -0
  162. package/test/fixtures/golden-project/Makefile +7 -0
  163. package/test/fixtures/golden-project/docs/adr/ADR-001-framework.md +23 -0
  164. package/test/fixtures/golden-project/docs/setup-guide.md +10 -0
  165. package/test/fixtures/golden-project/package.json +10 -0
  166. package/test/fixtures/golden-project/specs/api-spec.md +20 -0
  167. package/test/fixtures/golden-project/src/auth.ts +8 -0
  168. package/test/fixtures/golden-project/src/db.ts +11 -0
  169. package/test/fixtures/golden-project/src/index.ts +19 -0
  170. package/test/fixtures/golden-project/src/utils/format.ts +3 -0
  171. package/test/fixtures/golden-project/test/auth.test.ts +15 -0
  172. package/test/fixtures/golden-project/tsconfig.json +12 -0
  173. package/test/meta-sc-coverage.test.ts +159 -0
  174. package/test/phase-0.test.ts +846 -0
  175. package/test/phase-1.test.ts +617 -0
  176. package/test/phase-2.test.ts +620 -0
  177. package/test/phase-3.test.ts +99 -0
  178. package/test/scaffold-conformity.test.ts +8 -0
  179. package/test/schema-canary.test.ts +51 -0
  180. package/test/spec-compliance-auto.test.ts +64 -0
  181. package/test/spec-compliance.test.ts +295 -0
  182. package/test/spec-discovery.test.ts +68 -0
  183. package/test/spec-drift.test.ts +5 -0
  184. package/test/structure.test.ts +165 -0
  185. package/test/unit/agent-brief-guard-ship.test.ts +293 -0
  186. package/test/unit/extract-constraints.test.ts +145 -0
  187. package/test/unit/issue-close-guard.test.ts +204 -0
  188. package/test/unit/scaffold-project.test.ts +417 -0
  189. package/test/unit/skill-cooccurrence.test.ts +177 -0
  190. package/test/unit/skill-sequence-logger.test.ts +244 -0
  191. package/test/unit/workflow-state-guard.test.ts +95 -0
  192. package/workflows/batch-ship.js +295 -0
  193. package/workflows/council.js +481 -0
  194. package/workflows/prove.js +560 -0
  195. package/workflows/ship.js +789 -0
  196. package/workflows/verify.js +236 -0
@@ -0,0 +1,236 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * sync-spec-tests.ts — Reads HARNESS-SKILL-CHAIN.md, extracts mechanical claims,
4
+ * generates spec-compliance test assertions in test/spec-compliance-auto.test.ts.
5
+ *
6
+ * Run: bun scripts/sync-spec-tests.ts
7
+ * Generates: test/spec-compliance-auto.test.ts
8
+ *
9
+ * Claim markers in the spec:
10
+ * Lines containing `make <target>` → assert target file contains the make command
11
+ * Lines containing `**GATE:**` → assert phase ordering in workflow file
12
+ * Lines containing port numbers (:7776, :7778, :5173) → assert port references
13
+ * Lines containing `Quinn` + action verb → assert Quinn integration
14
+ */
15
+
16
+ import { readFileSync, writeFileSync, readdirSync } from "fs";
17
+ import { resolve, join } from "path";
18
+
19
+ const HOME = process.env.HOME || "";
20
+ const HARNESS_ROOT = process.env.HARNESS_ROOT || join(HOME, ".claude");
21
+ const SPECS_DIR = resolve(HARNESS_ROOT, "PAI/Specs");
22
+ const SHIP_PATH = resolve(HARNESS_ROOT, "workflows/ship.js");
23
+ const PROVE_PATH = resolve(HARNESS_ROOT, "workflows/prove.js");
24
+ const OUTPUT_PATH = resolve(HARNESS_ROOT, "test/spec-compliance-auto.test.ts");
25
+
26
+ function parseTestable(content: string): boolean | null {
27
+ const fmMatch = content.match(/^---\n([\s\S]*?)\n---/);
28
+ if (!fmMatch) return null;
29
+ const testableMatch = fmMatch[1].match(/^testable:\s*(true|false)\s*$/m);
30
+ if (!testableMatch) return null;
31
+ return testableMatch[1] === "true";
32
+ }
33
+
34
+ function discoverTestableSpecs(): { path: string; name: string }[] {
35
+ const files = readdirSync(SPECS_DIR).filter(f => f.endsWith(".md"));
36
+ const testable: { path: string; name: string }[] = [];
37
+ for (const f of files) {
38
+ const fullPath = join(SPECS_DIR, f);
39
+ const content = readFileSync(fullPath, "utf-8");
40
+ if (parseTestable(content) === true) {
41
+ testable.push({ path: fullPath, name: f });
42
+ }
43
+ }
44
+ return testable;
45
+ }
46
+
47
+ interface Claim {
48
+ id: string;
49
+ spec_line: number;
50
+ claim: string;
51
+ target: "ship" | "prove" | "both";
52
+ assertion_type: "contains" | "ordering" | "port";
53
+ search_term: string;
54
+ context: string;
55
+ }
56
+
57
+ function extractClaims(spec: string): Claim[] {
58
+ const claims: Claim[] = [];
59
+ const lines = spec.split("\n");
60
+ let claimCounter = 0;
61
+
62
+ for (let i = 0; i < lines.length; i++) {
63
+ const line = lines[i];
64
+ const lineNum = i + 1;
65
+
66
+ // Make commands: make test-up, make prove-up, make test-rebuild, make rebuild
67
+ const makeMatch = line.match(/`(make\s+[\w-]+)`/);
68
+ if (makeMatch) {
69
+ const cmd = makeMatch[1];
70
+ // Determine target based on section context and command name
71
+ const isProveSection = lines.slice(Math.max(0, i - 30), i).some(l => /Step 4.*PROVE|PROVE.*post-merge|Layer 3.*Prove/i.test(l));
72
+ const isReleaseSection = lines.slice(Math.max(0, i - 20), i).some(l => /Step 5.*RELEASE|RELEASE/i.test(l));
73
+ // Skip release commands — they belong to release skill, not ship/prove
74
+ if (isReleaseSection) continue;
75
+ const target = isProveSection || cmd.includes("prove") ? "prove" : "ship";
76
+ // For ship, test-up may have been upgraded to test-rebuild — check for either
77
+ const searchTerm = cmd.replace("make ", "");
78
+ claims.push({
79
+ id: `AUTO-MAKE-${++claimCounter}`,
80
+ spec_line: lineNum,
81
+ claim: `Spec requires make ${searchTerm}`,
82
+ target,
83
+ assertion_type: "contains",
84
+ search_term: searchTerm,
85
+ context: line.trim().slice(0, 100),
86
+ });
87
+ }
88
+
89
+ // GATE markers
90
+ if (line.includes("**GATE:") || line.includes("**Gate:**")) {
91
+ const gateText = line.replace(/\*\*/g, "").replace("GATE:", "").replace("Gate:", "").trim();
92
+ const target = line.toLowerCase().includes("prove") ? "prove" : "ship";
93
+ claims.push({
94
+ id: `AUTO-GATE-${++claimCounter}`,
95
+ spec_line: lineNum,
96
+ claim: `Gate: ${gateText.slice(0, 80)}`,
97
+ target,
98
+ assertion_type: "contains",
99
+ search_term: gateText.includes("Quinn") ? "quinn" : gateText.includes("Ship gate") ? "ship" : "gate",
100
+ context: line.trim().slice(0, 100),
101
+ });
102
+ }
103
+
104
+ // Port references in context of specific tools
105
+ const portMatch = line.match(/:(\d{4})\b/);
106
+ if (portMatch) {
107
+ const port = portMatch[1];
108
+ if (["7776", "7777", "7778", "5173"].includes(port)) {
109
+ // Determine which file should reference this port
110
+ const isProveSection = lines.slice(Math.max(0, i - 20), i).some(l => /Step 4.*PROVE|PROVE.*post-merge/i.test(l));
111
+ const target = isProveSection ? "prove" : "ship";
112
+ claims.push({
113
+ id: `AUTO-PORT-${++claimCounter}`,
114
+ spec_line: lineNum,
115
+ claim: `Port ${port} referenced in ${isProveSection ? "PROVE" : "SHIP"} context`,
116
+ target,
117
+ assertion_type: "port",
118
+ search_term: port,
119
+ context: line.trim().slice(0, 100),
120
+ });
121
+ }
122
+ }
123
+
124
+ // Quinn + action verb patterns
125
+ const quinnMatch = line.match(/Quinn\s+(validates|captures|tests|navigates|compares|verifies)/i);
126
+ if (quinnMatch) {
127
+ const action = quinnMatch[1].toLowerCase();
128
+ const isProveSection = lines.slice(Math.max(0, i - 20), i).some(l => /Step 4.*PROVE|PROVE.*post-merge/i.test(l));
129
+ const target = isProveSection ? "prove" : "ship";
130
+ claims.push({
131
+ id: `AUTO-QUINN-${++claimCounter}`,
132
+ spec_line: lineNum,
133
+ claim: `Quinn ${action} in ${isProveSection ? "PROVE" : "SHIP"}`,
134
+ target,
135
+ assertion_type: "contains",
136
+ search_term: "quinn",
137
+ context: line.trim().slice(0, 100),
138
+ });
139
+ }
140
+ }
141
+
142
+ // Deduplicate by search_term + target
143
+ const seen = new Set<string>();
144
+ return claims.filter(c => {
145
+ const key = `${c.target}:${c.assertion_type}:${c.search_term}`;
146
+ if (seen.has(key)) return false;
147
+ seen.add(key);
148
+ return true;
149
+ });
150
+ }
151
+
152
+ function generateTest(claims: Claim[]): string {
153
+ const shipClaims = claims.filter(c => c.target === "ship" || c.target === "both");
154
+ const proveClaims = claims.filter(c => c.target === "prove" || c.target === "both");
155
+
156
+ const lines: string[] = [
157
+ `// AUTO-GENERATED by scripts/sync-spec-tests.ts — do not edit manually`,
158
+ `// Regenerate: bun scripts/sync-spec-tests.ts`,
159
+ `// Source: PAI/specs/HARNESS-SKILL-CHAIN.md`,
160
+ `// Generated: ${new Date().toISOString().split("T")[0]}`,
161
+ ``,
162
+ `import { test, expect, describe } from "bun:test";`,
163
+ `import { readFileSync } from "fs";`,
164
+ ``,
165
+ `const SHIP_JS = readFileSync("${SHIP_PATH}", "utf-8");`,
166
+ `const PROVE_JS = readFileSync("${PROVE_PATH}", "utf-8");`,
167
+ ``,
168
+ ];
169
+
170
+ if (shipClaims.length > 0) {
171
+ lines.push(`describe("auto-spec: ship.js claims from HARNESS-SKILL-CHAIN.md", () => {`);
172
+ for (const claim of shipClaims) {
173
+ const testName = `${claim.id}: ${claim.claim}`.replace(/"/g, '\\"');
174
+ lines.push(` // Spec line ${claim.spec_line}: ${claim.context}`);
175
+ if (claim.assertion_type === "port") {
176
+ lines.push(` test("${testName}", () => {`);
177
+ lines.push(` expect(SHIP_JS).toContain("${claim.search_term}");`);
178
+ lines.push(` });`);
179
+ } else {
180
+ lines.push(` test("${testName}", () => {`);
181
+ lines.push(` expect(SHIP_JS.toLowerCase()).toContain("${claim.search_term.toLowerCase()}");`);
182
+ lines.push(` });`);
183
+ }
184
+ lines.push(``);
185
+ }
186
+ lines.push(`});`);
187
+ lines.push(``);
188
+ }
189
+
190
+ if (proveClaims.length > 0) {
191
+ lines.push(`describe("auto-spec: prove.js claims from HARNESS-SKILL-CHAIN.md", () => {`);
192
+ for (const claim of proveClaims) {
193
+ const testName = `${claim.id}: ${claim.claim}`.replace(/"/g, '\\"');
194
+ lines.push(` // Spec line ${claim.spec_line}: ${claim.context}`);
195
+ if (claim.assertion_type === "port") {
196
+ lines.push(` test("${testName}", () => {`);
197
+ lines.push(` expect(PROVE_JS).toContain("${claim.search_term}");`);
198
+ lines.push(` });`);
199
+ } else {
200
+ lines.push(` test("${testName}", () => {`);
201
+ lines.push(` expect(PROVE_JS.toLowerCase()).toContain("${claim.search_term.toLowerCase()}");`);
202
+ lines.push(` });`);
203
+ }
204
+ lines.push(``);
205
+ }
206
+ lines.push(`});`);
207
+ }
208
+
209
+ return lines.join("\n") + "\n";
210
+ }
211
+
212
+ // Main — glob scan all testable specs
213
+ const testableSpecs = discoverTestableSpecs();
214
+ const allFiles = readdirSync(SPECS_DIR).filter(f => f.endsWith(".md"));
215
+
216
+ console.log(`Spec discovery: ${allFiles.length} specs scanned, ${testableSpecs.length} testable`);
217
+
218
+ let allClaims: Claim[] = [];
219
+ for (const spec of testableSpecs) {
220
+ const content = readFileSync(spec.path, "utf-8");
221
+ const claims = extractClaims(content);
222
+ allClaims = allClaims.concat(claims);
223
+ console.log(` ${spec.name}: ${claims.length} claims`);
224
+ }
225
+
226
+ const testContent = generateTest(allClaims);
227
+ writeFileSync(OUTPUT_PATH, testContent);
228
+
229
+ console.log(`\nTotal: ${allClaims.length} claims extracted`);
230
+ console.log(` ship.js: ${allClaims.filter(c => c.target === "ship").length}`);
231
+ console.log(` prove.js: ${allClaims.filter(c => c.target === "prove").length}`);
232
+ console.log(`Written to: ${OUTPUT_PATH}`);
233
+
234
+ for (const c of allClaims) {
235
+ console.log(` ${c.id} [${c.target}] L${c.spec_line}: ${c.claim}`);
236
+ }