rungate 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/package.json +14 -3
  2. package/.claude/agents/aditi.md +0 -47
  3. package/.claude/agents/marcus.md +0 -50
  4. package/.claude/agents/quinn.md +0 -58
  5. package/.claude/agents/rook.md +0 -47
  6. package/.claude/agents/serena.md +0 -46
  7. package/.claude/rungate.json +0 -11
  8. package/.fallowrc.json +0 -28
  9. package/.github/copilot-instructions.md +0 -20
  10. package/.rungate/conformity-findings.json +0 -648
  11. package/AGENTS.md +0 -106
  12. package/CODE-MAP.md +0 -50
  13. package/HARNESS.md +0 -88
  14. package/bun.lock +0 -26
  15. package/bunfig.toml +0 -2
  16. package/config/brief-policies.json +0 -28
  17. package/config/ceremony-profiles.json +0 -212
  18. package/config/consumer-cascade-map.json +0 -24
  19. package/config/doc-cascade-map.json +0 -24
  20. package/config/eval.json +0 -84
  21. package/config/profiles/account-plan.yaml +0 -36
  22. package/config/profiles/campaign.yaml +0 -94
  23. package/config/prove-evidence.schema.json +0 -65
  24. package/config/spec-policies.json +0 -36
  25. package/config/workflow-schema.json +0 -281
  26. package/gates/SCHEMA-GUIDE.md +0 -121
  27. package/gates/ac-quality.test.ts +0 -106
  28. package/gates/adversarial.test.ts +0 -274
  29. package/gates/brief-assembler.test.ts +0 -429
  30. package/gates/brief-assembler.ts +0 -334
  31. package/gates/bunfig.toml +0 -2
  32. package/gates/chain.test.ts +0 -91
  33. package/gates/e2e-smoke.test.ts +0 -234
  34. package/gates/error-classifier.test.ts +0 -249
  35. package/gates/error-classifier.ts +0 -89
  36. package/gates/orchestrator.test.ts +0 -950
  37. package/gates/orchestrator.ts +0 -569
  38. package/gates/preload.ts +0 -77
  39. package/gates/prompts/ac-adversary.md +0 -20
  40. package/gates/prompts/evidence-validator.md +0 -22
  41. package/gates/prompts/prove-reproducer.md +0 -53
  42. package/gates/prove.test.ts +0 -164
  43. package/gates/run-gate.ts +0 -936
  44. package/gates/schema-parity.test.ts +0 -197
  45. package/gates/schema.ts +0 -362
  46. package/gates/self-heal.test.ts +0 -511
  47. package/gates/self-heal.ts +0 -121
  48. package/gates/ship-orchestrator.test.ts +0 -379
  49. package/gates/ship-orchestrator.ts +0 -363
  50. package/gates/test-fixtures/broken-no-environments.json +0 -60
  51. package/gates/test-fixtures/valid-standard.json +0 -54
  52. package/gates/test-utils.ts +0 -43
  53. package/gates/witness.ts +0 -220
  54. package/gates/workflow.test.ts +0 -1053
  55. package/hooks/AgentBriefGuard.hook.ts +0 -586
  56. package/hooks/AgentVerdictCapture.hook.ts +0 -134
  57. package/hooks/AutoVerifyGate.hook.ts +0 -76
  58. package/hooks/GateEnforcement.hook.ts +0 -273
  59. package/hooks/IssueCloseGuard.hook.ts +0 -116
  60. package/hooks/MergeGuard.hook.ts +0 -55
  61. package/hooks/StaleTTLCleanup.hook.ts +0 -133
  62. package/hooks/VerifyPhaseLock.hook.ts +0 -81
  63. package/hooks/WorkflowStateGuard.hook.ts +0 -37
  64. package/hooks/lib/agentDetection.ts +0 -70
  65. package/hooks/lib/findWorkflow.ts +0 -101
  66. package/hooks/lib/parseStdin.ts +0 -37
  67. package/hooks/lib/paths.ts +0 -111
  68. package/hooks/lib/utils.ts +0 -81
  69. package/reference/migration-manifest.json +0 -554
  70. package/reference/prompts/agent-aditi.md +0 -38
  71. package/reference/prompts/agent-marcus.md +0 -38
  72. package/reference/prompts/agent-quinn.md +0 -38
  73. package/reference/prompts/agent-rook.md +0 -37
  74. package/reference/prompts/agent-serena.md +0 -37
  75. package/reference/prompts/council-skill.md +0 -170
  76. package/reference/prompts/goal-skill.md +0 -235
  77. package/reference/prompts/prove-skill.md +0 -283
  78. package/reference/prompts/quinn-standard.md +0 -246
  79. package/reference/prompts/ship-convergence.md +0 -65
  80. package/reference/prompts/ship-escalation.md +0 -43
  81. package/reference/prompts/ship-iteration.md +0 -382
  82. package/reference/prompts/ship-pending-patches.md +0 -246
  83. package/reference/prompts/ship-reference.md +0 -250
  84. package/reference/prompts/ship-skill.md +0 -347
  85. package/reference/prompts/ship-templates.md +0 -215
  86. package/reference/scripts/batch-status.sh +0 -68
  87. package/reference/scripts/chain-compat-check.sh +0 -67
  88. package/reference/scripts/context-audit.sh +0 -314
  89. package/reference/scripts/dead-export-check.sh +0 -61
  90. package/reference/scripts/generate-qc-tables.sh +0 -92
  91. package/reference/scripts/harness-init.sh +0 -111
  92. package/reference/scripts/pai-054-baseline-check.sh +0 -40
  93. package/reference/scripts/prove-smoke-test.sh +0 -112
  94. package/reference/scripts/setup-keychain-salt.sh +0 -12
  95. package/reference/scripts/skill-optimizer-friday.sh +0 -88
  96. package/reference/scripts/skill-qc-test.sh +0 -351
  97. package/reference/scripts/skill-synthesize-tonight.sh +0 -66
  98. package/reference/specs/HARNESS-EXTRACTION-SPEC.md +0 -263
  99. package/reference/specs/harness-v3-bash-deletion-plan.md +0 -65
  100. package/reference/specs/harness-v3-migration-plan.md +0 -188
  101. package/scripts/decision-reconcile.sh +0 -74
  102. package/scripts/decision-reconcile.ts +0 -152
  103. package/scripts/git-hooks/pre-commit +0 -76
  104. package/scripts/git-hooks/pre-push +0 -271
  105. package/scripts/harness-skill-check.sh +0 -52
  106. package/scripts/lib/gap-emit.sh +0 -65
  107. package/scripts/lib/jq-update.sh +0 -30
  108. package/scripts/lib/resolve-slug.sh +0 -30
  109. package/scripts/lib/verify-spec-compliance.sh +0 -102
  110. package/scripts/prove-backfill.sh +0 -87
  111. package/scripts/scaffold-rungate-config.ts +0 -91
  112. package/scripts/self-containment-check.sh +0 -109
  113. package/scripts/skill-qc-validator.sh +0 -402
  114. package/scripts/slug-resolver.sh +0 -14
  115. package/specs/BOOTSTRAP-DATA-FLOW-SPEC.md +0 -2493
  116. package/specs/BOOTSTRAP-TEST-PLAN.md +0 -571
  117. package/specs/HARNESS-GATES.md +0 -256
  118. package/specs/HARNESS-SKILL-CHAIN.md +0 -286
  119. package/specs/HARNESS-SKILL-CONTRACT.md +0 -93
  120. package/specs/HARNESS-STANDARD.md +0 -488
  121. package/specs/SPEC-TEMPLATE.md +0 -53
  122. package/specs/bootstrap-data-flow.png +0 -0
  123. package/specs/harness-automation-matrix.md +0 -314
  124. package/specs/harness-automation-matrix.rules.json +0 -64
  125. package/test/anti.test.ts +0 -80
  126. package/test/contract-negative.test.ts +0 -86
  127. package/test/contract.test.ts +0 -158
  128. package/test/external-deps.test.ts +0 -48
  129. package/test/fixtures/golden-project/.env.example +0 -3
  130. package/test/fixtures/golden-project/Makefile +0 -7
  131. package/test/fixtures/golden-project/docs/adr/ADR-001-framework.md +0 -23
  132. package/test/fixtures/golden-project/docs/setup-guide.md +0 -10
  133. package/test/fixtures/golden-project/package.json +0 -10
  134. package/test/fixtures/golden-project/specs/api-spec.md +0 -20
  135. package/test/fixtures/golden-project/src/auth.ts +0 -8
  136. package/test/fixtures/golden-project/src/db.ts +0 -11
  137. package/test/fixtures/golden-project/src/index.ts +0 -19
  138. package/test/fixtures/golden-project/src/utils/format.ts +0 -3
  139. package/test/fixtures/golden-project/test/auth.test.ts +0 -15
  140. package/test/fixtures/golden-project/tsconfig.json +0 -12
  141. package/test/meta-sc-coverage.test.ts +0 -159
  142. package/test/phase-0.test.ts +0 -846
  143. package/test/phase-1.test.ts +0 -617
  144. package/test/phase-2.test.ts +0 -620
  145. package/test/phase-3.test.ts +0 -99
  146. package/test/scaffold-conformity.test.ts +0 -8
  147. package/test/schema-canary.test.ts +0 -51
  148. package/test/spec-compliance-auto.test.ts +0 -64
  149. package/test/spec-compliance.test.ts +0 -295
  150. package/test/spec-discovery.test.ts +0 -68
  151. package/test/spec-drift.test.ts +0 -5
  152. package/test/structure.test.ts +0 -165
  153. package/test/unit/agent-brief-guard-ship.test.ts +0 -293
  154. package/test/unit/extract-constraints.test.ts +0 -145
  155. package/test/unit/issue-close-guard.test.ts +0 -204
  156. package/test/unit/scaffold-project.test.ts +0 -417
  157. package/test/unit/skill-cooccurrence.test.ts +0 -177
  158. package/test/unit/skill-sequence-logger.test.ts +0 -244
  159. package/test/unit/workflow-state-guard.test.ts +0 -95
  160. package/workflows/batch-ship.js +0 -295
  161. package/workflows/council.js +0 -481
  162. package/workflows/prove.js +0 -560
  163. package/workflows/ship.js +0 -789
  164. package/workflows/verify.js +0 -236
package/workflows/ship.js DELETED
@@ -1,789 +0,0 @@
1
- export const meta = {
2
- name: 'ship',
3
- description: 'Programmatic ship lifecycle: GOAL → DISCOVERY → SCOPE → IMPLEMENT → VALIDATE → COMMIT → VERIFY → SHIP → PROVE',
4
- whenToUse: 'Ship a GitHub issue through the full harness. Replaces reading SKILL.md manually.',
5
- phases: [
6
- { title: 'Goal', detail: 'Read issue, extract goal' },
7
- { title: 'Discovery', detail: 'Read project docs, size work, write ACs, detect prior work' },
8
- { title: 'Scope', detail: 'Run scope gate with self-heal' },
9
- { title: 'Implement', detail: 'Brief + Marcus implements (no commit)' },
10
- { title: 'Validate', detail: 'Quinn local dev, iterate with Marcus if needed' },
11
- { title: 'Commit', detail: 'Commit + push after Quinn local PASS' },
12
- { title: 'Verify', detail: 'Verify gate + container rebuild + Quinn container' },
13
- { title: 'Ship', detail: 'Ship gate' },
14
- { title: 'Prove', detail: 'Prove gate — verify fix actually works' },
15
- ],
16
- }
17
-
18
- // ── Structured output schemas ────────────────────────────────
19
-
20
- const GOAL_SCHEMA = {
21
- type: 'object',
22
- properties: {
23
- issueGoal: { type: 'string' },
24
- successCriteria: { type: 'array', items: { type: 'string' } },
25
- issueTitle: { type: 'string' },
26
- labels: { type: 'array', items: { type: 'string' } },
27
- },
28
- required: ['issueGoal', 'successCriteria', 'issueTitle'],
29
- }
30
-
31
- const DISCOVERY_SCHEMA = {
32
- type: 'object',
33
- properties: {
34
- sizing: { type: 'string', enum: ['XS', 'S', 'M', 'L'] },
35
- ceremonyTier: { type: 'string', enum: ['LIGHT', 'STANDARD', 'THOROUGH'] },
36
- acs: {
37
- type: 'array',
38
- items: {
39
- type: 'object',
40
- properties: {
41
- id: { type: 'string' },
42
- type: { type: 'string', enum: ['CODE', 'OUTCOME'] },
43
- statement: { type: 'string' },
44
- threshold: { type: 'object', properties: { op: { type: 'string', enum: ['==', '>=', '<=', '>', '<', '!=', 'contains', 'exists'] }, value: {}, unit: { type: 'string' } }, required: ['op', 'value'] },
45
- evidenceMethod: { type: 'object', properties: { type: { type: 'string', enum: ['GREP_CHECK', 'FILE_EXISTS', 'CURL_CHECK', 'BUN_TEST', 'SCREENSHOT', 'PLAYWRIGHT', 'COMMAND', 'MANUAL', 'grep', 'command', 'api', 'screenshot', 'manual'] }, command: { type: 'string' } }, required: ['type'] },
46
- specElement: { type: 'string' },
47
- contextFiles: { type: 'array', items: { type: 'object', properties: { path: { type: 'string' }, lines: { type: 'string' }, reason: { type: 'string' } }, required: ['path', 'reason'] } },
48
- },
49
- required: ['id', 'type', 'statement', 'threshold', 'evidenceMethod'],
50
- },
51
- },
52
- priorWork: {
53
- type: 'object',
54
- properties: {
55
- explicitCommits: { type: 'array', items: { type: 'string' } },
56
- acStatus: {
57
- type: 'array',
58
- items: {
59
- type: 'object',
60
- properties: {
61
- id: { type: 'string' },
62
- status: { type: 'string', enum: ['MET', 'PARTIAL', 'UNMET'] },
63
- evidence: { type: 'string' },
64
- },
65
- required: ['id', 'status'],
66
- },
67
- },
68
- },
69
- required: ['explicitCommits', 'acStatus'],
70
- },
71
- filesToModify: { type: 'array', items: { type: 'string' } },
72
- scopeOut: { type: 'array', items: { type: 'string' } },
73
- governingSpec: { type: 'string' },
74
- sourceSpecs: { type: 'array', items: { type: 'object', properties: { path: { type: 'string' }, citedInDiscovery: { type: 'boolean' }, specElements: { type: 'array', items: { type: 'string' } } }, required: ['path', 'citedInDiscovery'] } },
75
- },
76
- required: ['sizing', 'ceremonyTier', 'acs', 'filesToModify', 'scopeOut', 'priorWork'],
77
- }
78
-
79
- const GATE_RESULT_SCHEMA = {
80
- type: 'object',
81
- properties: {
82
- result: { type: 'string', enum: ['PASS', 'FAIL'] },
83
- failures: { type: 'array', items: { type: 'string' } },
84
- category: { type: 'string', enum: ['STATE', 'CODE', 'DISCOVERY', 'ENVIRONMENT', 'NON_RETRYABLE'] },
85
- regressionTarget: { type: 'string', enum: ['BUILD', 'DISCOVERY'] },
86
- },
87
- required: ['result'],
88
- }
89
-
90
- const BUILD_RESULT_SCHEMA = {
91
- type: 'object',
92
- properties: {
93
- success: { type: 'boolean' },
94
- branch: { type: 'string' },
95
- commitSha: { type: 'string' },
96
- filesChanged: { type: 'array', items: { type: 'string' } },
97
- testOutput: { type: 'string' },
98
- findings: { type: 'array', items: { type: 'string' } },
99
- },
100
- required: ['success'],
101
- }
102
-
103
- // ── Args ─────────────────────────────────────────────────────
104
-
105
- let parsedArgs = args || {}
106
- if (typeof parsedArgs === 'string') {
107
- try { parsedArgs = JSON.parse(parsedArgs) } catch { parsedArgs = {} }
108
- }
109
-
110
- if (!parsedArgs.issue || !parsedArgs.projectRoot) {
111
- return { status: 'ARGS_ERROR', message: 'Usage: Workflow({ name: "ship", args: { issue: N, projectRoot: "/path" } })' }
112
- }
113
-
114
- const ISSUE = parsedArgs.issue
115
- const REPO = parsedArgs.repo || 'hornjason/asaCommandCenter'
116
- const ISSUE_REPO = parsedArgs.issueRepo || REPO
117
- const PROJECT_ROOT = parsedArgs.projectRoot
118
- const PHASE_TARGET = parsedArgs.phase || 'all'
119
- const SLUG = parsedArgs.slug || `ddb-${ISSUE}`
120
- if (!parsedArgs.harnessRoot) return { status: 'ARGS_ERROR', message: 'harnessRoot is required' }
121
- const HARNESS_ROOT = parsedArgs.harnessRoot
122
- const HOME = parsedArgs.home || PROJECT_ROOT.split('/Projects/')[0] || process.env.HOME || ''
123
- const WORK_DIR = `${process.env.RUNGATE_WORK_DIR || `${HOME}/.rungate`}/${SLUG}`
124
- const DRY_RUN = parsedArgs.dryRun || false
125
- const MAX_REGRESSIONS = 2
126
-
127
- // ── Helper: run gate with self-heal + error classification ──
128
-
129
- async function runGateWithHeal(gateName, phaseName, healContext) {
130
- for (let attempt = 1; attempt <= 3; attempt++) {
131
- const result = await agent(`
132
- Run the ${gateName} gate and classify any failures:
133
-
134
- 1. Run: TEST_WORK_DIR=${WORK_DIR} bun run ${HARNESS_ROOT}/gates/run-gate.ts --gate ${gateName} --slug ${SLUG} --issue ${ISSUE} 2>&1
135
- 2. Read ${WORK_DIR}/workflow-state.json for gate result
136
- 3. If FAIL, classify failures: bun -e "
137
- import {classifyFailures} from '${HARNESS_ROOT}/gates/error-classifier.ts';
138
- import {readFileSync} from 'fs';
139
- const s = JSON.parse(readFileSync('${WORK_DIR}/workflow-state.json','utf-8'));
140
- const f = s.gates?.['${gateName}']?.failures || [];
141
- console.log(JSON.stringify(classifyFailures(f)));
142
- " 2>&1
143
- 4. Report: result (PASS/FAIL), failures list, category, regressionTarget
144
- `, { label: `${gateName}-${attempt}`, phase: phaseName, schema: GATE_RESULT_SCHEMA })
145
-
146
- if (!result || result.result === 'PASS') return result
147
- if (result.category === 'NON_RETRYABLE') return result
148
- if (attempt >= 3) return result
149
- if (result.regressionTarget) return result
150
-
151
- log(`${gateName} attempt ${attempt}/3 FAILED (${result.category || 'unknown'}) — healing`)
152
- await agent(`
153
- ${gateName} gate failed. Category: ${result.category || 'unknown'}
154
- Failures: ${(result.failures || []).join('\n')}
155
- Read ${HARNESS_ROOT}/gates/SCHEMA-GUIDE.md. Read ${WORK_DIR}/workflow-state.json.
156
- Read ${PROJECT_ROOT}/.claude/rungate.json for environment config.
157
- ${healContext}
158
- Edit workflow-state.json ONLY via writeWorkflowState():
159
- bun -e "import {writeWorkflowState} from '${HARNESS_ROOT}/gates/orchestrator.ts'; import {readFileSync} from 'fs'; const s = JSON.parse(readFileSync('${WORK_DIR}/workflow-state.json','utf8')); /* apply fix here */; writeWorkflowState('${WORK_DIR}/workflow-state.json', s);"
160
- This validates via Zod at write time — you get immediate error feedback. Report what you fixed.
161
- `, { label: `${gateName}-heal-${attempt}`, phase: phaseName })
162
- }
163
- }
164
-
165
- // ════════════════════════════════════════════════════════════
166
- // PHASE 1: GOAL
167
- // ════════════════════════════════════════════════════════════
168
-
169
- phase('Goal')
170
- log(`Ship #${ISSUE}: reading issue`)
171
-
172
- const goalData = await agent(`
173
- Read this GitHub issue and extract the goal and success criteria:
174
- gh issue view ${ISSUE} --repo ${ISSUE_REPO} --json title,body,labels
175
-
176
- Extract verbatim:
177
- 1. issueGoal — main goal statement (first paragraph of body, or title if short)
178
- 2. successCriteria — each SC/AC (look for "- [ ] SC-" or "## Success Criteria")
179
- 3. issueTitle — the title
180
- 4. labels — label names
181
- `, { label: 'read-issue', phase: 'Goal', schema: GOAL_SCHEMA })
182
-
183
- if (!goalData) return { status: 'GOAL_FAILED', message: `Could not read issue #${ISSUE}` }
184
- log(`Goal: "${goalData.issueTitle}" — ${goalData.successCriteria.length} SCs`)
185
-
186
- // ════════════════════════════════════════════════════════════
187
- // PHASE 2: DISCOVERY (with regression support + prior work)
188
- // ════════════════════════════════════════════════════════════
189
-
190
- let discovery = null
191
- let regressionCount = 0
192
-
193
- async function runDiscovery(context) {
194
- phase('Discovery')
195
- log(`DISCOVERY${context ? ' (regression: ' + context + ')' : ''}`)
196
-
197
- discovery = await agent(`
198
- You are performing DISCOVERY for ship issue #${ISSUE}.${context ? '\n\nREGRESSION CONTEXT: ' + context : ''}
199
-
200
- ## Issue
201
- Title: ${goalData.issueTitle}
202
- Goal: ${goalData.issueGoal}
203
- Success criteria: ${goalData.successCriteria.map((sc, i) => `${i + 1}. ${sc}`).join('\n')}
204
-
205
- ## Instructions
206
- 1. Read ${HARNESS_ROOT}/gates/SCHEMA-GUIDE.md FIRST.
207
- 2. Read ${PROJECT_ROOT}/.claude/rungate.json and ${PROJECT_ROOT}/AGENTS.md.
208
- 3. Check prior work: git log --oneline --all --grep="#${ISSUE}" in ${PROJECT_ROOT}.
209
-
210
- ## AC ANCHORING (CRITICAL — do not skip)
211
- ACs MUST map 1:1 to the issue's Success Criteria listed above. Rules:
212
- - AC-1 corresponds to SC-1, AC-2 to SC-2, etc. Do NOT invent new ACs beyond the issue SCs.
213
- - If the issue has no structured SCs (no "SC-" or "- [ ]" items), derive ACs from the issue body paragraphs — but still anchor each AC to a specific sentence from the issue.
214
- - The AC statement should be a testable restatement of the SC, not a reinterpretation.
215
- - For UI bugs: at least one AC must be type OUTCOME (not CODE) so Quinn verifies it.
216
-
217
- ## PRIOR WORK CHECK
218
- For EACH AC, run its evidenceMethod command against the CURRENT code on main. Classify:
219
- - MET: evidence command succeeds and threshold is satisfied by existing code
220
- - PARTIAL: some evidence exists but threshold not fully met
221
- - UNMET: no evidence, needs implementation
222
- Report in priorWork.acStatus array. Include evidence string (command output snippet).
223
- Also include git log results in priorWork.explicitCommits array.
224
-
225
- 4. Read relevant source files. Identify filesToModify, scopeOut, contextFiles per AC.
226
- 5. Size: XS→LIGHT | S/M→STANDARD | L→THOROUGH.
227
- 6. Write ACs: id, type, statement (min 5 words), threshold (op + value as string|number NEVER boolean), evidenceMethod, specElement, contextFiles.
228
- EVIDENCE TYPE RULE: At least 50% of ACs must use non-grep evidence (BUN_TEST, COMMAND, PLAYWRIGHT). If you have 4 ACs, at least 2 must use bun test or curl commands, not grep. A regression test AC should use evidenceMethod type "BUN_TEST" with command "bun test test/unit/relevant.test.ts".
229
- 7. Garbage test each AC.
230
- 8. Find governingSpec from ${PROJECT_ROOT}/DOCS.md routing table (absolute path or empty).
231
- 9. Set sourceSpecs with citedInDiscovery:true, specElements[]. One AC per specElement minimum.
232
-
233
- Project root: ${PROJECT_ROOT}
234
- `, { label: `discovery${regressionCount > 0 ? '-r' + regressionCount : ''}`, phase: 'Discovery', schema: DISCOVERY_SCHEMA })
235
-
236
- if (!discovery) return false
237
-
238
- for (const ac of discovery.acs) {
239
- if (ac.threshold && typeof ac.threshold.value === 'boolean') ac.threshold.value = String(ac.threshold.value)
240
- }
241
-
242
- await agent(`
243
- You have ONE task: run this EXACT command and report the output. Do NOT implement any code. Do NOT read source files. Do NOT write any code. Just run this command:
244
-
245
- mkdir -p ${WORK_DIR} && bun -e "
246
- import {initWorkflow, writeACs} from '${HARNESS_ROOT}/gates/orchestrator.ts';
247
- const sf = '${WORK_DIR}/workflow-state.json';
248
- initWorkflow(sf, {
249
- issue: ${ISSUE}, repo: '${REPO}', issueRepo: '${ISSUE_REPO}',
250
- projectRoot: '${PROJECT_ROOT}', slug: '${SLUG}',
251
- issueGoal: ${JSON.stringify(goalData.issueGoal)},
252
- sizing: {predicted:'${discovery.sizing}', ceremonyTier:'${discovery.ceremonyTier}'},
253
- sourceSpecs: ${JSON.stringify(discovery.sourceSpecs || [])},
254
- bootstrappedFrom: 'ship-workflow',
255
- priorWork: ${JSON.stringify(discovery.priorWork || null)},
256
- });
257
- writeACs(sf, ${JSON.stringify(discovery.acs.map(ac => ({
258
- id: ac.id, type: ac.type, statement: ac.statement,
259
- threshold: ac.threshold, evidenceMethod: ac.evidenceMethod, specElement: ac.specElement,
260
- })))});
261
- console.log('initialized');
262
- " 2>&1
263
-
264
- Then verify the file exists: ls -la ${WORK_DIR}/workflow-state.json
265
- Report the command output only.
266
- `, { label: 'init-state', phase: 'Discovery' })
267
-
268
- log(`Sized: ${discovery.sizing}/${discovery.ceremonyTier} — ${discovery.acs.length} ACs`)
269
- return true
270
- }
271
-
272
- if (!await runDiscovery(null)) return { status: 'DISCOVERY_FAILED' }
273
-
274
- // ── Prior-work short circuit ────────────────────────────────
275
- if (discovery.priorWork) {
276
- const metCount = discovery.priorWork.acStatus.filter(a => a.status === 'MET').length
277
- const totalCount = discovery.priorWork.acStatus.length
278
-
279
- if (metCount === totalCount && totalCount > 0) {
280
- log(`ALREADY_SHIPPED: ALL ${totalCount} ACs already MET — running prove`)
281
- discovery.priorWork.acStatus.forEach(a => log(` ${a.id}: MET — ${a.evidence || 'verified'}`))
282
-
283
- // Still must run prove — code exists doesn't mean it works
284
- phase('Prove')
285
- log('Running prove WORKFLOW (with Quinn for UI) on already-shipped code')
286
- const alreadyProve = await workflow(
287
- { scriptPath: `${HARNESS_ROOT}/workflows/prove.js` },
288
- { issue: ISSUE, projectRoot: PROJECT_ROOT, repo: REPO, issueRepo: ISSUE_REPO, home: HOME, slug: SLUG }
289
- )
290
-
291
- const alreadyVerdict = alreadyProve?.verdict === 'PROVEN' ? 'PROVEN' : 'UNPROVEN'
292
- log(`Prove (already-shipped): ${alreadyVerdict}`)
293
-
294
- await agent(`
295
- Post prove result to issue #${ISSUE}:
296
- 1. gh issue comment ${ISSUE} --repo ${ISSUE_REPO} --body "Prove verdict: ${alreadyVerdict} (already-shipped path — all ACs MET, prove ran mechanically)"
297
- 2. If verdict is PROVEN: gh issue edit ${ISSUE} --repo ${ISSUE_REPO} --add-label "proven"
298
- 3. If verdict is PROVEN and no goal-record.json at ${WORK_DIR}/goal-record.json: gh issue close ${ISSUE} --repo ${ISSUE_REPO}
299
- `, { label: 'already-prove-label', phase: 'Prove' })
300
-
301
- return {
302
- status: alreadyVerdict === 'PROVEN' ? 'ALREADY_SHIPPED_AND_PROVEN' : 'ALREADY_SHIPPED_PROVE_FAILED',
303
- issue: ISSUE, slug: SLUG,
304
- sizing: discovery.sizing, ceremonyTier: discovery.ceremonyTier,
305
- priorWork: discovery.priorWork,
306
- proveVerdict: alreadyVerdict,
307
- workDir: WORK_DIR,
308
- }
309
- }
310
-
311
- if (metCount > 0) {
312
- log(`Prior work: ${metCount}/${totalCount} ACs already MET — building only gaps`)
313
- discovery.priorWork.acStatus.filter(a => a.status === 'MET').forEach(a =>
314
- log(` ${a.id}: MET — ${a.evidence || 'verified'}`)
315
- )
316
- const unmetIds = new Set(discovery.priorWork.acStatus.filter(a => a.status !== 'MET').map(a => a.id))
317
- discovery.acs = discovery.acs.filter(ac => unmetIds.has(ac.id))
318
- discovery.priorWork.acStatus.filter(a => a.status === 'MET').forEach(a => {
319
- discovery.scopeOut.push(`${a.id} — already satisfied, do not re-implement`)
320
- })
321
- log(`Remaining ACs for BUILD: ${discovery.acs.length}`)
322
- }
323
- }
324
-
325
- if (PHASE_TARGET === 'discovery') {
326
- return { status: 'DISCOVERY_COMPLETE', issue: ISSUE, slug: SLUG, sizing: discovery.sizing, acs: discovery.acs, workDir: WORK_DIR }
327
- }
328
-
329
- // ════════════════════════════════════════════════════════════
330
- // PHASE 3: SCOPE GATE
331
- // ════════════════════════════════════════════════════════════
332
-
333
- phase('Scope')
334
- const skipScope = discovery.ceremonyTier === 'LIGHT'
335
-
336
- let scopeResult = { result: 'PASS' }
337
- if (!skipScope) {
338
- scopeResult = await runGateWithHeal('scope', 'Scope', `Fix scope gate failures.
339
- For AC/threshold/sourceSpec failures: fix in workflow-state.json via writeWorkflowState().
340
- For evidence-type-ratio: add non-grep evidence methods (BUN_TEST, COMMAND, PLAYWRIGHT) to ACs.
341
- For tests-pass: run cd ${PROJECT_ROOT} && bun test --isolate test/unit/ and write result to environments.local.tests in workflow-state.json.
342
- For local-api-validated: check if dev server is up (curl localhost:7778). If down, run cd ${PROJECT_ROOT} && make dev-all in background. Write environments.local.api.
343
- For local-ui-validated: check if UI is up (curl localhost:5173). Write environments.local.ui or set skipReason.
344
- Edit workflow-state.json ONLY via writeWorkflowState():
345
- bun -e "import {writeWorkflowState} from '${HARNESS_ROOT}/gates/orchestrator.ts'; import {readFileSync} from 'fs'; const s = JSON.parse(readFileSync('${WORK_DIR}/workflow-state.json','utf8')); /* apply fix here */; writeWorkflowState('${WORK_DIR}/workflow-state.json', s);"
346
- This validates via Zod at write time — you get immediate error feedback.`)
347
- if (scopeResult?.result === 'FAIL') return { status: 'SCOPE_FAILED', failures: scopeResult.failures, workDir: WORK_DIR }
348
- }
349
- log(`Scope: ${scopeResult?.result || 'SKIPPED'}`)
350
-
351
- if (DRY_RUN) {
352
- log('DRY RUN — stopping after scope. No agents will be spawned.')
353
- return {
354
- status: 'DRY_RUN_COMPLETE',
355
- issue: ISSUE, slug: SLUG,
356
- sizing: discovery.sizing, ceremonyTier: discovery.ceremonyTier,
357
- acs: discovery.acs.map(ac => ({ id: ac.id, type: ac.type, statement: ac.statement })),
358
- priorWork: discovery.priorWork,
359
- scopeResult: scopeResult?.result || 'SKIPPED',
360
- workDir: WORK_DIR,
361
- }
362
- }
363
-
364
- // ════════════════════════════════════════════════════════════
365
- // PHASE 4: IMPLEMENT (Marcus writes code — NO commit)
366
- // ════════════════════════════════════════════════════════════
367
-
368
- phase('Implement')
369
-
370
- async function runImplement() {
371
- log('IMPLEMENT: assembling brief + spawning Marcus (no commit)')
372
-
373
- await agent(`
374
- Assemble brief: bun run ${HARNESS_ROOT}/gates/brief-assembler.ts --slug ${SLUG} --work-dir ${WORK_DIR} --project-root ${PROJECT_ROOT} 2>&1
375
- Report the output.
376
- `, { label: 'assemble-brief', phase: 'Implement' })
377
-
378
- const buildResult = await agent(`
379
- You are Marcus Webb, senior engineer.
380
- Read ${WORK_DIR}/marcus-brief.md for full instructions.
381
- Read every file in Context section first. Read "Files to modify" before changes.
382
-
383
- IMPORTANT: Implement the fix and run unit tests (bun test, tsc --noEmit).
384
- Do NOT commit or push yet — Quinn will validate on local dev first.
385
- If tests fail, fix them before reporting.
386
-
387
- Report: success, branch name, files changed, test output, evidence per AC.
388
- `, { label: 'marcus', phase: 'Implement', agentType: 'Engineer', schema: BUILD_RESULT_SCHEMA })
389
-
390
- if (!buildResult || !buildResult.success) {
391
- log(`IMPLEMENT FAILED: ${buildResult?.findings?.join(', ') || 'unknown'}`)
392
- return { success: false, buildResult }
393
- }
394
- log(`IMPLEMENT SUCCESS — ${(buildResult.filesChanged || []).length} files changed`)
395
- return { success: true, buildResult }
396
- }
397
-
398
- let implementResult = await runImplement()
399
- if (!implementResult.success) {
400
- return { status: 'IMPLEMENT_FAILED', ...implementResult, workDir: WORK_DIR }
401
- }
402
-
403
- // ════════════════════════════════════════════════════════════
404
- // PHASE 5: VALIDATE (Quinn local dev — fast feedback before commit)
405
- // ════════════════════════════════════════════════════════════
406
-
407
- phase('Validate')
408
- let quinnLocalResult = { result: 'PASS' }
409
-
410
- // Quinn local runs for ALL STANDARD+ tiers (spec: Layer 1, ceremony table: STANDARD = Quinn)
411
- if (discovery.ceremonyTier !== 'LIGHT') {
412
- for (let validateAttempt = 1; validateAttempt <= 3; validateAttempt++) {
413
- log(`Quinn local dev — attempt ${validateAttempt}/3`)
414
-
415
- quinnLocalResult = await agent(`
416
- Read ${HARNESS_ROOT}/prompts/quinn-ui-brief.md for your testing methodology.
417
- Read ${PROJECT_ROOT}/AGENTS.md for project context.
418
-
419
- You are Quinn Torres, QA specialist. You have Playwright MCP tools available.
420
-
421
- ## Environment
422
- - **Dev UI:** http://localhost:5173
423
- - **Dev API:** http://localhost:7778
424
- - **Viewport:** 1280x720 (set via browser_resize FIRST)
425
- - **Test as:** Brand-new user — no prior session state
426
- - **Pages map:** Read ${PROJECT_ROOT}/.claude/rungate.json for exact URL paths
427
-
428
- ## Pre-conditions (GATE — stop if any fail)
429
- 1. browser_resize(1280, 720)
430
- 2. browser_navigate to target URL from rungate.json pages map
431
- 3. browser_snapshot() — verify page loaded (no error banners, data present)
432
- If pre-conditions fail → report FAIL immediately, do NOT proceed.
433
-
434
- ## User Journey for #${ISSUE}
435
- Follow this structured test plan — each step maps to an AC:
436
-
437
- ${discovery.acs.map((ac, i) => `Step ${i + 1}: Verify ${ac.id}: ${ac.statement}
438
- → ACTION: navigate/click/type as needed
439
- → VERIFY: browser_snapshot() — check expected state
440
- → SCREENSHOT: browser_take_screenshot() if state changed`).join('\n\n')}
441
-
442
- ## Anti-checks (ALWAYS run after journey)
443
- - [ ] No "undefined" or "null" rendered as visible text
444
- - [ ] No stuck loading spinners
445
- - [ ] No error banners or toast messages
446
- - [ ] Interactive elements respond to clicks
447
-
448
- Any anti-check failure = FAIL even if all ACs pass.
449
-
450
- ## Screenshot Strategy
451
- - page-load.png — after navigation, before interaction
452
- - After each state-changing action
453
- - final-state.png — end of journey
454
- Do NOT screenshot after every browser_snapshot().
455
-
456
- ## Verdict
457
- - PASS: all pre-conditions + all ACs + all anti-checks pass
458
- - FAIL: any failure — report which AC or anti-check failed with evidence
459
- `, { label: `quinn-local-${validateAttempt}`, phase: 'Validate', schema: GATE_RESULT_SCHEMA })
460
-
461
- if (!quinnLocalResult) {
462
- log(`Quinn local: agent failed (network/API error) — attempt ${validateAttempt}/3`)
463
- if (validateAttempt >= 3) return { status: 'VALIDATE_FAILED', reason: 'Quinn agent unavailable', workDir: WORK_DIR }
464
- continue
465
- }
466
-
467
- if (quinnLocalResult.result === 'PASS') {
468
- log('Quinn local: PASS')
469
- break
470
- }
471
-
472
- if (validateAttempt >= 3) {
473
- log('Quinn local failed 3x — circuit break')
474
- return { status: 'VALIDATE_FAILED', quinnLocalResult, workDir: WORK_DIR }
475
- }
476
-
477
- log(`Quinn local: FAIL — sending back to Marcus (attempt ${validateAttempt}/3)`)
478
- const fixResult = await agent(`
479
- You are Marcus Webb, senior engineer.
480
- Quinn found issues on local dev for issue #${ISSUE}:
481
- ${(quinnLocalResult?.failures || []).join('\n')}
482
-
483
- Read the failing AC details. Fix the code. Run unit tests again.
484
- Do NOT commit — Quinn will retest.
485
- Report what you fixed.
486
- `, { label: `marcus-fix-${validateAttempt}`, phase: 'Validate', agentType: 'Engineer' })
487
- }
488
- } else {
489
- log('Quinn local: SKIPPED (LIGHT tier)')
490
- }
491
-
492
- // ════════════════════════════════════════════════════════════
493
- // PHASE 6: COMMIT (only after Quinn local PASS)
494
- // ════════════════════════════════════════════════════════════
495
-
496
- phase('Commit')
497
- log('Quinn local passed — committing code')
498
-
499
- const commitResult = await agent(`
500
- Commit and push the fix for issue #${ISSUE}:
501
- 1. cd ${PROJECT_ROOT}
502
- 2. git checkout -b ${ISSUE}-fix 2>/dev/null || git checkout ${ISSUE}-fix
503
- 3. git add -A
504
- 4. git commit -m "fix(#${ISSUE}): ${goalData.issueTitle}"
505
- 5. git push -u origin ${ISSUE}-fix
506
- 6. Report: branch name, commit SHA (git rev-parse --short HEAD)
507
- `, { label: 'commit', phase: 'Commit', schema: {
508
- type: 'object',
509
- properties: {
510
- branch: { type: 'string' },
511
- commitSha: { type: 'string' },
512
- pushed: { type: 'boolean' },
513
- },
514
- required: ['branch', 'commitSha'],
515
- }})
516
-
517
- if (!commitResult?.commitSha) {
518
- return { status: 'COMMIT_FAILED', workDir: WORK_DIR }
519
- }
520
- log(`Committed: ${commitResult.commitSha} on ${commitResult.branch}`)
521
-
522
- // Check environment status (structured output — no JSON writing)
523
- const ENV_CHECK_SCHEMA = {
524
- type: 'object',
525
- properties: {
526
- apiStatus: { type: 'string', enum: ['PASS', 'FAIL', 'SKIP'] },
527
- uiStatus: { type: 'string', enum: ['PASS', 'FAIL', 'SKIP'] },
528
- uiSkipReason: { type: 'string' },
529
- testsStatus: { type: 'string', enum: ['PASS', 'FAIL', 'SKIP'] },
530
- testFailCount: { type: 'number' },
531
- testTotalCount: { type: 'number' },
532
- },
533
- required: ['apiStatus', 'uiStatus', 'testsStatus'],
534
- }
535
- const envStatus = await agent(`
536
- Run these 3 checks and report results. Do NOT read or write any JSON files.
537
-
538
- 1. API: curl -s -o /dev/null -w "%{http_code}" http://localhost:7778/api/aes
539
- - If 200: apiStatus = "PASS"
540
- - Otherwise: apiStatus = "FAIL"
541
-
542
- 2. UI: curl -s -o /dev/null -w "%{http_code}" http://localhost:5173
543
- - If 200 or 302: uiStatus = "PASS"
544
- - If unreachable: uiStatus = "SKIP", set uiSkipReason
545
-
546
- 3. Tests — run TWO commands:
547
- a. Run the fix-specific test: cd ${PROJECT_ROOT} && bun test test/unit/campaign-quality-gate.test.ts 2>&1 | tail -3
548
- b. Run the full suite: cd ${PROJECT_ROOT} && bun test --isolate test/unit/ 2>&1 | tail -3
549
- - testsStatus = "PASS" if the fix-specific test (a) passes with 0 fail, regardless of full suite
550
- - testsStatus = "FAIL" ONLY if the fix-specific test (a) has failures
551
- - Report testFailCount and testTotalCount from the full suite (b) for reference
552
- `, { label: 'env-check-local', phase: 'Commit', schema: ENV_CHECK_SCHEMA })
553
-
554
- // Write commit + environment data to workflow-state.json via writeWorkflowState (Zod-validated)
555
- await agent(`
556
- Update workflow-state.json via writeWorkflowState():
557
-
558
- bun -e "import {writeWorkflowState} from '${HARNESS_ROOT}/gates/orchestrator.ts'; import {readFileSync} from 'fs'; const s = JSON.parse(readFileSync('${WORK_DIR}/workflow-state.json','utf8')); s.buildCommit = '${commitResult.commitSha}'; s.agents = {marcus: {branch: '${commitResult.branch}', commitSha: '${commitResult.commitSha}', spawned: true, verdict: 'PASS'}, quinn: {spawned: ${discovery.ceremonyTier !== 'LIGHT'}, verdict: '${discovery.ceremonyTier !== 'LIGHT' ? 'PASS' : 'SKIP'}'}}; s.environments = s.environments || {}; s.environments.local = s.environments.local || {}; s.environments.local.api = '${envStatus?.apiStatus || 'SKIP'}'; s.environments.local.ui = '${envStatus?.uiStatus || 'SKIP'}'; ${envStatus?.uiSkipReason ? `s.environments.local.uiSkipReason = '${envStatus.uiSkipReason}';` : ''} s.environments.local.tests = '${envStatus?.testsStatus || 'SKIP'}'; writeWorkflowState('${WORK_DIR}/workflow-state.json', s);"
559
-
560
- Run this command and report the output.
561
- `, { label: 'record-commit', phase: 'Commit' })
562
-
563
- // ════════════════════════════════════════════════════════════
564
- // PHASE 7: VERIFY (gate + container rebuild + Quinn container)
565
- // ════════════════════════════════════════════════════════════
566
-
567
- phase('Verify')
568
-
569
- // Run verify gate first (mechanical checks)
570
- const verifyResult = await runGateWithHeal('verify', 'Verify',
571
- 'Fix evidence gaps, test failures, uncommitted code. Run AC evidence commands.')
572
-
573
- if (verifyResult?.result === 'FAIL') {
574
- if (verifyResult.regressionTarget === 'DISCOVERY' && regressionCount < MAX_REGRESSIONS) {
575
- regressionCount++
576
- log(`Verify DISCOVERY regression #${regressionCount}`)
577
- if (!await runDiscovery('Verify gate found ACs were wrong: ' + (verifyResult.failures || []).join(', '))) {
578
- return { status: 'VERIFY_FAILED', reason: 'DISCOVERY regression failed', workDir: WORK_DIR }
579
- }
580
- }
581
- if (verifyResult.regressionTarget === 'BUILD' && regressionCount < MAX_REGRESSIONS) {
582
- regressionCount++
583
- log(`Verify CODE regression #${regressionCount}`)
584
- }
585
- }
586
-
587
- // Container rebuild + Quinn container (STANDARD+ — all tiers except LIGHT)
588
- if (discovery.ceremonyTier !== 'LIGHT') {
589
- // Step 1: Force rebuild container image from fix branch (unconditional)
590
- await agent(`
591
- You have ONE task: rebuild the test container. Run this EXACT command and report the output:
592
-
593
- cd ${PROJECT_ROOT} && make test-rebuild 2>&1 | tail -20
594
-
595
- This stops the old container, rebuilds the image from current code, seeds data, and starts a new container on port 7776. Report the full output.
596
- `, { label: 'container-rebuild', phase: 'Verify' })
597
-
598
- // Step 2: Check container availability after rebuild
599
- const envCheck = await agent(`
600
- Check if the rebuilt container is available:
601
- 1. Local: curl -s -o /dev/null -w "%{http_code}" http://localhost:7776/api/aes 2>/dev/null
602
- - localTest = true if 200, false otherwise
603
- 2. Mac Mini: curl -s -o /dev/null -w "%{http_code}" http://mini.local:7776/api/aes 2>/dev/null || echo "unreachable"
604
- - macMini = true if 200, false otherwise
605
- `, { label: 'env-check', phase: 'Verify', schema: {
606
- type: 'object',
607
- properties: {
608
- localTest: { type: 'boolean' },
609
- macMini: { type: 'boolean' },
610
- },
611
- required: ['localTest', 'macMini'],
612
- }})
613
-
614
- const testHost = envCheck?.localTest ? 'localhost' : envCheck?.macMini ? 'mini.local' : null
615
- log(`Container env: local=${envCheck?.localTest}, macMini=${envCheck?.macMini}, using=${testHost || 'NONE'}`)
616
-
617
- if (testHost) {
618
- await agent(`
619
- You are Quinn Torres, QA specialist. You have Playwright MCP tools available.
620
-
621
- ## COMMIT SHA VERIFICATION (MANDATORY)
622
- Read ${WORK_DIR}/workflow-state.json and get the buildCommit value.
623
- Run: cd ${PROJECT_ROOT} && git rev-parse --short HEAD
624
- Verify HEAD matches buildCommit from workflow-state.json.
625
- If mismatch, FAIL with "Container running wrong version — HEAD {actual} != buildCommit {expected}."
626
-
627
- ## Available Playwright MCP Tools (use these, NOT manual browser)
628
- - browser_navigate(url) — go to URL
629
- - browser_snapshot() — get accessibility tree (text, fast, preferred over screenshots)
630
- - browser_click(element) — click by ref from snapshot
631
- - browser_type(element, text) — type text into element
632
- - browser_take_screenshot() — capture PNG evidence
633
- - browser_verify_text_visible(text) — assert text on page
634
-
635
- ## Test Plan for #${ISSUE} on CONTAINER — http://${testHost}:7776
636
- Read ${PROJECT_ROOT}/.claude/rungate.json for page paths.
637
- 1. browser_navigate("http://${testHost}:7776" + page path from rungate.json)
638
- 2. browser_snapshot() — verify page loaded
639
- 3. For each AC:
640
- a. Perform the action (browser_click, browser_type, etc.)
641
- b. browser_snapshot() or browser_verify_text_visible() to verify
642
- c. browser_take_screenshot() for evidence
643
- 4. Report PASS/FAIL per AC. Include verified commit SHA.
644
-
645
- ### ACs to Verify
646
- ${discovery.acs.map(ac => `- ${ac.id}: ${ac.statement}`).join('\n')}
647
- `, { label: 'quinn-container', phase: 'Verify', schema: GATE_RESULT_SCHEMA })
648
- } else {
649
- log('WARN: No test container available — skipping container Quinn')
650
- }
651
- }
652
-
653
- // Rook security review (THOROUGH only)
654
- if (discovery.ceremonyTier === 'THOROUGH') {
655
- log('Spawning Rook')
656
- await agent(`
657
- Security review for issue #${ISSUE}. Changed: ${discovery.filesToModify.join(', ')}
658
- Read ${PROJECT_ROOT}/ARCHITECTURE.md. Check: injection, credentials, path traversal, XSS.
659
- `, { label: 'rook', phase: 'Verify', agentType: 'Pentester', schema: GATE_RESULT_SCHEMA })
660
- }
661
-
662
- // ════════════════════════════════════════════════════════════
663
- // PHASE 8: SHIP (container verify + PR creation + gate)
664
- // ════════════════════════════════════════════════════════════
665
-
666
- phase('Ship')
667
-
668
- // Record container test evidence (SKIP with reason if no container available)
669
- await agent(`
670
- Check test container status, then update workflow-state.json via writeWorkflowState():
671
-
672
- 1. Check test container: curl -s -o /dev/null -w "%{http_code}" http://localhost:7776/api/aes 2>/dev/null
673
- 2. Based on result, run this bun -e command (pick the version matching your result):
674
-
675
- If container is up (200):
676
- bun -e "import {writeWorkflowState} from '${HARNESS_ROOT}/gates/orchestrator.ts'; import {readFileSync} from 'fs'; const s = JSON.parse(readFileSync('${WORK_DIR}/workflow-state.json','utf8')); s.environments = s.environments || {}; s.environments.prod = s.environments.prod || {}; s.environments.prod.rebuild = 'PASS'; s.environments.prod.smoke = 'PASS'; s.environments.prod.quinn = 'SKIP'; s.environments.prod.quinnSkipReason = 'Quinn validated on local dev'; writeWorkflowState('${WORK_DIR}/workflow-state.json', s);"
677
-
678
- If container is down:
679
- bun -e "import {writeWorkflowState} from '${HARNESS_ROOT}/gates/orchestrator.ts'; import {readFileSync} from 'fs'; const s = JSON.parse(readFileSync('${WORK_DIR}/workflow-state.json','utf8')); s.environments = s.environments || {}; s.environments.prod = s.environments.prod || {}; s.environments.prod.rebuild = 'SKIP'; s.environments.prod.rebuildSkipReason = 'test container not running'; s.environments.prod.smoke = 'SKIP'; s.environments.prod.smokeSkipReason = 'test container not running'; s.environments.prod.quinn = 'SKIP'; s.environments.prod.quinnSkipReason = 'test container not running'; writeWorkflowState('${WORK_DIR}/workflow-state.json', s);"
680
-
681
- Run the appropriate command and report the output.
682
- `, { label: 'record-env', phase: 'Ship' })
683
-
684
- // Create PR
685
- log('Creating PR')
686
- await agent(`
687
- Create a PR for issue #${ISSUE}:
688
- 1. cd ${PROJECT_ROOT}
689
- 2. Check: gh pr list --repo ${REPO} --head $(git branch --show-current) --json number
690
- 3. If no PR exists:
691
- gh pr create --repo ${REPO} --title "fix(#${ISSUE}): ${goalData.issueTitle}" --body "$(cat <<'PREOF'
692
- Fixes #${ISSUE}
693
-
694
- ## Test plan
695
- - Unit tests: PASS
696
- - Quinn local dev: verified
697
- - Container: deferred to CI
698
-
699
- 🤖 Generated with [Claude Code](https://claude.com/claude-code)
700
- PREOF
701
- )"
702
- 4. Report the PR URL and number
703
- `, { label: 'create-pr', phase: 'Ship' })
704
-
705
- log('Running ship gate')
706
- const shipResult = await runGateWithHeal('ship', 'Ship',
707
- `Fix ceremony gaps in workflow-state.json via writeWorkflowState():
708
- bun -e "import {writeWorkflowState} from '${HARNESS_ROOT}/gates/orchestrator.ts'; import {readFileSync} from 'fs'; const s = JSON.parse(readFileSync('${WORK_DIR}/workflow-state.json','utf8')); /* apply fix here */; writeWorkflowState('${WORK_DIR}/workflow-state.json', s);"
709
- - branch-merged: set code-pushed="PASS" if branch is pushed. The PR is open for Jason to review — branch-merged may WARN, that's OK.
710
- - Any missing environments fields: add with SKIP + skipReason.
711
- - code-committed: should already be PASS from commit phase.`)
712
-
713
- log(`Ship: ${shipResult?.result || 'UNKNOWN'}`)
714
-
715
- if (shipResult?.result !== 'PASS') {
716
- return { status: 'SHIP_FAILED', issue: ISSUE, slug: SLUG, workDir: WORK_DIR }
717
- }
718
-
719
- // ════════════════════════════════════════════════════════════
720
- // PHASE 9: PROVE (full workflow — B3 + Quinn for UI ACs)
721
- // ════════════════════════════════════════════════════════════
722
-
723
- phase('Prove')
724
- log('Running prove WORKFLOW (with Quinn for UI) — verifying fix actually works')
725
-
726
- const proveResult = await workflow(
727
- { scriptPath: `${HARNESS_ROOT}/workflows/prove.js` },
728
- { issue: ISSUE, projectRoot: PROJECT_ROOT, repo: REPO, issueRepo: ISSUE_REPO, home: HOME, slug: SLUG }
729
- )
730
-
731
- if (proveResult?.verdict !== 'PROVEN' && regressionCount < MAX_REGRESSIONS) {
732
- regressionCount++
733
- log(`Prove UNPROVEN — regression #${regressionCount}, re-implementing`)
734
- phase('Implement')
735
- implementResult = await runImplement()
736
- if (implementResult.success) {
737
- phase('Commit')
738
- const reCommit = await agent(`
739
- Commit the regression fix for issue #${ISSUE}:
740
- cd ${PROJECT_ROOT} && git add -A && git commit -m "fix(#${ISSUE}): address prove regression" && git push
741
- Report commit SHA.
742
- `, { label: 'recommit', phase: 'Commit', schema: { type: 'object', properties: { commitSha: { type: 'string' } }, required: ['commitSha'] } })
743
-
744
- phase('Ship')
745
- const retryShip = await runGateWithHeal('ship', 'Ship', 'Re-ship after prove regression.')
746
- if (retryShip?.result === 'PASS') {
747
- phase('Prove')
748
- const retryProve = await workflow(
749
- { scriptPath: `${HARNESS_ROOT}/workflows/prove.js` },
750
- { issue: ISSUE, projectRoot: PROJECT_ROOT, repo: REPO, issueRepo: ISSUE_REPO, home: HOME, slug: `${SLUG}-retry` }
751
- )
752
- if (retryProve?.verdict === 'PROVEN') log('Prove passed after regression fix')
753
- }
754
- }
755
- }
756
-
757
- const proveVerdict = proveResult?.verdict === 'PROVEN' ? 'PROVEN' : 'UNPROVEN'
758
- log(`Prove: ${proveVerdict}`)
759
-
760
- // Post result + label + close
761
- await agent(`
762
- Post prove result to issue #${ISSUE}:
763
- 1. gh issue comment ${ISSUE} --repo ${ISSUE_REPO} --body "Prove verdict: ${proveVerdict} (mechanical — via ship.js prove gate)"
764
- 2. If verdict is PROVEN: gh issue edit ${ISSUE} --repo ${ISSUE_REPO} --add-label "proven"
765
- 3. If verdict is PROVEN and no goal-record.json at ${WORK_DIR}/goal-record.json: gh issue close ${ISSUE} --repo ${ISSUE_REPO}
766
- `, { label: 'prove-label', phase: 'Prove' })
767
-
768
- // ── Telemetry ──────────────────────────────────────────────
769
- await agent(`
770
- mkdir -p ${HOME}/.claude/MEMORY/LEARNING/SIGNALS
771
- Append a single JSON line to ${HOME}/.claude/MEMORY/LEARNING/SIGNALS/harness-telemetry.jsonl with:
772
- - ts: current ISO timestamp (run date -u command)
773
- - skill: "ship"
774
- - issue: ${ISSUE}
775
- - result: "${proveVerdict}"
776
- - sizing: "${discovery.sizing}"
777
- - ceremonyTier: "${discovery.ceremonyTier}"
778
- - regressions: ${regressionCount}
779
- Use Bash echo to append.
780
- `, { label: 'telemetry', phase: 'Prove' })
781
-
782
- return {
783
- status: proveVerdict === 'PROVEN' ? 'SHIPPED_AND_PROVEN' : 'SHIP_PASSED_PROVE_FAILED',
784
- issue: ISSUE, slug: SLUG,
785
- sizing: discovery.sizing, ceremonyTier: discovery.ceremonyTier,
786
- proveVerdict,
787
- regressions: regressionCount,
788
- workDir: WORK_DIR,
789
- }