@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
@@ -1,30 +1,33 @@
1
1
  import {isPlatformId} from './platform-registry.mjs';
2
2
  import {validateWorkflowState, text} from './schema.mjs';
3
- import {ROLES} from './operations.mjs';
3
+ import {ROLES,canonicalCooperativeRole} from './operations.mjs';
4
4
  import fs from 'node:fs/promises';
5
5
  import path from 'node:path';
6
6
  import {fingerprintRequest,saveDurableState} from './store.mjs';
7
7
  const same=(a,b)=>JSON.stringify(a)===JSON.stringify(b);
8
8
  /** Observation is supplied by the trusted platform provider, never agent/tool arguments. */
9
9
  export function registerAgentObservation(state, observation){
10
- validateWorkflowState(state);
11
- const result=(decision,reason)=>({decision,reason,state,proposedTransition:null});
10
+ const stored=state;
11
+ state=validateWorkflowState(state);
12
+ const result=(decision,reason)=>({decision,reason,state:stored,proposedTransition:null});
12
13
  if(!observation||!text(observation.actorRef)||!text(observation.taskId)||!text(observation.observationRef)||!ROLES.includes(observation.role))return result('hold','complete observed identity required');
13
14
  const old=state.identities.find(i=>i.actorRef===observation.actorRef);
14
15
  const lease=state.leases.find(l=>l.actorRef===observation.actorRef);
15
- if(old&&(old.taskId!==observation.taskId||old.role!==observation.role))return result('deny','identity rebind');
16
+ if(old&&(old.taskId!==observation.taskId||canonicalCooperativeRole(old.role)!==observation.role))return result('deny','identity rebind');
16
17
  if(lease?.status==='retired')return result('deny','retired identity');
17
18
  const p=observation.provenance;
18
19
  if(!text(observation.eventRef)||!text(observation.correlationRef)||!p||p.source!=='platform-event'||p.eventRef!==observation.eventRef||p.actorRef!==observation.actorRef||p.platform!==observation.platform||p.correlationRef!==observation.correlationRef||p.verification?.status!=='verified'||!text(p.verification.verifierRef)||p.verification.sourceRef!==observation.eventRef)return result('hold','trusted platform spawn observation and correlation required');
19
20
  const assignment=state.assignments.find(a=>a.assignmentId===observation.assignmentId&&a.correlationRef===observation.correlationRef);
20
- if(!assignment||assignment.taskId!==observation.taskId||assignment.role!==observation.role||assignment.platform!==observation.platform||assignment.approvalRef!==observation.approvalRef||!same(assignment.paths,observation.paths)||!same(assignment.operations,observation.operations))return result('hold','observation does not match approved pending assignment');
21
+ if(assignment?.status==='pending'&&assignment.role==='qa')return {...result('hold','Legacy pending assignment requires a current assignment'),reasonCode:'legacy_role_pending_assignment_unsupported'};
22
+ const assignedRole=assignment?.status==='active'?canonicalCooperativeRole(assignment.role):assignment?.role;
23
+ if(!assignment||assignment.taskId!==observation.taskId||assignedRole!==observation.role||assignment.platform!==observation.platform||assignment.approvalRef!==observation.approvalRef||!same(assignment.paths,observation.paths)||!same(assignment.operations,observation.operations))return result('hold','observation does not match approved pending assignment');
21
24
  if(old){
22
25
  if(assignment.status==='active'&&assignment.actorRef===old.actorRef&&old.observationRef===observation.observationRef&&lease?.status==='active')return result('allow','same confirmed observation');
23
26
  return result('hold','existing identity cannot be assigned through another observation');
24
27
  }
25
28
  if(assignment.status!=='pending'||assignment.actorRef!==null||lease)return result('hold','new identity requires pending unbound assignment');
26
29
  const task=state.tasks.find(t=>t.id===assignment.taskId);if(!task||['accepted','committed'].includes(task.status))return result('hold','task no longer accepts agent observations');
27
- const next=structuredClone(state);const active=next.assignments.find(a=>a.assignmentId===assignment.assignmentId);active.actorRef=observation.actorRef;active.status='active';active.observationRef=observation.observationRef;
30
+ const next=structuredClone(stored);const active=next.assignments.find(a=>a.assignmentId===assignment.assignmentId);active.actorRef=observation.actorRef;active.status='active';active.observationRef=observation.observationRef;
28
31
  next.identities.push({actorRef:observation.actorRef,taskId:observation.taskId,role:observation.role,observationRef:observation.observationRef});next.leases.push({actorRef:observation.actorRef,taskId:observation.taskId,status:'active'});next.tasks.find(t=>t.id===assignment.taskId).status='assigned';
29
32
  validateWorkflowState(next);
30
33
  return {decision:'allow',reason:'matching observed spawn bound to pending assignment',state:next,proposedTransition:next};
@@ -36,7 +39,7 @@ export async function recordPlannerAgentObservation({statePath,expectedRevision,
36
39
  const parent=await fs.realpath(path.dirname(statePath));statePath=path.join(parent,path.basename(statePath));let lock;
37
40
  try{
38
41
  lock=await fs.open(statePath+'.lock','wx',0o600);const stat=await fs.lstat(statePath);if(!stat.isFile()||stat.isSymbolicLink())throw Error('Observation state must be regular file');
39
- const state=validateWorkflowState(JSON.parse(await fs.readFile(statePath,'utf8'))),eventHash=fingerprintRequest({input,observation:observation??null});
42
+ const state=validateWorkflowState(JSON.parse(await fs.readFile(statePath,'utf8')),{preserveStoredOperations:true}),eventHash=fingerprintRequest({input,observation:observation??null});
40
43
  if(state.plannerObservations?.some(o=>o.eventHash===eventHash))return {decision:'hold',reason:'Observation replay',proposedTransition:null,replayed:true};
41
44
  const candidates=state.assignments.filter(a=>a.status==='pending'&&a.role==='planner');
42
45
  let decision={decision:'hold',reason:'Raw event lacks verified assignment correlation',proposedTransition:null};
@@ -6,9 +6,16 @@ import {runtimeRegistryOf} from './platform-registry.mjs';
6
6
 
7
7
  const environments = new WeakMap();
8
8
  const authKinds = new WeakMap();
9
+ export function unknownPlatformMessage(platform, knownIds) {
10
+ const id = typeof platform === 'string'
11
+ ? [...platform.replace(/[\p{Cc}\u2028\u2029]/gu, '')].slice(0, 256).join('')
12
+ : '(invalid)';
13
+ return `Unknown platform: ${id}. Known platforms: ${knownIds.join(', ')}`;
14
+ }
9
15
  export function resolveConfigHome(platform, context = {}) {
10
- const descriptor = runtimeRegistryOf(context).getPlatform(platform);
11
- if (!descriptor) throw Error('Target must be codex or claude');
16
+ const registry = runtimeRegistryOf(context);
17
+ const descriptor = registry.getPlatform(platform);
18
+ if (!descriptor) throw Error(unknownPlatformMessage(platform, registry.byDisplayOrder().map(({id}) => id)));
12
19
  return descriptor.home.resolve(context);
13
20
  }
14
21
  export function resolveLocalCli(platform, { cwd, userHome, env = process.env, runtimePlatforms } = {}) {
@@ -1,6 +1,44 @@
1
1
  /** Canonical semantic operations, independent of platform tool aliases. */
2
- export const ROLES = Object.freeze(['orchestrator','scouter','planner','implementer','qa','reviewer']);
2
+ export const ROLES = Object.freeze(['orchestrator','scouter','planner','implementer','tester','reviewer']);
3
3
  export const GIT_OPERATIONS = Object.freeze(['stage','commit','push','merge','rebase','reset','branch-create','branch-switch','worktree-create','worktree-remove']);
4
4
  export const EXTERNAL_OPERATIONS = Object.freeze(['push','merge','deploy','publish','external-message']);
5
- export const OPERATIONS = Object.freeze(['read','draft','write','check','qa','review','temporary-write','operational-query','install','prepare-target','request-approval','assign-agent','accept','transition','scope-expansion','indirect-bypass',...new Set([...GIT_OPERATIONS,...EXTERNAL_OPERATIONS])]);
6
- export const ROLE_OPERATIONS = Object.freeze({orchestrator:['read','write','check','prepare-target','request-approval','assign-agent','accept','transition','install',...GIT_OPERATIONS,...EXTERNAL_OPERATIONS],scouter:['read'],planner:['read','draft'],implementer:['read','write','check'],qa:['read','check','temporary-write'],reviewer:['read','review']});
5
+ export const OPERATIONS = Object.freeze(['read','draft','write','check','test','review','temporary-write','operational-query','install','prepare-target','request-approval','assign-agent','accept','transition','scope-expansion','indirect-bypass',...new Set([...GIT_OPERATIONS,...EXTERNAL_OPERATIONS])]);
6
+ export const LEGACY_OPERATIONS = Object.freeze({qa: 'test'});
7
+ export const LEGACY_COOPERATIVE_ROLES = Object.freeze({qa: 'tester'});
8
+ export const ROLE_OPERATIONS = Object.freeze({orchestrator:['read','write','check','prepare-target','request-approval','assign-agent','accept','transition','install',...GIT_OPERATIONS,...EXTERNAL_OPERATIONS],scouter:['read'],planner:['read','draft'],implementer:['read','write','check'],tester:['read','check','temporary-write'],reviewer:['read','review']});
9
+
10
+ /** Compare a stored role without rewriting historical evidence. */
11
+ export function canonicalCooperativeRole(role) {
12
+ return typeof role === 'string' && Object.hasOwn(LEGACY_COOPERATIVE_ROLES, role) ? LEGACY_COOPERATIVE_ROLES[role] : role;
13
+ }
14
+
15
+ export const isLegacyOperation = operation => typeof operation === 'string' && Object.hasOwn(LEGACY_OPERATIONS, operation);
16
+ const currentOperation = operation => isLegacyOperation(operation) ? LEGACY_OPERATIONS[operation] : operation;
17
+
18
+ /** Interpret only the operation fields of stored state. Request inputs stay strict. */
19
+ export function normalizeStoredOperations(state) {
20
+ const normalizeList = operations => Array.isArray(operations) && operations.some(isLegacyOperation) ? operations.map(currentOperation) : operations;
21
+ const approvals = state.approvals.map(entry => {
22
+ const operations = normalizeList(entry?.scope?.operations);
23
+ return operations === entry?.scope?.operations ? entry : {...entry, scope: {...entry.scope, operations}};
24
+ });
25
+ const assignments = state.assignments.map(entry => {
26
+ const operations = normalizeList(entry?.operations);
27
+ return operations === entry?.operations ? entry : {...entry, operations};
28
+ });
29
+ const audit = state.audit.map(entry => isLegacyOperation(entry?.operation) ? {...entry, operation: currentOperation(entry.operation)} : entry);
30
+ if (approvals.some((entry, i) => entry !== state.approvals[i]) || assignments.some((entry, i) => entry !== state.assignments[i]) || audit.some((entry, i) => entry !== state.audit[i])) return {...state, approvals, assignments, audit};
31
+ return state;
32
+ }
33
+
34
+ /** Writes may retain aliases on existing history, but must use current names for new records. */
35
+ export function hasNewStoredOperationAliases(state, previous) {
36
+ const hasNewAlias = (operations, original) => Array.isArray(operations)
37
+ && operations.some((operation, index) => isLegacyOperation(operation) && operation !== original?.[index]);
38
+ const approvals = new Map(previous.approvals.map((entry, index) => [entry?.id ?? index, entry]));
39
+ const assignmentKey = (entry, index) => entry?.assignmentId ?? entry?.actorRef ?? entry?.intentId ?? index;
40
+ const assignments = new Map(previous.assignments.map((entry, index) => [assignmentKey(entry, index), entry]));
41
+ return state.approvals.some((entry, index) => hasNewAlias(entry?.scope?.operations, approvals.get(entry?.id ?? index)?.scope?.operations))
42
+ || state.assignments.some((entry, index) => hasNewAlias(entry?.operations, assignments.get(assignmentKey(entry, index))?.operations))
43
+ || state.audit.some((entry, index) => isLegacyOperation(entry?.operation) && entry.operation !== previous.audit[index]?.operation);
44
+ }
@@ -5,27 +5,27 @@ import {GROK_CONTRACT} from './grok-stream.mjs';
5
5
  import {GEMINI_CONTRACT} from './gemini-stream.mjs';
6
6
  import {DEFAULT_POLICY, effectiveClaudeSandboxSettings} from './role-dispatch-policy.mjs';
7
7
 
8
- const ROLES = ['arc_scouter', 'arc_planner', 'arc_implementer', 'arc_qa', 'arc_reviewer'];
8
+ const ROLES = ['arc_scouter', 'arc_planner', 'arc_implementer', 'arc_tester', 'arc_reviewer'];
9
9
  const deepFreeze = value => { for (const child of Object.values(value)) if (child && typeof child === 'object') deepFreeze(child); return Object.freeze(value); };
10
10
  export const ROLE_BRIDGE_PERMISSIONS = deepFreeze({
11
11
  claude: {
12
12
  arc_scouter: {permissionMode: 'default', sandbox: false}, arc_planner: {permissionMode: 'default', sandbox: false},
13
- arc_implementer: {permissionMode: 'acceptEdits', sandbox: true}, arc_qa: {permissionMode: 'default', sandbox: true}, arc_reviewer: {permissionMode: 'default', sandbox: false}
13
+ arc_implementer: {permissionMode: 'acceptEdits', sandbox: true}, arc_tester: {permissionMode: 'default', sandbox: true}, arc_reviewer: {permissionMode: 'default', sandbox: false}
14
14
  },
15
15
  gemini: {
16
16
  arc_scouter: {approvalMode: 'plan', sandbox: false}, arc_planner: {approvalMode: 'plan', sandbox: false},
17
- arc_implementer: {approvalMode: 'auto_edit', sandbox: true}, arc_qa: {approvalMode: 'auto_edit', sandbox: true}, arc_reviewer: {approvalMode: 'plan', sandbox: false}
17
+ arc_implementer: {approvalMode: 'auto_edit', sandbox: true}, arc_tester: {approvalMode: 'auto_edit', sandbox: true}, arc_reviewer: {approvalMode: 'plan', sandbox: false}
18
18
  },
19
19
  grok: {
20
20
  arc_scouter: {permissionMode: 'plan', sandbox: 'read-only', deny: GROK_CONTRACT.readOnlyDeny},
21
21
  arc_planner: {permissionMode: 'plan', sandbox: 'read-only', deny: GROK_CONTRACT.readOnlyDeny},
22
22
  arc_reviewer: {permissionMode: 'plan', sandbox: 'read-only', deny: GROK_CONTRACT.readOnlyDeny},
23
23
  arc_implementer: {permissionMode: 'acceptEdits', sandbox: 'custom', deny: []},
24
- arc_qa: {permissionMode: 'acceptEdits', sandbox: 'custom', deny: []},
24
+ arc_tester: {permissionMode: 'acceptEdits', sandbox: 'custom', deny: []},
25
25
  },
26
26
  codex: {
27
27
  arc_scouter: {sandboxMode: 'read-only', search: true}, arc_planner: {sandboxMode: 'read-only', search: false},
28
- arc_implementer: {sandboxMode: 'workspace-write', search: false}, arc_qa: {sandboxMode: 'workspace-write', search: false}, arc_reviewer: {sandboxMode: 'read-only', search: false}
28
+ arc_implementer: {sandboxMode: 'workspace-write', search: false}, arc_tester: {sandboxMode: 'workspace-write', search: false}, arc_reviewer: {sandboxMode: 'read-only', search: false}
29
29
  }
30
30
  });
31
31
 
@@ -4,6 +4,7 @@ import {runtimeRegistryOf, DEFAULT_PLATFORM_REGISTRY} from './platform-registry.
4
4
  import fsp from 'node:fs/promises';
5
5
  import path from 'node:path';
6
6
  import {DEFAULT_POLICY, HOST_SANDBOX_GATES, reason, profileName, bridgeGateReasons, environmentReasons, capabilityReasons} from './role-dispatch-policy.mjs';
7
+ import {displayRoutingRole} from './role-routing-config.mjs';
7
8
  import {readLease, writeLease, listLeases, readHostLimits, NON_TERMINAL_STATES, readHeartbeat, requestCancel, clearCancel, TERMINAL_STATES, validateLease} from './role-dispatch-store.mjs';
8
9
  import {withRoutingLock, readActivation, readRevision, authenticate, resolveRuntimeHomes, locateAnchorHome, probeHomeWritable} from './role-routing.mjs';
9
10
  import {SUPERVISOR_IMPLEMENTATIONS, startSupervisor, processAlive, resolveWorktree, artifactDirectory, segmentDirectory, buildBridgeInvocation, reapRecordedDescendants} from './role-supervisor.mjs';
@@ -25,10 +26,14 @@ export function leaseTargetPlatform(lease,registry=DEFAULT_PLATFORM_REGISTRY){
25
26
  return v1Platforms.find(id=>id!==lease.hostPlatform);
26
27
  }
27
28
  const supportOf=lease=>lease.route==='bridge'&&!String(lease.executionEnvironment).endsWith('-desktop')&&lease.state==='completed'&&lease.reasons.length===0&&['identity','model','effort','permissions','terminal'].every(key=>lease.claims?.[key]?.level==='runtime-observed')?'verified':'unverified';
29
+ const displayRoleOf=lease=>displayRoutingRole(lease.role)??lease.role;
28
30
  /** Result view of a lease. failed and unknown hold dependent work; every other observed state is reported as allow. */
29
31
  function fromLease(lease,decision=['failed','unknown'].includes(lease.state)?'hold':'allow',runtimePlatforms=DEFAULT_PLATFORM_REGISTRY){
30
32
  const platform=leaseTargetPlatform(lease,runtimePlatforms);
31
- return {decision,routeStatus:lease.state,supportStatus:supportOf(lease),dispatchId:lease.dispatchId,route:lease.route,profileName:profileName(platform,lease.role,{runtimePlatforms}),executionEnvironment:lease.executionEnvironment,hostPlatform:lease.hostPlatform,role:lease.role,requested:{platform,model:lease.claims?.model?.requested??null,effort:lease.claims?.effort?.requested??null},authentication:null,cliVersion:null,claims:lease.claims,reasons:lease.reasons,resultPath:lease.resultPath};
33
+ const role=displayRoleOf(lease);
34
+ const legacy=lease.role!==role;
35
+ const name=legacy&&/^arc[_-]routing[_-]/.test(lease.role)?lease.role:profileName(platform,legacy?'arc_qa':role,{runtimePlatforms});
36
+ return {decision,routeStatus:lease.state,supportStatus:supportOf(lease),dispatchId:lease.dispatchId,route:lease.route,profileName:name,executionEnvironment:lease.executionEnvironment,hostPlatform:lease.hostPlatform,role,requested:{platform,model:lease.claims?.model?.requested??null,effort:lease.claims?.effort?.requested??null},authentication:null,cliVersion:null,claims:lease.claims,reasons:lease.reasons,resultPath:lease.resultPath};
32
37
  }
33
38
  const residualOf=error=>Array.isArray(error?.residualPaths)?error.residualPaths:undefined;
34
39
  const hold=(context,dispatchId,code,error)=>{const result=blank(context,dispatchId,'hold',code);const residual=residualOf(error);if(residual)result.residualPaths=residual;return result;};
@@ -47,6 +52,7 @@ export async function runBridgeDispatch({context,dispatchId,brief,now=Date.now()
47
52
  await withRoutingLock(anchorHome,async()=>{
48
53
  const lease=await readLease(anchorHome,dispatchId,{runtimePlatforms});
49
54
  if(!lease||lease.workflowId!==context.workflowId||lease.hostPlatform!==context.hostPlatform||lease.route!=='bridge'||lease.state!=='reserved'){result=blank(context,dispatchId,'deny','invalid_request');return;}
55
+ if(displayRoleOf(lease)!==lease.role){result=blank(context,dispatchId,'deny','legacy_role_arc_qa');return;}
50
56
  const platform=leaseTargetPlatform(lease,runtimePlatforms);
51
57
  let config;try{config=await readActivation(homes,lease.revision,{anchorHome,host:context.hostPlatform,runtimePlatforms});}catch{result=blank(context,dispatchId,'hold','activation_unverified');return;}
52
58
  validateLease(lease,{runtimePlatforms,config});
@@ -145,7 +151,9 @@ export async function resumeRoleDispatch({context,dispatchId,brief,now=Date.now(
145
151
  try{
146
152
  await withRoutingLock(anchorHome,async()=>{
147
153
  const lease=await readLease(anchorHome,dispatchId,{runtimePlatforms});
148
- if(!lease||lease.workflowId!==context.workflowId||lease.hostPlatform!==context.hostPlatform||lease.route!=='bridge'||!['completed','failed'].includes(lease.state)){result=blank(context,dispatchId,'deny','invalid_request');return;}
154
+ if(!lease||lease.workflowId!==context.workflowId||lease.hostPlatform!==context.hostPlatform){result=blank(context,dispatchId,'deny','invalid_request');return;}
155
+ if(displayRoleOf(lease)!==lease.role){result=blank(context,dispatchId,'hold','legacy_role_resume_unsupported');return;}
156
+ if(lease.route!=='bridge'||!['completed','failed'].includes(lease.state)){result=blank(context,dispatchId,'deny','invalid_request');return;}
149
157
  const targetPlatform=leaseTargetPlatform(lease,runtimePlatforms);
150
158
  if((targetPlatform==='gemini'||targetPlatform==='grok')&&!['on','verified'].includes(supervisorImplementations.get(targetPlatform)?.resume)){result=blank(context,dispatchId,'hold','resume_unverified');return;}
151
159
  if(!lease.sessionId){result=blank(context,dispatchId,'hold','execution_identity_unverified');return;}
@@ -1,4 +1,4 @@
1
- import {runtimeRegistryOf} from './platform-registry.mjs';
1
+ import {byDisplayOrder, runtimeRegistryOf} from './platform-registry.mjs';
2
2
  // Fixed policy values for composite role dispatch. G2 'escalation' means the bridge runs only with per-call user escalation approval on a Codex host; it is not a verified pass.
3
3
  // GK2/GG2 'approval' means a Grok/Gemini host keeps its platform-default sandbox (off), runs in ask mode, and obtains user approval for each runtime command; it is not a verified pass.
4
4
  // GK2 evidence: Grok 1.0.89, 2026-11-19, ask mode with the sandbox off.
@@ -33,7 +33,7 @@ export const effectiveClaudeSandboxSettings = policy => policy?.gates?.G1 === 'p
33
33
  export const CATALOG_MODEL_ALIASES = Object.freeze(['fable', 'opus', 'sonnet', 'haiku']);
34
34
  export const CODEX_DELEGATION_CALL_NAMES = Object.freeze(['spawn_agent', 'wait_agent']);
35
35
  export const DESKTOP_CHECKLIST_PASSED = Object.freeze({'claude-desktop': false, 'codex-desktop': false});
36
- export const ROLE_TIMEOUT_MINUTES = Object.freeze({arc_scouter: 20, arc_planner: 20, arc_implementer: 60, arc_qa: 30, arc_reviewer: 20});
36
+ export const ROLE_TIMEOUT_MINUTES = Object.freeze({arc_scouter: 20, arc_planner: 20, arc_implementer: 60, arc_tester: 60, arc_reviewer: 20});
37
37
  export const HEARTBEAT_MS = 5000;
38
38
  export const SUPERVISOR_LOST_MS = 30000;
39
39
  export const OBSERVE_MAX_WAIT_MS = 540000;
@@ -65,6 +65,9 @@ export const DEFAULT_POLICY = Object.freeze({
65
65
  probeTimeoutMs: PROBE_TIMEOUT_MS
66
66
  });
67
67
 
68
+ const cliEnvironments = byDisplayOrder().flatMap(({executionEnvironments}) => executionEnvironments)
69
+ .filter(environment => environment.endsWith('-cli')).join(' or ');
70
+
68
71
  export const RELEASE_CONDITIONS = Object.freeze({
69
72
  activation_unverified: 'Verify the active configuration, all prepared markers, installed bytes, host limits and the shared lock, and inspect the lease records in <anchor home>/arc-role-dispatch for unreadable or corrupted files.',
70
73
  resume_unverified: 'Update ARC after verifying platform session resume against the recorded session UUID.',
@@ -72,12 +75,14 @@ export const RELEASE_CONDITIONS = Object.freeze({
72
75
  'Not Available': 'Install the target platform CLI so that it is found on PATH.',
73
76
  Unauthorized: 'Authenticate the target platform CLI.',
74
77
  Incomplete: 'Make the target platform CLI authentication status check complete successfully.',
75
- environment_unverified: 'Desktop hosts are held in this release. If this session is not running inside a Desktop app (for example a terminal or IDE terminal session), declare codex-cli or claude-cli instead; otherwise use a CLI host or a later ARC update that changes the support status.',
78
+ environment_unverified: `Desktop hosts are held in this release. If this session is not running inside a Desktop app (for example a terminal or IDE terminal session), declare a CLI environment (${cliEnvironments}) instead; otherwise use a CLI host or a later ARC update that changes the support status.`,
76
79
  host_sandbox_blocked: 'Allow the host to write the anchor home and keep a detached supervisor alive, with explicit user approval.',
77
80
  capacity_exhausted: 'Finish or release active bridge executions, or raise the host limits.',
78
81
  permission_scope_unverified: 'Update ARC and verify enforcement of the role permissions and approved scope before starting.',
79
82
  native_profile_reload_unverified: 'Verify that the host session loaded the requested profile revision.',
80
83
  revision_changed: 'Re-run routing-status and prepare a new dispatch under the current revision.',
84
+ legacy_role_resume_unsupported: 'Prepare a new arc_tester dispatch under the current routing revision.',
85
+ legacy_role_arc_qa: 'Use arc_tester when preparing a new dispatch.',
81
86
  duplicate_dispatch: 'Use a new requestId, or finish the existing dispatch for the same workflow, task and role.',
82
87
  invalid_request: 'Provide a valid request with exactly the documented keys.',
83
88
  permission_scope_mismatch: 'Inspect the recorded permission mismatch before dependent work.',
@@ -117,9 +122,9 @@ export function hostGateReasons({hostPlatform, policy = DEFAULT_POLICY}) {
117
122
 
118
123
  export function bridgeGateReasons({platform, role, hostPlatform, policy = DEFAULT_POLICY}) {
119
124
  const gates = policy.gates ?? BRIDGE_GATE_RESULTS, codes = [];
120
- if (platform === 'claude' && (role === 'arc_implementer' || role === 'arc_qa') && effectiveClaudeSandboxSettings({gates, claudeSandboxSettings: policy.claudeSandboxSettings}) === null) codes.push('permission_scope_unverified');
121
- if (platform === 'gemini' && (role === 'arc_implementer' || role === 'arc_qa') && gates.GG1 !== 'pass') codes.push('permission_scope_unverified');
122
- if (platform === 'grok' && (role === 'arc_implementer' || role === 'arc_qa') && gates.GK1 !== 'pass') codes.push('permission_scope_unverified');
125
+ if (platform === 'claude' && (role === 'arc_implementer' || role === 'arc_tester') && effectiveClaudeSandboxSettings({gates, claudeSandboxSettings: policy.claudeSandboxSettings}) === null) codes.push('permission_scope_unverified');
126
+ if (platform === 'gemini' && (role === 'arc_implementer' || role === 'arc_tester') && gates.GG1 !== 'pass') codes.push('permission_scope_unverified');
127
+ if (platform === 'grok' && (role === 'arc_implementer' || role === 'arc_tester') && gates.GK1 !== 'pass') codes.push('permission_scope_unverified');
123
128
  codes.push(...hostGateReasons({hostPlatform, policy}));
124
129
  if (platform === 'codex' && gates.G4 === 'fail') codes.push('permission_scope_unverified');
125
130
  if (hostPlatform === 'codex' && gates.G2 === 'fail') codes.push('host_sandbox_blocked');
@@ -4,6 +4,7 @@ import fsp from 'node:fs/promises';
4
4
  import path from 'node:path';
5
5
  import crypto from 'node:crypto';
6
6
  import {runtimeRegistryOf} from './platform-registry.mjs';
7
+ import {displayRoutingRole} from './role-routing-config.mjs';
7
8
 
8
9
  export const NON_TERMINAL_STATES = Object.freeze(['reserved', 'starting', 'running', 'unknown']);
9
10
  export const TERMINAL_STATES = Object.freeze(['completed', 'failed', 'cancelled']);
@@ -48,6 +49,8 @@ export async function ensureDispatchDirectory(codexHome, {uid = process.getuid?.
48
49
  }
49
50
  export async function createLease(codexHome, lease, options) {
50
51
  const value = validateLease(lease, options);
52
+ const role = displayRoutingRole(value.role);
53
+ if (role !== null && role !== value.role) throw Error('Cannot create a lease with a legacy dispatch role');
51
54
  await ensureDispatchDirectory(codexHome);
52
55
  const handle = await fsp.open(leasePath(codexHome, value.dispatchId), 'wx', 0o600);
53
56
  try { await handle.writeFile(JSON.stringify(value, null, 2) + '\n'); await handle.sync(); } finally { await handle.close(); }
@@ -608,7 +608,7 @@ export async function observeHeadAdvance(root, before, after, role, allowedPaths
608
608
  }
609
609
  const paths = [...uniquePaths].sort();
610
610
  const allowed = Array.isArray(allowedPaths) ? allowedPaths : [];
611
- if (role === 'arc_implementer' || (role === 'arc_qa' && allowed.length)) {
611
+ if (role === 'arc_implementer' || (role === 'arc_tester' && allowed.length)) {
612
612
  const outOfScopePaths = paths.filter(file => !allowedBy(allowed, file));
613
613
  if (outOfScopePaths.length) return {...reject('out_of_scope'), outOfScopePaths};
614
614
  }
@@ -624,10 +624,10 @@ export async function observeHeadAdvance(root, before, after, role, allowedPaths
624
624
  * git:info/refs are tolerated and returned separately from violations.
625
625
  * Other HEAD changes and branch switches are violations.
626
626
  * Any other ref creation, deletion or movement is a violation.
627
- * Implementer and QA may change only allowedPaths in the worktree; with an
627
+ * Implementer and Tester may change only allowedPaths in the worktree; with an
628
628
  * empty or missing list they may change no worktree paths. Fast-forward
629
- * commit paths must stay within allowedPaths for Implementer and for QA with a
630
- * non-empty list; QA with an empty or missing list, like read-only roles, may
629
+ * commit paths must stay within allowedPaths for Implementer and for Tester with a
630
+ * non-empty list; Tester with an empty or missing list, like read-only roles, may
631
631
  * land a verified fast-forward touching any path.
632
632
  * Read-only roles may change no worktree paths beyond verified fast-forward
633
633
  * commits. Ordinary worktree snapshots omit Git-ignored paths. Control files
@@ -656,7 +656,7 @@ export function detectViolations({role, allowedPaths, before, after, headAdvance
656
656
  refsChanged = true;
657
657
  }
658
658
  }
659
- const allowed = (role === 'arc_implementer' || role === 'arc_qa') && Array.isArray(allowedPaths) ? allowedPaths : [];
659
+ const allowed = (role === 'arc_implementer' || role === 'arc_tester') && Array.isArray(allowedPaths) ? allowedPaths : [];
660
660
  const changed = new Set();
661
661
  for (const file of new Set([...before.entries.keys(), ...after.entries.keys()])) {
662
662
  if (before.entries.get(file) !== after.entries.get(file) && !allowedBy(allowed, file)) changed.add(file);
@@ -1,6 +1,8 @@
1
1
  import {runtimeRegistryOf} from './platform-registry.mjs';
2
2
 
3
- export const ROUTING_ROLES = Object.freeze(['arc_scouter', 'arc_planner', 'arc_implementer', 'arc_qa', 'arc_reviewer']);
3
+ export const ROUTING_ROLES = Object.freeze(['arc_scouter', 'arc_planner', 'arc_implementer', 'arc_tester', 'arc_reviewer']);
4
+ export const LEGACY_ROUTING_ROLES = Object.freeze({arc_qa: 'arc_tester'});
5
+ export const ROUTING_CONFIG_VERSION = 3;
4
6
  const validText = value => typeof value === 'string' && value.length > 0 && value === value.trim() && !/[\p{Cc}\u2028\u2029]/u.test(value);
5
7
  const exact = (value, keys) => value && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length === keys.length && keys.every(key => Object.hasOwn(value, key));
6
8
  const v1Platforms = Object.freeze(['codex', 'claude']);
@@ -8,22 +10,34 @@ const isV1Platforms = platforms => platforms.length === v1Platforms.length && v1
8
10
  // Keep injected validation context out of the public config and serialized bytes.
9
11
  const configRegistries = new WeakMap();
10
12
 
13
+ export function displayRoutingRole(role) {
14
+ if (ROUTING_ROLES.includes(role)) return role;
15
+ if (typeof role === 'string' && /^arc[_-](?:routing[_-])?qa$/.test(role)) return LEGACY_ROUTING_ROLES.arc_qa;
16
+ return null;
17
+ }
18
+
11
19
  export function validRoleValues(platform, model, effort, {runtimePlatforms} = {}) {
12
20
  const registry = runtimeRegistryOf({runtimePlatforms});
13
21
  return registry.isPlatformId(platform) && registry.getPlatform(platform).routing.validatePair(model, effort);
14
22
  }
15
23
  export function validateRoleRoutingConfig(config, opts = {}) {
16
24
  const keys = ['version', 'revision', 'platforms', 'roles'];
17
- if (!(exact(config, keys) || (config?.version === 1 && exact(config, ['version', 'revision', 'roles']))) || ![1, 2].includes(config.version) || !validText(config.revision) || !exact(config.roles, ROUTING_ROLES)) throw Error('Invalid role routing configuration');
25
+ if (!(exact(config, keys) || (config?.version === 1 && exact(config, ['version', 'revision', 'roles']))) || ![1, 2, ROUTING_CONFIG_VERSION].includes(config.version) || !validText(config.revision)) throw Error('Invalid role routing configuration');
26
+ let roles = config.roles;
27
+ if (roles && typeof roles === 'object' && !Array.isArray(roles) && Object.hasOwn(roles, 'arc_qa')) {
28
+ if (config.version === ROUTING_CONFIG_VERSION || Object.hasOwn(roles, 'arc_tester')) throw Error('Invalid role routing configuration');
29
+ roles = Object.fromEntries(Object.entries(roles).map(([role, fields]) => [Object.hasOwn(LEGACY_ROUTING_ROLES, role) ? LEGACY_ROUTING_ROLES[role] : role, fields]));
30
+ }
31
+ if (!exact(roles, ROUTING_ROLES)) throw Error('Invalid role routing configuration');
18
32
  const registry = runtimeRegistryOf(opts);
19
33
  const platforms = config.version === 1 && !Object.hasOwn(config, 'platforms') ? [...v1Platforms] : config.platforms;
20
34
  if (!Array.isArray(platforms) || platforms.length < 2 || new Set(platforms).size !== platforms.length || platforms.some(id => !registry.isPlatformId(id))) throw Error('Invalid role routing platforms');
21
35
  if (platforms.some((id, index) => index > 0 && registry.getPlatform(platforms[index - 1]).anchorOrder >= registry.getPlatform(id).anchorOrder) || (config.version === 1 && !isV1Platforms(platforms))) throw Error('Invalid role routing platforms');
22
36
  for (const role of ROUTING_ROLES) {
23
- const fields = config.roles[role];
37
+ const fields = roles[role];
24
38
  if (!exact(fields, ['platform', 'model', 'effort']) || !validRoleValues(fields.platform, fields.model, fields.effort, opts) || !platforms.includes(fields.platform)) throw Error(`Invalid role routing values for ${role}`);
25
39
  }
26
- const result = structuredClone({version: config.version, revision: config.revision, platforms, roles: config.roles});
40
+ const result = structuredClone({version: config.version, revision: config.revision, platforms, roles});
27
41
  configRegistries.set(result, registry);
28
42
  return result;
29
43
  }
@@ -33,7 +47,7 @@ export function parseRoleRoutingConfig(text, opts) {
33
47
  }
34
48
  export function serializeRoleRoutingConfig(config) {
35
49
  const {revision, platforms, roles} = validateRoleRoutingConfig(config, {runtimePlatforms: configRegistries.get(config)});
36
- const value = {version: 2, revision, platforms, roles};
50
+ const value = {version: ROUTING_CONFIG_VERSION, revision, platforms, roles};
37
51
  return JSON.stringify(value, null, 2) + '\n';
38
52
  }
39
53
  export function buildRoleRoutingConfig({revision, platforms = [], roles}, opts = {}) {
@@ -42,5 +56,5 @@ export function buildRoleRoutingConfig({revision, platforms = [], roles}, opts =
42
56
  const participating = [...new Set([...platforms, ...Object.values(roles).map(fields => fields.platform)])];
43
57
  if (participating.some(id => !registry.isPlatformId(id))) throw Error('Invalid role routing platforms');
44
58
  participating.sort((a, b) => registry.getPlatform(a).anchorOrder - registry.getPlatform(b).anchorOrder);
45
- return validateRoleRoutingConfig({version: 2, revision, platforms: participating, roles}, opts);
59
+ return validateRoleRoutingConfig({version: ROUTING_CONFIG_VERSION, revision, platforms: participating, roles}, opts);
46
60
  }
@@ -6,7 +6,7 @@ import crypto from 'node:crypto';
6
6
  import {COOPERATIVE_RUNTIME_MODULES, cooperativeVersions} from './bootstrap.mjs';
7
7
  import {inspectPath} from './scope.mjs';
8
8
  import {resolveConfigHome, resolveLocalCli, probePlatformAuth, probeCodexAuthStatus, probeCliVersion} from './local-cli.mjs';
9
- import {ROUTING_ROLES, parseRoleRoutingConfig} from './role-routing-config.mjs';
9
+ import {LEGACY_ROUTING_ROLES, ROUTING_ROLES, parseRoleRoutingConfig} from './role-routing-config.mjs';
10
10
  import {DEFAULT_POLICY, HOST_SANDBOX_GATES, reason, profileName, revisionTag, hostGateReasons, bridgeGateReasons, environmentReasons, initialClaims, capabilityReasons} from './role-dispatch-policy.mjs';
11
11
  import {NON_TERMINAL_STATES, createLease, listLeases, pruneTerminalLeases, readHostLimits} from './role-dispatch-store.mjs';
12
12
  import {allowedPathsCoverControl, claudeProjectSettingsWidenScope, resolveWorktree} from './role-observe.mjs';
@@ -172,7 +172,7 @@ function validateAssignment(assignment,expectedRevision,context){
172
172
  const paths=assignment.allowedPaths;
173
173
  if(role==='arc_implementer')return Array.isArray(paths)&&paths.length>0&&paths.every(validRelativePath);
174
174
  if(paths===undefined)return true;
175
- return role==='arc_qa'&&Array.isArray(paths)&&paths.every(validRelativePath);
175
+ return role==='arc_tester'&&Array.isArray(paths)&&paths.every(validRelativePath);
176
176
  }
177
177
  const blankResult=(host,environment,role)=>({decision:'hold',routeStatus:'held',supportStatus:'unverified',dispatchId:null,route:null,profileName:null,executionEnvironment:environment,hostPlatform:host,role,requested:null,authentication:null,cliVersion:null,claims:null,reasons:[]});
178
178
  const classify=error=>{
@@ -230,6 +230,7 @@ export async function routingStatus({context,now=Date.now(),policy=DEFAULT_POLIC
230
230
  export async function prepareRoleDispatch({context,assignment,expectedRevision,now=Date.now(),policy=DEFAULT_POLICY}={}){
231
231
  const host=hostOf(context),environment=environmentOf(context,host),role=ROUTING_ROLES.includes(assignment?.role)?assignment.role:null;
232
232
  const result=blankResult(host,environment,role);
233
+ if(typeof assignment?.role==='string'&&Object.hasOwn(LEGACY_ROUTING_ROLES,assignment.role)){result.decision='deny';result.reasons=[reason('legacy_role_arc_qa')];return result;}
233
234
  if(!host||!environment||!validateAssignment(assignment,expectedRevision,context)){result.decision='deny';result.reasons=[reason('invalid_request')];return result;}
234
235
  const codes=new Set();let duplicate=false,anchorHome;
235
236
  const homes=resolveRuntimeHomes(context),runtimePlatforms=runtimeRegistryOf(context);
@@ -241,7 +242,7 @@ export async function prepareRoleDispatch({context,assignment,expectedRevision,n
241
242
  const requested=config.roles[role],route=requested.platform===host?'native':'bridge';
242
243
  result.requested={...requested};result.route=route;result.profileName=profileName(requested.platform,role,{runtimePlatforms});
243
244
  if(route==='bridge'&&allowedPathsCoverControl(assignment.allowedPaths??[])){result.reasons=[reason('permission_scope_unverified')];return;}
244
- if(route==='bridge'&&requested.platform==='claude'&&(role==='arc_implementer'||role==='arc_qa')){
245
+ if(route==='bridge'&&requested.platform==='claude'&&(role==='arc_implementer'||role==='arc_tester')){
245
246
  const target=typeof context.cwd==='string'?await resolveWorktree(context.cwd).catch(()=>null):null;
246
247
  if(!target||await claudeProjectSettingsWidenScope(target.realpath)){result.reasons=[reason('permission_scope_unverified')];return;}
247
248
  }
@@ -26,7 +26,7 @@ import {isPlatformId} from './platform-registry.mjs';
26
26
  * @property {Array<object>} [facts] Provider-confirmed facts tied to state and source references.
27
27
  */
28
28
  import path from 'node:path';
29
- import {ROLES, OPERATIONS} from './operations.mjs';
29
+ import {ROLES, OPERATIONS, canonicalCooperativeRole, hasNewStoredOperationAliases, normalizeStoredOperations} from './operations.mjs';
30
30
  const fail = message => {throw new Error(`Runtime schema: ${message}`);};
31
31
  export const object = value => value !== null && typeof value === 'object' && !Array.isArray(value);
32
32
  export const text = value => typeof value === 'string' && value.length > 0;
@@ -36,7 +36,7 @@ const absolute = value => text(value) && path.isAbsolute(value) && path.normaliz
36
36
  const unique = (items,key) => items.every(x=>object(x)&&text(x[key])) && new Set(items.map(x=>x[key])).size===items.length;
37
37
  function approval(a){return object(a)&&text(a.id)&&['user-message','human-confirmation'].includes(a.source)&&text(a.messageRef)&&hash(a.contentHash)&&object(a.scope)&&text(a.scope.taskId)&&absolute(a.scope.target)&&strings(a.scope.operations)&&a.scope.operations.every(op=>OPERATIONS.includes(op))&&strings(a.scope.paths)&&a.scope.paths.every(absolute);}
38
38
  /** Validate stored workflow data. Observed provenance must still be checked by evaluate. */
39
- export function validateWorkflowState(s){
39
+ export function validateWorkflowState(s,{allowLegacyOperations=true,preserveStoredOperations=false,legacyOperationsFrom}={}){
40
40
  if(object(s)&&s.workflowKind!==undefined)fail('provider state cannot use cooperative contract');
41
41
  if(!object(s)||s.schemaVersion!==1||!text(s.workflowId)||!Number.isSafeInteger(s.revision)||s.revision<0)fail('version or identity');
42
42
  if(!object(s.versions)||['policy','runtime','adapter','policyHash','runtimeHash','adapterHash'].some(k=>!text(s.versions[k])))fail('versions');
@@ -44,11 +44,14 @@ export function validateWorkflowState(s){
44
44
  if(!object(s.target)||!absolute(s.target.realpath)||['repository','worktree','baseHead','head'].some(k=>!text(s.target[k]))||!(s.target.branch===null||text(s.target.branch)))fail('target');
45
45
  if(!['plan','small-task','no-plan'].includes(s.mode))fail('mode');
46
46
  for(const k of ['documents','approvals','tasks','assignments','identities','leases','checks','findings','acceptances','commits','audit','capabilities','requests'])if(!Array.isArray(s[k]))fail(k);
47
+ const stored=s,normalized=normalizeStoredOperations(s);
48
+ if(!allowLegacyOperations&&normalized!==s&&(!legacyOperationsFrom||hasNewStoredOperationAliases(s,legacyOperationsFrom)))fail('legacy operation in new state');
49
+ s=normalized;
47
50
  if(!unique(s.tasks,'id')||s.tasks.some(t=>!['pending','assigned','rework','verification','accepted','committed'].includes(t.status)||!strings(t.paths)||t.paths.some(p=>!absolute(p))||!strings(t.dependencies)||!text(t.baseCommit)||!strings(t.criteria)||!strings(t.requiredChecks)))fail('tasks');
48
51
  if(!unique(s.approvals,'id')||s.approvals.some(a=>!approval(a)))fail('approval provenance');
49
- if(!unique(s.identities,'actorRef')||s.identities.some(i=>!ROLES.includes(i.role)||!text(i.taskId)||!text(i.observationRef)))fail('identity');
52
+ if(!unique(s.identities,'actorRef')||s.identities.some(i=>!ROLES.includes(canonicalCooperativeRole(i.role))||!text(i.taskId)||!text(i.observationRef)))fail('identity');
50
53
  if(!unique(s.leases,'actorRef')||s.leases.some(l=>!text(l.taskId)||!['active','suspended','retired'].includes(l.status)))fail('lease');
51
- if(s.assignments.some(a=>!object(a)||!((a.status==='pending'&&a.actorRef===null&&text(a.assignmentId)&&text(a.correlationRef)&&text(a.requestId)&&text(a.requestedBy)&&isPlatformId(a.platform))||text(a.actorRef))||!text(a.taskId)||!ROLES.includes(a.role)||!strings(a.paths)||a.paths.some(p=>!absolute(p))||!strings(a.operations)||a.operations.some(op=>!OPERATIONS.includes(op))||!text(a.approvalRef)))fail('assignment');
54
+ if(s.assignments.some(a=>!object(a)||!((a.status==='pending'&&a.actorRef===null&&text(a.assignmentId)&&text(a.correlationRef)&&text(a.requestId)&&text(a.requestedBy)&&isPlatformId(a.platform))||text(a.actorRef))||!text(a.taskId)||!ROLES.includes(canonicalCooperativeRole(a.role))||!strings(a.paths)||a.paths.some(p=>!absolute(p))||!strings(a.operations)||a.operations.some(op=>!OPERATIONS.includes(op))||!text(a.approvalRef)))fail('assignment');
52
55
  for(const a of s.assignments){
53
56
  if(a.checks!==undefined&&(!Array.isArray(a.checks)||a.checks.some(c=>!object(c)||!absolute(c.executable)||!Array.isArray(c.args)||!c.args.every(x=>typeof x==='string')||!absolute(c.cwd)||!object(c.env)||!strings(c.outputs)||c.outputs.some(p=>!absolute(p)))))fail('check descriptor');
54
57
  if(a.temporary!==undefined&&(!object(a.temporary)||!strings(a.temporary.paths)||a.temporary.paths.some(p=>!absolute(p))||!text(a.temporary.cleanupOwner)||!Number.isFinite(Date.parse(a.temporary.expiresAt))))fail('temporary assignment');
@@ -61,7 +64,7 @@ export function validateWorkflowState(s){
61
64
  if(s.commits.some(c=>!object(c)||!text(c.purpose)||!text(c.taskId)||!text(c.expectedParent)||!text(c.expectedTree)))fail('commits');
62
65
  if(s.requests.some(r=>!object(r)||!text(r.requestId)||!hash(r.requestFingerprint)||!object(r.decision))||new Set(s.requests.map(r=>r.requestId)).size!==s.requests.length)fail('request replay');
63
66
  if(s.plannerLedger!==undefined){validatePlannerLedger(s.plannerLedger);if(s.plannerLedger.stages.some(stage=>stage.workflowId!==s.workflowId))fail('Planner workflow binding');}
64
- return s;
67
+ return preserveStoredOperations?stored:s;
65
68
  }
66
69
  export function validateRequest(r){
67
70
  if(!object(r)||['requestId','actorRef','taskId','toolName'].some(k=>!text(r[k]))||!isPlatformId(r.platform)||!OPERATIONS.includes(r.operation)||!absolute(r.cwd)||!object(r.arguments)||!object(r.descriptor)||!strings(r.paths)||r.paths.some(p=>!absolute(p)))fail('request');
@@ -11,7 +11,7 @@ export async function inspectPath(filename,{missing=false,directory=false}={}){
11
11
  for(let i=0;i<parts.length;i++){
12
12
  cursor=path.join(cursor,parts[i]);let stat;
13
13
  try{stat=await fs.lstat(cursor);}catch(error){if(missing&&error.code==='ENOENT')return;throw error;}
14
- if(stat.isSymbolicLink())throw Error('Unsafe symlink path');
14
+ if(stat.isSymbolicLink())throw Object.assign(Error('Unsafe symlink path'),{symlinkPath:cursor});
15
15
  if(i<parts.length-1||directory){if(!stat.isDirectory())throw Error('Unsafe directory type');}
16
16
  else if(!stat.isFile())throw Error('State must be a regular file');
17
17
  }
@@ -27,7 +27,7 @@ export async function transactWorkflow({statePath,expectedRevision,requestId,req
27
27
  try{
28
28
  lock=await fs.open(lockPath,'wx',0o600);
29
29
  const stat=await fs.lstat(statePath);if(!stat.isFile()||stat.isSymbolicLink())throw Error('State must be regular file');
30
- const state=validateWorkflowState(JSON.parse(await fs.readFile(statePath,'utf8')));
30
+ const state=validateWorkflowState(JSON.parse(await fs.readFile(statePath,'utf8')),{preserveStoredOperations:true});
31
31
  const prior=state.requests.find(r=>r.requestId===requestId);
32
32
  let decision;
33
33
  if(prior){
@@ -52,7 +52,7 @@ export async function transactWorkflow({statePath,expectedRevision,requestId,req
52
52
  for(const old of state.leases){const current=next.leases.find(l=>l.actorRef===old.actorRef);if(old.status==='retired'&&(!current||current.status!=='retired'||current.taskId!==old.taskId))throw Error('Retired lease revival forbidden');}
53
53
  next.revision=state.revision+1;next.requests=prior?state.requests.map(r=>r.requestId===requestId?{requestId,requestFingerprint,decision}:r):[...state.requests,{requestId,requestFingerprint,decision}];
54
54
  next.audit=[...state.audit,{requestId,revision:next.revision,decision:decision.decision,ruleIds:decision.ruleIds??[],result:'pending'}];
55
- validateWorkflowState(next);
55
+ validateWorkflowState(next,{allowLegacyOperations:false,legacyOperationsFrom:state});
56
56
  await saveDurableState({statePath,state:next});
57
57
  return {state:next,decision,replayed:false};
58
58
  }finally{
@@ -5,6 +5,8 @@ import {createHash} from 'node:crypto';
5
5
  import {spawnSync} from 'node:child_process';
6
6
  import {fingerprintRequest} from './store.mjs';
7
7
  import {absolute,within,inspectPath} from './scope.mjs';
8
+ import {legacyCooperativeRoleDenial} from './cooperative-schema.mjs';
9
+ import {canonicalCooperativeRole} from './operations.mjs';
8
10
  const same=(a,b)=>JSON.stringify(a)===JSON.stringify(b);
9
11
  const text=v=>typeof v==='string'&&v.length>0;
10
12
  const hash=v=>typeof v==='string'&&/^sha256:[a-f0-9]{64}$/.test(v);
@@ -27,7 +29,8 @@ const assignedImplementer=(state,id,taskId)=>state.assignments.some(a=>a.agentId
27
29
  function independent(state,actor,taskId){
28
30
  if(!fields(actor,['id','role'])||!text(actor.id))return false;
29
31
  if(state.assignments.some(a=>a.agentId===actor.id))return false;
30
- return !(state.intents??[]).some(i=>i.verificationActor?.id===actor.id&&(i.verificationActor.role!==actor.role||actor.role==='qa'&&i.taskId!==taskId))&&!(state.checks??[]).some(c=>c.verificationActor?.id===actor.id&&(c.verificationActor.role!==actor.role||actor.role==='qa'&&c.taskId!==taskId));
32
+ const conflicts=entry=>entry.verificationActor?.id===actor.id&&(canonicalCooperativeRole(entry.verificationActor.role)!==actor.role||actor.role==='tester'&&entry.taskId!==taskId);
33
+ return !(state.intents??[]).some(conflicts)&&!(state.checks??[]).some(conflicts);
31
34
  }
32
35
  /** Invalidate only the affected dependency closure; preserve all historical evidence. */
33
36
  export function invalidateAffectedEvidence({state,changedVersions={},affectedTaskIds}={}){
@@ -62,6 +65,8 @@ function record({state,request,evidence}){
62
65
  }
63
66
  /** Pure cooperative gate: verifies recorded consistency, never identity or semantic sufficiency. */
64
67
  export function evaluateCooperativeVerification({state,request,evidence}={}){
68
+ const denial=legacyCooperativeRoleDenial(request);
69
+ if(denial)return {...base(state),...denial};
65
70
  if(state?.mode!=='plan')return hold(state,'unsupported','Only the complete spec and plan path is supported');
66
71
  if(!request||request.expectedRevision!==state.revision)return hold(state,'revision','Stale verification request');
67
72
  if(request.actor?.role!=='orchestrator')return hold(state,'verification-actor','Orchestrator statement required');
@@ -73,11 +78,11 @@ export function evaluateCooperativeVerification({state,request,evidence}={}){
73
78
  if(a.scope==='task'&&(!authorized(state,t)||t.status==='held'||request.operation==='review'||!t.requiredChecks.some(d=>same(d,a.descriptor))))return hold(state,'verification-task','Current task approval and exact assigned check required; Reviewer is final only');
74
79
  if(a.scope==='final'&&(request.taskId!==undefined||request.operation!=='review'||!state.tasks.length||state.tasks.some(t=>!authorized(state,t)||!['accepted','committed'].includes(t.status))))return hold(state,'verification-final','Final review follows accepted tasks and required task checks');
75
80
  const finalCorrection=a.scope==='final'&&state.findings.some(f=>f.origin==='final-review'&&f.status==='resolved'&&a.findingIds?.includes(f.id));
76
- if(a.scope==='final'&&!finalCorrection&&state.tasks.some(task=>task.requiredChecks.some(descriptor=>!state.checks.some(c=>c.scope==='task'&&c.taskId===task.id&&c.operation==='check'&&!c.stale&&c.status==='passed'&&c.verdict==='proven'&&text(c.resultRef)&&c.verificationActor?.role==='qa'&&same(c.descriptor,descriptor)&&(c.changeFingerprint===evidence.changes?.tasks?.[task.id]||task.status==='committed'&&state.commits?.some(commit=>commit.taskId===task.id&&commit.observationSource==='local-git'&&commit.fingerprint===c.changeFingerprint&&commit.postCommitFingerprint===evidence.changes?.tasks?.[task.id]))))))return hold(state,'verification-final-checks','Initial final review requires current task QA evidence');
77
- if(a.actor?.role!==(request.operation==='review'?'reviewer':'qa')||a.actor.id===request.actor.id||!independent(state,a.actor,request.taskId))return hold(state,'verification-independence','Independent actor statement and fresh task QA required');
81
+ if(a.scope==='final'&&!finalCorrection&&state.tasks.some(task=>task.requiredChecks.some(descriptor=>!state.checks.some(c=>c.scope==='task'&&c.taskId===task.id&&c.operation==='check'&&!c.stale&&c.status==='passed'&&c.verdict==='proven'&&text(c.resultRef)&&canonicalCooperativeRole(c.verificationActor?.role)==='tester'&&same(c.descriptor,descriptor)&&(c.changeFingerprint===evidence.changes?.tasks?.[task.id]||task.status==='committed'&&state.commits?.some(commit=>commit.taskId===task.id&&commit.observationSource==='local-git'&&commit.fingerprint===c.changeFingerprint&&commit.postCommitFingerprint===evidence.changes?.tasks?.[task.id]))))))return hold(state,'verification-final-checks','Initial final review requires current task Tester evidence');
82
+ if(a.actor?.role!==(request.operation==='review'?'reviewer':'tester')||a.actor.id===request.actor.id||!independent(state,a.actor,request.taskId))return hold(state,'verification-independence','Independent actor statement and fresh task Tester required');
78
83
  const findings=state.findings.filter(f=>f.status!=='closed'&&(a.scope==='final'||f.scope==='task'&&f.taskId===request.taskId));
79
84
  if(a.findingIds!==undefined&&(!list(a.findingIds)||a.findingIds.some(id=>!findings.some(f=>f.id===id))))return hold(state,'finding-recheck','Unknown finding recheck');
80
- if(findings.some(f=>f.status!=='resolved'||!text(f.resolutionRef)||f.resolutionActor?.role!=='implementer'||f.changeFingerprint!==a.changeFingerprint||!a.findingIds?.includes(f.id)||f.origin==='final-review'&&request.operation!=='review'||f.origin!=='final-review'&&request.operation!=='check'))return hold(state,'finding-recheck','Implementer resolution and the required QA or final Reviewer recheck required');
85
+ if(findings.some(f=>f.status!=='resolved'||!text(f.resolutionRef)||f.resolutionActor?.role!=='implementer'||f.changeFingerprint!==a.changeFingerprint||!a.findingIds?.includes(f.id)||f.origin==='final-review'&&request.operation!=='review'||f.origin!=='final-review'&&request.operation!=='check'))return hold(state,'finding-recheck','Implementer resolution and the required Tester or final Reviewer recheck required');
81
86
  if(state.intents.some(i=>['check','review'].includes(i.operation)&&['prepared','unknown','mismatch'].includes(i.status)&&i.scope===a.scope&&i.taskId===request.taskId&&same(i.descriptor,a.descriptor)&&!i.stale))return hold(state,'verification-active','Reconcile the existing verification intent');
82
87
  const intent={requestId:request.requestId,operation:request.operation,status:'prepared',scope:a.scope,taskId:request.taskId,verificationActor:structuredClone(a.actor),descriptor:structuredClone(a.descriptor),changeFingerprint:a.changeFingerprint,findingIds:[...(a.findingIds??[])],scopeVersion:state.scopeVersion,targetVersion:state.targetVersion,versions:structuredClone(state.versions),target:structuredClone(state.target),approval:structuredClone(approval(state,request.taskId)),taskFingerprint:fingerprintRequest(a.scope==='final'?state.tasks:t),fingerprint:fingerprintRequest(request),source:'operator-attested'};
83
88
  return allow(state,{intent});
@@ -85,10 +90,13 @@ export function evaluateCooperativeVerification({state,request,evidence}={}){
85
90
  function outcome({state,request,evidence}){
86
91
  const intent=state.intents.find(i=>i.requestId===request.intentId),r=request.result,d=r?.data;
87
92
  if(!intent||!['check','review'].includes(intent.operation)||!['prepared','unknown','mismatch'].includes(intent.status))return hold(state,'verification-intent','Matching unresolved verification intent required');
88
- const valid=r&&['succeeded','failed','unknown','mismatch'].includes(r.status)&&text(r.messageRef)&&fields(d,['actor','descriptor','scope','taskId','changeFingerprint','verdict'])&&['proven','unmet','unverified'].includes(d.verdict)&&same(d.actor,intent.verificationActor)&&same(d.descriptor,intent.descriptor)&&d.scope===intent.scope&&d.taskId===intent.taskId&&d.changeFingerprint===intent.changeFingerprint;
89
- const fresh=!intent.stale&&intent.changeFingerprint===current(state,intent.scope,intent.taskId,evidence?.changes)&&(intent.scope==='task'||intent.scopeVersion===state.scopeVersion)&&intent.targetVersion===state.targetVersion&&same(intent.target,state.target)&&same(intent.versions,state.versions)&&independent(state,intent.verificationActor,intent.taskId)&&same(intent.approval,approval(state,intent.taskId))&&intent.taskFingerprint===fingerprintRequest(intent.scope==='final'?state.tasks:state.tasks.find(t=>t.id===intent.taskId));
93
+ const storedActor=intent.verificationActor;
94
+ const role=canonicalCooperativeRole(storedActor?.role);
95
+ const verificationActor=role===storedActor?.role?storedActor:{...storedActor,role};
96
+ const valid=r&&['succeeded','failed','unknown','mismatch'].includes(r.status)&&text(r.messageRef)&&fields(d,['actor','descriptor','scope','taskId','changeFingerprint','verdict'])&&['proven','unmet','unverified'].includes(d.verdict)&&same(d.actor,verificationActor)&&same(d.descriptor,intent.descriptor)&&d.scope===intent.scope&&d.taskId===intent.taskId&&d.changeFingerprint===intent.changeFingerprint;
97
+ const fresh=!intent.stale&&intent.changeFingerprint===current(state,intent.scope,intent.taskId,evidence?.changes)&&(intent.scope==='task'||intent.scopeVersion===state.scopeVersion)&&intent.targetVersion===state.targetVersion&&same(intent.target,state.target)&&same(intent.versions,state.versions)&&independent(state,verificationActor,intent.taskId)&&same(intent.approval,approval(state,intent.taskId))&&intent.taskFingerprint===fingerprintRequest(intent.scope==='final'?state.tasks:state.tasks.find(t=>t.id===intent.taskId));
90
98
  const status=!valid?'mismatch':r.status;
91
- const check={id:intent.requestId,operation:intent.operation,scope:intent.scope,taskId:intent.taskId,descriptor:structuredClone(intent.descriptor),verificationActor:structuredClone(intent.verificationActor),changeFingerprint:intent.changeFingerprint,resultRef:r?.messageRef,verdict:valid?d.verdict:'unverified',status:fresh&&status==='succeeded'&&d.verdict==='proven'?'passed':status==='failed'||d?.verdict==='unmet'?'failed':'unverified',stale:!fresh,source:'operator-attested'};
99
+ const check={id:intent.requestId,operation:intent.operation,scope:intent.scope,taskId:intent.taskId,descriptor:structuredClone(intent.descriptor),verificationActor:structuredClone(verificationActor),changeFingerprint:intent.changeFingerprint,resultRef:r?.messageRef,verdict:valid?d.verdict:'unverified',status:fresh&&status==='succeeded'&&d.verdict==='proven'?'passed':status==='failed'||d?.verdict==='unmet'?'failed':'unverified',stale:!fresh,source:'operator-attested'};
92
100
  const findings=[];
93
101
  if(check.status==='failed')findings.push({id:intent.requestId+':failure',checkId:check.id,scope:intent.scope,taskId:intent.taskId,origin:intent.operation==='review'?'final-review':'check',status:'open',source:'operator-attested',messageRef:r.messageRef});
94
102
  if(check.status==='passed')for(const id of intent.findingIds){const f=state.findings.find(f=>f.id===id);if(!f||f.status!=='resolved'||f.changeFingerprint!==intent.changeFingerprint)return hold(state,'finding-recheck','Finding changed after prepare');findings.push({...f,status:'closed',recheckRef:r.messageRef,recheckActor:structuredClone(d.actor)});}