@haposoft/cafekit 0.16.0-rc.2 → 0.16.0-rc.4

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 (98) hide show
  1. package/bin/__tests__/codex-hooks.test.js +794 -21
  2. package/bin/__tests__/codex-native.test.js +228 -7
  3. package/bin/__tests__/develop-contract.test.js +1838 -112
  4. package/bin/__tests__/installer-safety.test.js +82 -29
  5. package/bin/__tests__/opencode-spec-gate.test.js +799 -0
  6. package/bin/__tests__/package-inventory.test.js +841 -10
  7. package/bin/__tests__/specs-v2-execution-closeout.test.js +421 -0
  8. package/bin/__tests__/specs-v2-policy-and-scaffold.test.js +601 -0
  9. package/bin/__tests__/specs-v2-validator-grounder-contract.test.js +952 -0
  10. package/bin/__tests__/test-runtime-dependency-closure.cjs +182 -0
  11. package/bin/__tests__/validator-grounding.test.js +2469 -71
  12. package/bin/lib/managed-writer.js +12 -3
  13. package/bin/phases/codex-runtime.js +17 -1
  14. package/package.json +1 -1
  15. package/src/claude/CLAUDE.md +6 -0
  16. package/src/claude/agents/code-auditor.md +20 -0
  17. package/src/claude/agents/spec-maker.md +153 -202
  18. package/src/claude/hooks/__tests__/completion-authority.test.js +953 -0
  19. package/src/claude/hooks/__tests__/privacy-block.test.js +172 -0
  20. package/src/claude/hooks/__tests__/semantic-review-authority.test.js +257 -0
  21. package/src/claude/hooks/__tests__/spec-gate.test.js +604 -56
  22. package/src/claude/hooks/completion-authority-check.cjs +56 -0
  23. package/src/claude/hooks/completion-authority-state.cjs +527 -0
  24. package/src/claude/hooks/completion-authority.cjs +154 -0
  25. package/src/claude/hooks/docs-sync.cjs +5 -2
  26. package/src/claude/hooks/lib/privacy-command-analysis.cjs +393 -0
  27. package/src/claude/hooks/lib/runtime-path-safety.cjs +119 -0
  28. package/src/claude/hooks/privacy-block.cjs +77 -30
  29. package/src/claude/hooks/semantic-review-authority.cjs +152 -0
  30. package/src/claude/hooks/session.cjs +33 -19
  31. package/src/claude/hooks/spec-gate.cjs +181 -139
  32. package/src/claude/hooks/spec-state.cjs +112 -47
  33. package/src/claude/migration-manifest.json +15 -2
  34. package/src/claude/rules/state-sync.md +52 -21
  35. package/src/claude/rules/workflow.md +17 -9
  36. package/src/claude/scripts/provenance.cjs +315 -0
  37. package/src/claude/scripts/spec-final-state.cjs +244 -0
  38. package/src/claude/scripts/spec-ground.cjs +535 -173
  39. package/src/claude/scripts/spec-readiness.cjs +118 -0
  40. package/src/claude/scripts/spec-receipt.cjs +162 -0
  41. package/src/claude/scripts/spec-resolver.cjs +501 -0
  42. package/src/claude/scripts/spec-scaffold.cjs +1945 -55
  43. package/src/claude/scripts/spec-semantic-model.cjs +396 -0
  44. package/src/claude/scripts/validate-spec-output.cjs +3204 -262
  45. package/src/claude/scripts/workflow-policy.cjs +1888 -203
  46. package/src/claude/settings/settings.json +12 -0
  47. package/src/claude/skills/code-review/SKILL.md +94 -66
  48. package/src/claude/skills/code-review/references/spec-compliance-review.md +10 -2
  49. package/src/claude/skills/code-review/references/verification-gate.md +13 -0
  50. package/src/claude/skills/develop/SKILL.md +138 -283
  51. package/src/claude/skills/develop/references/parallel-waves.md +9 -6
  52. package/src/claude/skills/develop/references/quality-gate.md +123 -148
  53. package/src/claude/skills/develop/references/subagent-patterns.md +42 -37
  54. package/src/claude/skills/specs/SKILL.md +192 -397
  55. package/src/claude/skills/specs/references/ask-user-question-gates.md +27 -18
  56. package/src/claude/skills/specs/references/cross-spec-dependency.md +8 -4
  57. package/src/claude/skills/specs/references/research-strategy.md +4 -1
  58. package/src/claude/skills/specs/references/review.md +200 -260
  59. package/src/claude/skills/specs/references/scope-inquiry.md +18 -5
  60. package/src/claude/skills/specs/rules/design-discovery-full.md +33 -81
  61. package/src/claude/skills/specs/rules/design-discovery-light.md +21 -42
  62. package/src/claude/skills/specs/rules/design-principles.md +136 -180
  63. package/src/claude/skills/specs/rules/design-review.md +42 -97
  64. package/src/claude/skills/specs/rules/ears-format.md +42 -50
  65. package/src/claude/skills/specs/rules/phase-decision-matrix.md +42 -41
  66. package/src/claude/skills/specs/rules/task-scoring-rubric.md +46 -46
  67. package/src/claude/skills/specs/rules/tasks-generation.md +189 -271
  68. package/src/claude/skills/specs/templates/design.md +49 -263
  69. package/src/claude/skills/specs/templates/requirements.md +26 -36
  70. package/src/claude/skills/specs/templates/research.md +9 -98
  71. package/src/claude/skills/specs/templates/spec-state.json +26 -67
  72. package/src/claude/skills/specs/templates/task.md +30 -82
  73. package/src/claude/skills/sync/SKILL.md +45 -15
  74. package/src/claude/skills/sync/references/sync-protocols.md +34 -16
  75. package/src/claude/skills/test/SKILL.md +151 -167
  76. package/src/codex/AGENTS.md +6 -0
  77. package/src/codex/hooks/completion-authority-check.cjs +63 -0
  78. package/src/codex/hooks/completion-authority-state.cjs +527 -0
  79. package/src/codex/hooks/completion-authority.cjs +106 -0
  80. package/src/codex/hooks/lib/hook-context.cjs +58 -4
  81. package/src/codex/hooks/lib/privacy-command-analysis.cjs +3 -0
  82. package/src/codex/hooks/lib/privacy-state.cjs +38 -16
  83. package/src/codex/hooks/lib/runtime-path-safety.cjs +3 -0
  84. package/src/codex/hooks/lib/spec-receipt.cjs +86 -115
  85. package/src/codex/hooks/lib/spec-utils.cjs +104 -27
  86. package/src/codex/hooks/privacy-approval.cjs +1 -1
  87. package/src/codex/hooks/privacy-block.cjs +67 -11
  88. package/src/codex/hooks/semantic-review-authority.cjs +130 -0
  89. package/src/codex/hooks/session.cjs +2 -0
  90. package/src/codex/hooks/spec-gate.cjs +151 -24
  91. package/src/codex/hooks/spec-state.cjs +65 -12
  92. package/src/codex/hooks/state.cjs +2 -0
  93. package/src/codex/hooks.json +16 -1
  94. package/src/codex/rules/state-sync.md +47 -27
  95. package/src/common/AGENTS.md +1 -1
  96. package/src/opencode/AGENTS.md +4 -2
  97. package/src/opencode/plugins/spec-gate.ts +296 -122
  98. package/src/opencode/plugins/spec-state.ts +183 -116
@@ -1,179 +1,154 @@
1
- # Quality Gate — Task Evidence + Two-Stage Review Loop
1
+ # Quality Gate — one closeout, separate proof and review
2
2
 
3
- This is the critical checkpoint protecting codebase quality at Step 4 of `hapo:develop`.
4
- Runs AUTOMATICALLY. Only escalates to user after 3 consecutive failures or a critical block.
5
- Green tests are NOT enough. The gate requires four proofs:
6
- 1. Automated verification (typecheck/test/build)
7
- 2. Spec compliance review (scope/task/design adherence)
8
- 3. Code quality review
9
- 4. Task evidence (completion criteria + runtime/artifact/reachability proof from the task file)
3
+ This reference is loaded at develop closeout. It is an executable contract, not
4
+ a fixed actor checklist. Canonical v2.1 policy input is authoritative; lane and
5
+ `execution_tier` are derived/read-only compatibility views.
10
6
 
11
- `--flash` is the explicit fast path. It bypasses this full gate and uses the Flash Gate defined below.
7
+ ## Inputs and ownership
12
8
 
13
- Executable policy source: `src/claude/scripts/workflow-policy.cjs` (installed as `.claude/scripts/workflow-policy.cjs`). Use its tier delegation, verdict consumer, flash conflict, and promotion semantics; do not duplicate policy in prose or tests.
9
+ The single closeout owner receives the current scope, assurance, risk signals, blast
10
+ radius, exact evidence commands, and the current diff. It calls the test owner
11
+ once, then the review owner once when required. No parallel path, review path,
12
+ or sync hook runs a duplicate hidden gate.
14
13
 
15
- ## Tier input (from develop Delegation policy)
14
+ - **Test owner:** executes commands and creates the canonical execution receipt.
15
+ - **Review owner:** evaluates correctness, security, scope, and spec compliance;
16
+ consumes the receipt but never creates or claims execution proof.
17
+ - **Closeout owner:** combines both results and performs one state/docs sync.
16
18
 
17
- Quality-gate input MUST include `execution_tier` and `ship_point`:
19
+ Review depth follows assurance, risk, and blast radius, not the number of files or
20
+ tasks. There is no fixed Light/Standard/Deep agent sequence. The shared verdict
21
+ surface is `PASS | PASS_WITH_WARNINGS | FAIL | BLOCKED`; all adapters must use
22
+ the same normalizer.
18
23
 
19
- - **Light:** main session runs verification commands and the same spec-compliance checklist. Spawn zero `test-runner` or `code-auditor` subagents.
20
- - **Standard:** main session runs tests and spec checks. At the ship point, run exactly one combined `code-auditor` review for spec compliance plus code quality.
21
- - **Deep / `--parallel`:** retain the documented per-worktree Stage A+B chain in Track A. Do not treat that chain as a permanent product contract.
24
+ ## Working directory (parallel mode)
25
+
26
+ When an opt-in wave is active, each command runs in its task worktree. A
27
+ collapse of one task does not cancel other in-flight tasks; merge and state
28
+ synchronization remain single-writer operations.
29
+
30
+ ## Required evidence
31
+
32
+ Before completion, verify:
33
+
34
+ 1. compile/typecheck precheck and every exact command named by the active
35
+ `Verification Plan`;
36
+ 2. real runtime reachability and declared artifact inspection;
37
+ 3. canonical `receipts/<task-basename>.md` with task identity/path, non-empty
38
+ exact command, successful exit/result, expected versus observed behavior,
39
+ applicable negative/reachability proof, both provenance anchors bound to the
40
+ runtime's expected Base/Head pair, and required SHA-256 declarations;
41
+ 4. correctness/security/spec review at the selected depth;
42
+ 5. a real independent audit when `needsIndependentAudit` is persisted. The
43
+ audit must use schema version `1`, distinct reviewer and implementation
44
+ session IDs, matching expected Base/Head binding, concrete evidence, and
45
+ literal `verdict: "PASS"`.
22
46
 
23
- Checklist and FAIL conditions stay identical for every tier; tier changes only who executes each check and when.
47
+ `PRECHECK_FAIL` outranks no-tests. Missing, pending, marker-only, contradictory,
48
+ or placeholder proof is unfinished. `Audit: PASS` is not an independent audit.
49
+ `NO_TESTS` may be retained as a legacy diagnostic input, but it can never become
50
+ the shared completion verdict `PASS`.
24
51
 
25
52
  ## Spec compliance review
26
53
 
27
- Stage A applies same spec compliance review checklist for every tier: scope, requirements, completion criteria, evidence, and runtime reachability. A missing or unreachable deliverable is a FAIL.
28
-
29
-
30
- - **Specific-task mode:** requested task is ship point. Review that task packet and its diff exactly once.
31
- - **Full-spec Standard:** intermediate tasks receive only the main-session gate. After the final task and Final Integration Scout, run one combined auditor over the cumulative feature diff, all acceptance criteria, and runtime reachability.
32
- - Do not set feature-level `code_done` or completion before combined auditor returns `PASS`.
33
- - Auditor `FAIL` maps each finding to its owning task/surface. Fix only affected evidence, then rerun affected checks and the combined review; do not replay unrelated gates already passed.
34
-
35
- ## Automation Semantics
36
-
37
- - If the task names exact commands in `## Evidence` (legacy heading aliases still parse), those exact commands are mandatory and must run before any fallback repo defaults.
38
- - Preflight compile/typecheck/build health is mandatory. If compile/typecheck/build fails before tests are meaningful, the gate result is `PRECHECK_FAIL`, not `NO_TESTS`.
39
- - `NO_TESTS` is never an automatic PASS.
40
- - `NO_TESTS` is acceptable only when the task does **not** require a dedicated test suite command and every other required automated command/evidence item passes.
41
- - If the task explicitly requires tests and the repo has no such test command or suite, the task is FAIL or BLOCKED, not done.
42
- - If the task kind implies a concrete test type, the gate must enforce it: unit tests for logic/regression, component or integration tests for stateful UI or cross-module wiring, E2E/UI-flow checks for complete user workflows, visual/responsive checks for layout/theme work, accessibility checks for interactive UI, and smoke checks for scaffold/config. Performance/security checks are mandatory only when specified by requirement/risk/boundary.
43
- - Named frameworks, auth systems, transports, datastores, and runtime boundaries in the task/spec are contractual. Silent substitutions are review failures, not acceptable implementation trade-offs.
44
- - Multi-process or multi-runtime flows must prove shared real state or a real boundary contract. Matching in-memory placeholders on both sides do not count as working integration.
45
- - Scope fidelity is mandatory: missing scoped behavior, extra unapproved behavior, or task output that exists only as orphaned/unreachable code is a review failure even when build/tests pass.
46
- - Runtime-facing artifacts must be reachable from the real entrypoint/caller named by the task or the task-aware scout report.
47
-
48
- ### Critical security verification (apply only when the task touches these surfaces)
49
-
50
- No fixed ceremony for every task — apply the checklist below only when the
51
- touched files, risk signals, or task description include logging/redaction or
52
- filesystem write boundaries. Direct uses targeted unit test + diff self-check,
53
- Standard a bounded suite, Critical strict evidence (inspector/test-runner/
54
- code-auditor per lane policy).
55
-
56
- - **Logging / secret redaction:** assert broad matchers did not corrupt safe
57
- identifiers or public URLs; quoted `Bearer`/`Basic` redaction keeps surrounding
58
- quotes and leaves trailing `,`/`;`/whitespace outside the replacement; redaction
59
- is idempotent (`redact(redact(x)) === redact(x)`); no secret appears in test
60
- failures or the verification receipt.
61
- - **Filesystem write boundary:** assert lexical `path.resolve` **and** `realpath` of
62
- the deepest existing parent both stay inside the canonical root; parent-symlink
63
- and final-symlink targets are rejected without following/overwriting; no file
64
- outside root is created or mutated on rejection; write goes via same-directory
65
- temp file + atomic `rename` with cleanup on error; success returns canonical
66
- `realpath` (platform aliases resolved).
54
+ Check scope lock, requirements, design contracts, task Acceptance, Verification
55
+ Plan, runtime reachability, and artifact/provenance boundaries. A missing or orphaned
56
+ runtime deliverable is a failure even when compilation succeeds.
57
+
58
+ **Specific-task mode:** review exactly the requested task and its diff, then
59
+ stop. Do not select a next task.
60
+
61
+ **Full-feature mode:** use the cumulative feature scope only at its closeout;
62
+ intermediate synchronization does not claim feature completion. Run the Final
63
+ Integration Scout when runtime-facing surfaces exist.
64
+
65
+ ## Correctness and security review
66
+
67
+ Apply only the checks relevant to the touched boundary. For logging/redaction,
68
+ check safe identifiers, quoted schemes, idempotence, and receipt secrecy. For
69
+ filesystem writes, check lexical and canonical containment, symlink rejection,
70
+ atomic same-directory replacement, cleanup, and canonical return paths. Add
71
+ auth, persistence, provider, or concurrency checks only when scope/risk requires.
72
+
73
+ ## Quality cycle
74
+
75
+ ```text
76
+ retry_count = 0
77
+ while closeout is not PASS:
78
+ test owner executes required proof once
79
+ if proof is BLOCKED: stop without blind retry
80
+ review owner evaluates correctness/security/spec once
81
+ if FAIL: fix only the affected scope and rerun affected proof/review
82
+ if retry_count reaches 3: stop and request user intervention
83
+ ```
84
+
85
+ Only `FAIL` enters remediation. `BLOCKED` is terminal until its prerequisite
86
+ changes. `PASS_WITH_WARNINGS` is a review result only and remains unfinished;
87
+ only literal `PASS` may close when all execution and policy obligations are
88
+ complete.
67
89
 
68
90
  ## Flash Gate (`--flash`)
69
91
 
70
- Use this only when `/hapo:develop ... --flash` is present.
71
-
72
- - Skip dedicated test commands, E2E/browser/manual QA, full task evidence execution, test-runner delegation, and code-auditor retry loops.
73
- - Do not report `Test PASS`, `Evidence PASS`, `Auto-Approved`, or `production-ready`.
74
- - Still perform a scope sanity check against active task Completion Criteria.
75
- - Still perform a reachability sanity check for runtime-facing files: imported, mounted, registered, routed, or invoked where applicable.
76
- - Run a cheap compile/syntax/typecheck/build command only when available and expected to complete quickly without dependency install or external services.
77
- - If the cheap preflight fails, return to implementation; do not sync.
78
- - If the cheap preflight is unavailable or too slow, record `Preflight: skipped in --flash mode`.
79
- - Sync only with receipt fields:
80
- - `Mode: --flash`
81
- - `Tests: skipped by user request`
82
- - `Evidence: FLASH_UNVERIFIED`
83
- - `Status: in_progress`
84
- - `Blocker: awaiting /hapo:test <feature>`
85
- - `Next verification: /hapo:test <feature>`
92
+ Use only when the flag is explicit. Skip dedicated tests, full evidence
93
+ execution, extended UI/manual checks, and review retry loops. Still perform a
94
+ cheap preflight and scope/reachability sanity check.
86
95
 
87
- Terminal log:
96
+ The flash record must contain exactly the unfinished semantics:
88
97
 
89
98
  ```text
90
- ⚡ Step 4 Flash Gate: tests skipped by --flash; preflight=<pass|skipped>; evidence=FLASH_UNVERIFIED
99
+ Mode: --flash
100
+ Tests: skipped by user request
101
+ Evidence: FLASH_UNVERIFIED
102
+ Status: in_progress
103
+ Blocker: awaiting /hapo:test <feature>
104
+ Next verification: /hapo:test <feature>
91
105
  ```
92
106
 
93
- ## Quality Cycle
107
+ The persisted flash input must also contain `dependencyBlocked: true`,
108
+ `unblocks: false`, and a non-placeholder blocker, and must omit
109
+ `readyForSync`, `flashTransition`, and `promotionReceipt`. Sync-finalize
110
+ rejects minimal or caller-pre-promoted states.
94
111
 
95
- Maximum retry counter: **3 attempts**. Exceeding 3 triggers a collapse warning.
112
+ Terminal log:
96
113
 
97
114
  ```text
98
- Variable: retry_count = 0
99
-
100
- Before START_LOOP:
101
- - Read the active task file(s)
102
- - Extract Related Files, Completion Criteria, `## Evidence` (legacy heading aliases still parse)
103
- - Extract the exact executable verification commands in declaration order
104
- - Extract relevant design contracts/invariants for the touched area
105
- - Extract scope_lock, requirement IDs, runtime entrypoints/callers, and reachability proof obligations
106
- - If any of these are missing or too vague to verify, FAIL immediately and route back to spec correction
107
-
108
- START_LOOP:
109
- ---------------------------------------------------------------
110
- STAGE A: Test + SPEC COMPLIANCE review
111
- ---------------------------------------------------------------
112
- → Light: main session executes exact Evidence commands, spec checklist,
113
- artifact checks, and reachability checks; spawn 0 subagents.
114
- → Standard: main session executes exact Evidence commands and spec checklist;
115
- defer one combined auditor to the ship point.
116
- → Deep / --parallel: run the documented per-task sequence `inspector → implementer → test-runner → code-auditor` in the
117
- task worktree, then preserve its documented merge/integration gates.
118
-
119
- Test result and review result use the review enum only: PASS | FAIL | BLOCKED.
120
- PASS proceeds. FAIL returns actionable findings to implementer. BLOCKED means
121
- execution proof, permissions, environment, or a user-owned decision is missing:
122
- stop immediately and do not blind-retry.
123
-
124
- Standard specific-task ship point:
125
- → run exactly one combined code-auditor review after Stage A PASS.
126
- Standard full-spec ship point:
127
- → run exactly one combined code-auditor review after the final task and
128
- Final Integration Scout over the cumulative feature diff.
129
-
130
- CASE 1 — PRECHECK_FAIL OR Automated FAIL OR required command missing OR Evidence FAIL / UNVERIFIED OR Reachability FAIL:
131
- - For FAIL: increment retry_count; return to implementation while retry_count < 3.
132
- - For BLOCKED: stop without retry; record blocker and await resolution.
133
- - If retry_count >= 3: COLLAPSE and ask for user intervention.
134
-
135
- CASE 2 — Test PASS + Evidence PASS + spec checklist PASS:
136
- → Proceed to the ship-point review for Standard, or the Deep Stage B review.
137
-
138
- STAGE B:
139
- ---------------------------------------------------------------
140
- CODE QUALITY REVIEW (only after spec compliance passes)
141
- ---------------------------------------------------------------
142
- Standard uses the combined auditor described above; Deep retains the existing
143
- Stage B quality review chain inside each worktree.
144
- → PASS = no Critical, no High, at most one Medium; proceed to sync.
145
- → FAIL = findings mapped to task/surface; fix affected scope and rerun only
146
- affected evidence plus this combined review.
147
- → BLOCKED = missing proof/permission/environment/user decision; stop, no blind retry.
115
+ ⚡ Step 4 Flash Gate: tests skipped by --flash; preflight=<pass|skipped>; evidence=FLASH_UNVERIFIED
148
116
  ```
149
117
 
150
- ## Critical Issue Definitions
118
+ Do not report `Test PASS`, `Evidence PASS`, `Auto-Approved`, or
119
+ `production-ready`. Flash never sets `done`, unblocks dependents, or promotes
120
+ from a marker. Trusted sync-finalize alone may consume a fresh canonical PASS
121
+ receipt and derive promotion.
151
122
 
152
- - **Security:** XSS vulnerabilities, SQL injection, leaked env tokens/secrets.
153
- - **Performance:** Bottlenecks, O(n^3) algorithms, unbounded loops over DB calls.
154
- - **Architecture:** Breaking MVC boundaries, cross-module coupling, convention violations.
155
- - **Principles:** YAGNI violations, KISS violations, DRY violations (excessive code duplication).
156
- - **Evidence / Done-Criteria Drift:** Missing required artifacts, placeholder-only wiring, missing entrypoints, unproven completion criteria, or runtime contract mismatches.
157
- - **Reachability Failure:** Orphan components/services/hooks/routes/workers/commands/providers/reducers, unmounted UI, unregistered routes, uncalled data loaders, unused providers, disconnected actions, or any runtime-facing artifact that cannot be reached from the declared entrypoint/caller.
158
- - **Scope Drift:** Scoped acceptance criteria omitted, behavior added outside `scope_lock`, or a task marked complete while part of its approved requirement remains unwired.
159
- - **Overscope Delivery Drift:** Implementing later-task deliverables or editing out-of-scope files without direct justification for the active task packet.
160
- - **Contract Substitution Drift:** Replacing a named framework/auth/transport/datastore/runtime boundary with a custom simplification without a spec amendment.
161
- - **Cross-Service Reality Failure:** Claiming end-to-end behavior across web/api/worker/extension boundaries while state only exists in local process memory or placeholder adapters.
123
+ ## Closeout and docs impact
162
124
 
163
- ## Terminal Log Format
125
+ After the test receipt and review verdict are both available, the closeout owner
126
+ uses the policy adapter and synchronizes state. A review-only pass cannot close
127
+ missing execution proof. Evaluate docs impact from the actual behavior change:
164
128
 
165
- Must log the Quality Gate result to the terminal for user visibility:
129
+ - `none`: record no docs edit and stop;
130
+ - `minor` or `major`: update only affected existing docs through the normal docs
131
+ workflow.
166
132
 
167
- - **Quick Pass:** `✓ Step 4 Quality Gate: Test PASS + Evidence PASS + Spec PASS + Review PASS (no Critical, no High, at most one Medium) - Auto-Approved`
168
- - **Hard-Won Pass:** `✓ Step 4 Quality Gate: Failed 2 rounds → Test PASS + Evidence PASS + Spec PASS + Review PASS (no Critical, no High, at most one Medium)`
169
- - **Preflight Fail:** `[x] Step 4 Quality Gate: PRECHECK_FAIL → compile/typecheck/build failed before tests mattered`
170
- - **Fix Needed:** `[~] Step 4 Quality Gate: Tests/spec/evidence failed → returned to implementer`
171
- - **Awaiting Rescue:** `[!] Step 4 Quality Gate: Failed 3 rounds! Awaiting user intervention...`
133
+ Do not run a docs checkpoint merely because a task completed. Do not refresh the
134
+ whole repository for a local change.
172
135
 
173
- ## Working directory (parallel mode)
136
+ After every task receipt is valid, final integration execution creates
137
+ `feature-receipt.md` once. A task-bearing feature cannot close without all task
138
+ receipts and the feature receipt. A taskless Compact/Full feature closes from a
139
+ valid feature receipt; absence before final closeout is not a failure. Receipts
140
+ never supply or imply approval, readiness, audit status, or product semantics.
141
+
142
+ ## Review threshold
174
143
 
175
- When `hapo:develop` runs in Parallel Wave Mode (`references/parallel-waves.md`), every Stage A and Stage B command for a task executes **with that task's worktree as the working directory**. Gate evidence recorded from the worktree run feeds the task's verification receipt. Thresholds, retry counter, and the COLLAPSE protocol are identical to sequential mode. A COLLAPSE of one task does not cancel other in-flight tasks of the wave.
144
+ `PASS` requires no Critical or High correctness/security/spec finding and no
145
+ blocking Medium finding. `PASS_WITH_WARNINGS` may carry documented non-blocking
146
+ findings. Finding count never selects review depth or overrides missing proof.
147
+ Any missing proof, unresolved obligation, scope drift, contract substitution, or
148
+ reachability failure remains unfinished regardless of review severity.
176
149
 
177
- ## Post-merge integration check (per wave)
150
+ ### Reachability Failure
178
151
 
179
- After the orchestrator cherry-picks the last gate-passed task of a wave: run the project build **or** the affected test subset (never the full suite mid-flight — it runs once at develop completion). While this check fails, the next wave MUST NOT start.
152
+ An unmounted UI, unregistered route, uncalled service/loader, disconnected
153
+ worker/command/provider/reducer, missing artifact consumer, or other orphaned
154
+ runtime-facing output is a review failure.
@@ -1,46 +1,51 @@
1
- # Subagent Invocation Patterns
1
+ # Capability dispatch patterns
2
2
 
3
- Standard prompt templates for delegating work to subagents within the develop workflow.
3
+ This reference is optional. Load it only when the persisted lane requires
4
+ independent capability work. Role names are runtime configuration, not workflow
5
+ policy: resolve them from the installed catalog instead of hardcoding an actor
6
+ name or a sequence in a skill.
4
7
 
5
- ## Agent Tool Pattern
6
- Use the current Claude Code `Agent` tool for subagent invocation. In older runtimes, the same shape may appear as legacy `Task`.
7
- ```
8
- Agent(subagent_type="[agent-name]", prompt="[task description]", description="[short title]")
9
- ```
8
+ ## Dispatch contract
10
9
 
11
- ## Codebase Inspection Phase
12
- ```
13
- Agent(subagent_type="inspector", prompt="Scan and identify all files related to [feature-name] in the current codebase.", description="Scout [feature-name]")
14
- ```
10
+ Every dispatch prompt includes:
15
11
 
16
- ## Code Implementation Phase
17
- ```
18
- Agent(subagent_type="implementer", prompt="Implement the sub-tasks from [tasks-directory] based on the specification in [spec.json]", description="Code Feature [feature]")
19
- ```
12
+ - Work context: the git root of the primary files;
13
+ - Reports path: `<work-context>/plans/reports/`;
14
+ - Plans path: `<work-context>/plans/`;
15
+ - exact task/scope and owned files;
16
+ - lane snapshot, risk/blast-radius obligations, and stop conditions;
17
+ - required output, evidence, and status.
20
18
 
21
- ## UI Implementation Phase
22
- ```
23
- Agent(subagent_type="ui-ux-designer", prompt="Implement the frontend code for [feature] following ./docs/design-guidelines.md", description="Code UI [feature]")
24
- ```
19
+ Use a capability request such as:
25
20
 
26
- ## Code Review Phase
27
- ```
28
- Agent(subagent_type="code-auditor", prompt="Review all recently written code. Check for security holes, performance issues, and adherence to YAGNI/KISS/DRY. Return a verdict (PASS = no Critical, no High, at most one Medium), severity-classified findings, and concrete suggestions.", description="Review [phase]")
21
+ ```text
22
+ dispatch(capability="inspection|implementation|verification|review|docs",
23
+ work_context="<root>",
24
+ scope="<task or feature>",
25
+ owned_files=["<paths>"],
26
+ obligations=["<persisted obligations>"],
27
+ output="<required packet and evidence>")
29
28
  ```
30
29
 
31
- ## Test Execution Phase
32
- ```
33
- Agent(subagent_type="test-runner",
34
- prompt="Run tests for recently implemented code. Apply blast-radius scoping
35
- unless --full is requested. Return structured verdict with Status, Results,
36
- Coverage, Failures, and Action.",
37
- description="Test [feature]")
38
- ```
30
+ The runtime may map a capability to a local role. That mapping must not change
31
+ the lane, add ceremony, or become a new persisted policy field.
39
32
 
40
- ## Parallel Quality Gate (Step 4)
41
- Spawn both simultaneously — do NOT wait for one before starting the other:
42
- ```
43
- Agent(subagent_type="test-runner", prompt="...", description="Test [feature]")
44
- Agent(subagent_type="code-auditor", prompt="...", description="Review [feature]")
45
- ```
46
- Wait for both results → apply quality-gate.md combine logic.
33
+ ## Independence and ownership
34
+
35
+ - Inspection may report entrypoints and blast radius but does not edit source.
36
+ - Implementation edits only the active task scope and does not sync state.
37
+ - Verification is the sole producer of canonical execution proof.
38
+ - Review consumes proof and reports correctness/security/spec findings only.
39
+ - Documentation work is invoked only after a real docs-impact decision.
40
+
41
+ Specific-task mode ends after one task. Full-feature mode may continue only
42
+ after the closeout owner synchronizes the current task and finds another
43
+ unblocked task. A capability result marked `PENDING`, `BLOCKED`, or lacking
44
+ provenance cannot be converted into PASS by the controller.
45
+
46
+ ## Safe fallback
47
+
48
+ If the required capability or isolated workspace is unavailable, keep the
49
+ workflow in `BLOCKED` or run the permitted main-session check. Do not substitute
50
+ a model, profile, or actor silently, and do not claim an independent result
51
+ without an actually independent execution.