@punks/cli 4.0.3 → 5.0.0

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 (116) hide show
  1. package/dist/BASELINE_CHANGELOG.md +25 -1
  2. package/dist/CHANGELOG.md +41 -0
  3. package/dist/baseline/scaffold-baseline/baseline.json +563 -5
  4. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/authoring.d.mts +23 -0
  5. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/authoring.mjs +84 -0
  6. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/authoring.test.ts +79 -0
  7. package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/lint-feedback.test.ts +60 -28
  8. package/dist/baseline/scaffold-baseline/data/scripts/sync-subagents-validator.test.ts +59 -0
  9. package/dist/baseline/scaffold-baseline/data/scripts/sync-subagents.d.mts +1 -0
  10. package/dist/baseline/scaffold-baseline/data/scripts/sync-subagents.mjs +192 -16
  11. package/dist/baseline/scaffold-baseline/data/shared-agents.md +55 -0
  12. package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/references/post-command-flow.md +12 -0
  13. package/dist/baseline/scaffold-baseline/skills/agnostic/generic/handoff/SKILL.md +18 -5
  14. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-plan/SKILL.md +10 -2
  15. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-plan/references/plan-schema.md +28 -8
  16. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-plan/references/planner-task-graph.md +7 -3
  17. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-verification-skill/SKILL.md +66 -0
  18. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-verification-skill/references/upstream.md +20 -0
  19. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/SKILL.md +16 -41
  20. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/assets/IMPLEMENTATION-NOTES-TEMPLATE.md +14 -0
  21. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/architecture-conformance.md +10 -6
  22. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/lifecycle.md +47 -7
  23. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/parallel-orchestration.md +102 -134
  24. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/parallel-worker-brief.md +77 -67
  25. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/parallel.md +19 -39
  26. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/runtime-product-validation.md +27 -0
  27. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/swarm-planner/SKILL.md +27 -2
  28. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/update-verification-skill/SKILL.md +81 -0
  29. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/verify-behavior/SKILL.md +105 -65
  30. package/dist/baseline/scaffold-baseline/skills/agnostic/quality/autoreview/SKILL.md +17 -4
  31. package/dist/baseline/scaffold-baseline/skills/agnostic/quality/autoreview/scripts/autoreview +102 -5
  32. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/brainstorm/SKILL.md +11 -5
  33. package/dist/baseline/scaffold-baseline/skills/agnostic/subagents/swarm-planner/SKILL.md +27 -2
  34. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/SKILL.md +12 -14
  35. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/backlog.md +4 -0
  36. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/closeout.md +12 -4
  37. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/debug.md +11 -5
  38. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/docs-ingest.md +4 -0
  39. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/handback.md +6 -2
  40. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/implement.md +12 -7
  41. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/plan.md +7 -1
  42. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/review.md +61 -22
  43. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/router.md +45 -91
  44. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/spec.md +4 -0
  45. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/artifact-state.md +21 -9
  46. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/context-continuity.md +109 -0
  47. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/failure-continuity.md +27 -0
  48. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/phase-handoff.md +32 -20
  49. package/dist/baseline/scaffold-baseline/skills/phases/docs-ingest-phase/SKILL.md +4 -0
  50. package/dist/baseline/scaffold-baseline/skills/phases/docs-ingest-phase/references/wiki-ingest.md +4 -0
  51. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/prepare-review.md +41 -8
  52. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/retain-report.md +13 -4
  53. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/router.md +1 -1
  54. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/run-review.md +24 -18
  55. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/durable-report.md +40 -6
  56. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/review-packet.md +72 -0
  57. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/runtime-handoff.md +3 -0
  58. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/state-graph.md +51 -42
  59. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/scripts/review-contract.mjs +239 -4
  60. package/dist/baseline/scaffold-baseline.json +5 -5
  61. package/dist/baseline/scaffold-baseline.tgz +0 -0
  62. package/dist/data/scripts/harness-projection/authoring.d.mts +23 -0
  63. package/dist/data/scripts/harness-projection/authoring.mjs +84 -0
  64. package/dist/data/scripts/sync-subagents.d.mts +1 -0
  65. package/dist/data/scripts/sync-subagents.mjs +158 -15
  66. package/dist/data/shared-agents.md +2 -60
  67. package/dist/index.js +1417 -1407
  68. package/dist/skills/agnostic/cli/hi-cli/references/post-command-flow.md +12 -0
  69. package/dist/skills/agnostic/generic/handoff/SKILL.md +18 -5
  70. package/dist/skills/agnostic/planning/create-plan/SKILL.md +10 -2
  71. package/dist/skills/agnostic/planning/create-plan/references/plan-schema.md +28 -8
  72. package/dist/skills/agnostic/planning/create-plan/references/planner-task-graph.md +7 -3
  73. package/dist/skills/agnostic/planning/create-verification-skill/SKILL.md +66 -0
  74. package/dist/skills/agnostic/planning/create-verification-skill/references/upstream.md +20 -0
  75. package/dist/skills/agnostic/planning/implement-spec/SKILL.md +16 -41
  76. package/dist/skills/agnostic/planning/implement-spec/assets/IMPLEMENTATION-NOTES-TEMPLATE.md +14 -0
  77. package/dist/skills/agnostic/planning/implement-spec/references/architecture-conformance.md +10 -6
  78. package/dist/skills/agnostic/planning/implement-spec/references/lifecycle.md +47 -7
  79. package/dist/skills/agnostic/planning/implement-spec/references/parallel-orchestration.md +102 -134
  80. package/dist/skills/agnostic/planning/implement-spec/references/parallel-worker-brief.md +77 -67
  81. package/dist/skills/agnostic/planning/implement-spec/references/parallel.md +19 -39
  82. package/dist/skills/agnostic/planning/implement-spec/references/runtime-product-validation.md +27 -0
  83. package/dist/skills/agnostic/planning/swarm-planner/SKILL.md +27 -2
  84. package/dist/skills/agnostic/planning/update-verification-skill/SKILL.md +81 -0
  85. package/dist/skills/agnostic/planning/verify-behavior/SKILL.md +105 -65
  86. package/dist/skills/agnostic/quality/autoreview/SKILL.md +17 -4
  87. package/dist/skills/agnostic/quality/autoreview/scripts/autoreview +102 -5
  88. package/dist/skills/agnostic/requirements/brainstorm/SKILL.md +11 -5
  89. package/dist/skills/agnostic/subagents/swarm-planner/SKILL.md +27 -2
  90. package/dist/skills/phases/delivery-phase/SKILL.md +12 -14
  91. package/dist/skills/phases/delivery-phase/phases/backlog.md +4 -0
  92. package/dist/skills/phases/delivery-phase/phases/closeout.md +12 -4
  93. package/dist/skills/phases/delivery-phase/phases/debug.md +11 -5
  94. package/dist/skills/phases/delivery-phase/phases/docs-ingest.md +4 -0
  95. package/dist/skills/phases/delivery-phase/phases/handback.md +6 -2
  96. package/dist/skills/phases/delivery-phase/phases/implement.md +12 -7
  97. package/dist/skills/phases/delivery-phase/phases/plan.md +7 -1
  98. package/dist/skills/phases/delivery-phase/phases/review.md +61 -22
  99. package/dist/skills/phases/delivery-phase/phases/router.md +45 -91
  100. package/dist/skills/phases/delivery-phase/phases/spec.md +4 -0
  101. package/dist/skills/phases/delivery-phase/references/artifact-state.md +21 -9
  102. package/dist/skills/phases/delivery-phase/references/context-continuity.md +109 -0
  103. package/dist/skills/phases/delivery-phase/references/failure-continuity.md +27 -0
  104. package/dist/skills/phases/delivery-phase/references/phase-handoff.md +32 -20
  105. package/dist/skills/phases/docs-ingest-phase/SKILL.md +4 -0
  106. package/dist/skills/phases/docs-ingest-phase/references/wiki-ingest.md +4 -0
  107. package/dist/skills/phases/review-phase/phases/prepare-review.md +40 -8
  108. package/dist/skills/phases/review-phase/phases/retain-report.md +13 -4
  109. package/dist/skills/phases/review-phase/phases/router.md +1 -1
  110. package/dist/skills/phases/review-phase/phases/run-review.md +24 -18
  111. package/dist/skills/phases/review-phase/references/durable-report.md +40 -6
  112. package/dist/skills/phases/review-phase/references/review-packet.md +72 -0
  113. package/dist/skills/phases/review-phase/references/runtime-handoff.md +3 -0
  114. package/dist/skills/phases/review-phase/references/state-graph.md +21 -12
  115. package/dist/skills/phases/review-phase/scripts/review-contract.mjs +137 -4
  116. package/package.json +4 -1
@@ -2,23 +2,33 @@
2
2
 
3
3
  Each phase leaves enough durable state for resume without guessing.
4
4
 
5
- ## Base Shape
5
+ ## Phase exit and Delivery Handoff
6
+
7
+ Every phase emits the [common Phase Result](context-continuity.md#common-phase-result).
8
+ Keep its phase-specific evidence in the owning durable artifact. A cross-task
9
+ Delivery Handoff contains only:
6
10
 
7
11
  ```text
8
- Phase:
9
- Status: complete | blocked | skipped | human_steering_required
10
- Scope:
11
- Artifacts:
12
- Validation:
13
- Review/debug/docs state:
14
- UI Evidence:
15
- Next suggested route:
16
- Blockers:
12
+ delivery_goal_identity:
13
+ accepted_bounds_identity:
14
+ git_identity: branch, base, target
15
+ phase:
16
+ next_action:
17
+ context_pointers: typed stable pointers with identity and freshness rule
18
+ provider_identities: relevant identities or explicit none
19
+ blocker: exact blocker or explicit none
20
+ unknowns: explicit unknowns or none
21
+ boundary_rationale: at most one sentence plus rationale pointer, when unusual
17
22
  ```
18
23
 
19
- State only what ran. Prefer durable artifact paths/links. Carry approved
20
- artifacts and UI evidence. Give every skip an exact no-op reason. Honor explicit
21
- HITL stops.
24
+ Validate this envelope before handing off. Resolve fields from durable authority;
25
+ missing required proof remains explicit and blocks the dependent action. Exclude
26
+ full bodies, logs, unbounded narrative and the disposable Delivery Context Packet.
27
+ The receiving task always cold-routes under
28
+ [context continuity](context-continuity.md), checking current authority and prior
29
+ mutation receipts. Detailed review/repair state below lives in a pointed durable
30
+ state artifact, not embedded into the Delivery Handoff. This is distinct from a
31
+ scaffold CLI Post-Command Handoff, whose owning CLI contract remains unchanged.
22
32
 
23
33
  ## Review And Repair Projection
24
34
 
@@ -83,17 +93,19 @@ normalized_target:
83
93
 
84
94
  The `review_due` handoff leaves `review_run_id` unset. Full delivery consumes the
85
95
  context immediately; other modes return it for explicit operator invocation.
86
- Consumption preallocates the next ordinal, fixes the run id, and enters
87
- `review_running`.
96
+ Consumption fixes the attempt run id and proposed next completed ordinal and
97
+ enters `review_running`; only valid completed retained coverage advances the count.
88
98
 
89
99
  For `report_retention_pending`, the explicit resume context additionally carries
90
100
  the existing `review_run_id`, ordinal, local report path and SHA-256, target hash,
91
101
  source hashes, and intended retained ref. Full delivery resumes `$review-phase`;
92
102
  other modes return the context for explicit retry without rerunning lenses.
93
103
 
94
- After fix 3, `clean_handoff` is final authority. Link immutable review 3, final
95
- changes, the same passing focused validation, and clean status.
104
+ After accepted repair, retain Focused Repair Validation and affected Verification
105
+ evidence under the transition rules in [review.md](../phases/review.md). A clean
106
+ handoff links the retained review, final changes and passing required checks.
107
+ Historical ordinals remain unchanged during legacy read-time normalization.
96
108
 
97
- For `human_steering_required`, store the complete `$handback` outcome under
98
- `Blockers`. Keep the state terminal until the `$handback` authority guard
99
- passes.
109
+ For `human_steering_required`, store the complete `$handback` outcome in the
110
+ pointed durable state artifact. Keep only its pointer and exact blocker in the
111
+ Delivery Handoff. The state remains terminal until the authority guard passes.
@@ -42,6 +42,10 @@ Completion of one path does not imply loading the other path.
42
42
  - Public docs work that runs the writer flow must include the fragment sufficiency checkpoint from [phases/public-docs.md](phases/public-docs.md).
43
43
  - After a path completes, report enough state for future resume: selected path, inputs processed, docs written or skipped, validation, blockers, and next path if any.
44
44
 
45
+ ## Project Verifier boundary
46
+
47
+ Treat Feature Maps as read-only navigation inputs to ordinary product and domain documentation. Preserve all Project Verifier references; docs ingest never creates, edits, regenerates, or maintains Feature Maps, invokes either verification lifecycle skill, or performs a verifier audit. Record observed coverage gaps for `implement-spec` to handle in its selected scenario.
48
+
45
49
  ## Stop Conditions
46
50
 
47
51
  - Selected path completed and its resumable outcome was reported.
@@ -22,6 +22,10 @@ Resolve routed `content/docs/project/specs` folders first, then legacy root `spe
22
22
  - Use existing `<wiki-root>/content/docs/project/` sections for concise projections and links.
23
23
  - If no clear project route home exists, stop and report the missing route policy. Do not scaffold a second routed docs surface to satisfy this phase.
24
24
 
25
+ ## Feature Map navigation
26
+
27
+ When a Feature Map links to applicable product or domain authority, follow only the needed links as read-only navigation. Apply the [Project Verifier boundary](../SKILL.md#project-verifier-boundary) even when the ingested source describes changed behavior. Write ordinary routed docs and record any observed coverage gap; preserve the verifier tree and its expected behavior.
28
+
25
29
  ## Source Read
26
30
 
27
31
  Read in order:
@@ -28,7 +28,7 @@ reconciles retained-pass recovery, and owns the exit evidence.
28
28
 
29
29
  1. Validate accepted bounds and normalize the smallest-certain supported target
30
30
  before reading or evaluating any delivery review counter. Unsupported target
31
- or invalid bounds evidence is terminal even when a delivery counter is 3.
31
+ or invalid bounds evidence is terminal even when a delivery counter is 2 or a preserved legacy 3.
32
32
  2. Recompute the accepted-bounds hash, normalized target, inclusive scope,
33
33
  snapshot hash, governing source paths and blob hashes, and source-set hash
34
34
  from primitive current evidence.
@@ -37,21 +37,48 @@ reconciles retained-pass recovery, and owns the exit evidence.
37
37
  mode reads and writes no delivery review or repair counter.
38
38
  4. For delivery mode only, recover `review_count` from unique valid retained
39
39
  ordinals for this lineage and reconcile contradictory projections from that
40
- authority. When the recovered count is at least 3, return the terminal
41
- zero-write `review_budget_exhausted` result with exact current-route evidence.
40
+ authority. Call `planDeliveryReviewGate` in
41
+ [`review-contract.mjs`](../scripts/review-contract.mjs) with `currentState`,
42
+ `acceptedBoundsValid`, `targetSupported`, and `recoveredReviewCount`.
43
+ At count one, pass `acceptedRiskTrigger: { kind, evidence }` only for a
44
+ parent-accepted repair; `evidence` points to its accepted change and the kind
45
+ uses this exact mapping:
46
+
47
+ | Accepted change | `kind` |
48
+ | --- | --- |
49
+ | Architecture or ownership boundary | `architecture` |
50
+ | Security or authorization | `security` |
51
+ | Public contract | `public_contract` |
52
+ | Runtime or deployment topology | `runtime_topology` |
53
+ | Accepted scope | `accepted_scope` |
54
+
55
+ At count two or higher, an additional pass requires the parent-verified
56
+ `humanReviewDirection: { evidence, authorized_ordinal }` described in
57
+ [Review Packet](../references/review-packet.md). Its ordinal must equal
58
+ `recoveredReviewCount + 1`; pass the identical verified object to retention
59
+ and retain it as `review_epoch.human_direction`. It never resets lineage or
60
+ counters. Reusing direction for a different ordinal fails the guard.
61
+ Continue preparation only when the helper returns `review_due`. Return its
62
+ `focused_validation` outcome to delivery for ordinary after-pass repair, or
63
+ its terminal zero-write `review_budget_exhausted` outcome when allowance is
64
+ exhausted. Both preserve the current route, retained evidence and counters.
42
65
  5. After admissibility and the delivery budget guard pass, freeze the normalized
43
66
  target bytes and governing source bytes. In delivery mode preallocate ordinal
44
67
  `recovered review_count + 1` and derive `review_run_id` from lineage and that
45
68
  ordinal. In standalone mode derive `review_run_id` from lineage and
46
69
  `snapshot12`.
47
- 6. Assemble complete `review_running` predecessor evidence. Preparation ends
70
+ 6. Freeze the [Review Packet](../references/review-packet.md), including Spec,
71
+ plan, skill guidance, Verification evidence and relevant dependency pointers.
72
+ Assemble complete `review_running` predecessor evidence. Preparation ends
48
73
  before any review lens, validation command, report write, retention action,
49
74
  counter projection, or repair routing.
50
75
 
51
76
  ## Invariants
52
77
 
53
78
  - Target and bounds validity precede every delivery-budget decision.
54
- - A delivery ordinal is preallocated only after recovered `review_count < 3`.
79
+ - A delivery ordinal is preallocated only after `planDeliveryReviewGate` returns
80
+ `review_due`: first pass, accepted-risk second pass, or the exact
81
+ human-authorized additional ordinal.
55
82
  - Preallocation changes no completed-pass counter.
56
83
  - One run identity names exactly one frozen target and governing source set.
57
84
  - Full-repository scope exists only when the caller explicitly requested it.
@@ -75,10 +102,14 @@ Preparation is complete only when the gate can return all of:
75
102
 
76
103
  ## Declared Exits
77
104
 
105
+ - `focused_validation`: ordinary accepted repair after a completed pass; return
106
+ the helper result to the delivery caller without opening a review run or
107
+ changing report, handoff or counter authority.
108
+
78
109
  - `review_running`: admissibility passed, delivery budget remains, and the frozen
79
110
  target/source predecessor evidence is complete. Re-enter the router.
80
- - terminal `review_budget_exhausted`: valid delivery context recovered count 3
81
- or greater. Return exact current-route evidence with no report, counter,
111
+ - terminal `review_budget_exhausted`: valid delivery context recovered count 2
112
+ or greater without verified direction for the next ordinal. Return exact current-route evidence with no report, counter,
82
113
  handoff, or status write.
83
114
  - terminal `review_failed`: unsupported target, invalid accepted bounds, or a
84
115
  non-retryable normalization, identity, or recovery contract failure. Return
@@ -95,7 +126,8 @@ every stateful exit with its exact schema and mode-specific storage. Use its
95
126
  pre-storage failure or blocker exception only when lineage, run identity, or a
96
127
  safe handoff path cannot be established.
97
128
 
98
- `review_budget_exhausted` is the declared zero-write no-op: preserve the
129
+ `focused_validation` and `review_budget_exhausted` are declared pre-run
130
+ zero-write returns: preserve the
99
131
  caller-provided delivery handoff and retained-count authority unchanged, then
100
132
  return the required identity, count, and current-route evidence directly.
101
133
 
@@ -5,7 +5,7 @@
5
5
  Enter only when the router selected this gate from a complete immutable local
6
6
  report in `report_retention_pending`. Parse the report and prove its exact schema
7
7
  before any repository write. Delivery reports must carry an ordinal from 1
8
- through 3. A malformed report routes to `review_failed`; an ordinal above 3
8
+ through 2 for current epochs (legacy readback preserves 3). A malformed report routes to `review_failed`; an ordinal above 2 for a current epoch without verified matching human direction
9
9
  returns the zero-write `review_budget_exhausted` terminal.
10
10
 
11
11
  ## Inputs
@@ -18,6 +18,9 @@ returns the zero-write `review_budget_exhausted` terminal.
18
18
  - expected report SHA-256 and allowed navigation/wiki-log envelope paths
19
19
  - current retained candidates for the same lineage and run
20
20
  - repository-approved retained refs, or the evidence needed for approval
21
+ - parent-verified pre-protocol report commit SHAs for legacy readback
22
+ - parent-verified preceding-repair ordinal and evidence, or `null` when no repair
23
+ opened the pass
21
24
 
22
25
  Load [the report evidence contract](../references/durable-report.md) for the
23
26
  schema, canonical validity predicates, and same-run identity rules. Use
@@ -36,7 +39,13 @@ accepting an exit.
36
39
 
37
40
  1. Parse the immutable local bytes. Recompute report path, report SHA-256,
38
41
  lineage, run ID, snapshot, source-set hash, and delivery ordinal relations
39
- from primitive evidence. Reject a delivery ordinal above 3 before any write.
42
+ from primitive evidence. For an epoch-less report, require its exact
43
+ `reportCommitSha` in the parent-verified `approvedLegacyReportCommitShas`
44
+ allowlist. Otherwise require the primary/challenger protocol. Reject a
45
+ delivery ordinal above 2 in the current epoch without verified matching
46
+ human direction before any write. Bind `preceding_repair_ordinal` to
47
+ parent-verified `precedingRepairEvidence`; allow both values to be `null`
48
+ when human direction opens the pass without a repair.
40
49
  2. Recompute accepted-bounds, normalized-target, and governing-source hashes.
41
50
  When any value changed, mark the local report stale and route to
42
51
  `review_due` without committing it.
@@ -75,7 +84,7 @@ accepting an exit.
75
84
  review lenses.
76
85
  - Stale, malformed, conflicting, or non-retained evidence changes no pass or
77
86
  counter.
78
- - Delivery ordinals stop at 3. Retention never creates review 4 or opens a
87
+ - Default current epochs stop at 2. Legacy ordinals remain immutable. Retention never opens a
79
88
  repair.
80
89
 
81
90
  ## Completion Evidence
@@ -101,7 +110,7 @@ accepting an exit.
101
110
  the local report is stale.
102
111
  - `review_failed`: schema or identity validation failed, a malformed active
103
112
  candidate or `same_run_conflict` exists, or retention failed non-retryably.
104
- - `review_budget_exhausted`: a delivery ordinal above 3 was rejected before any
113
+ - `review_budget_exhausted`: a delivery ordinal above 2 for a current epoch without verified matching human direction was rejected before any
105
114
  write, pass, counter, or status mutation.
106
115
 
107
116
  ## Durable Handoff
@@ -45,7 +45,7 @@ output.
45
45
  | --- | --- | --- |
46
46
  | 1 | Durable `human_steering_required` while the `$handback` authority guard fails | terminal `human_steering_required` |
47
47
  | 2 | Unsupported target, invalid accepted bounds, non-retryable contract or infrastructure failure, malformed active retention candidate, or `same_run_conflict` | terminal `review_failed` |
48
- | 3 | Delivery entry is otherwise valid, recovered `review_count >= 3`, and no already-started run has valid predecessor evidence | terminal `review_budget_exhausted` |
48
+ | 3 | Delivery entry is otherwise valid, recovered `review_count >= 2`, no verified human direction authorizes the next ordinal, and no already-started run has valid predecessor evidence | terminal `review_budget_exhausted` |
49
49
  | 4 | A repository-approved retained ref is required but cannot be derived and requires an operator decision | checkpoint `retained_ref_approval_required` |
50
50
  | 5 | Same-authority admissible evidence conflicts and no declared tie-break resolves it | blocked `review_state_conflict` |
51
51
  | 6 | Required explicit invocation context, accepted bounds, target evidence, or reconstructible lineage inputs are missing | blocked `review_context_blocked` |
@@ -29,27 +29,32 @@ scope; the parent rejects stale, expanded, duplicated, or unverified output.
29
29
 
30
30
  1. Recompute the frozen target and source hashes before dispatch. A mismatch
31
31
  makes the prepared evidence stale and returns to `review_due`.
32
- 2. Invoke `autoreview` exactly once as advisory candidate generation for this
33
- frozen snapshot. A ClawPatch helper, when present, remains internal to that
34
- one advisory call and consumes no additional review pass.
35
- 3. Run all five normative lenses against the same snapshot as independent
36
- bounded work, in parallel when executors are available:
37
- - Standards
38
- - skill adherence and scoped skills
39
- - architecture
40
- - simplify
41
- - Spec
42
- 4. Keep Standards and Spec as distinct axes. Standards and skill adherence,
43
- architecture, simplify, then Spec controls report and triage order only; it
44
- does not serialize the lenses or change severity.
32
+ 2. Run `autoreview` once as the comprehensive primary reviewer using the
33
+ prepared-packet invocation in [Review Packet](../references/review-packet.md).
34
+ It consumes the frozen facts directly and emits one result for each of
35
+ Standards (including security), skill adherence, architecture, simplify,
36
+ and Spec. Keep Standards and Spec as distinct coverage obligations.
37
+ 3. Assign one independent risk-focused challenger the same prepared facts and
38
+ packet identity, without primary conclusions. Run both roles in parallel
39
+ when native capacity permits; capacity one runs them sequentially in fresh
40
+ independent contexts. Larger changes may split independent risk areas into
41
+ bounded challenger assignments. Every assigned challenger must finish.
42
+ 4. Validate each compact Lens Result using the packet contract. `clean` and
43
+ `findings` require completed assigned coverage; `incomplete` retains any
44
+ candidates and names unavailable coverage, cause, and follow-up. Account for
45
+ completed results on interruption; an incomplete role never completes a pass.
45
46
  5. For skill adherence, prove every implementation-applicable
46
47
  `assigned_skills` item maps to exactly one guidance entry and every guidance
47
48
  entry maps to exactly one implementation-note evidence record. Verify every
48
49
  `loaded`, `applied`, and `not_applicable` claim, including its how/where or
49
50
  why/where evidence, against frozen changed artifacts. Missing, extra, or
50
51
  contradicted evidence becomes a finding.
51
- 6. Parent-verify every advisory and lens candidate against the frozen target and
52
- adjacent evidence. Only verified candidates become findings. Give each
52
+ 6. Group duplicate primary/challenger candidates before investigation. Verify
53
+ every distinct underlying claim against the frozen target and adjacent
54
+ evidence, recording accepted or rejected disposition and all originating
55
+ candidate references. Parent owns final severity, route, stable IDs and report;
56
+ this adjudication does not open an automatic third discovery review.
57
+ Only verified candidates become findings. Give each
53
58
  accepted finding a stable identifier, lens, severity, location, impact,
54
59
  evidence, action, and one explicit `return_route`: `human_steering_required`,
55
60
  `debugging`, `implementation`, `debt_follow_up`, or `docs_ingest`. Use
@@ -76,9 +81,9 @@ scope; the parent rejects stale, expanded, duplicated, or unverified output.
76
81
  ## Invariants
77
82
 
78
83
  - One gate run inspects exactly one frozen bounded snapshot.
79
- - `autoreview` runs exactly once; the five normative lenses each run exactly
80
- once against the same snapshot.
81
- - Advisory output never bypasses parent verification.
84
+ - `autoreview` is the single comprehensive primary; the independent challenger
85
+ receives the same frozen facts. Five primary outcomes retain coverage authority.
86
+ - Candidate output never bypasses parent verification.
82
87
  - Standards and Spec remain distinct report sections.
83
88
  - Validation is readonly relative to the frozen target and remains within
84
89
  accepted bounds.
@@ -97,6 +102,7 @@ The run is complete only when one local report contains:
97
102
  - the prepared lineage, run, bounds, normalized-target, snapshot, source-set,
98
103
  and mode-specific delivery identities
99
104
  - explicit Standards, skill-adherence, architecture, simplify, and Spec outcomes
105
+ - complete primary/challenger Lens Results and parent adjudications in `review_epoch`
100
106
  - every verified stable finding and no unverified advisory candidate
101
107
  - one validated `return_route` on each accepted finding
102
108
  - evidence-cardinality results for all applicable skill guidance and notes
@@ -52,7 +52,7 @@ governing-source normalization requires a non-empty source set.
52
52
 
53
53
  The parsed JSON object is report authority. Detached objects, sidecars, and
54
54
  caller-supplied derived identities are never trusted. It contains exactly these
55
- fields:
55
+ fields, plus `review_epoch` for new primary/challenger runs:
56
56
 
57
57
  - `review_lineage_id`
58
58
  - `review_run_id`
@@ -76,7 +76,8 @@ as null or not applicable.
76
76
  `lens_outcomes` has exactly `standards`, `skill_adherence`, `architecture`,
77
77
  `simplify`, and `spec`; each value is `clean` or `findings`. Every finding has
78
78
  exactly the fields `id`, `lens`, `severity`, `location`, `impact`, `evidence`,
79
- `action`, and `return_route`. Finding IDs are unique, severity is `critical`,
79
+ `action`, and `return_route`. Finding IDs are unique and match the lowercase ASCII
80
+ pattern `^[a-z0-9][a-z0-9._-]*$` (for example, `f001`). Severity is `critical`,
80
81
  `high`, `medium`, or `low`, and each lens outcome agrees with whether that lens
81
82
  has a finding. Each finding's `return_route` is exactly
82
83
  `human_steering_required`, `debugging`, `implementation`, `debt_follow_up`, or
@@ -164,7 +165,40 @@ Recovery uses only unique or identical-reuse valid passes. Any same-run conflict
164
165
  blocks recovery from that run rather than choosing one candidate. Delivery
165
166
  projects the highest uniquely authoritative recovered ordinal.
166
167
 
167
- The review report is the frozen-snapshot handoff. After fix 3, the delivery
168
- handoff is final clean-state authority and links report 3, final changes,
169
- focused validation, and clean status. Report 3 remains immutable pre-fix
170
- evidence.
168
+ The review report is immutable evidence for its frozen snapshot. After an
169
+ accepted repair, the delivery handoff links the relevant retained report,
170
+ final changes, focused validation, affected Verification and clean status.
171
+ A legacy report with ordinal three remains unchanged historical evidence;
172
+ its number does not prescribe a current third pass or a special final-authority
173
+ transition.
174
+
175
+ ## Current epoch and legacy readback
176
+
177
+ New reports include a `review_epoch` derived from the
178
+ [Review Packet](review-packet.md). Call `validateRetainedPass` with
179
+ `reviewProtocol: "primary-challenger-v1"` for current run retention. All
180
+ completed primary outcomes, mandatory independent challenger results,
181
+ candidate accounting, and accepted-finding provenance must validate before the
182
+ pass can count. The helper checks the mechanical evidence; the parent still
183
+ verifies each claim against the target.
184
+
185
+ When recovering historical reports, omit the current-protocol expectation only
186
+ when the parent has verified that the retained report commit predates the
187
+ primary/challenger protocol. Supply that exact commit SHA through
188
+ `approvedLegacyReportCommitShas`. The validator rejects every epoch-less report
189
+ whose `reportCommitSha` is absent from that immutable allowlist. All other
190
+ reports require `reviewProtocol: "primary-challenger-v1"` and a complete
191
+ `review_epoch`.
192
+
193
+ Preserve a legacy report's exact retained bytes, report identity, lineage and
194
+ ordinals, including ordinal three. Legacy recovery supplies no permission for
195
+ another default pass. New default epochs admit ordinals one and two. For an
196
+ additional human-directed pass, retain `review_epoch.human_direction` and
197
+ validate the exact instruction pointer and authorized ordinal against
198
+ parent-verified `humanReviewDirection`.
199
+
200
+ Supply `precedingRepairEvidence: { ordinal, evidence }` only after the parent
201
+ verifies the repair that opened the pass. Its ordinal must immediately precede
202
+ the review ordinal. Supply `precedingRepairEvidence: null` and record
203
+ `preceding_repair_ordinal: null` when human direction opens a pass without an
204
+ intervening repair.
@@ -0,0 +1,72 @@
1
+ # Review Packet and Lens Results
2
+
3
+ Preparation freezes one disposable Review Packet for one epoch. Its facts contain
4
+ accepted bounds, normalized target and snapshot, governing source identities,
5
+ delivery lineage/run, and source-attributed Spec, plan, skill guidance,
6
+ Verification evidence and relevant dependency pointers. Each pointer gives exact
7
+ scope, source identity and freshness rule. Bounded source excerpts support lookup;
8
+ source authority stays at the pointer. Primary conclusions and persuasion prose
9
+ have no place in the shared facts.
10
+
11
+ Prepare the helper input as JSON with exactly `packet_identity`, `review_run_id`,
12
+ `accepted_bounds_hash`, `snapshot_hash`, `source_set_hash`, `facts` and
13
+ `facts_sha256`. Derive `packet_identity` using `reviewPacketIdentity` in the
14
+ existing review helper; `facts_sha256` hashes the UTF-8 facts bytes. Freeze the
15
+ packet bytes and retain their digest in task evidence. Parent verifies that facts
16
+ and pointers correspond to the normalized target and governing sources before
17
+ both roles receive those same bytes. The digest checks transport consistency;
18
+ it does not establish authority for unsourced prose.
19
+
20
+ Invoke the existing autoreview helper with `--review-packet <path>` and a unique
21
+ `--reviewer-identity`. The default prepared role is primary. A separate invocation
22
+ uses `--review-role challenger --risk-area <bounded assignment>`. The primary
23
+ receives all five obligations; challengers receive only their assignments and the
24
+ same facts. Capacity one uses sequential calls with independent fresh contexts.
25
+ Calls retain native handles and evidence through observation timeout; inspect the
26
+ same live process before retrying an actual failed call.
27
+
28
+ Each Lens Result has exactly:
29
+
30
+ - `reviewer_identity`, `role` (`primary` or `challenger`), `coverage` and `packet_identity`;
31
+ - `outcome`: `clean`, `findings`, or `incomplete`;
32
+ - `candidates`, each with only `location`, `evidence_pointer`, `impact`,
33
+ `proposed_severity`, `proposed_return_route` and `uncertainty`;
34
+ - `unavailable_coverage`, `cause`, `follow_up`.
35
+
36
+ Complete clean coverage has zero candidates; complete findings coverage has at
37
+ least one. Both use an empty unavailable list and null cause/follow-up.
38
+ Incomplete results name missing coverage, cause and required follow-up and may
39
+ retain already-found candidates. Preserve completed matching results during a
40
+ partial attempt, identify what remains, and complete all newly applicable roles
41
+ before assembling a report. Semantic changes invalidate the epoch rather than
42
+ turning partial coverage into a clean result.
43
+
44
+ The report's `review_epoch` has exactly `protocol: "primary-challenger-v1"`,
45
+ `packet_identity`, `results` and `adjudications`. Results include each of the five
46
+ primary obligations once, from one primary identity, plus every assigned
47
+ independent challenger. A candidate reference is the JSON-serialized triple
48
+ `[reviewer_identity, coverage, candidate_index]` (zero-based). Parent groups
49
+ duplicates and investigates every distinct claim. Each adjudication contains
50
+ `candidate_refs`, `finding_id` (accepted stable ID or null for rejection), and
51
+ `evidence` explaining verification/disposition. Account for each candidate exactly
52
+ once; accepted finding IDs must match retained findings. These references retain
53
+ primary/challenger provenance even when duplicates become one finding.
54
+
55
+ Use `validateRetainedPass` with `reviewProtocol: "primary-challenger-v1"` and
56
+ parent-frozen `assignedCoverage` entries (`reviewer_identity`, `role`, `coverage`)
57
+ for every assignment before retention
58
+ can consume an ordinal. Completeness includes actual assigned coverage and parent
59
+ verification, beyond mechanical schema checks. Required role failure, unavailable
60
+ coverage or stale target/bounds/source evidence consumes no completed pass.
61
+ Retention-only failure reuses the same complete fresh immutable report. An
62
+ accepted after-pass repair follows the focused/risk policy in the state graph;
63
+ changing a reviewed artifact after completion does not automatically open another
64
+ full review.
65
+
66
+ For an explicitly human-directed additional delivery pass, retain optional
67
+ `review_epoch.human_direction` with exactly `evidence` (the verified human
68
+ instruction pointer) and `authorized_ordinal`. Pass the same parent-verified
69
+ object as `humanReviewDirection` to entry and retention helpers. It authorizes
70
+ only that next ordinal; other ordinals still hit the default ceiling. Parent
71
+ verifies the human instruction itself; candidate or reviewer assertions cannot
72
+ supply this authority. Normal epochs omit this field.
@@ -122,6 +122,9 @@ The following already-authoritative outcomes write no new runtime record:
122
122
 
123
123
  - `review_budget_exhausted`, which preserves the caller's valid delivery
124
124
  handoff and retained-count authority unchanged;
125
+ - pre-run `focused_validation` from the preparation helper, which returns an
126
+ ordinary accepted repair to its existing delivery handoff without opening a
127
+ review run or changing retained-count authority;
125
128
  - `review_not_due`, whose caller-provided delivery handoff already proves a
126
129
  delivery-owned state;
127
130
  - pre-run `review_failed` from an unsupported target, invalid bounds, or
@@ -8,15 +8,15 @@ and clean handoff.
8
8
  | --- | --- | --- | --- | --- | --- | --- |
9
9
  | Current delivery state | Review considered | Unsupported target | Delivery caller | Return `review_failed` | None; zero handoff or status writes | Exact target failure; no report |
10
10
  | Current delivery state | Review considered | Invalid accepted bounds | Delivery caller | Return `review_failed` | None; zero handoff or status writes | Exact bounds failure; no report |
11
- | `review_due` | Authorized review invocation | Delivery; accepted bounds and target valid; recovered `review_count < 3` | Delivery caller | `review_running` | Preallocate ordinal `review_count + 1`; no completed-pass change | Lineage, run id, ordinal, bounds identity/hash, normalized target |
11
+ | `review_due` | Authorized review invocation | Delivery; accepted bounds and target valid; preparation helper returns `review_due` for first pass, accepted-risk second pass, or exact human-authorized next ordinal | Delivery caller | `review_running` | Preallocate ordinal `review_count + 1`; no completed-pass change | Lineage, run id, ordinal, bounds identity/hash, normalized target |
12
12
  | `review_due` | Explicit review invocation | Standalone; accepted bounds and target valid | Standalone caller | `review_running` | None | Lineage, run id, bounds identity/hash, normalized target |
13
- | Current delivery state | Review considered | Delivery; in-memory accepted bounds and target valid; recovered `review_count >= 3` | Delivery caller | Return `review_budget_exhausted` | None; zero handoff or status writes | Exact current route, lineage, counters; no report or status mutation |
14
- | `review_running` | All lenses and parent verification complete | One frozen snapshot; complete local report exists | `review-phase` | `report_retention_pending` | None; no completed-pass change | Complete report and fresh target/source hashes |
13
+ | Current delivery state | Review considered | Delivery; in-memory accepted bounds and target valid; recovered `review_count >= 2`; no verified human direction for the next ordinal | Delivery caller | Return `review_budget_exhausted` | None; zero handoff or status writes | Exact current route, lineage, counters; no report or status mutation |
14
+ | `review_running` | Comprehensive primary, every assigned independent challenger and parent verification complete | One frozen snapshot; complete local report exists | `review-phase` | `report_retention_pending` | None; no completed-pass change | Complete report and fresh target/source hashes |
15
15
  | `review_running` | Validation mutation detected | Frozen-target hash differs after validation | `review-phase` | `review_due` | None | Before/after hashes, command, mutation evidence; no report or pass |
16
16
  | `review_running` | Retryable infrastructure failure or partial run | No immutable report | `review-phase` | `review_due` | None | Exact retryable evidence; unchanged counters |
17
17
  | `review_running` | Non-retryable contract or infrastructure failure | No immutable report | `review-phase` | `review_failed` | None | Exact terminal evidence; no report; unchanged counters |
18
- | `report_retention_pending` | Retention verified | Delivery; valid retained-pass predicate; ordinal at most 3; hashes fresh | Report writer | `review_routed` | Unique retained commit establishes authoritative ordinal; reconcile projection | Path, SHA-256, commit, retained ref, ordinal, run id |
19
- | `report_retention_pending` | Retention rejected | Delivery; ordinal is greater than 3 | Report writer | `review_budget_exhausted` | None | Exact ordinal rejection/current route; no authoritative pass |
18
+ | `report_retention_pending` | Retention verified | Delivery; valid retained-pass predicate; current-protocol ordinal at most 2 or exact verified human direction; hashes fresh | Report writer | `review_routed` | Unique retained commit establishes authoritative ordinal; reconcile projection | Path, SHA-256, commit, retained ref, ordinal, run id |
19
+ | `report_retention_pending` | Retention rejected | Delivery; current-protocol ordinal is greater than 2 without exact verified human direction | Report writer | `review_budget_exhausted` | None | Exact ordinal rejection/current route; no authoritative pass |
20
20
  | `report_retention_pending` | Retention verified | Standalone; valid retained-pass predicate; hashes fresh | Report writer | `review_routed` | None | Path, SHA-256, commit, retained ref |
21
21
  | `report_retention_pending` | Idempotent retention recovery | Same lineage/run has identical valid path, report blob SHA-256, and commit | Report writer | `review_routed` | Reuse existing pass; project its ordinal at most once | Existing unique authority and containment evidence |
22
22
  | `report_retention_pending` | Same-run conflict | Same lineage/run has two valid candidates with different path, blob, or commit | Report writer | `review_failed` | None | `same_run_conflict`, both authorities; no pass or counter change |
@@ -39,10 +39,10 @@ and clean handoff.
39
39
  | `debt_follow_up` | Debt captured | Every debt key is present; `post_debt_route` is `docs_ingest` or `closeout` | Delivery review handoff | `docs_ingest` or `closeout` | None | Retained report commit/path, stable finding IDs, artifact path, captured keys |
40
40
  | `review_routed` | Documentation-only findings | Derived primary route is `docs_ingest` | `delivery-phase` | `docs_ingest` | None | Explicit docs routes and stable findings |
41
41
  | `review_routed` | Finding-free route | Finding set is empty | `delivery-phase` | `closeout` | None | Report and derived closeout route |
42
- | `repair_active` or `debug_active` | Ordinary repair completes | `review_count < 3` | `delivery-phase` | `review_due` | None | Stale prior report, changed target identity, preserved counters |
43
- | `repair_active` or `debug_active` | Fix 3 completes | `review_count = 3` and `repair_count = 3` | `delivery-phase` | `focused_validation` | None | Fix-3 changes and required focused validation |
44
- | `focused_validation` | Focused validation fails | Repair epoch 3 remains open | `delivery-phase` | `repair_active` or `debug_active` | None; unchanged counters | Failed validation and recorded owning route |
45
- | `focused_validation` | Focused validation passes | Repair epoch 3 complete | `delivery-phase` | `clean_handoff` | None | Passing validation, final changes, report-3 link, clean status |
42
+ | `repair_active` or `debug_active` | Ordinary accepted repair completes | Prior completed pass; no accepted high-risk trigger | `delivery-phase` | `focused_validation` | None | Focused checks and only invalidated Verification scenarios |
43
+ | `repair_active` or `debug_active` | Accepted high-risk repair completes | `review_count = 1`; architecture, security/authorization, public contract, runtime/deployment topology, or accepted scope changed | `delivery-phase` | `review_due` | None | Accepted risk trigger and source evidence; second pass only |
44
+ | `focused_validation` | Focused validation fails | Existing repair epoch remains open | `delivery-phase` | `repair_active` or `debug_active` | None; unchanged counters | Failed validation and recorded owning route |
45
+ | `focused_validation` | Focused validation passes | Accepted findings resolved and affected Verification current | `delivery-phase` | `clean_handoff` | None | Passing validation, final changes, prior retained-report link |
46
46
 
47
47
  ## Durable Budget
48
48
 
@@ -66,9 +66,18 @@ reuses recorded keys, adds only missing keys, and follows durable
66
66
  `debugging` or `implementation`; primary debt records `docs_ingest` or
67
67
  `closeout`. Capture completes before the recorded route opens.
68
68
 
69
- Review 1 may open fix 1, review 2 fix 2, and review 3 fix 3. Fix 3 never opens
70
- review 4. A failed focused validation stays in repair epoch 3 until that same
71
- validation passes.
69
+ Normal delivery runs one completed Full Code Review Pass after implementation,
70
+ applicable Verification, reconciliation and final acceptance. Ordinary accepted
71
+ repair gets Focused Repair Validation and only affected Verification reruns. A
72
+ second completed pass requires the accepted risk trigger above. Two completed
73
+ passes exhaust default allowance; further review requires explicit human
74
+ direction. Incomplete, interrupted or semantically invalidated attempts consume
75
+ no completed pass. Retention-only retry reuses the matching complete local report.
76
+
77
+ Valid legacy five-lens reports retain original immutable bytes and ordinals,
78
+ including three. Recovery preserves this authority without granting more default
79
+ passes. Historical numbered repair states normalize to the existing repair and
80
+ focused-validation route; their counters and report identities stay unchanged.
72
81
 
73
82
  `human_steering_required` opens no repair. It remains terminal until the
74
83
  `$handback` authority guard passes.