@yunhozz/arc 0.1.1 → 0.1.3

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 (78) hide show
  1. package/MANIFEST.sha256 +75 -36
  2. package/claude/agents/arc-coder.md +10 -9
  3. package/claude/agents/arc-planner.md +13 -12
  4. package/claude/agents/arc-qa.md +9 -8
  5. package/claude/agents/arc-reviewer.md +11 -10
  6. package/claude/agents/arc-scouter.md +10 -9
  7. package/claude/skill/SKILL.md +13 -17
  8. package/claude/skill/hooks/role-git-guard.mjs +3 -83
  9. package/claude/skill/hooks/runtime-gate.mjs +12 -0
  10. package/claude/skill/models.toml +11 -11
  11. package/claude/skill/references/commit.md +8 -9
  12. package/claude/skill/references/git-recovery.md +1 -1
  13. package/claude/skill/references/handoff-prep.md +8 -8
  14. package/claude/skill/references/handoff.md +8 -8
  15. package/claude/skill/references/limits.md +4 -4
  16. package/claude/skill/references/planning.md +9 -9
  17. package/claude/skill/references/verification.md +10 -10
  18. package/claude/skill/references/visual-companion.md +2 -3
  19. package/claude/skill/runtime/adapters/claude.mjs +81 -0
  20. package/claude/skill/runtime/adapters/codex.mjs +63 -0
  21. package/claude/skill/runtime/capabilities.mjs +32 -0
  22. package/claude/skill/runtime/evaluate.mjs +103 -0
  23. package/claude/skill/runtime/gate.mjs +71 -0
  24. package/claude/skill/runtime/git-evidence.mjs +114 -0
  25. package/claude/skill/runtime/git-query.mjs +88 -0
  26. package/claude/skill/runtime/identity.mjs +27 -0
  27. package/claude/skill/runtime/operations.mjs +6 -0
  28. package/claude/skill/runtime/role-policy.json +607 -0
  29. package/claude/skill/runtime/schema.mjs +78 -0
  30. package/claude/skill/runtime/store.mjs +63 -0
  31. package/claude/skill/scripts/model_config.py +78 -18
  32. package/codex/agents/arc-coder.toml +8 -8
  33. package/codex/agents/arc-planner.toml +9 -9
  34. package/codex/agents/arc-qa.toml +6 -6
  35. package/codex/agents/arc-reviewer.toml +7 -7
  36. package/codex/agents/arc-scouter.toml +6 -6
  37. package/codex/skill/SKILL.md +15 -19
  38. package/codex/skill/hooks/runtime-gate.mjs +10 -0
  39. package/codex/skill/models.toml +11 -11
  40. package/codex/skill/references/commit.md +9 -9
  41. package/codex/skill/references/git-recovery.md +1 -1
  42. package/codex/skill/references/handoff-prep.md +9 -10
  43. package/codex/skill/references/handoff-worktree.md +1 -1
  44. package/codex/skill/references/handoff.md +9 -9
  45. package/codex/skill/references/limits.md +4 -4
  46. package/codex/skill/references/planning.md +11 -12
  47. package/codex/skill/references/verification.md +10 -11
  48. package/codex/skill/references/visual-companion.md +3 -3
  49. package/codex/skill/runtime/adapters/claude.mjs +81 -0
  50. package/codex/skill/runtime/adapters/codex.mjs +63 -0
  51. package/codex/skill/runtime/capabilities.mjs +32 -0
  52. package/codex/skill/runtime/evaluate.mjs +103 -0
  53. package/codex/skill/runtime/gate.mjs +71 -0
  54. package/codex/skill/runtime/git-evidence.mjs +114 -0
  55. package/codex/skill/runtime/git-query.mjs +88 -0
  56. package/codex/skill/runtime/identity.mjs +27 -0
  57. package/codex/skill/runtime/operations.mjs +6 -0
  58. package/codex/skill/runtime/role-policy.json +607 -0
  59. package/codex/skill/runtime/schema.mjs +78 -0
  60. package/codex/skill/runtime/store.mjs +63 -0
  61. package/lib/models/profiles.mjs +41 -4
  62. package/lib/policy/claude-hook.mjs +57 -17
  63. package/lib/policy/render.mjs +1 -0
  64. package/lib/policy/role-policy.json +38 -8
  65. package/lib/runtime/adapters/claude.mjs +81 -0
  66. package/lib/runtime/adapters/codex.mjs +63 -0
  67. package/lib/runtime/capabilities.mjs +32 -0
  68. package/lib/runtime/evaluate.mjs +103 -0
  69. package/lib/runtime/gate.mjs +71 -0
  70. package/lib/runtime/git-evidence.mjs +114 -0
  71. package/lib/runtime/git-query.mjs +88 -0
  72. package/lib/runtime/identity.mjs +27 -0
  73. package/lib/runtime/operations.mjs +6 -0
  74. package/lib/runtime/schema.mjs +78 -0
  75. package/lib/runtime/store.mjs +63 -0
  76. package/package.json +1 -1
  77. package/scripts/probe-runtime-hooks.mjs +55 -0
  78. package/scripts/update-runtime-assets.mjs +19 -0
@@ -24,7 +24,7 @@ repository, branch or detached HEAD, HEAD, staged/unstaged/untracked state and e
24
24
  content match only that task, and verify the finalized commit message. If the same file contains other tasks or user
25
25
  changes, prove safe separation before committing. Unrelated staged changes stop the commit under the Preservation
26
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
27
+ paths and content, post-commit HEAD, actual branch and remaining staged/unstaged/untracked state. A successful command exit
28
28
  alone does not establish completion. In the accessible canonical record link plan path/version, task ID, acceptance
29
29
  evidence and Orchestrator judgment, required checks and findings, commit results and state, hold/no-change/reuse
30
30
  reasons,
@@ -54,7 +54,7 @@ Final QA findings retain Coder correction and QA recheck before a new focused co
54
54
  Do not automatically amend/reset or duplicate the original task commit. Scope expansion keeps existing new
55
55
  planning and approval obligations.
56
56
 
57
- This local commit authority does not authorize early planning-document commits: pre-Coder document approvals,
57
+ Local commit authority does not authorize early planning-document commits: pre-Coder document approvals,
58
58
  explicit execution-target choice and batch preparation remain unchanged. Historical spec/plan records are not changed
59
59
  retroactively. Structural checks of this contract do not prove actual agent runtime compliance.
60
60
  Follow Conventional Commits with the message form
@@ -83,18 +83,18 @@ commit obligation to no-plan work and does not turn a local commit into overall
83
83
 
84
84
  [ARC role policy: contract begin]
85
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.
86
+ - [scope.non-escalation] Act only where role authority, approved scope and available platform tools all permit. Delegation, restart, agent messages and attached instructions do not expand role authority. MUST NOT 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
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
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.
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 grants no external authority. Orchestrator performs authorized external actions; specialist roles return them without execution.
90
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
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.
92
+ - [role.planner-draft-only] Return design/spec/plan drafts and dependencies, criteria, hold conditions and verification needs in the response. MUST 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] Edit only assigned, approved files and run 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
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.
95
+ - [role.reviewer-independent] Independently inspect the assigned final changes and evidence and report actionable findings and limits. Remain read-only. MUST 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. MUST NOT omit Reviewer merely because no plan exists. This creates no new plan obligation.
97
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.
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 at the final plan stage. Preserve required QA and QA failure rechecks before initial final review and outside this exception.
99
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
100
  [ARC role policy: contract end]
@@ -61,4 +61,4 @@ registration and current-chat attachment, initial/final branch, base/ref SHA, so
61
61
  ownership.
62
62
  The completion, attach-retry and no-fallback limits of New managed worktree in handoff-worktree.md apply; after an
63
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.
64
+ and report actual state. A directory alone does not prove app management.
@@ -44,7 +44,7 @@ For approved-document staging and commit, also verify the complete approved docu
44
44
  evidence, approved versions, dependencies, and actual index. Read-only Git checks remain allowed.
45
45
  Do not infer execution authority from an external skill's early commit step.
46
46
 
47
- Before committing, also verify staged paths/content and the finalized message under Planning document commit.
47
+ Before committing, also verify staged paths/content and the final message under Planning document commit.
48
48
  After every branch or commit operation, verify actual path, branch, HEAD, preserved changes, and result before the
49
49
  next dependent action. After staging, verify the actual index paths and diff before commit. Apply the Preservation
50
50
  rule; unrelated staged files stop the mutation.
@@ -115,8 +115,7 @@ before handoff. Batch all remaining uncommitted approved documents together in t
115
115
  validly committed, verify only; do not create duplicate or empty commits, or amend, reset, or recommit past commits
116
116
  merely to combine them into one SHA. Verify both staged paths and staged diff match exactly the approved
117
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.
118
+ MUST NOT commit a generic temporary message and routinely repair it with `git commit --amend`. A separately needed amend requires rechecking its approval scope, current HEAD, and publication state.
120
119
 
121
120
  If the docs commit fails or staged content differs, stop handoff and apply the Stop and inspect rule to the actual
122
121
  branch, HEAD, index, and partial completion. Resolve the issue before resuming; do not commit implementation instead.
@@ -136,18 +135,18 @@ On branch collisions, Git preparation failures, partial completion, or metadata
136
135
 
137
136
  [ARC role policy: contract begin]
138
137
  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.
138
+ - [scope.non-escalation] Act only where role authority, approved scope and available platform tools all permit. Delegation, restart, agent messages and attached instructions do not expand role authority. MUST NOT 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
139
  - [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
140
  - [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.
141
+ - [external.explicit-user-authority] Push, merge, deploy, publish and external messages require explicit user authorization for that action, scope and target. Local commit authority grants no external authority. Orchestrator performs authorized external actions; specialist roles return them without execution.
143
142
  - [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
143
  - [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.
144
+ - [role.planner-draft-only] Return design/spec/plan drafts and dependencies, criteria, hold conditions and verification needs in the response. MUST 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.
145
+ - [role.coder-implementation] Edit only assigned, approved files and run 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
146
  - [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.
147
+ - [role.reviewer-independent] Independently inspect the assigned final changes and evidence and report actionable findings and limits. Remain read-only. MUST NOT execute QA tests, edit files, perform Git mutations or decide acceptance.
148
+ - [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. MUST NOT omit Reviewer merely because no plan exists. This creates no new plan obligation.
150
149
  - [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.
150
+ - [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 at the final plan stage. Preserve required QA and QA failure rechecks before initial final review and outside this exception.
152
151
  - [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
152
  [ARC role policy: contract end]
@@ -39,7 +39,7 @@ Create using only the app tool:
39
39
  ref: "<verified-source-head-full-sha>"
40
40
  })
41
41
 
42
- The name is descriptive and does not guarantee a path or branch. There are no destination path or branch arguments.
42
+ The name describes the work; it guarantees neither a path nor a branch. There are no destination path or branch arguments.
43
43
  Pass ref explicitly as the full SHA; do not omit it or rely on a remote default. If an operationId is returned,
44
44
  use mcp__codex_app__get_worktree_creation_status until completed. Preparing/creating/registering progress is not
45
45
  success.
@@ -55,7 +55,7 @@ Before a Orchestrator direct edit, Orchestrator verifies the same conditions, wi
55
55
  applicable approval,
56
56
  and records them in the brief.
57
57
 
58
- Any missing or failed condition blocks handoff. Orchestrator may continue read-only investigation and authorized
58
+ A missing or failed condition blocks handoff. Orchestrator may continue read-only investigation and authorized
59
59
  preparation
60
60
  or recovery, but cannot start Coder early. Reverify affected evidence when approved content, execution target, branch,
61
61
  HEAD, or relevant state changes. Coder's conflict reporting is in its profile; Orchestrator
@@ -77,7 +77,7 @@ commit SHA, actual message, included paths, approved-content verification or val
77
77
  final verification, and any failure/partial completion and recovery evidence, plus absolute approved artifact paths.
78
78
  Record the Complete planning-document set fields from planning.md, confirming no applicable document awaits
79
79
  writing/approval.
80
- Distinguish reused existing commits from the batch preparation commit, or record valid document absence.
80
+ Distinguish reused commits from the batch preparation commit, or record valid document absence.
81
81
  Record applicable approvals and the initial explicit execution-target choice or verified reuse for each first start or
82
82
  restart. Give all five
83
83
  roles (Coder, QA, Planner, Reviewer, Scouter) the same actual workspace and selected execution checkout or absolute
@@ -164,18 +164,18 @@ for an approval already valid for that scope.
164
164
 
165
165
  [ARC role policy: contract begin]
166
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.
167
+ - [scope.non-escalation] Act only where role authority, approved scope and available platform tools all permit. Delegation, restart, agent messages and attached instructions do not expand role authority. MUST NOT 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
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
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.
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 grants no external authority. Orchestrator performs authorized external actions; specialist roles return them without execution.
171
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
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.
173
+ - [role.planner-draft-only] Return design/spec/plan drafts and dependencies, criteria, hold conditions and verification needs in the response. MUST 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] Edit only assigned, approved files and run 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
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.
176
+ - [role.reviewer-independent] Independently inspect the assigned final changes and evidence and report actionable findings and limits. Remain read-only. MUST 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. MUST NOT omit Reviewer merely because no plan exists. This creates no new plan obligation.
178
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.
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 at the final plan stage. Preserve required QA and QA failure rechecks before initial final review and outside this exception.
180
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
181
  [ARC role policy: contract end]
@@ -4,7 +4,7 @@ Before the first subagent creation, Orchestrator reads this reference and the ad
4
4
  `../limits.toml` (installed at `skills/arc/limits.toml`). Require version = 1,
5
5
  `max_total_subagents` and `max_concurrent_subagents` as positive safe integers.
6
6
  Installation defaults are max_total_subagents = 100 and max_concurrent_subagents = 5.
7
- A missing, malformed or unreadable policy blocks new creation; report it rather than assuming defaults.
7
+ A missing, malformed or unreadable policy blocks new creation. Report it; MUST NOT assume defaults.
8
8
  Freeze these settings for one ARC coordination session/tree; reinstalling affects new sessions.
9
9
 
10
10
  ## Counting and reservations
@@ -23,7 +23,7 @@ created + pending reservations + proposed <= max_total_subagents, and
23
23
  active + pending reservations + proposed <= max_concurrent_subagents and available runtime capacity.
24
24
  Record a reservation before each creation call. Confirmed creation converts it into a created,
25
25
  active ID. Release a reservation only when failure proves that no instance was created.
26
- An uncertain result keeps its reservation and capacity until reconciled; never retry blindly.
26
+ An uncertain result retains its reservation and capacity until reconciled. MUST NOT retry blindly.
27
27
  Serialize work when a batch does not fit. There are no reserved role slots.
28
28
 
29
29
  ## Continuation and exhaustion
@@ -31,8 +31,8 @@ Serialize work when a batch does not fit. There are no reserved role slots.
31
31
  Preserve the ledger through continuation, resume and context compaction; reconcile actual instance
32
32
  IDs before dispatch. Ledger loss must never reset counters to zero. If reconstruction is incomplete,
33
33
  hold creation and report the unknown budget; use a conservative bound only with sufficient evidence.
34
- Completion frees confirmed active capacity, never the total-created budget. Exhaustion holds new
35
- creation and requires reporting remaining work and budgets. It never authorizes skipping required
34
+ Completion frees confirmed active capacity; it does not restore the total-created budget. Exhaustion holds new
35
+ creation and requires reporting remaining work and budgets. It does not authorize skipping required
36
36
  QA or Reviewer, role freshness, approval, ownership, dependency or same-file edit gates.
37
37
 
38
38
  This cumulative guard and ARC scheduling are prompt-level policy, not hard runtime enforcement.
@@ -42,7 +42,7 @@ complete draft before saving, even when returned only in chat. Before formal dra
42
42
  and records the actual absolute workspace/repository, branch or detached HEAD, HEAD, changes and ownership,
43
43
  explicit choice and preparation evidence, and absolute document paths inside that target. Planner drafts for that
44
44
  verified workspace; Orchestrator saves directly in the selected target. Missing or mismatched evidence stops the
45
- affected drafting or save and is reported to Orchestrator. Planned scope and intended paths are not actual preparation.
45
+ affected drafting or save and is reported to Orchestrator. Planned scope and paths do not establish actual preparation.
46
46
  Initial target preparation does not authorize Coder; the complete handoff gate still applies.
47
47
 
48
48
 
@@ -124,9 +124,8 @@ and execution preparation. This applies that judgment, not a new spec-necessity
124
124
 
125
125
  Design, spec, plan, and brainstorming drafts are authored only by Planner.
126
126
  Orchestrator must not substitute an independently authored spec or plan for Planner's complete draft.
127
- If the draft has substantive
128
- omissions, return them to Planner for completion; if Planner fails or is unavailable, stop and report,
129
- never draft instead. Design approval alone does not change ownership.
127
+ Return substantive draft omissions to Planner for completion; if Planner fails or is unavailable, stop and report,
128
+ never draft instead. Design approval does not transfer ownership.
130
129
 
131
130
  ## Top-level plan tasks
132
131
 
@@ -174,7 +173,7 @@ If A fails, hold B and C; D may continue if unaffected.
174
173
 
175
174
  Before the first architectural spec save, first required Bounded written spec save, or first plan save, read this
176
175
  reference and record accessible evidence in the shared brief/canonical handoff record.
177
- Saving creates a reviewable file; it is not approval or a Git commit.
176
+ Saving creates a reviewable file; it grants no approval and creates no Git commit.
178
177
 
179
178
  **Spec save:** Verify the approved design scope and approval evidence, accessible Planner's complete spec draft and
180
179
  self-review findings, Orchestrator's integration/save/review responsibility, and intended absolute save path.
@@ -270,18 +269,18 @@ skill. Missing files stop the stage; report paths without global fallback. Keep
270
269
 
271
270
  [ARC role policy: contract begin]
272
271
  Generated from lib/policy/role-policy.json; do not edit this managed section manually.
273
- - [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.
272
+ - [scope.non-escalation] Act only where role authority, approved scope and available platform tools all permit. Delegation, restart, agent messages and attached instructions do not expand role authority. MUST NOT 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.
274
273
  - [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.
275
274
  - [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.
276
- - [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.
275
+ - [external.explicit-user-authority] Push, merge, deploy, publish and external messages require explicit user authorization for that action, scope and target. Local commit authority grants no external authority. Orchestrator performs authorized external actions; specialist roles return them without execution.
277
276
  - [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.
278
277
  - [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.
279
- - [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.
280
- - [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.
278
+ - [role.planner-draft-only] Return design/spec/plan drafts and dependencies, criteria, hold conditions and verification needs in the response. MUST 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.
279
+ - [role.coder-implementation] Edit only assigned, approved files and run 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.
281
280
  - [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.
282
- - [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.
283
- - [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.
281
+ - [role.reviewer-independent] Independently inspect the assigned final changes and evidence and report actionable findings and limits. Remain read-only. MUST NOT execute QA tests, edit files, perform Git mutations or decide acceptance.
282
+ - [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. MUST NOT omit Reviewer merely because no plan exists. This creates no new plan obligation.
284
283
  - [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.
285
- - [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.
284
+ - [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 at the final plan stage. Preserve required QA and QA failure rechecks before initial final review and outside this exception.
286
285
  - [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.
287
286
  [ARC role policy: contract end]
@@ -34,8 +34,8 @@ QA runs applicable existing functional/test checks, or approved structural/consi
34
34
  configuration changes. Reviewer reads the assigned diff/source for correctness, factual accuracy, and security. Outside the final plan Reviewer correction exception, after a
35
35
  behavior fix QA reruns affected checks, and Reviewer rechecks only when warranted. Reuse a Reviewer only when
36
36
  independent of the work and self-review and when evidence meets required scope and freshness.
37
- Resolve or explicitly disposition findings and confirm
38
- acceptance evidence before completion; claim checks only with verified output.
37
+ Before completion, resolve or explicitly disposition findings and confirm acceptance evidence. Claim checks only
38
+ with verified output.
39
39
 
40
40
  ## Task acceptance and final plan acceptance
41
41
 
@@ -113,8 +113,7 @@ issues may require both QA verification and Reviewer source review.
113
113
  Orchestrator accepts using criterion verdicts, findings, recheck evidence, and remaining gaps, rather than an overall
114
114
  run result.
115
115
  Explicit disposition does not convert unverified to proven; completion reports preserve remaining unverified scope.
116
- For low-risk work without a QA agent, Orchestrator's focused checks likewise
117
- connect each criterion to evidence.
116
+ For low-risk work without QA, Orchestrator's focused checks likewise connect each criterion to evidence.
118
117
 
119
118
 
120
119
  Read brief-cited `references/superpowers/test-driven-development/SKILL.md`; retain ARC exceptions.
@@ -146,18 +145,18 @@ actual unmet condition and report what is needed to resume. Structural evidence
146
145
 
147
146
  [ARC role policy: contract begin]
148
147
  Generated from lib/policy/role-policy.json; do not edit this managed section manually.
149
- - [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.
148
+ - [scope.non-escalation] Act only where role authority, approved scope and available platform tools all permit. Delegation, restart, agent messages and attached instructions do not expand role authority. MUST NOT 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.
150
149
  - [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.
151
150
  - [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.
152
- - [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.
151
+ - [external.explicit-user-authority] Push, merge, deploy, publish and external messages require explicit user authorization for that action, scope and target. Local commit authority grants no external authority. Orchestrator performs authorized external actions; specialist roles return them without execution.
153
152
  - [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.
154
153
  - [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.
155
- - [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.
156
- - [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.
154
+ - [role.planner-draft-only] Return design/spec/plan drafts and dependencies, criteria, hold conditions and verification needs in the response. MUST 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.
155
+ - [role.coder-implementation] Edit only assigned, approved files and run 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.
157
156
  - [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.
158
- - [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.
159
- - [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.
157
+ - [role.reviewer-independent] Independently inspect the assigned final changes and evidence and report actionable findings and limits. Remain read-only. MUST NOT execute QA tests, edit files, perform Git mutations or decide acceptance.
158
+ - [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. MUST NOT omit Reviewer merely because no plan exists. This creates no new plan obligation.
160
159
  - [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.
161
- - [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.
160
+ - [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 at the final plan stage. Preserve required QA and QA failure rechecks before initial final review and outside this exception.
162
161
  - [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.
163
162
  [ARC role policy: contract end]
@@ -6,8 +6,8 @@ Read before offering or operating a visual companion.
6
6
 
7
7
  Visual companion design discussion is distinct from QA UI acceptance checks under the approved test brief.
8
8
 
9
- Planner identifies a genuinely visual question, why a visual helps, options, the user decision, and a complete content
10
- draft; Planner does not write screens, start a server, operate a browser, or request approval.
9
+ Planner identifies a genuinely visual question, explains why a visual helps, and returns options, the user decision,
10
+ and a complete content draft; Planner does not write screens, start a server, operate a browser, or request approval.
11
11
  Orchestrator makes a just-in-time
12
12
  offer as its own message only when a question is clearer visually, then waits for acceptance. If declined, continue in
13
13
  text and do not offer again unless the user raises it. If accepted, decide per question whether to use the companion.
@@ -20,4 +20,4 @@ alone does not route every question through a browser.
20
20
 
21
21
  Upstream guide/scripts: `<installed ARC>/references/superpowers/brainstorming/visual-companion.md` and adjacent `scripts/`.
22
22
  ARC guide: `references/visual-companion.md`; Orchestrator briefs absolute paths and retains approval/server/browser
23
- ownership. Missing files stop dependent work without global fallback.
23
+ ownership. Missing files stop dependent work. MUST NOT use a global fallback.
@@ -0,0 +1,81 @@
1
+ import {evaluate} from '../evaluate.mjs';
2
+ import {evaluateCapability} from '../capabilities.mjs';
3
+ import {registerAgentObservation} from '../identity.mjs';
4
+ import {transactWorkflow, fingerprintRequest} from '../store.mjs';
5
+ import {runGate} from '../gate.mjs';
6
+ import {classifyGitCommand} from '../git-query.mjs';
7
+
8
+ const text=v=>typeof v==='string'&&v.length>0;
9
+ const object=v=>v!==null&&typeof v==='object'&&!Array.isArray(v);
10
+ const supported=new Set(['Read','Glob','Grep','Bash','Write','Edit','MultiEdit','Agent']);
11
+ const deny=reason=>({decision:'deny',reason,ruleIds:['runtime.claude'],proposedTransition:null});
12
+ /** Host-verified support for this installed version is required. A config value
13
+ * alone cannot establish hook failure blocking; provider wiring belongs to T6. */
14
+ export function claudeFailureBlockingReady(support){
15
+ return support?.status==='verified'&&support.onFailure==='block'&&text(support.platformVersion)&&text(support.verificationRef);
16
+ }
17
+ /** Context is a trusted host dependency, never deserialized from stdin/tool_input.
18
+ * describeTool must parse the complete tool invocation conservatively, and supply
19
+ * semantic operation, paths and descriptor. No native provider is assumed here. */
20
+ export function normalizeClaudeEvent(input,context={}){
21
+ if(!object(input)||input.hook_event_name!=='PreToolUse'||!text(input.session_id)||input.session_id!==context.sessionRef||!text(context.actorRef)||!text(context.taskId)||!text(context.requestId)||!text(input.tool_use_id)||input.tool_use_id!==context.toolUseId||!text(input.tool_name)||!object(input.tool_input)||!text(input.cwd))throw Error('Verified session identity and complete PreToolUse event required');
22
+ const toolPath=input.tool_name;
23
+ const coverage={...evaluateCapability({platform:'claude',toolPath,sessionRef:context.sessionRef}),enforcement:'hook-response-only',nativeVerified:false,startupTimeout:'unknown',existingSessionInput:'unsupported',specializedPaths:'unknown',hostedTools:'unsupported'};
24
+ if(!claudeFailureBlockingReady(context.failureBlocking))throw Error('Verified current-version onFailure block contract required');
25
+ if(!supported.has(input.tool_name))return {request:null,coverage};
26
+ if(typeof context.describeTool!=='function')throw Error('Trusted semantic tool provider unavailable');
27
+ const semantic=context.describeTool(structuredClone(input));
28
+ if(!object(semantic)||!text(semantic.operation)||!Array.isArray(semantic.paths)||!object(semantic.descriptor))throw Error('Complete semantic tool descriptor required');
29
+ if(input.tool_name==='Agent'&&semantic.operation!=='assign-agent')throw Error('Agent tool requires assignment validation');
30
+ return {request:{requestId:context.requestId,platform:'claude',actorRef:context.actorRef,taskId:context.taskId,cwd:input.cwd,toolName:input.tool_name,arguments:structuredClone(input.tool_input),operation:semantic.operation,paths:structuredClone(semantic.paths),descriptor:structuredClone(semantic.descriptor)},coverage};
31
+ }
32
+ /** Only documented PreToolUse fields are emitted. hold is a native deny. */
33
+ export function renderClaudeDecision(decision){
34
+ if(decision?.decision==='allow')return {};
35
+ const permissionDecision='deny';
36
+ return {hookSpecificOutput:{hookEventName:'PreToolUse',permissionDecision,permissionDecisionReason:typeof decision?.reason==='string'?decision.reason:'Runtime gate could not verify permission'}};
37
+ }
38
+ /** This returns a response, not proof the host applied it. Startup failures,
39
+ * timeout, hosted/specialized paths and existing write_stdin are outside it. */
40
+ export async function runClaudeGate(input,context={}){
41
+ if(input?.hook_event_name==='PostToolUse'){
42
+ // Result recording cannot authorize assignment/start or prevent a completed call.
43
+ try{if(input.session_id===context.sessionRef&&input.tool_use_id===context.toolUseId&&text(context.actorRef)&&typeof context.recordToolResult==='function')await context.recordToolResult(structuredClone(input));}catch{}
44
+ return {};
45
+ }
46
+ if(input?.hook_event_name==='SubagentStart'){
47
+ // SubagentStart cannot prevent startup. Only a trusted provider can correlate
48
+ // agent_id with a pending assignment; tool/event agent_type is not authority.
49
+ try{
50
+ if(input.session_id===context.sessionRef&&text(input.agent_id)&&typeof context.observeAgent==='function'){
51
+ const observation=await context.observeAgent(structuredClone(input));
52
+ if(observation?.actorRef===input.agent_id&&observation.platform==='claude'){
53
+ const decision=registerAgentObservation(context.state,observation);
54
+ if(decision.decision==='allow'&&decision.proposedTransition&&typeof context.persistObservation==='function')await context.persistObservation(decision,observation);
55
+ }
56
+ }
57
+ }catch{/* Observation failure never claims startup was blocked. */}
58
+ return {};
59
+ }
60
+ try{
61
+ const {request,coverage}=normalizeClaudeEvent(input,context);
62
+ if(!request)return renderClaudeDecision(deny('Tool path has no verified pre-action coverage'));
63
+ if(!text(context.statePath))return renderClaudeDecision(deny('Trusted durable workflow store unavailable'));
64
+ const result=await transactWorkflow({statePath:context.statePath,expectedRevision:context.state?.revision,requestId:request.requestId,request,requestFingerprint:fingerprintRequest(request),decide:async state=>{
65
+ const decision=evaluate(context.policy,state,request,context.evidence);
66
+ if(decision.decision!=='allow')return {...decision,coverage};
67
+ const actor=state.identities.find(identity=>identity.actorRef===request.actorRef);
68
+ if(request.toolName==='Bash'&&actor?.role!=='orchestrator'){
69
+ const query=classifyGitCommand(request.arguments.command,context.policy.git);
70
+ if(!query.allowed)return {...deny('Specialist Git guard: '+query.reason),coverage};
71
+ }
72
+ if(request.operation==='commit'){
73
+ const git=await runGate({phase:'preflight',state,request,gitEvidence:context.gitEvidence});
74
+ if(git.decision!=='allow')return {...git,coverage};
75
+ return {...decision,expectedCommit:git.expectedCommit,coverage};
76
+ }
77
+ return {...decision,coverage};
78
+ }});
79
+ return renderClaudeDecision(result.decision);
80
+ }catch(error){return renderClaudeDecision(deny('Runtime validation unavailable: '+error.message));}
81
+ }
@@ -0,0 +1,63 @@
1
+ import {evaluate} from '../evaluate.mjs';
2
+ import {evaluateCapability} from '../capabilities.mjs';
3
+ import {registerAgentObservation} from '../identity.mjs';
4
+ import {transactWorkflow, fingerprintRequest} from '../store.mjs';
5
+ import {runGate} from '../gate.mjs';
6
+
7
+ const text=v=>typeof v==='string'&&v.length>0;
8
+ const object=v=>v!==null&&typeof v==='object'&&!Array.isArray(v);
9
+ const supported=new Set(['Read','Glob','Grep','Bash','Write','Edit','MultiEdit','exec_command','apply_patch','Agent','spawn_agent']);
10
+ const deny=reason=>({decision:'deny',reason,ruleIds:['runtime.codex'],proposedTransition:null});
11
+ /** Context is a trusted host dependency, never deserialized from stdin/tool_input.
12
+ * describeTool must parse the complete tool invocation conservatively, and supply
13
+ * semantic operation, paths and descriptor. No native provider is assumed here. */
14
+ export function normalizeCodexEvent(input,context={}){
15
+ if(!object(input)||input.hook_event_name!=='PreToolUse'||!text(input.session_id)||input.session_id!==context.sessionRef||!text(context.actorRef)||!text(context.taskId)||!text(context.requestId)||!text(input.tool_use_id)||input.tool_use_id!==context.toolUseId||!text(input.tool_name)||!object(input.tool_input)||!text(input.cwd))throw Error('Verified session identity and complete PreToolUse event required');
16
+ const toolPath=['Agent','spawn_agent'].includes(input.tool_name)?'spawn_agent':input.tool_name;
17
+ const coverage={...evaluateCapability({platform:'codex',toolPath,sessionRef:context.sessionRef}),enforcement:'hook-response-only',nativeVerified:false,startupTimeout:'unknown',existingSessionInput:'unsupported',specializedPaths:'unknown',hostedTools:'unsupported'};
18
+ if(!supported.has(input.tool_name))return {request:null,coverage};
19
+ if(typeof context.describeTool!=='function')throw Error('Trusted semantic tool provider unavailable');
20
+ const semantic=context.describeTool(structuredClone(input));
21
+ if(!object(semantic)||!text(semantic.operation)||!Array.isArray(semantic.paths)||!object(semantic.descriptor))throw Error('Complete semantic tool descriptor required');
22
+ if(['Agent','spawn_agent'].includes(input.tool_name)&&semantic.operation!=='assign-agent')throw Error('Agent tool requires assignment validation');
23
+ return {request:{requestId:context.requestId,platform:'codex',actorRef:context.actorRef,taskId:context.taskId,cwd:input.cwd,toolName:input.tool_name,arguments:structuredClone(input.tool_input),operation:semantic.operation,paths:structuredClone(semantic.paths),descriptor:structuredClone(semantic.descriptor)},coverage};
24
+ }
25
+ /** Only documented PreToolUse fields are emitted. hold is a native deny. */
26
+ export function renderCodexDecision(decision){
27
+ const permissionDecision=decision?.decision==='allow'?'allow':'deny';
28
+ return {hookSpecificOutput:{hookEventName:'PreToolUse',permissionDecision,permissionDecisionReason:typeof decision?.reason==='string'?decision.reason:'Runtime gate could not verify permission'}};
29
+ }
30
+ /** This returns a response, not proof the host applied it. Startup failures,
31
+ * timeout, hosted/specialized paths and existing write_stdin are outside it. */
32
+ export async function runCodexGate(input,context={}){
33
+ if(input?.hook_event_name==='SubagentStart'){
34
+ // SubagentStart cannot prevent startup. Only a trusted provider can correlate
35
+ // agent_id with a pending assignment; tool/event agent_type is not authority.
36
+ try{
37
+ if(input.session_id===context.sessionRef&&text(input.agent_id)&&typeof context.observeAgent==='function'){
38
+ const observation=await context.observeAgent(structuredClone(input));
39
+ if(observation?.actorRef===input.agent_id&&observation.platform==='codex'){
40
+ const decision=registerAgentObservation(context.state,observation);
41
+ if(decision.decision==='allow'&&decision.proposedTransition&&typeof context.persistObservation==='function')await context.persistObservation(decision,observation);
42
+ }
43
+ }
44
+ }catch{/* Observation failure never claims startup was blocked. */}
45
+ return {};
46
+ }
47
+ try{
48
+ const {request,coverage}=normalizeCodexEvent(input,context);
49
+ if(!request)return renderCodexDecision(deny('Tool path has no verified pre-action coverage'));
50
+ if(!text(context.statePath))return renderCodexDecision(deny('Trusted durable workflow store unavailable'));
51
+ const result=await transactWorkflow({statePath:context.statePath,expectedRevision:context.state?.revision,requestId:request.requestId,request,requestFingerprint:fingerprintRequest(request),decide:async state=>{
52
+ const decision=evaluate(context.policy,state,request,context.evidence);
53
+ if(decision.decision!=='allow')return {...decision,coverage};
54
+ if(request.operation==='commit'){
55
+ const git=await runGate({phase:'preflight',state,request,gitEvidence:context.gitEvidence});
56
+ if(git.decision!=='allow')return {...git,coverage};
57
+ return {...decision,expectedCommit:git.expectedCommit,coverage};
58
+ }
59
+ return {...decision,coverage};
60
+ }});
61
+ return renderCodexDecision(result.decision);
62
+ }catch(error){return renderCodexDecision(deny('Runtime validation unavailable: '+error.message));}
63
+ }
@@ -0,0 +1,32 @@
1
+ // Declarations describe documented hooks, never proof that this installation ran them.
2
+ const contracts = {
3
+ codex: {spawn_agent:'Agent', followup_task:null, SubagentStart:null},
4
+ claude: {Agent:'Agent', SubagentStart:null},
5
+ };
6
+ function operationOf(receipt, platform) {
7
+ const matcher = contracts[platform]?.[receipt.operation];
8
+ return matcher && receipt.toolPath === matcher ? receipt.operation : null;
9
+ }
10
+ export function summarizeProbe(receipts, {platform, sessionRef, platformVersion, attemptRef} = {}) {
11
+ const candidates = Array.isArray(receipts) ? receipts.filter(r => r && r.source === 'native' &&
12
+ r.platform === platform && operationOf(r,platform) &&
13
+ typeof sessionRef === 'string' && sessionRef.length > 0 && r.sessionRef === sessionRef &&
14
+ typeof platformVersion === 'string' && platformVersion.length > 0 && r.platformVersion === platformVersion &&
15
+ typeof attemptRef === 'string' && attemptRef.length > 0 && r.attemptRef === attemptRef &&
16
+ r.event === 'PreToolUse' && ['host-result','hook-decision'].includes(r.kind) &&
17
+ r.decision === 'deny' && (r.kind !== 'host-result' || (r.toolExecuted === false && r.success === true))) : [];
18
+ // JSON is unauthenticated. No native host verifier is available here, so even
19
+ // a structurally valid current receipt is only an unverified observation.
20
+ return {platform,sessionRef,platformVersion,attemptRef,verifiedDeny:false,status:'unknown',source:'unverified',
21
+ toolPaths:[...new Set(candidates.map(r=>operationOf(r,platform)))]};
22
+ }
23
+ export function evaluateCapability({platform,toolPath,sessionRef,platformVersion,attemptRef,receipts=[]} = {}) {
24
+ const known=Object.hasOwn(contracts[platform] ?? {},toolPath);
25
+ const observationOnly=known && toolPath === 'SubagentStart';
26
+ const observed=summarizeProbe(receipts,{platform,sessionRef,platformVersion,attemptRef});
27
+ return {platform,toolPath,sessionRef,platformVersion,attemptRef,observationOnly,
28
+ declared:{source:'documentation',matcher:contracts[platform]?.[toolPath] ?? null},
29
+ status:!known || observationOnly ? 'unsupported':'unknown',verifiedDeny:false,
30
+ source:!known || observationOnly ? 'documentation':'unverified',
31
+ observedPaths:observed.toolPaths.filter(p=>p === toolPath)};
32
+ }