@punks/cli 3.1.11 → 3.1.12

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 (45) hide show
  1. package/dist/BASELINE_CHANGELOG.md +28 -0
  2. package/dist/CHANGELOG.md +27 -0
  3. package/dist/index.js +6 -6
  4. package/dist/skills/agnostic/docs/writing-beats/LICENSE +21 -0
  5. package/dist/skills/agnostic/docs/writing-beats/UPSTREAM.md +11 -0
  6. package/dist/skills/agnostic/docs/writing-fragments/LICENSE +21 -0
  7. package/dist/skills/agnostic/docs/writing-fragments/UPSTREAM.md +11 -0
  8. package/dist/skills/agnostic/docs/writing-shape/LICENSE +21 -0
  9. package/dist/skills/agnostic/docs/writing-shape/UPSTREAM.md +11 -0
  10. package/dist/skills/agnostic/frontend/frontend-domain-structure/SKILL.md +24 -42
  11. package/dist/skills/agnostic/frontend/frontend-domain-structure/agents/openai.yaml +1 -1
  12. package/dist/skills/agnostic/frontend/frontend-domain-structure/references/react/structure.md +51 -78
  13. package/dist/skills/agnostic/frontend/frontend-domain-structure/references/structure.md +89 -212
  14. package/dist/skills/agnostic/generic/handoff/LICENSE +21 -0
  15. package/dist/skills/agnostic/generic/handoff/UPSTREAM.md +11 -0
  16. package/dist/skills/agnostic/quality/codebase-design/LICENSE +21 -0
  17. package/dist/skills/agnostic/quality/codebase-design/UPSTREAM.md +11 -0
  18. package/dist/skills/agnostic/quality/review/LICENSE +21 -0
  19. package/dist/skills/agnostic/quality/review/UPSTREAM.md +11 -0
  20. package/dist/skills/agnostic/quality/tdd/LICENSE +21 -0
  21. package/dist/skills/agnostic/quality/tdd/UPSTREAM.md +11 -0
  22. package/dist/skills/agnostic/research/improve-codebase-architecture/LICENSE +21 -0
  23. package/dist/skills/agnostic/research/improve-codebase-architecture/UPSTREAM.md +11 -0
  24. package/dist/skills/frameworks/effect/effect/SKILL.md +5 -12
  25. package/dist/skills/frameworks/effect/effect/references/CONFIG.md +10 -19
  26. package/dist/skills/frameworks/effect/effect/references/SERVICES_LAYERS.md +3 -63
  27. package/dist/skills/frameworks/effect/effect/references/TESTING.md +2 -72
  28. package/dist/skills/frameworks/effect/effect-backend-structure/SKILL.md +12 -29
  29. package/dist/skills/frameworks/effect/effect-backend-structure/agents/openai.yaml +1 -1
  30. package/dist/skills/frameworks/effect/effect-backend-structure/references/layout.md +9 -9
  31. package/dist/skills/frameworks/sqlalchemy/sqlalchemy-schema-design/SKILL.md +199 -0
  32. package/dist/skills/frameworks/sqlalchemy/sqlalchemy-schema-design/UPSTREAM.md +31 -0
  33. package/dist/skills/frameworks/sqlalchemy/sqlalchemy-schema-design/agents/openai.yaml +4 -0
  34. package/dist/skills/phases/prototype-phase/agents/openai.yaml +2 -0
  35. package/dist/skills/phases/review-phase/AUTHORING-HANDOFF.md +622 -0
  36. package/dist/skills/phases/review-phase/SKILL.md +9 -36
  37. package/dist/skills/phases/review-phase/phases/prepare-review.md +105 -0
  38. package/dist/skills/phases/review-phase/phases/retain-report.md +113 -0
  39. package/dist/skills/phases/review-phase/phases/return-route.md +95 -0
  40. package/dist/skills/phases/review-phase/phases/router.md +78 -0
  41. package/dist/skills/phases/review-phase/phases/run-review.md +128 -0
  42. package/dist/skills/phases/review-phase/references/durable-report.md +11 -30
  43. package/dist/skills/phases/review-phase/references/runtime-handoff.md +138 -0
  44. package/package.json +63 -9
  45. package/dist/skills/phases/review-phase/REFERENCE.md +0 -85
@@ -0,0 +1,105 @@
1
+ # Prepare Review Gate
2
+
3
+ ## Entry Guard
4
+
5
+ The router selected this gate from fresh `review_due` evidence supplied by an
6
+ explicit operator invocation. The review mode is `delivery` or `standalone`,
7
+ and no valid later-state evidence already owns the run.
8
+
9
+ ## Inputs
10
+
11
+ - explicit invocation context and mode
12
+ - accepted-bounds identity, scope, and primitive evidence
13
+ - delivery Git/diff or standalone artifact target primitives
14
+ - governing Spec, Standards, scoped guidance, named-skill, plan, and
15
+ implementation-note sources
16
+ - delivery-goal identity and retained-report candidates for delivery mode
17
+ - caller evidence needed to explain a retry, failure, or current route
18
+
19
+ ## Actor-Like Gate Boundary
20
+
21
+ This gate owns admissibility, normalization, identity derivation, delivery
22
+ budget recovery, and freezing the review inputs. A narrower target or hashing
23
+ executor may collect bytes and compute candidate values. This gate validates
24
+ those results against [`../references/targets.md`](../references/targets.md),
25
+ reconciles retained-pass recovery, and owns the exit evidence.
26
+
27
+ ## Bounded Action
28
+
29
+ 1. Validate accepted bounds and normalize the smallest-certain supported target
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.
32
+ 2. Recompute the accepted-bounds hash, normalized target, inclusive scope,
33
+ snapshot hash, governing source paths and blob hashes, and source-set hash
34
+ from primitive current evidence.
35
+ 3. Derive delivery lineage only from stable delivery-goal identity. Derive
36
+ standalone lineage from target locator and accepted-bounds hash. Standalone
37
+ mode reads and writes no delivery review or repair counter.
38
+ 4. For delivery mode only, recover `review_count` from unique valid retained
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.
42
+ 5. After admissibility and the delivery budget guard pass, freeze the normalized
43
+ target bytes and governing source bytes. In delivery mode preallocate ordinal
44
+ `recovered review_count + 1` and derive `review_run_id` from lineage and that
45
+ ordinal. In standalone mode derive `review_run_id` from lineage and
46
+ `snapshot12`.
47
+ 6. Assemble complete `review_running` predecessor evidence. Preparation ends
48
+ before any review lens, validation command, report write, retention action,
49
+ counter projection, or repair routing.
50
+
51
+ ## Invariants
52
+
53
+ - Target and bounds validity precede every delivery-budget decision.
54
+ - A delivery ordinal is preallocated only after recovered `review_count < 3`.
55
+ - Preallocation changes no completed-pass counter.
56
+ - One run identity names exactly one frozen target and governing source set.
57
+ - Full-repository scope exists only when the caller explicitly requested it.
58
+ - Standalone mode has no delivery-budget effect.
59
+ - Preparation mutates neither the reviewed target nor report/navigation/wiki-log
60
+ paths.
61
+
62
+ ## Completion Evidence
63
+
64
+ Preparation is complete only when the gate can return all of:
65
+
66
+ - mode, lineage, run identity, and delivery ordinal or standalone null
67
+ - accepted-bounds identity and recomputed hash
68
+ - exact normalized target and inclusive scope
69
+ - snapshot hash, `snapshot12`, and frozen target evidence locator
70
+ - governing source paths, individual hashes, source-set hash, and frozen source
71
+ evidence locator
72
+ - recovered delivery count and its authoritative retained-pass evidence, or
73
+ standalone null
74
+ - one declared exit with exact validation, failure, or blocker evidence
75
+
76
+ ## Declared Exits
77
+
78
+ - `review_running`: admissibility passed, delivery budget remains, and the frozen
79
+ 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,
82
+ handoff, or status write.
83
+ - terminal `review_failed`: unsupported target, invalid accepted bounds, or a
84
+ non-retryable normalization, identity, or recovery contract failure. Return
85
+ exact evidence with no report or counter change.
86
+ - `review_due`: retryable infrastructure or partial preparation failure. Return
87
+ exact evidence with no report or counter change.
88
+ - blocked `review_context_blocked`: a required primitive cannot be reconstructed
89
+ safely. Name the missing evidence and stop.
90
+
91
+ ## Durable Handoff
92
+
93
+ Load [the runtime handoff contract](../references/runtime-handoff.md). Persist
94
+ every stateful exit with its exact schema and mode-specific storage. Use its
95
+ pre-storage failure or blocker exception only when lineage, run identity, or a
96
+ safe handoff path cannot be established.
97
+
98
+ `review_budget_exhausted` is the declared zero-write no-op: preserve the
99
+ caller-provided delivery handoff and retained-count authority unchanged, then
100
+ return the required identity, count, and current-route evidence directly.
101
+
102
+ ## Stop Or Router Re-entry
103
+
104
+ Stop on terminal or blocked exits. Otherwise stop after the gate-local outcome,
105
+ or re-enter [`router.md`](router.md). Load no sibling gate directly.
@@ -0,0 +1,113 @@
1
+ # Retain Report
2
+
3
+ ## Entry Guard
4
+
5
+ Enter only when the router selected this gate from a complete immutable local
6
+ report in `report_retention_pending`. Parse the report and prove its exact schema
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
9
+ returns the zero-write `review_budget_exhausted` terminal.
10
+
11
+ ## Inputs
12
+
13
+ - exact local report path and bytes
14
+ - primitive accepted-bounds, normalized-target, and governing-source evidence
15
+ - review mode, lineage, run ID, and delivery ordinal when applicable
16
+ - expected report SHA-256 and allowed navigation/wiki-log envelope paths
17
+ - current retained candidates for the same lineage and run
18
+ - repository-approved retained refs, or the evidence needed for approval
19
+
20
+ Load [the report evidence contract](../references/durable-report.md) for the
21
+ schema, canonical validity predicates, and same-run identity rules. Use
22
+ [`review-contract.mjs`](../scripts/review-contract.mjs) to parse and validate
23
+ report bytes and derived identities.
24
+
25
+ ## Actor-Like Gate Boundary
26
+
27
+ The retention gate owns candidate reconciliation, freshness checks, the one
28
+ designated report-writer assignment, post-write validation, and its durable
29
+ outcome. The designated writer may commit and push only the report,
30
+ navigation, and wiki-log envelope. The gate validates that work itself before
31
+ accepting an exit.
32
+
33
+ ## Bounded Action
34
+
35
+ 1. Parse the immutable local bytes. Recompute report path, report SHA-256,
36
+ lineage, run ID, snapshot, source-set hash, and delivery ordinal relations
37
+ from primitive evidence. Reject a delivery ordinal above 3 before any write.
38
+ 2. Recompute accepted-bounds, normalized-target, and governing-source hashes.
39
+ When any value changed, mark the local report stale and route to
40
+ `review_due` without committing it.
41
+ 3. Validate every retained candidate for the same `(review_lineage_id,
42
+ review_run_id)` independently. Reuse one unique valid candidate, including
43
+ repeated discovery of its identical path, blob SHA-256, and commit. Treat
44
+ different valid candidates for the same run as `same_run_conflict`.
45
+ 4. Resolve the retained ref. Delivery uses its current delivery branch or
46
+ another repository-approved ref. Standalone uses
47
+ `review/<review-scope-slug>-<snapshot12>` or another approved ref. When the
48
+ required approval cannot be derived, emit the operator checkpoint before
49
+ repository mutation.
50
+ 5. When no reusable valid candidate exists, assign one writer to commit only
51
+ the report and allowed envelope, then push or use the approved ref. Preserve
52
+ the report bytes exactly.
53
+ 6. Verify that the retained ref contains the exact report commit and that the
54
+ commit changed only approved envelope paths. Run the complete retained-pass
55
+ validator again against the retained blob and current primitive evidence.
56
+ 7. Only a unique valid retained delivery report establishes its ordinal.
57
+ Reconcile the delivery `review_count` projection from the highest unique
58
+ valid retained ordinal. Standalone retention changes no delivery counter.
59
+
60
+ ## Invariants
61
+
62
+ - The reviewed target remains readonly. Only the report, navigation, and
63
+ wiki-log envelope may change.
64
+ - The local report becomes immutable when complete; retention preserves its
65
+ exact bytes.
66
+ - A report is not a pass until schema, identity, freshness, approved paths,
67
+ uniqueness, blob hash, and retained-ref containment all validate.
68
+ - Identical rediscovery reuses one pass and projects its ordinal at most once.
69
+ - Retryable retention reuses the same fresh local report and never reruns
70
+ review lenses.
71
+ - Stale, malformed, conflicting, or non-retained evidence changes no pass or
72
+ counter.
73
+ - Delivery ordinals stop at 3. Retention never creates review 4 or opens a
74
+ repair.
75
+
76
+ ## Completion Evidence
77
+
78
+ - local report path and SHA-256
79
+ - report schema and canonical-identity validation result
80
+ - target, bounds, and source freshness recomputation
81
+ - same-run candidate inventory and uniqueness decision
82
+ - report commit SHA and its exact changed-path set
83
+ - approved retained ref and proof that it contains the report commit
84
+ - delivery ordinal and reconciled counter projection, or standalone mode
85
+
86
+ ## Declared Exits
87
+
88
+ - `review_routed`: one unique fresh retained pass is verified.
89
+ - `report_retention_pending`: retention failed retryably; the fresh local report
90
+ remains reusable and no pass exists.
91
+ - `retained_ref_approval_required`: an operator must approve the retained ref;
92
+ no repository mutation or pass exists.
93
+ - `review_due`: target, bounds, or source freshness changed before retention;
94
+ the local report is stale.
95
+ - `review_failed`: schema or identity validation failed, a malformed active
96
+ candidate or `same_run_conflict` exists, or retention failed non-retryably.
97
+ - `review_budget_exhausted`: a delivery ordinal above 3 was rejected before any
98
+ write, pass, counter, or status mutation.
99
+
100
+ ## Durable Handoff
101
+
102
+ Load [the runtime handoff contract](../references/runtime-handoff.md). Persist
103
+ every stateful success, retry, failure, or retained-ref approval checkpoint with
104
+ its exact schema before stop or router re-entry.
105
+
106
+ `review_budget_exhausted` remains the zero-write no-op because the valid caller
107
+ handoff and retained-count authority already prove exhaustion.
108
+
109
+ ## Stop Or Router Re-entry
110
+
111
+ Stop on terminal, blocked, or checkpoint output. After a stateful outcome is
112
+ durable, stop or re-enter [`router.md`](router.md). Never load a sibling gate
113
+ directly, rerun lenses, mutate a delivery route, or enter repair.
@@ -0,0 +1,95 @@
1
+ # Return Route
2
+
3
+ ## Entry Guard
4
+
5
+ Enter only when the router selected this gate from one unique, fresh, valid
6
+ retained pass and no durable returned-routing outcome exists for its run. The
7
+ retained report is the only finding and routing authority.
8
+
9
+ ## Inputs
10
+
11
+ - exact retained report bytes, path, SHA-256, commit, and retained ref
12
+ - approved-path and ref-containment evidence
13
+ - primitive target, accepted-bounds, and governing-source evidence for one
14
+ final freshness check
15
+ - caller mode and the report's lineage, run ID, findings, routing object, and
16
+ validation evidence
17
+
18
+ Load [the report evidence contract](../references/durable-report.md) and use
19
+ [`review-contract.mjs`](../scripts/review-contract.mjs) to validate the retained
20
+ pass before deriving an output.
21
+
22
+ ## Actor-Like Gate Boundary
23
+
24
+ The return gate owns retained-pass revalidation, deterministic route
25
+ derivation, consistency checking, and the returned-routing handoff. It may use
26
+ a readonly validator. It delegates no delivery transition and owns no repair,
27
+ debug, debt, documentation, or closeout work.
28
+
29
+ ## Bounded Action
30
+
31
+ 1. Revalidate the retained blob, canonical identities, approved commit paths,
32
+ same-run uniqueness, ref containment, and current freshness. Reuse only the
33
+ immutable authority block inside those retained bytes.
34
+ 2. Derive the primary route from retained findings in this order:
35
+ - any finding with runtime-failure evidence -> `debugging`
36
+ - otherwise, any in-scope non-runtime blocking finding -> `implementation`
37
+ - otherwise, any broad architecture-debt finding -> `debt_follow_up`
38
+ - otherwise, incomplete required documentation -> `docs_ingest`
39
+ - otherwise -> `closeout`
40
+ 3. Set `secondary_architecture_follow_up` only when a broad architecture-debt
41
+ finding accompanies a higher-priority debugging or implementation route.
42
+ 4. Require the derived result to equal the retained report's `routing` object.
43
+ A mismatch is invalid retained routing evidence and routes to
44
+ `review_failed`.
45
+ 5. Write returned routing evidence containing the immutable report identity,
46
+ stable finding IDs, primary route, optional architecture follow-up, and
47
+ validation summary. Delivery returns `review_routed`; standalone returns
48
+ `review_complete`.
49
+
50
+ ## Invariants
51
+
52
+ - Findings and routing come strictly from the retained report. Current delivery
53
+ state, caller preference, and later unreviewed changes cannot rerank them.
54
+ - Runtime outranks implementation, which outranks debt, which outranks
55
+ documentation or closeout.
56
+ - The retained report and reviewed target remain readonly.
57
+ - This gate writes routing evidence only. Delivery owns any later route
58
+ mutation and every repair counter or active repair state.
59
+ - One return does not invoke review again, run validation again, create review
60
+ 4, or enter repair.
61
+
62
+ ## Completion Evidence
63
+
64
+ - valid retained-pass result and final freshness result
65
+ - retained report path, SHA-256, commit, and containing ref
66
+ - stable finding IDs used by each route class
67
+ - deterministic precedence result and exact match to report `routing`
68
+ - returned mode-specific state and routing-evidence artifact
69
+
70
+ ## Declared Exits
71
+
72
+ - `review_routed`: delivery-mode routing evidence is durable and ready for an
73
+ explicit delivery resume.
74
+ - `review_complete`: standalone routing evidence is durable and review is
75
+ complete.
76
+ - `report_retention_pending`: retained containment or blob evidence became
77
+ temporarily unverifiable; retry retention without rerunning lenses.
78
+ - `review_due`: target, bounds, or governing sources are no longer fresh for
79
+ this return.
80
+ - `review_failed`: the retained pass, uniqueness, or derived routing contract is
81
+ invalid or failed non-retryably.
82
+
83
+ ## Durable Handoff
84
+
85
+ Load [the runtime handoff contract](../references/runtime-handoff.md). Every new
86
+ declared exit writes its exact stateful record, including route output fields
87
+ inside `Artifacts`. Rediscovery of an identical already-recorded return is the
88
+ contract's idempotent no-write terminal.
89
+
90
+ ## Stop Or Router Re-entry
91
+
92
+ Return the durable routing evidence and stop. A delivery caller resumes
93
+ `delivery-phase` explicitly; this gate never performs that transition. Re-enter
94
+ [`router.md`](router.md) only for a declared nonterminal exit, never by loading
95
+ a sibling gate directly.
@@ -0,0 +1,78 @@
1
+ # Review Router
2
+
3
+ Load this file on every explicit invocation and re-entry. Recompute one route
4
+ from current evidence; transcript continuity and a recorded route suggestion
5
+ are never required.
6
+
7
+ Load [the runtime handoff contract](../references/runtime-handoff.md). Discover
8
+ the latest applicable record by its mode-specific rule before applying route
9
+ precedence. Persist router-owned stateful checkpoints and blockers through that
10
+ contract; use its declared no-write outcomes only when existing authority is
11
+ already sufficient.
12
+
13
+ Load [the state evidence model](../references/state-graph.md) only when
14
+ reconstructing delivery-budget authority, checking the review/delivery
15
+ ownership boundary, or resolving contradictory state evidence.
16
+
17
+ ## Inputs And Authority
18
+
19
+ Inspect:
20
+
21
+ 1. direct accepted-bounds, target, validation, failure, and caller evidence;
22
+ 2. fresh valid normalized targets, frozen snapshots, local reports, and retained
23
+ report candidates;
24
+ 3. committed review and delivery handoffs;
25
+ 4. any suggested route.
26
+
27
+ Apply that authority order. Evidence is eligible only when its scope matches the
28
+ current review lineage and its required hashes, schema, and retained-ref
29
+ containment remain valid. Recompute derived identities and freshness instead of
30
+ trusting labels or counters. A lower-authority state label cannot override
31
+ newer admissible evidence.
32
+
33
+ When eligible evidence conflicts, prefer the higher authority. At the same
34
+ authority, prefer the most advanced state whose complete predecessor evidence
35
+ is valid. A same-run retained-report conflict is `review_failed`; any other
36
+ same-authority conflict without a contract tie-break is
37
+ `review_state_conflict`.
38
+
39
+ ## Route Precedence
40
+
41
+ Evaluate top to bottom and return the first matching row. Return only its one
42
+ output.
43
+
44
+ | Priority | Current evidence | Output |
45
+ | --- | --- | --- |
46
+ | 1 | Unsupported target, invalid accepted bounds, non-retryable contract or infrastructure failure, malformed active retention candidate, or `same_run_conflict` | terminal `review_failed` |
47
+ | 2 | Delivery entry is otherwise valid, recovered `review_count >= 3`, and no already-started run has valid predecessor evidence | terminal `review_budget_exhausted` |
48
+ | 3 | A repository-approved retained ref is required but cannot be derived and requires an operator decision | checkpoint `retained_ref_approval_required` |
49
+ | 4 | Same-authority admissible evidence conflicts and no declared tie-break resolves it | blocked `review_state_conflict` |
50
+ | 5 | Required explicit invocation context, accepted bounds, target evidence, or reconstructible lineage inputs are missing | blocked `review_context_blocked` |
51
+ | 6 | The caller is in delivery-owned `debug_active`, `repair_active`, `debt_follow_up`, `docs_ingest`, `closeout`, `focused_validation`, or `clean_handoff` without fresh `review_due` evidence | blocked `review_not_due` |
52
+ | 7 | A valid retained standalone report and durable returned routing output exist | terminal `review_complete` |
53
+ | 8 | A valid retained delivery report and durable returned routing output exist | terminal `review_routed` |
54
+ | 9 | Retention is verified and fresh, but its returned routing output is absent | [`return-route.md`](return-route.md) |
55
+ | 10 | A complete fresh local report exists without unique verified retention, including a retryable retention failure | [`retain-report.md`](retain-report.md) |
56
+ | 11 | Fresh `review_running` predecessor evidence exists without a complete local report | [`run-review.md`](run-review.md) |
57
+ | 12 | Fresh `review_due` evidence exists, or mutation, partial-run, retryable failure, or stale target/source evidence invalidated later work | [`prepare-review.md`](prepare-review.md) |
58
+
59
+ ## State Coverage
60
+
61
+ - `review_due` selects `prepare-review.md` after the entry context passes the
62
+ higher-priority guards.
63
+ - `review_running` selects `run-review.md` unless newer valid evidence proves a
64
+ later state or direct failure evidence selects a terminal.
65
+ - `report_retention_pending` selects `retain-report.md`; fresh verified
66
+ retention advances to `return-route.md`.
67
+ - `review_routed` selects `return-route.md` until durable return evidence exists,
68
+ then terminates as `review_complete` for standalone or `review_routed` for
69
+ delivery.
70
+ - `review_failed` and `review_budget_exhausted` are terminal router outcomes.
71
+ - Review-owned mutation or retryable partial-run evidence projects back to
72
+ `review_due`; retryable fresh retention evidence remains
73
+ `report_retention_pending`.
74
+ - Delivery-owned post-review states are outside this skill and resolve to
75
+ `review_not_due` unless a fresh explicit `review_due` handoff exists.
76
+
77
+ Every gate output above resolves to one flat phase file. Load only that selected
78
+ file; sibling gates stay outside the current trace.
@@ -0,0 +1,128 @@
1
+ # Run Review Gate
2
+
3
+ ## Entry Guard
4
+
5
+ The router selected this gate from complete fresh `review_running` predecessor
6
+ evidence. One normalized target, snapshot hash, governing source set, lineage,
7
+ and run identity are frozen and mutually consistent.
8
+
9
+ ## Inputs
10
+
11
+ - the prepared mode, lineage, run identity, and delivery ordinal when applicable
12
+ - frozen normalized target bytes, inclusive scope, and snapshot hash
13
+ - frozen governing source bytes and source-set hash
14
+ - accepted Spec or standalone bounds, Standards, nearest scoped guidance, and
15
+ every named skill
16
+ - plan `assigned_skills` and `implementation_skill_guidance`, plus
17
+ `IMPLEMENTATION-NOTES.md` skill evidence and validation requirements
18
+ - any accepted broader-check authority from the governing spec or plan
19
+
20
+ ## Actor-Like Gate Boundary
21
+
22
+ The parent review gate owns the single review run, candidate reconciliation,
23
+ finding acceptance, validation safety, report assembly, and every exit. It may
24
+ delegate advisory generation and independent lenses to narrower readonly
25
+ executors. Every executor receives the same frozen snapshot identity and bounded
26
+ scope; the parent rejects stale, expanded, duplicated, or unverified output.
27
+
28
+ ## Bounded Action
29
+
30
+ 1. Recompute the frozen target and source hashes before dispatch. A mismatch
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.
45
+ 5. For skill adherence, prove every implementation-applicable
46
+ `assigned_skills` item maps to exactly one guidance entry and every guidance
47
+ entry maps to exactly one implementation-note evidence record. Verify every
48
+ `loaded`, `applied`, and `not_applicable` claim, including its how/where or
49
+ why/where evidence, against frozen changed artifacts. Missing, extra, or
50
+ 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
53
+ accepted finding a stable identifier, lens, severity, location, impact,
54
+ evidence, and action.
55
+ 7. Run only the smallest safe readonly validation needed to verify candidates or
56
+ governing acceptance evidence. Broader checks require explicit accepted spec
57
+ or plan authority. Record missing required RED/GREEN evidence as a finding;
58
+ this gate does not create it.
59
+ 8. Record the frozen-target hash before and after every validation. Proven
60
+ no-write commands may use the reviewed checkout. Commands that may write
61
+ caches, generated files, snapshots, lockfiles, or state run in a disposable
62
+ checkout or snapshot rooted at the frozen revision. Reconcile exact commands,
63
+ isolation mode, hashes, output, skipped checks, and residual risk.
64
+ 9. Derive the report route from verified findings: runtime evidence first,
65
+ otherwise an in-scope non-runtime blocker, otherwise broad architecture debt,
66
+ otherwise documentation ingest or closeout by documentation completeness.
67
+ Architecture debt may remain a secondary follow-up.
68
+ 10. Assemble exactly one complete local report using
69
+ [`../references/durable-report.md`](../references/durable-report.md). Record
70
+ an explicit outcome for every lens. After its final bytes are written, treat
71
+ the local report as immutable and end this gate before retention.
72
+
73
+ ## Invariants
74
+
75
+ - One gate run inspects exactly one frozen bounded snapshot.
76
+ - `autoreview` runs exactly once; the five normative lenses each run exactly
77
+ once against the same snapshot.
78
+ - Advisory output never bypasses parent verification.
79
+ - Standards and Spec remain distinct report sections.
80
+ - Validation is readonly relative to the frozen target and remains within
81
+ accepted bounds.
82
+ - A before/after target-hash mismatch invalidates every result and local report
83
+ from this attempt and consumes no pass.
84
+ - The reviewed target remains unchanged. The only allowed write is the local
85
+ immutable report; navigation, wiki-log, commit, push, and counter projection
86
+ belong to retention.
87
+ - This gate plans no work, assigns no implementation skills, creates no missing
88
+ implementation evidence, repairs no finding, and opens no repair state.
89
+
90
+ ## Completion Evidence
91
+
92
+ The run is complete only when one local report contains:
93
+
94
+ - the prepared lineage, run, bounds, normalized-target, snapshot, source-set,
95
+ and mode-specific delivery identities
96
+ - explicit Standards, skill-adherence, architecture, simplify, and Spec outcomes
97
+ - every verified stable finding and no unverified advisory candidate
98
+ - evidence-cardinality results for all applicable skill guidance and notes
99
+ - exact validation commands, isolation, before/after hashes, outcomes, skipped
100
+ checks, and residual risk
101
+ - report-derived primary routing and optional secondary architecture follow-up
102
+ - the immutable report path and local report SHA-256
103
+
104
+ ## Declared Exits
105
+
106
+ - `report_retention_pending`: the complete immutable local report exists and its
107
+ target/source hashes remain fresh. Re-enter the router.
108
+ - `review_due`: target or source freshness changed, validation mutated the
109
+ frozen target, or a retryable infrastructure/partial-run failure occurred.
110
+ Discard any local report authority and consume no pass.
111
+ - terminal `review_failed`: a non-retryable review, validation-isolation, or
112
+ report-contract failure occurred. Return exact evidence with no authoritative
113
+ report or counter change.
114
+ - blocked `review_context_blocked`: required frozen evidence became unavailable
115
+ and cannot be reconstructed without a new preparation attempt. Name it and
116
+ stop.
117
+
118
+ ## Durable Handoff
119
+
120
+ Load [the runtime handoff contract](../references/runtime-handoff.md). The gate
121
+ has valid lineage, run identity, and storage on entry, so every declared exit
122
+ writes its exact stateful record before stop or router re-entry.
123
+
124
+ ## Stop Or Router Re-entry
125
+
126
+ Stop on terminal or blocked exits. For `review_due` or
127
+ `report_retention_pending`, stop after the gate-local outcome or re-enter
128
+ [`router.md`](router.md). Load no sibling gate directly and perform no repair.
@@ -89,26 +89,19 @@ The snapshot hash excludes only the report itself, navigation metadata, and the
89
89
  wiki log envelope. Navigation ordering does not affect freshness. The report and
90
90
  normalized target omit raw selected bytes.
91
91
 
92
- ## Retention
92
+ ## Retention Evidence
93
93
 
94
- A complete local report enters `report_retention_pending` with no counter
95
- change. One designated writer:
94
+ This reference defines retention evidence only. The router-selected retention
95
+ gate owns execution. The outside-report retention envelope contains the report
96
+ path, exact report SHA-256, report commit SHA, verified retained ref, and the
97
+ commit's changed paths. Those fields are evidence, not additions to the
98
+ immutable report.
96
99
 
97
- 1. rejects a delivery ordinal greater than 3 without an authoritative pass or
98
- counter change;
99
- 2. confirms target and governing source hashes remain fresh;
100
- 3. commits only the report, navigation, and wiki-log envelope;
101
- 4. pushes or uses a repository-approved retained ref;
102
- 5. verifies that the retained ref contains the report commit.
103
-
104
- Delivery uses its current delivery branch or another approved ref. Standalone
105
- uses deterministic `review/<review-scope-slug>-<snapshot12>` or another approved
106
- ref.
107
-
108
- Return report path, report SHA-256, report commit SHA, and verified retained ref
109
- outside the immutable report. A verified retained delivery report is the
110
- authoritative completed ordinal; only then reconcile the handoff `review_count`
111
- projection. Standalone retention changes no delivery counter.
100
+ Delivery refs are the current delivery branch or another repository-approved
101
+ ref. Standalone refs are
102
+ `review/<review-scope-slug>-<snapshot12>` or another approved ref. Only a valid
103
+ retained delivery report establishes an ordinal; standalone reports have no
104
+ delivery-counter meaning.
112
105
 
113
106
  ## Valid Retained Pass
114
107
 
@@ -154,18 +147,6 @@ Recovery uses only unique or identical-reuse valid passes. Any same-run conflict
154
147
  blocks recovery from that run rather than choosing one candidate. Delivery
155
148
  projects the highest uniquely authoritative recovered ordinal.
156
149
 
157
- ## Retention Failure
158
-
159
- - A retryable retention failure stays `report_retention_pending`, returns exact
160
- evidence, and establishes no pass. While target and source hashes remain
161
- fresh, reuse the local report without rerunning lenses.
162
- - A non-retryable contract or infrastructure failure enters `review_failed`
163
- with exact evidence, no pass, and no counter change.
164
- - A malformed active retention candidate or `same_run_conflict` enters
165
- `review_failed` with exact evidence, no new pass, and no counter change.
166
- - If target or source hash changes before retention, mark the local report stale
167
- and return to `review_due` without consuming a pass.
168
-
169
150
  The review report is the frozen-snapshot handoff. After fix 3, the delivery
170
151
  handoff is final clean-state authority and links report 3, final changes,
171
152
  focused validation, and clean status. Report 3 remains immutable pre-fix