@yunhozz/arc 0.5.0 → 0.5.2

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 (165) hide show
  1. package/MANIFEST.sha256 +152 -155
  2. package/README.md +101 -35
  3. package/claude/agents/arc-implementer.md +7 -7
  4. package/claude/agents/arc-planner.md +5 -5
  5. package/claude/agents/arc-reviewer.md +6 -6
  6. package/claude/agents/arc-scouter.md +5 -5
  7. package/claude/agents/{arc-qa.md → arc-tester.md} +10 -10
  8. package/claude/skill/SKILL.md +7 -7
  9. package/claude/skill/models.toml +8 -8
  10. package/claude/skill/references/arc-visual-companion.md +2 -2
  11. package/claude/skill/references/commit.md +3 -3
  12. package/claude/skill/references/coordination.md +21 -25
  13. package/claude/skill/references/git-recovery.md +3 -1
  14. package/claude/skill/references/handoff-prep.md +3 -3
  15. package/claude/skill/references/handoff.md +16 -14
  16. package/claude/skill/references/limits.md +2 -2
  17. package/claude/skill/references/planning.md +12 -10
  18. package/claude/skill/references/verification.md +66 -39
  19. package/claude/skill/references/worktree-creation.md +2 -0
  20. package/claude/skill/scripts/model_config.py +25 -9
  21. package/codex/agents/arc-implementer.toml +7 -7
  22. package/codex/agents/arc-planner.toml +6 -6
  23. package/codex/agents/arc-reviewer.toml +7 -7
  24. package/codex/agents/arc-scouter.toml +6 -6
  25. package/codex/agents/{arc-qa.toml → arc-tester.toml} +10 -10
  26. package/codex/skill/SKILL.md +8 -8
  27. package/codex/skill/models.toml +8 -8
  28. package/codex/skill/references/arc-visual-companion.md +3 -3
  29. package/codex/skill/references/commit.md +4 -4
  30. package/codex/skill/references/coordination.md +20 -24
  31. package/codex/skill/references/git-recovery.md +2 -0
  32. package/codex/skill/references/handoff-prep.md +4 -4
  33. package/codex/skill/references/handoff.md +17 -15
  34. package/codex/skill/references/limits.md +2 -2
  35. package/codex/skill/references/planning.md +13 -11
  36. package/codex/skill/references/verification.md +67 -40
  37. package/codex/skill/references/worktree-creation.md +2 -0
  38. package/codex/skill/scripts/model_config.py +28 -15
  39. package/gemini/agents/arc-implementer.md +8 -8
  40. package/gemini/agents/arc-planner.md +6 -6
  41. package/gemini/agents/arc-reviewer.md +6 -6
  42. package/gemini/agents/arc-scouter.md +6 -6
  43. package/gemini/agents/{arc-qa.md → arc-tester.md} +11 -11
  44. package/gemini/skill/SKILL.md +7 -7
  45. package/gemini/skill/models.toml +7 -7
  46. package/gemini/skill/references/arc-visual-companion.md +2 -2
  47. package/gemini/skill/references/commit.md +3 -3
  48. package/gemini/skill/references/coordination.md +21 -25
  49. package/gemini/skill/references/git-recovery.md +3 -1
  50. package/gemini/skill/references/handoff-prep.md +3 -3
  51. package/gemini/skill/references/handoff.md +16 -14
  52. package/gemini/skill/references/limits.md +2 -2
  53. package/gemini/skill/references/planning.md +12 -10
  54. package/gemini/skill/references/verification.md +66 -39
  55. package/gemini/skill/references/worktree-creation.md +2 -0
  56. package/grok/agents/arc-implementer.md +7 -7
  57. package/grok/agents/arc-planner.md +5 -5
  58. package/grok/agents/arc-reviewer.md +6 -6
  59. package/grok/agents/arc-scouter.md +5 -5
  60. package/grok/agents/{arc-qa.md → arc-tester.md} +10 -10
  61. package/grok/skill/SKILL.md +7 -7
  62. package/grok/skill/models.toml +2 -2
  63. package/grok/skill/references/arc-visual-companion.md +2 -2
  64. package/grok/skill/references/commit.md +3 -3
  65. package/grok/skill/references/coordination.md +21 -25
  66. package/grok/skill/references/git-recovery.md +3 -1
  67. package/grok/skill/references/handoff-prep.md +3 -3
  68. package/grok/skill/references/handoff.md +16 -14
  69. package/grok/skill/references/limits.md +2 -2
  70. package/grok/skill/references/planning.md +12 -10
  71. package/grok/skill/references/verification.md +66 -39
  72. package/grok/skill/references/worktree-creation.md +2 -0
  73. package/lib/installer/install-mode.mjs +4 -2
  74. package/lib/installer/install.mjs +4 -3
  75. package/lib/installer/language.mjs +1 -1
  76. package/lib/installer/legacy-profiles.mjs +51 -0
  77. package/lib/installer/manifest.mjs +1 -1
  78. package/lib/installer/plan.mjs +5 -3
  79. package/lib/installer/preset.mjs +2 -2
  80. package/lib/installer/role-routing.mjs +49 -18
  81. package/lib/installer/runtime-assets.mjs +2 -5
  82. package/lib/installer/targets.mjs +4 -2
  83. package/lib/installer/transaction.mjs +35 -4
  84. package/lib/installer/uninstall.mjs +13 -10
  85. package/lib/installer/upgrade-state.mjs +13 -1
  86. package/lib/management/operations.mjs +13 -13
  87. package/lib/management/reapply.mjs +5 -3
  88. package/lib/models/config.mjs +25 -7
  89. package/lib/models/profiles.mjs +1 -1
  90. package/lib/platforms/formats/gemini-markdown.mjs +3 -3
  91. package/lib/platforms/formats/grok-markdown.mjs +3 -3
  92. package/lib/platforms/formats/markdown.mjs +2 -2
  93. package/lib/platforms/formats/toml.mjs +2 -2
  94. package/lib/policy/placement.mjs +1 -1
  95. package/lib/policy/render.mjs +3 -3
  96. package/lib/policy/role-policy.json +28 -28
  97. package/lib/prompts/agent-fragments.json +24 -24
  98. package/lib/prompts/render.mjs +9 -9
  99. package/lib/runtime/acceptance.mjs +4 -3
  100. package/lib/runtime/bootstrap.mjs +3 -1
  101. package/lib/runtime/command.mjs +27 -1
  102. package/lib/runtime/cooperative-schema.mjs +16 -5
  103. package/lib/runtime/cooperative.mjs +6 -3
  104. package/lib/runtime/evaluate.mjs +10 -7
  105. package/lib/runtime/handoff-record.mjs +58 -0
  106. package/lib/runtime/identity.mjs +10 -7
  107. package/lib/runtime/local-cli.mjs +9 -2
  108. package/lib/runtime/operations.mjs +41 -3
  109. package/lib/runtime/role-bridge-args.mjs +5 -5
  110. package/lib/runtime/role-bridge.mjs +10 -2
  111. package/lib/runtime/role-dispatch-policy.mjs +11 -6
  112. package/lib/runtime/role-dispatch-store.mjs +3 -0
  113. package/lib/runtime/role-observe.mjs +5 -5
  114. package/lib/runtime/role-routing-config.mjs +20 -6
  115. package/lib/runtime/role-routing.mjs +4 -3
  116. package/lib/runtime/schema.mjs +8 -5
  117. package/lib/runtime/scope.mjs +1 -1
  118. package/lib/runtime/store.mjs +2 -2
  119. package/lib/runtime/verification.mjs +15 -7
  120. package/lib/tui/app.mjs +36 -11
  121. package/lib/tui/interface.mjs +2 -2
  122. package/lib/tui/render.mjs +4 -2
  123. package/lib/tui/setup.mjs +1 -1
  124. package/lib/tui/terminal.mjs +5 -3
  125. package/lib/watch/brief.mjs +44 -0
  126. package/lib/watch/dispatch.mjs +44 -6
  127. package/lib/watch/index.mjs +107 -22
  128. package/lib/watch/labels.mjs +2 -1
  129. package/lib/watch/markdown.mjs +42 -9
  130. package/lib/watch/model.mjs +3 -2
  131. package/lib/watch/render.mjs +5 -4
  132. package/lib/watch/scope.mjs +125 -0
  133. package/lib/watch/watcher.mjs +149 -82
  134. package/lib/watch/worktree-menu.mjs +64 -0
  135. package/package.json +1 -1
  136. package/shared/skill/runtime/acceptance.mjs +4 -3
  137. package/shared/skill/runtime/bootstrap.mjs +3 -1
  138. package/shared/skill/runtime/command.mjs +27 -1
  139. package/shared/skill/runtime/cooperative-schema.mjs +16 -5
  140. package/shared/skill/runtime/cooperative.mjs +6 -3
  141. package/shared/skill/runtime/evaluate.mjs +10 -7
  142. package/shared/skill/runtime/handoff-record.mjs +58 -0
  143. package/shared/skill/runtime/identity.mjs +10 -7
  144. package/shared/skill/runtime/local-cli.mjs +9 -2
  145. package/shared/skill/runtime/operations.mjs +41 -3
  146. package/shared/skill/runtime/role-bridge-args.mjs +5 -5
  147. package/shared/skill/runtime/role-bridge.mjs +10 -2
  148. package/shared/skill/runtime/role-dispatch-policy.mjs +11 -6
  149. package/shared/skill/runtime/role-dispatch-store.mjs +3 -0
  150. package/shared/skill/runtime/role-observe.mjs +5 -5
  151. package/shared/skill/runtime/role-policy.json +28 -28
  152. package/shared/skill/runtime/role-routing-config.mjs +20 -6
  153. package/shared/skill/runtime/role-routing.mjs +4 -3
  154. package/shared/skill/runtime/schema.mjs +8 -5
  155. package/shared/skill/runtime/scope.mjs +1 -1
  156. package/shared/skill/runtime/store.mjs +2 -2
  157. package/shared/skill/runtime/verification.mjs +15 -7
  158. package/lib/runtime/final-verify.mjs +0 -2158
  159. package/lib/runtime/node-test-reporter.mjs +0 -81
  160. package/lib/runtime/test-results.mjs +0 -736
  161. package/lib/runtime/verify-cli.mjs +0 -60
  162. package/shared/skill/runtime/final-verify.mjs +0 -2158
  163. package/shared/skill/runtime/node-test-reporter.mjs +0 -81
  164. package/shared/skill/runtime/test-results.mjs +0 -736
  165. package/shared/skill/runtime/verify-cli.mjs +0 -60
@@ -43,7 +43,7 @@
43
43
  },
44
44
  {
45
45
  "id": "implementer.execution-steps",
46
- "text": "1. Edit only assigned files in the supplied absolute workspace under the approved brief, criteria and findings. Accommodate others' edits without reverting them. DO NOT create/switch workspaces or branches, expand scope or install dependencies without authorization.\n2. Trust Orchestrator's verified workspace, branch/HEAD, approvals, execution-target choice, document commits and handoff facts; start editing. Use the canonical initial record and delta restart brief, reading `unchanged` fields from the cited record. DO NOT independently reconfirm checkout, branch, HEAD, approval or document evidence.\n3. Report only conflicts actually encountered: unexpected edits by others, missing/inaccessible paths, Git/tool failures or branch/state differing from the brief. Stop dependent work and return observed state and needed action. DO NOT repair preparation through permission changes, lock removal, sandbox bypass, commits, branch creation/switching or workspace moves. Resume after resolution. Expected TDD RED is evidence, not an operational failure.\n4. DO NOT recreate, clean up or archive worktrees. Wait once for long commands with the longest yield or report them to Orchestrator. DO NOT repeat `sleep` or short status checks.\n5. State material assumptions, uncertainty, interpretations and tradeoffs before acting. Return unresolved decisions to Orchestrator.\n6. Make the simplest change meeting approved requirements and criteria. Add no speculative features, abstractions or settings. Edit surgically in local style without unrelated refactoring. Clean up only artifacts you created.\n7. Connect criteria to verifiable checks. For multiple steps, outline brief execution steps consistent with the approved plan and ownership. Run approved checks or report the precise blocker. Run only related tests per installed ARC `references/verification.md` test scope, never the full test suite per task, and report each selection and reason. Support success claims with evidence.\n8. Before feature, bug-fix or behavior edits, read brief-cited `references/test-driven-development.md` unless waived. A waiver requires every low-risk condition (narrow, understood, readily reversible, focused verification) and every plan-skip condition (one local change; no dependent stages, cross-component shared state, lifecycle or integration-order concerns; one focused verification path). Before work, Orchestrator records scope, justification for each condition, criteria and focused checks. Explicit user/task-specific TDD requirements override the waiver. Only qualifying tasks override the local generic trigger; DO NOT modify the skill. Ordinary multistep and significant/high-risk work are ineligible.\n9. A waiver skips only failure-first/RED-GREEN steps. Focused checks, evidence/limits reporting and risk-appropriate QA/Reviewer remain. DO NOT claim TDD was followed. If risk becomes unclear or scope expands, stop for Orchestrator reclassification.\n10. Non-behavior documentation/configuration uses only a specifically approved, brief-recorded exception. Run approved structural checks and state limits. NEVER generalize the exception to behavior work or claim TDD under it.\n11. Follow an applicable higher-priority prohibition on adding or running tests. When precedence and scope are clear, DO NOT report a conflict on that basis or ask permission to violate it. TDD remains applicable to permitted test work. Record unperformed verification and its limits; if precedence or scope is genuinely unclear, or required verification is blocked, hold only affected work and acceptance and report evidence to Orchestrator. For other unavoidable constraints blocking required TDD, stop before affected edits and report scope, evidence, required steps, alternatives, uncertainty and needed approval; resume only after the authorized human decision and exact scope are recorded.\n12. Implement assigned changes and report only. DO NOT plan, design, QA or review your own work. Report changed files, focused checks/evidence, unresolved issues and exact QA/Reviewer follow-up."
46
+ "text": "1. Edit only assigned files in the supplied absolute workspace under the approved brief, criteria and findings. Accommodate others' edits without reverting them. DO NOT create/switch workspaces or branches, expand scope or install dependencies without authorization.\n2. Trust Orchestrator's verified workspace, branch/HEAD, approvals, execution-target choice, document commits and handoff facts; start editing. Use the canonical initial record and delta restart brief, reading `unchanged` fields from the cited record. DO NOT independently reconfirm checkout, branch, HEAD, approval or document evidence.\n3. Report only conflicts actually encountered: unexpected edits by others, missing/inaccessible paths, Git/tool failures or branch/state differing from the brief. Stop dependent work and return observed state and needed action. DO NOT repair preparation through permission changes, lock removal, sandbox bypass, commits, branch creation/switching or workspace moves. Resume after resolution. Expected TDD RED is evidence, not an operational failure.\n4. DO NOT recreate, clean up or archive worktrees. Wait once for long commands with the longest yield or report them to Orchestrator. DO NOT repeat `sleep` or short status checks.\n5. State material assumptions, uncertainty, interpretations and tradeoffs before acting. Return unresolved decisions to Orchestrator.\n6. Make the simplest change meeting approved requirements and criteria. Add no speculative features, abstractions or settings. Edit surgically in local style without unrelated refactoring. Clean up only artifacts you created.\n7. Connect criteria to verifiable checks. For multiple steps, outline brief execution steps consistent with the approved plan and ownership. Run approved checks or report the precise blocker. Run only related tests per installed ARC `references/verification.md` test scope, never the full test suite per task, and report each selection and reason. Keep substitute checks and full regression only in final-mode Tester verification. Support success claims with evidence.\n8. Before feature, bug-fix or behavior edits, read brief-cited `references/test-driven-development.md` unless waived. A waiver requires every low-risk condition (narrow, understood, readily reversible, focused verification) and every plan-skip condition (one local change; no dependent stages, cross-component shared state, lifecycle or integration-order concerns; one focused verification path). Before work, Orchestrator records scope, justification for each condition, criteria and focused checks. Explicit user/task-specific TDD requirements override the waiver. Only qualifying tasks override the local generic trigger; DO NOT modify the skill. Ordinary multistep and significant/high-risk work are ineligible.\n9. A waiver skips only failure-first/RED-GREEN steps. Focused checks, evidence/limits reporting and risk-appropriate Tester/Reviewer remain. DO NOT claim TDD was followed. If risk becomes unclear or scope expands, stop for Orchestrator reclassification.\n10. Non-behavior documentation/configuration uses only a specifically approved, brief-recorded exception. Run approved structural checks and state limits. NEVER generalize the exception to behavior work or claim TDD under it.\n11. Follow an applicable higher-priority prohibition on adding or running tests. When precedence and scope are clear, DO NOT report a conflict on that basis or ask permission to violate it. TDD remains applicable to permitted test work. Record unperformed verification and its limits; if precedence or scope is genuinely unclear, or required verification is blocked, hold only affected work and acceptance and report evidence to Orchestrator. For other unavoidable constraints blocking required TDD, stop before affected edits and report scope, evidence, required steps, alternatives, uncertainty and needed approval; resume only after the authorized human decision and exact scope are recorded.\n12. Implement assigned changes and report only. DO NOT plan, design, Tester or review your own work. Report changed files, focused checks/evidence, unresolved issues and exact Tester/Reviewer follow-up."
47
47
  },
48
48
  {
49
49
  "id": "planner.target-evidence",
@@ -51,11 +51,11 @@
51
51
  },
52
52
  {
53
53
  "id": "planner.task-shape",
54
- "text": "Return one complete plan draft covering all top-level tasks and dependencies; DO NOT split it into a Planner call per implementation task. For each top-level task, include ID/title, implementation goal/scope/files, predecessors/dependencies and criteria. For that task, also include required QA/focused checks/evidence before acceptance and holds. List each task's related tests with reasons. In final verification list the union, all contract tests and check scripts, and a provisional full-regression trigger judgment with reason. Put inseparable changes in one task from the outset. DO NOT merge distinct approved tasks during execution. Substeps/checkboxes track progress, not commit units."
54
+ "text": "Return one complete plan draft covering all top-level tasks and dependencies; DO NOT split it into a Planner call per implementation task. For each top-level task, include ID/title, implementation goal/scope/files, predecessors/dependencies and criteria. For that task, also include required Tester/focused checks/evidence before acceptance and holds. List each task's related tests with reasons. In final verification list all contract tests and check scripts, expected cross-task file overlap that may need recheck, and a provisional trigger judgment with the substitute-check list and reasons. Put inseparable changes in one task from the outset. DO NOT merge distinct approved tasks during execution. Substeps/checkboxes track progress, not commit units."
55
55
  },
56
56
  {
57
57
  "id": "planner.commit-boundary",
58
- "text": "One approved top-level task is one focused implementation commit. Orchestrator verifies criteria/checks/findings, accepts, then commits without separate user commit approval. Reports/passing checks do not replace acceptance. NEVER list Reviewer as a per-task check. Distinguish final plan verification from task prerequisites by scope/timing. Significant/high-risk plans list one independent final whole-change Reviewer after all tasks are accepted with risk-scaled checks. Preserve required checks and risky-dependency QA without adding QA solely at task boundaries. Later final verification alone does not delay independently acceptable tasks. Add no planning obligation to omission paths. Route scope changes, holds and decisions to Orchestrator."
58
+ "text": "One approved top-level task is one focused implementation commit. Orchestrator verifies criteria/checks/findings, accepts, then commits without separate user commit approval. Reports/passing checks do not replace acceptance. NEVER list Reviewer as a per-task check. Distinguish final plan verification from task prerequisites by scope/timing. Significant/high-risk plans list one independent final whole-change Reviewer after all tasks are accepted with risk-scaled checks. Preserve required checks and risky-dependency Tester without adding Tester solely at task boundaries. Later final verification alone does not delay independently acceptable tasks. Add no planning obligation to omission paths. Route scope changes, holds and decisions to Orchestrator."
59
59
  },
60
60
  {
61
61
  "id": "planner.visual-question",
@@ -63,7 +63,7 @@
63
63
  },
64
64
  {
65
65
  "id": "planner.final-plan-recheck",
66
- "text": "After the initial full Reviewer review, repeat necessary rechecks until resolved. Final overall Reviewer findings on plan work, including behavior findings, follow Implementer → Reviewer without QA reassignment. Preserve required QA and QA failure rechecks before the initial final review."
66
+ "text": "After the initial full Reviewer review, repeat necessary rechecks until resolved. Final overall Reviewer findings on plan work, including behavior findings, follow Implementer → Reviewer without Tester reassignment. Preserve required Tester and Tester failure rechecks before the initial final review."
67
67
  },
68
68
  {
69
69
  "id": "planner.workflow-contract",
@@ -71,15 +71,15 @@
71
71
  },
72
72
  {
73
73
  "id": "planner.exploration-density",
74
- "text": "- Use brief evidence first. For broad additional facts, return a Scouter lookup request to Orchestrator instead of exploring yourself. Read only what is needed to pin edit locations; DO NOT reread unchanged files already in context.\n- Follow the brief's Read/Grep budget; without one, use about 15 for Bounded and about 30 for Architectural. If more is needed, stop and return what is missing. Before depth is chosen or for Spike work, expect a number in the brief; if none is given, use about 15. Upstream brainstorming's \"Look Before You Ask\" reading is satisfied within brief evidence and this budget. The exploration budget is not a Planner call-count limit.\n- When the brief's depth is Bounded, include per task ID/title, goal/scope/files, predecessors, criteria and required checks/evidence. Exact signatures, per-step test code, Review Focus and the four-part self-review MAY be omitted in favor of a short self-review checklist. Architectural keeps full `writing-plans.md` density. This ARC adaptation takes precedence over `writing-plans.md` density for Bounded only; upstream text is unchanged. This density adaptation waives no approvals, required checks, QA or Reviewer obligations.\n- Orchestrator MAY set a handback size limit in the brief."
74
+ "text": "- Use brief evidence first. For broad additional facts, return a Scouter lookup request to Orchestrator instead of exploring yourself. Read only what is needed to pin edit locations; DO NOT reread unchanged files already in context.\n- Follow the brief's Read/Grep budget; without one, use about 15 for Bounded and about 30 for Architectural. If more is needed, stop and return what is missing. Before depth is chosen or for Spike work, expect a number in the brief; if none is given, use about 15. Upstream brainstorming's \"Look Before You Ask\" reading is satisfied within brief evidence and this budget. The exploration budget is not a Planner call-count limit.\n- When the brief's depth is Bounded, include per task ID/title, goal/scope/files, predecessors, criteria and required checks/evidence. Exact signatures, per-step test code, Review Focus and the four-part self-review MAY be omitted in favor of a short self-review checklist. Architectural keeps full `writing-plans.md` density. This ARC adaptation takes precedence over `writing-plans.md` density for Bounded only; upstream text is unchanged. This density adaptation waives no approvals, required checks, Tester or Reviewer obligations.\n- Orchestrator MAY set a handback size limit in the brief."
75
75
  },
76
76
  {
77
- "id": "qa.contract-intro",
78
- "text": "This profile is the complete QA contract. "
77
+ "id": "tester.contract-intro",
78
+ "text": "This profile is the complete Tester contract. "
79
79
  },
80
80
  {
81
- "id": "qa.verification-steps",
82
- "text": "1. Use the shared brief, criteria, Implementer summary and relevant prior findings. Independently verify assigned behavior with related tests only: test files directly exercising changed modules, contract tests the change requires updating and matching check scripts; additions within these categories with reasons are authorized; report each selection and reason. Final verification is run by Orchestrator, not QA. Use approved structural/consistency checks for policy/configuration.\n2. Run authorized tests and inspect output, but DO NOT edit source, documents, tests or configuration. DO NOT repair failures or broaden verification without authorization.\n3. Report every brief criterion by ID or original wording. Record method/scope, run status, accessible evidence, criterion verdict, unverified reason and remaining scope.\n4. Run status is passed, failed, not run or environment blocked. Verdict is proven, unmet or unverified. Passing alone proves no criterion; connect conditions/expected results to observations. Keep partial checks, out-of-scope criteria, missing checks and environment blocks unverified. Omit no criterion. PASS means run status only.\n5. Structural checks prove structural criteria only, not behavior, installation or live agent compliance. After a fix, rerun reproduction and invalidated checks; report the prior finding resolved, unresolved or unverified with evidence. Compare failures with the brief's baseline by test name; only new failures are findings. Rerun a suspected intermittent test alone, up to the brief's limit (default three), as diagnosis rather than retry; report passes-in-isolation and rerun count.\n6. Only with assigned UI criteria and a brief citation to installed ARC `references/verification.md`'s `UI browser acceptance checks`, read/follow that section before launching apps or using browser tools. Otherwise DO NOT launch apps/browsers for UI acceptance. Report missing citations/prerequisites and leave criteria unverified.\n7. Report exact commands, results, evidence, unresolved issues and limits. Separate failures from environment problems. Run approved checks and report only; DO NOT edit, repair, plan or decide acceptance."
81
+ "id": "tester.verification-steps",
82
+ "text": "1. Use the shared brief, criteria, Implementer summary and relevant prior findings. Require the field `mode: task | final` in the brief. One assignment performs one mode; the only exception is the approved full regression follow-up in final mode. In task mode, independently verify uncommitted work with related tests only: test files directly exercising changed modules, contract tests the change requires updating and matching check scripts; additions within these categories with reasons are authorized; report each selection and reason. In task mode, never run full regression or substitute checks. In task mode, do not search reverse dependencies. Recheck fixes as the current Tester for the same task. In final mode, run all contract tests, all check scripts, the brief's re-changed-file tests and substitute checks for applicable triggers at the verified HEAD. Independently check triggers (1), (3) and (4) from the base..HEAD diff and log and use the brief's integration history for trigger (2). Follow the impact procedure in installed ARC `references/verification.md`. Use approved structural/consistency checks for policy/configuration.\n2. Run authorized tests and inspect output, but DO NOT edit source, documents, tests or configuration. DO NOT repair failures or broaden verification without authorization.\n3. Report every brief criterion by ID or original wording. Record method/scope, run status, accessible evidence, criterion verdict, unverified reason and remaining scope.\n4. Run status is passed, failed, not run or environment blocked. Verdict is proven, unmet or unverified. Passing alone proves no criterion; connect conditions/expected results to observations. Keep partial checks, out-of-scope criteria, missing checks and environment blocks unverified. Omit no criterion. PASS means run status only.\n5. Structural checks prove structural criteria only, not behavior, installation or live agent compliance. After a fix, rerun reproduction and invalidated checks; report the prior finding resolved, unresolved or unverified with evidence. Classify each HEAD failure first by read-only diff against the approved base (unrelated when its test, direct imports, fixtures and test configuration are unchanged), and report the rest as needing a base run; when Orchestrator supplies a base worktree, rerun only those by test name and classify them as baseline, new or new-failure candidate. Only new failures are findings; unrelated failures and candidates need Orchestrator disposition. Rerun a suspected intermittent test alone, up to the brief's limit (default three), as diagnosis rather than retry; report passes-in-isolation and rerun count.\n6. Only with assigned UI criteria and a brief citation to installed ARC `references/verification.md`'s `UI browser acceptance checks`, read/follow that section before launching apps or using browser tools. Otherwise DO NOT launch apps/browsers for UI acceptance. Report missing citations/prerequisites and leave criteria unverified.\n7. Report exact commands, results, evidence, unresolved issues and limits. For undeterminable scope, report each item, cause, substitute checks run and remaining unverified scope. Separate failures from environment problems. Run approved checks and report only; DO NOT edit, repair, plan or decide acceptance."
83
83
  },
84
84
  {
85
85
  "id": "reviewer.contract-intro",
@@ -87,11 +87,11 @@
87
87
  },
88
88
  {
89
89
  "id": "reviewer.review-steps",
90
- "text": "- Use goal, criteria, assigned diff/source scope and relevant QA evidence. Independently review only that scope for substantive correctness, factual accuracy and security.\n- Return actionable findings, relevant questions, next actions and workspace/path issues with file/page/source references. State when no substantive findings exist.\n- For acceptance-linked behavior findings, report criterion, expected behavior, observed problem, source, reproduction conditions/steps and evidence. Separate source inference from execution observation. DO NOT run QA tests to obtain observations.\n- Outside the final plan Reviewer exception, Orchestrator routes corrections to Implementer and post-fix QA. Continue reviewing structure/design/factual/security issues execution cannot settle.\n- For significant/high-risk work, review the final full change after required QA/focused checks and QA rechecks. QA owns task functional/test verification; Orchestrator runs final verification and owns overall completion and acceptance.\n- DO NOT run QA, plan or decide acceptance. "
90
+ "text": "- Use goal, criteria, assigned diff/source scope and relevant Tester evidence. Independently review only that scope for substantive correctness, factual accuracy and security.\n- Return actionable findings, relevant questions, next actions and workspace/path issues with file/page/source references. State when no substantive findings exist.\n- For acceptance-linked behavior findings, report criterion, expected behavior, observed problem, source, reproduction conditions/steps and evidence. Separate source inference from execution observation. DO NOT run Tester tests to obtain observations.\n- Outside the final plan Reviewer exception, Orchestrator routes corrections to Implementer and post-fix Tester. Continue reviewing structure/design/factual/security issues execution cannot settle.\n- For significant/high-risk work, review the final full change after required Tester/focused checks and Tester rechecks. Tester owns task and final functional/test verification; Orchestrator owns overall completion and acceptance.\n- DO NOT run Tester, plan or decide acceptance. "
91
91
  },
92
92
  {
93
93
  "id": "reviewer.final-plan-findings",
94
- "text": "Final overall Reviewer findings on plan work, including behavior findings, follow Implementer → Reviewer without QA reassignment until resolved, including repeat findings. Review the latest committed/uncommitted correction diff supplied by Orchestrator. Remain read-only. Earlier QA is not post-fix verification. Preserve required QA and QA failure rechecks before this final stage. New failures from final verification follow Implementer → QA; affected evidence needs a refreshed-diff recheck."
94
+ "text": "Final overall Reviewer findings on plan work, including behavior findings, follow Implementer → Reviewer without Tester reassignment until resolved, including repeat findings. Review the latest committed/uncommitted correction diff supplied by Orchestrator. Remain read-only. Earlier Tester is not post-fix verification. Preserve required Tester and Tester failure rechecks before this final stage. New failures from final verification follow Implementer → Tester; affected evidence needs a refreshed-diff recheck."
95
95
  },
96
96
  {
97
97
  "id": "scouter.research-brief",
@@ -103,7 +103,7 @@
103
103
  },
104
104
  {
105
105
  "id": "scouter.additional-boundaries",
106
- "text": "- DO NOT create/save standalone documents. Explain research in conversation. DO NOT make design/planning decisions, QA verdicts, final reviews or acceptance/completion decisions.\n- Planner owns design/spec/plan drafts; Implementer owns implementation/configuration/tests/dependent docs; QA independently verifies; Reviewer reviews final changes. Orchestrator integrates/accepts.\n- Publicly documented operational methods and supplied static operational reports are in scope. Acquiring/inspecting current disk/cache/system/filesystem/environment/app/process live state and operational cleanup are outside scope. This boundary assigns no owner to those activities.\n- Return mixed implementation work and needed changes without expanding assigned scope."
106
+ "text": "- DO NOT create/save standalone documents. Explain research in conversation. DO NOT make design/planning decisions, Tester verdicts, final reviews or acceptance/completion decisions.\n- Planner owns design/spec/plan drafts; Implementer owns implementation/configuration/tests/dependent docs; Tester independently verifies; Reviewer reviews final changes. Orchestrator integrates/accepts.\n- Publicly documented operational methods and supplied static operational reports are in scope. Acquiring/inspecting current disk/cache/system/filesystem/environment/app/process live state and operational cleanup are outside scope. This boundary assigns no owner to those activities.\n- Return mixed implementation work and needed changes without expanding assigned scope."
107
107
  }
108
108
  ],
109
109
  "targets": [
@@ -140,7 +140,7 @@
140
140
  ]
141
141
  },
142
142
  {
143
- "path": "claude/agents/arc-qa.md",
143
+ "path": "claude/agents/arc-tester.md",
144
144
  "fragments": [
145
145
  "common.brief-boundary",
146
146
  "common.specialist-basics",
@@ -149,9 +149,9 @@
149
149
  "common.optional-read-exception",
150
150
  "common.resume-gates",
151
151
  "claude.profile-guidance",
152
- "qa.contract-intro",
152
+ "tester.contract-intro",
153
153
  "common.verification-reference",
154
- "qa.verification-steps"
154
+ "tester.verification-steps"
155
155
  ]
156
156
  },
157
157
  {
@@ -215,16 +215,16 @@
215
215
  ]
216
216
  },
217
217
  {
218
- "path": "codex/agents/arc-qa.toml",
218
+ "path": "codex/agents/arc-tester.toml",
219
219
  "fragments": [
220
220
  "common.brief-boundary",
221
221
  "common.specialist-basics",
222
222
  "codex.incident-prefix",
223
223
  "common.optional-read-exception",
224
224
  "common.resume-gates",
225
- "qa.contract-intro",
225
+ "tester.contract-intro",
226
226
  "common.verification-reference",
227
- "qa.verification-steps"
227
+ "tester.verification-steps"
228
228
  ]
229
229
  },
230
230
  {
@@ -285,16 +285,16 @@
285
285
  ]
286
286
  },
287
287
  {
288
- "path": "gemini/agents/arc-qa.md",
288
+ "path": "gemini/agents/arc-tester.md",
289
289
  "fragments": [
290
290
  "common.brief-boundary",
291
291
  "common.specialist-basics",
292
292
  "common.preservation-choice-inspection",
293
293
  "common.optional-read-exception",
294
294
  "common.resume-gates",
295
- "qa.contract-intro",
295
+ "tester.contract-intro",
296
296
  "common.verification-reference",
297
- "qa.verification-steps"
297
+ "tester.verification-steps"
298
298
  ]
299
299
  },
300
300
  {
@@ -355,16 +355,16 @@
355
355
  ]
356
356
  },
357
357
  {
358
- "path": "grok/agents/arc-qa.md",
358
+ "path": "grok/agents/arc-tester.md",
359
359
  "fragments": [
360
360
  "common.brief-boundary",
361
361
  "common.specialist-basics",
362
362
  "common.preservation-choice-inspection",
363
363
  "common.optional-read-exception",
364
364
  "common.resume-gates",
365
- "qa.contract-intro",
365
+ "tester.contract-intro",
366
366
  "common.verification-reference",
367
- "qa.verification-steps"
367
+ "tester.verification-steps"
368
368
  ]
369
369
  },
370
370
  {
@@ -28,7 +28,7 @@ const EXPECTED = {
28
28
  "planner.visual-question",
29
29
  "planner.final-plan-recheck"
30
30
  ],
31
- "claude/agents/arc-qa.md": [
31
+ "claude/agents/arc-tester.md": [
32
32
  "common.brief-boundary",
33
33
  "common.specialist-basics",
34
34
  "common.preservation-choice-inspection",
@@ -36,9 +36,9 @@ const EXPECTED = {
36
36
  "common.optional-read-exception",
37
37
  "common.resume-gates",
38
38
  "claude.profile-guidance",
39
- "qa.contract-intro",
39
+ "tester.contract-intro",
40
40
  "common.verification-reference",
41
- "qa.verification-steps"
41
+ "tester.verification-steps"
42
42
  ],
43
43
  "claude/agents/arc-reviewer.md": [
44
44
  "common.brief-boundary",
@@ -88,15 +88,15 @@ const EXPECTED = {
88
88
  "planner.visual-question",
89
89
  "planner.final-plan-recheck"
90
90
  ],
91
- "codex/agents/arc-qa.toml": [
91
+ "codex/agents/arc-tester.toml": [
92
92
  "common.brief-boundary",
93
93
  "common.specialist-basics",
94
94
  "codex.incident-prefix",
95
95
  "common.optional-read-exception",
96
96
  "common.resume-gates",
97
- "qa.contract-intro",
97
+ "tester.contract-intro",
98
98
  "common.verification-reference",
99
- "qa.verification-steps"
99
+ "tester.verification-steps"
100
100
  ],
101
101
  "codex/agents/arc-reviewer.toml": [
102
102
  "common.brief-boundary",
@@ -123,12 +123,12 @@ const EXPECTED = {
123
123
  ],
124
124
  "gemini/agents/arc-implementer.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "implementer.execution-steps"],
125
125
  "gemini/agents/arc-planner.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "planner.target-evidence", "planner.workflow-contract", "planner.exploration-density", "planner.task-shape", "planner.commit-boundary", "planner.visual-question", "planner.final-plan-recheck"],
126
- "gemini/agents/arc-qa.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "qa.contract-intro", "common.verification-reference", "qa.verification-steps"],
126
+ "gemini/agents/arc-tester.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "tester.contract-intro", "common.verification-reference", "tester.verification-steps"],
127
127
  "gemini/agents/arc-reviewer.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "reviewer.contract-intro", "common.verification-reference", "reviewer.review-steps", "common.read-only-no-mutations", "reviewer.final-plan-findings"],
128
128
  "gemini/agents/arc-scouter.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "scouter.research-brief", "scouter.research-mode", "common.read-only-no-mutations", "scouter.additional-boundaries"],
129
129
  "grok/agents/arc-implementer.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "implementer.execution-steps"],
130
130
  "grok/agents/arc-planner.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "planner.target-evidence", "planner.workflow-contract", "planner.exploration-density", "planner.task-shape", "planner.commit-boundary", "planner.visual-question", "planner.final-plan-recheck"],
131
- "grok/agents/arc-qa.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "qa.contract-intro", "common.verification-reference", "qa.verification-steps"],
131
+ "grok/agents/arc-tester.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "tester.contract-intro", "common.verification-reference", "tester.verification-steps"],
132
132
  "grok/agents/arc-reviewer.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "reviewer.contract-intro", "common.verification-reference", "reviewer.review-steps", "common.read-only-no-mutations", "reviewer.final-plan-findings"],
133
133
  "grok/agents/arc-scouter.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "scouter.research-brief", "scouter.research-mode", "common.read-only-no-mutations", "scouter.additional-boundaries"]
134
134
  };
@@ -197,7 +197,7 @@ function templateSources(context) {
197
197
  const sources = new Map();
198
198
  for (const {runtime, payloadPrefix, agentTemplates} of installerRegistryOf(context).byAnchorOrder()) {
199
199
  const source = agentTemplates?.expectationsFrom ?? runtime.id;
200
- for (const role of ['scouter', 'planner', 'implementer', 'qa', 'reviewer']) {
200
+ for (const role of ['scouter', 'planner', 'implementer', 'tester', 'reviewer']) {
201
201
  const expected = Object.keys(EXPECTED).find(name => name.startsWith(`${source}/agents/arc-${role}.`));
202
202
  sources.set(`${payloadPrefix}/agents/${standaloneProfileFile(runtime, `arc_${role}`)}`, expected);
203
203
  }
@@ -2,6 +2,7 @@ import path from 'node:path';
2
2
  import {fingerprintRequest} from './store.mjs';
3
3
  import {validateGitPreflight,validateGitCommitResult} from './git-evidence.mjs';
4
4
  import {within} from './scope.mjs';
5
+ import {canonicalCooperativeRole} from './operations.mjs';
5
6
  const reconciliations=new WeakMap();
6
7
  export function verifiedCooperativeReconciliation(decision,state){const proof=reconciliations.get(decision);return !!proof&&proof.before===fingerprintRequest(state)&&proof.after===fingerprintRequest(decision.proposedTransition);}
7
8
  const completed=(state,id)=>state.tasks?.some(t=>t.id===id&&t.status==='committed'&&!t.invalidated)&&state.commits?.some(c=>c.taskId===id&&c.observationSource==='local-git'&&state.intents.some(i=>i.operation==='commit'&&i.requestId===c.requestId&&i.taskId===id&&i.status==='succeeded'));
@@ -20,9 +21,9 @@ function checkEvidence(state,task,a,changes){
20
21
  if(!same(a.criteria,task.criteria)||!task.criteria.length||!list(a.checkIds)||!list(a.findingIds)||a.changeFingerprint!==changes?.tasks?.[task.id])return false;
21
22
  const checks=state.checks.filter(c=>c.scope==='task'&&c.taskId===task.id);
22
23
  const latest=task.requiredChecks.map(d=>checks.filter(c=>same(c.descriptor,d)).at(-1));
23
- if(!task.requiredChecks.length||latest.some(c=>!c||c.stale||c.status!=='passed'||c.verdict!=='proven'||!text(c.resultRef)||c.source!=='operator-attested'||c.verificationActor?.role!=='qa'||!text(c.verificationActor.id)||state.assignments.some(a=>a.agentId===c.verificationActor.id)||c.changeFingerprint!==a.changeFingerprint)||!exact(a.checkIds,latest.map(c=>c?.id)))return false;
24
+ if(!task.requiredChecks.length||latest.some(c=>!c||c.stale||c.status!=='passed'||c.verdict!=='proven'||!text(c.resultRef)||c.source!=='operator-attested'||canonicalCooperativeRole(c.verificationActor?.role)!=='tester'||!text(c.verificationActor.id)||state.assignments.some(a=>a.agentId===c.verificationActor.id)||c.changeFingerprint!==a.changeFingerprint)||!exact(a.checkIds,latest.map(c=>c?.id)))return false;
24
25
  const findings=state.findings.filter(f=>f.scope==='task'&&f.taskId===task.id);
25
- return exact(a.findingIds,findings.map(f=>f.id))&&findings.every(f=>f.status==='closed'&&text(f.resolutionRef)&&text(f.recheckRef)&&f.resolutionActor?.role==='implementer'&&f.recheckActor?.role==='qa'&&f.changeFingerprint===a.changeFingerprint);
26
+ return exact(a.findingIds,findings.map(f=>f.id))&&findings.every(f=>f.status==='closed'&&text(f.resolutionRef)&&text(f.recheckRef)&&f.resolutionActor?.role==='implementer'&&canonicalCooperativeRole(f.recheckActor?.role)==='tester'&&f.changeFingerprint===a.changeFingerprint);
26
27
  }
27
28
  function waitingFor(state,task,predecessor){
28
29
  if(task.status!=='pending'||state.intents.some(i=>i.taskId===task.id&&i.operation==='assign-agent'&&['prepared','unknown','mismatch','succeeded'].includes(i.status)))return false;
@@ -34,7 +35,7 @@ function freshAcceptance(state,task,acceptance,changes){return acceptance&&!acce
34
35
  export function evaluateCooperativeAcceptance({state,request,evidence}={}){
35
36
  const task=state?.tasks?.find(t=>t.id===request?.taskId),a=request?.arguments,g=evidence?.git;
36
37
  if(request?.expectedRevision!==state?.revision||request.actor?.role!=='orchestrator'||!authorized(state,task)||task.status!=='pending'||state.acceptances.some(v=>v.taskId===task.id&&!v.stale)||state.commits.some(v=>v.taskId===task.id))return hold(state,'Current pending approved task and Orchestrator acceptance required');
37
- if(!fields(a,['messageRef','criteria','checkIds','findingIds','changeFingerprint'])||!text(a.messageRef)||!checkEvidence(state,task,a,evidence?.changes)||state.checks.some(c=>a.checkIds?.includes(c.id)&&c.verificationActor?.id===request.actor.id))return hold(state,'Exact criteria, current required QA checks and closed findings required');
38
+ if(!fields(a,['messageRef','criteria','checkIds','findingIds','changeFingerprint'])||!text(a.messageRef)||!checkEvidence(state,task,a,evidence?.changes)||state.checks.some(c=>a.checkIds?.includes(c.id)&&c.verificationActor?.id===request.actor.id))return hold(state,'Exact criteria, current required Tester checks and closed findings required');
38
39
  const descriptor={kind:'task',parent:state.target.head,indexTree:g?.indexTree,fingerprint:g?.stagedFingerprint,paths:g?.stagedPaths};
39
40
  const invalid=validateGitPreflight({target:state.target,descriptor,scope:task.paths,gitEvidence:g});
40
41
  if(invalid||dirtyOtherTask(state,task,g))return hold(state,invalid??'Index includes another task changes');
@@ -1,7 +1,7 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import crypto from 'node:crypto';
4
- import {validateCooperativeCommand,validateCooperativeState} from './cooperative-schema.mjs';
4
+ import {legacyCooperativeRoleDenial,validateCooperativeCommand,validateCooperativeState} from './cooperative-schema.mjs';
5
5
  import {observeCooperativeTarget,validateObservedTarget,validateWorkflowId,workflowStatePath,inspectPath} from './scope.mjs';
6
6
  import {saveDurableState} from './store.mjs';
7
7
  export const COOPERATIVE_RUNTIME_MODULES=Object.freeze([
@@ -22,6 +22,8 @@ export async function cooperativeVersions(){
22
22
  }
23
23
  export async function initializeCooperativeWorkflow({cwd,workflowId,input,observe=observeCooperativeTarget,storage={}}){
24
24
  validateWorkflowId(workflowId);validateCooperativeCommand({command:'init',input});
25
+ const denial=legacyCooperativeRoleDenial(input);
26
+ if(denial)return commandResult({workflowId,input,...denial});
25
27
  if(input.mode!=='plan')return commandResult({workflowId,input,decision:'hold',ruleId:'cooperative.unsupported'});
26
28
  const target=await validateObservedTarget(cwd,await observe(cwd));const statePath=await workflowStatePath(target,workflowId);
27
29
  const parent=path.dirname(statePath);await fs.mkdir(parent,{recursive:true,mode:0o700});await inspectPath(parent,{directory:true});
@@ -3,11 +3,37 @@ import path from 'node:path';
3
3
  import os from 'node:os';
4
4
  import {initializeCooperativeWorkflow,commandResult} from './bootstrap.mjs';
5
5
  import {runCooperativeCommand} from './cooperative.mjs';
6
- import {validateWorkflowId} from './scope.mjs';
6
+ import {absolute,validateWorkflowId} from './scope.mjs';
7
+ import {writeHandoffRecord} from './handoff-record.mjs';
7
8
  import {prepareRoleDispatch,routingStatus,invalidRoutingRequest} from './role-routing.mjs';
8
9
  import {runBridgeDispatch,recordRoleObservation,resumeRoleDispatch,cancelRoleDispatch,heldRoutingResult} from './role-bridge.mjs';
10
+ async function runHandoffRecordCommand([command,...args],io,output){
11
+ const options={};
12
+ try{
13
+ if(command!=='write')throw Error('Expected handoff-record write');
14
+ for(let i=0;i<args.length;i+=2){
15
+ const key=args[i];
16
+ if(!['--cwd','--slug','--input'].includes(key)||options[key]!==undefined||typeof args[i+1]!=='string')throw Error('Invalid handoff-record option');
17
+ options[key]=args[i+1];
18
+ }
19
+ const cwd=options['--cwd'],slug=options['--slug'];
20
+ if(!absolute(cwd))throw Error('Absolute workspace required');
21
+ if(slug===undefined||options['--input']!=='-')throw Error('Handoff record write requires --slug and --input -');
22
+ const rawInput=io.input??fs.readFileSync(0,'utf8');
23
+ let input;
24
+ try{input=JSON.parse(rawInput);}catch{throw Error('Expected JSON handoff input');}
25
+ if(typeof input?.content!=='string'||!input.content.length)throw Error('Expected nonempty handoff content');
26
+ const result=await writeHandoffRecord({cwd,slug,content:input.content});
27
+ output.write(JSON.stringify(result)+'\n');
28
+ return result.decision==='deny'?2:result.decision==='hold'?3:0;
29
+ }catch(error){
30
+ output.write(JSON.stringify({decision:'hold',reasonCode:'handoff_write_failed',message:error.message,fallback:'inline'})+'\n');
31
+ return 1;
32
+ }
33
+ }
9
34
  export async function runWorkflowCommand(args,io={}){
10
35
  const output=io.output??process.stdout;let workflowId=null,isRouting=false;
36
+ if(args[0]==='handoff-record')return runHandoffRecordCommand(args.slice(1),io,output);
11
37
  try{
12
38
  const [command,...rest]=args,options={};
13
39
  isRouting=['routing-status','prepare-dispatch','run-dispatch','observe','resume','cancel'].includes(command);
@@ -1,4 +1,4 @@
1
- import {ROLES} from './operations.mjs';
1
+ import {ROLES,canonicalCooperativeRole,hasNewStoredOperationAliases,isLegacyOperation,normalizeStoredOperations} from './operations.mjs';
2
2
  import {assertSecretFree} from './external.mjs';
3
3
  import {object,text,validatePlannerLedger} from './schema.mjs';
4
4
  import {absolute,validateWorkflowId} from './scope.mjs';
@@ -6,10 +6,17 @@ import {validateTargetPreparationRecord} from './target-preparation.mjs';
6
6
  const fail=message=>{throw Error('Cooperative schema: '+message);};
7
7
  const hash=value=>typeof value==='string'&&/^sha256:[a-f0-9]{64}$/.test(value);
8
8
  const revision=value=>Number.isSafeInteger(value)&&value>=0;
9
- const actor=value=>object(value)&&text(value.id)&&Object.keys(value).every(k=>['id','role'].includes(k))&&(value.role===undefined||ROLES.includes(value.role));
9
+ const actor=value=>object(value)&&text(value.id)&&Object.keys(value).every(k=>['id','role'].includes(k))&&(value.role===undefined||ROLES.includes(canonicalCooperativeRole(value.role)));
10
10
  const statement=value=>object(value)&&text(value.messageRef)&&object(value.data);
11
11
  function fields(value,allowed){if(!object(value)||Object.keys(value).some(k=>!allowed.includes(k)))fail('unexpected input field');}
12
12
  function json(value){try{const encoded=JSON.stringify(value);if(encoded===undefined)fail('JSON input');}catch{fail('JSON input');}}
13
+ export function legacyCooperativeRoleDenial(input){
14
+ let ruleId;
15
+ if(input?.actor?.role==='qa')ruleId='cooperative.verification-actor';
16
+ else if(input?.arguments?.actor?.role==='qa'||input?.result?.data?.actor?.role==='qa')ruleId='cooperative.verification-independence';
17
+ else if(input?.evidence?.kind==='finding'&&input.evidence.data?.actor?.role==='qa')ruleId='cooperative.finding-resolution';
18
+ if(ruleId)return {decision:'deny',ruleIds:[ruleId],reason:'legacy_role_qa'};
19
+ }
13
20
  export function validateCooperativeCommand(command){
14
21
  assertSecretFree(command);fields(command,['command','input']);const {input,command:name}=command;
15
22
  if(!['init','record','status','reconcile','prepare','result'].includes(name))fail('command');
@@ -17,6 +24,7 @@ export function validateCooperativeCommand(command){
17
24
  const resultStatement=name==='reconcile'||name==='result'&&input?.operation===undefined;
18
25
  const allowed=name==='init'?['mode','actor','selection']:name==='record'?['requestId','expectedRevision','actor','evidence']:resultStatement?['requestId','expectedRevision','actor','intentId','result']:['requestId','expectedRevision','actor','operation','taskId','arguments'];
19
26
  fields(input,allowed);json(input);
27
+ // Recognize this input shape so command entry points can return the role denial.
20
28
  if(!actor(input.actor))fail('actor attestation');
21
29
  if(name==='init'){
22
30
  if(!['plan','no-plan','small-task'].includes(input.mode)||!object(input.selection)||!text(input.selection.messageRef)||!hash(input.selection.contentHash)||Object.keys(input.selection).some(k=>!['messageRef','contentHash'].includes(k)))fail('target selection');
@@ -33,10 +41,10 @@ export function validateCooperativeCommand(command){
33
41
  if(!text(input.intentId)||!statement(input.result)||!['succeeded','failed','unknown','mismatch','cancelled'].includes(input.result.status))fail('result evidence');
34
42
  if(input.result.status==='cancelled'&&(!object(input.result.notExecutedEvidence)||!text(input.result.notExecutedEvidence.messageRef)))fail('cancel requires not-executed evidence');
35
43
  }
36
- if((name==='prepare'||name==='result'&&!resultStatement)&&!text(input.operation))fail('operation');
44
+ if((name==='prepare'||name==='result'&&!resultStatement)&&(!text(input.operation)||isLegacyOperation(input.operation)))fail('operation');
37
45
  return command;
38
46
  }
39
- export function validateCooperativeState(state){
47
+ export function validateCooperativeState(state,{allowLegacyOperations=true,preserveStoredOperations=false,legacyOperationsFrom}={}){
40
48
  if(!object(state)||state.workflowKind!=='cooperative'||state.contractVersion!==1||state.schemaVersion!==1||!revision(state.revision)||state.mode!=='plan')fail('explicit cooperative contract');
41
49
  validateWorkflowId(state.workflowId);
42
50
  if(!object(state.target)||!absolute(state.target.realpath)||!absolute(state.target.gitCommonDir)||!absolute(state.target.gitDir)||!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(state.target.head)||!(state.target.branch===null||text(state.target.branch)))fail('target');
@@ -60,5 +68,8 @@ export function validateCooperativeState(state){
60
68
  for(const checkpoint of checkpoints){try{validateTargetPreparationRecord('checkpoint',{type:'checkpoint',...checkpoint});}catch{fail('target checkpoint');}if(checkpoint.source!=='operator-attested'||!text(checkpoint.messageRef)||!preparationIntents.some(i=>i.id===checkpoint.intentId&&i.firstStageId===checkpoint.stageId)||!state.records.some(r=>r.kind==='target-preparation'&&r.messageRef===checkpoint.messageRef&&r.source==='operator-attested'))fail('target checkpoint provenance');}
61
69
  for(const transition of transitions){const request=transition.validation?.request;try{validateTargetPreparationRecord('transition',request);}catch{fail('target transition');}if(!object(transition.target)||!text(transition.messageRef)||!Number.isSafeInteger(transition.targetVersion)||transition.targetVersion!==transition.sourceTargetVersion+1||request.intentId!==transition.intentId||request.checkpointRef!==transition.checkpointRef||!preparationIntents.some(i=>i.id===transition.intentId)||!checkpoints.some(c=>c.intentId===transition.intentId&&c.messageRef===transition.checkpointRef)||!state.records.some(r=>r.kind==='target-preparation'&&r.messageRef===transition.messageRef&&r.source==='operator-attested'))fail('target transition provenance');}
62
70
  for(const document of documents){try{validateTargetPreparationRecord('destination',document);}catch{fail('target document');}if(document.sourceLink!=='operator-attested'||document.verification?.status!=='verified'||document.verification?.source!=='local-bytes'||!text(document.messageRef)||!transitions.some(t=>t.intentId===document.intentId&&t.messageRef===document.transitionRef&&t.targetVersion===document.targetVersion)||!state.records.some(r=>r.kind==='target-preparation'&&r.messageRef===document.messageRef&&r.source==='operator-attested'))fail('target document provenance');}
63
- assertSecretFree(state);json(state);return state;
71
+ assertSecretFree(state);json(state);
72
+ const normalized=normalizeStoredOperations(state);
73
+ if(!allowLegacyOperations&&normalized!==state&&(!legacyOperationsFrom||hasNewStoredOperationAliases(state,legacyOperationsFrom)))fail('legacy operation in new state');
74
+ return preserveStoredOperations?state:normalized;
64
75
  }
@@ -7,7 +7,7 @@ import fs from 'node:fs/promises';
7
7
  import {constants} from 'node:fs';
8
8
  import path from 'node:path';
9
9
  import {createHash} from 'node:crypto';
10
- import {validateCooperativeCommand,validateCooperativeState} from './cooperative-schema.mjs';
10
+ import {legacyCooperativeRoleDenial,validateCooperativeCommand,validateCooperativeState} from './cooperative-schema.mjs';
11
11
  import {observeCooperativeTarget,validateObservedTarget,validateWorkflowId,workflowStatePath,inspectPath,absolute,within} from './scope.mjs';
12
12
  import {fingerprintRequest,saveDurableState,applyCooperativeCommitTransition,applyCooperativeTargetTransition} from './store.mjs';
13
13
  import {commandResult,cooperativeVersions} from './bootstrap.mjs';
@@ -18,9 +18,11 @@ const sameCheckout=(a,b)=>['realpath','gitCommonDir','gitDir'].every(k=>a[k]===b
18
18
  /** Only trusted code may inject observation/storage. CLI JSON cannot set either. */
19
19
  export async function runCooperativeCommand({cwd,workflowId,command,input,observe=observeCooperativeTarget,storage={},readGit=readAssignmentGitEvidence,readChanges=readCooperativeChanges,readCommitGit=readCooperativeCommitGitEvidence}){
20
20
  validateWorkflowId(workflowId);validateCooperativeCommand({command,input});
21
+ const denial=legacyCooperativeRoleDenial(input);
22
+ if(denial)return commandResult({workflowId,input,...denial});
21
23
  if(command==='init')throw Error('Use initializeCooperativeWorkflow for init');
22
24
  const target=await validateObservedTarget(cwd,await observe(cwd)),statePath=await workflowStatePath(target,workflowId);
23
- const read=async()=>{await inspectPath(statePath);const state=validateCooperativeState(JSON.parse(await fs.readFile(statePath,'utf8')));if(state.workflowId!==workflowId)throw Error('Workflow identity mismatch');return state;};
25
+ const read=async()=>{await inspectPath(statePath);const state=validateCooperativeState(JSON.parse(await fs.readFile(statePath,'utf8')),{preserveStoredOperations:command!=='status'});if(state.workflowId!==workflowId)throw Error('Workflow identity mismatch');return state;};
24
26
  const result=(state,decision,extra={})=>commandResult({workflowId,state,input,...decision,...extra});
25
27
  const removedDecision=state=>{const decision=evaluateCooperative({state,request:{command,input}});return decision.ruleIds[0]==='cooperative.plan-amend-removed'?decision:null;};
26
28
  if(command==='status'){
@@ -35,6 +37,7 @@ export async function runCooperativeCommand({cwd,workflowId,command,input,observ
35
37
  let lock,plannerLock;
36
38
  try{
37
39
  lock=await fs.open(statePath+'.lock','wx',0o600);let state=await read();
40
+ const previousOperations={approvals:[...state.approvals],assignments:[...state.assignments],audit:[...state.audit]};
38
41
  const removed=removedDecision(state);if(removed)return result(state,removed);
39
42
  const plannerWork=command==='prepare'&&input.operation==='planner-call'||command==='record'&&input.evidence.kind.startsWith('planner-');
40
43
  if(plannerWork)plannerLock=await fs.open(path.join(target.gitCommonDir,'arc','planner.lock'),'wx',0o600);
@@ -182,7 +185,7 @@ export async function runCooperativeCommand({cwd,workflowId,command,input,observ
182
185
  const output=result(state,decision,{persisted:true});
183
186
  state.requests.push({requestId:input.requestId,requestFingerprint,request:structuredClone({command,input}),decision:output});
184
187
  state.audit.push({command,requestId:input.requestId,revision:state.revision,decision:output.decision,ruleIds:output.ruleIds,source:'operator-attested',actor:input.actor,...(input.intentId?{intentId:input.intentId,resolution:state.results.at(-1)?.status}:{}),...(input.operation?{operation:input.operation}:{})});
185
- validateCooperativeState(state);await inspectPath(statePath);await saveDurableState({statePath,state,storage});return output;
188
+ validateCooperativeState(state,{allowLegacyOperations:false,legacyOperationsFrom:previousOperations});await inspectPath(statePath);await saveDurableState({statePath,state,storage});return output;
186
189
  }finally{if(plannerLock){await plannerLock.close();await fs.unlink(path.join(target.gitCommonDir,'arc','planner.lock'));}if(lock){await lock.close();await fs.unlink(statePath+'.lock');}}
187
190
  }
188
191
 
@@ -14,20 +14,21 @@ import {prepareCooperativeAssignment} from './assignment.mjs';
14
14
  * @property {object} coverage
15
15
  */
16
16
  import path from 'node:path';
17
- import {validateCooperativeState,validateCooperativeCommand} from './cooperative-schema.mjs';
17
+ import {legacyCooperativeRoleDenial,validateCooperativeState,validateCooperativeCommand} from './cooperative-schema.mjs';
18
18
  import {validateWorkflowState, validateRequest, validateEvidence,validatePlannerStage} from './schema.mjs';
19
- import {ROLES, ROLE_OPERATIONS, GIT_OPERATIONS, EXTERNAL_OPERATIONS} from './operations.mjs';
19
+ import {ROLES, ROLE_OPERATIONS, GIT_OPERATIONS, EXTERNAL_OPERATIONS, canonicalCooperativeRole} from './operations.mjs';
20
20
  const same=(a,b)=>JSON.stringify(a)===JSON.stringify(b);
21
21
  const within=(base,file)=>{const relative=path.relative(base,file);return relative===''||(!relative.startsWith('..'+path.sep)&&relative!=='..'&&!path.isAbsolute(relative));};
22
22
  /** Pure policy decision. Evidence is supplied by a trusted adapter/provider, never tool arguments. */
23
23
  export function evaluate(policy, state, request, evidence){
24
+ const stored=state;
24
25
  const result=(decision,id,reason,requiredEvidence=[])=>({decision,ruleIds:[id],reason,requiredEvidence,expectedRevision:state?.revision??0,proposedTransition:null,coverage:{platform:request?.platform??'unknown',enforcement:'decision-only'}});
25
- try{validateWorkflowState(state);validateRequest(request);validateEvidence(evidence);}catch(error){return result('hold','runtime.schema',error.message,['valid-state-request-evidence']);}
26
+ try{state=validateWorkflowState(state);validateRequest(request);validateEvidence(evidence);}catch(error){return result('hold','runtime.schema',error.message,['valid-state-request-evidence']);}
26
27
  if(policy?.runtime?.schemaVersion!==1||!same(policy.runtime.roles,ROLES)||!Array.isArray(policy.runtime.ruleIds)||!Array.isArray(policy.runtime.requiredEvidence)||policy.runtime.status!=='decision-only')return result('hold','runtime.policy','runtime policy unavailable',['runtime-policy']);
27
28
  const actor=state.identities.find(i=>i.actorRef===request.actorRef);
28
29
  if(!actor)return result('hold','runtime.identity','platform identity unresolved',['platform-identity']);
29
30
  const role=actor.role;
30
- const roleRule={orchestrator:'role.orchestrator-boundary',scouter:'role.scouter-read-only',planner:'role.planner-draft-only',implementer:'role.implementer-implementation',qa:'role.qa-verification',reviewer:'role.reviewer-independent'}[role];
31
+ const roleRule={orchestrator:'role.orchestrator-boundary',scouter:'role.scouter-read-only',planner:'role.planner-draft-only',implementer:'role.implementer-implementation',tester:'role.tester-verification',reviewer:'role.reviewer-independent'}[role]??'runtime.identity';
31
32
  if(!ROLE_OPERATIONS[role]?.includes(request.operation))return result('deny',GIT_OPERATIONS.includes(request.operation)?'git.specialists-deny':roleRule,'operation forbidden for assigned role');
32
33
  const lease=state.leases.find(l=>l.actorRef===actor.actorRef);
33
34
  if(lease?.status==='retired')return result('deny','runtime.identity','retired identity');
@@ -53,7 +54,7 @@ export function evaluate(policy, state, request, evidence){
53
54
  if(role==='implementer'&&['accepted','committed'].includes(task.status))return result('deny','runtime.identity','task execution ended');
54
55
  if(request.operation==='temporary-write'){
55
56
  const temporary=assignment.temporary;
56
- if(!temporary||temporary.cleanupOwner!==request.actorRef||!Number.isFinite(Date.parse(temporary.expiresAt))||!Number.isFinite(Date.parse(evidence.observedAt))||Date.parse(temporary.expiresAt)<=Date.parse(evidence.observedAt)||!request.paths.every(p=>temporary.paths?.some(base=>within(base,p))))return result('hold','role.qa-verification','temporary scope lifetime and cleanup ownership required',['temporary-assignment']);
57
+ if(!temporary||temporary.cleanupOwner!==request.actorRef||!Number.isFinite(Date.parse(temporary.expiresAt))||!Number.isFinite(Date.parse(evidence.observedAt))||Date.parse(temporary.expiresAt)<=Date.parse(evidence.observedAt)||!request.paths.every(p=>temporary.paths?.some(base=>within(base,p))))return result('hold','role.tester-verification','temporary scope lifetime and cleanup ownership required',['temporary-assignment']);
57
58
  }
58
59
  if(request.operation==='check'){
59
60
  if(!assignment.checks?.some(c=>same(c,request.descriptor)))return result('hold',roleRule,'exact assigned check descriptor required',['check-descriptor']);
@@ -82,7 +83,7 @@ export function evaluate(policy, state, request, evidence){
82
83
  if(d.checks&&(!Array.isArray(approval.scope.checks)||d.checks.some(c=>!approval.scope.checks.some(approved=>same(approved,c)))))return result('hold','runtime.assignment','delegated checks not approved',['delegated-checks']);
83
84
  if(d.temporary&&!same(d.temporary,approval.scope.temporary))return result('hold','runtime.assignment','delegated temporary scope not approved',['delegated-temporary-scope']);
84
85
  if(state.assignments.some(a=>a.assignmentId===request.requestId||a.correlationRef===d.correlationRef))return result('hold','runtime.identity','assignment correlation already registered',['new-assignment-correlation']);
85
- const next=structuredClone(state);
86
+ const next=structuredClone(stored);
86
87
  if(d.role==='planner'){
87
88
  const stage=state.plannerLedger?.stages.find(s=>s.id===d.plannerCall?.stageId),proof=fact('planner-call');
88
89
  const contract=stage&&{document:stage.document,inputVersion:stage.inputVersion,criteriaVersion:stage.criteriaVersion,scopeVersion:stage.scopeVersion};
@@ -98,7 +99,7 @@ export function evaluate(policy, state, request, evidence){
98
99
  }
99
100
  if(request.operation==='accept'){
100
101
  const d=request.descriptor;const observed=fact('acceptance')?.data;
101
- const checks=Array.isArray(d.checkIds)&&task.requiredChecks?.every(id=>d.checkIds?.includes(id)&&state.checks.some(c=>c.id===id&&c.taskId===task.id&&c.status==='passed'&&c.fingerprint===d.fingerprint&&c.resultRef&&c.actorRef!==actor.actorRef&&state.identities.some(i=>i.actorRef===c.actorRef&&i.taskId===task.id&&i.role==='qa')));
102
+ const checks=Array.isArray(d.checkIds)&&task.requiredChecks?.every(id=>d.checkIds?.includes(id)&&state.checks.some(c=>c.id===id&&c.taskId===task.id&&c.status==='passed'&&c.fingerprint===d.fingerprint&&c.resultRef&&c.actorRef!==actor.actorRef&&state.identities.some(i=>i.actorRef===c.actorRef&&i.taskId===task.id&&canonicalCooperativeRole(i.role)==='tester')));
102
103
  const findings=state.findings.filter(f=>f.taskId===task.id);
103
104
  if(!observed||!same(observed,d)||!d.fingerprint||!task.criteria?.length||!same(task.criteria,d.criteria)||!checks||findings.some(f=>!Array.isArray(d.findingIds)||!d.findingIds.includes(f.id)||!f.resolutionRef))return result('hold','git.orchestrator-accept-commit','criteria checks findings and fingerprint verification required',['acceptance-evidence']);
104
105
  }
@@ -123,6 +124,8 @@ export function evaluateCooperative({policy,state,request,evidence}={}){
123
124
  const base={expectedRevision:state?.revision??0,coverage:{enforcement:'cooperative',provenance:'operator-attested',nativeVerified:false}};
124
125
  const hold=(id,reason)=>({...base,decision:'hold',ruleIds:[id],reason,requiredEvidence:[],nextActions:[],proposedTransition:null});
125
126
  try{validateCooperativeState(state);validateCooperativeCommand(request);}catch(error){return hold('cooperative.schema',error.message);}
127
+ const denial=legacyCooperativeRoleDenial(request.input);
128
+ if(denial)return {...base,...denial,requiredEvidence:[],nextActions:[],proposedTransition:null};
126
129
  if(state.intents.some(i=>i.operation==='plan-amend'&&['prepared','unknown','mismatch','failed'].includes(i.status)))return {...hold('cooperative.plan-amend-removed','Legacy plan-amend intent is no longer supported; inspect Git history and any refs/arc/recovery/* refs manually, then start a new workflow'),nextActions:['inspect-legacy-plan-amend','start-new-workflow']};
127
130
  if(request.command==='prepare'&&request.input?.operation==='plan-amend')return hold('cooperative.plan-amend-removed','Plan-amend operation is no longer supported');
128
131
  if(policy!==undefined&&policy.workflowKind!=='cooperative')return hold('cooperative.contract','Explicit cooperative policy required');
@@ -0,0 +1,58 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import {randomUUID} from 'node:crypto';
4
+ import {inspectPath, observeCooperativeTarget, within} from './scope.mjs';
5
+
6
+ export async function writeHandoffRecord({cwd, slug, content}) {
7
+ if (typeof slug !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(slug) || slug.includes('..')) {
8
+ return {decision: 'deny', reasonCode: 'invalid_slug', message: 'Invalid handoff record slug.'};
9
+ }
10
+
11
+ let gitCommonDir;
12
+ let filename;
13
+ let temporaryFile;
14
+ try {
15
+ if (typeof content !== 'string' || !content.length) throw Error('Expected nonempty handoff content.');
16
+ ({gitCommonDir} = await observeCooperativeTarget(cwd));
17
+ const directory = path.join(gitCommonDir, 'arc', 'handoff');
18
+ filename = path.join(directory, `${slug}.md`);
19
+ if (!within(gitCommonDir, filename)) {
20
+ return {decision: 'deny', reasonCode: 'path_outside_common_dir', message: 'Handoff record path must stay inside the Git common directory.'};
21
+ }
22
+
23
+ await inspectPath(filename, {missing: true});
24
+ await fs.mkdir(directory, {recursive: true, mode: 0o700});
25
+ await inspectPath(filename, {missing: true});
26
+ let created = false;
27
+ try {
28
+ await fs.lstat(filename);
29
+ } catch (error) {
30
+ if (error.code !== 'ENOENT') throw error;
31
+ created = true;
32
+ }
33
+
34
+ const candidate = path.join(directory, `.handoff-${randomUUID()}.tmp`);
35
+ const file = await fs.open(candidate, 'wx', 0o600);
36
+ temporaryFile = candidate;
37
+ try {
38
+ await file.writeFile(content, 'utf8');
39
+ await file.sync();
40
+ } finally {
41
+ await file.close();
42
+ }
43
+ await fs.rename(temporaryFile, filename);
44
+ temporaryFile = undefined;
45
+ return {decision: 'allow', path: filename, created};
46
+ } catch (error) {
47
+ if (gitCommonDir && error.symlinkPath && within(gitCommonDir, error.symlinkPath)) {
48
+ const destination = await fs.readlink(error.symlinkPath).catch(() => null);
49
+ if (destination !== null && !within(gitCommonDir, path.resolve(path.dirname(error.symlinkPath), destination))) {
50
+ return {decision: 'deny', reasonCode: 'path_outside_common_dir', message: `Handoff record path must stay inside the Git common directory: ${filename}`};
51
+ }
52
+ }
53
+ const failedPath = error.symlinkPath ?? filename;
54
+ return {decision: 'hold', reasonCode: 'handoff_write_failed', message: failedPath ? `${failedPath}: ${error.message}` : error.message, fallback: 'inline'};
55
+ } finally {
56
+ if (temporaryFile) await fs.rm(temporaryFile, {force: true}).catch(() => {});
57
+ }
58
+ }