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,314 @@
1
+ ---
2
+ doc-type: spec
3
+ status: active
4
+ owner: jason
5
+ created: 2026-09-07
6
+ updated: 2026-09-07
7
+ tracks: "#353"
8
+ council: "2026-09-07 — bash vs hooks vs workflows (D-001 through D-009)"
9
+ testable: true
10
+ ---
11
+
12
+ # Harness v2 Automation Matrix
13
+
14
+ Living document tracking every step in the ship cycle — what's mechanical, what's behavioral, and the fix plan. Updated each session.
15
+
16
+ ## Ship Cycle Steps
17
+
18
+ ### Chain Entry (goal → ship → prove)
19
+
20
+ | Step | Current | Issue | Status |
21
+ |---|---|---|---|
22
+ | Auto-chain: goal artifact → invoke /ship | PostToolUse on Write (AutoChainTrigger.hook.ts) | #352 | **DONE** |
23
+ | Auto-chain: ship artifact → invoke /prove | PostToolUse on Write (AutoChainTrigger.hook.ts) | #352 | **DONE** |
24
+ | Block /ship without goal-record | skill-runner.sh SUGGEST WARN | #350 | **DONE** |
25
+ | Block Marcus spawn without /ship | AgentBriefGuard Bypass 3 fix | #328 | **DONE** |
26
+ | Batch chain: /goal on umbrella cascades to children | skill-runner.sh goal pre-phase | #362 | **DONE** |
27
+
28
+ ### Ship SCOPE Phase
29
+
30
+ | Step | Current | Issue | Status |
31
+ |---|---|---|---|
32
+ | Initialize workflow-state.json | skill-runner.sh pre-phase for ship | #356 | **DONE** |
33
+ | Write .ship-active marker | skill-runner.sh pre-phase for ship | #357 | **DONE** |
34
+ | Size the work (XS/S/M/L) | **DA decides** | — | DEFERRED |
35
+ | Post DISCOVERY comment | **DA writes** | #358 | **DONE** (auto-post on gate PASS) |
36
+
37
+ ### Ship BUILD Phase
38
+
39
+ | Step | Current | Issue | Status |
40
+ |---|---|---|---|
41
+ | Write Marcus brief | **DA writes** | — | BY DESIGN |
42
+ | Validate brief (5 fields) | AgentBriefGuard template markers only | #345 | OPEN — council: brief-policies.json |
43
+ | Marcus commits changes | MarcusCommitCheck.hook.ts + tripwire signal | #361 | **DONE** |
44
+ | Merge worktree branch | **DA runs git merge** | — | DEFERRED |
45
+ | Run verify gate after Marcus | AutoVerifyGate nudge | #360 | **DONE** (phase advancement) |
46
+
47
+ ### Ship VERIFY Phase
48
+
49
+ | Step | Current | Issue | Status |
50
+ |---|---|---|---|
51
+ | Fill AC verdicts | gate-runner auto-populates from evidenceMethod | #354 | **DONE** |
52
+ | Spawn Quinn on UI changes | **DA must remember** | #343 | OPEN — council: FileChanged + tripwire |
53
+ | Record environment results | **DA writes** | — | DEFERRED |
54
+
55
+ ### Ship GATE Phase
56
+
57
+ | Step | Current | Issue | Status |
58
+ |---|---|---|---|
59
+ | Generate ship-evidence.json | gate-runner auto-generates on PASS | #355 | **DONE** |
60
+ | Post completion comment | gate-runner auto-posts on PASS | #358 | **DONE** |
61
+ | Add shipped label | gate-runner auto-adds on PASS | #360 | **DONE** |
62
+ | Advance phase to DONE | gate-runner advances on all gate PASS | #360 | **DONE** |
63
+ | Push to remote | gate-runner auto-pushes on ship PASS | #374 | **DONE** |
64
+
65
+ ### Prove Phase
66
+
67
+ | Step | Current | Issue | Status |
68
+ |---|---|---|---|
69
+ | Compute verdict mechanically | skill-runner.sh post-phase counts FAILs | #344 | **DONE** |
70
+ | Post proof comment | skill-runner.sh post-phase | — | **DONE** |
71
+ | Close issue (chain mode) | skill-runner.sh prove post-phase auto-closes on PROVEN | #373 | **DONE** |
72
+
73
+ ## Automation Score
74
+
75
+ - **Total steps in ship cycle:** 33 (expanded with D-016–D-020 checks)
76
+ - **Mechanical (DONE):** 28 (85%)
77
+ - **By design (DA's job):** 1 (3%)
78
+ - **Behavioral (OPEN):** 1 (3%)
79
+ - **Deferred:** 3 (9%)
80
+
81
+ **Target:** 80%+ mechanical. Session start: 30%. Prior session: 75%. QC session: 82%. Current: **85%** ✅ target exceeded.
82
+
83
+ **QC session (2026-09-07/08) added:** D-019 ceremony tier (#397), D-017 HMAC provenance (#398), D-018 chain advancement (#399), D-020 decision-ID tracing (#400), D-016 evidence classification (#401). Plus 8 infrastructure fixes (Wave 8).
84
+
85
+ ## Waves (Implementation Plan)
86
+
87
+ ### Wave 1: Foundation (COMPLETE — this session)
88
+
89
+ | Issue | What | Commit | Status |
90
+ |---|---|---|---|
91
+ | #328 | Engineer spawn gate fix | ccd8d43d | **Proven** ✅ |
92
+ | #350 | Auto-chain trigger | 5f127abb | **Proven** ✅ |
93
+ | #352 | Unified work dir + auto-chain on Write | e4551ab7 | **Proven** ✅ |
94
+
95
+ ### Wave 2: Gate-Runner Automation (COMPLETE — this session)
96
+
97
+ | Issue | What | Commit | Status |
98
+ |---|---|---|---|
99
+ | #354 | AC verdicts auto-populated | b38a98f6 | **Proven** ✅ |
100
+ | #355 | ship-evidence.json auto-generated | b38a98f6 | **Proven** ✅ |
101
+ | #360 | Phase advancement + shipped label | b38a98f6 | **Proven** ✅ |
102
+ | #356 | workflow-state.json auto-initialized | a4549427 | **Proven** ✅ |
103
+ | #357 | .ship-active auto-written | a4549427 | **Proven** ✅ |
104
+ | #358 | Completion comment auto-posted | 8aa829e5 | **Proven** ✅ |
105
+ | #344 | Prove verdict mechanical | 8aa829e5 | **Proven** ✅ |
106
+
107
+ ### Wave 3: Architecture (COMPLETE)
108
+
109
+ **Pattern:** Tripwire — hooks detect + write signals, bash reads + enforces (D-005)
110
+
111
+ | Issue | What | Commit | Status |
112
+ |---|---|---|---|
113
+ | #361 | Marcus commit enforcement | (prior session) | **Proven** ✅ |
114
+ | #343 | Quinn auto-spawn on UI changes | (prior session) | **Proven** ✅ |
115
+ | #345 | Brief content validation | (prior session) | **Proven** ✅ |
116
+ | D-006 | Split gate-runner.sh | Moved to Wave 4 (#376) | **Proven** ✅ |
117
+
118
+ ### Wave 4: Chain Orchestration (umbrella #375)
119
+
120
+ | Issue | What | Commit | Status |
121
+ |---|---|---|---|
122
+ | #373 | Auto-close issue on PROVEN | (prior session) | **Proven** ✅ |
123
+ | #329 | Evidence commands in issue body | 01244560 | **Proven** ✅ |
124
+ | #374 | Auto-push on ship gate PASS | 73e2ad40 | **Proven** ✅ |
125
+ | #376 | Split gate-runner.sh into modules | d28ff318 | **Proven** ✅ |
126
+ | #362 | Batch chain mode | 43f2993f | **Proven** ✅ |
127
+
128
+ ### Wave 5: Shared Lib Extraction (umbrella #369)
129
+
130
+ | Issue | What | Commit | Status |
131
+ |---|---|---|---|
132
+ | #372 | Path constants (BASE_DIR/WORK_DIR) | 4fe21eab | **Proven** ✅ |
133
+ | #371 | Agent detection (Marcus/Quinn/Rook) | 32e7ad2d | **Proven** ✅ |
134
+ | #368 | Slug resolution | ff830082 | **Proven** ✅ |
135
+ | #370 | Stdin JSON parsing (34 hooks) | 1cb2fe68 | **Proven** ✅ |
136
+
137
+ ### Wave 6: Gate Architecture
138
+
139
+ | Issue | What | Mechanism | Effort |
140
+ |---|---|---|---|
141
+ | #308 | Registry-based universal gating | 136fc1d1 | **Proven** ✅ |
142
+ | #377 | Scope gate: validate SCs follow spec principles | e37f8925 | **Proven** ✅ |
143
+ | #366 | Completion comment evidence format | gate-runner SC table | XS |
144
+ | #331 | chain-state.json for resume | 29513c78 | **Proven** ✅ |
145
+ | #334 | Chain YAML skip-list for sizing | Superseded by ceremony-profiles + #331 | **Closed** (wontfix) |
146
+ | #336 | Council signal after STANDARD+ ships | Already in skill-runner.sh:1005 | **Closed** ✅ |
147
+ | #378 | Fix code-pushed circular dependency in pre-push | 7844db37 | **Proven** ✅ |
148
+ | #307 | Doc-hygiene: format stamping → content alignment | Global, project-agnostic | M |
149
+ | #379 | Extract spec-alignment patterns to spec-policies.json | 07093bb7 | **Proven** ✅ |
150
+ | #380 | Post-ship drift audit: verify impl follows spec decisions | 98b9f144 | **Proven** ✅ |
151
+ | #381 | Pre-push uses stale gate results from prior issues | 20f3a7ce | **Proven** ✅ |
152
+ | #382 | Data-driven agent detection config | 00d56ee0 | **Proven** ✅ |
153
+ | #384 | Prove coverage count + cached issueSCs (D-010, D-011) | Coverage check before auto-close | S |
154
+ | #385 | Expand batch mode scope checks (D-012) | a411ed10 | **Proven** ✅ |
155
+
156
+ ### Wave 7: Precision + Promotion (data-gated)
157
+
158
+ | Issue | What | Decision | Effort |
159
+ |---|---|---|---|
160
+ | #386 | Improve acs-no-skillmd-enforcement regex precision | D-013 | S |
161
+ | — | WARN→FAIL promotion (after D-013 validates) | D-014 | XS (gated) |
162
+ | — | Evidence-target-alignment (if D-010 data insufficient) | D-015 | M (gated) |
163
+
164
+ ### Wave 8: Gaps from QC Session (2026-09-07)
165
+
166
+ | Issue | What | Severity | Effort |
167
+ |---|---|---|---|
168
+ | #390 | .ship-active markers never cleaned after prove/close | eec3c723 | **Fixed** ✅ |
169
+ | #391 | SecurityValidator blocks JSON config writes to hooks/lib/ | c5f5528f | **Fixed** ✅ |
170
+ | #392 | gate-checks.sh line 313 syntax error on scope gate | Fixed by #379 refactor | **Closed** ✅ |
171
+ | #387 | ac-populate.sh crashes under set -e pre-BUILD | 7e5470a2 | **Fixed** ✅ |
172
+ | #388 | Pre-push symlink broken for resolve-slug.sh | 7e5470a2 | **Fixed** ✅ |
173
+ | #389 | Goal skill missing decomposed label on umbrellas | 7e5470a2 | **Fixed** ✅ |
174
+ | #393 | Pre-push validates against wrong issue's .ship-active | 9d0bb23c — commit-message resolution | **Fixed** ✅ |
175
+ | #394 | AgentBriefGuard error message references stale path | cbf80eaf | **Fixed** ✅ |
176
+
177
+ ### Wave 9: Council Decisions (D-016 through D-020)
178
+
179
+ | Issue | What | Decision | Status |
180
+ |---|---|---|---|
181
+ | #397 | Default STANDARD + mechanical tier computation + one-way ratchet | D-019 | **Proven** ✅ |
182
+ | #398 | HMAC provenance on gate PASS — blocks fake workflow-states | D-017 | **Proven** ✅ |
183
+ | #399 | Chain advancement via successors in skill-registry.json | D-018 | **Proven** ✅ |
184
+ | #400 | Decision-ID tracing + evidence-target validation in gate checks | D-020 | **Proven** ✅ |
185
+ | #401 | Evidence-type classification (pattern/unit/behavioral) + ratio check | D-016 | **Proven** ✅ |
186
+
187
+ ### Deferred
188
+
189
+ | Issue | What | Priority |
190
+ |---|---|---|
191
+ | #310 | Research workflows vs bash | p2 (council decided hybrid) |
192
+ | #330 | L3 cross-skill compatibility | p3 |
193
+ | #295 | Council structured decisions | p2 |
194
+ | #281 | Framework repo extraction | p3 |
195
+ | #337 | /audit skill implementation | p3 |
196
+ | #338-341 | AgentGrit integration | p4 |
197
+ | #312 | Council frontmatter protection | p4 |
198
+ | #342 | Doc archival: prune stale docs from DOCS.md/INDEX.md | p2 |
199
+
200
+ ## Council Decisions (2026-09-07)
201
+
202
+ | ID | Decision | Status |
203
+ |---|---|---|
204
+ | D-001 | #361 via SubagentStop hook + tripwire signal | **SHIPPED** (#361) |
205
+ | D-002 | #343 via FileChanged hook + tripwire signal | **SHIPPED** (#343) |
206
+ | D-003 | #345 via brief-policies.json in AgentBriefGuard | **SHIPPED** (#345) |
207
+ | D-004 | #362 via sequential Skill + chain-state.json | **SHIPPED** (#362) |
208
+ | D-005 | **Tripwire pattern**: hooks detect, bash enforces | ACCEPTED (architectural — no issue) |
209
+ | D-006 | **Split gate-runner.sh** into 4 modules + orchestrator | **SHIPPED** (#376) |
210
+ | D-007 | GitHub posting stays as module, not hook | ACCEPTED (architectural — no issue) |
211
+ | D-008 | Migrate verdict threshold logic to TS | DEFERRED |
212
+ | D-009 | Full bash-to-TS migration | REJECTED |
213
+ | D-010 | **prove-coverage-count**: compare GoalRecord SC count vs criteriaResults count before auto-close | **SHIPPED** (#384) |
214
+ | D-011 | **Cache issueSCs** in goal-record.json at goal time | **SHIPPED** (#384) |
215
+ | D-012 | **Batch mode scope expansion**: add acs-no-skillmd-enforcement + acs-no-behavioral-language | **SHIPPED** (#385) |
216
+ | D-013 | **Improve acs-no-skillmd-enforcement regex**: distinguish enforcement vs documentation refs | ACCEPTED (Wave 7, #386) |
217
+ | D-014 | **WARN→FAIL promotion**: conditional on D-013 precision >80% over 10+ ship cycles | CONDITIONAL (data-gated) |
218
+ | D-015 | **Defer evidence-target-alignment**: monitor D-010 coverage data first | DEFERRED |
219
+ | D-016 | **SC evidence classification**: `evidenceType` enum (pattern/unit/behavioral). STANDARD+ WARNs if >50% pattern | **SHIPPED** (#401, 29019fc8) |
220
+ | D-017 | **Gate result provenance via HMAC**: gate-runner computes hash, IssueCloseGuard validates. Blocks fake PASS | **SHIPPED** (#398, b51ac2b1) |
221
+ | D-018 | **Chain advancement in orchestrator**: skill-runner.sh drives chain (not Write-tool hook). AutoChainTrigger as fallback | **SHIPPED** (#399, 1a81cf4e) |
222
+ | D-019 | **Ceremony tier mechanical computation**: Default STANDARD. Compute from AC+file count. One-way ratchet | **SHIPPED** (#397, b9df31b4) |
223
+ | D-020 | **Structural spec alignment via decision-ID tracing**: SCs cite spec decision IDs. Gate validates IDs exist in spec | **SHIPPED** (#400, cb991c4f) |
224
+
225
+ ### Council Decisions (2026-09-08 — QC systemic + viability)
226
+
227
+ | ID | Decision | Priority | Status |
228
+ |---|---|---|---|
229
+ | D-021 | **Gate-salt rotation**: gitignore, generate per-machine, chmod 600 | Wave 1 (security) | ACCEPTED |
230
+ | D-022 | **IssueCloseGuard v1 removal** + silent catch-block signal-writing | Wave 1 (security) | ACCEPTED |
231
+ | D-023 | **safe_grep wrapper** + inherit_errexit + shellcheck | Wave 1 (security) | ACCEPTED |
232
+ | D-024 | **AgentBriefGuard marker validation** with diagnostic catches | Wave 1 (security) | ACCEPTED |
233
+ | D-025 | **Pre-push verify-only** + commit-prefix fast-path (solves Gap #19 + circular dep) | Wave 2 (infra) | ACCEPTED |
234
+ | D-026 | **Per-project ceremony overrides** with protected-checks | Wave 2 (infra) | ACCEPTED |
235
+ | D-027 | **HOTFIX bypass hardening**: rate-limit, format validation, GitHub logging | Wave 2 (infra) | ACCEPTED |
236
+ | D-028 | **jq_update extraction** to scripts/lib/jq-update.sh | Wave 2 (infra) | ACCEPTED |
237
+ | D-029 | **Gate output grouping** with per-category rollups (EVIDENCE/BUILD/ENV/SPEC) | Wave 3 (UX) | ACCEPTED |
238
+ | D-030 | **D-008 amendment** — second TS extraction trigger | Wave 3 (governance) | ACCEPTED |
239
+ | D-031 | **Pre-push path resolution** for cross-project symlinks | Wave 3 (infra) | ACCEPTED |
240
+ | D-032 | **Spec #378 contradiction** cleanup (OPEN→Proven) | Wave 3 (hygiene) | **SHIPPED** (#417) |
241
+
242
+ ### Council Decisions (2026-09-08 — mechanical learning loop)
243
+
244
+ | ID | Decision | Status |
245
+ |---|---|---|
246
+ | D-033 | **No new gaps.jsonl** — use existing harness-telemetry.jsonl + gate-runs.jsonl | ACCEPTED (unanimous) |
247
+ | D-034 | **Enrich emit()** with gap_type field in gate-runner.sh (3 lines) | ACCEPTED |
248
+ | D-035 | **Hybrid filing**: prompted in interactive, auto-file in AFK (capped at 5/cycle) | ACCEPTED |
249
+ | D-036 | **Session-end gap summary** with progressive disclosure, not a new skill | ACCEPTED |
250
+ | D-037 | **Self-modification firewall**: no automated path from gap data to gate enforcement | ACCEPTED (unanimous) |
251
+ | D-038 | **Deprecate feedback_emit()**: dead code in skill-runner.sh:76, zero call sites | ACCEPTED |
252
+ | D-039 | **AgentGrit reads, PAI emits**: PAI thin (5 lines/skill), AgentGrit thick (patterns, correlation) | ACCEPTED (per CLAUDE.md rule) |
253
+
254
+ ### Infrastructure Fixes (discovered during Wave 3)
255
+
256
+ | Issue | What | Fix | Status |
257
+ |---|---|---|---|
258
+ | #363 | evidence-type-valid crashes on string evidence | `select(type == "object")` guard | **DONE** |
259
+ | #364 | Gate-runner hangs (recursive QC → gate-runner loop) | `GATE_RUNNER_ACTIVE` env guard + tsc-pass tsconfig check | **DONE** |
260
+ | #365 | Prod checks FAIL for non-containerized projects | `check_skip()` detects null `prod.rebuild` | **DONE** |
261
+ | #367 | Pre-push nested slug resolution | `${path#${WORK_DIR}/}` preserves relative path | **DONE** |
262
+
263
+ ## Key Architectural Decisions
264
+
265
+ 1. **Unified work dir:** All hooks read from RUNGATE_WORK_DIR (~/.rungate/). MEMORY/WORK is legacy. (#352)
266
+ 2. **Auto-chain on Write:** PostToolUse on Write detects artifact creation. (#352)
267
+ 3. **Data-driven enforcement:** skill-registry.json + enforcement-policies.json. Adding enforcement = adding JSON, not code. (#306)
268
+ 4. **SKILL.md is docs-only:** Skills run on runner + gates, not on instructions. (#349)
269
+ 5. **Tripwire pattern:** Hooks own detection (thin tripwires writing signals). Bash owns enforcement (reads signals, gates). (Council D-005)
270
+ 6. **TS migration threshold:** When a bash function needs >2 jq pipes with conditional field access, extract that function to TS. Not whole files. (Council D-008/D-009)
271
+ 7. **Deep modules, thin consumers:** Shared logic lives in `scripts/lib/` (bash) and `hooks/lib/` (TS). Consumers source the lib and call one function. If a pattern appears in 2+ files, extract to a lib. Prevents duplicate-fix bugs like #367 (slug resolution fixed 4 times). Audit: #369.
272
+ 8. **Spec-alignment at scope gate:** SCs must target scripts/hooks/gates for enforcement, never SKILL.md (docs-only). Behavioral language ("DA should", "remember to") in SCs triggers WARN — mechanical enforcement required. #377.
273
+ 9. **WARN→data→FAIL ladder:** New checks ship as WARN. Run 10+ ship cycles. Measure false positive rate. Promote to FAIL only if precision >80%. Document promotion decision with data. (Council 2026-09-07)
274
+ 10. **Prove coverage count:** Prove must verify criteriaResults count matches GoalRecord SC count before auto-close. WARN on mismatch — prevents closing with incomplete proof. (Council D-010, #384)
275
+ 11. **Cache issue SCs at goal time:** GoalRecord stores `issueSCs[]` extracted from issue body at creation. Prove reads cache — no API call at prove time. (Council D-011, #384)
276
+
277
+ ## Verification Gaps (Council 2026-09-07)
278
+
279
+ | Gap | Description | Fix | Issue |
280
+ |---|---|---|---|
281
+ | A | No cross-check between GoalRecord SCs and issue body SCs | D-010 + D-011 | #384 |
282
+ | B | Evidence command scope not validated against assertion text | D-015 (deferred, monitor D-010) | — |
283
+ | C | LIGHT tier skips scope gate entirely | By design (XS ceremony) | — |
284
+ | D | Prove gate checks verdict but not criteria completeness | D-010 | #384 |
285
+ | F | Auto-close fires on PROVEN without coverage check | D-010 | #384 |
286
+ | G | Batch mode scope checks limited to acs-measurable only | D-012 | new issue |
287
+
288
+ ## Shared Lib Extraction Plan (#369 audit, 2026-09-07)
289
+
290
+ | Priority | Pattern | Sites | Target Lib |
291
+ |---|---|---|---|
292
+ | HIGH | Stdin JSON parsing | 27 hooks | `hooks/lib/parseStdin.ts` |
293
+ | HIGH | Agent detection | 2+ | `hooks/lib/agentDetection.ts` |
294
+ | HIGH | Path construction | 4+ | `hooks/lib/paths.ts` |
295
+ | MEDIUM | Issue extraction | 1 outlier | Fix import in AutoChainTrigger |
296
+ | MEDIUM | Atomic write | 2 | `hooks/lib/atomicWrite.ts` |
297
+ | MEDIUM | Signal write | 2+ | `hooks/lib/signals.ts` |
298
+ | MEDIUM | Telemetry append | 3 | `scripts/lib/telemetry.sh` |
299
+ | MEDIUM | Slug resolution | 4 (fixed) | `scripts/lib/resolve-slug.sh` (#368) |
300
+
301
+ ## Hook Events (21 available, using 8)
302
+
303
+ | Event | Hooks | New Uses (council-approved) |
304
+ |---|---|---|
305
+ | PreToolUse | 13 | #345: brief-policies.json validation |
306
+ | PostToolUse | 10 | Auto-chain on Write (done) |
307
+ | PostToolBatch | 0 | Future: stronger nudge pattern |
308
+ | Stop | 4 | — |
309
+ | SessionStart | 7 | — |
310
+ | SessionEnd | 11 | — |
311
+ | UserPromptSubmit | 5 | — |
312
+ | **SubagentStop** | **0** | **#361: Marcus commit check + tripwire** |
313
+ | **FileChanged** | **0** | **#343: UI file detection + tripwire** |
314
+ | Others (12) | 0 | Not planned |
@@ -0,0 +1,64 @@
1
+ {
2
+ "description": "Enforcement rules for harness-automation-matrix.md — derived from Key Architectural Decisions",
3
+ "spec": "PAI/specs/harness-automation-matrix.md",
4
+
5
+ "pattern_rules": [
6
+ {
7
+ "id": "no-hardcoded-thresholds",
8
+ "decision": "#3",
9
+ "pattern": "(THRESHOLD|_CAP|_LIMIT|_MAX|_MIN)=[0-9]",
10
+ "scope": "changed",
11
+ "severity": "WARN",
12
+ "max_occurrences": 0,
13
+ "message": "Hardcoded threshold — move to config JSON (Decision #3: data-driven)"
14
+ },
15
+ {
16
+ "id": "no-duplicated-jq-update",
17
+ "decision": "#7",
18
+ "pattern": "jq_update\\(\\)",
19
+ "scope": "all-bash",
20
+ "severity": "WARN",
21
+ "max_occurrences": 1,
22
+ "message": "jq_update defined in multiple files — use scripts/lib/jq-update.sh (Decision #7: deep modules)"
23
+ },
24
+ {
25
+ "id": "no-behavioral-language-in-scripts",
26
+ "decision": "#8",
27
+ "pattern": "(DA should|remember to|must manually|don.t forget)",
28
+ "scope": "changed",
29
+ "severity": "WARN",
30
+ "max_occurrences": 0,
31
+ "message": "Behavioral language in code — use mechanical enforcement (Decision #8)"
32
+ },
33
+ {
34
+ "id": "no-hardcoded-telemetry-path",
35
+ "decision": "#7",
36
+ "pattern": "harness-telemetry\\.jsonl",
37
+ "scope": "changed",
38
+ "severity": "WARN",
39
+ "max_occurrences": 1,
40
+ "message": "Telemetry path hardcoded — use shared constant from paths lib (Decision #7)"
41
+ }
42
+ ],
43
+
44
+ "behavior_rules": [
45
+ {
46
+ "id": "bash-syntax-valid",
47
+ "command": "find scripts/ skills/ship/ -name '*.sh' -exec bash -n {} \\; 2>&1 | grep -c 'syntax error' || echo 0",
48
+ "expect": "0",
49
+ "message": "All bash scripts must parse without syntax errors"
50
+ },
51
+ {
52
+ "id": "no-empty-catches-hooks",
53
+ "command": "grep -rn 'catch {' hooks/*.ts 2>/dev/null | grep -cv 'console.error' || echo 0",
54
+ "expect": "0",
55
+ "message": "All catch blocks must have diagnostic output (D-005 tripwire)"
56
+ },
57
+ {
58
+ "id": "gate-salt-not-tracked",
59
+ "command": "git ls-files hooks/lib/.gate-salt 2>/dev/null | wc -l | tr -d ' '",
60
+ "expect": "0",
61
+ "message": "Gate salt must not be git-tracked (D-021)"
62
+ }
63
+ ]
64
+ }
@@ -0,0 +1,80 @@
1
+ import { test, expect, describe } from "bun:test";
2
+ import { existsSync, readFileSync, readdirSync } from "fs";
3
+ import { join } from "path";
4
+ import { execSync } from "child_process";
5
+
6
+ const HARNESS = join(import.meta.dir, "..");
7
+
8
+ describe("Anti-Criteria: must NOT happen", () => {
9
+
10
+ // SC-A1: No workflow file references specific projects
11
+ describe("SC-A1: no project-specific references in workflows", () => {
12
+ test("no DailyBriefDashboard references", () => {
13
+ const files = findTsFiles(HARNESS, ["gates", "scripts", "lib"]);
14
+ const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
15
+ expect(content).not.toContain("DailyBriefDashboard");
16
+ });
17
+
18
+ test("no asaCommandCenter references", () => {
19
+ const files = findTsFiles(HARNESS, ["gates", "scripts", "lib"]);
20
+ const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
21
+ expect(content).not.toContain("asaCommandCenter");
22
+ });
23
+ });
24
+
25
+ // SC-A2: No hardcoded file paths in rungate.json generation
26
+ describe("SC-A2: no hardcoded paths in config generation", () => {
27
+ test("no dashboard/src/App.tsx in scaffold", () => {
28
+ const scaffold = readFileSync(join(HARNESS, "scripts/scaffold-project.ts"), "utf-8");
29
+ expect(scaffold).not.toContain("dashboard/src/App.tsx");
30
+ });
31
+
32
+ test("no callGemini patterns in scaffold", () => {
33
+ const scaffold = readFileSync(join(HARNESS, "scripts/scaffold-project.ts"), "utf-8");
34
+ expect(scaffold).not.toContain("callGemini");
35
+ });
36
+ });
37
+
38
+ // SC-A3: No "PAI" references in runtime paths
39
+ describe("SC-A3: no PAI naming in runtime paths", () => {
40
+ test("no .pai- prefixed paths in gate/lib code", () => {
41
+ const files = findTsFiles(HARNESS, ["gates", "lib", "scripts"]);
42
+ for (const f of files) {
43
+ const content = readFileSync(f, "utf-8");
44
+ const lines = content.split("\n");
45
+ for (let i = 0; i < lines.length; i++) {
46
+ const line = lines[i];
47
+ // Skip comments and strings that are documentation
48
+ if (line.trim().startsWith("//") || line.trim().startsWith("*")) continue;
49
+ // Check for .pai- in actual path construction
50
+ if (line.match(/["'`].*\.pai-/) && !line.includes("CLAUDE.md") && !line.includes("doc-type")) {
51
+ expect(`${f}:${i + 1}: ${line.trim()}`).not.toMatch(/\.pai-/);
52
+ }
53
+ }
54
+ }
55
+ });
56
+
57
+ test("lock files use rungate naming", () => {
58
+ const files = findTsFiles(HARNESS, ["gates", "lib", "scripts"]);
59
+ const content = files.map(f => readFileSync(f, "utf-8")).join("\n");
60
+ // If there are lock file references, they should use rungate, not pai
61
+ if (content.includes("lock")) {
62
+ expect(content).not.toMatch(/pai-testing-lock|\.pai-lock/);
63
+ }
64
+ });
65
+ });
66
+ });
67
+
68
+ function findTsFiles(root: string, dirs: string[]): string[] {
69
+ const files: string[] = [];
70
+ for (const dir of dirs) {
71
+ const dirPath = join(root, dir);
72
+ if (!existsSync(dirPath)) continue;
73
+ for (const f of readdirSync(dirPath)) {
74
+ if (f.endsWith(".ts") && !f.endsWith(".test.ts")) {
75
+ files.push(join(dirPath, f));
76
+ }
77
+ }
78
+ }
79
+ return files;
80
+ }
@@ -0,0 +1,86 @@
1
+ import { test, expect, describe } from "bun:test";
2
+ import { mkdirSync, writeFileSync } from "fs";
3
+ import { join } from "path";
4
+ import { execSync } from "child_process";
5
+
6
+ const TEST_BASE = "/tmp/harness-contract-neg";
7
+ const GATES_DIR = join(import.meta.dir, "..", "gates");
8
+
9
+ function runGate(gate: string, slug: string): { pass: number; fail: number; output: string } {
10
+ const gateRunner = join(GATES_DIR, "run-gate.ts");
11
+ const cmd = `RUNGATE_WORK_DIR=${TEST_BASE} RUNGATE_SKIP_AGENTS=1 bun run ${gateRunner} --gate ${gate} --slug ${slug} --issue 9999 2>&1`;
12
+ try {
13
+ const output = execSync(cmd, { encoding: "utf-8", timeout: 30000 });
14
+ const passMatch = output.match(/(\d+) pass/);
15
+ const failMatch = output.match(/(\d+) fail/);
16
+ return { pass: passMatch ? parseInt(passMatch[1]) : 0, fail: failMatch ? parseInt(failMatch[1]) : 0, output };
17
+ } catch (e: any) {
18
+ const out = (e.stdout || "") + (e.stderr || "");
19
+ const passMatch = out.match(/(\d+) pass/);
20
+ const failMatch = out.match(/(\d+) fail/);
21
+ return { pass: passMatch ? parseInt(passMatch[1]) : 0, fail: failMatch ? parseInt(failMatch[1]) : 0, output: out };
22
+ }
23
+ }
24
+
25
+ function makeNegFixture(slug: string, state: any): void {
26
+ const dir = join(TEST_BASE, slug);
27
+ mkdirSync(dir, { recursive: true });
28
+ writeFileSync(join(dir, "workflow-state.json"), JSON.stringify(state, null, 2));
29
+ if (state.agents?.marcus?.spawned) {
30
+ const acIds = (state.acs || []).map((ac: any) => ac.id).join(", ");
31
+ writeFileSync(join(dir, "marcus-brief.md"), `# Marcus Brief\n\nCovers: ${acIds}\n\n${(state.acs || []).map((ac: any) => `## ${ac.id}\n${ac.statement}`).join("\n\n")}\n`);
32
+ }
33
+ }
34
+
35
+ const BASE = {
36
+ schemaVersion: 2, repo: "test/repo", issueRepo: "test/repo",
37
+ projectRoot: "/tmp/test", phase: "DONE",
38
+ sizing: { predicted: "S", ceremonyTier: "STANDARD" },
39
+ sourceSpecs: [{ path: join(process.env.HOME || "", "Projects/rungate/specs/BOOTSTRAP-DATA-FLOW-SPEC.md"), citedInDiscovery: true }],
40
+ gates: { scope: { result: "PASS", attempt: 1, failures: [] }, verify: { result: "PASS", attempt: 1, failures: [] } },
41
+ environments: { local: { api: "PASS", ui: "PASS", tests: "PASS" } },
42
+ agents: { marcus: { spawned: true, verdict: "PASS" } },
43
+ buildCommit: "abc1234", changelog: [], bootstrappedFrom: "ship-workflow",
44
+ };
45
+
46
+ describe("contract: negative — missing environments fails ship", () => {
47
+ test("fails", () => {
48
+ makeNegFixture("broken-env", {
49
+ ...BASE, issue: 9997, slug: "broken-env", issueGoal: "Broken env test",
50
+ acs: [{ id: "AC-1", type: "CODE", statement: "Fix applied correctly to module", threshold: { op: "contains", value: "fix" }, evidenceMethod: { type: "BUN_TEST", command: "bun test" }, evidence: { type: "command-output", content: "24 pass" }, verdict: "PASS" }],
51
+ environments: {},
52
+ });
53
+ const r = runGate("ship", "broken-env");
54
+ expect(r.fail).toBeGreaterThan(0);
55
+ });
56
+ });
57
+
58
+ describe("contract: negative — all-grep evidence fails ratio", () => {
59
+ test("fails", () => {
60
+ makeNegFixture("broken-grep", {
61
+ ...BASE, issue: 9996, slug: "broken-grep", issueGoal: "Broken grep test",
62
+ acs: [
63
+ { id: "AC-1", type: "CODE", statement: "First check passes via grep only", threshold: { op: ">=", value: 10 }, evidenceMethod: { type: "grep", command: "grep x y" }, evidence: { type: "command-output", content: "10" }, verdict: "PASS" },
64
+ { id: "AC-2", type: "CODE", statement: "Second check passes via grep only", threshold: { op: ">=", value: 10 }, evidenceMethod: { type: "grep", command: "grep x y" }, evidence: { type: "command-output", content: "10" }, verdict: "PASS" },
65
+ { id: "AC-3", type: "CODE", statement: "Third check passes via grep only", threshold: { op: ">=", value: 10 }, evidenceMethod: { type: "grep", command: "grep x y" }, evidence: { type: "command-output", content: "10" }, verdict: "PASS" },
66
+ { id: "AC-4", type: "CODE", statement: "Fourth check passes via grep only", threshold: { op: ">=", value: 10 }, evidenceMethod: { type: "grep", command: "grep x y" }, evidence: { type: "command-output", content: "10" }, verdict: "PASS" },
67
+ ],
68
+ });
69
+ const r = runGate("ship", "broken-grep");
70
+ expect(r.output).toContain("evidence-type-ratio");
71
+ });
72
+ });
73
+
74
+ describe("contract: negative — missing AC evidence fails ship", () => {
75
+ test("fails", () => {
76
+ makeNegFixture("broken-evidence", {
77
+ ...BASE, issue: 9995, slug: "broken-evidence", issueGoal: "Broken evidence test",
78
+ acs: [
79
+ { id: "AC-1", type: "CODE", statement: "Has evidence from test run output", threshold: { op: ">=", value: 10 }, evidenceMethod: { type: "BUN_TEST", command: "bun test" }, evidence: { type: "command-output", content: "24 pass" }, verdict: "PASS" },
80
+ { id: "AC-2", type: "CODE", statement: "Missing evidence for grep verification", threshold: { op: ">=", value: 10 }, evidenceMethod: { type: "grep", command: "grep x y" }, verdict: "PENDING" },
81
+ ],
82
+ });
83
+ const r = runGate("ship", "broken-evidence");
84
+ expect(r.output).toContain("all-acs-have-evidence");
85
+ });
86
+ });