@punks/cli 3.3.3 → 3.3.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 (75) hide show
  1. package/AGENTS.md +1 -0
  2. package/dist/BASELINE_CHANGELOG.md +3 -1
  3. package/dist/CHANGELOG.md +7 -1
  4. package/dist/baseline/scaffold-baseline/baseline.json +5 -5
  5. package/dist/baseline/scaffold-baseline/data/catalog/packs.json +2 -1
  6. package/dist/baseline/scaffold-baseline/data/catalog/skills.json +16 -0
  7. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/AUTHORING-HANDOFF.md +12 -0
  8. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/SKILL.md +84 -0
  9. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/agents/openai.yaml +4 -0
  10. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/audit.md +33 -0
  11. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/define-authority.md +26 -0
  12. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/define-handoffs.md +34 -0
  13. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/model-state.md +30 -0
  14. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/qualify.md +27 -0
  15. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/router.md +36 -0
  16. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/test-routes.md +33 -0
  17. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/verify-disclosure.md +28 -0
  18. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/write-phases.md +33 -0
  19. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/write-router.md +30 -0
  20. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/references/authoring-contract.md +226 -0
  21. package/dist/baseline/scaffold-baseline/skills/agnostic/generic/handback/SKILL.md +27 -0
  22. package/dist/baseline/scaffold-baseline/skills/agnostic/quality/autoreview/SKILL.md +9 -4
  23. package/dist/baseline/scaffold-baseline/skills/phases/debugging-phase/SKILL.md +6 -5
  24. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/SKILL.md +5 -1
  25. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/debug.md +2 -2
  26. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/handback.md +23 -0
  27. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/implement.md +2 -0
  28. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/review.md +6 -4
  29. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/router.md +25 -19
  30. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/phase-handoff.md +6 -2
  31. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/return-route.md +14 -9
  32. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/router.md +15 -13
  33. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/run-review.md +3 -2
  34. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/durable-report.md +15 -12
  35. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/runtime-handoff.md +2 -2
  36. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/state-graph.md +5 -1
  37. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/scripts/review-contract.mjs +15 -4
  38. package/dist/baseline/scaffold-baseline.json +5 -5
  39. package/dist/baseline/scaffold-baseline.tgz +0 -0
  40. package/dist/data/AGENTS.md +1 -0
  41. package/dist/data/shared-agents.md +113 -0
  42. package/dist/index.js +15 -9
  43. package/dist/skills/agnostic/docs/write-graph-based-skills/AUTHORING-HANDOFF.md +12 -0
  44. package/dist/skills/agnostic/docs/write-graph-based-skills/SKILL.md +84 -0
  45. package/dist/skills/agnostic/docs/write-graph-based-skills/agents/openai.yaml +4 -0
  46. package/dist/skills/agnostic/docs/write-graph-based-skills/phases/audit.md +33 -0
  47. package/dist/skills/agnostic/docs/write-graph-based-skills/phases/define-authority.md +26 -0
  48. package/dist/skills/agnostic/docs/write-graph-based-skills/phases/define-handoffs.md +34 -0
  49. package/dist/skills/agnostic/docs/write-graph-based-skills/phases/model-state.md +30 -0
  50. package/dist/skills/agnostic/docs/write-graph-based-skills/phases/qualify.md +27 -0
  51. package/dist/skills/agnostic/docs/write-graph-based-skills/phases/router.md +36 -0
  52. package/dist/skills/agnostic/docs/write-graph-based-skills/phases/test-routes.md +33 -0
  53. package/dist/skills/agnostic/docs/write-graph-based-skills/phases/verify-disclosure.md +28 -0
  54. package/dist/skills/agnostic/docs/write-graph-based-skills/phases/write-phases.md +33 -0
  55. package/dist/skills/agnostic/docs/write-graph-based-skills/phases/write-router.md +30 -0
  56. package/dist/skills/agnostic/docs/write-graph-based-skills/references/authoring-contract.md +211 -0
  57. package/dist/skills/agnostic/generic/handback/SKILL.md +27 -0
  58. package/dist/skills/agnostic/quality/autoreview/SKILL.md +9 -4
  59. package/dist/skills/frameworks/nestjs/nestjs-best-practices/.gitignore +29 -0
  60. package/dist/skills/phases/debugging-phase/SKILL.md +6 -5
  61. package/dist/skills/phases/delivery-phase/SKILL.md +5 -1
  62. package/dist/skills/phases/delivery-phase/phases/debug.md +2 -2
  63. package/dist/skills/phases/delivery-phase/phases/handback.md +23 -0
  64. package/dist/skills/phases/delivery-phase/phases/implement.md +2 -0
  65. package/dist/skills/phases/delivery-phase/phases/review.md +6 -4
  66. package/dist/skills/phases/delivery-phase/phases/router.md +23 -17
  67. package/dist/skills/phases/delivery-phase/references/phase-handoff.md +6 -2
  68. package/dist/skills/phases/review-phase/phases/return-route.md +14 -9
  69. package/dist/skills/phases/review-phase/phases/router.md +15 -13
  70. package/dist/skills/phases/review-phase/phases/run-review.md +3 -2
  71. package/dist/skills/phases/review-phase/references/durable-report.md +10 -8
  72. package/dist/skills/phases/review-phase/references/runtime-handoff.md +2 -2
  73. package/dist/skills/phases/review-phase/references/state-graph.md +5 -1
  74. package/dist/skills/phases/review-phase/scripts/review-contract.mjs +2 -0
  75. package/package.json +9 -52
@@ -0,0 +1,226 @@
1
+ # Authoring Contract for Durable Workflow Graph Skills
2
+
3
+ Use this contract when you are creating a graph-based skill, converting a linear multi-step skill, or auditing and repairing routing failures.
4
+
5
+ ## Authoring Phase Outcome
6
+
7
+ Every creator phase writes or updates its entry in `<target-skill>/AUTHORING-HANDOFF.md`. The authoring router discovers the record at that exact path. This authoring record is separate from the target skill's runtime handoff contract.
8
+
9
+ ```text
10
+ Phase:
11
+ Status:
12
+ Scope:
13
+ Artifacts:
14
+ Validation:
15
+ Domain state:
16
+ UI Evidence:
17
+ Next suggested route:
18
+ Blockers:
19
+ Resume identity:
20
+ ```
21
+
22
+ Status is phase-scoped. Keep artifacts and validation separate, use domain state for authoring decisions or unresolved obligations, and omit UI evidence when it is not applicable. The next suggested route is advisory; router re-entry derives the route from current evidence. Resume identity contains only run, revision, attempt, or dependency fields that current artifacts cannot reconstruct reliably.
23
+
24
+ ## Obligation Map
25
+
26
+ | Obligation | Mandatory | Survives interruption | Evidence artifact | Owner | Audit criterion |
27
+ | ---------- | --------- | --------------------- | ----------------- | ----- | --------------- |
28
+ | | | | | | |
29
+ | | | | | | |
30
+
31
+ Freshness note:
32
+
33
+ - Assign freshness checks wherever evidence can change while waiting.
34
+
35
+ Default decision:
36
+
37
+ - Use a graph for every multi-step skill.
38
+ - Use direct composition only for one atomic, discardable, cheap-to-restart action with no routing, repair, or resume obligation.
39
+
40
+ Completion criterion:
41
+
42
+ - Mandatory obligations each include evidence artifact and audit criterion.
43
+ - Graph authoring is selected unless the direct-composition exception is proved.
44
+
45
+ ## State and Topology
46
+
47
+ ### State Table
48
+
49
+ | State ID | Meaning | Scope | Entry guard | Exit guard | Next states |
50
+ | -------- | ------- | ----- | ----------- | ---------- | ----------- |
51
+ | | | | | | |
52
+ | | | | | | |
53
+
54
+ ### Gate Table
55
+
56
+ | Gate ID | Entry guard | Actor-like gate boundary owner | Internal delegation policy | Reconciliation rule | Outputs | Exit semantics | Durable handoff |
57
+ | ------- | ----------- | ------------------------------ | -------------------------- | ------------------- | ------- | -------------- | --------------- |
58
+ | | | | | | | | |
59
+ | | | | | | | | |
60
+
61
+ ### Graph Layer
62
+
63
+ | Path | Branch condition | Cycle target | Skip condition | Checkpoint condition |
64
+ | ---- | ---------------- | ------------ | -------------- | -------------------- |
65
+ | | | | | |
66
+ | | | | | |
67
+
68
+ Completion criterion:
69
+
70
+ - Every state defines scope, entry guard, exit guard, and next states.
71
+ - Every branch/cycle/skip/checkpoint form is represented in Graph Layer or marked N/A.
72
+
73
+ ## Transition Guards and Precedence
74
+
75
+ | Transition | Evidence condition | Freshness | Scope | Validity | Conflicts | Tie-break rule | Derived route |
76
+ | ---------- | ------------------ | --------- | ----- | -------- | --------- | -------------- | ------------- |
77
+ | | | | | | | | |
78
+ | | | | | | | | |
79
+
80
+ Authority table:
81
+
82
+ | Signal | Priority | Allowed when conditions pass |
83
+ | ------------------------------- | -------- | -------------------------------------- |
84
+ | Current direct evidence | 1 | evidence is direct and admissible |
85
+ | Fresh workflow-native artifacts | 2 | artifact is fresh, valid, and in scope |
86
+ | Committed handoff | 3 | handoff is committed and intact |
87
+ | Suggested route | 4 | suggestion only |
88
+
89
+ Completion criterion:
90
+
91
+ - Every ambiguous set has an explicit precedence path and deterministic tie-break to one route.
92
+
93
+ ## Router Contract
94
+
95
+ Inputs:
96
+
97
+ - current evidence,
98
+ - active obligations,
99
+ - current artifacts,
100
+ - committed handoffs,
101
+ - terminal flags.
102
+
103
+ Outputs:
104
+
105
+ - Exactly one of:
106
+ 1. one selected gate,
107
+ 2. one terminal route,
108
+ 3. one checkpoint route,
109
+ 4. one blocked route.
110
+
111
+ Rules:
112
+
113
+ - Router names the internal transition contract.
114
+ - Decision recomputes on re-entry and cold resume using the authority table.
115
+
116
+ Completion criterion:
117
+
118
+ - one output route for each legal state.
119
+
120
+ ## Human Steering Terminal
121
+
122
+ Every graph includes `human_steering_required` as a terminal, non-success
123
+ state. The gate that selects it invokes `$handback`, writes that skill's durable
124
+ outcome, and stops. The router keeps returning the terminal until the
125
+ `$handback` authority guard passes.
126
+
127
+ ## Gate Contract
128
+
129
+ For each gate define:
130
+
131
+ - Entry guard.
132
+ - Actor-like gate boundary and bounded ownership.
133
+ - Optional internal delegation.
134
+ - Reconciliation plan for delegated work.
135
+ - Output artifacts and validation.
136
+ - Exit semantics in workflow-owned vocabulary.
137
+ - Durable handoff.
138
+
139
+ Use this category shape for each produced target handoff:
140
+
141
+ ```text
142
+ Phase:
143
+ Status:
144
+ Scope:
145
+ Artifacts:
146
+ Validation:
147
+ Domain state:
148
+ UI Evidence:
149
+ Next suggested route:
150
+ Blockers:
151
+ Resume identity:
152
+ ```
153
+
154
+ Status remains phase-scoped, while the domain-state label uses workflow-specific vocabulary; for example, a delivery workflow may use `Review/debug/docs state`. UI evidence is optional. Resume identity includes only run, revision, attempt, or dependency fields required for reliable resume.
155
+
156
+ Across the graph, exit semantics coverage must include applicable operational outcomes:
157
+
158
+ - successful completion,
159
+ - blockers,
160
+ - intentional skip or no-op,
161
+ - human checkpoint.
162
+
163
+ The [human steering terminal](#human-steering-terminal) is distinct from a
164
+ planned human checkpoint.
165
+
166
+ Completion criterion:
167
+
168
+ - across the graph, coverage includes applicable completion, blocker, skip-or-no-op, and human-checkpoint meanings.
169
+ - each gate lists only outcomes it can emit.
170
+ - each actor-like gate boundary owns only its bounded work, and every exit writes a durable handoff.
171
+
172
+ ## Durable Handoff Questions
173
+
174
+ Ask only for state that the router cannot infer from current evidence:
175
+
176
+ - Which gate-local facts cannot be reconstructed from current artifacts?
177
+ - Which uncertainty blocks deterministic continuation?
178
+ - What exact evidence is missing to choose a safe next route?
179
+ - What minimum preserved state is needed for a reliable resume?
180
+
181
+ Optional note:
182
+
183
+ - A route suggestion may be attached but remains optional and lowest authority.
184
+
185
+ Completion criterion:
186
+
187
+ - each selected question is workflow-specific and captures state current evidence cannot infer.
188
+
189
+ ## Route Matrix (ten scenarios)
190
+
191
+ | Scenario | Predicted route (record first) | Derived route (apply contracts) | Match | Repair if mismatch |
192
+ | ------------------------------------------------------------- | ------------------------------ | ------------------------------- | ----- | ------------------ |
193
+ | Baseline path | | | | |
194
+ | Branch path | | | | |
195
+ | Repair cycle | | | | |
196
+ | Human checkpoint | | | | |
197
+ | Failure handback terminal | | | | |
198
+ | Cold resume | | | | |
199
+ | Stale, out-of-scope, or invalid artifact | | | | |
200
+ | Contradictory suggested route loses to evidence | | | | |
201
+ | Nested executor substitution with an actor-like gate boundary | | | | |
202
+ | Premature completion rejected by terminal guard | | | | |
203
+
204
+ Completion criterion:
205
+
206
+ - all ten rows are filled with stale, out-of-scope, and invalid as subcases.
207
+ - the failure-handback row proves the `human_steering_required` terminal and
208
+ `$handback` authority guard; the planned human-checkpoint row remains distinct.
209
+ - repairs are present only when match is No.
210
+
211
+ ## Final Audit
212
+
213
+ - All mandatory obligations map to states and gates.
214
+ - Router and gates are deterministic under the authority table.
215
+ - Cold resume derives from current evidence, workflow-native artifacts, and committed handoffs.
216
+ - Every exit commits a durable handoff.
217
+ - `human_steering_required` invokes `$handback`, commits its outcome, and keeps
218
+ the terminal until that skill's authority guard passes.
219
+ - Terminal guard accounts for every mandatory obligation.
220
+ - The skill-protocol boundary is the set of written contracts and durable evidence.
221
+ - Markdown cannot enforce exclusive writers, execution ordering, or atomic persistence; require an external runtime only when one of those guarantees is a correctness requirement.
222
+ - Progressive-disclosure context-load trace shows bootstrap/router and the single selected gate only.
223
+
224
+ Completion criterion:
225
+
226
+ - all decisions required for safe route reconstruction and resume are resolved.
@@ -0,0 +1,27 @@
1
+ ---
2
+ name: handback
3
+ description: Hand control back when a blocker or proposed next step crosses accepted goal bounds, changes accepted requirements, weakens a gate, or substantially redesigns implementation.
4
+ ---
5
+
6
+ # Handback
7
+
8
+ Autonomy applies only while the next action remains inside the accepted goal.
9
+
10
+ Return `human_steering_required` with:
11
+
12
+ - initial goal and accepted bounds
13
+ - current phase and last known-good state
14
+ - attempts and evidence
15
+ - blocker and what it prevents
16
+ - proposed next action
17
+ - why it changes scope or authority
18
+ - exact human decision required
19
+
20
+ Preserve completed in-bounds work, then stop. The authority guard passes only
21
+ on explicit human authorization for the proposed next action. A proposal is not
22
+ authority. “All steps”, “full
23
+ delivery”, “do not stop”, and equivalent persistence language apply only within
24
+ accepted bounds.
25
+
26
+ `human_steering_required` is a terminal, non-success outcome. Expanded design,
27
+ implementation, delegation, and recursive review begin only after authority.
@@ -22,9 +22,12 @@ Use when:
22
22
  - Read dependency docs/source/types when the finding depends on external behavior.
23
23
  - Reject unrealistic edge cases, speculative risks, broad rewrites, and fixes that over-complicate the codebase.
24
24
  - Prefer small fixes at the right ownership boundary; no refactor unless it clearly improves the bug class.
25
- - Outside `review-phase`, keep going until structured review returns no
26
- accepted/actionable findings. If a review-triggered fix changes code, rerun
27
- focused tests and the structured review helper.
25
+ - Outside `review-phase`, run the structured review helper exactly once. Verify
26
+ candidates, fix only accepted findings inside the accepted goal, and run
27
+ focused tests for changed code. End this invocation without rerunning the
28
+ helper. A further direct pass requires formal `$review-phase` or a new
29
+ explicit user instruction after this result.
30
+ - When a finding triggers `$handback`, invoke it before any expanded repair.
28
31
  - For security-audit suppression changes, verify accepted findings remain auditable: suppressed findings stay in structured output, active output keeps an unsuppressible suppression notice, and aggregate findings cannot hide unrelated active risk.
29
32
  - Never switch or override the requested review engine/model. If the review hits model capacity, retry the same command a few times with the same engine/model.
30
33
  - Be patient with large bundles. Structured review can take up to 30 minutes while the model call is active, especially with Codex tools or web search.
@@ -109,7 +112,9 @@ Format first if formatting can change line locations. Then it is OK to run tests
109
112
  scripts/autoreview --parallel-tests "<focused test command>"
110
113
  ```
111
114
 
112
- Tradeoff: tests may force code changes that stale the review. If tests or review lead to code edits, rerun the affected tests and rerun review until no accepted/actionable findings remain. Once that rerun exits cleanly, stop; do not spend another long review cycle on redundant confirmation.
115
+ Tradeoff: tests may force code changes that stale the review. If tests or review
116
+ lead to code edits, rerun the affected tests, then apply the direct-call
117
+ contract above.
113
118
 
114
119
  ## Review Panels
115
120
 
@@ -17,7 +17,7 @@ description: >-
17
17
  - **Delivery-internal inputs:** `implement-spec` validation failure or `review-phase` runtime failure
18
18
  - **Wraps:** `$verify-behavior`, `$debug-agent`, optional readonly `$parallel-research`, bounded fixes, focused tests or scenario reruns, review
19
19
  - **Owns:** evidence matrices, cited log references, hypothesis status, fix verification
20
- - **Exit conditions:** bug fixed, concrete blocker proven, or scope proven to require a spec/delivery goal
20
+ - **Exit conditions:** bug fixed, concrete blocker proven, or `human_steering_required`
21
21
 
22
22
  ## Use When
23
23
 
@@ -30,7 +30,7 @@ description: >-
30
30
 
31
31
  - The work is pure planning, requirements discovery, or design.
32
32
  - The failure is already proven and only needs implementation inside an active spec plan.
33
- - The fix would require broad product scope, architecture, or acceptance changes; exit to `create-spec`, `create-plan`, or a delivery goal instead.
33
+ - The next action triggers `$handback`; return human steering instead.
34
34
  - The request is only static code review with no runtime symptom.
35
35
 
36
36
  ## Workflow
@@ -42,7 +42,7 @@ description: >-
42
42
  2. **Set bounds.**
43
43
  - Define owned files, systems, and scenarios.
44
44
  - For delivery-internal debugging, patch only inside the active delivery scope.
45
- - If the evidence points outside that scope, record debt or open a separate debugging/debt goal.
45
+ - When the next action triggers `$handback`, invoke it and stop.
46
46
  3. **Reproduce visible behavior.**
47
47
  - Before forming hypotheses or starting fix work, run `$verify-behavior` in
48
48
  `reproduce` mode when the reported behavior is visibly exercisable.
@@ -71,7 +71,7 @@ description: >-
71
71
  8. **Exit.**
72
72
  - Fixed: report cause, patch, verification, and residual risk.
73
73
  - Blocked: report the concrete blocker and the missing artifact/access/action.
74
- - Out of scope: report why this needs a spec/delivery goal or debt issue.
74
+ - Human steering: return the durable `$handback` outcome and stop.
75
75
 
76
76
  ## Parallel Rules
77
77
 
@@ -83,6 +83,7 @@ description: >-
83
83
  - Never let parallel workers make speculative fixes against unproven hypotheses.
84
84
  - Merge worker findings into one evidence matrix before deciding on a patch.
85
85
  - In delivery-internal mode, parallel workers must stay inside the delivery scope unless assigned readonly investigation.
86
+ - A `$handback` trigger ends fix delegation.
86
87
 
87
88
  ## Output Contract
88
89
 
@@ -94,4 +95,4 @@ Return a concise debugging report with:
94
95
  - **Root cause:** confirmed cause or why none is proven
95
96
  - **Changes:** bounded patch summary, or none if blocked/out of scope
96
97
  - **Verification:** commands/scenarios rerun and result
97
- - **Exit:** fixed, blocked, or escalated to spec/delivery/debt
98
+ - **Exit:** fixed, blocked, or `human_steering_required`
@@ -17,7 +17,7 @@ disable-model-invocation: true
17
17
  4. Load exactly one phase file from `phases/`.
18
18
  5. Complete that phase and write its outcome. Full delivery re-enters routing immediately; other modes stop at their selected boundary.
19
19
 
20
- Full delivery grants its selected inner steps the authority needed to reach closeout. Progressive loading still exposes one phase at a time.
20
+ Within accepted bounds, full delivery grants its selected inner steps the authority needed to reach closeout. Progressive loading still exposes one phase at a time.
21
21
 
22
22
  ## Entry Modes
23
23
 
@@ -36,6 +36,7 @@ Full delivery grants its selected inner steps the authority needed to reach clos
36
36
  - [phases/review.md](phases/review.md): prepare the explicit review handoff or
37
37
  classify findings from a retained report.
38
38
  - [phases/debug.md](phases/debug.md): investigate runtime-evidence failures.
39
+ - [phases/handback.md](phases/handback.md): return a scope or authority boundary for human steering.
39
40
  - [phases/docs-ingest.md](phases/docs-ingest.md): ingest docs-affecting changes or record a no-op.
40
41
  - [phases/closeout.md](phases/closeout.md): finish tracker, PR, validation, and final report state.
41
42
 
@@ -52,9 +53,12 @@ Full delivery grants its selected inner steps the authority needed to reach clos
52
53
  - After a phase completes, write enough state for future resume. Review-triggered
53
54
  repair uses the idempotent fields in
54
55
  [references/phase-handoff.md](references/phase-handoff.md).
56
+ - Boundary evidence selects [handback.md](phases/handback.md). Persistence
57
+ remains autonomous only inside accepted bounds.
55
58
 
56
59
  ## Stop Conditions
57
60
 
58
61
  - User explicitly requested a HITL checkpoint or one-phase mode and its resumable state was written.
59
62
  - Router reaches closeout and final evidence is reported.
60
63
  - Scope is ambiguous, stale, contradictory, or blocked by missing access.
64
+ - `human_steering_required` is durable while the `$handback` authority guard fails.
@@ -14,8 +14,8 @@ Load `debugging-phase` only after this phase is selected.
14
14
  trace, reproduction, or review finding.
15
15
  - Readonly parallel hypothesis research is allowed.
16
16
  - Speculative parallel fixes are not allowed.
17
- - If the bug is broader than delivery scope, capture debt or open a separate
18
- debugging goal.
17
+ - When current evidence triggers `$handback`, return it to the router without
18
+ opening another goal.
19
19
  - Preserve review lineage, `review_count`, `repair_count`, and the opening
20
20
  `review_run_id` through the repair.
21
21
  - After an ordinary fix with `review_count < 3`, stale the preceding report and
@@ -0,0 +1,23 @@
1
+ # Handback Phase
2
+
3
+ ## Guard
4
+
5
+ The router selected current evidence that triggers `$handback`.
6
+
7
+ ## Bounded Action
8
+
9
+ 1. Invoke `$handback` with the active delivery evidence.
10
+ 2. Persist its complete outcome as `human_steering_required` in the delivery
11
+ handoff.
12
+ 3. Stop.
13
+
14
+ ## Completion Evidence
15
+
16
+ - the durable `$handback` outcome
17
+ - unchanged accepted bounds and in-bounds artifacts
18
+ - no expanded design, implementation, delegation, or review
19
+
20
+ ## Exit
21
+
22
+ Return terminal `human_steering_required`. Resume routing only after the
23
+ `$handback` authority guard passes.
@@ -15,6 +15,8 @@ Load `implement-spec` only after this phase is selected.
15
15
  - Use a one-worker wave only when dependencies or ownership leave one task
16
16
  unblocked.
17
17
  - Keep changes inside the active delivery scope.
18
+ - When current evidence triggers `$handback`, return it to the router without
19
+ expanding worker ownership.
18
20
  - Parent orchestration owns shared notes and final validation evidence.
19
21
  - For UI work, require `implement-spec` to carry durable before/after links through `UI Evidence Links`; use `repo-asset-management` only through that evidence contract.
20
22
  - If runtime evidence appears during validation, finish the phase handoff and route to debug.
@@ -33,14 +33,16 @@ After the retained report establishes the completed ordinal:
33
33
  1. Recompute aggregate routing from every finding's validated `return_route`
34
34
  with the review contract helper. Reject a mismatch with the retained routing
35
35
  object.
36
- 2. When `secondary_architecture_follow_up` is true, enter `debt_follow_up`
36
+ 2. For primary `human_steering_required`, preserve the returned `$handback`
37
+ outcome and stop. It never opens a repair state.
38
+ 3. When `secondary_architecture_follow_up` is true, enter `debt_follow_up`
37
39
  first and persist the primary `debugging` or `implementation` route as
38
40
  `post_debt_route`.
39
- 3. Without secondary debt, `debugging` opens debugging and `implementation`
41
+ 4. Without secondary debt, `debugging` opens debugging and `implementation`
40
42
  opens implementation.
41
- 4. Primary `debt_follow_up` enters debt capture with `post_debt_route` set to
43
+ 5. Primary `debt_follow_up` enters debt capture with `post_debt_route` set to
42
44
  `docs_ingest` when documentation remains, otherwise `closeout`.
43
- 5. `docs_ingest` enters docs ingest. `closeout` enters closeout.
45
+ 6. `docs_ingest` enters docs ingest. `closeout` enters closeout.
44
46
 
45
47
  Architecture debt may remain a secondary follow-up beside debugging or
46
48
  implementation. Open its repair only after debt capture. Opening either repair
@@ -13,51 +13,54 @@ state take precedence over inferred artifact order.
13
13
 
14
14
  ## Route
15
15
 
16
- 1. Stop on unclear goal bounds and ask one concrete question.
17
- 2. For durable `review_due`, load [review.md](review.md). It first validates
16
+ 1. For durable `human_steering_required`, stop until the `$handback` authority
17
+ guard passes.
18
+ 2. When current evidence triggers `$handback`, load [handback.md](handback.md).
19
+ 3. Stop on unclear goal bounds and ask one concrete question.
20
+ 4. For durable `review_due`, load [review.md](review.md). It first validates
18
21
  accepted bounds and normalizes a supported target. A rejection enters
19
22
  `review_failed` even when a persisted counter is 3. Only after those checks
20
23
  may it recover `review_count` and evaluate the budget in memory. Exhaustion
21
24
  returns `review_budget_exhausted` with zero handoff or status writes. A count
22
25
  below 3 persists `review_due`. Full delivery activates `$review-phase` with
23
26
  that context; other modes return the exact explicit invocation context and stop.
24
- 3. For `report_retention_pending`, load [review.md](review.md) to resume
27
+ 5. For `report_retention_pending`, load [review.md](review.md) to resume
25
28
  `$review-phase` in full delivery or return its exact resume context in other
26
29
  modes. A fresh local report resumes without rerunning lenses. Stop on terminal
27
30
  `review_failed` with its exact evidence.
28
- 4. Otherwise recover review state by `review_lineage_id`: read the highest valid
31
+ 6. Otherwise recover review state by `review_lineage_id`: read the highest valid
29
32
  retained ordinal, reconcile the handoff `review_count` projection, then assess
30
33
  target and source freshness separately.
31
- 5. Route a fresh retained `review_routed` report through [review.md](review.md)
34
+ 7. Route a fresh retained `review_routed` report through [review.md](review.md)
32
35
  when no durable route handoff exists yet.
33
- 6. Resume an atomic handoff already in `debug_active` through [debug.md](debug.md)
36
+ 8. Resume an atomic handoff already in `debug_active` through [debug.md](debug.md)
34
37
  or `repair_active` through [implement.md](implement.md). A recorded
35
38
  `review_run_id` cannot increment `repair_count` again.
36
- 7. Resume `debt_follow_up` through [review.md](review.md). Its handler reuses or
39
+ 9. Resume `debt_follow_up` through [review.md](review.md). Its handler reuses or
37
40
  records the goal/spec-linked debt artifact, then follows durable
38
41
  `post_debt_route`: `debugging` or `implementation` for secondary debt;
39
42
  `docs_ingest` or `closeout` for primary debt. It never implements the debt.
40
- 8. Route `focused_validation` to its recorded implementation or debugging owner.
41
- Passing becomes `clean_handoff`; failure remains repair epoch 3.
42
- 9. Route `clean_handoff` to [docs-ingest.md](docs-ingest.md) when docs remain,
43
- otherwise [closeout.md](closeout.md).
44
- 10. For durable `docs_ingest`, load [docs-ingest.md](docs-ingest.md).
45
- 11. For durable `closeout`, load [closeout.md](closeout.md).
46
- 12. If no matching agent-ready `SPEC.md` exists, it is stale, contradictory, or
43
+ 10. Route `focused_validation` to its recorded implementation or debugging owner.
44
+ Passing becomes `clean_handoff`; failure remains repair epoch 3.
45
+ 11. Route `clean_handoff` to [docs-ingest.md](docs-ingest.md) when docs remain,
46
+ otherwise [closeout.md](closeout.md).
47
+ 12. For durable `docs_ingest`, load [docs-ingest.md](docs-ingest.md).
48
+ 13. For durable `closeout`, load [closeout.md](closeout.md).
49
+ 14. If no matching agent-ready `SPEC.md` exists, it is stale, contradictory, or
47
50
  incomplete, or its remote retention or stable blob URL is missing or
48
51
  unverified, load [spec.md](spec.md).
49
- 13. If the verified post-spec backlog projection is missing or stale, load
52
+ 15. If the verified post-spec backlog projection is missing or stale, load
50
53
  [backlog.md](backlog.md).
51
- 14. If no execution-ready matching plan exists, or it lacks dependencies, owned
54
+ 16. If no execution-ready matching plan exists, or it lacks dependencies, owned
52
55
  paths, validation gates, or wave boundaries, load [plan.md](plan.md).
53
- 15. If accepted plan work is incomplete, load [implement.md](implement.md).
54
- 16. If implementation exists and its retained review is missing or stale, load
56
+ 17. If accepted plan work is incomplete, load [implement.md](implement.md).
57
+ 18. If implementation exists and its retained review is missing or stale, load
55
58
  [review.md](review.md). That phase validates accepted bounds and normalizes a
56
59
  supported target before any delivery-budget evaluation, then returns either
57
60
  `review_failed`, `review_budget_exhausted`, or a valid `$review-phase`
58
61
  context. Full delivery consumes that context immediately; other modes
59
62
  return the exact explicit invocation context and stop.
60
- 17. Route remaining docs-affecting work to [docs-ingest.md](docs-ingest.md),
63
+ 19. Route remaining docs-affecting work to [docs-ingest.md](docs-ingest.md),
61
64
  otherwise [closeout.md](closeout.md).
62
65
 
63
66
  Only an explicitly new delivery goal with materially changed accepted bounds
@@ -71,6 +74,9 @@ delivery otherwise continues across ordinary in-bounds operations without
71
74
  confirmation. Earlier phases may have completed through direct skills; reuse
72
75
  fresh matching artifacts rather than rerunning them.
73
76
 
77
+ `human_steering_required` is a terminal boundary, not an optional HITL
78
+ checkpoint.
79
+
74
80
  ## Output
75
81
 
76
82
  Report the selected state and phase, the durable evidence that selected it, the
@@ -6,7 +6,7 @@ Each phase leaves enough durable state for resume without guessing.
6
6
 
7
7
  ```text
8
8
  Phase:
9
- Status: complete | blocked | skipped
9
+ Status: complete | blocked | skipped | human_steering_required
10
10
  Scope:
11
11
  Artifacts:
12
12
  Validation:
@@ -30,7 +30,7 @@ accepted_bounds_identity:
30
30
  accepted_bounds_hash:
31
31
  review_lineage_id:
32
32
  review_run_id:
33
- state: review_due | review_running | report_retention_pending | review_routed | debt_follow_up | debug_active | repair_active | focused_validation | docs_ingest | closeout | clean_handoff
33
+ state: review_due | review_running | report_retention_pending | review_routed | debt_follow_up | debug_active | repair_active | focused_validation | docs_ingest | closeout | clean_handoff | human_steering_required
34
34
  primary_route:
35
35
  secondary_architecture_follow_up:
36
36
  post_debt_route:
@@ -93,3 +93,7 @@ other modes return the context for explicit retry without rerunning lenses.
93
93
 
94
94
  After fix 3, `clean_handoff` is final authority. Link immutable review 3, final
95
95
  changes, the same passing focused validation, and clean status.
96
+
97
+ For `human_steering_required`, store the complete `$handback` outcome under
98
+ `Blockers`. Keep the state terminal until the `$handback` authority guard
99
+ passes.
@@ -33,27 +33,30 @@ debug, debt, documentation, or closeout work.
33
33
  immutable authority block inside those retained bytes.
34
34
  2. Pass the complete retained finding set to the public `deriveReviewRouting`
35
35
  helper. Each non-empty finding already carries one validated `return_route`.
36
- The helper applies `debugging` > `implementation` > `debt_follow_up` >
37
- `docs_ingest`; an empty set returns `closeout`.
36
+ The helper applies `human_steering_required` > `debugging` >
37
+ `implementation` > `debt_follow_up` > `docs_ingest`; an empty set returns
38
+ `closeout`.
38
39
  3. Accept `secondary_architecture_follow_up` only when a `debt_follow_up`
39
40
  finding accompanies a higher-priority debugging or implementation route.
40
41
  4. Require the derived result to equal the retained report's `routing` object.
41
42
  A mismatch is invalid retained routing evidence and routes to
42
43
  `review_failed`.
43
- 5. Write returned routing evidence containing the immutable report identity,
44
- stable finding IDs, primary route, optional architecture follow-up, and
45
- validation summary. Delivery returns `review_routed`; standalone returns
44
+ 5. If the primary route is `human_steering_required`, invoke `$handback`, write
45
+ its durable outcome, and stop.
46
+ 6. Otherwise write returned routing evidence containing the immutable report
47
+ identity, stable finding IDs, primary route, optional architecture follow-up,
48
+ and validation summary. Delivery returns `review_routed`; standalone returns
46
49
  `review_complete`.
47
50
 
48
51
  ## Invariants
49
52
 
50
53
  - Findings and routing come strictly from the retained report. Current delivery
51
54
  state, caller preference, and later unreviewed changes cannot rerank them.
52
- - Runtime outranks implementation, which outranks debt, which outranks
53
- documentation or closeout.
55
+ - Human steering outranks runtime, implementation, debt, documentation, and
56
+ closeout.
54
57
  - The retained report and reviewed target remain readonly.
55
- - This gate writes routing evidence only. Delivery owns any later route
56
- mutation and every repair counter or active repair state.
58
+ - This gate writes routing or `$handback` evidence only. Delivery owns any later
59
+ route mutation and every repair counter or active repair state.
57
60
  - One return does not invoke review again, run validation again, create review
58
61
  4, or enter repair.
59
62
 
@@ -71,6 +74,8 @@ debug, debt, documentation, or closeout work.
71
74
  explicit delivery resume.
72
75
  - `review_complete`: standalone routing evidence is durable and review is
73
76
  complete.
77
+ - `human_steering_required`: the `$handback` outcome is durable and expanded
78
+ repair awaits that skill's authority guard.
74
79
  - `report_retention_pending`: retained containment or blob evidence became
75
80
  temporarily unverifiable; retry retention without rerunning lenses.
76
81
  - `review_due`: target, bounds, or governing sources are no longer fresh for