@haposoft/cafekit 0.16.0-rc.6 → 0.16.0-rc.8

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 (87) hide show
  1. package/README.md +21 -58
  2. package/bin/__tests__/change-firewall.semantic-firewall.test.js +4 -5
  3. package/bin/__tests__/codex-hooks.test.js +382 -0
  4. package/bin/__tests__/codex-native.test.js +579 -80
  5. package/bin/__tests__/develop-contract.test.js +155 -76
  6. package/bin/__tests__/installer-safety.test.js +19 -154
  7. package/bin/__tests__/package-inventory.test.js +494 -26
  8. package/bin/__tests__/release-preflight.semantic-firewall.test.js +2 -2
  9. package/bin/__tests__/validator-grounding.test.js +11 -11
  10. package/bin/install.js +2 -7
  11. package/bin/lib/context.js +0 -45
  12. package/bin/lib/copy-utils.js +1 -1
  13. package/bin/lib/i18n.js +0 -3
  14. package/bin/lib/manifest.js +1 -1
  15. package/bin/phases/claude-runtime.js +1 -3
  16. package/bin/phases/codex-runtime.js +4 -2
  17. package/bin/phases/copy-payload.js +3 -15
  18. package/bin/phases/post-install.js +5 -17
  19. package/bin/phases/root-config.js +2 -3
  20. package/bin/phases/select-platform.js +2 -5
  21. package/bin/phases/summary.js +0 -1
  22. package/package.json +2 -5
  23. package/src/claude/CLAUDE.md +19 -6
  24. package/src/claude/agents/project-manager.md +41 -9
  25. package/src/claude/agents/spec-maker.md +82 -155
  26. package/src/claude/gitignore +1 -1
  27. package/src/claude/hooks/__tests__/spec-gate.test.js +238 -0
  28. package/src/claude/hooks/__tests__/state.test.js +249 -3
  29. package/src/claude/hooks/lib/context.cjs +1 -1
  30. package/src/claude/hooks/lib/detect.cjs +1 -1
  31. package/src/claude/hooks/spec-gate.cjs +44 -9
  32. package/src/claude/hooks/spec-state.cjs +51 -13
  33. package/src/claude/hooks/task-scaffold-guard.cjs +1 -1
  34. package/src/claude/migration-manifest.json +17 -3
  35. package/src/claude/rules/manage-docs.md +43 -24
  36. package/src/claude/rules/state-sync.md +57 -62
  37. package/src/claude/rules/workflow.md +30 -13
  38. package/src/claude/scripts/change-firewall.cjs +2 -2
  39. package/src/claude/scripts/generate-skill-catalog.cjs +0 -1
  40. package/src/claude/scripts/spec-receipt.cjs +196 -1
  41. package/src/claude/scripts/spec-resolver.cjs +428 -0
  42. package/src/claude/skills/develop/SKILL.md +89 -125
  43. package/src/claude/skills/develop/references/parallel-waves.md +75 -162
  44. package/src/claude/skills/develop/references/quality-gate.md +61 -121
  45. package/src/claude/skills/develop/references/subagent-patterns.md +31 -38
  46. package/src/claude/skills/question/SKILL.md +1 -1
  47. package/src/claude/skills/specs/SKILL.md +152 -204
  48. package/src/claude/skills/specs/references/review.md +124 -243
  49. package/src/claude/skills/specs/references/templates.md +202 -0
  50. package/src/claude/skills/sync/SKILL.md +66 -90
  51. package/src/claude/skills/sync/references/sync-protocols.md +62 -83
  52. package/src/codex/AGENTS.md +20 -7
  53. package/src/codex/hooks/lib/spec-receipt.cjs +18 -0
  54. package/src/codex/hooks/lib/spec-utils.cjs +25 -0
  55. package/src/codex/hooks/spec-gate.cjs +46 -16
  56. package/src/codex/hooks/spec-state.cjs +54 -16
  57. package/src/codex/rules/state-sync.md +57 -61
  58. package/src/common/AGENTS.md +8 -1
  59. package/bin/__tests__/opencode-spec-gate.test.js +0 -799
  60. package/bin/lib/opencode-install.js +0 -899
  61. package/bin/phases/opencode-runtime.js +0 -38
  62. package/src/claude/skills/specs/references/archive-workflow.md +0 -74
  63. package/src/claude/skills/specs/references/ask-user-question-gates.md +0 -70
  64. package/src/claude/skills/specs/references/codebase-analysis.md +0 -102
  65. package/src/claude/skills/specs/references/cross-spec-dependency.md +0 -76
  66. package/src/claude/skills/specs/references/research-strategy.md +0 -107
  67. package/src/claude/skills/specs/references/scope-inquiry.md +0 -107
  68. package/src/claude/skills/specs/references/translation-mirror.md +0 -83
  69. package/src/claude/skills/specs/rules/design-discovery-full.md +0 -45
  70. package/src/claude/skills/specs/rules/design-discovery-light.md +0 -28
  71. package/src/claude/skills/specs/rules/design-principles.md +0 -138
  72. package/src/claude/skills/specs/rules/design-review.md +0 -55
  73. package/src/claude/skills/specs/rules/ears-format.md +0 -42
  74. package/src/claude/skills/specs/rules/phase-decision-matrix.md +0 -56
  75. package/src/claude/skills/specs/rules/task-scoring-rubric.md +0 -52
  76. package/src/claude/skills/specs/rules/tasks-generation.md +0 -189
  77. package/src/opencode/AGENTS.md +0 -41
  78. package/src/opencode/plugins/docs-sync.ts +0 -175
  79. package/src/opencode/plugins/inspect-block.ts +0 -164
  80. package/src/opencode/plugins/privacy-block.ts +0 -182
  81. package/src/opencode/plugins/rules.ts +0 -155
  82. package/src/opencode/plugins/session.ts +0 -179
  83. package/src/opencode/plugins/spec-gate.ts +0 -457
  84. package/src/opencode/plugins/spec-state.ts +0 -311
  85. package/src/opencode/plugins/state.ts +0 -253
  86. package/src/opencode/plugins/task-scaffold-guard.ts +0 -161
  87. package/src/opencode/plugins/usage.ts +0 -178
@@ -1,187 +1,151 @@
1
1
  ---
2
2
  name: hapo:develop
3
- description: "Implement an explicitly invoked ready or low-risk change with policy-proportional evidence and one closeout owner."
3
+ description: "Implement an explicitly requested process-first feature or task, run its real verification, and close it with one evidence owner. Also supports existing legacy Specs packets."
4
4
  user-invocable: true
5
- when_to_use: "Use to implement a ready spec, a specific task, or a Direct low-risk change."
5
+ when_to_use: "Use to implement a ready feature packet, one named task, or a clear low-risk change."
6
6
  category: utilities
7
7
  keywords: [implementation, specs, verification]
8
8
  argument-hint: "[feature-name|specs-directory-path] [task-file] [--flash] [--parallel [N]] [--notes]"
9
9
  metadata:
10
10
  author: haposoft
11
- version: "1.0.0"
11
+ version: "3.0.0"
12
12
  ---
13
- # Develop — implementation and closeout contract
13
+ # Develop — implement, prove, synchronize
14
14
 
15
- Implement the requested scope, then close it with one canonical execution owner.
16
- For a durable spec, `spec.json` is machine authority and Markdown is a human
17
- projection. The v2.1 policy snapshot persists minimum input; lane, label,
18
- artifact profile, and ceremony are derived views. The executable policy source
19
- is `src/claude/scripts/workflow-policy.cjs` (installed as
20
- `.claude/scripts/workflow-policy.cjs`).
15
+ Implement only the explicitly requested scope. For a process-first feature,
16
+ `plan.md` and flat tasks are the durable packet; one closeout owner coordinates verification, review, sync, and docs impact without borrowing evidence.
17
+
18
+ Develop never starts merely because Specs finished. The user invokes it.
21
19
 
22
20
  ## Usage and pre-state guard
23
21
 
24
22
  ```text
25
23
  /hapo:develop <feature>
26
24
  /hapo:develop specs/<feature>
27
- /hapo:develop <feature> <specific-task-file.md>
25
+ /hapo:develop <feature> task-02-<slug>.md
28
26
  /hapo:develop <feature> --flash
29
27
  /hapo:develop <feature> --parallel [N]
30
28
  /hapo:develop <feature> --notes
31
29
  ```
32
30
 
33
- `--notes` is opt-in. Without it, do not create or update `implementation-notes.html`; there is no notes opt-out flag. When requested, load `references/implementation-notes-template.html` and record concrete decisions, gaps, scope-escape exceptions, risks, and verification caveats.
31
+ `--notes` is opt-in. Only then load `references/implementation-notes-template.html`;
32
+ record decisions, scope exceptions, risks, gaps, and verification limits. Never create it by default.
34
33
 
35
- Run the policy pre-state guard before loading a spec or mutating state. The incompatible pair must exit `2` and create no state, receipt, worktree, subagent, or commit: this is the `flash+parallel fail-fast` gate.
34
+ Before any state mutation, reject `--flash` combined with `--parallel`:
36
35
 
37
36
  ```bash
38
37
  node .claude/scripts/workflow-policy.cjs --flash --parallel --json
39
38
  ```
40
39
 
41
- Expected message:
42
-
43
- ```text
44
- Unsupported flags: --flash and --parallel are incompatible.
45
- Remediation: run `/hapo:develop <feature> --flash` or `/hapo:develop <feature> --parallel [N]`.
46
- No spec state, task receipt, worktree, subagent, or commit was created.
47
- ```
48
-
49
- ## Policy authority
50
-
51
- For durable specs, persisted `workflow_policy` authority is the v2.1 minimum.
52
- Canonical authoring supplies `planning_depth`, `assurance_level`,
53
- `classified_minimum`, and normalized `risks`; lane and ceremony remain derived
54
- views.
55
-
56
- Classify before spec/state mutation:
57
-
58
- ```bash
59
- node .claude/scripts/workflow-policy.cjs --classify-lane --task-json '<task JSON>' --json
60
- ```
61
-
62
- - **Direct**: clear, isolated, reversible, low-risk. Skip spec/state/registry ceremony and run targeted verification with proportional evidence.
63
- - **Standard**: use the bounded spec profile and focused inspection. A small feature needs no task registry/bundle and closes once at the feature boundary.
64
- - **Critical**: derived Strict view. Add durable task state, research, or review
65
- only when actual topology, uncertainty, or assurance requires it.
40
+ The pair exits `2` before a task edit, receipt, worktree, subagent, or commit. Do not reproduce it with a looser parser.
66
41
 
67
- Risk can raise the classified minimum. Reclassify before persistence. After
68
- persistence, a per-feature baseline is monotonic and no downgrade is supported
69
- until a trusted issuer exists; the baseline applies only to that feature.
70
- Legacy approval fields and caller booleans have zero authority.
42
+ ## Resolve the work packet
71
43
 
72
- Develop starts only from the user's explicit Develop invocation. Technical
73
- `ready_for_implementation` never dispatches Develop, and Specs must never
74
- auto-chain into this workflow.
44
+ 1. Resolve one `specs/<feature>/plan.md` plus flat `task-NN-*.md`; an explicit task path wins.
45
+ 2. Read C1 scope, exclusions, acceptance mapping, ownership, and task order.
46
+ 3. A task is unblocked only when every named dependency is done with a valid inline Receipt.
47
+ 4. Full-feature mode selects one unblocked task at a time, in plan order.
48
+ Specific-task mode implements only that task and then stops.
49
+ 5. Without a packet, work directly only when the change is clear, isolated, reversible, and low-risk.
75
50
 
76
- `execution_tier` (`Light | Standard | Deep`) is a read-only legacy adapter (`Direct | Standard | Critical`). It cannot emit policy, create obligations, select a workflow, or override the lane. Do not branch on it for new behavior.
51
+ Ambiguity, overlapping ownership, a dependency cycle, or a missing Verification Plan is a blocker. Do not guess.
77
52
 
78
53
  ## Modes
79
54
 
80
- ### Specific task
55
+ ### Sequential feature or specific task
81
56
 
82
- Load exactly one task packet, implement only its scope, run its evidence, and stop after synchronization. Specific-task mode never selects or chains into another pending task.
57
+ Set the selected task's single `Status:` field to `in_progress`. Implement its
58
+ Outcome and Acceptance only. Do not start the next task until proof, review,
59
+ and sync for the current task finish. A specific-task invocation never chains.
83
60
 
84
- ### Full feature
61
+ ### Parallel (`--parallel [N]`)
85
62
 
86
- For a task-bearing policy, resolve one unblocked task at a time, complete its cycle, synchronize, and recompute the queue. A bounded Standard feature without tasks runs one feature-level cycle. Stop on the first unresolved block or missing proof; run final integration only after all pending tasks finish.
63
+ Load `references/parallel-waves.md`. Require disjoint writes, satisfied dependencies,
64
+ isolated worktrees, a bounded wave, and one controller writer; otherwise work sequentially.
87
65
 
88
- ### Parallel (opt-in)
66
+ ### Flash (`--flash`)
89
67
 
90
- Load `references/parallel-waves.md` only with `--parallel`. It may use isolated worktrees and a bounded wave, but lane obligations, single-writer rules, immutable provenance, and final integration remain in force. Otherwise process one unblocked task at a time.
68
+ Flash is an explicit speed trade-off, never completion:
91
69
 
92
- ### 3. Flash Mode (`--flash`)
93
- Flash is an explicit speed trade-off, not a completion shortcut:
94
-
95
- - skip dedicated test suites, full task evidence execution, and extended manual
96
- checks;
97
- - run only a cheap available syntax/typecheck/compile preflight;
98
- - never weaken or delete tests;
99
- - synchronize only as `in_progress` with `FLASH_UNVERIFIED`,
100
- `dependencyBlocked: true`, `unblocks: false`, and blocker
70
+ - run only an available cheap syntax, typecheck, or compile preflight;
71
+ - skip dedicated tests, extended manual checks, and review retry loops;
72
+ - keep `Status: in_progress` and record `FLASH_UNVERIFIED` plus blocker
101
73
  `awaiting /hapo:test <feature>`;
102
- - never claim `Test PASS`, `Evidence PASS`, `Auto-Approved`, or
103
- `production-ready`.
74
+ - do not unblock dependents or report Test PASS, Evidence PASS,
75
+ production-ready, or done;
76
+ - promotion later requires a fresh canonical PASS receipt through the trusted
77
+ sync-finalize path.
104
78
 
105
- Only trusted sync-finalize may promote a current `FLASH_UNVERIFIED` task with explicit `--verdict PASS` and canonical proof; caller promotion fields are ignored/rejected, and marker-only proof never promotes. Stored state remains `in_progress`/`FLASH_UNVERIFIED`, dependency-blocked with a concrete blocker, omits promotion fields, and binds proof to expected Base/Head anchors.
106
- ## Workflow
107
- `Classify lane → load lane artifacts → scout obligations → implement current
108
- scope → one closeout owner → test receipt → review → docs-impact sync.`
79
+ Never weaken, delete, or rewrite tests to make Flash look complete.
109
80
 
110
- ### Step 1 — Load and scope
81
+ ## Task cycle
111
82
 
112
- - Direct does not create a spec, state, registry, task bundle, or notes file.
113
- - Standard requires its bounded validated artifacts, but not a
114
- registry when the scope is small and no task obligation is persisted.
115
- - Critical requires only the artifacts named by its snapshot obligations.
116
- - For task-bearing work, load one requested task or one unblocked task and
117
- extract the exact seven v2.1 sections: `Outcome`, `Scope`, `Anchors and Ownership`,
118
- `Changes`, `Acceptance`, `Dependencies`, and `Verification Plan`.
119
- Use typed `coordination.boundaries` for ownership/DAG/proof/parallel authority.
120
- - Before implementation, transition `pending` to `in_progress` in task Markdown `**Status:**` and `spec.json.task_registry[path]` with synchronized timestamps. Never write execution proof into the task plan.
121
- - A spec-ready execution-evidence or independent-audit slot may be `PENDING`
122
- before implementation; pending is not proof and cannot close the feature.
83
+ ### 1. Scout
123
84
 
124
- ### Step 2 — Scout
85
+ Trace entrypoints, callers, dependents, registration, errors, and owned files.
86
+ Compilation does not prove an unmounted UI, unregistered route, uncalled service, or missing consumer.
125
87
 
126
- Scout depth follows assurance, risk, and blast radius. Identify real
127
- entrypoints/callers, integration points, dependents, reachability risks, and
128
- safe scope. File count is not review depth; stop if a runtime entrypoint cannot
129
- be grounded.
88
+ ### 2. Implement
130
89
 
131
- ### Step 3 — Implement
90
+ Honor Scope, Ownership, Acceptance, and Dependencies. Do not silently replace named contracts;
91
+ scope expansion requires evidence and a return to C1, not implementation convenience.
132
92
 
133
- Implement only the scoped behavior and named contracts. Do not silently replace
134
- frameworks, auth, transport, storage, or runtime boundaries. Do not mark a
135
- runtime-facing file complete while it is orphaned, unmounted, unregistered, or
136
- uncalled. A specific-task request ends after that task; no automatic chain.
93
+ ### 3. Verify and review once
137
94
 
138
- <SCOPE-FIDELITY>
139
- The `scope_lock`, requirements, design contracts, and active task are
140
- the implementation contract. Scope escape requires a concrete reachability or
141
- compile reason and must not deliver a later task early.
142
- </SCOPE-FIDELITY>
95
+ The test owner executes the exact Verification Plan and records real output.
96
+ The review owner, when risk or repository policy requires review, evaluates
97
+ correctness, security, scope, and reachability but does not manufacture proof.
98
+ Use `PASS | PASS_WITH_WARNINGS | FAIL | BLOCKED`; only literal PASS can close.
143
99
 
144
- ### Step 4 — Closeout owner
100
+ Load `references/quality-gate.md` for the closeout contract. Remediate an
101
+ observed failure, then rerun only affected proof and review. Do not blind-retry
102
+ a blocked environment. After three failed repair rounds, stop and ask the user.
145
103
 
146
- The controller assigns exactly one closeout owner for the current task or feature. It invokes testing once, then review once when required; no phase re-runs either as a hidden gate.
104
+ ### 4. Write the inline Receipt and sync
147
105
 
148
- - For task-bearing work, the test owner executes the Verification Plan and writes the canonical execution receipt to `receipts/<task-basename>.md` only after real execution.
149
- - The review owner evaluates correctness, security, and spec compliance; it
150
- consumes existing proof but never creates or claims execution proof.
151
- - Review depth follows `assurance_level`, risk, and blast radius. Lane is only
152
- a derived view, and depth does not follow the
153
- number of files changed.
154
- - Finding count never selects review depth or overrides missing execution proof.
155
- - Use the shared adapter surface: `PASS | PASS_WITH_WARNINGS | FAIL | BLOCKED`.
156
- Warnings do not waive missing proof; `FAIL` is remediable and `BLOCKED` stops.
106
+ After a real pass, append or replace the task's final `## Receipt` with:
157
107
 
158
- Load `references/quality-gate.md` for the exact closeout contract. It has no
159
- fixed Light/Standard/Deep agent sequence.
108
+ - `Verification: PASS`;
109
+ - the exact `Command:` and `Exit: 0`;
110
+ - runtime-derived `Base:` and `Head:`;
111
+ - a non-empty fenced block containing current command output;
112
+ - required negative, reachability, and artifact proof from the task.
160
113
 
161
- ### Step 5 — Sync and docs checkpoint
114
+ Then set `Status: done`, update only implemented checkboxes, and recompute the
115
+ queue. Missing, stale, contradictory, zero-test, placeholder, or marker-only
116
+ proof leaves the task unfinished.
162
117
 
163
- Only a canonical receipt with task identity/path, exact command/result, expected versus observed behavior, bound provenance, applicable negative/reachability proof, and required artifact hashes can close a task. Prefer `receipts/<task-basename>.md`; legacy task `## Evidence` is read-compatible, but conflicting proof identities fail closed. Missing, pending, marker-only, or contradictory evidence stays unfinished. Critical audits need distinct session IDs, expected Base/Head binding, concrete evidence, and literal `verdict: "PASS"`; `Audit: PASS` is not evidence.
164
- After verification, synchronize status/timestamps/task state. Then evaluate
165
- actual docs impact:
118
+ ### 5. Finish the requested boundary
166
119
 
167
- - `none`: record it and stop;
168
- - `minor`/`major`: update only affected existing docs through the normal docs
169
- workflow, with no broad refresh.
120
+ Specific-task mode stops after its sync. Full-feature mode continues one task
121
+ at a time, then runs the feature-level integration command and reachability
122
+ check named by the repository or plan. Show current evidence and limitations at
123
+ C3; the user decides completion.
170
124
 
171
- Do not run a docs checkpoint merely because a task finished.
125
+ Evaluate docs impact from the behavior actually changed:
172
126
 
173
- ## Definition of done and handoff
127
+ - `none`: report it and make no docs edit;
128
+ - `minor` or `major`: update only affected existing docs through the docs flow.
174
129
 
175
- Done requires active criteria, all required evidence, reachable runtime behavior,
176
- a receipt bound to expected Base/Head, and every lane obligation. Only literal
177
- `PASS` can complete; `PASS_WITH_WARNINGS` remains unfinished.
178
- `--flash` records only `FLASH_UNVERIFIED` and never done.
130
+ ## Definition of done
179
131
 
180
- For a full feature, after the last task run the **Final Integration Scout** for runtime-facing surfaces and compare reachability/scope before completion. The same test owner creates `feature-receipt.md` exactly once from final integration proof. Task-bearing closeout requires every task receipt plus that feature receipt; taskless Compact/Full creates only the feature receipt at closeout. Its earlier absence is normal. A specific task stops after synchronization and creates no feature receipt unless it also completes the full integration boundary.
132
+ Done requires satisfied acceptance, reachable behavior, current executable
133
+ proof, correct Base/Head binding, resolved blocking review findings, and no
134
+ scope substitution. `PASS_WITH_WARNINGS`, `NO_TESTS`, `FLASH_UNVERIFIED`, or a
135
+ review-only pass cannot close work.
181
136
 
182
137
  ## Attached references
183
138
 
184
- - `references/quality-gate.md` — closeout ownership, verdict normalization, and
185
- evidence checks.
186
- - `references/parallel-waves.md` — opt-in worktree waves.
187
- - `references/implementation-notes-template.html` — loaded only with `--notes`.
139
+ - `references/quality-gate.md` — proof and review ownership.
140
+ - `references/parallel-waves.md` — opt-in isolated worktree waves.
141
+ - `references/implementation-notes-template.html` — only with `--notes`.
142
+
143
+ ## Legacy workflow compatibility
144
+
145
+ If the selected feature contains `spec.json`, use its persisted
146
+ `workflow_policy`, `task_registry`, nested task paths, typed boundaries,
147
+ separate task receipts, and feature closeout receipt exactly as the legacy
148
+ adapters require. Preserve `planning_depth`, `assurance_level`, derived lane,
149
+ and read-only `execution_tier`; do not project these fields into a new v3
150
+ packet. Keep JSON and Markdown status synchronized, and use the existing
151
+ completion-authority path for final closeout.
@@ -1,194 +1,107 @@
1
- # Parallel Waves — hapo:develop `--parallel` operating procedure
2
-
3
- Normative protocol for executing independent spec tasks concurrently. Loaded by
4
- `develop/SKILL.md` when Full-Spec mode runs with `--parallel [N]`. Verified against
5
- live worktree-subagent behavior (spec `develop-parallel-wave`,
6
- `reports/worktree-spike.md`, 2026-07-19).
7
-
8
- ## 1. Preconditions (check before anything else)
9
-
10
- 1. `.claude/runtime.json` → `develop.parallel` is not `false` (escape hatch; missing
11
- key = allowed). If `false`: refuse `--parallel`, tell the user the hatch is active
12
- and which key controls it, then run the standard sequential loop.
13
- 2. The work context is a git repository and worktree isolation is available.
14
- Otherwise: state the reason ("not a git repo" / "isolation unavailable") and run
15
- the standard **sequential fallback**.
16
- 3. `--parallel N`: **wave cap** = N clamped to 1..5; default 3. Never exceed 5 —
17
- each subagent carries a ~200K context budget (orchestrator.md resource rule).
18
- 4. The destination tree must be clean (`git status --porcelain` is empty) and
19
- compatible with the selected base before dispatch. Record the destination
20
- `base_sha` and stop without mutation when cleanliness, repository, or base
21
- compatibility checks fail.
22
- 5. Before dispatch, state whether `--parallel` consent authorizes worker commits
23
- and orchestrator cherry-picks. If that consent is not explicit, obtain the
24
- separate confirmation before creating worktrees or asking workers to commit.
25
-
26
- ### Receipt contract (required per wave/task)
27
-
28
- Every task and wave receipt records these exact fields:
1
+ # Parallel waves — `hapo:develop --parallel`
2
+
3
+ Load this reference only for explicit parallel execution. The goal is bounded
4
+ concurrency with immutable provenance and one state writer.
5
+
6
+ ## Preconditions
7
+
8
+ 1. Confirm the work context is a Git repository and worktree isolation is
9
+ available. Otherwise state why and fall back to the sequential loop.
10
+ 2. Respect `.claude/runtime.json` `develop.parallel: false` when present.
11
+ 3. Clamp `--parallel N` to 1..5; default to 3.
12
+ 4. Require a clean destination and record its exact `base_sha`. Stop without
13
+ mutation if cleanliness or base compatibility fails.
14
+ 5. Confirm whether the user's parallel consent also authorizes worker commits
15
+ and controller cherry-picks before creating worktrees.
16
+
17
+ Every task receipt for a wave records:
29
18
 
30
19
  ```text
31
20
  base_sha: <destination commit before dispatch>
32
- head_sha: <latest worker/integration commit>
21
+ head_sha: <worker or integrated commit>
33
22
  branch: <worker branch>
34
- worktree_path: <retained or merged worktree path>
23
+ worktree_path: <path>
35
24
  commit_range: <base_sha>..<head_sha>
36
25
  retention: retained|released
37
26
  cleanup_authorization: pending|explicit-discard|merged-release
38
27
  ```
39
28
 
40
- Reviewer and tester commands MUST inspect `git diff <base_sha>..<head_sha>` (or
41
- `git diff --stat <base_sha>..<head_sha>`), never an ambient working-tree diff.
42
- Every fix is a new commit: advance `head_sha`, replace `commit_range`, and rerun
43
- only affected gates plus the wave integration check. A receipt without these
44
- fields is incomplete.
29
+ Test and review commands inspect `git diff <base_sha>..<head_sha>`, never an
30
+ ambient working-tree diff. A fix creates a new commit and advances Head.
45
31
 
46
- ## 2. Wave planning (normative)
47
-
48
- ```
49
- ready(t) = t.status == "pending" AND every dep in task_registry[t].dependencies
50
- has status == "done"
51
- candidates = ready tasks in task_registry order
52
- wave = first ≤cap candidates, EXCLUDING any task that conflicts with an
53
- earlier task already in the wave under the conflict graph below
54
- ```
32
+ ## Build a wave
55
33
 
56
- **Conflict graph.** A pair conflicts when either task writes the same exact file,
57
- one writes a directory another writes, or either touches a shared mutable surface:
58
- lockfiles, manifests/export barrels, migrations/registries, generated artifacts,
59
- or shared state writers. `Create`/`Modify`/`Delete` rows are writers; `Read` rows
60
- are still conflicts when they consume a mutable generated or registry surface.
61
- Normalize paths before comparison. If overlap is uncertain, classify it as a
62
- conflict and defer the task to the sequential fallback; never guess that two
63
- writers are independent.
34
+ Read dependencies from the plan task table and each flat task's
35
+ `## Dependencies`. A candidate is ready only when all named dependencies are
36
+ done with valid Receipts.
64
37
 
65
- **Single writer per file per wave** remains absolute. Read-only tasks can still
66
- be deferred when they inspect a directory or shared generated state that a sibling
67
- writes.
38
+ Add ready tasks in plan order up to the cap, excluding a task when it shares a
39
+ write target with an earlier task or touches the same mutable registry,
40
+ lockfile, manifest, generated output, migration, or export barrel. Normalize
41
+ paths. Uncertain overlap is a conflict, not an invitation to guess.
68
42
 
69
- If the wave is empty but pending tasks remain, dependencies or conflicts are
70
- unsatisfiable in parallel — finish them with the sequential loop and say so.
43
+ One file has one writer per wave. If no safe wave remains, use the sequential
44
+ loop and state the dependency or ownership conflict.
71
45
 
72
- ### Worked example
46
+ ## Dispatch
73
47
 
74
- Registry: A (deps: –), B (deps: –), C (deps: A), D (deps: – but shares
75
- `src/api/users.ts` Modify with B). Cap 3.
48
+ Each worker receives the complete task packet, work context, exact owned paths,
49
+ acceptance, Verification Plan, dependencies, and these constraints:
76
50
 
77
- - Wave 1 = A, B (D excluded: path collision with B; C excluded: dep on A)
78
- - Wave 2 = C, D (A done unblocks C; B done releases D's path)
51
+ 1. Work only in the assigned isolated worktree.
52
+ 2. Do not edit `plan.md`, task Status, or `## Receipt`; the controller owns
53
+ state and evidence synchronization.
54
+ 3. Do not touch a path outside granted ownership or undo another worker's edit.
55
+ 4. Run task-local prechecks and report exact commands and exits.
56
+ 5. Commit only when the user's authorization covers worker commits.
57
+ 6. Return status plus branch, worktree, Base, Head, range, and retention.
79
58
 
80
- ## 3. Dispatch (one implementer per wave task)
59
+ A blocked or failed worker keeps its identifiable worktree and branch. Never
60
+ force-delete it without merge success or explicit discard authorization.
81
61
 
82
- Every dispatch uses worktree isolation + background execution and a
83
- self-contained prompt per `rules/orchestrator.md` (task file content, design and
84
- requirements excerpts, work-context/specs/docs paths, acceptance criteria) plus
85
- these mandatory lines:
62
+ ## Verify before integration
86
63
 
87
- 1. "You are in an isolated git worktree. Implement ONLY this task."
88
- 2. "Do NOT edit `spec.json` or any `tasks/*.md` — the orchestrator owns spec state."
89
- 3. "Write only exact targets granted by this task's `Anchors and Ownership`
90
- table and typed ownership/parallel boundaries."
91
- 4. "When done, `git add` your changes and `git commit -m \"task(<id>): <title>\"` —
92
- an uncommitted worktree cannot be merged."
93
- 5. End with the standard `Status: DONE|CONCERNS|BLOCKED|NEEDS_INFO` block, plus
94
- the receipt fields from §1, including worktree path, branch, and commit range.
95
- 6. If a worker fails or blocks, do not remove its worktree or delete its branch.
96
- Mark `retention: retained` and `cleanup_authorization: pending` until merge
97
- succeeds or the user gives explicit discard authorization.
64
+ Inside each worktree, run the task's proof through `quality-gate.md` against the
65
+ immutable commit range. A task with missing proof, overlap, or unresolved High
66
+ or Critical finding is not eligible to integrate. Three failed repair rounds
67
+ collapse only that task; siblings may finish but do not erase its blocker.
98
68
 
99
- The orchestrator records `base_sha` immediately before dispatch. The worker's
100
- first accepted commit becomes `head_sha`; no receipt may use a moving ambient
101
- HEAD as a substitute. The Agent result returns `worktreePath` and
102
- `worktreeBranch`; record both in the receipt.
69
+ ## Integrate sequentially
103
70
 
104
- ## 4. Quality gate — inside the worktree, before merge
105
-
106
- Run the unchanged Stage A + Stage B gate (`references/quality-gate.md`) per task
107
- **with the task's worktree as working directory**. Before reviewing, tester and
108
- reviewer commands must inspect the receipt's immutable range:
71
+ Apply accepted worker commits one at a time in plan order:
109
72
 
110
73
  ```bash
111
- git diff --stat "$BASE_SHA..$HEAD_SHA"
112
- git diff "$BASE_SHA..$HEAD_SHA"
74
+ git cherry-pick <worker-commit>
113
75
  ```
114
76
 
115
- Do not replace this range with `git diff`, `git status`, or another ambient
116
- working-tree view. Gate evidence from that run feeds the task receipt. Three
117
- failed rounds → COLLAPSE protocol for that task only; sibling tasks in the wave
118
- keep running. Any fix creates a new commit and updates `head_sha`/`commit_range`
119
- before affected gates rerun.
77
+ On conflict, abort the cherry-pick, mark the task blocked, and retain its
78
+ worktree/branch. After success, update the receipt range to the integrated Head.
79
+ Release a worktree only after recording `cleanup_authorization: merged-release`.
120
80
 
121
- ## 5. Merge protocol (spike-verified — do not improvise)
81
+ ## Post-merge proof
122
82
 
123
- ⚠️ Spike finding: worktree branches are based on **`origin/<default-branch>`**
124
- (`worktree.baseRef: "fresh"` default), NOT the session HEAD. On repos whose origin
125
- default diverges, `git merge <agent-branch>` explodes into unrelated conflicts.
83
+ After the wave's last integration, run an affected integration command derived
84
+ from the tasks and repository contract. Record command, exit, Base, Head,
85
+ range, and output. Failure blocks the next wave.
126
86
 
127
- Therefore, for each gate-passed task, sequentially (one at a time, registry order):
87
+ Classify a failure before acting:
128
88
 
129
- ```bash
130
- git cherry-pick <agent-commit> # base-agnostic: applies only the agent's diff
131
- # conflict? → git cherry-pick --abort
132
- # → task_registry[task].status = "blocked", blocker = one-line conflict summary
133
- # → retain the worktree/branch; receipt says retention=retained
134
- ```
89
+ - `baseline`: reproduces from the recorded Base;
90
+ - `environment`: required tool, service, permission, or dependency unavailable;
91
+ - `spec`: acceptance or evidence contract is wrong or incomplete;
92
+ - `code`: implementation or integration regression.
135
93
 
136
- A successful merge may release the worktree and branch only after the receipt
137
- records `head_sha` at the merge result, the new `commit_range`, and
138
- `cleanup_authorization: merged-release`:
94
+ Do not blind-retry. Fix code/spec with a new commit and rerun affected proof;
95
+ record baseline/environment as blockers.
139
96
 
140
- ```bash
141
- git worktree remove .claude/worktrees/agent-<id>
142
- git branch -d worktree-agent-<id>
143
- ```
97
+ After the final wave, run the feature-level integration and reachability proof.
98
+ The controller then writes inline Receipts and Status updates one task at a
99
+ time. Worker reports are evidence inputs, not permission to claim done.
100
+
101
+ ## Legacy workflow compatibility
144
102
 
145
- Never use `--force` cleanup for failed or blocked work. Retain its identifiable
146
- worktree and branch for inspect/resume until the merge succeeds or the user
147
- explicitly authorizes discard; record `cleanup_authorization: explicit-discard`
148
- when that happens. Optionally set `worktree.baseRef: "head"` in settings;
149
- cherry-pick remains the recipe regardless.
150
-
151
- ## 6. Post-merge integration check (per wave)
152
-
153
- After the wave's last cherry-pick, run an affected integration command derived
154
- from the task's `Verification Plan` and repository contract (build or affected test
155
- subset; never the full suite mid-flight). Record command, `base_sha`, `head_sha`,
156
- range, and result in the wave receipt. Failure blocks the next wave.
157
-
158
- After the final wave, run an explicit feature/full integration command derived
159
- from the repository contract — for example the feature's exact verification suite
160
- or the repository's documented full test/build command. A final scout is not a
161
- substitute. On PASS, the test owner creates `feature-receipt.md` once; task
162
- receipts alone cannot close the feature. Classify every failure before acting as exactly one of:
163
-
164
- - `baseline` — reproduces from the recorded destination `base_sha`;
165
- - `environment` — tool, dependency, permission, or service unavailable;
166
- - `spec` — requirement, acceptance, or evidence contract mismatch;
167
- - `code` — implementation or integration regression.
168
-
169
- Do not blind-retry. Fix `code`/`spec` failures with a new commit and affected
170
- gates; record `baseline`/`environment` blockers and escalate or use the
171
- sequential fallback according to the task contract.
172
-
173
- ## 7. State sync — orchestrator is the single writer
174
-
175
- Only the orchestrator writes `spec.json` and task markdown, after each task's
176
- cherry-pick: registry `status`/`completed_at`/`last_updated_at`, task-md `Status`,
177
- checkbox ticks, and a canonical `receipts/<task-basename>.md` citing the
178
- worktree gate evidence plus the post-merge check result. Never append execution
179
- proof to task Markdown. The Stop completion gate (`spec-gate.cjs`) applies
180
- unchanged — a receipt-less done blocks the turn. After syncing the wave, recompute
181
- §2 and continue until no pending tasks remain.
182
-
183
- ## 8. Failure summary
184
-
185
- | Event | Action |
186
- |---|---|
187
- | Escape hatch on / not a git repo / no isolation | Sequential fallback + stated reason |
188
- | Same-wave path collision | Defer the later task to next wave (§2) |
189
- | Gate fails 3× for a task | COLLAPSE for that task; retain worktree/branch and receipt; wave continues |
190
- | Worker failure or blocked task | Retain identifiable worktree/branch; no force-remove; classify and await resume or explicit discard |
191
- | Cherry-pick conflict | Abort pick; task `blocked` + conflict blocker; retain worktree/branch; wave continues |
192
- | Post-merge check fails | Classify baseline/environment/spec/code; no next wave until resolved or explicitly blocked |
193
- | Final integration fails | Record failure class and stop; do not claim completion from a final scout |
194
- | Empty wave, tasks pending | Sequential loop for the remainder + notice |
103
+ For an existing `spec.json` feature, readiness and dependencies come from the
104
+ persisted `task_registry` and typed `coordination.boundaries`. Workers still do
105
+ not edit that state. The controller writes the legacy separate task receipt,
106
+ synchronizes registry plus nested task Markdown, and creates the required final
107
+ feature receipt only after integrated proof.