rungate 0.2.0 → 0.3.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 (282) hide show
  1. package/bin/rungate.ts +70 -0
  2. package/lib/aes-calculator.ts +66 -0
  3. package/lib/agent-audit.ts +139 -0
  4. package/lib/agent-brief-validation.ts +359 -0
  5. package/lib/agents-md-refs.ts +90 -0
  6. package/lib/bash-file-read.ts +197 -0
  7. package/lib/behavioral-cache.ts +78 -0
  8. package/lib/branch-cleanup.ts +234 -0
  9. package/lib/brief-context-parser.ts +35 -0
  10. package/lib/canary.ts +117 -0
  11. package/lib/check-registry.ts +226 -0
  12. package/lib/ci-checkout.ts +400 -0
  13. package/lib/cli-commands.ts +137 -0
  14. package/lib/compliance-backfill.ts +220 -0
  15. package/lib/compliance-report.ts +504 -0
  16. package/lib/compliance.ts +361 -0
  17. package/lib/config-loader.ts +255 -0
  18. package/lib/conformity.ts +1818 -131
  19. package/lib/container-provenance.ts +230 -0
  20. package/lib/create-brief.ts +150 -0
  21. package/lib/create-sc.ts +272 -0
  22. package/lib/deep-merge.ts +69 -0
  23. package/lib/dev-liveness.ts +214 -0
  24. package/lib/directive-extractor.ts +210 -0
  25. package/lib/distribution-standing.ts +113 -0
  26. package/lib/doc-hygiene.ts +238 -0
  27. package/lib/eval-criteria.ts +6 -0
  28. package/lib/evidence-portability.ts +123 -0
  29. package/lib/evidence-prevalidator.ts +390 -0
  30. package/lib/evidence-required.ts +150 -0
  31. package/lib/evidence-satisfiability.ts +288 -0
  32. package/lib/frontmatter.ts +163 -0
  33. package/lib/gap-scanner.ts +348 -0
  34. package/lib/gate-enforcement.ts +366 -0
  35. package/lib/generators/agent-briefs.ts +136 -0
  36. package/lib/generators/agents-md.ts +506 -0
  37. package/lib/generators/code-map.ts +60 -0
  38. package/lib/generators/types.ts +184 -0
  39. package/lib/git-ref-normalizer.ts +107 -0
  40. package/lib/github.ts +539 -0
  41. package/lib/harness-identity.ts +63 -0
  42. package/lib/hill-climb.ts +164 -0
  43. package/lib/instruction-effectiveness.ts +131 -0
  44. package/lib/issue-closure-audit.ts +225 -0
  45. package/lib/issue-create-override.ts +343 -0
  46. package/lib/js-top-level-code.ts +250 -0
  47. package/lib/liveness-contradiction.ts +149 -0
  48. package/lib/organize.ts +505 -0
  49. package/lib/paths.ts +197 -6
  50. package/lib/post-fix-verify.ts +157 -0
  51. package/lib/prior-branch.ts +489 -0
  52. package/lib/project-state-shape.ts +166 -0
  53. package/lib/promote-outputs.ts +156 -0
  54. package/lib/prove-label-gate.ts +35 -0
  55. package/lib/reachability.ts +302 -0
  56. package/lib/release-preflight.ts +186 -0
  57. package/lib/rule-health-pipeline.ts +264 -0
  58. package/lib/rule-health-trend.ts +161 -0
  59. package/lib/rule-provenance.ts +149 -0
  60. package/lib/rule-registry.ts +128 -0
  61. package/lib/rungate-schema.ts +114 -4
  62. package/lib/sc-claim-forms.ts +179 -0
  63. package/lib/sc-cover.ts +150 -0
  64. package/lib/sc-guard.ts +157 -0
  65. package/lib/sc-ids.ts +344 -0
  66. package/lib/scaffold/defaults.ts +165 -0
  67. package/lib/scaffold/managed-workflow.ts +370 -0
  68. package/lib/scaffold/owned-files.ts +265 -0
  69. package/lib/scaffold/steps.ts +2680 -0
  70. package/lib/scanner.ts +701 -0
  71. package/lib/screenshot-upload.ts +73 -0
  72. package/lib/secret-patterns.ts +112 -0
  73. package/lib/security-verdict.ts +616 -0
  74. package/lib/signal-phrases.ts +1 -0
  75. package/lib/spec-change-conformity.ts +80 -0
  76. package/lib/spec-files.ts +62 -0
  77. package/lib/spec-registry.ts +133 -0
  78. package/lib/spec-updater.ts +96 -0
  79. package/lib/stale-cleanup.ts +224 -0
  80. package/lib/stale-issue-scanner.ts +36 -0
  81. package/lib/strip-js-comments.ts +269 -0
  82. package/lib/suite-measurement.ts +228 -0
  83. package/lib/task-completion-checks.ts +177 -0
  84. package/lib/test-suite-lock.ts +1136 -0
  85. package/lib/transcript-checker.ts +1140 -0
  86. package/lib/validators/spec-validators.ts +171 -0
  87. package/lib/verdict-capture.ts +73 -0
  88. package/lib/verified-push.ts +358 -0
  89. package/lib/workflow-security.ts +174 -0
  90. package/lib/worktree-cleanup.ts +250 -0
  91. package/lib/worktree-collect.ts +283 -0
  92. package/lib/worktree-isolation.ts +82 -0
  93. package/package.json +36 -3
  94. package/prompts/ac-adversary.md +14 -2
  95. package/prompts/aditi.md +5 -0
  96. package/prompts/blast-radius.md +5 -0
  97. package/prompts/container-verify.md +5 -0
  98. package/prompts/discovery.md +4 -0
  99. package/prompts/environment.md +5 -0
  100. package/prompts/evidence-hierarchy.md +5 -0
  101. package/prompts/evidence-validator.md +11 -0
  102. package/prompts/marcus.md +5 -0
  103. package/prompts/prevention.md +5 -0
  104. package/prompts/prove-reproducer.md +12 -0
  105. package/prompts/quinn-decision-tree.md +5 -0
  106. package/prompts/quinn-ui-brief.md +5 -0
  107. package/prompts/quinn.md +5 -0
  108. package/prompts/rca.md +5 -0
  109. package/prompts/read-before-write.md +4 -0
  110. package/prompts/regression.md +5 -0
  111. package/prompts/serena.md +5 -0
  112. package/scripts/audit-specs.ts +464 -0
  113. package/scripts/convert-spec.ts +293 -0
  114. package/scripts/create-sc.ts +92 -0
  115. package/scripts/create-spec.ts +166 -0
  116. package/scripts/extract-constraints.ts +4 -3
  117. package/scripts/generate-code-map.ts +1 -1
  118. package/scripts/scaffold-project.ts +138 -1426
  119. package/scripts/sync-spec-tests.ts +211 -126
  120. package/.claude/agents/aditi.md +0 -47
  121. package/.claude/agents/marcus.md +0 -50
  122. package/.claude/agents/quinn.md +0 -58
  123. package/.claude/agents/rook.md +0 -47
  124. package/.claude/agents/serena.md +0 -46
  125. package/.claude/rungate.json +0 -11
  126. package/.fallowrc.json +0 -28
  127. package/.github/copilot-instructions.md +0 -20
  128. package/.rungate/conformity-findings.json +0 -648
  129. package/AGENTS.md +0 -106
  130. package/CODE-MAP.md +0 -50
  131. package/HARNESS.md +0 -88
  132. package/bun.lock +0 -26
  133. package/bunfig.toml +0 -2
  134. package/config/brief-policies.json +0 -28
  135. package/config/ceremony-profiles.json +0 -212
  136. package/config/consumer-cascade-map.json +0 -24
  137. package/config/doc-cascade-map.json +0 -24
  138. package/config/eval.json +0 -84
  139. package/config/profiles/account-plan.yaml +0 -36
  140. package/config/profiles/campaign.yaml +0 -94
  141. package/config/prove-evidence.schema.json +0 -65
  142. package/config/spec-policies.json +0 -36
  143. package/config/workflow-schema.json +0 -281
  144. package/gates/SCHEMA-GUIDE.md +0 -121
  145. package/gates/ac-quality.test.ts +0 -106
  146. package/gates/adversarial.test.ts +0 -274
  147. package/gates/brief-assembler.test.ts +0 -429
  148. package/gates/brief-assembler.ts +0 -334
  149. package/gates/bunfig.toml +0 -2
  150. package/gates/chain.test.ts +0 -91
  151. package/gates/e2e-smoke.test.ts +0 -234
  152. package/gates/error-classifier.test.ts +0 -249
  153. package/gates/error-classifier.ts +0 -89
  154. package/gates/orchestrator.test.ts +0 -950
  155. package/gates/orchestrator.ts +0 -569
  156. package/gates/preload.ts +0 -77
  157. package/gates/prompts/ac-adversary.md +0 -20
  158. package/gates/prompts/evidence-validator.md +0 -22
  159. package/gates/prompts/prove-reproducer.md +0 -53
  160. package/gates/prove.test.ts +0 -164
  161. package/gates/run-gate.ts +0 -936
  162. package/gates/schema-parity.test.ts +0 -197
  163. package/gates/schema.ts +0 -362
  164. package/gates/self-heal.test.ts +0 -511
  165. package/gates/self-heal.ts +0 -121
  166. package/gates/ship-orchestrator.test.ts +0 -379
  167. package/gates/ship-orchestrator.ts +0 -363
  168. package/gates/test-fixtures/broken-no-environments.json +0 -60
  169. package/gates/test-fixtures/valid-standard.json +0 -54
  170. package/gates/test-utils.ts +0 -43
  171. package/gates/witness.ts +0 -220
  172. package/gates/workflow.test.ts +0 -1053
  173. package/hooks/AgentBriefGuard.hook.ts +0 -586
  174. package/hooks/AgentVerdictCapture.hook.ts +0 -134
  175. package/hooks/AutoVerifyGate.hook.ts +0 -76
  176. package/hooks/GateEnforcement.hook.ts +0 -273
  177. package/hooks/IssueCloseGuard.hook.ts +0 -116
  178. package/hooks/MergeGuard.hook.ts +0 -55
  179. package/hooks/StaleTTLCleanup.hook.ts +0 -133
  180. package/hooks/VerifyPhaseLock.hook.ts +0 -81
  181. package/hooks/WorkflowStateGuard.hook.ts +0 -37
  182. package/hooks/lib/agentDetection.ts +0 -70
  183. package/hooks/lib/findWorkflow.ts +0 -101
  184. package/hooks/lib/parseStdin.ts +0 -37
  185. package/hooks/lib/paths.ts +0 -111
  186. package/hooks/lib/utils.ts +0 -81
  187. package/reference/migration-manifest.json +0 -554
  188. package/reference/prompts/agent-aditi.md +0 -38
  189. package/reference/prompts/agent-marcus.md +0 -38
  190. package/reference/prompts/agent-quinn.md +0 -38
  191. package/reference/prompts/agent-rook.md +0 -37
  192. package/reference/prompts/agent-serena.md +0 -37
  193. package/reference/prompts/council-skill.md +0 -170
  194. package/reference/prompts/goal-skill.md +0 -235
  195. package/reference/prompts/prove-skill.md +0 -283
  196. package/reference/prompts/quinn-standard.md +0 -246
  197. package/reference/prompts/ship-convergence.md +0 -65
  198. package/reference/prompts/ship-escalation.md +0 -43
  199. package/reference/prompts/ship-iteration.md +0 -382
  200. package/reference/prompts/ship-pending-patches.md +0 -246
  201. package/reference/prompts/ship-reference.md +0 -250
  202. package/reference/prompts/ship-skill.md +0 -347
  203. package/reference/prompts/ship-templates.md +0 -215
  204. package/reference/scripts/batch-status.sh +0 -68
  205. package/reference/scripts/chain-compat-check.sh +0 -67
  206. package/reference/scripts/context-audit.sh +0 -314
  207. package/reference/scripts/dead-export-check.sh +0 -61
  208. package/reference/scripts/generate-qc-tables.sh +0 -92
  209. package/reference/scripts/harness-init.sh +0 -111
  210. package/reference/scripts/pai-054-baseline-check.sh +0 -40
  211. package/reference/scripts/prove-smoke-test.sh +0 -112
  212. package/reference/scripts/setup-keychain-salt.sh +0 -12
  213. package/reference/scripts/skill-optimizer-friday.sh +0 -88
  214. package/reference/scripts/skill-qc-test.sh +0 -351
  215. package/reference/scripts/skill-synthesize-tonight.sh +0 -66
  216. package/reference/specs/HARNESS-EXTRACTION-SPEC.md +0 -263
  217. package/reference/specs/harness-v3-bash-deletion-plan.md +0 -65
  218. package/reference/specs/harness-v3-migration-plan.md +0 -188
  219. package/scripts/decision-reconcile.sh +0 -74
  220. package/scripts/decision-reconcile.ts +0 -152
  221. package/scripts/git-hooks/pre-commit +0 -76
  222. package/scripts/git-hooks/pre-push +0 -271
  223. package/scripts/harness-skill-check.sh +0 -52
  224. package/scripts/lib/gap-emit.sh +0 -65
  225. package/scripts/lib/jq-update.sh +0 -30
  226. package/scripts/lib/resolve-slug.sh +0 -30
  227. package/scripts/lib/verify-spec-compliance.sh +0 -102
  228. package/scripts/prove-backfill.sh +0 -87
  229. package/scripts/scaffold-rungate-config.ts +0 -91
  230. package/scripts/self-containment-check.sh +0 -109
  231. package/scripts/skill-qc-validator.sh +0 -402
  232. package/scripts/slug-resolver.sh +0 -14
  233. package/specs/BOOTSTRAP-DATA-FLOW-SPEC.md +0 -2493
  234. package/specs/BOOTSTRAP-TEST-PLAN.md +0 -571
  235. package/specs/HARNESS-GATES.md +0 -256
  236. package/specs/HARNESS-SKILL-CHAIN.md +0 -286
  237. package/specs/HARNESS-SKILL-CONTRACT.md +0 -93
  238. package/specs/HARNESS-STANDARD.md +0 -488
  239. package/specs/SPEC-TEMPLATE.md +0 -53
  240. package/specs/bootstrap-data-flow.png +0 -0
  241. package/specs/harness-automation-matrix.md +0 -314
  242. package/specs/harness-automation-matrix.rules.json +0 -64
  243. package/test/anti.test.ts +0 -80
  244. package/test/contract-negative.test.ts +0 -86
  245. package/test/contract.test.ts +0 -158
  246. package/test/external-deps.test.ts +0 -48
  247. package/test/fixtures/golden-project/.env.example +0 -3
  248. package/test/fixtures/golden-project/Makefile +0 -7
  249. package/test/fixtures/golden-project/docs/adr/ADR-001-framework.md +0 -23
  250. package/test/fixtures/golden-project/docs/setup-guide.md +0 -10
  251. package/test/fixtures/golden-project/package.json +0 -10
  252. package/test/fixtures/golden-project/specs/api-spec.md +0 -20
  253. package/test/fixtures/golden-project/src/auth.ts +0 -8
  254. package/test/fixtures/golden-project/src/db.ts +0 -11
  255. package/test/fixtures/golden-project/src/index.ts +0 -19
  256. package/test/fixtures/golden-project/src/utils/format.ts +0 -3
  257. package/test/fixtures/golden-project/test/auth.test.ts +0 -15
  258. package/test/fixtures/golden-project/tsconfig.json +0 -12
  259. package/test/meta-sc-coverage.test.ts +0 -159
  260. package/test/phase-0.test.ts +0 -846
  261. package/test/phase-1.test.ts +0 -617
  262. package/test/phase-2.test.ts +0 -620
  263. package/test/phase-3.test.ts +0 -99
  264. package/test/scaffold-conformity.test.ts +0 -8
  265. package/test/schema-canary.test.ts +0 -51
  266. package/test/spec-compliance-auto.test.ts +0 -64
  267. package/test/spec-compliance.test.ts +0 -295
  268. package/test/spec-discovery.test.ts +0 -68
  269. package/test/spec-drift.test.ts +0 -5
  270. package/test/structure.test.ts +0 -165
  271. package/test/unit/agent-brief-guard-ship.test.ts +0 -293
  272. package/test/unit/extract-constraints.test.ts +0 -145
  273. package/test/unit/issue-close-guard.test.ts +0 -204
  274. package/test/unit/scaffold-project.test.ts +0 -417
  275. package/test/unit/skill-cooccurrence.test.ts +0 -177
  276. package/test/unit/skill-sequence-logger.test.ts +0 -244
  277. package/test/unit/workflow-state-guard.test.ts +0 -95
  278. package/workflows/batch-ship.js +0 -295
  279. package/workflows/council.js +0 -481
  280. package/workflows/prove.js +0 -560
  281. package/workflows/ship.js +0 -789
  282. package/workflows/verify.js +0 -236
@@ -1,560 +0,0 @@
1
- export const meta = {
2
- name: 'prove',
3
- description: 'Standalone verification: prove a fix solves the user problem. GOAL → VERIFY-DEPLOYED → VALIDATE → VERDICT → OUTPUT',
4
- whenToUse: 'After /ship to prove the fix works. Standalone on any issue. Replaces reading prove SKILL.md manually.',
5
- phases: [
6
- { title: 'Goal', detail: 'Read issue, extract what was fixed, load chain context' },
7
- { title: 'Verify-Deployed', detail: 'Confirm fix commit is on main' },
8
- { title: 'Validate', detail: 'Spawn B3 reproducer + optional Quinn for UI' },
9
- { title: 'Verdict', detail: 'Mechanical verdict from criteriaResults' },
10
- { title: 'Output', detail: 'Write prove-evidence.json, post proof comment, add label, telemetry' },
11
- ],
12
- }
13
-
14
- // ── Structured output schemas ────────────────────────────────
15
-
16
- const PROVE_EVIDENCE_SCHEMA = {
17
- type: 'object',
18
- properties: {
19
- issueNumber: { type: 'number' },
20
- verdict: { type: 'string', enum: ['PROVEN', 'UNPROVEN', 'INCONCLUSIVE'] },
21
- commitSHA: { type: 'string' },
22
- capturedAt: { type: 'string' },
23
- criteriaResults: {
24
- type: 'array',
25
- items: {
26
- type: 'object',
27
- properties: {
28
- scId: { type: 'string' },
29
- verdict: { type: 'string', enum: ['PASS', 'FAIL', 'SKIP'] },
30
- evidence: { type: 'string' },
31
- },
32
- required: ['scId', 'verdict'],
33
- },
34
- },
35
- reproduced: { type: 'boolean' },
36
- },
37
- required: ['issueNumber', 'verdict', 'commitSHA', 'criteriaResults'],
38
- }
39
-
40
- const ISSUE_SCHEMA = {
41
- type: 'object',
42
- properties: {
43
- issueGoal: { type: 'string' },
44
- issueTitle: { type: 'string' },
45
- issueBody: { type: 'string' },
46
- labels: { type: 'array', items: { type: 'string' } },
47
- successCriteria: { type: 'array', items: { type: 'string' } },
48
- hasUIACs: { type: 'boolean' },
49
- },
50
- required: ['issueGoal', 'issueTitle', 'issueBody'],
51
- }
52
-
53
- const DEPLOY_CHECK_SCHEMA = {
54
- type: 'object',
55
- properties: {
56
- deployed: { type: 'boolean' },
57
- commitSHA: { type: 'string' },
58
- branch: { type: 'string' },
59
- reason: { type: 'string' },
60
- },
61
- required: ['deployed', 'commitSHA'],
62
- }
63
-
64
- const REPRODUCER_SCHEMA = {
65
- type: 'object',
66
- properties: {
67
- verdict: { type: 'string', enum: ['PROVEN', 'UNPROVEN', 'INCONCLUSIVE'] },
68
- criteriaResults: {
69
- type: 'array',
70
- items: {
71
- type: 'object',
72
- properties: {
73
- scId: { type: 'string' },
74
- verdict: { type: 'string', enum: ['PASS', 'FAIL', 'SKIP'] },
75
- evidence: { type: 'string' },
76
- },
77
- required: ['scId', 'verdict'],
78
- },
79
- },
80
- reproduced: { type: 'boolean' },
81
- gaps: { type: 'array', items: { type: 'string' } },
82
- quinnNeeded: { type: 'array', items: { type: 'string' } },
83
- },
84
- required: ['verdict', 'criteriaResults', 'reproduced'],
85
- }
86
-
87
- const QUINN_SCHEMA = {
88
- type: 'object',
89
- properties: {
90
- verdict: { type: 'string', enum: ['PASS', 'FAIL'] },
91
- findings: { type: 'array', items: { type: 'string' } },
92
- criteriaResults: {
93
- type: 'array',
94
- items: {
95
- type: 'object',
96
- properties: {
97
- scId: { type: 'string' },
98
- verdict: { type: 'string', enum: ['PASS', 'FAIL', 'SKIP'] },
99
- evidence: { type: 'string' },
100
- },
101
- required: ['scId', 'verdict'],
102
- },
103
- },
104
- },
105
- required: ['verdict'],
106
- }
107
-
108
- // ── Args ─────────────────────────────────────────────────────
109
-
110
- let parsedArgs = args || {}
111
- if (typeof parsedArgs === 'string') {
112
- try { parsedArgs = JSON.parse(parsedArgs) } catch { parsedArgs = {} }
113
- }
114
-
115
- if (!parsedArgs.issue) {
116
- return { status: 'ARGS_ERROR', message: 'Usage: Workflow({ name: "prove", args: { issue: N, projectRoot: "/path" } })' }
117
- }
118
-
119
- const ISSUE = parsedArgs.issue
120
- const REPO = parsedArgs.repo || 'hornjason/asaCommandCenter'
121
- const ISSUE_REPO = parsedArgs.issueRepo || REPO
122
- const PROJECT_ROOT = parsedArgs.projectRoot || ''
123
- if (!parsedArgs.harnessRoot) return { status: 'ARGS_ERROR', message: 'harnessRoot is required' }
124
- const HARNESS_ROOT = parsedArgs.harnessRoot
125
- const HOME = parsedArgs.home || PROJECT_ROOT.split('/Projects/')[0] || process.env.HOME || ''
126
- const SLUG = parsedArgs.slug || `ddb-${ISSUE}`
127
- const WORK_DIR = `${process.env.RUNGATE_WORK_DIR || `${HOME}/.rungate`}/${SLUG}`
128
- const PROVE_PROMPT = `${HARNESS_ROOT}/gates/prompts/prove-reproducer.md`
129
-
130
- // ── Chain detection ──────────────────────────────────────────
131
-
132
- const GOAL_RECORD_PATH = `${WORK_DIR}/goal-record.json`
133
- const SHIP_EVIDENCE_PATH = `${WORK_DIR}/ship-evidence.json`
134
-
135
- // ════════════════════════════════════════════════════════════
136
- // PHASE 1: GOAL — Read issue, extract what was fixed
137
- // ════════════════════════════════════════════════════════════
138
-
139
- phase('Goal')
140
- log(`Prove #${ISSUE}: reading issue and chain context`)
141
-
142
- const issueData = await agent(`
143
- Read this GitHub issue and extract the goal:
144
- gh issue view ${ISSUE} --repo ${ISSUE_REPO} --json title,body,labels
145
-
146
- Also check for chain artifacts:
147
- 1. test -f ${GOAL_RECORD_PATH} && echo "GOAL_RECORD: exists" || echo "GOAL_RECORD: none"
148
- 2. test -f ${SHIP_EVIDENCE_PATH} && echo "SHIP_EVIDENCE: exists" || echo "SHIP_EVIDENCE: none"
149
-
150
- If goal-record.json exists, read it and extract the structured SCs.
151
- If ship-evidence.json exists, read it and extract mergeCommitSha.
152
-
153
- Extract:
154
- 1. issueGoal — main goal statement
155
- 2. issueTitle — the title
156
- 3. issueBody — full body text
157
- 4. labels — label names
158
- 5. successCriteria — each SC/AC (from goal-record.json if chain mode, else from issue body)
159
- 6. hasUIACs — true if any AC mentions UI, screenshot, visual, page, component, render
160
- `, { label: 'read-issue', phase: 'Goal', schema: ISSUE_SCHEMA })
161
-
162
- if (!issueData) return { status: 'GOAL_FAILED', message: `Could not read issue #${ISSUE}` }
163
- log(`Goal: "${issueData.issueTitle}" — UI ACs: ${issueData.hasUIACs ? 'yes' : 'no'}`)
164
-
165
- // ════════════════════════════════════════════════════════════
166
- // PHASE 2: VERIFY-DEPLOYED — Confirm fix is on main
167
- // ════════════════════════════════════════════════════════════
168
-
169
- phase('Verify-Deployed')
170
- log('Checking fix is deployed to main')
171
-
172
- const deployCheck = await agent(`
173
- Verify the fix for issue #${ISSUE} is on main:
174
-
175
- 1. Check for ship-evidence.json: test -f ${SHIP_EVIDENCE_PATH}
176
- If it exists, read it and extract mergeCommitSha.
177
-
178
- 2. If mergeCommitSha exists:
179
- cd ${PROJECT_ROOT || '.'} && git branch --contains <sha> | grep -q main && echo "ON_MAIN" || echo "NOT_ON_MAIN"
180
-
181
- 3. If no mergeCommitSha (standalone mode):
182
- cd ${PROJECT_ROOT || '.'} && git log --oneline --all --grep="#${ISSUE}" | head -5
183
- Use the latest commit SHA found.
184
- Verify it's on main: git branch --contains <sha> | grep -q main
185
-
186
- 4. Get current HEAD:
187
- cd ${PROJECT_ROOT || '.'} && git rev-parse HEAD
188
-
189
- Report: deployed (boolean), commitSHA (the fix commit or HEAD), branch, reason.
190
- `, { label: 'deploy-check', phase: 'Verify-Deployed', schema: DEPLOY_CHECK_SCHEMA })
191
-
192
- if (!deployCheck || !deployCheck.deployed) {
193
- log(`VERIFY-DEPLOYED FAILED: ${deployCheck?.reason || 'fix not on main'}`)
194
- return {
195
- status: 'DEPLOY_FAILED',
196
- issue: ISSUE, slug: SLUG,
197
- reason: deployCheck?.reason || 'Fix commit not found on main',
198
- workDir: WORK_DIR,
199
- }
200
- }
201
-
202
- const COMMIT_SHA = deployCheck.commitSHA || 'unknown'
203
- log(`Fix deployed: ${COMMIT_SHA.slice(0, 8)} on main`)
204
-
205
- // ════════════════════════════════════════════════════════════
206
- // PHASE 3: VALIDATE — Spawn B3 reproducer + optional Quinn
207
- // ════════════════════════════════════════════════════════════
208
-
209
- phase('Validate')
210
-
211
- // Ensure dev server is running for OUTCOME AC evidence collection
212
- if (PROJECT_ROOT) {
213
- log('Checking dev server availability')
214
- await agent(`
215
- Check if the dev server is running. Read ${PROJECT_ROOT}/.claude/rungate.json to get dev.apiBase and dev.start.
216
-
217
- 1. Try: curl -sf $(dev.apiBase)/api/health -o /dev/null && echo "DEV_UP" || echo "DEV_DOWN"
218
- 2. If DEV_DOWN and dev.start exists:
219
- - Run: cd ${PROJECT_ROOT} && $(dev.start) &
220
- - Wait 10 seconds, then retry the health check
221
- - Report: started (boolean), apiBase, command used
222
- 3. If DEV_UP: report already running
223
-
224
- Report the dev server status.
225
- `, { label: 'ensure-dev-server', phase: 'Validate' })
226
- }
227
-
228
- log('Spawning B3 Prove Reproducer')
229
-
230
- // Read before-state context for the reproducer
231
- const beforeContext = await agent(`
232
- Check for before-state evidence:
233
- 1. test -f ${WORK_DIR}/workflow-state.json && echo "WF_STATE: exists" || echo "WF_STATE: none"
234
- 2. If workflow-state.json exists, read it and extract beforeState field.
235
- 3. Read the issue body for reproduction steps.
236
-
237
- Check project harness for API/UI bases:
238
- 4. test -f ${PROJECT_ROOT}/.claude/rungate.json && cat ${PROJECT_ROOT}/.claude/rungate.json || echo "NO_HARNESS"
239
-
240
- Report the before-state description, reproduction steps, apiBase, and uiBase.
241
- Return as a string summary.
242
- `, { label: 'before-context', phase: 'Validate' })
243
-
244
- // Spawn B3 reproducer agent
245
- const reproducerResult = await agent(`
246
- You are a prove reproducer for issue #${ISSUE}.
247
- Read the prove reproducer prompt at ${PROVE_PROMPT} for your full instructions.
248
-
249
- ## Issue
250
- Title: ${issueData.issueTitle}
251
- Body (first 2000 chars): ${(issueData.issueBody || '').slice(0, 2000)}
252
-
253
- ## Success Criteria
254
- ${(issueData.successCriteria || []).map((sc, i) => `${i + 1}. ${sc}`).join('\n') || 'Derive from issue body'}
255
-
256
- ## Before State
257
- ${beforeContext || 'No before-state captured. Derive from issue description.'}
258
-
259
- ## Fix Commit
260
- ${COMMIT_SHA}
261
-
262
- ## Environment
263
- Project root: ${PROJECT_ROOT || 'not set'}
264
-
265
- ## Instructions
266
- 1. Read ${PROVE_PROMPT} for your full protocol.
267
- 2. For CODE ACs: run evidence commands (grep, bun test, curl) against current code.
268
- 3. For UI/OUTCOME ACs: output SKIP with reason "B3 limitation: no browser tools — requires Quinn".
269
- 4. Compare before-state against current after-state.
270
- 5. Capture real evidence for each criterion.
271
-
272
- Output your verdict, criteriaResults, reproduced, gaps, and quinnNeeded (list of AC IDs needing Quinn).
273
- `, { label: 'b3-reproducer', phase: 'Validate', schema: REPRODUCER_SCHEMA })
274
-
275
- let allCriteriaResults = reproducerResult?.criteriaResults || []
276
- let quinnResults = null
277
-
278
- // Spawn Quinn for UI ACs if needed
279
- const needsQuinn = issueData.hasUIACs ||
280
- (reproducerResult?.quinnNeeded && reproducerResult.quinnNeeded.length > 0)
281
-
282
- if (needsQuinn) {
283
- log('UI ACs detected — starting prove container with prod data, then spawning Quinn')
284
-
285
- // Start prove container with prod data (make prove-up = build + rsync prod data + start on :7776)
286
- await agent(`
287
- You have ONE task: start the prove container with prod data. Run this EXACT command and report the output:
288
-
289
- cd ${PROJECT_ROOT} && make prove-up 2>&1 | tail -20
290
-
291
- This rebuilds the container image, rsyncs prod data to data-test/, and starts the container on port 7776.
292
- After it completes, verify the container is up: curl -s -o /dev/null -w "%{http_code}" http://localhost:7776/api/aes
293
- Report the output.
294
- `, { label: 'prove-container-up', phase: 'Validate' })
295
-
296
- const quinnACs = (reproducerResult?.quinnNeeded || []).join(', ') ||
297
- (issueData.successCriteria || []).filter(sc =>
298
- /ui|screenshot|visual|page|component|render|display|show/i.test(sc)
299
- ).join('\n')
300
-
301
- quinnResults = await agent(`
302
- You are Quinn Torres, QA specialist. You have Playwright MCP tools available.
303
-
304
- ## Issue #${ISSUE}: ${issueData.issueTitle}
305
- Fix commit: ${COMMIT_SHA}
306
-
307
- ## Available Playwright MCP Tools (use these, NOT manual browser)
308
- - browser_navigate(url) — go to URL
309
- - browser_snapshot() — get accessibility tree (text, fast, preferred over screenshots)
310
- - browser_click(element) — click by ref from snapshot
311
- - browser_type(element, text) — type text into element
312
- - browser_take_screenshot() — capture PNG evidence
313
- - browser_verify_text_visible(text) — assert text on page
314
-
315
- ## Target URLs
316
- Read ${PROJECT_ROOT}/.claude/rungate.json for page paths.
317
- Prove container base: http://localhost:7776
318
-
319
- ## ACs to verify (UI/OUTCOME — skipped by B3)
320
- ${quinnACs}
321
-
322
- ## Test Plan for #${ISSUE} on PROVE CONTAINER
323
- 1. Verify fix deployed: cd ${PROJECT_ROOT} && git rev-parse --short HEAD should match ${COMMIT_SHA.slice(0, 8)}
324
- 2. For each AC:
325
- a. browser_navigate("http://localhost:7776" + page path from rungate.json)
326
- b. browser_snapshot() — verify page loaded
327
- c. Perform action (browser_click, browser_type, etc.)
328
- d. browser_snapshot() or browser_verify_text_visible() to verify
329
- e. browser_take_screenshot() for evidence
330
- 3. Test as a brand-new user — use a customer that HAS contacts (prod data on :7776)
331
- 4. Report PASS/FAIL per AC with tool output as evidence
332
-
333
- IMPORTANT: Test on port 7776 (prove container with prod data), NOT dev server (port 5173/7778).
334
- Report verdict and criteriaResults.
335
- `, { label: 'quinn-prove', phase: 'Validate', schema: QUINN_SCHEMA })
336
-
337
- // Merge Quinn results into allCriteriaResults (replace SKIPs from B3)
338
- if (quinnResults?.criteriaResults) {
339
- const quinnMap = new Map(quinnResults.criteriaResults.map(cr => [cr.scId, cr]))
340
- allCriteriaResults = allCriteriaResults.map(cr => {
341
- if (cr.verdict === 'SKIP' && quinnMap.has(cr.scId)) {
342
- return quinnMap.get(cr.scId)
343
- }
344
- return cr
345
- })
346
- // Add any Quinn results for ACs not in B3 output
347
- for (const qr of quinnResults.criteriaResults) {
348
- if (!allCriteriaResults.some(cr => cr.scId === qr.scId)) {
349
- allCriteriaResults.push(qr)
350
- }
351
- }
352
- }
353
- log(`Quinn: ${quinnResults?.verdict || 'no result'}`)
354
- }
355
-
356
- // ════════════════════════════════════════════════════════════
357
- // PHASE 4: VERDICT — Mechanical computation + self-heal loop
358
- // ════════════════════════════════════════════════════════════
359
-
360
- phase('Verdict')
361
-
362
- const MAX_SELF_HEAL_ATTEMPTS = 3
363
-
364
- function computeVerdict(criteriaResults) {
365
- const fc = criteriaResults.filter(cr => cr.verdict === 'FAIL').length
366
- const psc = criteriaResults.filter(cr => cr.verdict === 'PASS' || cr.verdict === 'SKIP').length
367
- let v
368
- if (criteriaResults.length === 0) {
369
- v = 'INCONCLUSIVE'
370
- } else if (fc > 0) {
371
- v = 'UNPROVEN'
372
- } else {
373
- v = 'PROVEN'
374
- }
375
- return { verdict: v, failCount: fc, passSkipCount: psc }
376
- }
377
-
378
- let { verdict, failCount, passSkipCount } = computeVerdict(allCriteriaResults)
379
- log(`Verdict: ${verdict} — ${passSkipCount} PASS/SKIP, ${failCount} FAIL, ${allCriteriaResults.length} total`)
380
-
381
- // ── Self-heal loop: on UNPROVEN, spawn Marcus to fix, re-prove ──
382
- let selfHealIteration = 0
383
-
384
- while (verdict === 'UNPROVEN' && selfHealIteration < MAX_SELF_HEAL_ATTEMPTS) {
385
- selfHealIteration++
386
- log(`Self-heal iteration ${selfHealIteration}/${MAX_SELF_HEAL_ATTEMPTS} — spawning fix agent`)
387
-
388
- const failedCriteria = allCriteriaResults.filter(cr => cr.verdict === 'FAIL')
389
- const failSummary = failedCriteria.map(cr => `${cr.scId}: ${cr.evidence || 'FAIL'}`).join('\n')
390
-
391
- // Spawn Marcus to fix the failures
392
- await agent(`
393
- You are Marcus Webb, senior engineer. Prove found UNPROVEN criteria for issue #${ISSUE}.
394
-
395
- ## Failed Criteria (iteration ${selfHealIteration}/${MAX_SELF_HEAL_ATTEMPTS})
396
- ${failSummary}
397
-
398
- ## Issue
399
- Title: ${issueData.issueTitle}
400
- Body (first 2000 chars): ${(issueData.issueBody || '').slice(0, 2000)}
401
-
402
- ## Instructions
403
- 1. Read the failed criteria above.
404
- 2. cd ${PROJECT_ROOT || '.'} and investigate why each criterion failed.
405
- 3. Fix the code to address each failure.
406
- 4. Run tests: bun test, tsc --noEmit.
407
- 5. Commit and push the fix: git add -A && git commit -m "fix(#${ISSUE}): prove self-heal iteration ${selfHealIteration}" && git push
408
-
409
- Report what you fixed and evidence that each failed criterion is now addressed.
410
- `, { label: `self-heal-fix-${selfHealIteration}`, phase: 'Verdict', agentType: 'Engineer' })
411
-
412
- log(`Self-heal fix ${selfHealIteration} complete — re-validating`)
413
-
414
- // Re-run B3 reproducer to check if fixes resolved the failures
415
- const revalidateResult = await agent(`
416
- You are a prove reproducer for issue #${ISSUE} (self-heal re-validation, iteration ${selfHealIteration}).
417
-
418
- ## Issue
419
- Title: ${issueData.issueTitle}
420
- Body (first 2000 chars): ${(issueData.issueBody || '').slice(0, 2000)}
421
-
422
- ## Success Criteria
423
- ${(issueData.successCriteria || []).map((sc, i) => `${i + 1}. ${sc}`).join('\n') || 'Derive from issue body'}
424
-
425
- ## Previously Failed Criteria
426
- ${failSummary}
427
-
428
- ## Fix Commit
429
- Run: cd ${PROJECT_ROOT || '.'} && git rev-parse --short HEAD
430
-
431
- ## Instructions
432
- 1. For CODE ACs: run evidence commands (grep, bun test, curl) against current code.
433
- 2. For UI/OUTCOME ACs: output SKIP with reason "B3 limitation: no browser tools — requires Quinn".
434
- 3. Focus on the previously failed criteria — verify the fix resolved them.
435
-
436
- Output your verdict, criteriaResults, reproduced, gaps.
437
- `, { label: `self-heal-validate-${selfHealIteration}`, phase: 'Verdict', schema: REPRODUCER_SCHEMA })
438
-
439
- if (revalidateResult?.criteriaResults) {
440
- allCriteriaResults = revalidateResult.criteriaResults
441
- }
442
-
443
- const recomputed = computeVerdict(allCriteriaResults)
444
- verdict = recomputed.verdict
445
- failCount = recomputed.failCount
446
- passSkipCount = recomputed.passSkipCount
447
-
448
- log(`Self-heal iteration ${selfHealIteration} verdict: ${verdict} — ${passSkipCount} PASS/SKIP, ${failCount} FAIL`)
449
- }
450
-
451
- if (selfHealIteration >= MAX_SELF_HEAL_ATTEMPTS && verdict === 'UNPROVEN') {
452
- log(`CIRCUIT BREAKER: prove self-heal exhausted ${MAX_SELF_HEAL_ATTEMPTS} iterations — still UNPROVEN`)
453
- }
454
-
455
- // ════════════════════════════════════════════════════════════
456
- // PHASE 5: OUTPUT — Write evidence, post comment, label, telemetry
457
- // ════════════════════════════════════════════════════════════
458
-
459
- phase('Output')
460
-
461
- const proveEvidence = {
462
- contractVersion: '1.0',
463
- issueNumber: ISSUE,
464
- verdict,
465
- commitSHA: COMMIT_SHA,
466
- capturedAt: 'AGENT_FILL_TIMESTAMP',
467
- criteriaResults: allCriteriaResults,
468
- reproduced: reproducerResult?.reproduced ?? false,
469
- source: 'prove-workflow',
470
- }
471
-
472
- // Write prove-evidence.json
473
- await agent(`
474
- mkdir -p ${WORK_DIR}
475
- Write this JSON to ${WORK_DIR}/prove-evidence.json using the Write tool.
476
- Replace the capturedAt value "AGENT_FILL_TIMESTAMP" with the current ISO timestamp (run: date -u +%Y-%m-%dT%H:%M:%SZ).
477
-
478
- ${JSON.stringify(proveEvidence, null, 2)}
479
- `, { label: 'write-evidence', phase: 'Output' })
480
-
481
- log('prove-evidence.json written')
482
-
483
- // Post proof comment to issue
484
- const proofComment = [
485
- '## Proof',
486
- '',
487
- `- **Fix:** commit ${COMMIT_SHA.slice(0, 8)}`,
488
- `- **Reproduced:** ${proveEvidence.reproduced ? 'yes' : 'no'}`,
489
- ...allCriteriaResults.map(cr => `- **${cr.scId}:** ${cr.verdict}${cr.evidence ? ' — ' + cr.evidence.slice(0, 100) : ''}`),
490
- quinnResults ? `- **Quinn:** ${quinnResults.verdict}` : '',
491
- `- **Verdict:** ${verdict}`,
492
- ].filter(Boolean).join('\n')
493
-
494
- await agent(`
495
- Post this comment to issue #${ISSUE}:
496
- gh issue comment ${ISSUE} --repo ${ISSUE_REPO} --body ${JSON.stringify(proofComment)}
497
- `, { label: 'post-comment', phase: 'Output' })
498
-
499
- log('Proof comment posted')
500
-
501
- // Add proven label + close issue (chain mode only) if PROVEN
502
- if (verdict === 'PROVEN') {
503
- const chainMode = await agent(`
504
- test -f ${GOAL_RECORD_PATH} && echo "CHAIN" || echo "STANDALONE"
505
- `, { label: 'chain-check', phase: 'Output' })
506
-
507
- await agent(`
508
- Add the "proven" label to issue #${ISSUE}:
509
- gh issue edit ${ISSUE} --repo ${ISSUE_REPO} --add-label "proven" 2>&1 || echo "label add failed"
510
-
511
- ${String(chainMode).includes('CHAIN') ? `
512
- Also close the issue (chain mode — goal-record.json exists):
513
- gh issue close ${ISSUE} --repo ${ISSUE_REPO} 2>&1 || echo "close failed"
514
- gh issue comment ${ISSUE} --repo ${ISSUE_REPO} --body "Issue closed by /prove — verdict: PROVEN"
515
- ` : '# Standalone mode — do NOT close the issue'}
516
- `, { label: 'label-close', phase: 'Output' })
517
-
518
- log(String(chainMode).includes('CHAIN') ? 'Issue labeled + closed (chain mode)' : 'Issue labeled proven (standalone)')
519
- } else if (verdict === 'UNPROVEN') {
520
- await agent(`
521
- Post a re-investigation comment:
522
- gh issue comment ${ISSUE} --repo ${ISSUE_REPO} --body "Prove verdict: UNPROVEN — issue remains open for re-investigation"
523
- `, { label: 'unproven-comment', phase: 'Output' })
524
- log('UNPROVEN — issue remains open')
525
- } else {
526
- await agent(`
527
- Post an inconclusive comment:
528
- gh issue comment ${ISSUE} --repo ${ISSUE_REPO} --body "Prove verdict: INCONCLUSIVE — could not reproduce. Manual investigation needed."
529
- `, { label: 'inconclusive-comment', phase: 'Output' })
530
- log('INCONCLUSIVE — manual investigation needed')
531
- }
532
-
533
- // Telemetry — agent handles timestamps since workflow sandbox bans Date.now()
534
- await agent(`
535
- Append a telemetry entry to ${HOME}/.claude/MEMORY/LEARNING/SIGNALS/harness-telemetry.jsonl.
536
- Use Bash to echo a single JSON line with: ts (current ISO timestamp), skill: "prove", issue: ${ISSUE}, check: "verdict", result: "${verdict}".
537
- Create the directory if it doesn't exist: mkdir -p ${HOME}/.claude/MEMORY/LEARNING/SIGNALS
538
- `, { label: 'telemetry', phase: 'Output' })
539
-
540
- log(`Telemetry logged — prove #${ISSUE}: ${verdict}`)
541
-
542
- // Cleanup: stop prove container
543
- await agent(`
544
- Run: cd ${PROJECT_ROOT} && make prove-down 2>&1 || true
545
- Report output.
546
- `, { label: 'prove-container-down', phase: 'Output' })
547
-
548
- return {
549
- status: verdict,
550
- issue: ISSUE,
551
- slug: SLUG,
552
- verdict,
553
- commitSHA: COMMIT_SHA,
554
- criteriaResults: allCriteriaResults,
555
- reproduced: proveEvidence.reproduced,
556
- quinnVerdict: quinnResults?.verdict || null,
557
- selfHealIterations: selfHealIteration,
558
- circuitBroken: selfHealIteration >= MAX_SELF_HEAL_ATTEMPTS && verdict === 'UNPROVEN',
559
- workDir: WORK_DIR,
560
- }