@haposoft/cafekit 0.16.0-rc.1 → 0.16.0-rc.3
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/bin/__tests__/codex-hooks.test.js +355 -12
- package/bin/__tests__/codex-native.test.js +1 -1
- package/bin/__tests__/develop-contract.test.js +1374 -78
- package/bin/__tests__/installer-safety.test.js +43 -29
- package/bin/__tests__/opencode-spec-gate.test.js +791 -0
- package/bin/__tests__/package-inventory.test.js +157 -0
- package/bin/__tests__/validator-grounding.test.js +707 -2
- package/package.json +1 -1
- package/src/claude/agents/code-auditor.md +8 -1
- package/src/claude/agents/spec-maker.md +107 -200
- package/src/claude/hooks/__tests__/completion-authority.test.js +720 -0
- package/src/claude/hooks/__tests__/spec-gate.test.js +511 -38
- package/src/claude/hooks/completion-authority-check.cjs +307 -0
- package/src/claude/hooks/completion-authority-state.cjs +525 -0
- package/src/claude/hooks/completion-authority.cjs +148 -0
- package/src/claude/hooks/session.cjs +33 -19
- package/src/claude/hooks/spec-gate.cjs +173 -61
- package/src/claude/hooks/spec-state.cjs +104 -45
- package/src/claude/migration-manifest.json +6 -1
- package/src/claude/scripts/provenance.cjs +315 -0
- package/src/claude/scripts/spec-resolver.cjs +450 -0
- package/src/claude/scripts/spec-scaffold.cjs +716 -41
- package/src/claude/scripts/validate-spec-output.cjs +355 -53
- package/src/claude/scripts/workflow-policy.cjs +1529 -162
- package/src/claude/settings/settings.json +8 -0
- package/src/claude/skills/backend-development/references/backend-security.md +52 -0
- package/src/claude/skills/code-review/SKILL.md +85 -66
- package/src/claude/skills/develop/SKILL.md +153 -285
- package/src/claude/skills/develop/references/quality-gate.md +112 -124
- package/src/claude/skills/develop/references/subagent-patterns.md +42 -37
- package/src/claude/skills/specs/SKILL.md +170 -381
- package/src/claude/skills/specs/rules/task-scoring-rubric.md +45 -46
- package/src/claude/skills/specs/rules/tasks-generation.md +49 -20
- package/src/claude/skills/specs/templates/spec-state.json +23 -2
- package/src/claude/skills/specs/templates/task.md +20 -0
- package/src/claude/skills/sync/SKILL.md +15 -8
- package/src/claude/skills/sync/references/sync-protocols.md +4 -4
- package/src/claude/skills/test/SKILL.md +141 -167
- package/src/codex/hooks/completion-authority-check.cjs +260 -0
- package/src/codex/hooks/completion-authority-state.cjs +525 -0
- package/src/codex/hooks/completion-authority.cjs +100 -0
- package/src/codex/hooks/lib/hook-context.cjs +42 -2
- package/src/codex/hooks/lib/spec-receipt.cjs +76 -43
- package/src/codex/hooks/lib/spec-utils.cjs +53 -27
- package/src/codex/hooks/session.cjs +2 -0
- package/src/codex/hooks/spec-gate.cjs +132 -20
- package/src/codex/hooks/spec-state.cjs +56 -10
- package/src/codex/hooks.json +10 -0
- package/src/opencode/AGENTS.md +4 -2
- package/src/opencode/plugins/spec-gate.ts +296 -122
- package/src/opencode/plugins/spec-state.ts +183 -116
|
@@ -1,53 +1,41 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: hapo:develop
|
|
3
|
-
description: "
|
|
3
|
+
description: "Implement an approved or explicitly low-risk change with lane-proportional evidence and one closeout owner."
|
|
4
4
|
user-invocable: true
|
|
5
|
-
when_to_use: "
|
|
5
|
+
when_to_use: "Use to implement a ready spec, a specific task, or a Direct low-risk change."
|
|
6
6
|
category: utilities
|
|
7
|
-
keywords: [implementation, specs,
|
|
8
|
-
argument-hint: "[feature-name|specs-directory-path] [task-file] [--flash] [--parallel [N]] [--
|
|
7
|
+
keywords: [implementation, specs, verification]
|
|
8
|
+
argument-hint: "[feature-name|specs-directory-path] [task-file] [--flash] [--parallel [N]] [--notes]"
|
|
9
9
|
metadata:
|
|
10
10
|
author: haposoft
|
|
11
11
|
version: "1.0.0"
|
|
12
12
|
---
|
|
13
|
-
# Develop —
|
|
13
|
+
# Develop — implementation and closeout contract
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Implement the requested scope, then close it with one canonical execution owner. Keep the lane, not a legacy tier or fixed actor sequence, as authority.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
The executable policy source is `src/claude/scripts/workflow-policy.cjs`; the persisted workflow-policy snapshot is the contract (installed as `.claude/scripts/workflow-policy.cjs`). It owns `workflow_policy`, escalation, approvals, verdict adaptation, receipt validation, and flash promotion.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
## Usage and pre-state guard
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/hapo:develop <feature
|
|
25
|
-
/hapo:develop
|
|
26
|
-
/hapo:develop <feature
|
|
27
|
-
/hapo:develop <feature
|
|
28
|
-
/hapo:develop <feature name> <specific-task-file.md> --flash
|
|
29
|
-
/hapo:develop <feature name> --no-notes
|
|
21
|
+
```text
|
|
22
|
+
/hapo:develop <feature>
|
|
23
|
+
/hapo:develop specs/<feature>
|
|
24
|
+
/hapo:develop <feature> <specific-task-file.md>
|
|
25
|
+
/hapo:develop <feature> --flash
|
|
26
|
+
/hapo:develop <feature> --parallel [N]
|
|
27
|
+
/hapo:develop <feature> --notes
|
|
30
28
|
```
|
|
31
29
|
|
|
32
|
-
|
|
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 |
|
|
30
|
+
`--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.
|
|
41
31
|
|
|
42
|
-
|
|
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:
|
|
32
|
+
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.
|
|
45
33
|
|
|
46
34
|
```bash
|
|
47
35
|
node .claude/scripts/workflow-policy.cjs --flash --parallel --json
|
|
48
36
|
```
|
|
49
37
|
|
|
50
|
-
Expected
|
|
38
|
+
Expected message:
|
|
51
39
|
|
|
52
40
|
```text
|
|
53
41
|
Unsupported flags: --flash and --parallel are incompatible.
|
|
@@ -55,278 +43,158 @@ Remediation: run `/hapo:develop <feature> --flash` or `/hapo:develop <feature> -
|
|
|
55
43
|
No spec state, task receipt, worktree, subagent, or commit was created.
|
|
56
44
|
```
|
|
57
45
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
## Lane selection before spec gate
|
|
46
|
+
## Lane authority
|
|
62
47
|
|
|
63
|
-
|
|
48
|
+
Classify before spec/state mutation:
|
|
64
49
|
|
|
65
50
|
```bash
|
|
66
51
|
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
52
|
```
|
|
70
53
|
|
|
71
|
-
- **Direct
|
|
72
|
-
|
|
73
|
-
- **
|
|
54
|
+
- **Direct**: clear, isolated, reversible, low-risk. Skip spec/state/registry
|
|
55
|
+
ceremony and run targeted verification with proportional evidence.
|
|
56
|
+
- **Standard**: use the bounded spec profile and focused inspection. A small
|
|
57
|
+
feature need not have a task registry or task bundle. Close once at the
|
|
58
|
+
feature boundary.
|
|
59
|
+
- **Critical**: require the approved strict profile. Add durable task state,
|
|
60
|
+
registry/DAG, research, or independent audit only when the persisted
|
|
61
|
+
`proof_obligations` require each one.
|
|
62
|
+
|
|
63
|
+
Risk can escalate but cannot downgrade the persisted lane. A downgrade without a
|
|
64
|
+
trusted runtime-issued receipt is blocked; `user_approved` requires explicit user
|
|
65
|
+
approval, and `userAuthorized` plus similar booleans are not authorization.
|
|
66
|
+
|
|
67
|
+
`execution_tier` (`Light | Standard | Deep`) is a read-only legacy adapter
|
|
68
|
+
(`Direct | Standard | Critical`). It cannot emit policy, create obligations,
|
|
69
|
+
select a workflow, or override the lane. Do not branch on it for new behavior.
|
|
70
|
+
|
|
71
|
+
## Modes
|
|
72
|
+
|
|
73
|
+
### Specific task
|
|
74
|
+
|
|
75
|
+
Load exactly one task packet, implement only its scope, run its evidence, and
|
|
76
|
+
stop after synchronization. Specific-task mode never selects or chains into the
|
|
77
|
+
next task, even when another task is pending.
|
|
78
|
+
|
|
79
|
+
### Full feature
|
|
80
|
+
|
|
81
|
+
For a task-bearing policy, resolve one unblocked task at a time, complete its
|
|
82
|
+
cycle, synchronize, and recompute the queue. A bounded Standard feature without
|
|
83
|
+
tasks runs one feature-level cycle. Stop on the first unresolved block or
|
|
84
|
+
missing proof. Run a final integration check only when the feature has no more
|
|
85
|
+
pending tasks.
|
|
86
|
+
|
|
87
|
+
### Parallel (opt-in)
|
|
88
|
+
|
|
89
|
+
Load `references/parallel-waves.md` only when `--parallel` is present. It may
|
|
90
|
+
use isolated worktrees and a bounded wave, but lane obligations, single-writer
|
|
91
|
+
rules, immutable provenance, and the final integration check remain in force.
|
|
92
|
+
Without `--parallel`, process one unblocked task at a time.
|
|
93
|
+
|
|
94
|
+
### 3. Flash Mode (`--flash`)
|
|
95
|
+
Flash is an explicit speed trade-off, not a completion shortcut:
|
|
96
|
+
|
|
97
|
+
- skip dedicated test suites, full task evidence execution, and extended manual
|
|
98
|
+
checks;
|
|
99
|
+
- run only a cheap available syntax/typecheck/compile preflight;
|
|
100
|
+
- never weaken or delete tests;
|
|
101
|
+
- synchronize only as `in_progress` with `FLASH_UNVERIFIED`,
|
|
102
|
+
`dependencyBlocked: true`, `unblocks: false`, and blocker
|
|
103
|
+
`awaiting /hapo:test <feature>`;
|
|
104
|
+
- never claim `Test PASS`, `Evidence PASS`, `Auto-Approved`, or
|
|
105
|
+
`production-ready`.
|
|
106
|
+
|
|
107
|
+
Only trusted sync-finalize may promote a flash task. It must receive the current
|
|
108
|
+
`FLASH_UNVERIFIED` task plus explicit `--verdict PASS` and a canonical proof;
|
|
109
|
+
caller-supplied promotion fields are ignored/rejected. A marker-only proof
|
|
110
|
+
never promotes or finalizes. Stored state keeps `in_progress`,
|
|
111
|
+
`FLASH_UNVERIFIED`, `dependencyBlocked: true`, `unblocks: false`, and a concrete
|
|
112
|
+
blocker, omits promotion fields, and binds proof to expected Base/Head anchors.
|
|
113
|
+
## Workflow
|
|
114
|
+
`Classify lane → load lane artifacts → scout obligations → implement current
|
|
115
|
+
scope → one closeout owner → test receipt → review → docs-impact sync.`
|
|
116
|
+
|
|
117
|
+
### Step 1 — Load and scope
|
|
118
|
+
|
|
119
|
+
- Direct does not create a spec, state, registry, task bundle, or notes file.
|
|
120
|
+
- Standard requires its bounded artifacts and explicit approval, but not a
|
|
121
|
+
registry when the scope is small and no task obligation is persisted.
|
|
122
|
+
- Critical requires only the artifacts named by its snapshot obligations.
|
|
123
|
+
- For task-bearing work, load one requested task or one unblocked task and
|
|
124
|
+
extract scope, requirements, contracts, completion criteria, and exact
|
|
125
|
+
evidence commands.
|
|
126
|
+
- A spec-ready execution-evidence or independent-audit slot may be `PENDING`
|
|
127
|
+
before implementation; pending is not proof and cannot close the feature.
|
|
128
|
+
|
|
129
|
+
### Step 2 — Scout
|
|
130
|
+
|
|
131
|
+
Scout depth follows the persisted lane, risk, and blast radius. Identify real
|
|
132
|
+
entrypoints/callers, integration points, dependent files, reachability risks,
|
|
133
|
+
and safe scope. Do not use file count as a proxy for review depth. If a runtime
|
|
134
|
+
entrypoint cannot be grounded, stop.
|
|
135
|
+
|
|
136
|
+
### Step 3 — Implement
|
|
137
|
+
|
|
138
|
+
Implement only the approved scope and named contracts. Do not silently replace
|
|
139
|
+
frameworks, auth, transport, storage, or runtime boundaries. Do not mark a
|
|
140
|
+
runtime-facing file complete while it is orphaned, unmounted, unregistered, or
|
|
141
|
+
uncalled. A specific-task request ends after that task; no automatic chain.
|
|
74
142
|
|
|
75
|
-
|
|
143
|
+
<SCOPE-FIDELITY>
|
|
144
|
+
The approved `scope_lock`, requirements, design contracts, and active task are
|
|
145
|
+
the implementation contract. Scope escape requires a concrete reachability or
|
|
146
|
+
compile reason and must not deliver a later task early.
|
|
147
|
+
</SCOPE-FIDELITY>
|
|
76
148
|
|
|
77
|
-
|
|
149
|
+
### Step 4 — Closeout owner
|
|
78
150
|
|
|
79
|
-
|
|
80
|
-
|
|
151
|
+
The controller assigns exactly one closeout owner for the current task or
|
|
152
|
+
feature. That owner invokes the test workflow once, receives its result, then
|
|
153
|
+
invokes the review workflow once when the lane requires it. No other phase
|
|
154
|
+
re-runs the same test or review as a hidden gate.
|
|
81
155
|
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
|
|
85
|
-
-
|
|
156
|
+
- The test owner executes commands and creates the canonical execution receipt.
|
|
157
|
+
- The review owner evaluates correctness, security, and spec compliance; it
|
|
158
|
+
consumes existing proof but never creates or claims execution proof.
|
|
159
|
+
- Review depth follows lane, risk, and blast radius. It does not follow the
|
|
160
|
+
number of files changed.
|
|
161
|
+
- Finding count never selects review depth or overrides missing execution proof.
|
|
162
|
+
- Use the shared adapter surface: `PASS | PASS_WITH_WARNINGS | FAIL | BLOCKED`.
|
|
163
|
+
Warnings do not waive missing proof; `FAIL` is remediable and `BLOCKED` stops.
|
|
86
164
|
|
|
87
|
-
|
|
88
|
-
|
|
165
|
+
Load `references/quality-gate.md` for the exact closeout contract. It has no
|
|
166
|
+
fixed Light/Standard/Deep agent sequence.
|
|
89
167
|
|
|
90
|
-
|
|
91
|
-
- Select the next `pending` + unblocked task only.
|
|
92
|
-
- Run the full implementation cycle for that single task.
|
|
93
|
-
- Sync state.
|
|
94
|
-
- Recompute the queue and continue.
|
|
95
|
-
- STOP the overall run on the first blocked task, unresolved gate failure, or missing 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.
|
|
168
|
+
### Step 5 — Sync and docs checkpoint
|
|
97
169
|
|
|
98
|
-
|
|
99
|
-
|
|
170
|
+
Only a canonical execution receipt with command, exit result, bound provenance,
|
|
171
|
+
and required artifact hashes can close a task/feature. Missing, pending,
|
|
172
|
+
marker-only, or contradictory evidence stays unfinished. Critical audits need
|
|
173
|
+
distinct session IDs, expected Base/Head binding, concrete evidence, and literal
|
|
174
|
+
`verdict: "PASS"`; `Audit: PASS` is not evidence.
|
|
175
|
+
After verification, synchronize status/timestamps/task state. Then evaluate
|
|
176
|
+
actual docs impact:
|
|
100
177
|
|
|
101
|
-
|
|
178
|
+
- `none`: record it and stop;
|
|
179
|
+
- `minor`/`major`: update only affected existing docs through the normal docs
|
|
180
|
+
workflow, with no broad refresh.
|
|
102
181
|
|
|
103
|
-
|
|
104
|
-
```jsonc
|
|
105
|
-
// .claude/runtime.json — develop parallel toggle (missing key = allowed)
|
|
106
|
-
"develop": {
|
|
107
|
-
"parallel": true // false = --parallel refused, sequential run + notice
|
|
108
|
-
}
|
|
109
|
-
// Flag: /hapo:develop <feature> --parallel [N] (N = wave cap, 1..5, default 3)
|
|
110
|
-
```
|
|
182
|
+
Do not run a docs checkpoint merely because a task finished.
|
|
111
183
|
|
|
112
|
-
|
|
113
|
-
- Waves are computed from `task_registry.dependencies` with the single-writer-per-file rule; wave cap = N (1..5, default 3).
|
|
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`).
|
|
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.
|
|
116
|
-
- The orchestrator is the single writer of spec state: registry/task-md/receipts update after each cherry-pick, exactly as in sequential mode.
|
|
117
|
-
- Without `--parallel`, nothing in this section applies — the sequential Full-Spec loop below is unchanged.
|
|
118
|
-
|
|
119
|
-
### 3. Flash Mode
|
|
120
|
-
Triggered by adding `--flash` to either specific-task or full-spec mode.
|
|
121
|
-
|
|
122
|
-
- Optimize for fast implementation, not full verification.
|
|
123
|
-
- Still load the approved spec, scout every task, obey scope, and implement real code.
|
|
124
|
-
- Skip dedicated test suites, E2E/browser/manual QA loops, full task evidence execution, and code-review retry loops.
|
|
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.
|
|
126
|
-
- Never weaken, delete, or rewrite tests to avoid running them.
|
|
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.
|
|
128
|
-
- Final output MUST recommend `/hapo:test <feature>` before merge, release, or publish.
|
|
129
|
-
|
|
130
|
-
### 4. Implementation Notes
|
|
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`.
|
|
132
|
-
|
|
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.
|
|
135
|
-
- Keep the file self-contained: inline CSS, no JS, no external fonts, no network assets.
|
|
136
|
-
- Style notes as readable Claude Code-like blocks: compact cards, left accent bars, category badges, monospace file paths, and a task timeline.
|
|
137
|
-
- Record decisions and caveats while implementing, not only at the end.
|
|
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`.
|
|
139
|
-
|
|
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>
|
|
160
|
-
|
|
161
|
-
<DEFINITION-OF-DONE>
|
|
162
|
-
A task is NOT done because code compiles or a placeholder renders.
|
|
163
|
-
A task is done only when the task file's Completion Criteria AND `## Evidence` (legacy heading aliases still parse) are satisfied with real execution proof.
|
|
164
|
-
`--flash` is the only exception: it records fast implementation closeout with `FLASH_UNVERIFIED`, not full Definition of Done.
|
|
165
|
-
</DEFINITION-OF-DONE>
|
|
166
|
-
|
|
167
|
-
<CONTRACT-FIDELITY>
|
|
168
|
-
If the spec/task explicitly names a framework, auth system, datastore, transport path, or runtime boundary, that named choice is contractual.
|
|
169
|
-
You MUST NOT silently replace it with a simpler custom substitute ("for MVP", "placeholder", "temporary auth", "in-memory until later") unless the spec itself is updated first.
|
|
170
|
-
</CONTRACT-FIDELITY>
|
|
184
|
+
## Definition of done and handoff
|
|
171
185
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
186
|
+
Done requires active criteria, all required evidence, reachable runtime behavior,
|
|
187
|
+
a receipt bound to expected Base/Head, and every lane obligation. Only literal
|
|
188
|
+
`PASS` can complete; `PASS_WITH_WARNINGS` remains unfinished.
|
|
189
|
+
`--flash` records only `FLASH_UNVERIFIED` and never done.
|
|
176
190
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
flowchart TD
|
|
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
|
|
187
|
-
D --> E{Flash Mode?}
|
|
188
|
-
E -->|No| Q[Step 4: Quality Gate: Test + Spec Review + Code Review + Evidence]
|
|
189
|
-
E -->|Yes| R[Step 4F: Flash Gate: Minimal Preflight + Scope Sanity]
|
|
190
|
-
Q -->|Fail| D
|
|
191
|
-
Q -->|Pass| F[Step 5: State Sync + Incremental Docs Sync]
|
|
192
|
-
R -->|Syntax/compile fail| D
|
|
193
|
-
R -->|Flash closeout| F
|
|
194
|
-
F --> H{More tasks?}
|
|
195
|
-
H -->|Yes| B
|
|
196
|
-
H -->|No| G[Final Integration Scout + Report Completion]
|
|
197
|
-
```
|
|
191
|
+
For a full feature, after the last task run the **Final Integration Scout** when
|
|
192
|
+
runtime-facing surfaces exist; compare reachability and scope before reporting
|
|
193
|
+
completion. For a specific task, stop after its synchronized result.
|
|
198
194
|
|
|
199
|
-
|
|
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`:
|
|
205
|
-
- If missing, create it from `references/implementation-notes-template.html`.
|
|
206
|
-
- Replace template placeholders for feature name, spec path, creation timestamp, and current mode.
|
|
207
|
-
- If present, preserve existing note cards and update the summary/timeline/status fields.
|
|
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.
|
|
213
|
-
|
|
214
|
-
### Step 2: Scout (Codebase Inspection)
|
|
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:
|
|
217
|
-
- Active task file path and extracted task packet
|
|
218
|
-
- Requirement IDs and `scope_lock`
|
|
219
|
-
- Relevant `design.md` contracts/invariants
|
|
220
|
-
- Prior completed task outputs from `spec.json.task_registry`
|
|
221
|
-
- Related Files from the active task
|
|
222
|
-
- The scout MUST report:
|
|
223
|
-
- Real runtime entrypoints/callers affected by the task (`App.tsx`, routes, CLI command, worker registration, manifest, API consumer, etc.)
|
|
224
|
-
- Existing integration points and adjacent code patterns to follow
|
|
225
|
-
- Prior task outputs this task must consume or preserve
|
|
226
|
-
- Blast-radius touchpoints and dependent files that can regress
|
|
227
|
-
- Reachability risks: orphan components, unmounted UI, unregistered routes, uncalled services/loaders, unused providers, disconnected reducers/actions
|
|
228
|
-
- Exact files likely safe to modify and any files outside `Related Files` that require a justified scope escape
|
|
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.
|
|
230
|
-
|
|
231
|
-
### Step 3: Implement Code
|
|
232
|
-
- Act as the `implementer` per the Delegation policy (default: the main session), executing tasks specified in the loaded Markdown file(s) sequentially.
|
|
233
|
-
- **Important:** You may create and modify files directly, but must faithfully follow the design from the Spec.
|
|
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.
|
|
235
|
-
- **Standard/Critical only**: unless `--no-notes` is present, append a note card to `implementation-notes.html` whenever any of these occurs:
|
|
236
|
-
- `decision`: a necessary implementation choice not specified by the spec
|
|
237
|
-
- `spec-gap`: missing or ambiguous spec detail discovered during implementation
|
|
238
|
-
- `codebase-reality`: existing code requires a different integration path than the task implied
|
|
239
|
-
- `tradeoff`: a conscious simplicity, performance, UX, or maintainability tradeoff
|
|
240
|
-
- `scope-escape`: a file or behavior outside Related Files must be touched for reachability/compile/integration
|
|
241
|
-
- `risk`: known residual risk, edge case, or deferred follow-up
|
|
242
|
-
- `verification`: command result, skipped check, manual proof, or evidence caveat
|
|
243
|
-
- Progress tracking: Temporarily change `[ ]` to `[/]` in Spec files while coding is in progress. Do NOT mark `[x]` before Step 4 passes.
|
|
244
|
-
- **Task Boundary Protocol (CRITICAL):**
|
|
245
|
-
- Default editable scope is `Related Files` from the task packet.
|
|
246
|
-
- You may additionally touch direct test files plus minimal support files required to make the current task executable (shared types, exports, config glue, generated migration wiring).
|
|
247
|
-
- If you must edit a file outside this scope, explicitly treat it as a `scope escape` and justify why it is required for the current task.
|
|
248
|
-
- If the out-of-scope change would deliver functionality clearly assigned to a later task, STOP instead of implementing it early.
|
|
249
|
-
- **Hard Stop Protocol:** If you were asked to implement a specific task file, you MUST STOP completely after that task is verified. DO NOT auto-chain or jump to "Next Task" simply because you see it in the spec. Wait for the user's next command.
|
|
250
|
-
- **Full-Spec Loop Protocol:** If you were asked to implement the whole feature, you MUST still work one task at a time. Finish Step 4 and Step 5 for the current task before selecting the next unblocked task from `task_registry`.
|
|
251
|
-
- **Test Integrity Protocol:** You MUST NOT delete, replace, or reduce the scope of existing test cases to make tests pass. If a test fails, you must fix the **implementation code** or fix the **test setup/mock**, NOT remove the assertion. Reducing test count or weakening assertions (e.g., removing `toHaveBeenCalledWith` and replacing with `toEqual(expect.any(...))`) is a Critical violation.
|
|
252
|
-
- **Contract Integrity Protocol:** If implementation appears to require changing auth/session, transport, persistence, entrypoint wiring, or generated artifact behavior beyond what `design.md` states, STOP and route back to spec correction instead of inventing a new contract in code.
|
|
253
|
-
- **Named Technology Rule:** If the task/spec explicitly requires a named dependency or runtime choice (for example Better Auth, Hono, Next.js proxy routes, Redis, Drizzle, S3), you MUST implement that choice or stop. Do not swap it for a custom/in-memory/local substitute and still call the task complete.
|
|
254
|
-
- **Cross-Service Reality Rule:** If a task spans multiple processes or runtimes (web ↔ API, worker ↔ DB, extension ↔ backend), you MUST prove the integration uses shared real state or a real contract boundary. Process-local placeholders on both sides do not count as completion.
|
|
255
|
-
- **Placeholder Completion Rule:** You MAY scaffold future files only when the active task truly needs them to compile, but placeholder route handlers, in-memory stores, or fake adapters MUST NOT be used as evidence that the current task's behavior works end-to-end.
|
|
256
|
-
- **Reachability Rule:** Runtime-facing work is incomplete until it is reachable from the real entrypoint/caller named in the task evidence or Step 2 scout report. Creating a component/service/route/provider/reducer without importing, mounting, registering, or invoking it is not implementation.
|
|
257
|
-
- **Prior Output Consumption Rule:** If this task depends on previous task outputs, verify those outputs are consumed through real code paths. If a prior output is unused and this task is responsible for wiring it, wire it now; if a later task owns the wiring, keep the current task pending unless that deferral is named in the active task evidence.
|
|
258
|
-
|
|
259
|
-
### Step 4: Self-Healing (Quality Gate Auto-Fix)
|
|
260
|
-
The moment you finish coding, DO NOT proceed further. Switch to `references/quality-gate.md` and run the automatic review loop.
|
|
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.
|
|
262
|
-
|
|
263
|
-
If `--flash` is active, use **Step 4F: Flash Gate** instead of the full automatic review loop.
|
|
264
|
-
|
|
265
|
-
- Passing Step 4 requires ALL of the following:
|
|
266
|
-
1. Automated verification passes, including preflight compile/typecheck/build health and every exact command named in the task's `## Evidence` (legacy heading aliases still parse)
|
|
267
|
-
2. Spec compliance review passes: every scoped requirement and active task criterion is implemented, with no extras and no omissions
|
|
268
|
-
3. Code quality review passes
|
|
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.
|
|
271
|
-
- `PRECHECK_FAIL` outranks `NO_TESTS`. If compile/typecheck/build fails, the task is FAIL even when no test suite exists yet.
|
|
272
|
-
- If build/test passes but task evidence is missing, the task is still FAIL.
|
|
273
|
-
- Only escalate to the user after 3 consecutive failed review rounds.
|
|
274
|
-
|
|
275
|
-
### Step 4F: Flash Gate (`--flash` only)
|
|
276
|
-
Flash mode is an explicit speed trade-off requested by the user.
|
|
277
|
-
|
|
278
|
-
- Skip:
|
|
279
|
-
- dedicated test commands from task Evidence
|
|
280
|
-
- full test-runner delegation
|
|
281
|
-
- E2E/browser/manual QA loops
|
|
282
|
-
- full code-auditor retry loop
|
|
283
|
-
- screenshot, accessibility, performance, and visual verification unless the active task is purely visual and can be checked cheaply
|
|
284
|
-
- Still perform:
|
|
285
|
-
- task-aware scout from Step 2
|
|
286
|
-
- active task scope sanity check against Completion Criteria
|
|
287
|
-
- reachability sanity check for runtime-facing files: imported, mounted, registered, routed, or invoked where applicable
|
|
288
|
-
- cheap compile/syntax/typecheck/build command when it is already available and expected to run quickly
|
|
289
|
-
- If the cheap preflight fails, return to Step 3 and fix before syncing.
|
|
290
|
-
- If no cheap preflight exists or it would require slow setup/external services, record `Preflight: skipped in --flash mode`.
|
|
291
|
-
- Flash output MUST log: `⚡ Step 4 Flash Gate: tests skipped by --flash; preflight=<pass|skipped>; evidence=FLASH_UNVERIFIED`.
|
|
292
|
-
- Flash output MUST NOT say `Test PASS`, `Evidence PASS`, `Auto-Approved`, or `production-ready`.
|
|
293
|
-
|
|
294
|
-
### Step 5: State Sync + Task-Level Docs Sync
|
|
295
|
-
- Only after Step 4 passes may you mark task checkboxes completed and sync `spec.json` progress/timestamps/task_registry.
|
|
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.
|
|
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.
|
|
298
|
-
- A completed task MUST leave behind:
|
|
299
|
-
- markdown `**Status:** done`
|
|
300
|
-
- `spec.json.task_registry[path].status = "done"`
|
|
301
|
-
- `completed_at` + `last_updated_at`
|
|
302
|
-
- synchronized top-level `updated_at`
|
|
303
|
-
- a human-readable verification receipt inside the task's `Evidence` section showing which commands ran, their outcomes, and what proof was observed
|
|
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>`.
|
|
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`.
|
|
306
|
-
- Exception: `FLASH_UNVERIFIED` is allowed only when `--flash` is explicitly present. It records fast implementation completion, not full verification completion.
|
|
307
|
-
- Unless `--no-notes` is present, update `implementation-notes.html` before reporting the task:
|
|
308
|
-
- Mark the task block as `done`, `blocked`, or `flash_unverified`.
|
|
309
|
-
- Add a `verification` note with exact commands run or `Tests skipped by --flash`.
|
|
310
|
-
- If no implementation note was needed for the task, add a compact `decision` note: `No spec gaps, tradeoffs, scope escapes, or deferred risks recorded for this task.`
|
|
311
|
-
- Add `Next verification: /hapo:test <feature>` when any evidence is skipped, partial, or `FLASH_UNVERIFIED`.
|
|
312
|
-
- After syncing the active task, run a **Task Closeout Docs Checkpoint**
|
|
313
|
-
- Task Closeout Docs Checkpoint:
|
|
314
|
-
- Evaluate `Docs impact: none | minor | major` based on real behavior changes from the just-completed task
|
|
315
|
-
- If `none`: record that explicitly in the completion report and stop
|
|
316
|
-
- If `minor` or `major`: trigger `docs-keeper` to surgically update affected existing docs under `./docs`
|
|
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
|
|
318
|
-
- **CWD Protocol (CRITICAL):** When spawning `docs-keeper`, set its Current Working Directory (CWD context) to the **Workspace Root**, not the inner package directory.
|
|
319
|
-
- Task-level docs sync happens after every verified completed task, but actual edits still depend on `Docs impact`.
|
|
320
|
-
- In **Specific-Task Mode**, STOP after sync and report the result.
|
|
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.
|
|
322
|
-
- When no pending tasks remain, run a **Final Integration Scout** before reporting completion:
|
|
323
|
-
- Trace runtime entrypoints from `main`/route/CLI/worker/manifest/API consumer through the scoped feature surfaces.
|
|
324
|
-
- Compare reachable behavior against `scope_lock`, `requirements.md`, `design.md`, and all task Completion Criteria.
|
|
325
|
-
- FAIL completion if any scoped surface is missing, any created runtime-facing artifact is orphaned, or spec progress/registry says done while evidence is missing.
|
|
326
|
-
- Only then set top-level progress to `code_done` / next phase.
|
|
195
|
+
## Attached references
|
|
327
196
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
- `references/
|
|
331
|
-
- `references/
|
|
332
|
-
- `references/implementation-notes-template.html` - Self-contained visual implementation notes template.
|
|
197
|
+
- `references/quality-gate.md` — closeout ownership, verdict normalization, and
|
|
198
|
+
evidence checks.
|
|
199
|
+
- `references/parallel-waves.md` — opt-in worktree waves.
|
|
200
|
+
- `references/implementation-notes-template.html` — loaded only with `--notes`.
|