@yunhozz/arc 0.5.5 → 0.5.6

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 (39) hide show
  1. package/MANIFEST.sha256 +38 -38
  2. package/claude/skill/SKILL.md +1 -1
  3. package/claude/skill/references/coordination.md +1 -1
  4. package/claude/skill/references/handoff-prep.md +4 -4
  5. package/claude/skill/references/handoff.md +5 -5
  6. package/claude/skill/references/planning.md +72 -24
  7. package/codex/skill/SKILL.md +1 -1
  8. package/codex/skill/references/coordination.md +1 -1
  9. package/codex/skill/references/handoff-prep.md +4 -4
  10. package/codex/skill/references/handoff.md +5 -5
  11. package/codex/skill/references/planning.md +72 -24
  12. package/gemini/skill/SKILL.md +1 -1
  13. package/gemini/skill/references/coordination.md +1 -1
  14. package/gemini/skill/references/handoff-prep.md +4 -4
  15. package/gemini/skill/references/handoff.md +5 -5
  16. package/gemini/skill/references/planning.md +72 -24
  17. package/grok/skill/SKILL.md +1 -1
  18. package/grok/skill/references/coordination.md +1 -1
  19. package/grok/skill/references/handoff-prep.md +4 -4
  20. package/grok/skill/references/handoff.md +5 -5
  21. package/grok/skill/references/planning.md +72 -24
  22. package/lib/policy/role-policy.json +1 -1
  23. package/lib/prompts/agent-fragments.json +2 -2
  24. package/lib/runtime/assignment.mjs +3 -2
  25. package/lib/runtime/cooperative.mjs +36 -3
  26. package/lib/runtime/evaluate.mjs +21 -6
  27. package/lib/runtime/gate.mjs +2 -1
  28. package/lib/runtime/schema.mjs +16 -0
  29. package/lib/runtime/target-preparation.mjs +7 -2
  30. package/lib/runtime/verification.mjs +1 -1
  31. package/package.json +1 -1
  32. package/shared/skill/runtime/assignment.mjs +3 -2
  33. package/shared/skill/runtime/cooperative.mjs +36 -3
  34. package/shared/skill/runtime/evaluate.mjs +21 -6
  35. package/shared/skill/runtime/gate.mjs +2 -1
  36. package/shared/skill/runtime/role-policy.json +1 -1
  37. package/shared/skill/runtime/schema.mjs +16 -0
  38. package/shared/skill/runtime/target-preparation.mjs +7 -2
  39. package/shared/skill/runtime/verification.mjs +1 -1
@@ -22,7 +22,7 @@ If explicitly requested probe+implementation is fully specified, classify the wh
22
22
  <a id="formal-drafting-boundary"></a>
23
23
  ## Formal drafting boundary
24
24
 
25
- Initial design/brainstorming MAY precede target choice. Before the first required spec/plan draft, record verified source workspace/repository, branch/HEAD, changes/ownership, explicit choice, approved scope/depth/document set and planned relative paths. Planner returns the complete first draft and self-review in chat before target preparation. Revalidate source and selected target at the focused preparation gate, prepare the chosen target, compare actual target and preservation, then review and save in the verified prepared target. Planned paths prove no preparation. Missing or mismatched evidence holds affected work; preparation alone never starts Implementer.
25
+ Initial design/brainstorming MAY precede target choice. On the Architectural path, [start confirmation](#architectural-start-confirmation) supplies the approved scope/depth/document set and the explicit choice that the next sentence requires. Before the first required spec/plan draft, record verified source workspace/repository, branch/HEAD, changes/ownership, explicit choice, approved scope/depth/document set and planned relative paths. Planner returns the complete first draft and self-review in chat before target preparation. Revalidate source and selected target at the focused preparation gate, prepare the chosen target, compare actual target and preservation, then review and save in the verified prepared target. Planned paths prove no preparation. Missing or mismatched evidence holds affected work; preparation alone never starts Implementer.
26
26
 
27
27
  Small-task direct edits follow only [handoff](handoff.md#orchestrator-direct-path-for-small-tasks), stopping/reclassifying changed scope/risk. Otherwise follow this reference. `brainstorming`/`writing-plans` instruct existing roles, not extra agents; ARC routing/approval overrides alternate executors. Missing required skills block their stage. Integration includes saving, reviewing and directly revising the same spec or plan after the complete Planner first draft; design/brainstorming retain their Planner drafting path.
28
28
 
@@ -37,11 +37,45 @@ Before Planner dispatch, evaluate F1–F8 direct-path eligibility and Bounded pl
37
37
 
38
38
  1. Preflight relevant policy/references/profiles/tests/parity/manifest/conflicts. Apply formal-target and coordination provenance/input/local-skill gates, including required paths, approved bounded read alternatives and return conditions. Missing inputs/conflicts hold drafting. Read recovery grants no preparation/check/write/approval authority.
39
39
  2. Maintain a compact ledger of original requirements/IDs, approved/open decisions, exclusions and scope deltas. Consolidate intervening user changes into one brief delta. Separate approvals, path/line-verified facts, assumptions and open decisions.
40
- 3. NEVER reuse a Planner instance across stages. Within the design/brainstorming stage, reuse one Planner instance for the initial draft, its consolidated correction and any eligible further call while role, context and source remain valid; within a spec or plan stage, reuse that stage's Planner only for a budget-hold delta. After design approval, the spec stage and the plan stage each use a fresh Planner; its initial brief contains every required field plus saved document paths and approved versions, and cites a prior brief only when that brief is an accessible file. Send one complete stage-specific initial brief. Include verified source/HEAD/ownership, selected target intent and planned paths (or prepared target for later stages), and scope/exclusions/depth/dependencies/shared contracts/criteria/checks/evidence/holds. Include preceding approved versions and paths, current behavior and connected source/generated/runtime/installer/docs, policy conflicts/resolution direction and exact deliverable. Visual work includes approved sources/versions/criteria/open interpretations. Follow-up briefs send changed fields and cite an accessible prior brief for unchanged fields; inaccessible conversations or hashes alone cannot replace required inputs. Reuse evidence only for the same source set, absolute locator, resolved path, content fingerprint, purpose, approval scope and accessible context. When source, target or scope changed, reconfirm affected inputs.
41
- 4. Planner returns the complete proportional first draft and self-review. Bounded plan density follows the Planner profile's ARC adaptation (per task ID/title, goal/scope/files, predecessors, criteria and required checks; short self-review checklist), while Architectural plans keep full writing-plans.md density. Briefs carry the Read/Grep exploration budget and MAY set a handback size limit. A return that stops at the exploration budget with a Scouter request is an input hold, not a missing or failed first draft; resend the stage brief as a delta with the Scouter evidence to the same stage Planner. In the design stage, a resend after a return without a draft uses the consolidated-correction opportunity. Orchestrator saves and reviews it against the fixed checklist: scope/evidence; targets/ownership/paths; policy/conflicts; task boundaries/dependencies/criteria; checks/evidence/holds; roles/approval/commit boundaries; completeness. For spec or plan, Orchestrator directly revises the same document, including substantive omissions, before requesting approval. New product decisions outside approved scope require user input first; Orchestrator then revises the document. Missing or failed first drafts stop the stage and do not transfer initial authorship.
42
- 5. For design and brainstorming, finish the checklist before one consolidated correction covering every substantive omission with criterion/defect/evidence/expected fix. Use deltas/`unchanged`; NEVER split by omission. Further calls after correction need approved material scope/evidence changes or concrete unmet checklist items plus meaningful new input/criterion progress. State changed input/target criterion/expected artifact/progress. Existing-scope omissions need no renewed scope approval. Repeated unmet criteria without new input/evidence/progress hold the stage; report criterion/observation/exact unblock decision. DO NOT repeat resolved questions or count rewording/agent replacement as progress.
43
-
44
- For design and brainstorming, allow initial draft and one consolidated correction. Orchestrator handles reformatting, re-expression, save and patch errors without Planner calls. Separate substantive work uses normal gates. Design/spec/plan stages remain separately ordered; spec approval precedes dependent planning. Add no fixed call cap/profile count condition or incomplete-draft acceptance.
40
+ 3. NEVER reuse a Planner instance across stages, except the Architectural continuation below. Within the design/brainstorming stage, reuse one Planner instance for every [design conversation](#design-conversation) response, the final design, its consolidated correction and any eligible further call while role, context and source remain valid; within a spec or plan stage, reuse that stage's Planner only for a budget-hold delta. On the Architectural path, the design Planner returns the start summary instead of a final design and, after [start confirmation](#architectural-start-confirmation), continues as the spec Planner through a spec-stage delta brief while role, context and source remain valid. Every plan stage, and an Architectural spec stage without that continuation, uses a fresh Planner; its initial brief contains every required field plus saved document paths and approved versions (for the Architectural plan stage, the reviewed spec path, version and SHA-256), and cites a prior brief only when that brief is an accessible file. Send one complete stage-specific initial brief. Include verified source/HEAD/ownership, selected target intent and planned paths (or prepared target for later stages), and scope/exclusions/depth/dependencies/shared contracts/criteria/checks/evidence/holds. Include preceding approved versions and paths, current behavior and connected source/generated/runtime/installer/docs, policy conflicts/resolution direction and exact deliverable. Visual work includes approved sources/versions/criteria/open interpretations. Follow-up briefs send changed fields and cite an accessible prior brief for unchanged fields; inaccessible conversations or hashes alone cannot replace required inputs. Reuse evidence only for the same source set, absolute locator, resolved path, content fingerprint, purpose, approval scope and accessible context. When source, target or scope changed, reconfirm affected inputs.
41
+ 4. Planner returns the complete proportional first draft and self-review. Bounded plan density follows the Planner profile's ARC adaptation (per task ID/title, goal/scope/files, predecessors, criteria and required checks; short self-review checklist), while Architectural plans keep full writing-plans.md density. Briefs carry the Read/Grep exploration budget and MAY set a handback size limit. A return that stops at the exploration budget with a Scouter request is an input hold, not a missing or failed first draft; resend the stage brief as a delta with the Scouter evidence to the same stage Planner. In the design stage, [design conversation](#design-conversation) responses are expected returns and use no correction opportunity. Orchestrator saves and reviews it against the fixed checklist: scope/evidence; targets/ownership/paths; policy/conflicts; task boundaries/dependencies/criteria; checks/evidence/holds; roles/approval/commit boundaries; completeness; inventory/scope notation (final design, Architectural start summary and Architectural spec: complete [decision inventory](#decision-inventory); every document: every file or contract marked change or no change (reason), no ambiguous scope wording). For spec or plan, Orchestrator directly revises the same document, including substantive omissions, before requesting approval. New product decisions outside approved scope require user input first; Orchestrator then revises the document. Missing or failed first drafts stop the stage and do not transfer initial authorship.
42
+ 5. For design and brainstorming, finish the checklist on the final design before one consolidated correction covering every substantive omission with criterion/defect/evidence/expected fix. Use deltas/`unchanged`; NEVER split by omission. Further calls after correction need approved material scope/evidence changes or concrete unmet checklist items plus meaningful new input/criterion progress. State changed input/target criterion/expected artifact/progress. Existing-scope omissions need no renewed scope approval. Repeated unmet criteria without new input/evidence/progress hold the stage; report criterion/observation/exact unblock decision. DO NOT repeat resolved questions or count rewording/agent replacement as progress.
43
+
44
+ For design and brainstorming, converse under [design conversation](#design-conversation) and allow one consolidated correction on the final design. On the Architectural path the conversation ends with the start summary instead of a final design; the summary receives no consolidated correction, and Orchestrator's review and direct revision apply to the spec draft. Orchestrator handles reformatting, re-expression, save and patch errors without Planner calls. Separate substantive work uses normal gates. Design, spec and plan stages remain separately ordered: Architectural plan drafting starts only after the spec is saved, reviewed and revised and its reviewed path, version and SHA-256 are fixed; NEVER draft spec and plan concurrently. Add no fixed call cap/profile count condition or incomplete-draft acceptance.
45
+
46
+ <a id="design-conversation"></a>
47
+ ### Design conversation
48
+
49
+ These rules apply to feature/design/behavior design and brainstorming. Spike, the direct path (F1–F8) and non-behavior paths keep their existing rules and need no conversation. Planner never talks to the user directly: Planner → Orchestrator → user → Orchestrator → the same design Planner.
50
+
51
+ 1. Response shape: each design Planner response is exactly one of: one question; 2–3 approaches with a recommendation and a selection question; one design section with a confirmation question; or the final design (Architectural: the start summary). Planner splits each response into a user message and Orchestrator notes; Orchestrator relays the user message unchanged.
52
+ 2. When to ask: ask one question at a time, only when the answer changes the outcome and neither the sources nor the conversation already answer it. Otherwise state "my judgment" with its reason so the user can correct it.
53
+ 3. Reason first: when the user's reason is unknown, first ask one open question without options; offer options only after hearing the reason.
54
+ 4. Short path and opt-out: when the request is clear enough, the first response may carry a short design and ask for approval (Architectural: a short start summary and ask for start confirmation). When the user says to just proceed, stop asking, decide the remaining items as author judgments and list them in the final design or start summary.
55
+ 5. Relay: Orchestrator relays each user answer verbatim to the same design Planner and marks any interpretation it adds separately.
56
+ 6. No spinning: every call carries a new user answer or new evidence. DO NOT repeat a question without progress; without progress, report the blocked criterion, observed facts and the decision needed to unblock, and hold.
57
+ 7. Reuse and correction: reuse the same design Planner while role, context and source remain valid. Conversation responses are expected returns, not missing or failed drafts, and use no correction opportunity. Orchestrator's fixed-checklist review and one consolidated correction apply to the final design. On the Architectural path the consolidated correction does not apply to the start summary; Orchestrator checks its decision inventory and scope notation before presenting it, and the spec draft takes Orchestrator's review and direct revision.
58
+ 8. Full Auto: under [Full Auto](#full-auto-run-mode), Orchestrator records answers decidable within the original request as auto-decisions and sends only questions that need a new decision to the user; [approval.run-mode] limits apply unchanged.
59
+
60
+ <a id="architectural-start-confirmation"></a>
61
+ ### Architectural start confirmation
62
+
63
+ 1. Scope: on the Architectural path there is no design document and no design approval. Bounded keeps its design approval; Spike, the direct path (F1–F8) and non-behavior paths are unchanged.
64
+ 2. Start summary: when the [design conversation](#design-conversation) ends, the design Planner returns a short start summary instead of a final design: scope to change, user decisions, author judgments, already-answered items, open checks, path/depth/risk judgment, document set with planned relative paths, and every file or contract marked change or no change (reason). It carries the [decision inventory](#decision-inventory).
65
+ 3. Confirmation: Orchestrator checks the summary's decision inventory and scope notation, presents it and, in one confirmation, obtains the user's scope confirmation and explicit target choice under [handoff](handoff.md). The summary is neither saved nor committed. The confirmed summary supplies the approved scope/depth/document set and explicit choice required by the [formal drafting boundary](#formal-drafting-boundary).
66
+ 4. Continuation: Orchestrator sends the same Planner a spec-stage delta brief with verified source/branch/HEAD/ownership, the target choice, confirmed scope/depth, document set, planned paths and exploration budget; that Planner returns the complete first spec draft and self-review. If that Planner is unavailable or its role, context or source is no longer valid, assign a fresh spec Planner with a complete initial brief.
67
+ 5. Records: the spec records the conversation's user decisions and author judgments; later author judgments join the same list. A genuinely new decision during spec or plan drafting goes to the user; Orchestrator records the answer in the spec, rechecks spec↔plan consistency and redrafts affected documents. No design approval is requested.
68
+ 6. Full Auto: under [Full Auto](#full-auto-run-mode), scope confirmation within the original request may be auto-decided; target choice follows the Execution-target choice row; [approval.run-mode] limits apply unchanged.
69
+
70
+ <a id="decision-inventory"></a>
71
+ ### Decision inventory and question classification
72
+
73
+ 1. Decision inventory: before returning the final design or Architectural start summary, Planner lists what spec and plan drafting must decide, such as changed files, data formats, table notation, tests and generated artifacts, and classifies each item as a user decision (asked in the conversation; the answer is recorded in the design, or for Architectural in the start summary and then the spec), an author judgment (a minor item that does not change the deliverable; record "my judgment" and the reason) or already answered (cite the existing source or conversation). Bounded short designs carry a proportional inventory of a few lines; the per-file scope notation stays mandatory.
74
+ 2. Scope notation: designs, specs and plans mark every file or contract "change" or "no change (reason)". DO NOT use ambiguous scope wording such as "review only" or "if needed".
75
+ 3. Final design: the final design and its design approval request attach the author-judgment list. On the Architectural path the start summary and its start-confirmation request attach it, and the spec records the user decisions and author judgments.
76
+ 4. Spec and plan questions: spec and plan Planners classify each question raised while drafting. Answered by the design (Architectural: the confirmed start summary): follow it and cite the basis. Minor: decide it as an author judgment and record it in the document's author-judgment list with ID, judgment and reason; it is not an open decision. Genuinely new decision (changes the deliverable and is absent from the design or confirmed start summary): return it as an open decision with why the design review or start confirmation missed it; Orchestrator routes it to the user.
77
+ 5. Approval attachments: the Architectural [combined approval](#architectural-combined-approval) request attaches the complete author-judgment lists of the spec and every plan, and the Bounded plan approval request attaches the author judgments made since design approval. The approval unit is unchanged.
78
+ 6. Full Auto: author judgments are not open decisions when [Full Auto](#full-auto-run-mode) counts zero open decisions.
45
79
 
46
80
  <a id="design-and-planning"></a>
47
81
  <a id="design-path-and-plan-depth"></a>
@@ -50,14 +84,25 @@ For design and brainstorming, allow initial draft and one consolidated correctio
50
84
  Record depth separately from risk. Risk controls checks/review, not design paths/plan approval. Bounded/omission is not low risk; Architectural adds no Tester/Reviewer at every stage. Apply risk rules and specific obligations.
51
85
 
52
86
  1. Before feature/design/behavior work, assign brief/evidence/local `brainstorming` to Planner. Planner proposes context/path/options/tradeoffs/criteria/assumptions/questions; Orchestrator selects path, integrates, announces scope, routes revisions and obtains approval. NEVER run drafting skills itself. Direct path uses scope record only.
53
- 2. Spike distinguishes probe-only from specific combined scope. Bounded approves short design before Implementer; direct edits use approved scope record. Architectural approves design, then complete Planner spec/self-review, Orchestrator save/review and written-spec approval before planning. Planner is read-only and requests no approval.
54
- 3. Assess plan depth after design/spec approval and before Implementer, separately from files/LOC/Bounded label. Architectural always uses `writing-plans` and written-plan approval regardless of size/locality/risk. Bounded skips only for one local change, no dependent stages/cross-component shared state/lifecycle/integration-order concerns and one verification path. Otherwise require a plan. Labels/no-plan requests do not bypass judgment, which also records Bounded spec necessity.
87
+ 2. Spike distinguishes probe-only from specific combined scope. Bounded approves short design before Implementer; direct edits use approved scope record. Architectural replaces design approval with one [start confirmation](#architectural-start-confirmation), then complete Planner spec/self-review and Orchestrator save/review/revision without a separate spec approval request; a fresh plan Planner then drafts from the reviewed spec, and the spec and every plan receive one [combined approval](#architectural-combined-approval). Planner is read-only and requests no approval.
88
+ 3. Assess plan depth after design approval (Architectural: start confirmation) and before Implementer, separately from files/LOC/Bounded label. Architectural always uses `writing-plans` and the combined spec+plan approval regardless of size/locality/risk. Bounded skips only for one local change, no dependent stages/cross-component shared state/lifecycle/integration-order concerns and one verification path. Otherwise require a plan. Labels/no-plan requests do not bypass judgment.
55
89
  4. Record dependencies/depth reasons; also post the design path, depth and risk judgments in the SKILL.md Pre-action gate record. Planner returns complete plan/assumptions/open decisions/checks/self-review. Orchestrator saves/reviews/obtains approval before Implementer at user path or `docs/superpowers/plans/YYYY-MM-DD-<feature-name>.md`. Default spec path is `docs/superpowers/specs/YYYY-MM-DD-<topic>-design.md`.
56
90
  5. Every Implementer first start/restart needs applicable approvals/artifacts/brief/findings and full handoff. Non-behavior docs/config omit only inapplicable stages. Direct edits need approved scope record and same first-edit gates.
57
91
 
58
- If Bounded requires written spec, record necessity/scope using approved short design as basis. Planner returns proportional full spec/self-review; After actual preparation, Orchestrator saves/reviews/obtains individual approval in the prepared target before the dependent plan. Short design approval never substitutes. This applies recorded judgment, not new spec necessity. Required plans alone imply no written spec.
92
+ Bounded has no spec stage, spec approval or spec-necessity record. If Bounded work appears to need a spec-level document, do not write one inside Bounded: reassess the design path as Architectural, inform the user and obtain the path-change approval required by existing rules before dependent drafting. Required plans alone imply no written spec.
93
+
94
+ Only Planner authors the first complete spec or plan draft and self-review. Orchestrator reviews and directly revises the same document before approval. Unavailable/failed Planner stops first drafting rather than transferring authorship. Design approval or start confirmation does not transfer initial authorship.
59
95
 
60
- Only Planner authors the first complete spec or plan draft and self-review. Orchestrator reviews and directly revises the same document before approval. Unavailable/failed Planner stops first drafting rather than transferring authorship. Design approval does not transfer initial authorship.
96
+ <a id="architectural-combined-approval"></a>
97
+ ## Architectural combined approval
98
+
99
+ 1. Sequential drafting (R0): Assign the fresh plan Planner only after the spec Planner returned the complete draft and self-review, Orchestrator saved it in the prepared target, reviewed it and made needed revisions, and the reviewed spec's path, version and SHA-256 are fixed and cited in the plan brief. NEVER draft a plan early or dispatch spec and plan Planners in parallel. Request no approval between the spec and plan stages.
100
+ 2. Approval unit (R1): Before requesting approval, verify spec↔plan consistency: every spec requirement and acceptance criterion maps to plan tasks or final verification, and the plan cites the current spec version and SHA-256. Request one combined approval for the exact versions and SHA-256 of the spec and every in-scope plan, attaching the complete author-judgment lists of the spec and every plan ([decision inventory](#decision-inventory)); record it once and make every document's `approvalRef` cite it.
101
+ 3. Partial answers (R2): A reply approving only part of the set, such as approving the spec while asking for plan changes, is a revision request. Orchestrator revises the documents directly, asking the user first for decisions outside approved scope; after any spec change it rechecks spec↔plan consistency; then it requests combined approval for the whole revised set. Partial approvals never carry over.
102
+ 4. Invalidation (R3): Any content change to any document after the approval request voids that request; request combined approval again for the current set.
103
+ 5. Spec ownership in the plan stage (R4): The plan Planner never edits the spec; it returns needed spec changes classified under [question classification](#decision-inventory). Within the confirmed start scope Orchestrator revises the spec directly; a genuinely new decision outside it needs user input, which Orchestrator records in the spec; it then rechecks spec↔plan consistency and the affected documents are redrafted.
104
+ 6. Rework (R5): If spec rejection requires substantive plan rework, use a fresh plan Planner under the normal Planner gate; Orchestrator handles formatting, re-expression, save and patch errors.
105
+ 7. Commit and Implementer (R6): Before combined approval, commit no planning document and start no Implementer. After it, make one planning-document commit under [handoff-prep](handoff-prep.md#planning-document-commit).
61
106
 
62
107
  For initial fast judgment apply the [fast gate](handoff.md#orchestrator-direct-path-for-small-tasks); its sufficient conditions do not change these depth decisions.
63
108
 
@@ -84,32 +129,32 @@ Example: with A → B → C, independent D and two slots, start A/D. After A's c
84
129
  <a id="document-save-evidence-gates"></a>
85
130
  ## Document-save evidence gates
86
131
 
87
- Before first Architectural spec, required Bounded spec or plan save, read this and record accessible brief/canonical evidence. Saving creates reviewable files, not approval/commits.
132
+ Before the first Architectural spec save or any plan save, read this and record accessible brief/canonical evidence. Saving creates reviewable files, not approval/commits.
88
133
 
89
134
  | Save | Required evidence |
90
135
  |---|---|
91
- | Spec | Approved design scope/evidence, complete Planner draft/self-review, Orchestrator integration/save/review ownership and absolute path. Required Bounded specs also need depth judgment, short design, necessity/scope |
92
- | Plan | Approved design and required approved spec/version/evidence, depth judgment, plan list/dependencies, complete Planner draft/self-review, ownership and absolute path |
136
+ | Spec | Confirmed start scope/evidence ([start confirmation](#architectural-start-confirmation)), complete Planner draft/self-review, Orchestrator integration/save/review ownership and absolute path. Architectural only |
137
+ | Plan | Bounded: approved design; Architectural: confirmed start scope and the reviewed spec path/version/SHA-256 and review evidence; depth judgment, plan list/dependencies, complete Planner draft/self-review, ownership and absolute path |
93
138
 
94
- Saving for review does not require prior written-spec approval, but does require valid target choice/actual preparation. Individually approved specs enter the document set before dependent planning. NEVER call uncommitted files committed. Missing or mismatched evidence stops the affected save.
139
+ Saving for review requires no prior document approval, but does require valid target choice/actual preparation. The reviewed Architectural spec enters the document set before dependent planning; approval follows once for the full set. NEVER call uncommitted files committed. Missing or mismatched evidence stops the affected save.
95
140
 
96
141
  <a id="complete-planning-document-set"></a>
97
142
  ## Complete planning-document set
98
143
 
99
- Include all current-scope required specs/plans, excluding future projects. Record scope/depth/absolute paths/coverage/versions/status/dependencies/order/omissions/reasons/pending drafting and approvals. Complete means every required document written/individually approved and no unresolved decision requiring another document. Omit no required artifact.
144
+ Include all current-scope required specs/plans, excluding future projects. Record scope/depth/absolute paths/coverage/versions/status/dependencies/order/omissions/reasons/pending drafting and approvals. Complete means every required document written and approved (Architectural: one combined spec+plan approval; Bounded: plan approval) and no unresolved decision requiring another document. Omit no required artifact.
100
145
 
101
- A required plan implies no spec. Bounded follows recorded judgment; spec stages cover Architectural/required Bounded only, plan stages required plans only. Add no spec duty to Spike/plan-skip/non-behavior paths.
146
+ A required plan implies no spec. Spec stages cover Architectural only; plan stages cover required plans only. Add no spec duty to Spike/plan-skip/non-behavior paths.
102
147
 
103
- Order: initial design approval → explicit target and source snapshot → first required draft/self-review → focused preparation gate → actual preparation/comparison → save/review/individual approval → dependent plans drafting/save/review/individual approval → full set → verify existing commits/batch remaining approvals → final Git → Implementer. Omission skips only inapplicable documents with rationale. Complete documents precede staging/commit/handoff, not initial preparation/choice request. Partial approvals authorize no early implementation.
148
+ Order: initial design approval → explicit target and source snapshot → first required draft/self-review → focused preparation gate → actual preparation/comparison → save/review/revision → Architectural: dependent plan drafting/save/review/revision → spec↔plan consistency check → one combined approval; Bounded: plan approval → full set → verify existing commits/batch remaining approvals → final Git → Implementer. On the Architectural path, [start confirmation](#architectural-start-confirmation) takes the place of initial design approval in this order and carries the explicit target choice. Omission skips only inapplicable documents with rationale. Complete documents precede staging/commit/handoff, not initial preparation/choice request. Partial approvals authorize no early implementation.
104
149
 
105
- Defer local `brainstorming`'s early spec commit: save/self-review/approve uncommitted spec, approve all plans, then final batch. Modify no external skill. `writing-plans` implementation commits grant neither planning-document commits nor early Implementer.
150
+ Defer local `brainstorming`'s early spec commit: save/self-review/review the uncommitted spec, draft/save/review all plans, obtain the combined approval, then final batch. Modify no external skill. `writing-plans` implementation commits grant neither planning-document commits nor early Implementer.
106
151
 
107
152
  | Path | Approval/preparation |
108
153
  |---|---|
109
154
  | Spike | Approve question/method/scope/criteria/constraints; no forced unknown-implementation docs. Implementer probes require handoff; read-only Orchestrator/Planner probes without Implementer do not trigger it |
110
155
  | Bounded, plan skipped | Approve short design; record omission conditions. Complete approvals, target choice, actual docs or valid absence, then handoff |
111
- | Bounded, plan required | Approve design/all required plans; approve necessary specs before dependent planning. Draft the first required document before target preparation; complete set before batch/handoff |
112
- | Architectural | Design → written spec → all `writing-plans` plans. First spec draft before target preparation; full set before batch/final checks/handoff |
156
+ | Bounded, plan required | Approve design and all required plans; no spec. Draft the first required plan before target preparation; complete set before batch/handoff |
157
+ | Architectural | Start confirmation → reviewed written spec → all `writing-plans` plans → one combined spec+plan approval. First spec draft before target preparation; full set before batch/final checks/handoff |
113
158
  | Non-behavior docs/config | Record scope/criteria/inapplicability. Preserve target/Git/docs-or-absence/handoff |
114
159
 
115
160
  New planning scope requires list/depth/dependency reassessment and approvals before dependent drafting/commit. Approved-body changes need revised approval except task progress records below. New implementation scope holds execution until docs/approvals/preparation complete. Running Implementer stops before newly dependent edits; inspect actual changes/Git without retrospective preparation claims. Reflect approved versions through pending revisions below. Unchanged-document restarts follow handoff lifetime.
@@ -119,7 +164,9 @@ New planning scope requires list/depth/dependency reassessment and approvals bef
119
164
 
120
165
  Task progress records (checkboxes, notes, results, evidence and completion status) preserving the approved contract need no new approval; record classification/reason/actual time. Plan-level progress records (final verification results, final Reviewer round verdicts and finding dispositions with user-decision references, and overall completion status) follow [commit](commit.md#execution-time-plan-document-updates): they ride the plan's next task acceptance or final Reviewer follow-up commit, or a standalone closing commit made for pending revisions; otherwise they stay only in the canonical record. After task completion Orchestrator includes that task's own records with its accepted implementation work in the same focused commit, excluding other tasks. DO NOT amend the original planning commit or create a separate docs/fixup commit for those records. Accepted no-change tasks follow the no-change path without empty commits. Removing checks, invented success, unsupported acceptance or mixed scope changes are not progress records.
121
166
 
122
- Changes to goals, task boundaries, scope, criteria, method, risk, dependencies or checks require revised approval before affected work. Hold, obtain ordered design/spec/plan approvals and prepare target/ownership/checks/handoff. Other body corrections follow version approval; classify typos/paths/commands/explanations by semantic effect. Every non-progress content change, including a mechanical correction, is a plan revision requiring applicable approval/preparation. A contract revision requires a fresh Implementer for remaining work; obtain written-spec approval before a dependent plan revision.
167
+ Changes to goals, task boundaries, scope, criteria, method, risk, dependencies or checks require revised approval before affected work. Hold, obtain the applicable design approval (Bounded; Architectural records the new decision in the revised spec) and document approvals below and prepare target/ownership/checks/handoff. Other body corrections follow version approval; classify typos/paths/commands/explanations by semantic effect. Every non-progress content change, including a mechanical correction, is a plan revision requiring applicable approval/preparation. A contract revision requires a fresh Implementer for remaining work.
168
+
169
+ Execution-time document revisions take this approval: a spec change with affected plans needs one combined revision approval for the spec and those plans; a plan-only change needs plan approval; a spec-only change needs spec approval after Orchestrator records why no plan is affected. Partial approvals never carry over.
123
170
 
124
171
  After approval Orchestrator edits the same file, appends a revision-history row and leaves the revision uncommitted. Apply cumulative revisions to that file and append another row. At document end use `Version | Approval time | Classification | Affected tasks | Reason`; keep rows append-only, with no SHA. Add v1 at the first revision using the actual initial approval time. Preserve actual approval chronology, not retroactive authorization; later committed content proves no earlier approval.
125
172
 
@@ -157,7 +204,7 @@ Generated from lib/policy/role-policy.json; do not edit this managed section man
157
204
  - [review.significant-plan] Significant/high-risk plan work follows Implementer → required fresh Tester → Orchestrator acceptance and focused commit for each task. After all tasks are accepted and required Tester is complete, Reviewer reviews the final full change once. Reviewer is not a per-task or per-commit gate. Preserve required checks and necessary finding rechecks.
158
205
  - [review.final-plan-recheck] Complete required Tester, Tester failure rechecks and final-mode Tester work before the initial final overall Reviewer review; final-mode Tester work concludes when its report is delivered, its new failures are resolved through Implementer → Tester recheck, its new-failure and intermittent candidates are dispositioned, any approved full regression is complete and every undeterminable-scope item is dispositioned. Once that review begins on plan work, every final Reviewer finding, including behavior, follows Implementer → Reviewer without Tester reassignment until resolved. Keep corrections uncommitted through Reviewer rechecks, then accept and create one focused follow-up commit. Tester findings and new failures from final verification follow Implementer → Tester before that review begins. Preserve required Tester outside this final Reviewer exception.
159
206
  - [planning.plan-revision] Task progress records (checkboxes, notes, results, evidence and status) preserving the approved contract need no new user approval; Orchestrator includes the completed task's own records in its accepted implementation commit and records classification, reason and actual time as applicable. Plan-level progress records preserving the approved contract also need no new user approval and alone never trigger the standalone docs(plan) closing commit. All other spec/plan content changes, contract or mechanical, require applicable approval and preparation; changes to goals, scope, criteria, method, risk, dependencies or required verification need revised-version approval, preparation and holds on affected work before it continues, with a fresh Implementer for remaining work. After approval Orchestrator edits the same document, appends a revision-history row and leaves it uncommitted as an Orchestrator-owned pending revision, recording version, content hash, approval reference, actual time, classification, reason, affected tasks and the full approved content in the canonical handoff record. Orchestrator includes all pending revisions with Plan-Revision, Plan-Approved-At and Plan-Reason trailers in the accepted commit of the first top-level task executed or reconfirmed against the revised version, otherwise in a current task or final Reviewer follow-up commit; only when no implementation work remains before overall completion MAY it make one standalone docs(plan) closing commit without implementation files. Exclude revision hunks from commits of independent tasks accepted on a prior version, or hold that commit when separation is unsafe. NEVER amend or rewrite planning or implementation commits, create any other docs/fixup commit or authorize past work retroactively. After commit verify the committed document content matches the latest approved content apart from classified progress records of that commit's task or committed for other tasks after approval, or plan-level progress records carried by that commit, and that no pending revision remains. Follow planning, handoff-prep, commit and verification for the full contract.
160
- - [planning.planner-brief] Follow planning.md's Planner drafting preparation and review procedure, including preflight, ledger, evidence classification, target preparation, preceding approvals, provenance and reference gates. Before Planner dispatch, evaluate F1–F8 direct-path eligibility and Bounded plan-omission eligibility independently. Enter each path only when all of that path's existing conditions are proven; if neither path qualifies, use normal full evaluation. Send one complete stage-specific initial brief. Reuse the same Planner instance only within the design/brainstorming stage while its role, context and source remain valid; after design approval, use a fresh Planner instance for each spec and plan stage, whose initial brief contains every required field, saved document paths and approved versions. Follow-up briefs send changed fields and cite an accessible prior brief for unchanged fields. Reuse evidence only for the same source set, absolute locator, resolved path, content fingerprint, purpose and approval scope in an accessible matching context. When source, target or scope changed, reconfirm affected inputs. Planner returns a complete proportional first draft and self-review. Orchestrator reviews and directly revises the same spec or plan when needed. A missing or failed first draft does not transfer initial authorship to Orchestrator. New product decisions outside approved scope require user input before Orchestrator revises the document. For design and brainstorming, allow the initial draft and one consolidated correction. Orchestrator reviews once with the fixed checklist and sends one consolidated correction using changed fields only. Further calls require user-approved material scope/evidence changes or concrete unmet checklist items after correction, plus meaningful new input or criterion-state progress. State changed input, target criterion, expected artifact and expected progress. Repeated unmet criteria without new input, evidence or progress hold the stage; report the criterion, observed evidence and exact unblock input/decision. DO NOT split omissions, repeat resolved items or count rewording/agent replacement as progress. DO NOT invoke Planner only for reformatting, re-expression, save errors or patch-application errors; Orchestrator handles these. Evaluate separate substantive work under the normal Planner gate. Preserve separate sequential design/spec/plan approvals. Add no fixed call cap or profile call-count conditions, and NEVER accept an incomplete draft. Keep user progress brief and based on Planner status without relaying draft content. At approval, present the integrated, saved and reviewed Markdown without repeating its body in chat.
207
+ - [planning.planner-brief] Follow planning.md's Planner drafting preparation and review procedure, including preflight, ledger, evidence classification, target preparation, preceding approvals, provenance and reference gates. Before Planner dispatch, evaluate F1–F8 direct-path eligibility and Bounded plan-omission eligibility independently. Enter each path only when all of that path's existing conditions are proven; if neither path qualifies, use normal full evaluation. Send one complete stage-specific initial brief. Reuse the same Planner instance only within the design/brainstorming stage while its role, context and source remain valid, except that on the Architectural path that Planner continues as the spec Planner after start confirmation through a spec-stage delta brief; use a fresh Planner instance for each plan stage, and for an Architectural spec stage when that Planner is unavailable or its role, context or source is no longer valid, whose initial brief contains every required field, saved document paths and approved versions (for the Architectural plan stage, the reviewed spec path, version and SHA-256). Follow-up briefs send changed fields and cite an accessible prior brief for unchanged fields. Reuse evidence only for the same source set, absolute locator, resolved path, content fingerprint, purpose and approval scope in an accessible matching context. When source, target or scope changed, reconfirm affected inputs. Planner returns a complete proportional first draft and self-review. Orchestrator reviews and directly revises the same spec or plan when needed. A missing or failed first draft does not transfer initial authorship to Orchestrator. New product decisions outside approved scope require user input before Orchestrator revises the document. For design and brainstorming, follow planning.md's design conversation: each Planner response is exactly one of one question, 2–3 approaches with a recommendation and a selection question, one design section with a confirmation question, or the final design (Architectural: the start summary). Ask one question at a time only when the answer changes the outcome and is not already answered; otherwise state the judgment and its reason. Ask an open question about the user's reason before offering options. A clear request may receive a short design for approval at once; when the user says to proceed, stop asking and list the remaining author judgments in the final design or start summary. Relay user answers verbatim and mark added interpretation separately. Every call needs a new user answer or new evidence; without progress, report the blocked criterion, observed facts and needed decision, and hold. Conversation responses use no correction opportunity. Orchestrator reviews the final design once with the fixed checklist, including decision-inventory completeness and no ambiguous scope wording, and sends one consolidated correction using changed fields only. On the Architectural path the start summary receives no consolidated correction; Orchestrator checks its decision inventory and scope notation before presenting it, and the spec draft takes Orchestrator's review and direct revision. Further calls require user-approved material scope/evidence changes or concrete unmet checklist items after correction, plus meaningful new input or criterion-state progress. State changed input, target criterion, expected artifact and expected progress. Repeated unmet criteria without new input, evidence or progress hold the stage; report the criterion, observed evidence and exact unblock input/decision. DO NOT split omissions, repeat resolved items or count rewording/agent replacement as progress. DO NOT invoke Planner only for reformatting, re-expression, save errors or patch-application errors; Orchestrator handles these. Evaluate separate substantive work under the normal Planner gate. For Bounded work, obtain design approval before plan drafting. For Architectural work, obtain one start confirmation (scope and explicit target; no design document or design approval) before spec drafting, let the design Planner continue as the spec Planner (a fresh spec Planner when it is unavailable or invalid), then draft the plan with a fresh Planner, assigning the plan Planner only after the spec is saved and reviewed and its path, version and SHA-256 are fixed; NEVER draft them concurrently; then obtain one combined spec+plan approval. Bounded work has no spec stage; required plans keep their own approval. Add no fixed call cap or profile call-count conditions, and NEVER accept an incomplete draft. Keep user progress brief and based on Planner status without relaying draft content. At approval, present the integrated, saved and reviewed Markdown without repeating its body in chat.
161
208
  - [platform.grok] Role restrictions are prompt-level contracts, not a filesystem sandbox. Grok sandboxing, native tool restriction fields, observer hooks and Git guards are unverified, and Grok may continue without its sandbox. Use only available authorized tools; ARC disables Grok Claude compatibility (agents, skills, rules in config.toml; also MCPs and hooks for bridge children), but whether Grok sessions honor these settings is unverified.
162
209
  [ARC role policy: contract end]
163
210
 
@@ -168,7 +215,7 @@ Installed workflow connects plan-mode document commits to initial Implementer as
168
215
 
169
216
  Entry updates migrate no state/renew no approvals; drift requires current evidence. Scope is repository cooperative decisions/records, not native hook/provider/installer installation or blocking direct tools. `no-plan`/omission stays unsupported through Phases 2/3, implying neither policy violation nor new document duty.
170
217
 
171
- Record approved spec/plan SHA-256, shared docs-only commit and document/approval versions. CLI verifies exact Git-object paths/current bytes before assignment intent. New workflows/late commits prove no past compliance. Prior history/outside execution stays unverified. Approval/native results are `operator-attested`; agent IDs are not authenticated identity.
218
+ Record approved planning-document SHA-256 (Architectural spec and plans; Bounded plans), shared docs-only commit and document/approval versions. CLI verifies exact Git-object paths/current bytes before assignment intent. New workflows/late commits prove no past compliance. Prior history/outside execution stays unverified. Approval/native results are `operator-attested`; agent IDs are not authenticated identity.
172
219
 
173
220
  <a id="full-auto-run-mode"></a>
174
221
  ## Full Auto run mode
@@ -181,7 +228,8 @@ Applies only when the installed SKILL.md contains `**Run mode:** Full Auto.` and
181
228
  | Branch name collision | auto | Next numeric suffix (`-2`, `-3`, …) |
182
229
  | Planner options and questions | auto | Recommended option; record assumptions in the brief |
183
230
  | Design and short-design approval | auto | After Orchestrator review |
184
- | Written spec approval | auto | After Orchestrator review |
231
+ | Architectural start confirmation | auto | Scope only within the original request, otherwise user; target follows the Execution-target choice row |
232
+ | Architectural spec+plan combined approval | auto | Only with zero open decisions; otherwise user |
185
233
  | Plan approval | auto | Only with zero open decisions; otherwise user |
186
234
  | Spec/plan revision within the original scope | auto | Scope-expanding revisions → user |
187
235
  | Non-blocking final Reviewer finding disposition | auto | Fix or no-fix decision only: recommended disposition within approved scope; scope-expanding fixes → user; Reviewer recheck and acceptance stay unchanged |
@@ -428,7 +428,7 @@
428
428
  "preceding-approval"
429
429
  ],
430
430
  "authority": "orchestrator",
431
- "text": "Follow planning.md's Planner drafting preparation and review procedure, including preflight, ledger, evidence classification, target preparation, preceding approvals, provenance and reference gates. Before Planner dispatch, evaluate F1–F8 direct-path eligibility and Bounded plan-omission eligibility independently. Enter each path only when all of that path's existing conditions are proven; if neither path qualifies, use normal full evaluation. Send one complete stage-specific initial brief. Reuse the same Planner instance only within the design/brainstorming stage while its role, context and source remain valid; after design approval, use a fresh Planner instance for each spec and plan stage, whose initial brief contains every required field, saved document paths and approved versions. Follow-up briefs send changed fields and cite an accessible prior brief for unchanged fields. Reuse evidence only for the same source set, absolute locator, resolved path, content fingerprint, purpose and approval scope in an accessible matching context. When source, target or scope changed, reconfirm affected inputs. Planner returns a complete proportional first draft and self-review. Orchestrator reviews and directly revises the same spec or plan when needed. A missing or failed first draft does not transfer initial authorship to Orchestrator. New product decisions outside approved scope require user input before Orchestrator revises the document. For design and brainstorming, allow the initial draft and one consolidated correction. Orchestrator reviews once with the fixed checklist and sends one consolidated correction using changed fields only. Further calls require user-approved material scope/evidence changes or concrete unmet checklist items after correction, plus meaningful new input or criterion-state progress. State changed input, target criterion, expected artifact and expected progress. Repeated unmet criteria without new input, evidence or progress hold the stage; report the criterion, observed evidence and exact unblock input/decision. DO NOT split omissions, repeat resolved items or count rewording/agent replacement as progress. DO NOT invoke Planner only for reformatting, re-expression, save errors or patch-application errors; Orchestrator handles these. Evaluate separate substantive work under the normal Planner gate. Preserve separate sequential design/spec/plan approvals. Add no fixed call cap or profile call-count conditions, and NEVER accept an incomplete draft. Keep user progress brief and based on Planner status without relaying draft content. At approval, present the integrated, saved and reviewed Markdown without repeating its body in chat.",
431
+ "text": "Follow planning.md's Planner drafting preparation and review procedure, including preflight, ledger, evidence classification, target preparation, preceding approvals, provenance and reference gates. Before Planner dispatch, evaluate F1–F8 direct-path eligibility and Bounded plan-omission eligibility independently. Enter each path only when all of that path's existing conditions are proven; if neither path qualifies, use normal full evaluation. Send one complete stage-specific initial brief. Reuse the same Planner instance only within the design/brainstorming stage while its role, context and source remain valid, except that on the Architectural path that Planner continues as the spec Planner after start confirmation through a spec-stage delta brief; use a fresh Planner instance for each plan stage, and for an Architectural spec stage when that Planner is unavailable or its role, context or source is no longer valid, whose initial brief contains every required field, saved document paths and approved versions (for the Architectural plan stage, the reviewed spec path, version and SHA-256). Follow-up briefs send changed fields and cite an accessible prior brief for unchanged fields. Reuse evidence only for the same source set, absolute locator, resolved path, content fingerprint, purpose and approval scope in an accessible matching context. When source, target or scope changed, reconfirm affected inputs. Planner returns a complete proportional first draft and self-review. Orchestrator reviews and directly revises the same spec or plan when needed. A missing or failed first draft does not transfer initial authorship to Orchestrator. New product decisions outside approved scope require user input before Orchestrator revises the document. For design and brainstorming, follow planning.md's design conversation: each Planner response is exactly one of one question, 2–3 approaches with a recommendation and a selection question, one design section with a confirmation question, or the final design (Architectural: the start summary). Ask one question at a time only when the answer changes the outcome and is not already answered; otherwise state the judgment and its reason. Ask an open question about the user's reason before offering options. A clear request may receive a short design for approval at once; when the user says to proceed, stop asking and list the remaining author judgments in the final design or start summary. Relay user answers verbatim and mark added interpretation separately. Every call needs a new user answer or new evidence; without progress, report the blocked criterion, observed facts and needed decision, and hold. Conversation responses use no correction opportunity. Orchestrator reviews the final design once with the fixed checklist, including decision-inventory completeness and no ambiguous scope wording, and sends one consolidated correction using changed fields only. On the Architectural path the start summary receives no consolidated correction; Orchestrator checks its decision inventory and scope notation before presenting it, and the spec draft takes Orchestrator's review and direct revision. Further calls require user-approved material scope/evidence changes or concrete unmet checklist items after correction, plus meaningful new input or criterion-state progress. State changed input, target criterion, expected artifact and expected progress. Repeated unmet criteria without new input, evidence or progress hold the stage; report the criterion, observed evidence and exact unblock input/decision. DO NOT split omissions, repeat resolved items or count rewording/agent replacement as progress. DO NOT invoke Planner only for reformatting, re-expression, save errors or patch-application errors; Orchestrator handles these. Evaluate separate substantive work under the normal Planner gate. For Bounded work, obtain design approval before plan drafting. For Architectural work, obtain one start confirmation (scope and explicit target; no design document or design approval) before spec drafting, let the design Planner continue as the spec Planner (a fresh spec Planner when it is unavailable or invalid), then draft the plan with a fresh Planner, assigning the plan Planner only after the spec is saved and reviewed and its path, version and SHA-256 are fixed; NEVER draft them concurrently; then obtain one combined spec+plan approval. Bounded work has no spec stage; required plans keep their own approval. Add no fixed call cap or profile call-count conditions, and NEVER accept an incomplete draft. Keep user progress brief and based on Planner status without relaying draft content. At approval, present the integrated, saved and reviewed Markdown without repeating its body in chat.",
432
432
  "controls": {
433
433
  "codex": "prompt",
434
434
  "claude": "prompt",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  {
49
49
  "id": "planner.target-evidence",
50
- "text": "Before the first required spec/plan draft, require verified source workspace/repository, branch or detached HEAD, HEAD, changes/ownership, explicit target choice, approved scope/depth/document set and planned relative paths in the brief. Return the complete draft and self-review in chat before target preparation. Initial design proposals and brainstorming MAY precede selection. Planned paths or approvals alone do not prove preparation. Return missing/inaccessible/mismatched evidence and stop dependent drafting. NEVER prepare or switch targets. Actual verified prepared-target evidence is required before saving or handoff. Required written-spec approval precedes dependent plans. Return drafts only; Orchestrator saves them and requests approval."
50
+ "text": "Before the first required spec/plan draft, require verified source workspace/repository, branch or detached HEAD, HEAD, changes/ownership, explicit target choice, approved scope/depth/document set and planned relative paths in the brief. Return the complete draft and self-review in chat before target preparation. Initial design proposals and brainstorming MAY precede selection. Planned paths or approvals alone do not prove preparation. Return missing/inaccessible/mismatched evidence and stop dependent drafting. NEVER prepare or switch targets. Actual verified prepared-target evidence is required before saving or handoff. Architectural plan drafting requires the saved, Orchestrator-reviewed spec's path, version and SHA-256; NEVER draft a plan before or in parallel with the spec. The spec and plans receive one combined approval; Bounded work has no spec stage. Return drafts only; Orchestrator saves them and requests approval."
51
51
  },
52
52
  {
53
53
  "id": "planner.task-shape",
@@ -67,7 +67,7 @@
67
67
  },
68
68
  {
69
69
  "id": "planner.workflow-contract",
70
- "text": "- Draft only designs/specs/plans for Orchestrator. DO NOT implement, verify, review or save documents. Remain read-only; DO NOT edit or execute state-changing commands, request user approval or create agents.\n- Use supplied brief/prior evidence. Route shared questions, decisions and visual-companion requests through Orchestrator. Wait at applicable gates for required answers/decisions. Orchestrator owns development approval and completion.\n- For assigned feature/design/behavior work, read brief-cited `references/brainstorming.md`. Return context, Spike/Bounded/Architectural path, designs/options, tradeoffs, criteria, assumptions and focused questions. Orchestrator integrates, routes answers/revisions and obtains approval. After architectural design approval, return a complete spec and self-review; Orchestrator saves/reviews and directly revises the same spec when needed, then obtains written-spec approval.\n- After written-spec approval, Architectural work always reads brief-cited `references/writing-plans.md`, regardless of size, locality or risk. Bounded work follows Orchestrator's separate depth assessment. Skip planning only for one local change, no dependent stages/cross-component shared state/lifecycle/integration-order concerns and one focused verification path.\n- When needed, return the complete proportional plan, dependencies, assumptions/open decisions, verification needs and self-review. Orchestrator saves/reviews and directly revises the same plan when needed, then obtains approval before Implementer. Bounded/no-plan labels waive nothing.\n- If a skill requires writing, approval or implementation, return the draft and next actions instead. Skills add no agents. Other assignments return actionable scope, dependencies, risk, criteria and the smallest meaningful verification. Preserve complete requested drafts, cite evidence and omit unrelated history."
70
+ "text": "- Draft only designs/specs/plans for Orchestrator. DO NOT implement, verify, review or save documents. Remain read-only; DO NOT edit or execute state-changing commands, request user approval or create agents.\n- Use supplied brief/prior evidence. Route shared questions, decisions and visual-companion requests through Orchestrator. Wait at applicable gates for required answers/decisions. Orchestrator owns development approval and completion.\n- For assigned feature/design/behavior work, read brief-cited `references/brainstorming.md`. Converse through Orchestrator under planning.md's design conversation: each response is exactly one of one question, 2–3 approaches with a recommendation and a selection question, one design section with a confirmation question, or the final design (on the Architectural path, the start summary) with context, Spike/Bounded/Architectural path, options, tradeoffs, criteria and assumptions. Split each response into a user message, which Orchestrator relays unchanged, and Orchestrator notes. Ask one question at a time only when the answer changes the outcome and is not already answered; otherwise state your judgment and reason. Ask an open question about the user's reason before offering options. For a clear request, the first response may be a short design for approval; when the user says to proceed, stop asking and list the remaining author judgments. Each call carries a new user answer, relayed verbatim with any Orchestrator interpretation marked, or new evidence; without progress, return the blocked criterion, observed facts and needed decision as a hold. The same design Planner continues while role, context and source remain valid; conversation responses use no correction opportunity, and only the final design receives Orchestrator's one consolidated correction. Before the final design or Architectural start summary, build a decision inventory classifying each item as user decision, author judgment or already answered, mark every file or contract change or no change (reason) without ambiguous scope wording, and attach the author-judgment list. Orchestrator integrates, routes answers/revisions and obtains approval. On the Architectural path there is no design document or design approval: after Orchestrator relays the start confirmation in a spec-stage delta brief, continue as the spec Planner and return a complete spec and self-review; Orchestrator saves/reviews and directly revises the same spec when needed, without a separate spec approval; a fresh plan Planner drafts next.\n- In spec and plan stages, classify each drafting question: answered by the design or confirmed start summary → follow it and cite the basis; minor, with no deliverable change → decide it as an author judgment and list it with ID, judgment and reason (not an open decision); genuinely new decision that changes the deliverable and is absent from the design or confirmed start summary → return it as an open decision with why the design review or start confirmation missed it. Mark every file or contract change or no change (reason).\n- In the Architectural plan stage, whose brief cites the reviewed spec's path, version and SHA-256, always read brief-cited `references/writing-plans.md`, regardless of size, locality or risk. NEVER edit the spec; return needed spec changes under the question classification above. Bounded work follows Orchestrator's separate depth assessment. Skip planning only for one local change, no dependent stages/cross-component shared state/lifecycle/integration-order concerns and one focused verification path.\n- When needed, return the complete proportional plan, dependencies, assumptions, author judgments, open decisions, verification needs and self-review. Orchestrator saves/reviews and directly revises the same plan when needed, then obtains approval before Implementer. Bounded/no-plan labels waive nothing.\n- If a skill requires writing, approval or implementation, return the draft and next actions instead. Skills add no agents. Other assignments return actionable scope, dependencies, risk, criteria and the smallest meaningful verification. Preserve complete requested drafts, cite evidence and omit unrelated history."
71
71
  },
72
72
  {
73
73
  "id": "planner.exploration-density",
@@ -1,5 +1,6 @@
1
1
  import {fingerprintRequest} from './store.mjs';
2
2
  import {absolute,within} from './scope.mjs';
3
+ import {hasExactPlanningKinds,expectedCooperativePlanningKinds} from './schema.mjs';
3
4
  const completed=(state,id)=>state.tasks?.some(t=>t.id===id&&t.status==='committed'&&!t.invalidated)&&state.commits?.some(c=>c.taskId===id&&c.observationSource==='local-git'&&state.intents.some(i=>i.operation==='commit'&&i.requestId===c.requestId&&i.taskId===id&&i.status==='succeeded'));
4
5
  const same=(a,b)=>JSON.stringify(a)===JSON.stringify(b);
5
6
  const text=value=>typeof value==='string'&&value.length>0;
@@ -22,8 +23,8 @@ export function prepareCooperativeAssignment({policy,state,request,observations}
22
23
  if(task&&(task.invalidated||task.status==='held'||task.dependencies?.some(id=>{const predecessor=state.tasks.find(t=>t.id===id);return !predecessor||predecessor.invalidated||!['accepted','committed'].includes(predecessor.status);})))return hold(state,'task-stale','Affected task or predecessor requires renewed readiness and approval');
23
24
  const scope=state.scopes?.findLast(s=>s.scopeVersion===state.scopeVersion&&(!s.data.affectedTaskIds||s.data.affectedTaskIds.includes(request.taskId)));
24
25
  if(!task||!task.paths?.length||args.paths.some(p=>!task.paths.some(base=>within(base,p)))||scope&&args.paths.some(p=>!scope.data.paths?.some(base=>within(base,p))))return hold(state,'assignment-scope','Assignment must stay inside approved task and recorded scope');
25
- const documents=args.documents,git=observations.git;
26
- if(!Array.isArray(documents)||documents.length!==2||!setEqual(documents.map(d=>d.kind),['spec','plan'])||!git.docsCommit||!setEqual(git.docsCommit.paths,documents.map(d=>d.gitPath))||!same(git.docsCommit.documents,documents)||documents.some(d=>d.commit!==git.docsCommit.commit)||!Array.isArray(git.documents)||git.documents.length!==2||documents.some(d=>!git.documents.some(o=>o.path===d.path&&o.gitPath===d.gitPath&&o.kind===d.kind&&o.observedHash===d.contentHash&&o.currentHash===d.contentHash)))return hold(state,'documents','Exact committed spec and plan plus current bytes must match approval');
26
+ const documents=args.documents,git=observations.git,kinds=expectedCooperativePlanningKinds(state);
27
+ if(!hasExactPlanningKinds(documents,kinds)||!git.docsCommit||!setEqual(git.docsCommit.paths,documents.map(d=>d.gitPath))||!same(git.docsCommit.documents,documents)||documents.some(d=>d.commit!==git.docsCommit.commit)||!hasExactPlanningKinds(git.documents,kinds)||documents.some(d=>!git.documents.some(o=>o.path===d.path&&o.gitPath===d.gitPath&&o.kind===d.kind&&o.observedHash===d.contentHash&&o.currentHash===d.contentHash)))return hold(state,'documents','Exact committed spec and plan plus current bytes must match approval');
27
28
  const approval=state.records.filter(r=>r.kind==='approval'&&(!r.data.affectedTaskIds||r.data.affectedTaskIds.includes(request.taskId))).at(-1);
28
29
  if(task.approvalRef!==args.approvalRef||task.approvalVersion!==args.approvalVersion||task.documentVersion!==args.documentVersion||task.scopeVersion!==state.scopeVersion||task.targetVersion!==state.targetVersion||!approval||approval.source!=='operator-attested'||approval.messageRef!==args.approvalRef||approval.targetVersion!==state.targetVersion||approval.scopeVersion!==state.scopeVersion||approval.data.approvalVersion!==args.approvalVersion||approval.data.documentVersion!==args.documentVersion||!same(approval.data.documents,documents)||documents.some(d=>d.approvalRef!==args.approvalRef))return hold(state,'approval','Current document and approval versions must match');
29
30
  const intent={requestId:request.requestId,taskId:request.taskId,operation:request.operation,status:'prepared',role:args.role,paths:[...args.paths],operations:[...args.operations],correlation:args.correlation,documents:structuredClone(documents),docsCommit:git.docsCommit.commit,approvalRef:args.approvalRef,approvalVersion:args.approvalVersion,documentVersion:args.documentVersion,target:structuredClone(state.target),targetVersion:state.targetVersion,scopeVersion:state.scopeVersion,revision:state.revision+1,fingerprint:fingerprintRequest(request),source:'operator-attested'};
@@ -13,6 +13,7 @@ import {fingerprintRequest,saveDurableState,applyCooperativeCommitTransition,app
13
13
  import {commandResult,cooperativeVersions} from './bootstrap.mjs';
14
14
  import {evaluateCooperative,reconcileCooperativeResult} from './evaluate.mjs';
15
15
  import {evaluateTargetPreparation,readTargetPreparationEvidence} from './target-preparation.mjs';
16
+ import {expectedCooperativePlanningKinds,hasExactPlanningKinds,preparedTargetIntent} from './schema.mjs';
16
17
  const same=(a,b)=>JSON.stringify(a)===JSON.stringify(b);
17
18
  const sameCheckout=(a,b)=>['realpath','gitCommonDir','gitDir'].every(k=>a[k]===b[k]);
18
19
  /** Only trusted code may inject observation/storage. CLI JSON cannot set either. */
@@ -59,8 +60,17 @@ export async function runCooperativeCommand({cwd,workflowId,command,input,observ
59
60
  const changes=state.tasks.length?await readChanges({state}):undefined;
60
61
  const plannerArtifacts=plannerWork?await readPlannerArtifacts(state,command==='record'&&input.evidence.kind==='planner-evidence'?input.evidence:undefined):undefined;
61
62
  const plannerHistory=command==='record'&&input.evidence.kind==='planner-stage'?await readPlannerHistory(state,statePath,input.evidence.data.document?.path):{};
63
+ let reviewedSpec;
64
+ if(command==='record'&&input.evidence.kind==='planner-stage'&&input.evidence.data.document?.kind==='plan'){
65
+ const intent=preparedTargetIntent(state),spec=intent?.documents.find(d=>d.kind==='spec');
66
+ if(spec){
67
+ let observed;
68
+ try{observed=await readTargetPreparationEvidence({state,targetIntent:intent,destination:{realpath:state.target.realpath,path:spec.path},observe,readChanges});}catch{}
69
+ reviewedSpec={path:spec.path,hash:observed?.destination?.document?.hash};
70
+ }
71
+ }
62
72
  let destinationReview=false;
63
- let decision=evaluateCooperative({state,request:{command,input},evidence:{target:currentTarget,versions,git,changes,requestFingerprint,plannerArtifacts,...plannerHistory}});
73
+ let decision=evaluateCooperative({state,request:{command,input},evidence:{target:currentTarget,versions,git,changes,requestFingerprint,plannerArtifacts,...plannerHistory,reviewedSpec}});
64
74
  if(command==='record'&&input.evidence.kind==='planner-review'){
65
75
  const data=input.evidence.data,stage=state.plannerLedger?.stages.find(s=>s.id===data.stageId),intent=state.targetIntents?.find(i=>i.id===stage?.targetIntentId),transition=state.targetTransitions?.find(t=>t.intentId===intent?.id&&t.targetVersion===state.targetVersion),document=intent?.documents.find(d=>d.kind===stage?.document.kind);
66
76
  if(transition&&document){
@@ -70,7 +80,11 @@ export async function runCooperativeCommand({cwd,workflowId,command,input,observ
70
80
  decision=valid?{decision:'allow',ruleIds:['cooperative.target-preparation']}:{decision:'hold',ruleIds:['cooperative.target-preparation'],reason:'Current destination bytes and complete source-bound review required'};
71
81
  }
72
82
  }
73
- if(command==='record'&&['document','approval'].includes(input.evidence.kind)&&state.targetIntents?.some(intent=>!state.targetTransitions?.some(t=>t.intentId===intent.id)&&intent.documents.some(doc=>doc.kind===input.evidence.data.kind&&(input.evidence.data.path===doc.path||input.evidence.data.path===path.join(intent.sourceTarget.realpath,doc.path)))))decision={decision:'hold',ruleIds:['cooperative.target-preparation'],reason:'Prepared target transition required before document records'};
83
+ if(command==='record'&&['document','approval'].includes(input.evidence.kind)){
84
+ const {kind,data}=input.evidence;
85
+ const documents=kind==='approval'&&Array.isArray(data.documents)?data.documents:[data];
86
+ if(state.targetIntents?.some(intent=>!state.targetTransitions?.some(t=>t.intentId===intent.id)&&intent.documents.some(doc=>documents.some(d=>d?.kind===doc.kind&&[doc.path,path.join(intent.sourceTarget.realpath,doc.path)].includes(d.path)))))decision={decision:'hold',ruleIds:['cooperative.target-preparation'],reason:'Prepared target transition required before document records'};
87
+ }
74
88
  if(command==='record'&&input.evidence.kind==='approval'){
75
89
  const data=input.evidence.data,intent=state.targetIntents?.find(i=>state.targetTransitions?.some(t=>t.intentId===i.id&&t.targetVersion===state.targetVersion)&&i.documents.some(d=>d.kind===data.kind));
76
90
  if(intent){
@@ -81,6 +95,25 @@ export async function runCooperativeCommand({cwd,workflowId,command,input,observ
81
95
  if(stage?.scopeVersion!==state.scopeVersion||![document.path,path.join(state.target.realpath,document.path)].includes(data.path)||!review||observed?.destination?.document?.hash!==data.contentHash||!same(currentTarget,state.target)||!same(versions,state.versions)||input.actor.role!=='orchestrator')decision={decision:'hold',ruleIds:['cooperative.target-preparation'],reason:'Current reviewed destination bytes required for approval'};
82
96
  }
83
97
  }
98
+ if(command==='record'&&input.evidence.kind==='approval'&&Array.isArray(input.evidence.data.documents)&&decision.decision==='allow'){
99
+ const intent=preparedTargetIntent(state),documents=input.evidence.data.documents;
100
+ if(intent){
101
+ let valid=input.actor.role==='orchestrator'&&same(currentTarget,state.target)&&same(versions,state.versions)&&hasExactPlanningKinds(documents,expectedCooperativePlanningKinds(state));
102
+ for(const doc of intent.documents){
103
+ if(!valid)break;
104
+ const absolutePath=path.join(state.target.realpath,doc.path);
105
+ const entry=documents.find(d=>d.kind===doc.kind&&[doc.path,absolutePath].includes(d.path));
106
+ const firstStage=state.plannerLedger?.stages.find(s=>s.id===intent.firstStageId);
107
+ const stage=firstStage?.document.kind===doc.kind?firstStage:state.plannerLedger?.stages.find(s=>s.document.kind===doc.kind&&s.document.path===absolutePath&&s.targetVersion===state.targetVersion);
108
+ const review=entry&&state.records.findLast(r=>r.kind==='planner-review'&&r.source==='operator-attested'&&r.scopeVersion===state.scopeVersion&&r.targetVersion===state.targetVersion&&r.data?.stageId===stage?.id&&r.data?.resultRef===stage?.result?.ref&&r.data?.full===true&&r.data?.complete===true&&r.data?.hash===entry.contentHash);
109
+ if(!review||stage?.scopeVersion!==state.scopeVersion){valid=false;break;}
110
+ let observed;
111
+ try{observed=await readTargetPreparationEvidence({state,targetIntent:intent,destination:{realpath:state.target.realpath,path:doc.path},observe,readChanges});}catch{}
112
+ valid=same(observed?.destination?.target,state.target)&&observed.destination.document?.hash===entry.contentHash;
113
+ }
114
+ if(!valid)decision={decision:'hold',ruleIds:['cooperative.target-preparation'],reason:'Current reviewed bytes required for every approved document'};
115
+ }
116
+ }
84
117
  if(command==='record'&&input.evidence.kind==='target-preparation'){
85
118
  let observed;
86
119
  try{const intent=state.targetIntents?.find(i=>i.id===input.evidence.data.intentId);observed=await readTargetPreparationEvidence({state,targetIntent:intent,destination:input.evidence.data.destination,observe,readChanges});}catch{}
@@ -171,7 +204,7 @@ export async function runCooperativeCommand({cwd,workflowId,command,input,observ
171
204
  const task=state.tasks.find(t=>t.id===id),approval=state.records.findLast(r=>r.kind==='approval'&&(!r.data.affectedTaskIds||r.data.affectedTaskIds.includes(id)));
172
205
  if(!task||task.invalidated||task.scopeVersion!==state.scopeVersion||!approval||approval.revision<=marker.revision||approval.scopeVersion!==state.scopeVersion||approval.targetVersion!==state.targetVersion||task.approvalRef!==approval.messageRef||task.approvalVersion!==approval.data.approvalVersion||task.documentVersion!==approval.data.documentVersion){ready=false;break;}
173
206
  const documents=approval.data.documents;
174
- if(!Array.isArray(documents)||documents.length!==2||!['spec','plan'].every(kind=>documents.some(d=>d.kind===kind))){ready=false;break;}
207
+ if(!hasExactPlanningKinds(documents,expectedCooperativePlanningKinds(state))){ready=false;break;}
175
208
  try{const observed=await readGit({target:currentTarget,documents});if(!same(observed.target,currentTarget)||!observed.docsCommit||!same(observed.docsCommit.documents,documents)||documents.some(d=>d.commit!==observed.docsCommit.commit||d.approvalRef!==approval.messageRef||!observed.documents?.some(o=>o.path===d.path&&o.gitPath===d.gitPath&&o.observedHash===d.contentHash&&o.currentHash===d.contentHash))){ready=false;break;}}
176
209
  catch{ready=false;break;}
177
210
  const scope=state.scopes.find(s=>s.scopeVersion===state.scopeVersion);if(!scope||task.paths.some(p=>!scope.data.paths.some(base=>within(base,p)))){ready=false;break;}
@@ -15,7 +15,7 @@ import {prepareCooperativeAssignment} from './assignment.mjs';
15
15
  */
16
16
  import path from 'node:path';
17
17
  import {legacyCooperativeRoleDenial,validateCooperativeState,validateCooperativeCommand} from './cooperative-schema.mjs';
18
- import {validateWorkflowState, validateRequest, validateEvidence,validatePlannerStage} from './schema.mjs';
18
+ import {validateWorkflowState, validateRequest, validateEvidence,validatePlannerStage,hasExactPlanningKinds,planningDocumentKinds} from './schema.mjs';
19
19
  import {ROLES, ROLE_OPERATIONS, GIT_OPERATIONS, EXTERNAL_OPERATIONS, canonicalCooperativeRole} from './operations.mjs';
20
20
  const same=(a,b)=>JSON.stringify(a)===JSON.stringify(b);
21
21
  const within=(base,file)=>{const relative=path.relative(base,file);return relative===''||(!relative.startsWith('..'+path.sep)&&relative!=='..'&&!path.isAbsolute(relative));};
@@ -68,7 +68,7 @@ export function evaluate(policy, state, request, evidence){
68
68
  if(d.role==='implementer'){
69
69
  if(state.mode==='plan'){
70
70
  // T3 supplies verified Git object evidence. Local assertions never satisfy this gate.
71
- if(!state.documents.some(d=>d.kind==='spec')||!state.documents.some(d=>d.kind==='plan'))return result('hold','runtime.docs-commit','approved complete spec and plan required',['approved-documents','docs-only-commit']);
71
+ if(!hasExactPlanningKinds(state.documents,planningDocumentKinds(state.planningDepth)))return result('hold','runtime.docs-commit','approved complete planning-document set required',['approved-documents','docs-only-commit']);
72
72
  const docs=fact('docs-commit')?.data;
73
73
  const approved=state.documents.every(d=>state.approvals.some(a=>a.id===d.approvalRef&&a.contentHash===d.contentHash&&evidence.provenance.some(p=>p.id===a.id&&p.source===a.source&&p.verification.sourceRef===p.messageRef&&p.messageRef===a.messageRef&&p.contentHash===d.contentHash)));
74
74
  if(!approved||!docs||!docs.commit||!docs.parent||!docs.tree||!same(docs.documents,state.documents)||!same([...docs.paths??[]].sort(),state.documents.map(d=>d.gitPath).sort())||state.documents.some(d=>d.commit!==docs.commit))return result('hold','runtime.docs-commit','Git object and approval verification required',['verified-docs-only-commit']);
@@ -88,7 +88,12 @@ export function evaluate(policy, state, request, evidence){
88
88
  const stage=state.plannerLedger?.stages.find(s=>s.id===d.plannerCall?.stageId),proof=fact('planner-call');
89
89
  const contract=stage&&{document:stage.document,inputVersion:stage.inputVersion,criteriaVersion:stage.criteriaVersion,scopeVersion:stage.scopeVersion};
90
90
  if(!stage||stage.workflowId!==state.workflowId||stage.approvalRef!==approval.id||!same(approval.scope.plannerStage,contract)||!d.paths.includes(stage.document.path)||proof?.sourceRef!==correlation.sourceRef||!same({stageId:proof?.data.stageId,inputVersion:proof?.data.inputVersion,criteriaVersion:proof?.data.criteriaVersion,scopeVersion:proof?.data.scopeVersion},{stageId:stage.id,inputVersion:stage.inputVersion,criteriaVersion:stage.criteriaVersion,scopeVersion:stage.scopeVersion}))return result('hold','runtime.planner-call','Current approved Planner stage and provider evidence required',['planner-stage-ledger','planner-call-evidence']);
91
- if(stage.document.kind==='plan'&&!state.documents.some(doc=>doc.kind==='spec'&&state.approvals.some(a=>a.id===doc.approvalRef&&a.contentHash===doc.contentHash&&evidence.provenance.some(p=>p.id===a.id&&p.messageRef===a.messageRef&&p.contentHash===doc.contentHash&&p.verification.sourceRef===a.messageRef))))return result('hold','runtime.planner-call','Approved spec prerequisite required',['approved-spec']);
91
+ if(state.planningDepth==='Bounded'&&stage.document.kind==='spec')return result('hold','runtime.planner-call','Bounded depth has no spec stage',['approved-spec']);
92
+ if(stage.document.kind==='plan'&&state.planningDepth!=='Bounded'){
93
+ const reviewedSpecStage=state.plannerLedger.stages.some(s=>s.workflowId===state.workflowId&&s.document.kind==='spec'&&s.ready===true&&s.review.full===true&&s.review.complete===true&&s.scopeVersion===stage.scopeVersion);
94
+ const approvedSpec=reviewedSpecStage||state.documents.some(doc=>doc.kind==='spec'&&state.approvals.some(a=>a.id===doc.approvalRef&&a.contentHash===doc.contentHash&&evidence.provenance.some(p=>p.id===a.id&&p.messageRef===a.messageRef&&p.contentHash===doc.contentHash&&p.verification.sourceRef===a.messageRef)));
95
+ if(!approvedSpec)return result('hold','runtime.planner-call','Reviewed spec prerequisite required',['approved-spec']);
96
+ }
92
97
  const planner=evaluatePlannerCall({stage,request:{...d.plannerCall,requestId:request.requestId},evidence:{artifacts:proof.data.artifacts,semanticProvenance:'operator-attested'}});
93
98
  if(planner.decision!=='allow')return planner;
94
99
  next.plannerLedger.stages[next.plannerLedger.stages.findIndex(s=>s.id===stage.id)]=planner.proposedTransition;
@@ -108,7 +113,7 @@ export function evaluate(policy, state, request, evidence){
108
113
  const relative=p=>typeof p==='string'&&p.length>0&&!/[\\\x00\r\n:]/.test(p)&&!p.startsWith('/')&&!p.split('/').some(x=>!x||x==='.'||x==='..');
109
114
  if(!observed||!same(observed,d)||d.parent!==state.target.head||!d.indexTree||!Array.isArray(d.paths)||!d.paths.length||!d.paths.every(relative)||new Set(d.paths).size!==d.paths.length||!same([...d.paths.map(p=>path.join(state.target.realpath,...p.split('/')))].sort(),[...request.paths].sort()))return result('hold','git.orchestrator-accept-commit','actual Git objects and relative path verification required',['git-evidence']);
110
115
  if(d.kind==='documents'){
111
- if(state.mode!=='plan'||state.documents.length!==2||!same(state.documents.map(x=>x.kind).sort(),['plan','spec'])||!same([...d.paths].sort(),state.documents.map(x=>x.gitPath).sort())||state.documents.some(doc=>doc.path!==path.join(state.target.realpath,...doc.gitPath.split('/'))||!state.approvals.some(a=>a.id===doc.approvalRef&&a.contentHash===doc.contentHash&&evidence.provenance.some(p=>p.id===a.id&&p.source===a.source&&p.messageRef===a.messageRef&&p.contentHash===doc.contentHash&&p.verification.sourceRef===a.messageRef))))return result('hold','runtime.docs-commit','exact approved documents required',['approved-documents']);
116
+ if(state.mode!=='plan'||!hasExactPlanningKinds(state.documents,planningDocumentKinds(state.planningDepth))||!same([...d.paths].sort(),state.documents.map(x=>x.gitPath).sort())||state.documents.some(doc=>doc.path!==path.join(state.target.realpath,...doc.gitPath.split('/'))||!state.approvals.some(a=>a.id===doc.approvalRef&&a.contentHash===doc.contentHash&&evidence.provenance.some(p=>p.id===a.id&&p.source===a.source&&p.messageRef===a.messageRef&&p.contentHash===doc.contentHash&&p.verification.sourceRef===a.messageRef))))return result('hold','runtime.docs-commit','exact approved documents required',['approved-documents']);
112
117
  }else{
113
118
  const accepted=state.acceptances.find(a=>a.taskId===task.id&&a.fingerprint===d.fingerprint&&state.identities.some(i=>i.actorRef===a.actorRef&&i.role==='orchestrator'));
114
119
  if(d.kind!=='task'||!accepted||task.status!=='accepted'||request.paths.some(p=>!task.paths.some(base=>within(base,p))))return result('hold','git.orchestrator-accept-commit','accepted task verification required',['git-evidence']);
@@ -222,8 +227,18 @@ export function evaluateCooperativePlanner({state,request,evidence}={}){
222
227
  if(data.targetIntentId){const intent=state.targetIntents?.find(i=>i.id===data.targetIntentId);if(!intent||intent.firstStageId!==data.id||intent.sourceTargetVersion!==state.targetVersion||intent.documents.some(d=>d.kind==='spec')&&data.document.kind!=='spec'||!intent.documents.some(d=>d.kind===data.document.kind&&path.join(state.target.realpath,d.path)===data.document.path))return result('hold','Current target intent and matching first document required');}
223
228
  const targetIntent=state.targetIntents?.find(i=>i.id===data.targetIntentId);
224
229
  const approvedOmission=targetIntent?.depth==='Bounded'&&targetIntent.firstStageId===data.id&&targetIntent.documents.length===1&&targetIntent.documents[0].kind==='plan';
225
- const approvedSpec=approval.data.prerequisiteRefs?.some(ref=>state.records.some(r=>r.kind==='approval'&&r.messageRef===ref&&r.data.kind==='spec'&&r.source==='operator-attested'&&r.scopeVersion===state.scopeVersion&&r.targetVersion===state.targetVersion&&(!preparedIntent||state.targetDocuments?.some(d=>d.intentId===preparedIntent.id&&preparedIntent.documents.some(doc=>doc.kind==='spec'&&doc.path===d.path)&&d.approvalRef===ref&&d.scopeVersion===state.scopeVersion&&d.targetVersion===state.targetVersion&&[d.path,path.join(state.target.realpath,d.path)].includes(r.data.path)&&d.hash===r.data.contentHash))));
226
- if(data.document.kind==='plan'&&!approvedOmission&&!approvedSpec)return result('hold','Approved spec prerequisite is required for plan drafting');
230
+ if(data.document.kind==='plan'&&!approvedOmission){
231
+ const refs=approval.data.prerequisiteRefs;
232
+ const current=r=>r.source==='operator-attested'&&r.scopeVersion===state.scopeVersion&&r.targetVersion===state.targetVersion;
233
+ if(preparedIntent){
234
+ const spec=preparedIntent.documents.find(d=>d.kind==='spec');
235
+ const reviewedSpec=state.targetDocuments?.findLast(d=>d.intentId===preparedIntent.id&&d.path===spec?.path&&d.scopeVersion===state.scopeVersion&&d.targetVersion===state.targetVersion);
236
+ const review=reviewedSpec&&state.records.find(r=>r.kind==='planner-review'&&r.messageRef===reviewedSpec.reviewRef&&current(r)&&r.data?.full===true&&r.data?.complete===true&&r.data?.hash===reviewedSpec.hash);
237
+ const approvedSpec=reviewedSpec?.approvalRef&&state.records.find(r=>r.kind==='approval'&&r.messageRef===reviewedSpec.approvalRef&&r.data.kind==='spec'&&current(r)&&[reviewedSpec.path,path.join(state.target.realpath,reviewedSpec.path)].includes(r.data.path)&&r.data.contentHash===reviewedSpec.hash);
238
+ if(!review||approval.actor?.role!=='orchestrator'||!Array.isArray(refs)||!(refs.includes(reviewedSpec.reviewRef)||approvedSpec&&refs.includes(approvedSpec.messageRef)))return result('hold','Reviewed spec prerequisite is required for plan drafting');
239
+ if(evidence.reviewedSpec?.hash!==reviewedSpec.hash)return result('hold','Reviewed spec bytes changed');
240
+ }else if(!Array.isArray(refs)||!refs.some(ref=>state.records.some(r=>r.kind==='approval'&&r.messageRef===ref&&r.data.kind==='spec'&&current(r))))return result('hold','Reviewed spec prerequisite is required for plan drafting');
241
+ }
227
242
  const previous=[...ledger.stages,...(evidence.plannerHistory??[]).map(h=>h.stage)].filter(s=>s.document.path===data.document.path&&s.document.kind===data.document.kind&&s.document.phase===data.document.phase);
228
243
  if(evidence.plannerHistoryError)return result('hold','Planner history could not be verified: '+evidence.plannerHistoryError);
229
244
  if(previous.length){
@@ -1,6 +1,7 @@
1
1
  import {validateGitPreflight,validateGitCommitResult} from './git-evidence.mjs';
2
2
  export {validateGitPreflight,validateGitCommitResult} from './git-evidence.mjs';
3
3
  import path from 'node:path';
4
+ import {hasExactPlanningKinds,planningDocumentKinds} from './schema.mjs';
4
5
 
5
6
  const reconciliations=new WeakMap();
6
7
  export function verifiedReconciliation(decision,state,next,expectedCommit){const proof=reconciliations.get(decision);return !!proof&&proof.before===JSON.stringify(state)&&proof.after===JSON.stringify(next)&&(expectedCommit===undefined||proof.expected===JSON.stringify(expectedCommit));}
@@ -33,7 +34,7 @@ export async function runGate({phase,state,request,gitEvidence,expectedCommit,re
33
34
  return path.relative(state.target.realpath,file).split(path.sep).join('/');
34
35
  }),d.paths))return hold('Request paths differ from commit paths');
35
36
  if(d.kind==='documents'){
36
- if(state.mode!=='plan'||state.documents?.length!==2||!samePaths(state.documents.map(x=>x.kind),['spec','plan'])||!samePaths(d.paths,state.documents.map(x=>x.gitPath)))return hold('Complete exact approved spec and plan set required','runtime.docs-commit');
37
+ if(state.mode!=='plan'||!hasExactPlanningKinds(state.documents,planningDocumentKinds(state.planningDepth))||!samePaths(d.paths,state.documents.map(x=>x.gitPath)))return hold('Complete exact approved planning-document set required','runtime.docs-commit');
37
38
  for(const document of state.documents){
38
39
  const approvals=state.approvals?.filter(a=>a.id===document.approvalRef);
39
40
  if(!hash(document.contentHash)||document.path!==path.join(state.target.realpath,...document.gitPath.split('/'))||approvals?.length!==1||!['user-message','human-confirmation'].includes(approvals[0].source)||!approvals[0].messageRef||approvals[0].contentHash!==document.contentHash)return hold('Approved document hash unavailable','runtime.docs-commit');
@@ -43,6 +43,7 @@ export function validateWorkflowState(s,{allowLegacyOperations=true,preserveStor
43
43
  if(['policyHash','runtimeHash','adapterHash'].some(k=>!hash(s.versions[k])))fail('hash algorithm');
44
44
  if(!object(s.target)||!absolute(s.target.realpath)||['repository','worktree','baseHead','head'].some(k=>!text(s.target[k]))||!(s.target.branch===null||text(s.target.branch)))fail('target');
45
45
  if(!['plan','small-task','no-plan'].includes(s.mode))fail('mode');
46
+ if(s.planningDepth!==undefined&&!['Architectural','Bounded'].includes(s.planningDepth))fail('planning depth');
46
47
  for(const k of ['documents','approvals','tasks','assignments','identities','leases','checks','findings','acceptances','commits','audit','capabilities','requests'])if(!Array.isArray(s[k]))fail(k);
47
48
  const stored=s,normalized=normalizeStoredOperations(s);
48
49
  if(!allowLegacyOperations&&normalized!==s&&(!legacyOperationsFrom||hasNewStoredOperationAliases(s,legacyOperationsFrom)))fail('legacy operation in new state');
@@ -66,6 +67,21 @@ export function validateWorkflowState(s,{allowLegacyOperations=true,preserveStor
66
67
  if(s.plannerLedger!==undefined){validatePlannerLedger(s.plannerLedger);if(s.plannerLedger.stages.some(stage=>stage.workflowId!==s.workflowId))fail('Planner workflow binding');}
67
68
  return preserveStoredOperations?stored:s;
68
69
  }
70
+ export function planningDocumentKinds(depth){
71
+ return depth==='Bounded'?['plan']:['plan','spec'];
72
+ }
73
+ export function hasExactPlanningKinds(documents,kinds){
74
+ if(!Array.isArray(documents)||documents.length!==kinds.length)return false;
75
+ const actual=documents.map(d=>d?.kind).sort();
76
+ return kinds.every((kind,index)=>kind===actual[index]);
77
+ }
78
+ export function preparedTargetIntent(state){
79
+ return state.targetIntents?.find(i=>state.targetTransitions?.some(t=>t.intentId===i.id&&t.targetVersion===state.targetVersion));
80
+ }
81
+ export function expectedCooperativePlanningKinds(state){
82
+ const intent=preparedTargetIntent(state);
83
+ return intent?[...new Set(intent.documents.map(d=>d.kind))].sort():planningDocumentKinds();
84
+ }
69
85
  export function validateRequest(r){
70
86
  if(!object(r)||['requestId','actorRef','taskId','toolName'].some(k=>!text(r[k]))||!isPlatformId(r.platform)||!OPERATIONS.includes(r.operation)||!absolute(r.cwd)||!object(r.arguments)||!object(r.descriptor)||!strings(r.paths)||r.paths.some(p=>!absolute(p)))fail('request');
71
87
  return r;