@yunhozz/arc 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/MANIFEST.sha256 +96 -0
  2. package/README.md +265 -2
  3. package/bin/arc.mjs +3 -0
  4. package/claude/agents/arc-coder.md +67 -0
  5. package/claude/agents/arc-planner.md +74 -0
  6. package/claude/agents/arc-qa.md +68 -0
  7. package/claude/agents/arc-reviewer.md +65 -0
  8. package/claude/agents/arc-scouter.md +63 -0
  9. package/claude/skill/SKILL.md +370 -0
  10. package/claude/skill/hooks/git-policy.json +208 -0
  11. package/claude/skill/hooks/role-git-guard.mjs +98 -0
  12. package/claude/skill/models.toml +64 -0
  13. package/claude/skill/references/commit.md +77 -0
  14. package/claude/skill/references/git-recovery.md +46 -0
  15. package/claude/skill/references/handoff-prep.md +102 -0
  16. package/claude/skill/references/handoff.md +100 -0
  17. package/claude/skill/references/limits.md +42 -0
  18. package/claude/skill/references/planning.md +250 -0
  19. package/claude/skill/references/superpowers/LICENSE +21 -0
  20. package/claude/skill/references/superpowers/brainstorming/SKILL.md +225 -0
  21. package/claude/skill/references/superpowers/brainstorming/builder-check-prompt.md +23 -0
  22. package/claude/skill/references/superpowers/brainstorming/scripts/frame-template.html +213 -0
  23. package/claude/skill/references/superpowers/brainstorming/scripts/helper.js +167 -0
  24. package/claude/skill/references/superpowers/brainstorming/scripts/server.cjs +723 -0
  25. package/claude/skill/references/superpowers/brainstorming/scripts/start-server.sh +209 -0
  26. package/claude/skill/references/superpowers/brainstorming/scripts/stop-server.sh +120 -0
  27. package/claude/skill/references/superpowers/brainstorming/visual-companion.md +299 -0
  28. package/claude/skill/references/superpowers/provenance.json +26 -0
  29. package/claude/skill/references/superpowers/test-driven-development/SKILL.md +330 -0
  30. package/claude/skill/references/superpowers/test-driven-development/writing-good-tests.md +198 -0
  31. package/claude/skill/references/superpowers/writing-plans/SKILL.md +204 -0
  32. package/claude/skill/references/verification.md +125 -0
  33. package/claude/skill/references/visual-companion.md +16 -0
  34. package/claude/skill/scripts/apply-models.py +31 -0
  35. package/claude/skill/scripts/model_config.py +211 -0
  36. package/codex/agents/arc-coder.toml +37 -0
  37. package/codex/agents/arc-planner.toml +38 -0
  38. package/codex/agents/arc-qa.toml +24 -0
  39. package/codex/agents/arc-reviewer.toml +25 -0
  40. package/codex/agents/arc-scouter.toml +37 -0
  41. package/codex/skill/SKILL.md +356 -0
  42. package/codex/skill/models.toml +64 -0
  43. package/codex/skill/references/commit.md +100 -0
  44. package/codex/skill/references/git-recovery.md +64 -0
  45. package/codex/skill/references/handoff-prep.md +153 -0
  46. package/codex/skill/references/handoff-worktree.md +93 -0
  47. package/codex/skill/references/handoff.md +181 -0
  48. package/codex/skill/references/limits.md +43 -0
  49. package/codex/skill/references/planning.md +287 -0
  50. package/codex/skill/references/superpowers/LICENSE +21 -0
  51. package/codex/skill/references/superpowers/brainstorming/SKILL.md +225 -0
  52. package/codex/skill/references/superpowers/brainstorming/builder-check-prompt.md +23 -0
  53. package/codex/skill/references/superpowers/brainstorming/scripts/frame-template.html +213 -0
  54. package/codex/skill/references/superpowers/brainstorming/scripts/helper.js +167 -0
  55. package/codex/skill/references/superpowers/brainstorming/scripts/server.cjs +723 -0
  56. package/codex/skill/references/superpowers/brainstorming/scripts/start-server.sh +209 -0
  57. package/codex/skill/references/superpowers/brainstorming/scripts/stop-server.sh +120 -0
  58. package/codex/skill/references/superpowers/brainstorming/visual-companion.md +299 -0
  59. package/codex/skill/references/superpowers/provenance.json +26 -0
  60. package/codex/skill/references/superpowers/test-driven-development/SKILL.md +330 -0
  61. package/codex/skill/references/superpowers/test-driven-development/writing-good-tests.md +198 -0
  62. package/codex/skill/references/superpowers/writing-plans/SKILL.md +204 -0
  63. package/codex/skill/references/verification.md +163 -0
  64. package/codex/skill/references/visual-companion.md +23 -0
  65. package/codex/skill/scripts/apply-models.py +207 -0
  66. package/codex/skill/scripts/model_config.py +362 -0
  67. package/install.command +5 -0
  68. package/lib/cli/choices.mjs +47 -0
  69. package/lib/cli/completion.mjs +53 -0
  70. package/lib/cli/index.mjs +55 -0
  71. package/lib/cli/preset.mjs +29 -0
  72. package/lib/cli/progress.mjs +10 -0
  73. package/lib/cli/root.mjs +20 -0
  74. package/lib/cli/uninstall.mjs +17 -0
  75. package/lib/installer/acquisition.mjs +77 -0
  76. package/lib/installer/global-config.mjs +43 -0
  77. package/lib/installer/install.mjs +28 -0
  78. package/lib/installer/language.mjs +13 -0
  79. package/lib/installer/limits.mjs +21 -0
  80. package/lib/installer/manifest.mjs +37 -0
  81. package/lib/installer/package-references.mjs +32 -0
  82. package/lib/installer/plan.mjs +62 -0
  83. package/lib/installer/preset.mjs +26 -0
  84. package/lib/installer/runtime-config.mjs +85 -0
  85. package/lib/installer/shell-completion.mjs +29 -0
  86. package/lib/installer/stage-cleanup.mjs +40 -0
  87. package/lib/installer/superpowers.mjs +113 -0
  88. package/lib/installer/targets.mjs +55 -0
  89. package/lib/installer/transaction.mjs +91 -0
  90. package/lib/installer/uninstall.mjs +32 -0
  91. package/lib/limits.mjs +13 -0
  92. package/lib/models/config.mjs +58 -0
  93. package/lib/models/index.mjs +2 -0
  94. package/lib/models/profiles.mjs +111 -0
  95. package/lib/policy/claude-hook.mjs +40 -0
  96. package/lib/policy/render.mjs +74 -0
  97. package/lib/policy/role-policy.json +577 -0
  98. package/lib/safe-fs/index.mjs +67 -0
  99. package/lib/safe-fs/native.mjs +54 -0
  100. package/native/binding.c +157 -0
  101. package/native/binding.gyp +1 -0
  102. package/package.json +43 -4
  103. package/prebuilds/darwin-arm64/arc_safe_fs.node +0 -0
  104. package/prebuilds/darwin-x64/arc_safe_fs.node +0 -0
  105. package/prebuilds/index.json +64 -0
  106. package/prebuilds/linux-arm64-gnu/arc_safe_fs.node +0 -0
  107. package/prebuilds/linux-x64-gnu/arc_safe_fs.node +0 -0
  108. package/scripts/build-native.mjs +36 -0
  109. package/scripts/check-installer-parity.mjs +59 -0
  110. package/scripts/update-manifest.mjs +28 -0
  111. package/scripts/update-role-policy.mjs +15 -0
  112. package/scripts/update-superpowers.mjs +4 -0
  113. package/scripts/vendor-toml.mjs +40 -0
  114. package/vendor/toml/LICENSE +24 -0
  115. package/vendor/toml/dist/date.js +156 -0
  116. package/vendor/toml/dist/error.js +67 -0
  117. package/vendor/toml/dist/extract.js +293 -0
  118. package/vendor/toml/dist/index.js +34 -0
  119. package/vendor/toml/dist/parse.js +164 -0
  120. package/vendor/toml/dist/primitive.js +151 -0
  121. package/vendor/toml/dist/stringify.js +219 -0
  122. package/vendor/toml/dist/struct.js +156 -0
  123. package/vendor/toml/dist/util.js +57 -0
  124. package/vendor/toml/package.json +6 -0
  125. package/vendor/toml/provenance.json +35 -0
@@ -0,0 +1,100 @@
1
+ # Commit contract
2
+
3
+ Orchestrator reads before accepting an approved top-level plan task and creating its focused commit, and before resuming
4
+ a task whose commit result is unclear.
5
+
6
+ ## Automatic commit after plan-task acceptance
7
+
8
+ One approved top-level task is the unit of one focused implementation commit. Orchestrator verifies the task's
9
+ acceptance
10
+ criteria, currently required checks (Reviewer timing: SKILL.md Risk-scaled execution), and findings,
11
+ accepts the task by its own judgment, then immediately
12
+ creates its focused local Git commit without additional user commit approval.
13
+ After Orchestrator accepts a task, the next action is the required Git state/scope checks, staging, and focused commit.
14
+ Do not commit before task acceptance or defer the task commit until the plan ends.
15
+ Only Orchestrator accepts the task and executes its focused commit; Coder completion does not replace acceptance.
16
+ Substeps and checkboxes are progress records, not separate commit units. Checkbox completion, Coder reports, and
17
+ passing checks alone do not establish task acceptance: connect criteria's conditions and expected results to actual
18
+ evidence. Existing plan-skip paths have no new plan obligation; their commits follow applicable guidance and user
19
+ requests.
20
+
21
+ Before committing, Orchestrator verifies the approved plan version, task ID and accepted scope, actual absolute
22
+ workspace,
23
+ repository, branch or detached HEAD, HEAD, staged/unstaged/untracked state and edit ownership. Verify staged paths and
24
+ content match only that task, and verify the finalized commit message. If the same file contains other tasks or user
25
+ changes, prove safe separation before committing. Unrelated staged changes stop the commit under the Preservation
26
+ rule. After committing, verify SHA, actual message, included
27
+ paths and content, post-commit HEAD, actual branch and remaining staged/unstaged/untracked state. Command exit success
28
+ alone does not establish completion. In the accessible canonical record link plan path/version, task ID, acceptance
29
+ evidence and Orchestrator judgment, required checks and findings, commit results and state, hold/no-change/reuse
30
+ reasons,
31
+ and remaining final plan verification.
32
+
33
+ Hold the task commit for unmet or unresolved criteria, required checks that failed or were not run,
34
+ unresolved findings or evidence gaps without disposition, scope expansion or revised-plan needs, ownership or staged
35
+ scope/content mismatch, unexpected workspace, branch, HEAD or Git state, or Git failure/partial completion. Record the
36
+ reason and required next action. Do not waive unmet criteria or required checks to commit. Explicit disposition follows
37
+ existing policy and the Evidence verdict. After a Git failure inspect actual branch, HEAD, index,
38
+ working tree and partial completion before retrying; if commit creation is unclear, stop rather than retry immediately.
39
+ Orchestrator follows git-recovery and reverifies affected evidence after resolving the failure.
40
+
41
+ For a no-change task, make no empty commit; record acceptance evidence and no change. On resume, verify the same task's
42
+ existing commit SHA, content and validity, then reuse it; do not duplicate a successful task commit.
43
+ For a missing record,
44
+ inspect the actual result before any retry. Normal accepted task commits retain valid choice reuse under handoff, with
45
+ fresh state and ownership checks. Task acceptance/commit is distinct from final plan acceptance; remaining final
46
+ QA/Reviewer/integration checks still apply with the timing in verification.
47
+
48
+ For final Reviewer findings on already committed plan work, Orchestrator defines a follow-up task and required
49
+ planning/approvals. Coder leaves corrections uncommitted during rechecks. Orchestrator refreshes the latest committed
50
+ state plus uncommitted diff and changed-file list in the Reviewer artifact/brief. Reuse an independent Reviewer or
51
+ assign another independent Reviewer as needed. Repeat Coder → Reviewer without QA reassignment until findings are
52
+ resolved; Orchestrator then accepts the corrections and creates one focused follow-up commit.
53
+ Final QA findings retain Coder correction and QA recheck before a new focused commit.
54
+ Do not automatically amend/reset or duplicate the original task commit. Scope expansion keeps existing new
55
+ planning and approval obligations.
56
+
57
+ This local commit authority does not authorize early planning-document commits: pre-Coder document approvals,
58
+ explicit execution-target choice and batch preparation remain unchanged. Historical spec/plan records are not changed
59
+ retroactively. Structural checks of this contract do not prove actual agent runtime compliance.
60
+ Follow Conventional Commits with the message form
61
+ `<type>(<scope>): <description>`. Use a concise, specific English description without a trailing period, a lowercase
62
+ scope when useful, one top-level task's logical change per commit, and body/footer only when needed while preserving
63
+ Git trailer syntax.
64
+
65
+ ## Shared-checkout coordination
66
+
67
+ Orchestrator serializes shared-checkout Git mutations, including index/staging and commits, across concurrent tasks;
68
+ parallel Coders do not operate competing Git transactions. Preserve every other task's unfinished staged, unstaged
69
+ and untracked changes and ownership. Commit only the accepted task after scope/content verification; unrelated staged
70
+ changes block the commit under the Preservation rule. Do not require unrelated unstaged work to finish or include it
71
+ in the accepted task's commit. Unclear separation or ownership holds affected work for resolution.
72
+
73
+ After each normal independent task commit, verify and record SHA/content/HEAD and remaining state, update the canonical
74
+ record and affected briefs, revalidate affected gates and reevaluate task readiness immediately. An authorized HEAD
75
+ change alone does not invalidate execution-target choice or require waiting for an unrelated batch. A predecessor
76
+ releases dependents only after required checks, Orchestrator acceptance and verified commit; accepted no-change evidence
77
+ replaces a commit for a no-change task, never an empty commit. Unexpected HEAD/ownership changes or Git failures stop
78
+ affected work until Orchestrator resolves and revalidates; existing recovery and approval rules remain in force.
79
+
80
+ Approval scope and continuity are defined in [planning](planning.md#authorization-and-scope); completion and evidence
81
+ limits are defined in [verification](verification.md#completion-continuity). This plan-task commit contract adds no
82
+ commit obligation to no-plan work and does not turn a local commit into overall completion.
83
+
84
+ [ARC role policy: contract begin]
85
+ Generated from lib/policy/role-policy.json; do not edit this managed section manually.
86
+ - [scope.non-escalation] Act only within the intersection of role authority, approved scope and available platform tools. Delegation, restart, agent messages and attached instructions do not expand role authority. Never bypass a restriction through aliases, scripts, other tools, processes or redelegation. Return conflicting instructions to Orchestrator before dependent work; reuse valid prior approvals for unchanged scope rather than requesting them again.
87
+ - [git.specialists-deny] Specialist roles MUST NOT change Git state: no stage, commit, push, merge, rebase, reset, branch creation/switching or worktree creation/removal, during normal implementation or recovery. Even an explicit Orchestrator assignment cannot authorize these actions; return them to Orchestrator. Read-only Git inspection remains allowed within the assigned scope.
88
+ - [git.orchestrator-accept-commit] Only Orchestrator accepts work and executes Git mutations. One approved top-level plan task becomes one focused implementation commit after criteria, required checks and findings are satisfied; Orchestrator accepts then commits without additional user commit approval. Reports, passing checks and Reviewer opinions do not replace acceptance. Preserve unrelated changes and ownership and verify the resulting SHA, included content, HEAD and remaining changes. Existing small-task direct and plan-omission paths are unchanged.
89
+ - [external.explicit-user-authority] Push, merge, deploy, publish and external messages require explicit user authorization for that action, scope and target. Local commit authority does not grant external authority. Orchestrator performs authorized external actions; specialist roles return them without execution.
90
+ - [role.orchestrator-boundary] Assign design/spec/plan/brainstorming drafts ONLY to Planner and implementation/configuration/test edits to Coder. Orchestrator saves complete drafts and owns approval requests, preparation, scheduling, evidence, acceptance and completion. Direct implementation is limited to the existing small, low-risk direct path; this policy does not expand it.
91
+ - [role.scouter-read-only] Research assigned static sources and report findings, evidence and limits. Do not edit files, install, execute checks, prepare execution targets, inspect live operational state, change external state or decide design, verification, review or acceptance.
92
+ - [role.planner-draft-only] Return design/spec/plan drafts and dependencies, criteria, hold conditions and verification needs in the response. Do not save documents, implement, run checks, prepare targets, request user approval or decide acceptance. Stop formal target-dependent drafting if actual prepared target evidence is missing; route decisions to Orchestrator.
93
+ - [role.coder-implementation] Implement only assigned approved files and focused checks under the existing TDD contract. Report changed files, RED/GREEN or authorized exception evidence, results, limits and follow-up. Do not plan, independently QA/review your own work, accept the task or declare overall completion. Git changes remain forbidden even when implementation succeeds.
94
+ - [role.qa-verification] Run approved checks and report commands, observations, reproduction, evidence and limits. Create only essential temporary data/logs/reports in the brief-authorized location and lifetime. Do not edit product source, tests, fixtures or configuration to pass checks, deploy or accept work. Persistent product-state checks require explicit scope and cleanup ownership. Return failures for Coder correction and required QA recheck.
95
+ - [role.reviewer-independent] Independently inspect the assigned final changes and evidence and report actionable findings and limits. Remain read-only; do not execute QA tests, edit files, perform Git mutations or decide acceptance.
96
+ - [review.significant-no-plan] For significant/high-risk work without a plan: Coder → QA and required QA rechecks → Reviewer of the final full change → Orchestrator acceptance. Do not omit Reviewer merely because no plan exists. This creates no new plan obligation.
97
+ - [review.significant-plan] For significant/high-risk plan work: each task uses Coder → fresh QA as required → Orchestrator acceptance and focused commit. After all tasks are accepted and required QA is complete, Reviewer reviews the final full change once. Reviewer is NOT a per-task or per-commit required gate. Preserve required checks and necessary finding rechecks.
98
+ - [review.final-plan-recheck] For final overall Reviewer findings on plan work, including behavior findings, use Coder → Reviewer without QA reassignment; repeat until resolved. This exception applies only to that final plan stage. Preserve required QA and QA failure rechecks before initial final review and outside this exception.
99
+ - [platform.codex] Role restrictions are prompt-level contracts, not a filesystem sandbox. No documented role-specific Git hook or generic per-agent tool allowlist is assumed. Existing shell capabilities are retained because static read access after shell reduction has not been verified; Coder and QA need shell for approved checks.
100
+ [ARC role policy: contract end]
@@ -0,0 +1,64 @@
1
+ # Git recovery contract
2
+
3
+ Read on branch collision, Git preparation failure, partial completion, or metadata write denial.
4
+ Use [handoff-prep.md](handoff-prep.md) for approved branch selection, [handoff-worktree.md](handoff-worktree.md) for the
5
+ managed worktree path, and [handoff.md](handoff.md) for the complete restart gate.
6
+
7
+ ### Git metadata write denial
8
+
9
+ If authorized staging, committing, branch creation, or switching is denied while writing `.git/index.lock` or other
10
+ Git metadata, Orchestrator blocks handoff and safely inspects the exact command, workspace, error, failed path,
11
+ actual Git
12
+ directory, branch, HEAD, index state, and partial completion. Read-only inspection includes lock existence and any
13
+ observable related processes, sandbox restrictions, OS permissions/ACLs, and concurrent Git activity. Record supported
14
+ causes and remaining uncertainty; denial of lock creation alone does not prove a stale lock.
15
+
16
+ Apply the Preservation rule: do not delete lock files, use `chmod` or `chown`, bypass the sandbox, or move to another
17
+ workspace. If
18
+ evidence confirms sandbox denial of an already authorized operation, request through the permission system only (not
19
+ a sandbox bypass) the tool-supported minimum escalation for only the exact single Git command and workspace, never
20
+ broad Git access. Before retrying,
21
+ recheck branch, HEAD, index, and partial completion; do not repeat work already completed. After success verify the
22
+ commit or branch result and final state, then reevaluate the entire handoff gate. Denied escalation or unresolved OS
23
+ permission/ACL problems keep handoff blocked; report the reason and actual state to Orchestrator/user.
24
+ Choosing the final
25
+ message in advance prevents unnecessary amend but does not repair required Git write access; only successful
26
+ authorized writes and verified results establish recovery.
27
+
28
+ ### Existing changes and failures
29
+
30
+ A branch does not isolate uncommitted changes into a separate directory as a worktree does. Record how existing staged,
31
+ unstaged, and untracked changes relate to the task and their preservation and edit ownership in the brief. Apply the
32
+ Preservation rule and do not automatically commit or delete changes to prepare the checkout. Only the
33
+ approved docs commit on all three paths is an exception to that no-commit rule; preserve all unrelated dirty files.
34
+ If existing changes prevent switching or ownership is unclear, stop handoff until Orchestrator resolves the state and
35
+ scope.
36
+
37
+ For an invalid name, branch creation or switching failure, lookup error, or unexpected current branch, inspect and
38
+ record the error and actual Git state, then stop Coder handoff. A branch created without a successful switch is partial
39
+ completion: report it, do not automatically delete it, and do not treat preparation as complete. Do not automatically
40
+ fall back to the current checkout path after an operational failure. Both operational failure and missing
41
+ execution-target choice block handoff. Orchestrator resolves the problem and rechecks preparation before handoff.
42
+
43
+
44
+ ### Worktree failures and partial completion
45
+
46
+ Worktree creation, registration, attachment, identity/base verification, checkout, document transfer, staging,
47
+ or commit failure means stop dependent work
48
+ and Coder handoff. Partial completion includes branch-only creation, partial path creation, registration/actual-path
49
+ mismatch, wrong base or branch, and partial document transfer. Record source and target exact command, error,
50
+ branch, HEAD, Git common directory, registration, index and files, including target dirty state and source preservation.
51
+ Before any authorized retry, inspect actual state and completed work under the Stop and inspect rule; do not repeat
52
+ completed actions.
53
+ Do not automatically fallback, retry another path/branch, delete paths, prune registrations with `git worktree prune`,
54
+ or use `--force` or `-B`; apply the Preservation rule.
55
+ Normal worktree preparation after explicit third-path selection is permitted under handoff; moving to an arbitrary
56
+ workspace during recovery remains prohibited. Resolve preparation and revalidate the full gate; a new explicit choice
57
+ follows Choice lifetime and restart record in handoff.md. No automatic cleanup/archive is authorized.
58
+
59
+ For managed worktree failures record tool inputs, operationId, result/error, returned actual path, app-managed
60
+ registration and current-chat attachment, initial/final branch, base/ref SHA, source/target HEAD/index/files and
61
+ ownership.
62
+ The completion, attach-retry and no-fallback limits of New managed worktree in handoff-worktree.md apply; after an
63
+ attach retry check completion and current-chat attachment again; if it still fails or results cannot be verified, stop
64
+ and report actual state. Never treat a directory as proof of app management.
@@ -0,0 +1,153 @@
1
+ # Handoff preparation contract
2
+
3
+ Orchestrator reads before an execution-target choice request and each preparation Git mutation (branch creation/switch,
4
+ staging, commit). The new managed worktree option's selection target is listed in the Execution-target request gate.
5
+ The Coder start gate, handoff evidence and choice lifetime are in [handoff.md](handoff.md).
6
+
7
+ ## Workspace handoff
8
+
9
+ ### Execution-target request gate
10
+
11
+ Before requesting the user's execution-target choice, Orchestrator verifies and records planned document scope,
12
+ absolute paths and scope coverage, design/plan depth and valid omissions, dependencies and intended execution order.
13
+ The request does not require completed documents or individual approvals; unfinished drafts alone do not block it.
14
+ The set contains required artifacts, not a spec on every path. Resolve scope/dependency decisions needed to identify
15
+ the target; do not require choice evidence before asking for that choice.
16
+ For every supported execution-target option, before obtaining the user's choice, present to the user:
17
+
18
+ - Planned document list, each document's scope and coverage, repository-relative expected paths, dependencies and order,
19
+ and pending writing and approval status.
20
+ - Verified absolute workspace, intended repository, current branch or detached HEAD, base HEAD, any validated
21
+ new-branch candidate and collision status when offered, staged/unstaged/untracked changes, preservation and edit ownership.
22
+
23
+ Obtain explicit choice under the Explicit choice rule before preparation.
24
+ When offering the new managed worktree option, Orchestrator first verifies and then presents its selection target
25
+ (source absolute
26
+ path, intended repository and Git common directory, source branch or detached HEAD, verified full source HEAD SHA,
27
+ approved branch candidate and collision status, descriptive name, planned document scope and any existing approved document transfer/commit scope). Verification
28
+ validates the approved branch candidate and collision status under New task branch naming rules and checks source state
29
+ (unrelated staged changes; existing approved document HEAD/index/working-tree state) before offering. The app chooses the actual
30
+ destination path: do not ask the user for a destination path or propose one, and do not fetch or substitute a remote
31
+ HEAD
32
+ or default branch for the base. Read [handoff-worktree.md](handoff-worktree.md) only after the user
33
+ explicitly selects that option and before its creation, branch work, or document transfer.
34
+
35
+ ### Git mutation evidence gate
36
+
37
+ Before each preparation Git mutation—branch creation/switch, worktree creation, approved-document staging,
38
+ or commit—read this reference and recheck explicit execution-target choice or verified valid reuse; absolute workspace
39
+ and intended repository; current branch or detached HEAD and HEAD; staged/unstaged/untracked changes, preservation and
40
+ edit ownership; and the exact command, target paths, and approved scope. Confirm no unresolved failure or partial
41
+ completion. Record these facts before the action. Missing or mismatched evidence stops that mutation.
42
+ Initial target preparation does not require the complete approved document set: verify planned scope and target inputs.
43
+ For approved-document staging and commit, also verify the complete approved document set and individual approval
44
+ evidence, approved versions, dependencies, and actual index. Read-only Git checks remain allowed.
45
+ Do not infer execution authority from an external skill's early commit step.
46
+
47
+ Before committing, also verify staged paths/content and the finalized message under Planning document commit.
48
+ After every branch or commit operation, verify actual path, branch, HEAD, preserved changes, and result before the
49
+ next dependent action. After staging, verify the actual index paths and diff before commit. Apply the Preservation
50
+ rule; unrelated staged files stop the mutation.
51
+ Reverify affected evidence after changes or failures; do not retroactively approve an action taken before its gate.
52
+
53
+ ### New task branch
54
+
55
+ With explicit user approval for the execution target, prepare the new task branch in the existing checkout.
56
+ Choose a valid Git branch name in the form `<type>/<short-kebab-case-topic>`. Use a lowercase prefix for the task's
57
+ main purpose and a short, specific lowercase kebab-case topic with no spaces. For mixed tasks, choose the main purpose.
58
+
59
+ | Prefix | Purpose |
60
+ |--------|---------|
61
+ | feat/ | Add a feature |
62
+ | fix/ | Fix a bug |
63
+ | refactor/ | Improve code structure while preserving behavior |
64
+ | docs/ | Change documentation |
65
+ | test/ | Add or change tests |
66
+ | build/ | Change build, packaging, or dependencies |
67
+ | ci/ | Change CI configuration |
68
+ | perf/ | Improve performance |
69
+ | style/ | Change formatting or style without behavior changes |
70
+ | chore/ | Change operational policy, tools, or maintenance |
71
+ | revert/ | Revert a prior change |
72
+
73
+ Validate the name and check for collisions before creation. If the base name exists, never automatically substitute a
74
+ suffix; present a new candidate for explicit approval. Never reuse, delete, or overwrite an existing branch.
75
+ Distinguish a lookup error from a missing branch.
76
+ Recheck the workspace, current branch or detached HEAD, base HEAD, and candidate before execution. If the approval
77
+ target changes, present the new target and obtain explicit user approval. If the candidate changes because of a new
78
+ collision, obtain approval for that candidate before creating or switching; without that approval, block handoff.
79
+ Use the current checkout only after the user explicitly selects it for this handoff. A failure during creation remains
80
+ an operational failure subject to Stop and inspect (SKILL.md) and Recovery prerequisite below.
81
+
82
+ Create and switch to the approved new branch from the confirmed base HEAD in the current checkout, for example with
83
+ `git switch -c <branch>`. Detached HEAD is acceptable when HEAD is resolved and included in the approval target.
84
+ After success, confirm the actual current branch matches the approved candidate, HEAD matches the recorded base, the
85
+ checkout absolute path is unchanged, and existing changes are preserved. Do not create a worktree or fall back to
86
+ worktree provisioning on failure. Only explicit selection of New managed worktree and task branch permits worktree
87
+ creation.
88
+
89
+ ### Current checkout
90
+
91
+ Only after the user explicitly selects the current checkout for this handoff, or valid reuse is verified,
92
+ confirm the absolute workspace,
93
+ current branch or detached HEAD, HEAD, and existing changes with their preservation and edit ownership. Record this
94
+ state and the choice evidence in the brief. Missing choice, unconfirmed state, or unclear ownership blocks handoff.
95
+
96
+ ### Planning document commit
97
+
98
+ Begin only after target preparation and the complete applicable set is written and individually approved.
99
+ Verify complete approved document set, approval evidence and versions before staging or commit.
100
+ On the new task branch path, verify the successful switch, actual branch, unchanged checkout path, and preserved
101
+ changes first. On the current checkout path, verify the selected branch or detached HEAD, path, and existing changes.
102
+ On the new worktree path, verify the created app-managed worktree, current-chat attachment, identity/base, approved
103
+ branch and direct target documents (or protected legacy/restart document transfer) before any target docs commit.
104
+ At the target, commit only remaining approved documents once; do not automatically make a source document commit.
105
+ Record the selected base SHA and post-commit HEAD.
106
+ Orchestrator verifies each approved spec/plan already committed for this task by SHA, actual message, included paths,
107
+ and
108
+ content matching the approved version and validity in the selected checkout; reuse valid commits without recommitting
109
+ them.
110
+
111
+ For approved documents still uncommitted, Orchestrator records the approved versions and paths, finalizes the specific
112
+ English
113
+ Conventional Commit message before the first commit, and stages only those documents for one focused docs commit
114
+ before handoff. Batch all remaining uncommitted approved documents together in that single commit. If all are
115
+ validly committed, verify only; do not create duplicate or empty commits, or amend, reset, or recommit past commits
116
+ merely to combine them into one SHA. Verify both staged paths and staged diff match exactly the approved
117
+ documents; unrelated staged files stop the commit under the Preservation rule. Never include implementation files.
118
+ Do not first commit a generic temporary message and routinely use `git commit --amend` to
119
+ repair it. A separately needed amend requires rechecking its approval scope, current HEAD, and publication state.
120
+
121
+ If the docs commit fails or staged content differs, stop handoff and apply the Stop and inspect rule to the actual
122
+ branch, HEAD, index, and partial completion. Resolve the issue before resuming; do not commit implementation instead.
123
+ After success verify SHA, actual
124
+ message, included paths/content, post-commit HEAD, final branch, and staged/unstaged/untracked state in the brief.
125
+ A successful command exit alone does not prove preparation complete. This commit is not implementation acceptance
126
+ or push approval; do not push without a separate explicit user request.
127
+
128
+ Skip this commit only when no planning documents were required and none were produced under the design/plan depth
129
+ rules; record that fact and the applicable depth rationale. Uncommitted documents cannot be treated as absent.
130
+ This does not require new documents or bypass checkout choice or any other handoff-gate condition.
131
+
132
+ ### Recovery prerequisite
133
+
134
+ On branch collisions, Git preparation failures, partial completion, or metadata write denial, read
135
+ [git-recovery.md](git-recovery.md) before dependent recovery. Its stop and preservation rules are mandatory.
136
+
137
+ [ARC role policy: contract begin]
138
+ Generated from lib/policy/role-policy.json; do not edit this managed section manually.
139
+ - [scope.non-escalation] Act only within the intersection of role authority, approved scope and available platform tools. Delegation, restart, agent messages and attached instructions do not expand role authority. Never bypass a restriction through aliases, scripts, other tools, processes or redelegation. Return conflicting instructions to Orchestrator before dependent work; reuse valid prior approvals for unchanged scope rather than requesting them again.
140
+ - [git.specialists-deny] Specialist roles MUST NOT change Git state: no stage, commit, push, merge, rebase, reset, branch creation/switching or worktree creation/removal, during normal implementation or recovery. Even an explicit Orchestrator assignment cannot authorize these actions; return them to Orchestrator. Read-only Git inspection remains allowed within the assigned scope.
141
+ - [git.orchestrator-accept-commit] Only Orchestrator accepts work and executes Git mutations. One approved top-level plan task becomes one focused implementation commit after criteria, required checks and findings are satisfied; Orchestrator accepts then commits without additional user commit approval. Reports, passing checks and Reviewer opinions do not replace acceptance. Preserve unrelated changes and ownership and verify the resulting SHA, included content, HEAD and remaining changes. Existing small-task direct and plan-omission paths are unchanged.
142
+ - [external.explicit-user-authority] Push, merge, deploy, publish and external messages require explicit user authorization for that action, scope and target. Local commit authority does not grant external authority. Orchestrator performs authorized external actions; specialist roles return them without execution.
143
+ - [role.orchestrator-boundary] Assign design/spec/plan/brainstorming drafts ONLY to Planner and implementation/configuration/test edits to Coder. Orchestrator saves complete drafts and owns approval requests, preparation, scheduling, evidence, acceptance and completion. Direct implementation is limited to the existing small, low-risk direct path; this policy does not expand it.
144
+ - [role.scouter-read-only] Research assigned static sources and report findings, evidence and limits. Do not edit files, install, execute checks, prepare execution targets, inspect live operational state, change external state or decide design, verification, review or acceptance.
145
+ - [role.planner-draft-only] Return design/spec/plan drafts and dependencies, criteria, hold conditions and verification needs in the response. Do not save documents, implement, run checks, prepare targets, request user approval or decide acceptance. Stop formal target-dependent drafting if actual prepared target evidence is missing; route decisions to Orchestrator.
146
+ - [role.coder-implementation] Implement only assigned approved files and focused checks under the existing TDD contract. Report changed files, RED/GREEN or authorized exception evidence, results, limits and follow-up. Do not plan, independently QA/review your own work, accept the task or declare overall completion. Git changes remain forbidden even when implementation succeeds.
147
+ - [role.qa-verification] Run approved checks and report commands, observations, reproduction, evidence and limits. Create only essential temporary data/logs/reports in the brief-authorized location and lifetime. Do not edit product source, tests, fixtures or configuration to pass checks, deploy or accept work. Persistent product-state checks require explicit scope and cleanup ownership. Return failures for Coder correction and required QA recheck.
148
+ - [role.reviewer-independent] Independently inspect the assigned final changes and evidence and report actionable findings and limits. Remain read-only; do not execute QA tests, edit files, perform Git mutations or decide acceptance.
149
+ - [review.significant-no-plan] For significant/high-risk work without a plan: Coder → QA and required QA rechecks → Reviewer of the final full change → Orchestrator acceptance. Do not omit Reviewer merely because no plan exists. This creates no new plan obligation.
150
+ - [review.significant-plan] For significant/high-risk plan work: each task uses Coder → fresh QA as required → Orchestrator acceptance and focused commit. After all tasks are accepted and required QA is complete, Reviewer reviews the final full change once. Reviewer is NOT a per-task or per-commit required gate. Preserve required checks and necessary finding rechecks.
151
+ - [review.final-plan-recheck] For final overall Reviewer findings on plan work, including behavior findings, use Coder → Reviewer without QA reassignment; repeat until resolved. This exception applies only to that final plan stage. Preserve required QA and QA failure rechecks before initial final review and outside this exception.
152
+ - [platform.codex] Role restrictions are prompt-level contracts, not a filesystem sandbox. No documented role-specific Git hook or generic per-agent tool allowlist is assumed. Existing shell capabilities are retained because static read access after shell reduction has not been verified; Coder and QA need shell for approved checks.
153
+ [ARC role policy: contract end]
@@ -0,0 +1,93 @@
1
+ # Managed worktree handoff contract
2
+
3
+ Orchestrator reads after the user explicitly selects the new managed worktree option, before its creation,
4
+ branch work or
5
+ document transfer. Apply [handoff-prep.md](handoff-prep.md) and [handoff.md](handoff.md) gates as well.
6
+
7
+ ## Workspace handoff
8
+
9
+ ### New managed worktree
10
+
11
+ Before formal drafting and saving, complete actual creation, managed registration, current-chat attachment,
12
+ repository/common directory and base verification, approved branch verification, and source preservation checks below.
13
+ The normal new-document path drafts and saves directly in the verified target. Planned destination paths are not
14
+ preparation evidence. Initial preparation does not authorize Coder or a document commit.
15
+
16
+ Only an explicit user choice of this third path authorizes preparation. Its selection target is the one verified
17
+ under the Execution-target request gate in handoff-prep.md.
18
+ The app determines the actual destination path; do not propose a sibling path or require a user-specified path
19
+ candidate.
20
+ Use the verified source HEAD full SHA as the base; do not substitute remote HEAD or a default branch or fetch
21
+ automatically.
22
+ Recheck approved source state, base SHA, approved branch candidate/collision status, name and approved document scope
23
+ after choice and immediately before the tool call. After selection and before creation, any changes require
24
+ a fresh explicit choice for the updated inputs. This is the pre-creation candidate rule. After successful creation
25
+ and verification, apply Choice lifetime and restart record in handoff.md.
26
+
27
+ Before calling mcp__codex_app__create_worktree, validate the approved branch candidate and collision state with
28
+ New task branch naming rules in handoff-prep.md. A collision requires a new explicit choice; never automatically
29
+ substitute a suffix.
30
+ Exception for this managed path: an existing approved branch at the same base and not checked out in any worktree
31
+ may be reused; verify both conditions before reuse. An unexpected branch, different base or lookup uncertainty means
32
+ stop.
33
+
34
+ Create using only the app tool:
35
+
36
+ mcp__codex_app__create_worktree({
37
+ allowAsync: true,
38
+ name: "<approved-descriptive-name>",
39
+ ref: "<verified-source-head-full-sha>"
40
+ })
41
+
42
+ The name is descriptive and does not guarantee a path or branch. There are no destination path or branch arguments.
43
+ Pass ref explicitly as the full SHA; do not omit it or rely on a remote default. If an operationId is returned,
44
+ use mcp__codex_app__get_worktree_creation_status until completed. Preparing/creating/registering progress is not
45
+ success.
46
+ For registration failure only, retry the returned workspace with mcp__codex_app__attach_worktree. Before completed
47
+ managed registration, current-chat attachment and approved branch verification, perform no formal drafting, saving, document transfer, staging,
48
+ commit or Coder start. If tools are unavailable, reattachment fails or results mismatch, stop and record actual state.
49
+ Do not fall back to raw Git worktree creation, automatically retry other name/ref/path/branch inputs,
50
+ or perform automatic
51
+ cleanup, delete, prune or archive. See git-recovery.md before dependent recovery.
52
+
53
+ Verify the returned actual absolute worktree path and app-managed current-chat attachment using app artifacts.
54
+ Record initial branch or detached HEAD, approved branch candidate, final branch, and target HEAD equal to approved ref.
55
+ Verify linked-worktree registration and source/target Git common directory identity, registered path,
56
+ target dirty state,
57
+ and source branch, HEAD, index and files preservation; shared Git metadata additions for the approved target are
58
+ authorized.
59
+ Linked worktree .git may be a file; do not require the same top-level path or a .git directory for repository identity.
60
+ Verify registration, attachment and base before creating/checking out the approved branch. If initially detached,
61
+ use `git switch -c <approved-branch> <ref>`; if the existing approved branch has the same base and is not checked out
62
+ in any worktree, use `git switch <approved-branch>`. Do not move a branch pointer, choose another branch or use --force
63
+ or -B.
64
+ If the app initially returns the approved branch, verify it and its base rather than repeating completed work.
65
+ Unexpected branch or mismatched HEAD means stop. Verify final approved branch and HEAD before formal drafting, saving, document transfer,
66
+ the batch docs commit, final Git verification and Coder handoff.
67
+
68
+ The tool does not copy uncommitted changes. The following transfer rules apply only to legacy or restart cases
69
+ with existing approved documents (including an explicitly selected target change), not the normal new-document path. For untracked approved documents, source HEAD and index paths must be
70
+ absent and source working-tree bytes must match the latest approved version. For tracked approved documents, source
71
+ index blob and mode must equal source HEAD, while source working-tree bytes must match the latest approved version.
72
+ Approved working-tree revisions may differ from HEAD/index; do not repair or verify them by staging source documents.
73
+ Any mismatch means stop. Unrelated staged changes, required uncommitted implementation/configuration/test changes,
74
+ and unclear ownership block preparation. Clearly unrelated unstaged/untracked changes remain in source.
75
+ Do not automatically stash, commit, reset, clean, or unstage; do not transfer dirty implementation files.
76
+ For those existing approved documents, use Worktree document transfer before target docs preparation.
77
+
78
+ ### Worktree document transfer
79
+
80
+ Use only for existing approved documents in legacy or restart/target-change cases.
81
+
82
+ Verify existing approved commits by SHA, message, paths and approved content valid at base and target; reuse them.
83
+ Copy only uncommitted approved spec/plan documents to the target at the same repository-relative path.
84
+ Do not move, delete, or modify the source documents. If a destination resolves outside the worktree, including through
85
+ an escaping symlink, stop. Before transfer verify target HEAD equals the selected source base SHA.
86
+ Before replacing an existing destination,
87
+ prove its clean base state with no staged/unstaged changes and index and working-tree bytes matching the base version;
88
+ then replace with the approved version. A document absent from base must also be absent at the destination.
89
+ For unexpected changes, do not overwrite; stop.
90
+ For identical content, verify approved bytes before reuse. After transfer verify bytes match the approved version.
91
+ The canonical record includes each document approval/version/evidence, source and target absolute paths and the common
92
+ relative path plus content verification. Changed content or approval scope requires approval of the revised version.
93
+ Transfer no other files. Failure or partial transfer blocks all dependent staging, commit and Coder handoff.
@@ -0,0 +1,181 @@
1
+ # Handoff contract
2
+
3
+ Orchestrator reads before every Coder first start or restart preparation. Coder trusts the Orchestrator-verified facts
4
+ in the brief under
5
+ the Coder profile and reads this file only for sections the brief explicitly cites. First-start preparation
6
+ (execution-target choice request, preparation Git mutations, planning-document commit) is in
7
+ [handoff-prep.md](handoff-prep.md); the new managed worktree path is in [handoff-worktree.md](handoff-worktree.md).
8
+
9
+ ## Workspace handoff
10
+
11
+ ### Checkout approval
12
+
13
+ Before every Coder first start and restart, Orchestrator confirms the supplied absolute workspace is accessible and
14
+ belongs
15
+ to the intended Git repository; record its actual absolute path, current branch or detached HEAD, HEAD, and staged,
16
+ unstaged, and untracked changes. Stop if the workspace is inaccessible, is not the intended repository, or HEAD
17
+ cannot be resolved. Do not initialize Git or switch to another repository automatically.
18
+
19
+ Execution-target choice and actual preparation precede formal drafting and saving of required specs/plans.
20
+ Initial design proposals may precede choice. Initial target preparation does not authorize Coder; all applicable
21
+ approvals, complete documents, verified batch docs commits or valid absence, and final Git verification remain required.
22
+ Record planned document scope/paths and actual preparation separately, followed by actual drafting/save/approval and
23
+ commit results; preserve actual order and evidence gaps. Reuse a valid choice during document drafting and subsequent
24
+ implementation while scope and target remain unchanged. Authorized HEAD and dirty-state changes alone do not invalidate
25
+ choice; verify preservation and ownership. A changed scope or target requires fresh explicit choice before dependent
26
+ drafting or preparation and does not require document completion. Never fall back automatically.
27
+
28
+ After initial design approval, obtain and record an explicit user choice for the first start under the
29
+ Explicit choice rule: use the current checkout, create a new task branch from the verified base HEAD in that same
30
+ checkout, or create a new managed worktree and task branch (selection target under handoff-prep.md; contract in
31
+ handoff-worktree.md after selection). Without an
32
+ explicit execution-target choice or verified valid reuse under the choice-lifetime rules below, wait and do not start or
33
+ restart Coder.
34
+
35
+ ### Coder handoff gate
36
+
37
+ Orchestrator may start or restart Coder only after all of these conditions are verified:
38
+
39
+ 1. All applicable design/spec/plan approvals are recorded with approved artifact paths or valid depth-omission reasons.
40
+ For a Coder Spike probe, record its approved question, method/scope, acceptance criteria, and constraints.
41
+ The complete current-scope document list, approved versions, plan dependencies/order, and absence of unfinished
42
+ applicable documents are verified. Future implementation artifacts are not part of the probe scope or approved by it.
43
+ 2. The user explicitly selected the execution target initially, or that initial choice remains valid under the restart
44
+ rules below.
45
+ 3. The accessible absolute workspace is the intended Git repository.
46
+ 4. Actual branch or detached HEAD, HEAD, staged/unstaged/untracked state, preservation, and edit ownership are known.
47
+ Unrelated staged files are preserved and block handoff until Orchestrator resolves preparation.
48
+ 5. Approved planning-document commits are verified, or no documents were required or produced and the valid depth
49
+ rationale is recorded.
50
+ 6. After any commit or branch operation, final path, branch, HEAD, and change state are rechecked with no unresolved
51
+ failure or partial completion.
52
+ 7. The brief includes these preparation and final-verification facts and evidence.
53
+
54
+ Before a Orchestrator direct edit, Orchestrator verifies the same conditions, with the approved scope record as the
55
+ applicable approval,
56
+ and records them in the brief.
57
+
58
+ Any missing or failed condition blocks handoff. Orchestrator may continue read-only investigation and authorized
59
+ preparation
60
+ or recovery, but cannot start Coder early. Reverify affected evidence when approved content, execution target, branch,
61
+ HEAD, or relevant state changes. Coder's conflict reporting is in its profile; Orchestrator
62
+ resolves preparation and passes the gate again before Coder resumes.
63
+
64
+ ### Handoff evidence
65
+
66
+ For the worktree path the canonical record maps source and target absolute paths, Git common directory, base SHA,
67
+ selected branch, descriptive name, returned actual path, app-managed current-chat attachment, operationId/result,
68
+ registration and preservation checks, and document transfer evidence. Do not automatically recreate, cleanup, or
69
+ archive a worktree.
70
+
71
+ Include the document-save gate evidence and results from planning.md, execution-target request readiness, and each
72
+ preparation Git mutation's pre-action evidence and post-action result in the same canonical record.
73
+ Record the actual absolute workspace, prior branch or detached HEAD and base HEAD, prior change state and preservation
74
+ and edit scope, checkout approval result and evidence, selected execution path, final branch or detached HEAD,
75
+ creation/switch result if attempted, and post-selection branch/path/HEAD/change checks in the brief. Include the docs
76
+ commit SHA, actual message, included paths, approved-content verification or valid no-document depth rationale,
77
+ final verification, and any failure/partial completion and recovery evidence, plus absolute approved artifact paths.
78
+ Record the Complete planning-document set fields from planning.md, confirming no applicable document awaits
79
+ writing/approval.
80
+ Distinguish reused existing commits from the batch preparation commit, or record valid document absence.
81
+ Record applicable approvals and the initial explicit execution-target choice or verified reuse for each first start or
82
+ restart. Give all five
83
+ roles (Coder, QA, Planner, Reviewer, Scouter) the same actual workspace and selected execution checkout or absolute
84
+ worktree path, preparation
85
+ evidence, and absolute artifact paths. Each
86
+ role stays in the supplied workspace, reports missing, inaccessible, or conflicting paths and unexpected branch state to
87
+ Orchestrator before dependent work, and does not create or switch workspaces or branches.
88
+
89
+ ### Task readiness at every assignment
90
+
91
+ Before each first start or restart, if an approved plan exists, link its current dependency/readiness record
92
+ (planning.md) in the canonical record and brief. Where plan omission is valid under existing rules, do not create a
93
+ plan or map solely to satisfy this linking duty; record the applicable omission judgment and rationale in the
94
+ canonical record and brief. Plan absence alone does not qualify for omission, and an unapproved required plan
95
+ cannot bypass its approval gate.
96
+
97
+ Before assignment, apply every readiness condition in
98
+ [planning.md, Dependency and readiness record](planning.md#dependency-and-readiness-record), including predecessor
99
+ checks, Orchestrator acceptance and verified focused commit or accepted no-change evidence. A Coder completion report
100
+ alone is insufficient. Verify the linked record is current and capacity and file ownership permit assignment.
101
+ Readiness supplements the full handoff gate and execution-target restrictions; it never waives them.
102
+ For authorized HEAD or state changes, refresh this record and affected briefs, verify preservation and ownership,
103
+ revalidate affected gates, and reassess readiness under planning.md and [commit.md](commit.md#shared-checkout-coordination).
104
+ Unexpected HEAD or ownership changes stop affected work for Orchestrator resolution and revalidation.
105
+
106
+ ### Choice lifetime and restart record
107
+
108
+ For the same approved scope, workspace, repository, and execution target, reuse the initial explicit choice only
109
+ when its evidence is accessible and still valid. On every first start and restart, Orchestrator rechecks actual Git
110
+ state
111
+ against the current brief: absolute workspace and repository identity, branch or detached HEAD, HEAD,
112
+ staged/unstaged/untracked changes, preservation and edit ownership, applicable approvals and artifacts,
113
+ planning-document SHA/message/paths/content or valid no-document rationale, and Orchestrator's final state verification
114
+ (Coder handoff gate items 1-7); a reused choice never waives any gate. A restart without document changes reuses
115
+ verified valid planning-document commits without recommitting them and a still-valid initial choice, with fresh
116
+ actual-state checks. Normal authorized HEAD and dirty-state changes, including accepted task commits, docs commits,
117
+ implementation, and approved worktree document transfer, do not by themselves invalidate the choice; record them and
118
+ verify that they match approved work, ownership, and the intended target. A worktree's creation base SHA remains
119
+ evidence; target HEAD need not remain at that base; source preservation and unexpected-state checks still apply.
120
+ Link the approved plan version, task ID and commit SHA/content/validity with current Git state and edit ownership in
121
+ the restart brief under Orchestrator's full handoff gate. Verify/reuse successful task commits without duplication and
122
+ keep planning-document preparation
123
+ evidence distinct; task commits do not require repeating valid document preparation.
124
+
125
+ If scope, workspace, repository, target, or approved branch candidate changes, obtain a fresh explicit choice before dependent drafting or preparation; reselection does not require document completion. If an invalidating failure means the old target cannot be trusted,
126
+ obtain a fresh explicit choice after Orchestrator resolves preparation. State mismatches and unresolved failures block
127
+ editing until Orchestrator resolves and revalidates the full gate; resolution does not automatically require a new
128
+ choice
129
+ unless it invalidates the old target. Do not fall back automatically; apply the Explicit choice rule.
130
+
131
+ Keep one canonical initial handoff record accessible to each assigned role, containing the approved scope/version,
132
+ repository/workspace identity, and the Handoff evidence fields above; do not create a separate storage service.
133
+ Orchestrator writes it as a
134
+ Markdown file at `<git-common-dir>/arc/handoff/<plan-or-task-slug>.md` (slug unique to the plan, the dated plan filename
135
+ stem, or a spec/task slug when no plan exists; never overwrite another plan's record; resolve with
136
+ `git rev-parse --path-format=absolute --git-common-dir`; outside the working tree and shared by linked worktrees; not a
137
+ Git mutation, never staged or committed; contains no secrets), gives its absolute path in every brief, and restart
138
+ briefs cite it. If
139
+ the write is denied or unavailable, each Coder brief states why and includes the full record inline, with no delta;
140
+ that inline record satisfies the accessible record requirement. Do not delete it automatically.
141
+
142
+ Restart brief: supply only verified deltas and mark unchanged fields; `unchanged` means unchanged relative to the record
143
+ file the fresh Coder reads, and every other brief field is in full. Include: initial record location,
144
+ next objective and edit ownership, changed decisions,
145
+ approvals, documents and scope (or explicit no-change confirmation), current Git state and differences, choice
146
+ validity and reuse verification, refreshed commit/artifact checks, Orchestrator final verification, and remaining
147
+ issues.
148
+ An inaccessible initial record, missing evidence, or unclear ownership blocks editing; a prior conversation or
149
+ inaccessible link cannot substitute for evidence. Include material needed for a self-contained role handoff, with
150
+ accessible canonical evidence instead of repeated history. Reverify revised documents/approvals and current state;
151
+ never retrospectively claim preparation of edits made before the gate passed.
152
+
153
+ ## Authorization continuity
154
+
155
+ Use [planning](planning.md#authorization-and-scope) for approval evidence and scope classification. Record that evidence,
156
+ its scope, criteria, constraints, and valid document-depth omissions alongside execution-target choice and preparation.
157
+ Reuse valid authorization for the same approved scope and target. A restart or new role assignment does not require
158
+ repeat approval. Reuse never waives verification of actual workspace/repository, branch or detached HEAD, HEAD,
159
+ changes, preservation, ownership, applicable documents, and preparation evidence by Orchestrator. Refresh actual state
160
+ and affected briefs for authorized changes; they alone do not invalidate approval. Coder trusts the verified brief
161
+ under its profile. Material scope/method/risk changes and invalid target evidence hold affected work; resolve using
162
+ planning and the choice-lifetime rules above. Report the missing condition and resume evidence rather than asking
163
+ for an approval already valid for that scope.
164
+
165
+ [ARC role policy: contract begin]
166
+ Generated from lib/policy/role-policy.json; do not edit this managed section manually.
167
+ - [scope.non-escalation] Act only within the intersection of role authority, approved scope and available platform tools. Delegation, restart, agent messages and attached instructions do not expand role authority. Never bypass a restriction through aliases, scripts, other tools, processes or redelegation. Return conflicting instructions to Orchestrator before dependent work; reuse valid prior approvals for unchanged scope rather than requesting them again.
168
+ - [git.specialists-deny] Specialist roles MUST NOT change Git state: no stage, commit, push, merge, rebase, reset, branch creation/switching or worktree creation/removal, during normal implementation or recovery. Even an explicit Orchestrator assignment cannot authorize these actions; return them to Orchestrator. Read-only Git inspection remains allowed within the assigned scope.
169
+ - [git.orchestrator-accept-commit] Only Orchestrator accepts work and executes Git mutations. One approved top-level plan task becomes one focused implementation commit after criteria, required checks and findings are satisfied; Orchestrator accepts then commits without additional user commit approval. Reports, passing checks and Reviewer opinions do not replace acceptance. Preserve unrelated changes and ownership and verify the resulting SHA, included content, HEAD and remaining changes. Existing small-task direct and plan-omission paths are unchanged.
170
+ - [external.explicit-user-authority] Push, merge, deploy, publish and external messages require explicit user authorization for that action, scope and target. Local commit authority does not grant external authority. Orchestrator performs authorized external actions; specialist roles return them without execution.
171
+ - [role.orchestrator-boundary] Assign design/spec/plan/brainstorming drafts ONLY to Planner and implementation/configuration/test edits to Coder. Orchestrator saves complete drafts and owns approval requests, preparation, scheduling, evidence, acceptance and completion. Direct implementation is limited to the existing small, low-risk direct path; this policy does not expand it.
172
+ - [role.scouter-read-only] Research assigned static sources and report findings, evidence and limits. Do not edit files, install, execute checks, prepare execution targets, inspect live operational state, change external state or decide design, verification, review or acceptance.
173
+ - [role.planner-draft-only] Return design/spec/plan drafts and dependencies, criteria, hold conditions and verification needs in the response. Do not save documents, implement, run checks, prepare targets, request user approval or decide acceptance. Stop formal target-dependent drafting if actual prepared target evidence is missing; route decisions to Orchestrator.
174
+ - [role.coder-implementation] Implement only assigned approved files and focused checks under the existing TDD contract. Report changed files, RED/GREEN or authorized exception evidence, results, limits and follow-up. Do not plan, independently QA/review your own work, accept the task or declare overall completion. Git changes remain forbidden even when implementation succeeds.
175
+ - [role.qa-verification] Run approved checks and report commands, observations, reproduction, evidence and limits. Create only essential temporary data/logs/reports in the brief-authorized location and lifetime. Do not edit product source, tests, fixtures or configuration to pass checks, deploy or accept work. Persistent product-state checks require explicit scope and cleanup ownership. Return failures for Coder correction and required QA recheck.
176
+ - [role.reviewer-independent] Independently inspect the assigned final changes and evidence and report actionable findings and limits. Remain read-only; do not execute QA tests, edit files, perform Git mutations or decide acceptance.
177
+ - [review.significant-no-plan] For significant/high-risk work without a plan: Coder → QA and required QA rechecks → Reviewer of the final full change → Orchestrator acceptance. Do not omit Reviewer merely because no plan exists. This creates no new plan obligation.
178
+ - [review.significant-plan] For significant/high-risk plan work: each task uses Coder → fresh QA as required → Orchestrator acceptance and focused commit. After all tasks are accepted and required QA is complete, Reviewer reviews the final full change once. Reviewer is NOT a per-task or per-commit required gate. Preserve required checks and necessary finding rechecks.
179
+ - [review.final-plan-recheck] For final overall Reviewer findings on plan work, including behavior findings, use Coder → Reviewer without QA reassignment; repeat until resolved. This exception applies only to that final plan stage. Preserve required QA and QA failure rechecks before initial final review and outside this exception.
180
+ - [platform.codex] Role restrictions are prompt-level contracts, not a filesystem sandbox. No documented role-specific Git hook or generic per-agent tool allowlist is assumed. Existing shell capabilities are retained because static read access after shell reduction has not been verified; Coder and QA need shell for approved checks.
181
+ [ARC role policy: contract end]