@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.
Files changed (51) hide show
  1. package/bin/__tests__/codex-hooks.test.js +355 -12
  2. package/bin/__tests__/codex-native.test.js +1 -1
  3. package/bin/__tests__/develop-contract.test.js +1374 -78
  4. package/bin/__tests__/installer-safety.test.js +43 -29
  5. package/bin/__tests__/opencode-spec-gate.test.js +791 -0
  6. package/bin/__tests__/package-inventory.test.js +157 -0
  7. package/bin/__tests__/validator-grounding.test.js +707 -2
  8. package/package.json +1 -1
  9. package/src/claude/agents/code-auditor.md +8 -1
  10. package/src/claude/agents/spec-maker.md +107 -200
  11. package/src/claude/hooks/__tests__/completion-authority.test.js +720 -0
  12. package/src/claude/hooks/__tests__/spec-gate.test.js +511 -38
  13. package/src/claude/hooks/completion-authority-check.cjs +307 -0
  14. package/src/claude/hooks/completion-authority-state.cjs +525 -0
  15. package/src/claude/hooks/completion-authority.cjs +148 -0
  16. package/src/claude/hooks/session.cjs +33 -19
  17. package/src/claude/hooks/spec-gate.cjs +173 -61
  18. package/src/claude/hooks/spec-state.cjs +104 -45
  19. package/src/claude/migration-manifest.json +6 -1
  20. package/src/claude/scripts/provenance.cjs +315 -0
  21. package/src/claude/scripts/spec-resolver.cjs +450 -0
  22. package/src/claude/scripts/spec-scaffold.cjs +716 -41
  23. package/src/claude/scripts/validate-spec-output.cjs +355 -53
  24. package/src/claude/scripts/workflow-policy.cjs +1529 -162
  25. package/src/claude/settings/settings.json +8 -0
  26. package/src/claude/skills/backend-development/references/backend-security.md +52 -0
  27. package/src/claude/skills/code-review/SKILL.md +85 -66
  28. package/src/claude/skills/develop/SKILL.md +153 -285
  29. package/src/claude/skills/develop/references/quality-gate.md +112 -124
  30. package/src/claude/skills/develop/references/subagent-patterns.md +42 -37
  31. package/src/claude/skills/specs/SKILL.md +170 -381
  32. package/src/claude/skills/specs/rules/task-scoring-rubric.md +45 -46
  33. package/src/claude/skills/specs/rules/tasks-generation.md +49 -20
  34. package/src/claude/skills/specs/templates/spec-state.json +23 -2
  35. package/src/claude/skills/specs/templates/task.md +20 -0
  36. package/src/claude/skills/sync/SKILL.md +15 -8
  37. package/src/claude/skills/sync/references/sync-protocols.md +4 -4
  38. package/src/claude/skills/test/SKILL.md +141 -167
  39. package/src/codex/hooks/completion-authority-check.cjs +260 -0
  40. package/src/codex/hooks/completion-authority-state.cjs +525 -0
  41. package/src/codex/hooks/completion-authority.cjs +100 -0
  42. package/src/codex/hooks/lib/hook-context.cjs +42 -2
  43. package/src/codex/hooks/lib/spec-receipt.cjs +76 -43
  44. package/src/codex/hooks/lib/spec-utils.cjs +53 -27
  45. package/src/codex/hooks/session.cjs +2 -0
  46. package/src/codex/hooks/spec-gate.cjs +132 -20
  47. package/src/codex/hooks/spec-state.cjs +56 -10
  48. package/src/codex/hooks.json +10 -0
  49. package/src/opencode/AGENTS.md +4 -2
  50. package/src/opencode/plugins/spec-gate.ts +296 -122
  51. package/src/opencode/plugins/spec-state.ts +183 -116
@@ -1,52 +1,51 @@
1
- # Task Scoring Rubric
1
+ # Task Scoring Rubric (optional advisory)
2
2
 
3
- Use this rubric after applying the Phase Decision Matrix and before writing each task file. The score determines priority, split/merge, spike needs, dependency shape, and evidence depth.
3
+ Load this rubric only when the persisted policy requires a task bundle and the
4
+ decomposition has a real split/merge or dependency question. It is not a lane
5
+ classifier, readiness gate, approval gate, or reason to create a task bundle.
4
6
 
5
- ## Score Each Candidate Task
7
+ ## Candidate dimensions
6
8
 
7
- Score each dimension 0-3.
9
+ Score each candidate from 0–3 only when the score will change a task decision:
8
10
 
9
11
  | Dimension | 0 | 1 | 2 | 3 |
10
12
  |---|---|---|---|---|
11
- | Dependency criticality | Standalone | Depends on one task | Blocks one feature slice | Blocks many tasks or core runtime |
12
- | Implementation risk | Routine | Known pattern, minor edge cases | Complex logic or integration | Unproven behavior, migration, security, provider/platform uncertainty |
13
- | Blast radius | Isolated file | Feature-local files | Shared component/API/config | Auth, data layer, routing, permissions, package export, or critical path |
14
- | User value | Internal cleanup | Enables later work | User-visible improvement | Core acceptance criterion or launch blocker |
15
- | Evidence confidence | Proven by code/tests/docs | Mostly proven | Partial evidence | Low/no evidence |
16
- | Testability burden | Simple unit/smoke | Component/integration | Multi-step workflow | E2E/security/performance/rollback proof required |
17
- | File conflict risk | No overlap | Minor shared utility | Shared module with consumers | Same files as another task or cross-agent conflict likely |
18
- | Scope creep risk | Fully in scope | Small interpretation | Adds adjacent behavior | Adds unapproved feature/contract |
19
-
20
- ## Interpret Score
21
-
22
- | Total | Priority | Action |
23
- |---:|---|---|
24
- | 0-6 | P3 | Keep compact. Merge if no independent proof exists. |
25
- | 7-12 | P2 | Normal task. Include explicit dependencies and evidence. |
26
- | 13-18 | P1 | High attention. Consider split, stronger evidence, and validation note. |
27
- | 19+ | P1 critical | Split or add spike. Do not mark parallel unless file ownership is isolated. |
28
-
29
- ## Mandatory Overrides
30
-
31
- - If Scope creep risk = 3, stop and use `AskUserQuestion` before generating the task.
32
- - If Evidence confidence = 3 and Implementation risk >= 2, create a spike task first.
33
- - If Blast radius = 3, include rollback/negative-path proof in `Evidence`.
34
- - If File conflict risk >= 2, remove `(P)` unless ownership is explicitly separated.
35
- - If User value = 3 and Dependency criticality >= 2, schedule early unless blocked by foundation work.
36
-
37
- ## Task Metadata Decisions
38
-
39
- - `priority`: from total score plus overrides.
40
- - `dependencies`: list every required predecessor task file.
41
- - `(P)` marker: allowed only when dependency and file conflict scores are <= 1 and design boundaries do not overlap.
42
- - `Evidence`: choose proof type from `tasks-generation.md` Test Type Selection table; increase proof depth for high scores.
43
- - `Risk Assessment`: include all dimensions scored 2-3 as risks or constraints.
44
-
45
- ## Compact Output
46
-
47
- Do not write the raw score table into every task file. Use the rubric to shape task content. Surface only decisions that affect implementation:
48
-
49
- - why task is P1/P2/P3
50
- - why it is split/merged
51
- - why it is or is not parallel
52
- - why a spike or extra proof is required
13
+ | Dependency criticality | standalone | one predecessor | one slice blocked | core path blocked |
14
+ | Implementation risk | routine | known pattern | complex integration | unproven/security |
15
+ | Blast radius | isolated | feature-local | shared contract | critical boundary |
16
+ | User value | internal | enables work | visible improvement | acceptance/launch |
17
+ | Evidence confidence | proven | mostly proven | partial | low/no evidence |
18
+ | Test burden | unit/smoke | component/integration | workflow | security/rollback |
19
+ | File conflict | none | minor | shared module | overlapping ownership |
20
+ | Scope creep | none | interpretation | adjacent behavior | unapproved contract |
21
+
22
+ ## Use of the result
23
+
24
+ Use the result only to explain priority, split/merge, dependency order,
25
+ parallel ownership, or proof depth. Prefer one task when one boundary and one
26
+ proof path are enough. Split only for a real dependency, ownership boundary, or
27
+ independent proof path.
28
+
29
+ - Scope-creep score 3: stop and ask for scope approval.
30
+ - Low evidence plus risk ≥2: consider a time-boxed spike, but do not create one
31
+ solely because a Cynefin label says `Complex`.
32
+ - Blast radius 3: include rollback/negative-path proof.
33
+ - File conflict ≥2: remove `(P)` unless ownership is isolated.
34
+ - High value plus dependency ≥2: schedule early only after real prerequisites.
35
+
36
+ Cynefin is advisory discovery language. It may suggest a spike or research
37
+ question; it never changes Direct/Standard/Critical, adds registry/DAG
38
+ ceremony, or decides readiness.
39
+
40
+ ## Compact task metadata
41
+
42
+ Do not copy the raw table into task files. Record only decisions that affect
43
+ execution:
44
+
45
+ - why the task is split or merged;
46
+ - why it is early or deferred;
47
+ - why it is or is not parallel;
48
+ - why a spike or deeper proof is useful;
49
+ - exact dependencies and evidence.
50
+
51
+ If no decision changes, omit scoring entirely and keep the task packet compact.
@@ -2,16 +2,25 @@
2
2
 
3
3
  ## Core Principles
4
4
 
5
- ### 0. Pre-Generation Decision Gates
5
+ ### 0. Conditional generation gates
6
+
7
+ This file is loaded only after the persisted lane obligations say that a task
8
+ bundle is needed. A bounded Standard scope may finish with its feature receipt
9
+ and no `tasks/` or registry.
6
10
 
7
11
  Before writing any `tasks/task-R*.md` file:
8
12
 
9
- 1. Load `phase-decision-matrix.md` and identify implementation slices/task clusters: R0 foundation, risk spikes, vertical slices, layer slices, cross-cutting slices, integration gates, verification gates, and release/packaging slices when in scope.
10
- 2. Load `task-scoring-rubric.md` and score each candidate task. Use the result to choose priority, split/merge, spike needs, dependencies, parallel eligibility, and evidence depth.
11
- 3. Load `../references/ask-user-question-gates.md` if scoring or slicing detects unapproved scope expansion, unresolved architecture tie, missing evidence, contract ambiguity, or final contradiction.
12
- 4. Do not ask about facts that targeted scout, repo files, tests, or official/current docs can answer.
13
+ 1. Load `phase-decision-matrix.md` only if the task boundaries are unclear.
14
+ 2. Load `task-scoring-rubric.md` only if an actual split/merge, dependency, or
15
+ evidence-depth decision needs it. Scoring is optional and never selects a
16
+ lane or makes tasks mandatory.
17
+ 3. Load `../references/ask-user-question-gates.md` only for an unapproved scope
18
+ change, unresolved architecture choice, missing evidence, or contradiction.
19
+ 4. Use targeted scout, repository files, tests, and current primary docs for
20
+ facts before asking the user.
13
21
 
14
- The raw score table does not need to appear in each task file. The task file must reflect the decisions: why the task exists, what it depends on, why it is split/merged, whether it can be parallel, and what proof is required.
22
+ The task file must explain only decisions that affect execution: scope,
23
+ dependencies, ownership, proof, and any intentional split/merge.
15
24
 
16
25
  ### 1. Natural Language Descriptions
17
26
  Focus on capabilities and outcomes, not code structure.
@@ -32,7 +41,10 @@ Detail bullets must include:
32
41
  - API payloads, routes, and JSON contracts.
33
42
  - Edge cases, error handling, and exact validation thresholds (e.g., `Return 403 if invalid`).
34
43
 
35
- **Rationale**: Humans review tasks to verify business requirements are met; AI Coders (like implementer or ck) read tasks to write explicit code. If you only write business jargon, the AI hallucinates. If you only write code names, the human reviewer cannot verify the business value. You MUST provide both.
44
+ **Rationale**: Humans review tasks to verify business requirements are met;
45
+ coding agents read tasks to write explicit code. If you only write business
46
+ jargon, the AI hallucinates. If you only write code names, the human reviewer
47
+ cannot verify the business value. You MUST provide both.
36
48
 
37
49
  ### 2. Task Integration & Progression
38
50
 
@@ -48,8 +60,10 @@ Detail bullets must include:
48
60
  - Reuse canonical contracts from `design.md` verbatim; never invent alternate auth/provider/deletion policies in task prose
49
61
  - Use major task summaries sparingly—omit detail bullets if the work is fully captured by child tasks.
50
62
 
51
- **End with integration tasks** to wire everything together.
52
- - For UI/app/runtime workflows, the final integration task MUST name the real entrypoint (`App.tsx`, route, command, worker, extension manifest, API route, etc.) and verify every user-visible surface from the requirements is reachable from that entrypoint.
63
+ **Add integration proof when the surface needs it**.
64
+ - For UI/app/runtime workflows, the last task or a final integration section
65
+ names the real entrypoint (`App.tsx`, route, command, worker, extension
66
+ manifest, API route, etc.) and verifies every scoped surface is reachable.
53
67
  - Components, services, routes, commands, workers, providers, and data loaders created by earlier tasks MUST be consumed by a later integration task or explicitly marked as internal support in `design.md`; orphaned deliverables are invalid.
54
68
  - Prefer compact, implementation-ready task prose over large boilerplate. The golden shape is: `Context` -> `Steps` -> `Requirements` -> `Related Files` -> `Completion Criteria` -> `Evidence` -> `Risk Assessment`.
55
69
  - A compact task is valid when it names exact files/contracts, maps requirements, and gives executable evidence. Do not expand it into nested filler just to satisfy a template.
@@ -94,15 +108,24 @@ Some requirements (e.g., "language handling", "error handling") naturally touch
94
108
 
95
109
  Grouping tasks vertically by requirement carries the risk of "siloed" or fragmented code (e.g., each requirement building its own isolated setup). To ensure the system remains cohesive:
96
110
 
97
- 1. **Foundation First (The R0 Concept)**: Extract shared infrastructure, core database migrations, authentication wrappers, and base UI layouts into foundational tasks running before feature work. If these aren't explicitly in requirements, classify them as `task-R0-XX-foundation.md` or map them to the most logical architectural requirement. All parallel feature tasks MUST depend on these foundation tasks.
111
+ 1. **Foundation only when real**: Add a foundation task only for a shared
112
+ prerequisite that has its own ownership or proof boundary. Do not invent an
113
+ R0 task for a small bounded change.
98
114
  2. **Shared Interfaces (Horizontal Contracts)**: Sub-tasks that touch shared cross-requirement architecture (like registering a new page in a global `router.ts` or adding a column to a shared table) MUST explicitly reference the shared contract defined in `design.md`.
99
115
  3. **Integration Enforcers**: If R1 and R2 interact (e.g., R2 UI displays data fetched by R1 backend), the later task MUST have a sub-task explicitly dedicated to "Wiring/Integrating with [Previous Feature] output".
100
- 4. **Final Runtime Integration**: For any feature that has a user-facing screen, public route, CLI command, background worker, browser extension surface, or API flow, create a final integration task (or a final integration section in the last dependent task) that proves the whole scoped feature works from its runtime entrypoint. This task MUST fail if prior-task outputs exist but are not imported, mounted, registered, or invoked.
101
- 5. **Scored Sequencing**: Use `task-scoring-rubric.md` to schedule high-value/high-dependency tasks early, but only after required foundation/spike work. High file-conflict or high blast-radius tasks must not be marked `(P)` without isolated ownership.
116
+ 4. **Final Runtime Integration**: For a feature with a user-facing or
117
+ runtime-facing surface, include a final integration task or section only if
118
+ the existing task evidence does not already prove the entrypoint. It MUST
119
+ fail when outputs are not imported, mounted, registered, or invoked.
120
+ 5. **Advisory sequencing**: If the optional rubric was used, apply its
121
+ dependency/ownership notes. Never use a score to add ceremony or override
122
+ the persisted lane.
102
123
 
103
- ### 3d. Spike Tasks for Complex/Uncertain Areas (MANDATORY)
124
+ ### 3d. Spike tasks for unresolved uncertainty (ADVISORY)
104
125
 
105
- When the 5-Dimension Complexity Assessment (Step 3) flags a component or requirement as **Risk = Complex** (Cynefin), the task breakdown MUST include a dedicated **spike/prototype task** before the main implementation task for that area.
126
+ When the assessment flags an unproven assumption, a time-boxed spike may be
127
+ useful before implementation. A Cynefin `Complex` label alone does not mandate
128
+ one, change the lane, or create a registry/DAG.
106
129
 
107
130
  **Purpose**: Validate assumptions and reduce uncertainty before committing to full implementation.
108
131
 
@@ -117,8 +140,9 @@ When the 5-Dimension Complexity Assessment (Step 3) flags a component or require
117
140
  5. **Dependencies**: The main implementation task for this area MUST depend on the spike task.
118
141
 
119
142
  **When NOT to create spike tasks:**
120
- - Risk = Clear or Complicated → skip spike, proceed directly.
121
- - The uncertain area is already covered by research.md with concrete evidence (real API tests, not just documentation links).
143
+ - the assumption is already grounded by targeted evidence or required research;
144
+ - the change is clear enough for a direct implementation/proof path;
145
+ - the spike would add ceremony without reducing a concrete uncertainty.
122
146
 
123
147
  ### 6. Risk Assessment Table (MANDATORY)
124
148
 
@@ -190,7 +214,9 @@ Choose verification by task risk and touched surface. Do not force every task to
190
214
  | Bug fix/regression | Regression test reproducing the old failure, then passing |
191
215
  | Performance/security-sensitive requirement or touched surface | Performance/security check only when specified by requirements, design risk, or changed boundary |
192
216
 
193
- `hapo:specs` writes the expected proof into each task. `hapo:develop` executes the task-local proof before marking the task done. `hapo:test` runs the broader system pass after implementation or for a requested feature scope.
217
+ `hapo:specs` writes the expected proof into each task. `hapo:test` is the sole
218
+ execution-proof owner and emits the canonical receipt. `hapo:develop` consumes
219
+ that proof at closeout; it does not create a second execution receipt.
194
220
 
195
221
  ### Frontend Fidelity Rule (when a visual reference is provided)
196
222
 
@@ -260,12 +286,15 @@ Reuse vs new component:
260
286
 
261
287
  ## Requirements Coverage
262
288
 
263
- **Mandatory Check**:
264
- - ALL requirements from requirements.md MUST be covered
289
+ **Check when a task bundle exists**:
290
+ - ALL requirements assigned to the task bundle MUST be covered
265
291
  - Cross-reference every requirement ID with task mappings
266
292
  - If gaps found: Return to requirements or design phase
267
293
  - No requirement should be left without corresponding tasks
268
294
 
269
- Use the requirement ID style already present in `requirements.md` (`R1`, `REQ-01`, or `N.M`). The task filename cluster (`task-R1-01-*`) does not have to mirror every requirement ID exactly, but every requirement MUST be listed in at least one task's `## Requirements` section.
295
+ Use the requirement ID style already present in `requirements.md` (`R1`,
296
+ `REQ-01`, or `N.M`). The task filename cluster (`task-R1-01-*`) does not have
297
+ to mirror every requirement ID exactly, but every requirement represented by
298
+ the bundle MUST be listed in at least one task's `## Requirements` section.
270
299
 
271
300
  Document any intentionally deferred requirements with rationale.
@@ -64,7 +64,6 @@
64
64
  "design_context": {
65
65
  "discovery_mode": null,
66
66
  "discovery_reason": null,
67
- "execution_tier": "standard",
68
67
  "validation_recommended": false
69
68
  },
70
69
  "validation": {
@@ -81,5 +80,27 @@
81
80
  "sync": "always",
82
81
  "last_synced_at": null
83
82
  },
84
- "ready_for_implementation": false
83
+ "ready_for_implementation": false,
84
+ "workflow_policy": {
85
+ "version": "1",
86
+ "lane": "Standard",
87
+ "automatic_lane": "Standard",
88
+ "risks": [],
89
+ "artifact_profile": "bounded",
90
+ "proof_obligations": [
91
+ "needsInspection",
92
+ "needsExecutionProof"
93
+ ],
94
+ "actor_needs": [
95
+ {
96
+ "capability": "inspection",
97
+ "independence": "same-session"
98
+ },
99
+ {
100
+ "capability": "execution-proof",
101
+ "independence": "same-session"
102
+ }
103
+ ],
104
+ "override_receipt": null
105
+ }
85
106
  }
@@ -7,6 +7,13 @@
7
7
  **Dependencies:** {{DEPENDENCIES}}
8
8
  **Spec:** specs/{{FEATURE_NAME}}/
9
9
 
10
+ The owning `spec.json.workflow_policy` snapshot is authoritative for this task.
11
+ `needsInspection` and `needsExecutionProof` are separate capabilities; Standard
12
+ requires both, while Direct requires execution proof. Do not encode an agent
13
+ chain in this task. The canonical verdicts are `PASS`, `PASS_WITH_WARNINGS`,
14
+ `FAIL`, and `BLOCKED`. Legacy diagnostic inputs `PARTIAL` and `NO_TESTS` are
15
+ normalized to unfinished `BLOCKED`; they are not canonical verdicts.
16
+
10
17
  ## Context
11
18
 
12
19
  - **Why**: {{Business/user reason this task exists}}
@@ -48,12 +55,22 @@
48
55
  | `{{FILE_PATH_1}}` | Create / Modify / Delete | {{DESCRIPTION_1}} |
49
56
  | `{{FILE_PATH_2}}` | Create / Modify / Delete | {{DESCRIPTION_2}} |
50
57
 
58
+ ### Optional artifact declaration
59
+
60
+ If this task produces a hashable compiled or generated output, the producer MUST add
61
+ `task_registry[path].artifacts` as a non-empty JSON array of safe relative path
62
+ strings. Omit the field when the task has no such artifact. A `Related Files`
63
+ row (`Create`, `Modify`, `Delete`, or `Read`) is not an artifact declaration by
64
+ itself. The receipt must declare each artifact path with its own `SHA-256:` value
65
+ containing exactly 64 hexadecimal characters.
66
+
51
67
  ## Completion Criteria
52
68
 
53
69
  - [ ] {{Criteria 1 — observable output or artifact, maps to acceptance criteria R{{REQ_NUMBER}}}}
54
70
  - [ ] {{Criteria 2 — measurable behavior or negative-path outcome}}
55
71
  - [ ] {{Criteria 3 — maps directly to acceptance criteria from requirements.md and can be proven below}}
56
72
  - [ ] {{Criteria 4 — no orphaned component/service/route/command; created runtime-facing work is reachable from the declared entrypoint or explicitly deferred to a named integration task}}
73
+ - [ ] Completion decision is canonical: only literal `PASS` may complete after a canonical execution receipt bound to the runtime's expected Base/Head pair and every `workflow_policy.proof_obligations` proof; `PASS_WITH_WARNINGS` stays unfinished, `FAIL` needs fix-and-rerun, and `BLOCKED` plus legacy diagnostics record the blocker or missing proof.
57
74
 
58
75
  ## Evidence
59
76
 
@@ -61,6 +78,8 @@ This section is both the task-level test plan and the proof checklist. Keep it s
61
78
  Select the proof by task risk; do not run every test type for every task.
62
79
 
63
80
  Verification: PENDING
81
+ Canonical verdict: PASS | PASS_WITH_WARNINGS | FAIL | BLOCKED
82
+ Legacy diagnostic input: PARTIAL | NO_TESTS -> unfinished BLOCKED
64
83
 
65
84
  - Logic/data/validator task: include unit tests.
66
85
  - Stateful UI/component task: include component or integration tests.
@@ -74,6 +93,7 @@ Verification: PENDING
74
93
  - [ ] Automated verification (unit/component/integration/E2E as applicable)
75
94
  - Command(s): `{{TYPECHECK / TEST / BUILD COMMANDS OR N/A}}`
76
95
  - Expected proof: {{What output, exit code, or report proves success}}
96
+ - Runtime binding: `policy.createReceiptBinding({ base, head })` must be supplied to completion/flash adapters; a valid-length receipt pair without expected binding is not proof of identity.
77
97
  - [ ] Artifact / runtime verification
78
98
  - Inspect: `{{artifact path | route | UI state | DB object | manifest entry}}`
79
99
  - Expect: {{Observable result that proves the task is really wired}}
@@ -23,8 +23,8 @@ node .claude/scripts/workflow-policy.cjs --classify-lane --task-json '<task JSON
23
23
  ```
24
24
 
25
25
  - Direct may have no spec/state/registry; sync only concrete targeted evidence and never invents approval state.
26
- - Standard stores one bounded spec and one canonical feature receipt; one combined `code-auditor` review gates feature closeout.
27
- - Critical requires strict durable evidence and `inspector → implementer → test-runner → code-auditor` delegation by default.
26
+ - Standard stores one bounded spec and one canonical feature receipt; a combined closeout review is required only when the persisted policy says an independent audit is needed.
27
+ - Critical requires strict durable evidence and the persisted capability obligations; choose available actors or the main session according to required capability and independence, never a fixed actor sequence.
28
28
  - `generated`, `agent_validated`, and `user_approved` are independent. Missing `user_approved` stays false; sync never auto-approves user-owned state.
29
29
  - Explicit lane overrides must preserve automatic classification and warning in receipt/state output, especially Critical downgrades.
30
30
 
@@ -54,20 +54,27 @@ Scans the `spec.json` against all physical `task-R*.md` files to detect mismatch
54
54
  2. **Machine + Human Sync:** Every task status update MUST modify both `spec.json.task_registry[...]` and the matching markdown task file header/status section.
55
55
  3. **Markdown Integrity:** When marking a task `done`, only then turn `[ ]` into `[x]` inside `## Steps` / `## Implementation Steps` and relevant `Completion Criteria` / `Evidence` checkboxes that have actual proof. Use `## Evidence` (legacy heading aliases still parse).
56
56
  4. **Verification Receipt Rule:** `done` is illegal without a human-readable verification receipt already present in `## Evidence` (legacy heading aliases still parse) (commands executed, artifact/runtime proof, or equivalent concrete evidence). If proof is missing, keep the task `in_progress` or `blocked`.
57
- 5. **Task Docs Hook:** Every time `hapo:sync` marks a task as `done`, it must flag that a task-level docs checkpoint is now due for that verified task.
58
- 6. **Phase Prompt Rule:** When `hapo:sync` marks the final pending task in the whole feature as `done`, it should automatically prompt the user if they'd like to advance the phase, but only after the docs checkpoint for that last completed task has been considered.
57
+ 5. **Task Docs Hook:** When `hapo:sync` marks a task as `done`, assess actual documentation impact and report `Docs impact: major|minor|none`; do not create a docs update request when impact is `none`.
58
+ 6. **Phase Prompt Rule:** When the final pending task becomes `done`, a phase-advance prompt may mention documentation only when the impact assessment found affected docs; otherwise continue without a docs ceremony.
59
59
 
60
60
  ### 4. Explicit Flash Finalization
61
61
 
62
- **Usage:** `/hapo:sync <feature_name> <task_id|task-file> sync-finalize`
62
+ **Usage:** `/hapo:sync <feature_name> <task_id|task-file> sync-finalize` (the adapter must call `workflow-policy.cjs --sync-finalize --task-json <current-task> --verdict PASS --proof <canonical-receipt> --json`)
63
63
 
64
- This is the only operation allowed to turn a flash-promoted task (`Verification: PASS`, `status: in_progress`, `readyForSync: true`) into `done` and unblock dependencies. A normal `done` request cannot bypass flash promotion or stale `FLASH_UNVERIFIED` state.
64
+ This is the only operation allowed to turn the current `FLASH_UNVERIFIED` task into `done` and unblock dependencies. The policy derives promotion from that current state and explicit proof; `readyForSync`, `flashTransition`, and `promotionReceipt` supplied by the caller are not proof. A normal `done` request cannot bypass flash promotion or stale `FLASH_UNVERIFIED` state.
65
+
66
+ The current state must be the exact stored form: `status: "in_progress"`,
67
+ `receipt: "FLASH_UNVERIFIED"`, `dependencyBlocked: true`, `unblocks: false`, a
68
+ concrete blocker, and no caller promotion fields. The canonical proof must be
69
+ bound by the runtime adapter with `policy.createReceiptBinding({ base, head })`
70
+ and must match both receipt anchors; arbitrary valid-length Base/Head values do
71
+ not authorize finalization.
65
72
 
66
73
  ### Flash implementation state
67
74
 
68
- Executable policy source: `.claude/scripts/workflow-policy.cjs` (source: `src/claude/scripts/workflow-policy.cjs`). Use `promoteFlashTask` only after exact task Evidence and reachability return PASS; FAIL, BLOCKED, and NO_TESTS remain blocked in progress.
75
+ Executable policy source: `.claude/scripts/workflow-policy.cjs` (source: `src/claude/scripts/workflow-policy.cjs`). Trusted sync-finalize invokes `promoteFlashTask` only after exact task Evidence and reachability return PASS; test PASS itself only supplies canonical proof and leaves the persisted task blocked in progress. FAIL, BLOCKED, and NO_TESTS remain blocked in progress.
69
76
 
70
- `FLASH_UNVERIFIED` is storage for implemented-but-unverified work, not a completion status. Store it as `status: "in_progress"` with blocker `awaiting /hapo:test <feature>`; do not unblock dependencies. `/hapo:test` may promote one task only after its exact Evidence and reachability PASS, replacing the receipt with proof, clearing blocker, and setting `readyForSync: true` while dependencies remain blocked. Only explicit `/hapo:sync ... sync-finalize` may set `done` and unblock. FAIL, BLOCKED, and NO_TESTS remain `in_progress`.
77
+ `FLASH_UNVERIFIED` is storage for implemented-but-unverified work, not a completion status. Store it as `status: "in_progress"` with `dependencyBlocked: true`, `unblocks: false`, a concrete blocker, and no promotion fields; do not unblock dependencies. `/hapo:test` may produce canonical proof, but the supported sync-finalize boundary must receive explicit `--verdict PASS` and `--proof`, require the runtime Base/Head binding, revalidate the receipt/artifact, derive the transition, and only then set `done`. FAIL, BLOCKED, NO_TESTS, marker-only proof, minimal state, and pre-promoted caller JSON remain `in_progress`.
71
78
 
72
79
  ## References
73
80
  Read `references/sync-protocols.md` for exact Search/Replace regex patterns and JSON schema expectations before acting on the files.
@@ -2,7 +2,7 @@
2
2
 
3
3
  The following guidelines dictate exactly how `hapo:sync` should interact with files to prevent data corruption.
4
4
 
5
- **Flash implementation state:** `FLASH_UNVERIFIED` MUST remain `status: "in_progress"` with blocker `awaiting /hapo:test <feature>`. It never unblocks dependencies. A task-scoped `/hapo:test` PASS replaces receipt with real `Verification: PASS`, clears blocker, and sets `readyForSync: true` while dependency blocking remains. Only explicit `/hapo:sync ... sync-finalize` may set `done` and unblock; FAIL, BLOCKED, and NO_TESTS stay `in_progress`.
5
+ **Flash implementation state:** `FLASH_UNVERIFIED` MUST remain the exact stored form: `status: "in_progress"`, `dependencyBlocked: true`, `unblocks: false`, a concrete blocker, and no `readyForSync`, `flashTransition`, or `promotionReceipt` fields. It never unblocks dependencies. The supported sync-finalize adapter must pass the current task, `--verdict PASS`, and canonical `--proof` to `workflow-policy.cjs`; the policy derives promotion, requires a runtime `createReceiptBinding({ base, head })` match for both receipt anchors, revalidates receipt/artifact requirements, and rejects caller-supplied promotion fields before setting `done`. FAIL, BLOCKED, NO_TESTS, marker-only proof, minimal state, and pre-promoted caller JSON stay `in_progress`.
6
6
 
7
7
  **Lane state rule:** classify Direct/Standard/Critical before sync. Direct may omit spec/state/registry for clear, reversible low-risk work; Standard uses one bounded spec and one feature receipt; Critical requires strict durable evidence. Explicit overrides must retain automatic lane, risk signals, and warning. `generated`, `agent_validated`, and `user_approved` are independent booleans; never infer or write `user_approved: true` from agent fields.
8
8
 
@@ -18,7 +18,7 @@ The following guidelines dictate exactly how `hapo:sync` should interact with fi
18
18
  * **Done-State Rule:** Never set `task_registry[path].status = "done"` unless the matching markdown task file already contains a verification receipt in `## Evidence` (legacy heading aliases still parse), or the caller explicitly provides proof that can be written there first.
19
19
  * **Receipt Integrity Rule:** A valid verification receipt must include the exact commands run, their outcomes, and artifact/runtime proof. Receipts containing `PRECHECK_FAIL`, `FAIL`, `UNVERIFIED`, or explicit "placeholder / simplified for MVP / production later" contract deviations are not eligible for `done`.
20
20
  * **Contract Fidelity Rule:** If the task file notes or evidence show that a named framework/auth/runtime choice from the spec was silently replaced, sync MUST refuse `done` until the spec is amended or the implementation is corrected.
21
- * **Task Docs Rule:** After a task is moved to `done`, emit a short alert that a task-level docs checkpoint is due for this verified task.
21
+ * **Task Docs Rule:** After a task is moved to `done`, assess actual documentation impact and report `Docs impact: major|minor|none`. Only affected docs receive a follow-up checkpoint.
22
22
 
23
23
  ## 2. Updating `tasks/task-**.md`
24
24
 
@@ -33,7 +33,7 @@ When `/hapo:sync <feature> <task-id> done`:
33
33
  5. Locate block: `## Steps` or `## Implementation Steps`.
34
34
  6. Convert `- [ ]` into `- [x]` strictly within that section.
35
35
  7. Update relevant checkboxes in `## Completion Criteria` and `## Evidence` (legacy heading aliases still parse) only when the caller provides or the file already contains real proof.
36
- 8. Surface a note such as: `Docs checkpoint due: task Rn-mm just completed`.
36
+ 8. Surface `Docs impact: major|minor|none`; if impact is not `none`, name the affected docs and the follow-up checkpoint.
37
37
 
38
38
  ### B. Blocking a Task
39
39
  When `/hapo:sync <feature> <task-id> blocked "API error"`:
@@ -62,4 +62,4 @@ When `/hapo:sync audit <feature>` is activated:
62
62
  - Either side says `done` but `## Evidence` (legacy heading aliases still parse) has no concrete proof → downgrade to `in_progress` or flag conflict instead of preserving fake completion
63
63
  - Either side says `done` but the receipt contains `PRECHECK_FAIL`, `FAIL`, `UNVERIFIED`, or explicit contract-substitution notes → downgrade to `in_progress` or flag conflict
64
64
  5. **Correction Alert:** Output a brief markdown alert detailing mismatches fixed and any unresolved conflicts requiring manual review.
65
- 6. **Task Docs Alert:** If audit reveals tasks newly marked `done`, include whether task-level docs sync appears still due or already accounted for in the current run summary.
65
+ 6. **Task Docs Alert:** If audit reveals tasks newly marked `done`, include the actual docs impact; do not emit a generic docs-sync request when no docs are affected.