@haposoft/cafekit 0.15.3 → 0.16.0-rc.2
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.
- package/README.md +4 -2
- package/bin/__tests__/codex-hooks.test.js +140 -0
- package/bin/__tests__/codex-native.test.js +2 -2
- package/bin/__tests__/develop-contract.test.js +1120 -0
- package/bin/__tests__/installer-safety.test.js +510 -2
- package/bin/__tests__/package-inventory.test.js +258 -0
- package/bin/__tests__/secret-scanner.test.js +157 -0
- package/bin/__tests__/validator-grounding.test.js +713 -0
- package/bin/install.js +5 -1
- package/bin/lib/codex-install.js +21 -6
- package/bin/lib/context.js +17 -6
- package/bin/lib/copy-utils.js +31 -0
- package/bin/lib/instruction-blocks.js +85 -0
- package/bin/lib/managed-writer.js +4 -1
- package/bin/lib/opencode-install.js +75 -30
- package/bin/phases/claude-runtime.js +103 -4
- package/bin/phases/codex-runtime.js +9 -5
- package/bin/phases/post-install.js +29 -22
- package/bin/phases/root-config.js +89 -10
- package/package.json +14 -4
- package/src/claude/CLAUDE.md +6 -122
- package/src/claude/agents/code-auditor.md +28 -22
- package/src/claude/agents/debugger.md +3 -3
- package/src/claude/agents/deployer.md +1 -1
- package/src/claude/agents/{god-developer.md → implementer.md} +2 -2
- package/src/claude/agents/project-manager.md +1 -1
- package/src/claude/agents/spec-maker.md +2 -2
- package/src/claude/hooks/__tests__/spec-gate.test.js +356 -5
- package/src/claude/hooks/agent.cjs +7 -14
- package/src/claude/hooks/rules.cjs +33 -53
- package/src/claude/hooks/spec-gate.cjs +66 -21
- package/src/claude/hooks/spec-state.cjs +5 -0
- package/src/claude/migration-manifest.json +9 -2
- package/src/claude/runtime.json +0 -3
- package/src/claude/scripts/generate-skill-catalog.cjs +1 -1
- package/src/claude/scripts/scan-staged-secrets.cjs +170 -0
- package/src/claude/scripts/spec-ground.cjs +189 -83
- package/src/claude/scripts/validate-spec-output.cjs +294 -30
- package/src/claude/scripts/workflow-policy.cjs +609 -0
- package/src/claude/skills/ai-multimodal/SKILL.md +2 -2
- package/src/claude/skills/ai-multimodal/references/audio-processing.md +6 -6
- package/src/claude/skills/ai-multimodal/references/video-analysis.md +1 -1
- package/src/claude/skills/backend-development/SKILL.md +4 -4
- package/src/claude/skills/backend-development/references/backend-architecture.md +1 -1
- package/src/claude/skills/backend-development/references/backend-devops.md +2 -2
- package/src/claude/skills/backend-development/references/backend-mindset.md +3 -3
- package/src/claude/skills/backend-development/references/backend-performance.md +5 -5
- package/src/claude/skills/backend-development/references/backend-security.md +55 -3
- package/src/claude/skills/backend-development/references/backend-technologies.md +5 -5
- package/src/claude/skills/backend-development/references/backend-testing.md +2 -2
- package/src/claude/skills/brainstorm/SKILL.md +2 -3
- package/src/claude/skills/code-review/SKILL.md +12 -8
- package/src/claude/skills/code-review/references/verification-gate.md +4 -4
- package/src/claude/skills/debug/SKILL.md +2 -0
- package/src/claude/skills/develop/SKILL.md +100 -52
- package/src/claude/skills/develop/references/parallel-waves.md +105 -26
- package/src/claude/skills/develop/references/quality-gate.md +78 -38
- package/src/claude/skills/develop/references/subagent-patterns.md +2 -2
- package/src/claude/skills/git/SKILL.md +44 -50
- package/src/claude/skills/hotfix/SKILL.md +10 -8
- package/src/claude/skills/hotfix/references/parallel-patterns.md +2 -2
- package/src/claude/skills/hotfix/references/review-cycle.md +26 -21
- package/src/claude/skills/inspect/SKILL.md +12 -30
- package/src/claude/skills/mobile-development/SKILL.md +12 -12
- package/src/claude/skills/mobile-development/references/mobile-android.md +7 -7
- package/src/claude/skills/mobile-development/references/mobile-best-practices.md +22 -23
- package/src/claude/skills/mobile-development/references/mobile-frameworks.md +13 -13
- package/src/claude/skills/mobile-development/references/mobile-ios.md +1 -1
- package/src/claude/skills/mobile-development/references/mobile-mindset.md +17 -19
- package/src/claude/skills/question/SKILL.md +13 -13
- package/src/claude/skills/research/SKILL.md +2 -2
- package/src/claude/skills/specs/SKILL.md +32 -15
- package/src/claude/skills/specs/references/review.md +3 -3
- package/src/claude/skills/specs/rules/tasks-generation.md +1 -1
- package/src/claude/skills/specs/templates/spec-state.json +7 -3
- package/src/claude/skills/sync/SKILL.md +26 -1
- package/src/claude/skills/sync/references/sync-protocols.md +3 -3
- package/src/claude/skills/test/SKILL.md +12 -4
- package/src/claude/skills/test/references/failure-triage.md +17 -17
- package/src/claude/skills/test/references/test-memory.md +2 -2
- package/src/codex/AGENTS.md +16 -24
- package/src/codex/hooks/lib/spec-receipt.cjs +57 -4
- package/src/codex/hooks/rules.cjs +27 -26
- package/src/codex/hooks/spec-gate.cjs +19 -8
- package/src/codex/hooks/spec-state.cjs +10 -1
- package/src/common/AGENTS.md +43 -0
- package/src/opencode/AGENTS.md +21 -121
- package/src/opencode/plugins/rules.ts +26 -34
- package/src/opencode/plugins/spec-gate.ts +283 -0
- package/src/claude/skills/inspect/references/external-gemini-inspection.md +0 -169
|
@@ -16,6 +16,8 @@ Reads the project specification (`hapo:specs`) and implements code through a dis
|
|
|
16
16
|
|
|
17
17
|
**Principles:** YAGNI, KISS, DRY | Continuous execution | Smart self-healing
|
|
18
18
|
|
|
19
|
+
**Executable policy source:** `src/claude/scripts/workflow-policy.cjs` defines Direct/Standard/Critical lane classification, lane delegation, approval-state semantics, mode conflict fail-fast, legacy Light/Standard/Deep delegation, review verdict handling, and flash promotion. Installed Claude runtime uses `.claude/scripts/workflow-policy.cjs`; contracts below must match it.
|
|
20
|
+
|
|
19
21
|
## Usage
|
|
20
22
|
|
|
21
23
|
```bash
|
|
@@ -27,7 +29,52 @@ Reads the project specification (`hapo:specs`) and implements code through a dis
|
|
|
27
29
|
/hapo:develop <feature name> --no-notes
|
|
28
30
|
```
|
|
29
31
|
|
|
30
|
-
##
|
|
32
|
+
## Mode Matrix
|
|
33
|
+
|
|
34
|
+
| Mode | Scout | Quality gate | Receipt | Notes |
|
|
35
|
+
|---|---|---|---|---|
|
|
36
|
+
| default (specific-task / full-spec) | per tier | full (Step 4) | verified | |
|
|
37
|
+
| `--flash` | per tier | Flash Gate (4F) | `FLASH_UNVERIFIED` | |
|
|
38
|
+
| `--parallel` | inspector per task (Critical) | full, inside each worktree | verified | implies Critical lane (legacy Deep) |
|
|
39
|
+
| `--flash --parallel` | **flash+parallel fail-fast — no execution** | | | reject before state/worktree changes |
|
|
40
|
+
| `--no-notes` | — | — | — | composable with all modes |
|
|
41
|
+
|
|
42
|
+
## Argument validation
|
|
43
|
+
|
|
44
|
+
Run policy pre-state guard before loading spec files or mutating state. For the incompatible flag pair, the command must exit nonzero and write no state, receipt, worktree, subagent, or commit:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
node .claude/scripts/workflow-policy.cjs --flash --parallel --json
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Expected JSON contract: `{"ok":false,"contract":"execution-policy","failFast":true,...}` with exit code `2`. If both `--flash` and `--parallel` are present, print:
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
Unsupported flags: --flash and --parallel are incompatible.
|
|
54
|
+
Remediation: run `/hapo:develop <feature> --flash` or `/hapo:develop <feature> --parallel [N]`.
|
|
55
|
+
No spec state, task receipt, worktree, subagent, or commit was created.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Then STOP with no execution. Never silently drop `--flash`, prefer `--parallel`, or start a more expensive workflow.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
## Lane selection before spec gate
|
|
62
|
+
|
|
63
|
+
Run lane classification at the runtime boundary before loading spec files or mutating state. Decisions are executable, not advisory prose:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
node .claude/scripts/workflow-policy.cjs --classify-lane --task-json '<task JSON>' --json
|
|
67
|
+
# Downgrade requires explicit user authorization - model-supplied downgrade is blocked
|
|
68
|
+
node .claude/scripts/workflow-policy.cjs --classify-lane --task-json '{"riskSignals":{"auth":true},"override":"Direct","userAuthorized":true}' --json
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
- **Direct** — clear, isolated, reversible, low-risk work. May skip spec/state/subagents and full task/spec/registry ceremony; execute targeted test, diff self-check, and proportional evidence only.
|
|
72
|
+
- **Standard** — default. Use one bounded spec artifact (`requirements.md` + `design.md` in current layout), one canonical receipt, and exactly one combined `code-auditor` review at feature ship point (not per-task).
|
|
73
|
+
- **Critical** — destructive/irreversible, auth/payment/privacy/data, schema/migration, public contract, cross-runtime coupling, outcome-changing ambiguity, or difficult rollback. Use strict durable state and evidence with risk-driven delegation (inspector/test-runner/code-auditor enabled per risk lens), not a fixed four-agent chain.
|
|
74
|
+
|
|
75
|
+
Explicit overrides are enforced at the runtime boundary. A model-supplied lane or downgrade must not bypass risk signals. Downgrading from Critical requires explicit user-originated authorization (`userAuthorized:true` or `origin:user`) and must surface the trade-off (reduced review/evidence coverage). Keep `generated`, `agent_validated`, and `user_approved` independent; agent validation or --auto never fabricates `user_approved`.
|
|
76
|
+
|
|
77
|
+
Direct may bypass the approved-spec hard gate only for low-risk reversible work. Standard and Critical still require their lane-appropriate spec/state gate.
|
|
31
78
|
|
|
32
79
|
### 1. Specific-Task Mode
|
|
33
80
|
Triggered by `/hapo:develop <feature> <task-file>`.
|
|
@@ -46,7 +93,7 @@ Triggered by `/hapo:develop <feature>` or `/hapo:develop specs/<feature>`.
|
|
|
46
93
|
- Sync state.
|
|
47
94
|
- Recompute the queue and continue.
|
|
48
95
|
- STOP the overall run on the first blocked task, unresolved gate failure, or missing proof.
|
|
49
|
-
- In `--flash` mode, missing full test proof
|
|
96
|
+
- In `--flash` mode, missing full test proof stores the task as `status: "in_progress"` with receipt `FLASH_UNVERIFIED` and blocker `awaiting /hapo:test <feature>`. It does not unblock dependencies or mark the task done.
|
|
50
97
|
|
|
51
98
|
### 2b. Parallel Wave Mode (opt-in)
|
|
52
99
|
Triggered by adding `--parallel [N]` to Full-Spec mode. Load `references/parallel-waves.md` and follow it exactly — it is the operating procedure (wave planning, dispatch, merge, cleanup).
|
|
@@ -64,7 +111,7 @@ Contracts: WAVE_CONFIG
|
|
|
64
111
|
|
|
65
112
|
- Preconditions first: if `runtime.json` sets `develop.parallel: false`, refuse `--parallel`, name the key, and run the sequential loop. If the work context is not a git repository or worktree isolation is unavailable, state the reason and fall back sequential (see parallel-waves.md §1).
|
|
66
113
|
- Waves are computed from `task_registry.dependencies` with the single-writer-per-file rule; wave cap = N (1..5, default 3).
|
|
67
|
-
- Dispatch one `
|
|
114
|
+
- Dispatch one `implementer` per wave task — worktree isolation, background, self-contained prompt per `rules/orchestrator.md`, plus the mandatory lines in parallel-waves.md §3 (commit mandate; never edit `spec.json`/`tasks/*.md`; never touch files outside the task's `Related Files`).
|
|
68
115
|
- Quality gate (Stage A+B, unchanged) runs inside each task's worktree BEFORE merge; merge = sequential `git cherry-pick` of agent commits with explicit worktree/branch cleanup (spike-verified — see parallel-waves.md §5); post-merge integration check gates the next wave.
|
|
69
116
|
- The orchestrator is the single writer of spec state: registry/task-md/receipts update after each cherry-pick, exactly as in sequential mode.
|
|
70
117
|
- Without `--parallel`, nothing in this section applies — the sequential Full-Spec loop below is unchanged.
|
|
@@ -77,23 +124,39 @@ Triggered by adding `--flash` to either specific-task or full-spec mode.
|
|
|
77
124
|
- Skip dedicated test suites, E2E/browser/manual QA loops, full task evidence execution, and code-review retry loops.
|
|
78
125
|
- Run only cheap preflight checks when available and fast: syntax, typecheck, or build commands that do not require installing dependencies or starting external services.
|
|
79
126
|
- Never weaken, delete, or rewrite tests to avoid running them.
|
|
80
|
-
- Sync
|
|
127
|
+
- Sync the implementation as `status: "in_progress"` with receipt `FLASH_UNVERIFIED`, blocker `awaiting /hapo:test <feature>`, and no dependency unblocking. Do not claim task or feature completion.
|
|
81
128
|
- Final output MUST recommend `/hapo:test <feature>` before merge, release, or publish.
|
|
82
129
|
|
|
83
130
|
### 4. Implementation Notes
|
|
84
|
-
|
|
131
|
+
Implementation notes apply to Standard/Critical modes by default; Direct stays artifact-free unless user explicitly requests a receipt. Disable notes with `--no-notes`.
|
|
85
132
|
|
|
86
|
-
-
|
|
87
|
-
-
|
|
133
|
+
- **Standard/Critical**: maintain `specs/<feature-name>/implementation-notes.html`.
|
|
134
|
+
- **Standard/Critical**: use `references/implementation-notes-template.html` when the file does not exist.
|
|
88
135
|
- Keep the file self-contained: inline CSS, no JS, no external fonts, no network assets.
|
|
89
136
|
- Style notes as readable Claude Code-like blocks: compact cards, left accent bars, category badges, monospace file paths, and a task timeline.
|
|
90
137
|
- Record decisions and caveats while implementing, not only at the end.
|
|
91
138
|
- Do not use notes to justify scope changes that alter the approved contract. If the contract changes, stop and route back to `/hapo:specs update`.
|
|
92
139
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
140
|
+
## Delegation policy (single source for this skill)
|
|
141
|
+
|
|
142
|
+
Implement in the main session by default. Do not spawn a subagent because a step
|
|
143
|
+
mentions an agent name — spawn only per this table:
|
|
144
|
+
|
|
145
|
+
| Lane | Delegation (risk-driven) | Quality gate |
|
|
146
|
+
|---|---|---|
|
|
147
|
+
| Direct | None | Main-session targeted verification and diff self-check |
|
|
148
|
+
| Standard | Exactly one combined `code-auditor` at feature ship point (not per-task) | Feature-level ship point |
|
|
149
|
+
| Critical | Risk-driven: `inspector` when discovery needed, `test-runner` when code changes, `code-auditor` at feature closeout (not fixed four-agent per task) | Strict evidence gate |
|
|
150
|
+
|
|
151
|
+
Legacy `execution_tier` (`Light | Standard | Deep`) is retained only as backward-compatible metadata (tier = Light → Direct, Standard → Standard, Deep → Critical). When both exist, lane policy controls ceremony/delegation and tier is metadata only. Do not treat tier as authoritative.
|
|
152
|
+
|
|
153
|
+
<LANE-GATE>
|
|
154
|
+
Do not write implementation code until lane classification runs at the runtime boundary.
|
|
155
|
+
- **Direct** may bypass spec/state/registry and full task ceremony only when classifier confirms clear, isolated, reversible, low-risk work; targeted verification and evidence remain mandatory.
|
|
156
|
+
- **Standard** requires one bounded approved spec artifact (`requirements.md` + `design.md` in current layout) and canonical receipt before implementation; exactly one feature-level closeout review.
|
|
157
|
+
- **Critical** requires approved lane-appropriate spec/state plus strict evidence before implementation; delegation is risk-driven, not a fixed chain.
|
|
158
|
+
Never treat a Direct override as automatic low risk; preserve its warning, risk signals, and user authorization requirement. Model-supplied downgrades without user authorization are blocked.
|
|
159
|
+
</LANE-GATE>
|
|
97
160
|
|
|
98
161
|
<DEFINITION-OF-DONE>
|
|
99
162
|
A task is NOT done because code compiles or a placeholder renders.
|
|
@@ -111,21 +174,16 @@ The approved `scope_lock`, requirements, design contracts, and active task packe
|
|
|
111
174
|
You MUST implement all scoped behavior for the active task, MUST NOT add out-of-scope behavior, and MUST NOT mark work done while required surfaces exist only as orphaned files, unmounted UI, unregistered routes, uncalled loaders, or placeholder wiring.
|
|
112
175
|
</SCOPE-FIDELITY>
|
|
113
176
|
|
|
114
|
-
## Anti-Rationalization Protocol
|
|
115
|
-
|
|
116
|
-
| Thought (Excuse) | Reality (Rule) |
|
|
117
|
-
|-------------------|----------------|
|
|
118
|
-
| "No need to scout first" | Coding without knowing the architecture is blind. ALWAYS call the `inspector` agent to scan files. |
|
|
119
|
-
| "Review process is too tedious, let me just finish it myself" | The system needs an audit trail through agents. ALWAYS delegate via the `Agent` tool. |
|
|
120
|
-
|
|
121
177
|
## Absolute Workflow
|
|
122
178
|
|
|
123
179
|
```mermaid
|
|
124
180
|
flowchart TD
|
|
125
|
-
A["/hapo:develop \u003cfeature\u003e"] -->
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
181
|
+
A["/hapo:develop \u003cfeature\u003e"] --> L[Classify lane]
|
|
182
|
+
L -->|Direct| D[Step 3: Implement (targeted or lane-scoped)]
|
|
183
|
+
L -->|Standard/Critical| B[Step 1: Load lane spec/state]
|
|
184
|
+
B -->|Missing or not approved| Z[Stop: Run lane-appropriate /hapo:specs]
|
|
185
|
+
B -->|Ready| C[Step 2: Task-Aware Scout (per lane policy)]
|
|
186
|
+
C --> D
|
|
129
187
|
D --> E{Flash Mode?}
|
|
130
188
|
E -->|No| Q[Step 4: Quality Gate: Test + Spec Review + Code Review + Evidence]
|
|
131
189
|
E -->|Yes| R[Step 4F: Flash Gate: Minimal Preflight + Scope Sanity]
|
|
@@ -139,37 +197,29 @@ flowchart TD
|
|
|
139
197
|
```
|
|
140
198
|
|
|
141
199
|
### Step 1: Initialize & Load Spec
|
|
142
|
-
-
|
|
143
|
-
-
|
|
144
|
-
-
|
|
145
|
-
-
|
|
200
|
+
- **Direct**: after classifier confirms low-risk reversible work, skip spec/state/registry initialization and continue with targeted implementation/evidence.
|
|
201
|
+
- **Standard/Critical**: identify input and open the lane-appropriate `spec.json` plus bounded spec artifacts; require approved state before implementation.
|
|
202
|
+
- Check `ready_for_implementation` only for Standard/Critical specs. If not ready, notify user.
|
|
203
|
+
- **Standard/Critical only**: load `task_registry` and verify it matches the requested task file(s). If registry is missing or stale, route to `/hapo:sync audit <feature>` before coding.
|
|
204
|
+
- **Standard/Critical only**: unless `--no-notes` is present, initialize or update `specs/<feature-name>/implementation-notes.html`:
|
|
146
205
|
- If missing, create it from `references/implementation-notes-template.html`.
|
|
147
206
|
- Replace template placeholders for feature name, spec path, creation timestamp, and current mode.
|
|
148
207
|
- If present, preserve existing note cards and update the summary/timeline/status fields.
|
|
149
|
-
- **
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
-
|
|
153
|
-
|
|
154
|
-
- Related Files
|
|
155
|
-
- Completion Criteria
|
|
156
|
-
- `## Evidence` (legacy heading aliases still parse)
|
|
157
|
-
- Exact executable verification commands named in the task
|
|
158
|
-
- Requirement IDs referenced by the task
|
|
159
|
-
- Named technologies, frameworks, protocols, and data stores that the task/spec explicitly requires
|
|
160
|
-
- Relevant `Canonical Contracts & Invariants` from `design.md`
|
|
161
|
-
- If the task file is missing actionable completion or verification detail, STOP and route back to spec correction. Do not guess.
|
|
162
|
-
- Before coding, set the active task(s) to `in_progress` in both markdown and `spec.json.task_registry`, or route through `/hapo:sync` if the runtime expects the sync protocol.
|
|
208
|
+
- **Direct** does not create or update spec implementation notes unless user explicitly asks for a receipt.
|
|
209
|
+
- **Standard/Critical only**: load exactly one task packet for specific-task mode, or resolve one unblocked task from `task_registry` for full-spec mode.
|
|
210
|
+
- **Standard/Critical only**: extract Objective + Constraints, Related Files, Completion Criteria, Evidence commands, requirement IDs, named technologies, and canonical contracts before coding.
|
|
211
|
+
- If a Standard/Critical task file lacks actionable completion or verification detail, stop and route back to spec correction. Direct does not use this packet gate.
|
|
212
|
+
- **Standard/Critical only**: set the active task to `in_progress` in markdown and `spec.json.task_registry` before coding. Direct has no registry mutation.
|
|
163
213
|
|
|
164
214
|
### Step 2: Scout (Codebase Inspection)
|
|
165
|
-
- **
|
|
166
|
-
- The
|
|
215
|
+
- **Scout per Delegation policy** — Critical may delegate to `inspector` when risk lens requires discovery; Direct/Standard scout in the main session with the same required outputs (legacy Light/Standard/Deep tier is metadata only):
|
|
216
|
+
- The scout prompt MUST include:
|
|
167
217
|
- Active task file path and extracted task packet
|
|
168
218
|
- Requirement IDs and `scope_lock`
|
|
169
219
|
- Relevant `design.md` contracts/invariants
|
|
170
220
|
- Prior completed task outputs from `spec.json.task_registry`
|
|
171
221
|
- Related Files from the active task
|
|
172
|
-
-
|
|
222
|
+
- The scout MUST report:
|
|
173
223
|
- Real runtime entrypoints/callers affected by the task (`App.tsx`, routes, CLI command, worker registration, manifest, API consumer, etc.)
|
|
174
224
|
- Existing integration points and adjacent code patterns to follow
|
|
175
225
|
- Prior task outputs this task must consume or preserve
|
|
@@ -179,10 +229,10 @@ flowchart TD
|
|
|
179
229
|
- If the inspector cannot identify the entrypoint/caller for a runtime-facing task, STOP and route back to spec correction or ask the user. Do not guess.
|
|
180
230
|
|
|
181
231
|
### Step 3: Implement Code
|
|
182
|
-
- Act as `
|
|
232
|
+
- Act as the `implementer` per the Delegation policy (default: the main session), executing tasks specified in the loaded Markdown file(s) sequentially.
|
|
183
233
|
- **Important:** You may create and modify files directly, but must faithfully follow the design from the Spec.
|
|
184
234
|
- You MUST use the Step 2 scout report as implementation context. If code reality contradicts the task packet, stop and reconcile the spec before coding.
|
|
185
|
-
-
|
|
235
|
+
- **Standard/Critical only**: unless `--no-notes` is present, append a note card to `implementation-notes.html` whenever any of these occurs:
|
|
186
236
|
- `decision`: a necessary implementation choice not specified by the spec
|
|
187
237
|
- `spec-gap`: missing or ambiguous spec detail discovered during implementation
|
|
188
238
|
- `codebase-reality`: existing code requires a different integration path than the task implied
|
|
@@ -208,7 +258,7 @@ flowchart TD
|
|
|
208
258
|
|
|
209
259
|
### Step 4: Self-Healing (Quality Gate Auto-Fix)
|
|
210
260
|
The moment you finish coding, DO NOT proceed further. Switch to `references/quality-gate.md` and run the automatic review loop.
|
|
211
|
-
**Mantra:** Scope/spec compliance first, code quality second. All feedback from code-auditor must be addressed thoroughly:
|
|
261
|
+
**Mantra:** Scope/spec compliance first, code quality second. All feedback from code-auditor must be addressed thoroughly: PASS requires no Critical findings, no High findings, and at most one Medium.
|
|
212
262
|
|
|
213
263
|
If `--flash` is active, use **Step 4F: Flash Gate** instead of the full automatic review loop.
|
|
214
264
|
|
|
@@ -217,11 +267,9 @@ If `--flash` is active, use **Step 4F: Flash Gate** instead of the full automati
|
|
|
217
267
|
2. Spec compliance review passes: every scoped requirement and active task criterion is implemented, with no extras and no omissions
|
|
218
268
|
3. Code quality review passes
|
|
219
269
|
4. Task evidence passes (artifacts/runtime surfaces/reachability/negative-path checks from the task file are proven)
|
|
270
|
+
- Violating any Step 3 rule = FAIL.
|
|
220
271
|
- `PRECHECK_FAIL` outranks `NO_TESTS`. If compile/typecheck/build fails, the task is FAIL even when no test suite exists yet.
|
|
221
|
-
- `NO_TESTS` is NOT equivalent to PASS. If the task explicitly requires a test command or automated test proof, `NO_TESTS` is a FAIL or BLOCKED outcome until the requirement is satisfied or the spec is corrected.
|
|
222
272
|
- If build/test passes but task evidence is missing, the task is still FAIL.
|
|
223
|
-
- If runtime-facing work is orphaned, unmounted, unregistered, uncalled, or unreachable from the declared entrypoint/caller, the task is still FAIL.
|
|
224
|
-
- If the implementation silently replaced a named contract choice or relies on cross-service process-local stand-ins, the task is still FAIL.
|
|
225
273
|
- Only escalate to the user after 3 consecutive failed review rounds.
|
|
226
274
|
|
|
227
275
|
### Step 4F: Flash Gate (`--flash` only)
|
|
@@ -245,7 +293,7 @@ Flash mode is an explicit speed trade-off requested by the user.
|
|
|
245
293
|
|
|
246
294
|
### Step 5: State Sync + Task-Level Docs Sync
|
|
247
295
|
- Only after Step 4 passes may you mark task checkboxes completed and sync `spec.json` progress/timestamps/task_registry.
|
|
248
|
-
- In `--flash
|
|
296
|
+
- In `--flash`, Step 4F may record implementation closeout only as `status: "in_progress"` with `FLASH_UNVERIFIED` and blocker `awaiting /hapo:test <feature>`; it never syncs `done` or unblocks dependencies.
|
|
249
297
|
- If verification is partial or blocked by environment, keep the task in `pending` or `in_progress` and record the blocker instead of pretending completion.
|
|
250
298
|
- A completed task MUST leave behind:
|
|
251
299
|
- markdown `**Status:** done`
|
|
@@ -253,7 +301,7 @@ Flash mode is an explicit speed trade-off requested by the user.
|
|
|
253
301
|
- `completed_at` + `last_updated_at`
|
|
254
302
|
- synchronized top-level `updated_at`
|
|
255
303
|
- a human-readable verification receipt inside the task's `Evidence` section showing which commands ran, their outcomes, and what proof was observed
|
|
256
|
-
- In `--flash
|
|
304
|
+
- In `--flash`, the receipt MUST include `Mode: --flash`, `Tests: skipped by user request`, `Evidence: FLASH_UNVERIFIED`, `Status: in_progress`, `Blocker: awaiting /hapo:test <feature>`, and `Next verification: /hapo:test <feature>`.
|
|
257
305
|
- Verification receipts with `PRECHECK_FAIL`, `FAIL`, `UNVERIFIED`, or an explicit note that the implementation intentionally simplified a named contract MUST NOT be synchronized as `done`.
|
|
258
306
|
- Exception: `FLASH_UNVERIFIED` is allowed only when `--flash` is explicitly present. It records fast implementation completion, not full verification completion.
|
|
259
307
|
- Unless `--no-notes` is present, update `implementation-notes.html` before reporting the task:
|
|
@@ -267,7 +315,7 @@ Flash mode is an explicit speed trade-off requested by the user.
|
|
|
267
315
|
- If `none`: record that explicitly in the completion report and stop
|
|
268
316
|
- If `minor` or `major`: trigger `docs-keeper` to surgically update affected existing docs under `./docs`
|
|
269
317
|
- Default to **lightweight docs sync**: update only the docs touched by this task and its verified behavior; do NOT run `repomix` unless `docs-keeper` truly cannot verify the required architecture/context from the code, spec, and current docs
|
|
270
|
-
- **CWD Protocol (CRITICAL):** When spawning `docs-keeper`,
|
|
318
|
+
- **CWD Protocol (CRITICAL):** When spawning `docs-keeper`, set its Current Working Directory (CWD context) to the **Workspace Root**, not the inner package directory.
|
|
271
319
|
- Task-level docs sync happens after every verified completed task, but actual edits still depend on `Docs impact`.
|
|
272
320
|
- In **Specific-Task Mode**, STOP after sync and report the result.
|
|
273
321
|
- In **Full-Spec Mode**, only after sync may you re-read `task_registry`, pick the next unblocked pending task, and repeat from Step 1 for that task.
|
|
@@ -15,6 +15,33 @@ live worktree-subagent behavior (spec `develop-parallel-wave`,
|
|
|
15
15
|
the standard **sequential fallback**.
|
|
16
16
|
3. `--parallel N`: **wave cap** = N clamped to 1..5; default 3. Never exceed 5 —
|
|
17
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:
|
|
29
|
+
|
|
30
|
+
```text
|
|
31
|
+
base_sha: <destination commit before dispatch>
|
|
32
|
+
head_sha: <latest worker/integration commit>
|
|
33
|
+
branch: <worker branch>
|
|
34
|
+
worktree_path: <retained or merged worktree path>
|
|
35
|
+
commit_range: <base_sha>..<head_sha>
|
|
36
|
+
retention: retained|released
|
|
37
|
+
cleanup_authorization: pending|explicit-discard|merged-release
|
|
38
|
+
```
|
|
39
|
+
|
|
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.
|
|
18
45
|
|
|
19
46
|
## 2. Wave planning (normative)
|
|
20
47
|
|
|
@@ -22,14 +49,25 @@ live worktree-subagent behavior (spec `develop-parallel-wave`,
|
|
|
22
49
|
ready(t) = t.status == "pending" AND every dep in task_registry[t].dependencies
|
|
23
50
|
has status == "done"
|
|
24
51
|
candidates = ready tasks in task_registry order
|
|
25
|
-
wave = first ≤cap candidates, EXCLUDING any task that
|
|
26
|
-
|
|
27
|
-
earlier task already in the wave — the excluded task returns to the pool
|
|
52
|
+
wave = first ≤cap candidates, EXCLUDING any task that conflicts with an
|
|
53
|
+
earlier task already in the wave under the conflict graph below
|
|
28
54
|
```
|
|
29
55
|
|
|
30
|
-
**
|
|
31
|
-
|
|
32
|
-
|
|
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.
|
|
64
|
+
|
|
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.
|
|
68
|
+
|
|
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.
|
|
33
71
|
|
|
34
72
|
### Worked example
|
|
35
73
|
|
|
@@ -39,7 +77,7 @@ Registry: A (deps: –), B (deps: –), C (deps: A), D (deps: – but shares
|
|
|
39
77
|
- Wave 1 = A, B (D excluded: path collision with B; C excluded: dep on A)
|
|
40
78
|
- Wave 2 = C, D (A done unblocks C; B done releases D's path)
|
|
41
79
|
|
|
42
|
-
## 3. Dispatch (one
|
|
80
|
+
## 3. Dispatch (one implementer per wave task)
|
|
43
81
|
|
|
44
82
|
Every dispatch uses worktree isolation + background execution and a
|
|
45
83
|
self-contained prompt per `rules/orchestrator.md` (task file content, design and
|
|
@@ -52,16 +90,32 @@ these mandatory lines:
|
|
|
52
90
|
4. "When done, `git add` your changes and `git commit -m \"task(<id>): <title>\"` —
|
|
53
91
|
an uncommitted worktree cannot be merged."
|
|
54
92
|
5. End with the standard `Status: DONE|CONCERNS|BLOCKED|NEEDS_INFO` block, plus
|
|
55
|
-
|
|
93
|
+
the receipt fields from §1, including worktree path, branch, and commit range.
|
|
94
|
+
6. If a worker fails or blocks, do not remove its worktree or delete its branch.
|
|
95
|
+
Mark `retention: retained` and `cleanup_authorization: pending` until merge
|
|
96
|
+
succeeds or the user gives explicit discard authorization.
|
|
56
97
|
|
|
57
|
-
The
|
|
98
|
+
The orchestrator records `base_sha` immediately before dispatch. The worker's
|
|
99
|
+
first accepted commit becomes `head_sha`; no receipt may use a moving ambient
|
|
100
|
+
HEAD as a substitute. The Agent result returns `worktreePath` and
|
|
101
|
+
`worktreeBranch`; record both in the receipt.
|
|
58
102
|
|
|
59
103
|
## 4. Quality gate — inside the worktree, before merge
|
|
60
104
|
|
|
61
105
|
Run the unchanged Stage A + Stage B gate (`references/quality-gate.md`) per task
|
|
62
|
-
**with the task's worktree as working directory**.
|
|
63
|
-
|
|
64
|
-
|
|
106
|
+
**with the task's worktree as working directory**. Before reviewing, tester and
|
|
107
|
+
reviewer commands must inspect the receipt's immutable range:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
git diff --stat "$BASE_SHA..$HEAD_SHA"
|
|
111
|
+
git diff "$BASE_SHA..$HEAD_SHA"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Do not replace this range with `git diff`, `git status`, or another ambient
|
|
115
|
+
working-tree view. Gate evidence from that run feeds the task receipt. Three
|
|
116
|
+
failed rounds → COLLAPSE protocol for that task only; sibling tasks in the wave
|
|
117
|
+
keep running. Any fix creates a new commit and updates `head_sha`/`commit_range`
|
|
118
|
+
before affected gates rerun.
|
|
65
119
|
|
|
66
120
|
## 5. Merge protocol (spike-verified — do not improvise)
|
|
67
121
|
|
|
@@ -69,27 +123,50 @@ sibling tasks in the wave keep running.
|
|
|
69
123
|
(`worktree.baseRef: "fresh"` default), NOT the session HEAD. On repos whose origin
|
|
70
124
|
default diverges, `git merge <agent-branch>` explodes into unrelated conflicts.
|
|
71
125
|
|
|
72
|
-
Therefore, for each gate-passed task,
|
|
126
|
+
Therefore, for each gate-passed task, sequentially (one at a time, registry order):
|
|
73
127
|
|
|
74
128
|
```bash
|
|
75
129
|
git cherry-pick <agent-commit> # base-agnostic: applies only the agent's diff
|
|
76
130
|
# conflict? → git cherry-pick --abort
|
|
77
131
|
# → task_registry[task].status = "blocked", blocker = one-line conflict summary
|
|
78
|
-
# →
|
|
79
|
-
git worktree remove --force .claude/worktrees/agent-<id> # NOT auto-cleaned —
|
|
80
|
-
git branch -D worktree-agent-<id> # explicit cleanup, always
|
|
132
|
+
# → retain the worktree/branch; receipt says retention=retained
|
|
81
133
|
```
|
|
82
134
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
135
|
+
A successful merge may release the worktree and branch only after the receipt
|
|
136
|
+
records `head_sha` at the merge result, the new `commit_range`, and
|
|
137
|
+
`cleanup_authorization: merged-release`:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
git worktree remove .claude/worktrees/agent-<id>
|
|
141
|
+
git branch -d worktree-agent-<id>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Never use `--force` cleanup for failed or blocked work. Retain its identifiable
|
|
145
|
+
worktree and branch for inspect/resume until the merge succeeds or the user
|
|
146
|
+
explicitly authorizes discard; record `cleanup_authorization: explicit-discard`
|
|
147
|
+
when that happens. Optionally set `worktree.baseRef: "head"` in settings;
|
|
148
|
+
cherry-pick remains the recipe regardless.
|
|
86
149
|
|
|
87
150
|
## 6. Post-merge integration check (per wave)
|
|
88
151
|
|
|
89
|
-
After the wave's last cherry-pick
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
152
|
+
After the wave's last cherry-pick, run an affected integration command derived
|
|
153
|
+
from the task's `## Evidence` and repository contract (build or affected test
|
|
154
|
+
subset; never the full suite mid-flight). Record command, `base_sha`, `head_sha`,
|
|
155
|
+
range, and result in the wave receipt. Failure blocks the next wave.
|
|
156
|
+
|
|
157
|
+
After the final wave, run an explicit feature/full integration command derived
|
|
158
|
+
from the repository contract — for example the feature's exact Evidence suite
|
|
159
|
+
or the repository's documented full test/build command. A final scout is not a
|
|
160
|
+
substitute. Classify every failure before acting as exactly one of:
|
|
161
|
+
|
|
162
|
+
- `baseline` — reproduces from the recorded destination `base_sha`;
|
|
163
|
+
- `environment` — tool, dependency, permission, or service unavailable;
|
|
164
|
+
- `spec` — requirement, acceptance, or evidence contract mismatch;
|
|
165
|
+
- `code` — implementation or integration regression.
|
|
166
|
+
|
|
167
|
+
Do not blind-retry. Fix `code`/`spec` failures with a new commit and affected
|
|
168
|
+
gates; record `baseline`/`environment` blockers and escalate or use the
|
|
169
|
+
sequential fallback according to the task contract.
|
|
93
170
|
|
|
94
171
|
## 7. State sync — orchestrator is the single writer
|
|
95
172
|
|
|
@@ -106,7 +183,9 @@ unchanged — a receipt-less done blocks the turn. After syncing the wave, recom
|
|
|
106
183
|
|---|---|
|
|
107
184
|
| Escape hatch on / not a git repo / no isolation | Sequential fallback + stated reason |
|
|
108
185
|
| Same-wave path collision | Defer the later task to next wave (§2) |
|
|
109
|
-
| Gate fails 3× for a task | COLLAPSE for that task; wave continues |
|
|
110
|
-
|
|
|
111
|
-
|
|
|
186
|
+
| Gate fails 3× for a task | COLLAPSE for that task; retain worktree/branch and receipt; wave continues |
|
|
187
|
+
| Worker failure or blocked task | Retain identifiable worktree/branch; no force-remove; classify and await resume or explicit discard |
|
|
188
|
+
| Cherry-pick conflict | Abort pick; task `blocked` + conflict blocker; retain worktree/branch; wave continues |
|
|
189
|
+
| Post-merge check fails | Classify baseline/environment/spec/code; no next wave until resolved or explicitly blocked |
|
|
190
|
+
| Final integration fails | Record failure class and stop; do not claim completion from a final scout |
|
|
112
191
|
| Empty wave, tasks pending | Sequential loop for the remainder + notice |
|