@yunhozz/arc 0.5.6 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MANIFEST.sha256 +124 -110
- package/README.md +37 -113
- package/claude/agents/arc-architect.md +44 -0
- package/claude/agents/arc-implementer.md +2 -2
- package/claude/agents/arc-planner.md +5 -5
- package/claude/agents/arc-reviewer.md +1 -1
- package/claude/agents/arc-scouter.md +1 -1
- package/claude/agents/arc-tester.md +1 -1
- package/claude/skill/SKILL.md +6 -6
- package/claude/skill/models.toml +5 -1
- package/claude/skill/references/arc-visual-companion.md +2 -21
- package/claude/skill/references/commit.md +5 -32
- package/claude/skill/references/coordination.md +29 -134
- package/claude/skill/references/git-recovery.md +3 -3
- package/claude/skill/references/handoff-prep.md +9 -24
- package/claude/skill/references/handoff.md +19 -108
- package/claude/skill/references/limits.md +4 -15
- package/claude/skill/references/planning.md +32 -119
- package/claude/skill/references/verification.md +17 -119
- package/claude/skill/references/worktree-creation.md +1 -1
- package/claude/skill/scripts/model_config.py +24 -11
- package/codex/agents/arc-architect.md +36 -0
- package/codex/agents/{arc-implementer.toml → arc-implementer.md} +10 -5
- package/codex/agents/{arc-planner.toml → arc-planner.md} +14 -7
- package/codex/agents/{arc-reviewer.toml → arc-reviewer.md} +13 -4
- package/codex/agents/{arc-scouter.toml → arc-scouter.md} +13 -4
- package/codex/agents/{arc-tester.toml → arc-tester.md} +13 -4
- package/codex/skill/SKILL.md +6 -6
- package/codex/skill/models.toml +5 -1
- package/codex/skill/references/arc-visual-companion.md +3 -27
- package/codex/skill/references/commit.md +5 -32
- package/codex/skill/references/coordination.md +25 -131
- package/codex/skill/references/git-recovery.md +2 -7
- package/codex/skill/references/handoff-prep.md +9 -24
- package/codex/skill/references/handoff.md +19 -108
- package/codex/skill/references/limits.md +5 -16
- package/codex/skill/references/planning.md +32 -119
- package/codex/skill/references/verification.md +16 -118
- package/codex/skill/scripts/apply-models.py +5 -5
- package/codex/skill/scripts/model_config.py +23 -12
- package/gemini/GEMINI.md +1 -1
- package/gemini/agents/arc-architect.md +39 -0
- package/gemini/agents/arc-implementer.md +1 -1
- package/gemini/agents/arc-planner.md +4 -4
- package/gemini/instructions.md +1 -1
- package/gemini/skill/SKILL.md +6 -6
- package/gemini/skill/models.toml +5 -1
- package/gemini/skill/references/arc-visual-companion.md +2 -21
- package/gemini/skill/references/commit.md +5 -32
- package/gemini/skill/references/coordination.md +32 -137
- package/gemini/skill/references/git-recovery.md +3 -3
- package/gemini/skill/references/handoff-prep.md +9 -24
- package/gemini/skill/references/handoff.md +19 -108
- package/gemini/skill/references/limits.md +4 -15
- package/gemini/skill/references/planning.md +32 -119
- package/gemini/skill/references/verification.md +17 -119
- package/grok/AGENTS.md +1 -1
- package/grok/agents/arc-architect.md +39 -0
- package/grok/agents/arc-implementer.md +1 -1
- package/grok/agents/arc-planner.md +4 -4
- package/grok/instructions.md +1 -1
- package/grok/skill/SKILL.md +5 -5
- package/grok/skill/models.toml +5 -1
- package/grok/skill/references/arc-visual-companion.md +2 -21
- package/grok/skill/references/commit.md +5 -32
- package/grok/skill/references/coordination.md +30 -135
- package/grok/skill/references/git-recovery.md +3 -3
- package/grok/skill/references/handoff-prep.md +9 -24
- package/grok/skill/references/handoff.md +19 -108
- package/grok/skill/references/limits.md +4 -15
- package/grok/skill/references/planning.md +32 -119
- package/grok/skill/references/verification.md +17 -119
- package/lib/installer/global-config.mjs +1 -1
- package/lib/installer/manifest.mjs +20 -3
- package/lib/installer/role-routing.mjs +6 -3
- package/lib/installer/targets.mjs +1 -1
- package/lib/installer/upgrade-state.mjs +3 -2
- package/lib/models/config.mjs +22 -5
- package/lib/models/profiles.mjs +6 -1
- package/lib/platforms/agent-templates.mjs +1 -0
- package/lib/platforms/codex.mjs +2 -0
- package/lib/platforms/formats/codex-markdown.mjs +58 -0
- package/lib/platforms/formats/gemini-markdown.mjs +3 -2
- package/lib/platforms/formats/grok-markdown.mjs +3 -2
- package/lib/platforms/formats/markdown.mjs +3 -2
- package/lib/platforms/formats/toml.mjs +3 -2
- package/lib/policy/placement.mjs +1 -1
- package/lib/policy/render.mjs +6 -5
- package/lib/policy/role-policy.json +36 -7
- package/lib/prompts/agent-fragments.json +107 -24
- package/lib/prompts/render.mjs +69 -19
- package/lib/runtime/adapters/codex.mjs +1 -1
- package/lib/runtime/evaluate.mjs +4 -3
- package/lib/runtime/identity.mjs +1 -1
- package/lib/runtime/operations.mjs +2 -2
- package/lib/runtime/role-bridge-args.mjs +5 -3
- package/lib/runtime/role-bridge.mjs +24 -2
- package/lib/runtime/role-dispatch-policy.mjs +2 -1
- package/lib/runtime/role-dispatch-store.mjs +44 -1
- package/lib/runtime/role-observe.mjs +12 -4
- package/lib/runtime/role-routing-config.mjs +9 -4
- package/lib/runtime/role-supervisor.mjs +16 -2
- package/lib/tui/diagram.mjs +2 -3
- package/lib/tui/setup.mjs +13 -11
- package/lib/watch/labels.mjs +1 -1
- package/lib/watch/model.mjs +2 -2
- package/lib/watch/render.mjs +2 -2
- package/package.json +1 -1
- package/scripts/update-manifest.mjs +1 -1
- package/shared/skill/references/arc-visual-companion-common.md +39 -0
- package/shared/skill/references/commit-common.md +45 -0
- package/shared/skill/references/coordination-common.md +200 -0
- package/shared/skill/references/git-recovery-common.md +15 -0
- package/shared/skill/references/handoff-common.md +182 -0
- package/shared/skill/references/handoff-prep-common.md +53 -0
- package/shared/skill/references/limits-common.md +34 -0
- package/shared/skill/references/planning-common.md +185 -0
- package/shared/skill/references/verification-common.md +172 -0
- package/shared/skill/runtime/adapters/codex.mjs +1 -1
- package/shared/skill/runtime/evaluate.mjs +4 -3
- package/shared/skill/runtime/identity.mjs +1 -1
- package/shared/skill/runtime/operations.mjs +2 -2
- package/shared/skill/runtime/role-bridge-args.mjs +5 -3
- package/shared/skill/runtime/role-bridge.mjs +24 -2
- package/shared/skill/runtime/role-dispatch-policy.mjs +2 -1
- package/shared/skill/runtime/role-dispatch-store.mjs +44 -1
- package/shared/skill/runtime/role-observe.mjs +12 -4
- package/shared/skill/runtime/role-policy.json +36 -7
- package/shared/skill/runtime/role-routing-config.mjs +9 -4
- package/shared/skill/runtime/role-supervisor.mjs +16 -2
package/lib/runtime/evaluate.mjs
CHANGED
|
@@ -28,7 +28,7 @@ export function evaluate(policy, state, request, evidence){
|
|
|
28
28
|
const actor=state.identities.find(i=>i.actorRef===request.actorRef);
|
|
29
29
|
if(!actor)return result('hold','runtime.identity','platform identity unresolved',['platform-identity']);
|
|
30
30
|
const role=actor.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
|
+
const roleRule={orchestrator:'role.orchestrator-boundary',scouter:'role.scouter-read-only',architect:'role.architect-draft-only',planner:'role.planner-draft-only',implementer:'role.implementer-implementation',tester:'role.tester-verification',reviewer:'role.reviewer-independent'}[role]??'runtime.identity';
|
|
32
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');
|
|
33
33
|
const lease=state.leases.find(l=>l.actorRef===actor.actorRef);
|
|
34
34
|
if(lease?.status==='retired')return result('deny','runtime.identity','retired identity');
|
|
@@ -84,11 +84,12 @@ export function evaluate(policy, state, request, evidence){
|
|
|
84
84
|
if(d.temporary&&!same(d.temporary,approval.scope.temporary))return result('hold','runtime.assignment','delegated temporary scope not approved',['delegated-temporary-scope']);
|
|
85
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']);
|
|
86
86
|
const next=structuredClone(stored);
|
|
87
|
-
if(d.role==='planner'){
|
|
87
|
+
if(d.role==='planner'||d.role==='architect'){
|
|
88
88
|
const stage=state.plannerLedger?.stages.find(s=>s.id===d.plannerCall?.stageId),proof=fact('planner-call');
|
|
89
89
|
const contract=stage&&{document:stage.document,inputVersion:stage.inputVersion,criteriaVersion:stage.criteriaVersion,scopeVersion:stage.scopeVersion};
|
|
90
90
|
if(!stage||stage.workflowId!==state.workflowId||stage.approvalRef!==approval.id||!same(approval.scope.plannerStage,contract)||!d.paths.includes(stage.document.path)||proof?.sourceRef!==correlation.sourceRef||!same({stageId:proof?.data.stageId,inputVersion:proof?.data.inputVersion,criteriaVersion:proof?.data.criteriaVersion,scopeVersion:proof?.data.scopeVersion},{stageId:stage.id,inputVersion:stage.inputVersion,criteriaVersion:stage.criteriaVersion,scopeVersion:stage.scopeVersion}))return result('hold','runtime.planner-call','Current approved Planner stage and provider evidence required',['planner-stage-ledger','planner-call-evidence']);
|
|
91
91
|
if(state.planningDepth==='Bounded'&&stage.document.kind==='spec')return result('hold','runtime.planner-call','Bounded depth has no spec stage',['approved-spec']);
|
|
92
|
+
if((d.role==='architect')!==(stage.document.kind==='spec'))return result('hold','runtime.planner-call','Architect binds only spec stages and Planner only plan stages',['planner-stage-role']);
|
|
92
93
|
if(stage.document.kind==='plan'&&state.planningDepth!=='Bounded'){
|
|
93
94
|
const reviewedSpecStage=state.plannerLedger.stages.some(s=>s.workflowId===state.workflowId&&s.document.kind==='spec'&&s.ready===true&&s.review.full===true&&s.review.complete===true&&s.scopeVersion===stage.scopeVersion);
|
|
94
95
|
const approvedSpec=reviewedSpecStage||state.documents.some(doc=>doc.kind==='spec'&&state.approvals.some(a=>a.id===doc.approvalRef&&a.contentHash===doc.contentHash&&evidence.provenance.some(p=>p.id===a.id&&p.messageRef===a.messageRef&&p.contentHash===doc.contentHash&&p.verification.sourceRef===a.messageRef)));
|
|
@@ -98,7 +99,7 @@ export function evaluate(policy, state, request, evidence){
|
|
|
98
99
|
if(planner.decision!=='allow')return planner;
|
|
99
100
|
next.plannerLedger.stages[next.plannerLedger.stages.findIndex(s=>s.id===stage.id)]=planner.proposedTransition;
|
|
100
101
|
}
|
|
101
|
-
next.assignments.push({assignmentId:request.requestId,requestId:request.requestId,requestedBy:request.actorRef,status:'pending',actorRef:null,platform:request.platform,correlationRef:d.correlationRef,role:d.role,taskId:d.taskId,paths:[...d.paths],operations:[...d.operations],approvalRef:d.approvalRef,...(d.role==='planner'?{plannerStageId:d.plannerCall.stageId}:{}),...(d.checks?{checks:structuredClone(d.checks)}:{}),...(d.temporary?{temporary:structuredClone(d.temporary)}:{})});
|
|
102
|
+
next.assignments.push({assignmentId:request.requestId,requestId:request.requestId,requestedBy:request.actorRef,status:'pending',actorRef:null,platform:request.platform,correlationRef:d.correlationRef,role:d.role,taskId:d.taskId,paths:[...d.paths],operations:[...d.operations],approvalRef:d.approvalRef,...((d.role==='planner'||d.role==='architect')?{plannerStageId:d.plannerCall.stageId}:{}),...(d.checks?{checks:structuredClone(d.checks)}:{}),...(d.temporary?{temporary:structuredClone(d.temporary)}:{})});
|
|
102
103
|
try{validateWorkflowState(next);}catch{return result('hold','runtime.assignment','invalid pending assignment scope',['valid-assignment']);}
|
|
103
104
|
return {...result('allow','runtime.assignment','pending assignment authorized; observed spawn result still required'),proposedTransition:next};
|
|
104
105
|
}
|
package/lib/runtime/identity.mjs
CHANGED
|
@@ -41,7 +41,7 @@ export async function recordPlannerAgentObservation({statePath,expectedRevision,
|
|
|
41
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');
|
|
42
42
|
const state=validateWorkflowState(JSON.parse(await fs.readFile(statePath,'utf8')),{preserveStoredOperations:true}),eventHash=fingerprintRequest({input,observation:observation??null});
|
|
43
43
|
if(state.plannerObservations?.some(o=>o.eventHash===eventHash))return {decision:'hold',reason:'Observation replay',proposedTransition:null,replayed:true};
|
|
44
|
-
const candidates=state.assignments.filter(a=>a.status==='pending'&&a.role==='planner');
|
|
44
|
+
const candidates=state.assignments.filter(a=>a.status==='pending'&&(a.role==='planner'||a.role==='architect'));
|
|
45
45
|
let decision={decision:'hold',reason:'Raw event lacks verified assignment correlation',proposedTransition:null};
|
|
46
46
|
if(state.revision!==expectedRevision)decision.reason='Stale provider context cannot bind identity';
|
|
47
47
|
else if(observation?.actorRef===input.agent_id&&observation.platform===platform)decision=registerAgentObservation(state,observation);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/** Canonical semantic operations, independent of platform tool aliases. */
|
|
2
|
-
export const ROLES = Object.freeze(['orchestrator','scouter','planner','implementer','tester','reviewer']);
|
|
2
|
+
export const ROLES = Object.freeze(['orchestrator','scouter','architect','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
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
6
|
export const LEGACY_OPERATIONS = Object.freeze({qa: 'test'});
|
|
7
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']});
|
|
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'],architect:['read','draft'],planner:['read','draft'],implementer:['read','write','check'],tester:['read','check','temporary-write'],reviewer:['read','review']});
|
|
9
9
|
|
|
10
10
|
/** Compare a stored role without rewriting historical evidence. */
|
|
11
11
|
export function canonicalCooperativeRole(role) {
|
|
@@ -6,27 +6,29 @@ import {GEMINI_CONTRACT} from './gemini-stream.mjs';
|
|
|
6
6
|
import {CODEX_PROFILE_ARGS_FORM, CODEX_PROFILE_GIT_ENTRIES, DEFAULT_POLICY, effectiveClaudeSandboxSettings} from './role-dispatch-policy.mjs';
|
|
7
7
|
import {TOOL_PATHS, TOOL_UNIX_SOCKETS} from './tool-access.mjs';
|
|
8
8
|
|
|
9
|
-
const ROLES = ['arc_scouter', 'arc_planner', 'arc_implementer', 'arc_tester', 'arc_reviewer'];
|
|
9
|
+
const ROLES = ['arc_scouter', 'arc_architect', 'arc_planner', 'arc_implementer', 'arc_tester', 'arc_reviewer'];
|
|
10
10
|
const deepFreeze = value => { for (const child of Object.values(value)) if (child && typeof child === 'object') deepFreeze(child); return Object.freeze(value); };
|
|
11
11
|
export const ROLE_BRIDGE_PERMISSIONS = deepFreeze({
|
|
12
12
|
claude: {
|
|
13
13
|
arc_scouter: {permissionMode: 'default', sandbox: false, allowedTools: ['WebFetch', 'WebSearch']},
|
|
14
|
+
arc_architect: {permissionMode: 'default', sandbox: false},
|
|
14
15
|
arc_planner: {permissionMode: 'default', sandbox: false},
|
|
15
16
|
arc_implementer: {permissionMode: 'acceptEdits', sandbox: true}, arc_tester: {permissionMode: 'default', sandbox: true}, arc_reviewer: {permissionMode: 'default', sandbox: false}
|
|
16
17
|
},
|
|
17
18
|
gemini: {
|
|
18
|
-
arc_scouter: {approvalMode: 'plan', sandbox: false}, arc_planner: {approvalMode: 'plan', sandbox: false},
|
|
19
|
+
arc_scouter: {approvalMode: 'plan', sandbox: false}, arc_architect: {approvalMode: 'plan', sandbox: false}, arc_planner: {approvalMode: 'plan', sandbox: false},
|
|
19
20
|
arc_implementer: {approvalMode: 'auto_edit', sandbox: true}, arc_tester: {approvalMode: 'auto_edit', sandbox: true}, arc_reviewer: {approvalMode: 'plan', sandbox: false}
|
|
20
21
|
},
|
|
21
22
|
grok: {
|
|
22
23
|
arc_scouter: {permissionMode: 'plan', sandbox: 'read-only', deny: GROK_CONTRACT.readOnlyDeny},
|
|
24
|
+
arc_architect: {permissionMode: 'plan', sandbox: 'read-only', deny: GROK_CONTRACT.readOnlyDeny},
|
|
23
25
|
arc_planner: {permissionMode: 'plan', sandbox: 'read-only', deny: GROK_CONTRACT.readOnlyDeny},
|
|
24
26
|
arc_reviewer: {permissionMode: 'plan', sandbox: 'read-only', deny: GROK_CONTRACT.readOnlyDeny},
|
|
25
27
|
arc_implementer: {permissionMode: 'acceptEdits', sandbox: 'custom', deny: []},
|
|
26
28
|
arc_tester: {permissionMode: 'acceptEdits', sandbox: 'custom', deny: []},
|
|
27
29
|
},
|
|
28
30
|
codex: {
|
|
29
|
-
arc_scouter: {sandboxMode: 'read-only', search: true}, arc_planner: {sandboxMode: 'read-only', search: false},
|
|
31
|
+
arc_scouter: {sandboxMode: 'read-only', search: true}, arc_architect: {sandboxMode: 'read-only', search: false}, arc_planner: {sandboxMode: 'read-only', search: false},
|
|
30
32
|
arc_implementer: {sandboxMode: 'workspace-write', search: false}, arc_tester: {sandboxMode: 'workspace-write', search: false}, arc_reviewer: {sandboxMode: 'read-only', search: false}
|
|
31
33
|
}
|
|
32
34
|
});
|
|
@@ -5,7 +5,8 @@ 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
7
|
import {displayRoutingRole} from './role-routing-config.mjs';
|
|
8
|
-
import {readLease, writeLease, listLeases, readHostLimits, NON_TERMINAL_STATES, readHeartbeat, requestCancel, clearCancel, TERMINAL_STATES, validateLease} from './role-dispatch-store.mjs';
|
|
8
|
+
import {readLease, writeLease, listLeases, readHostLimits, NON_TERMINAL_STATES, readHeartbeat, requestCancel, clearCancel, TERMINAL_STATES, validateLease, readWorktreeRecord, writeWorktreeRecord, removeWorktreeRecord, worktreeWriters} from './role-dispatch-store.mjs';
|
|
9
|
+
import {pathsOverlap} from './role-observe.mjs';
|
|
9
10
|
import {withRoutingLock, readActivation, readRevision, authenticate, resolveRuntimeHomes, locateAnchorHome, probeHomeWritable} from './role-routing.mjs';
|
|
10
11
|
import {SUPERVISOR_IMPLEMENTATIONS, startSupervisor, processAlive, resolveWorktree, artifactDirectory, segmentDirectory, buildBridgeInvocation, reapRecordedDescendants, reapRecordedHostServices} from './role-supervisor.mjs';
|
|
11
12
|
|
|
@@ -39,6 +40,18 @@ const residualOf=error=>Array.isArray(error?.residualPaths)?error.residualPaths:
|
|
|
39
40
|
const hold=(context,dispatchId,code,error)=>{const result=blank(context,dispatchId,'hold',code);const residual=residualOf(error);if(residual)result.residualPaths=residual;return result;};
|
|
40
41
|
const classifyLock=error=>{const code=error?.code==='ARC_ROUTING_LOCK_RELEASE'&&error.failure?error.failure.code:error?.code;return code==='ARC_HOST_SANDBOX'?'host_sandbox_blocked':'activation_unverified';};
|
|
41
42
|
|
|
43
|
+
async function overlapHold({anchorHome,lease,worktree,runtimePlatforms}){
|
|
44
|
+
const leases=await listLeases(anchorHome,{runtimePlatforms});
|
|
45
|
+
const records=new Map();
|
|
46
|
+
for(const item of leases){
|
|
47
|
+
if(item.route==='bridge'&&(item.role==='arc_implementer'||item.role==='arc_tester')){
|
|
48
|
+
records.set(item.dispatchId,await readWorktreeRecord(anchorHome,item.dispatchId));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const owners=worktreeWriters({leases,records,dispatchId:lease.dispatchId,worktree,terminalSinceMs:null});
|
|
52
|
+
return owners.some(owner=>pathsOverlap(owner.allowedPaths,lease.allowedPaths));
|
|
53
|
+
}
|
|
54
|
+
|
|
42
55
|
/** Starts the detached supervisor for a reserved bridge lease; the supervisor, not this function, spawns the child. */
|
|
43
56
|
export async function runBridgeDispatch({context,dispatchId,brief,now=Date.now(),policy=DEFAULT_POLICY,startSupervisor:starter=startSupervisor,observeToolContext}={}){
|
|
44
57
|
if(!validContext(context)||typeof dispatchId!=='string'||!ID.test(dispatchId)||dispatchId.startsWith('.')||typeof brief!=='string'){return blank(context,dispatchId,'deny','invalid_request');}
|
|
@@ -59,6 +72,7 @@ export async function runBridgeDispatch({context,dispatchId,brief,now=Date.now()
|
|
|
59
72
|
const capabilities=capabilityReasons({hostPlatform:lease.hostPlatform,targetPlatform:platform,route:lease.route,runtimePlatforms});
|
|
60
73
|
if(capabilities.length){result=blank(context,dispatchId,'hold',capabilities[0]);return;}
|
|
61
74
|
let target;try{target=await resolveWorktree(context.cwd);}catch{result=blank(context,dispatchId,'hold','activation_unverified');return;}
|
|
75
|
+
if(await overlapHold({anchorHome,lease,worktree:target.realpath,runtimePlatforms})){result=blank(context,dispatchId,'hold','allowed_paths_overlap');return;}
|
|
62
76
|
const directory=artifactDirectory(target,lease.workflowId,dispatchId),resultPath=path.join(directory,'result.md');
|
|
63
77
|
let invocation;try{invocation=await buildBridgeInvocation({lease,config,homes,worktree:target.realpath,resultPath,userHome:context.userHome,env:context.env??process.env,target,runtimePlatforms,policy,observeToolContext});}catch(error){result=blank(context,dispatchId,'hold',error.reasonCode??'activation_unverified');return;}
|
|
64
78
|
await fsp.mkdir(directory,{recursive:true,mode:0o700});await fsp.chmod(directory,0o700);
|
|
@@ -68,6 +82,7 @@ export async function runBridgeDispatch({context,dispatchId,brief,now=Date.now()
|
|
|
68
82
|
if(!probe.ok){result=hold(context,dispatchId,probe.code,probe);return;}
|
|
69
83
|
}
|
|
70
84
|
let supervisor;
|
|
85
|
+
await writeWorktreeRecord(anchorHome,dispatchId,{segment:lease.segment,worktree:target.realpath});
|
|
71
86
|
try{supervisor=await starter({codexHome:anchorHome,dispatchId,cwd:target.realpath,userHome:context.userHome,env:context.env??process.env});}
|
|
72
87
|
catch{result=blank(context,dispatchId,'hold','host_sandbox_blocked');return;}
|
|
73
88
|
const next=await writeLease(anchorHome,{...lease,state:'starting',supervisor,argsDigest:invocation.argsDigest,resultPath},{now,runtimePlatforms});
|
|
@@ -196,6 +211,7 @@ export async function resumeRoleDispatch({context,dispatchId,brief,now=Date.now(
|
|
|
196
211
|
if(limits&&(await listLeases(anchorHome,{runtimePlatforms})).filter(item=>item.route==='bridge'&&NON_TERMINAL_STATES.includes(item.state)).length+1>limits.maxConcurrent)codes.add('capacity_exhausted');
|
|
197
212
|
if(codes.size){result=blank(context,dispatchId,'hold','activation_unverified');result.reasons=[...codes].map(reason);return;}
|
|
198
213
|
let target;try{target=await resolveWorktree(context.cwd);}catch{result=blank(context,dispatchId,'hold','activation_unverified');return;}
|
|
214
|
+
if(await overlapHold({anchorHome,lease,worktree:target.realpath,runtimePlatforms})){result=blank(context,dispatchId,'hold','allowed_paths_overlap');return;}
|
|
199
215
|
const segment=lease.segment+1,directory=segmentDirectory(target,lease.workflowId,dispatchId,segment),resultPath=path.join(directory,'result.md');
|
|
200
216
|
let invocation;try{invocation=await buildBridgeInvocation({lease:{...lease,segment},config,homes,worktree:target.realpath,resultPath,userHome:context.userHome,env:context.env??process.env,target,runtimePlatforms,policy,supervisorImplementations,observeToolContext});}catch(error){result=blank(context,dispatchId,'hold',error.reasonCode??'activation_unverified');return;}
|
|
201
217
|
await fsp.mkdir(directory,{recursive:true,mode:0o700});await fsp.chmod(path.dirname(directory),0o700);await fsp.chmod(directory,0o700);
|
|
@@ -204,10 +220,16 @@ export async function resumeRoleDispatch({context,dispatchId,brief,now=Date.now(
|
|
|
204
220
|
const probe=await probeHomeWritable(homes[platform]);
|
|
205
221
|
if(!probe.ok){result=hold(context,dispatchId,probe.code,probe);return;}
|
|
206
222
|
}
|
|
223
|
+
const previousRecord=await readWorktreeRecord(anchorHome,dispatchId);
|
|
224
|
+
await writeWorktreeRecord(anchorHome,dispatchId,{segment,worktree:target.realpath});
|
|
207
225
|
await clearCancel(anchorHome,dispatchId);
|
|
208
226
|
let supervisor;
|
|
209
227
|
try{supervisor=await starter({codexHome:anchorHome,dispatchId,cwd:target.realpath,userHome:context.userHome,env:context.env??process.env});}
|
|
210
|
-
catch{
|
|
228
|
+
catch{
|
|
229
|
+
if(previousRecord)await writeWorktreeRecord(anchorHome,dispatchId,previousRecord);
|
|
230
|
+
else await removeWorktreeRecord(anchorHome,dispatchId);
|
|
231
|
+
result=blank(context,dispatchId,'hold','host_sandbox_blocked');return;
|
|
232
|
+
}
|
|
211
233
|
const claims=lease.claims?{...lease.claims,terminal:{level:'unverified',source:'none'}}:null;
|
|
212
234
|
const next=await writeLease(anchorHome,{...lease,state:'starting',supervisor,child:null,argsDigest:invocation.argsDigest,resultPath,segment,claims,reasons:[]},{now,runtimePlatforms});
|
|
213
235
|
result={...view(next,'allow'),segment};
|
|
@@ -41,7 +41,7 @@ export const effectiveClaudeSandboxSettings = policy => policy?.gates?.G1 === 'p
|
|
|
41
41
|
export const CATALOG_MODEL_ALIASES = Object.freeze(['fable', 'opus', 'sonnet', 'haiku']);
|
|
42
42
|
export const CODEX_DELEGATION_CALL_NAMES = Object.freeze(['spawn_agent', 'wait_agent']);
|
|
43
43
|
export const DESKTOP_CHECKLIST_PASSED = Object.freeze({'claude-desktop': false, 'codex-desktop': false});
|
|
44
|
-
export const ROLE_TIMEOUT_MINUTES = Object.freeze({arc_scouter: 20, arc_planner: 20, arc_implementer: 60, arc_tester: 60, arc_reviewer: 20});
|
|
44
|
+
export const ROLE_TIMEOUT_MINUTES = Object.freeze({arc_scouter: 20, arc_architect: 20, arc_planner: 20, arc_implementer: 60, arc_tester: 60, arc_reviewer: 20});
|
|
45
45
|
export const HEARTBEAT_MS = 5000;
|
|
46
46
|
export const SUPERVISOR_LOST_MS = 30000;
|
|
47
47
|
export const OBSERVE_MAX_WAIT_MS = 540000;
|
|
@@ -86,6 +86,7 @@ export const RELEASE_CONDITIONS = Object.freeze({
|
|
|
86
86
|
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.`,
|
|
87
87
|
host_sandbox_blocked: 'Allow the host to write the anchor home and keep a detached supervisor alive, with explicit user approval.',
|
|
88
88
|
capacity_exhausted: 'Finish or release active bridge executions, or raise the host limits.',
|
|
89
|
+
allowed_paths_overlap: 'Wait until the started bridge dispatch whose allowedPaths overlap in the same worktree reaches a terminal state, resolving it first when it is unknown, or prepare a new dispatch with non-overlapping allowedPaths; then run or resume again.',
|
|
89
90
|
permission_scope_unverified: 'Update ARC and verify enforcement of the role permissions and approved scope before starting.',
|
|
90
91
|
native_profile_reload_unverified: 'Verify that the host session loaded the requested profile revision.',
|
|
91
92
|
revision_changed: 'Re-run routing-status and prepare a new dispatch under the current revision.',
|
|
@@ -77,6 +77,7 @@ export async function writeLease(codexHome, lease, {now = Date.now(), runtimePla
|
|
|
77
77
|
return value;
|
|
78
78
|
}
|
|
79
79
|
const HEARTBEAT_SUFFIX = '.heartbeat.json';
|
|
80
|
+
const WORKTREE_SUFFIX = '.worktree';
|
|
80
81
|
const leaseFiles = async codexHome => {
|
|
81
82
|
try { return (await fsp.readdir(dispatchDirectory(codexHome))).filter(name => name.endsWith('.json') && !name.endsWith(HEARTBEAT_SUFFIX) && !name.startsWith('.')).sort(); }
|
|
82
83
|
catch (error) { if (error.code === 'ENOENT') return []; throw error; }
|
|
@@ -97,7 +98,7 @@ export async function pruneTerminalLeases(codexHome, {now = Date.now(), retentio
|
|
|
97
98
|
const updated = Date.parse(lease.updatedAt);
|
|
98
99
|
if (!TERMINAL_STATES.includes(lease.state) || !Number.isFinite(updated) || now - updated <= retentionMs) continue;
|
|
99
100
|
await fsp.unlink(file); removed += 1;
|
|
100
|
-
for (const
|
|
101
|
+
for (const suffix of [HEARTBEAT_SUFFIX, '.cancel', WORKTREE_SUFFIX]) await fsp.unlink(sidecarPath(codexHome, lease.dispatchId, suffix)).catch(() => {});
|
|
101
102
|
} catch { errors += 1; }
|
|
102
103
|
}
|
|
103
104
|
return {removed, errors};
|
|
@@ -117,6 +118,48 @@ export function readHostLimits(hostHome) {
|
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
const sidecarPath = (codexHome, dispatchId, suffix) => path.join(dispatchDirectory(codexHome), `${path.basename(leasePath(codexHome, dispatchId), '.json')}${suffix}`);
|
|
121
|
+
const validWorktree = (segment, worktree) => Number.isInteger(segment) && segment >= 0 && typeof worktree === 'string' && path.isAbsolute(worktree);
|
|
122
|
+
|
|
123
|
+
/** Records the worktree for one segment while the caller holds the routing lock. */
|
|
124
|
+
export async function writeWorktreeRecord(codexHome, dispatchId, {segment, worktree}) {
|
|
125
|
+
if (!validWorktree(segment, worktree)) throw Error('Invalid worktree record');
|
|
126
|
+
const target = sidecarPath(codexHome, dispatchId, WORKTREE_SUFFIX);
|
|
127
|
+
const temp = path.join(dispatchDirectory(codexHome), `.${dispatchId}.${crypto.randomUUID()}.wt.tmp`);
|
|
128
|
+
try {
|
|
129
|
+
const handle = await fsp.open(temp, 'wx', 0o600);
|
|
130
|
+
try { await handle.writeFile(JSON.stringify({version: 1, dispatchId, segment, worktree}) + '\n'); } finally { await handle.close(); }
|
|
131
|
+
await fsp.rename(temp, target);
|
|
132
|
+
} catch (error) { await fsp.unlink(temp).catch(() => {}); throw error; }
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export async function readWorktreeRecord(codexHome, dispatchId) {
|
|
136
|
+
try {
|
|
137
|
+
const value = JSON.parse(await fsp.readFile(sidecarPath(codexHome, dispatchId, WORKTREE_SUFFIX), 'utf8'));
|
|
138
|
+
if (!isObject(value) || Object.keys(value).length !== 4 || value.version !== 1 ||
|
|
139
|
+
value.dispatchId !== dispatchId || !validWorktree(value.segment, value.worktree)) return null;
|
|
140
|
+
return value;
|
|
141
|
+
} catch { return null; }
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export async function removeWorktreeRecord(codexHome, dispatchId) {
|
|
145
|
+
try { await fsp.unlink(sidecarPath(codexHome, dispatchId, WORKTREE_SUFFIX)); }
|
|
146
|
+
catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function worktreeWriters({leases, records, dispatchId, worktree, terminalSinceMs, excludeUnknown = false}) {
|
|
150
|
+
const writers = leases.filter(lease => {
|
|
151
|
+
if (lease.dispatchId === dispatchId || lease.route !== 'bridge' ||
|
|
152
|
+
(lease.role !== 'arc_implementer' && lease.role !== 'arc_tester') || !lease.allowedPaths.length) return false;
|
|
153
|
+
if (excludeUnknown && lease.state === 'unknown') return false;
|
|
154
|
+
const record = records.get(lease.dispatchId);
|
|
155
|
+
if (!record || record.segment !== lease.segment || record.worktree !== worktree) return false;
|
|
156
|
+
return (lease.state !== 'reserved' && NON_TERMINAL_STATES.includes(lease.state)) ||
|
|
157
|
+
(terminalSinceMs !== null && TERMINAL_STATES.includes(lease.state) && Date.parse(lease.updatedAt) >= terminalSinceMs);
|
|
158
|
+
});
|
|
159
|
+
return writers.sort((a, b) => a.dispatchId < b.dispatchId ? -1 : a.dispatchId > b.dispatchId ? 1 : 0)
|
|
160
|
+
.map(({dispatchId, allowedPaths}) => ({dispatchId, allowedPaths}));
|
|
161
|
+
}
|
|
162
|
+
|
|
120
163
|
/** The supervisor alone writes its heartbeat; no routing lock is needed because the file is replaced atomically and holds no lease state. */
|
|
121
164
|
export async function writeHeartbeat(codexHome, dispatchId, {at, pid}) {
|
|
122
165
|
if (!Number.isFinite(at) || !Number.isInteger(pid) || pid <= 0) throw Error('Invalid heartbeat');
|
|
@@ -568,6 +568,8 @@ function otherWorktreeBranches(before, after) {
|
|
|
568
568
|
}
|
|
569
569
|
|
|
570
570
|
const allowedBy = (allowedPaths, file) => allowedPaths.some(entry => entry.endsWith('/') ? file.startsWith(entry) : file === entry);
|
|
571
|
+
export const pathsOverlap = (a, b) => a.some(file => allowedBy(b, file)) || b.some(file => allowedBy(a, file));
|
|
572
|
+
const byPath = (a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0;
|
|
571
573
|
const hasBranchRefs = (before, after) => before.branchRef !== undefined && after.branchRef !== undefined;
|
|
572
574
|
const branchChanged = (before, after) => hasBranchRefs(before, after)
|
|
573
575
|
? before.branchRef !== after.branchRef
|
|
@@ -638,7 +640,7 @@ export async function observeHeadAdvance(root, before, after, role, allowedPaths
|
|
|
638
640
|
* commits. Ordinary worktree snapshots omit Git-ignored paths. Control files
|
|
639
641
|
* are compared regardless of role and allowedPaths.
|
|
640
642
|
*/
|
|
641
|
-
export function detectViolations({role, allowedPaths, before, after, headAdvance}) {
|
|
643
|
+
export function detectViolations({role, allowedPaths, before, after, headAdvance, otherOwners = []}) {
|
|
642
644
|
const branchSwitched = branchChanged(before, after);
|
|
643
645
|
const headMoved = before.head !== after.head;
|
|
644
646
|
const targetBranch = before.branchRef;
|
|
@@ -663,8 +665,12 @@ export function detectViolations({role, allowedPaths, before, after, headAdvance
|
|
|
663
665
|
}
|
|
664
666
|
const allowed = (role === 'arc_implementer' || role === 'arc_tester') && Array.isArray(allowedPaths) ? allowedPaths : [];
|
|
665
667
|
const changed = new Set();
|
|
668
|
+
const attributedPaths = [];
|
|
666
669
|
for (const file of new Set([...before.entries.keys(), ...after.entries.keys()])) {
|
|
667
|
-
if (before.entries.get(file)
|
|
670
|
+
if (before.entries.get(file) === after.entries.get(file) || allowedBy(allowed, file)) continue;
|
|
671
|
+
const owners = otherOwners.filter(owner => allowedBy(owner.allowedPaths, file)).map(owner => owner.dispatchId).sort();
|
|
672
|
+
if (owners.length) attributedPaths.push({path: file, owners});
|
|
673
|
+
else changed.add(file);
|
|
668
674
|
}
|
|
669
675
|
if (headAdvance?.state === 'rejected') {
|
|
670
676
|
for (const file of headAdvance.outOfScopePaths ?? []) changed.add(file);
|
|
@@ -679,15 +685,17 @@ export function detectViolations({role, allowedPaths, before, after, headAdvance
|
|
|
679
685
|
}
|
|
680
686
|
const reason = headChanged || refsChanged || changedPaths.length || controlChanged.length ? 'permission_violation_observed' : null;
|
|
681
687
|
const toleratedCommitPaths = acceptedAdvance ? [...headAdvance.paths].sort() : [];
|
|
682
|
-
return {reason, changedPaths, headChanged, refsChanged, controlChanged: controlChanged.sort(), toleratedRefs: toleratedRefs.sort(), toleratedControl, toleratedCommitPaths};
|
|
688
|
+
return {reason, changedPaths, headChanged, refsChanged, controlChanged: controlChanged.sort(), toleratedRefs: toleratedRefs.sort(), toleratedControl, toleratedCommitPaths, attributedPaths: attributedPaths.sort(byPath)};
|
|
683
689
|
}
|
|
684
690
|
|
|
685
|
-
export function toleratedRecord({toleratedRefs = [], toleratedControl = [], toleratedCommitPaths = []} = {}) {
|
|
691
|
+
export function toleratedRecord({toleratedRefs = [], toleratedControl = [], toleratedCommitPaths = [], attributedPaths = []} = {}) {
|
|
686
692
|
const record = {};
|
|
687
693
|
for (const [key, names] of [['refs', toleratedRefs], ['control', toleratedControl], ['commitPaths', toleratedCommitPaths]]) {
|
|
688
694
|
if (!names.length) continue;
|
|
689
695
|
record[key] = [...names].sort().slice(0, 100);
|
|
690
696
|
if (names.length > 100) record.truncated = true;
|
|
691
697
|
}
|
|
698
|
+
if (attributedPaths.length) record.attributed = [...attributedPaths].sort(byPath).slice(0, 100);
|
|
699
|
+
if (attributedPaths.length > 100) record.truncated = true;
|
|
692
700
|
return Object.keys(record).length ? record : null;
|
|
693
701
|
}
|
|
@@ -1,8 +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_tester', 'arc_reviewer']);
|
|
3
|
+
export const ROUTING_ROLES = Object.freeze(['arc_scouter', 'arc_architect', 'arc_planner', 'arc_implementer', 'arc_tester', 'arc_reviewer']);
|
|
4
4
|
export const LEGACY_ROUTING_ROLES = Object.freeze({arc_qa: 'arc_tester'});
|
|
5
|
-
export const ROUTING_CONFIG_VERSION =
|
|
5
|
+
export const ROUTING_CONFIG_VERSION = 4;
|
|
6
6
|
const validText = value => typeof value === 'string' && value.length > 0 && value === value.trim() && !/[\p{Cc}\u2028\u2029]/u.test(value);
|
|
7
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));
|
|
8
8
|
const v1Platforms = Object.freeze(['codex', 'claude']);
|
|
@@ -22,13 +22,18 @@ export function validRoleValues(platform, model, effort, {runtimePlatforms} = {}
|
|
|
22
22
|
}
|
|
23
23
|
export function validateRoleRoutingConfig(config, opts = {}) {
|
|
24
24
|
const keys = ['version', 'revision', 'platforms', 'roles'];
|
|
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');
|
|
25
|
+
if (!(exact(config, keys) || (config?.version === 1 && exact(config, ['version', 'revision', 'roles']))) || ![1, 2, 3, ROUTING_CONFIG_VERSION].includes(config.version) || !validText(config.revision)) throw Error('Invalid role routing configuration');
|
|
26
26
|
let roles = config.roles;
|
|
27
27
|
if (roles && typeof roles === 'object' && !Array.isArray(roles) && Object.hasOwn(roles, 'arc_qa')) {
|
|
28
|
-
if (config.version
|
|
28
|
+
if (config.version >= 3 || Object.hasOwn(roles, 'arc_tester')) throw Error('Invalid role routing configuration');
|
|
29
29
|
roles = Object.fromEntries(Object.entries(roles).map(([role, fields]) => [Object.hasOwn(LEGACY_ROUTING_ROLES, role) ? LEGACY_ROUTING_ROLES[role] : role, fields]));
|
|
30
30
|
}
|
|
31
|
+
if (config.version < ROUTING_CONFIG_VERSION && roles && typeof roles === 'object' && !Array.isArray(roles)
|
|
32
|
+
&& !Object.hasOwn(roles, 'arc_architect') && Object.hasOwn(roles, 'arc_planner')) {
|
|
33
|
+
roles = {...roles, arc_architect: structuredClone(roles.arc_planner)};
|
|
34
|
+
}
|
|
31
35
|
if (!exact(roles, ROUTING_ROLES)) throw Error('Invalid role routing configuration');
|
|
36
|
+
roles = Object.fromEntries(ROUTING_ROLES.map(role => [role, roles[role]]));
|
|
32
37
|
const registry = runtimeRegistryOf(opts);
|
|
33
38
|
const platforms = config.version === 1 && !Object.hasOwn(config, 'platforms') ? [...v1Platforms] : config.platforms;
|
|
34
39
|
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');
|
|
@@ -11,7 +11,7 @@ import {GROK_CONTRACT, normalizeGrokStreamEvent, evaluateGrokObservation} from '
|
|
|
11
11
|
import {GROK_SANDBOX_RELATIVE, grokSandboxProfileName, renderGrokSandboxProfile, grokProfileCovered, inspectGrokProfileSlot, checkGrokHome, createGrokSandboxProfile, verifyGrokSandboxProfile, removeGrokSandboxProfile, grokEventsBaseline, readGrokProfileApplied, grokConfigSecurityProjection} from './grok-sandbox.mjs';
|
|
12
12
|
import {GEMINI_CONTRACT, normalizeGeminiStreamEvent, evaluateGeminiObservation} from './gemini-stream.mjs';
|
|
13
13
|
import {CODEX_PROFILE_SANDBOX_TYPE, DEFAULT_POLICY, DESCENDANT_LIMIT, DESCENDANT_SAMPLE_MS, reason, bridgeGateReasons} from './role-dispatch-policy.mjs';
|
|
14
|
-
import {readLease, writeLease, writeHeartbeat, cancelRequested, dispatchDirectory, TERMINAL_STATES} from './role-dispatch-store.mjs';
|
|
14
|
+
import {readLease, writeLease, writeHeartbeat, cancelRequested, dispatchDirectory, TERMINAL_STATES, listLeases, readWorktreeRecord, worktreeWriters} from './role-dispatch-store.mjs';
|
|
15
15
|
import {withRoutingLock, readActivation, resolveRuntimeHomes} from './role-routing.mjs';
|
|
16
16
|
import {resolveLocalCli, localCliEnvironment} from './local-cli.mjs';
|
|
17
17
|
import {parseCompositeProfile, buildBridgeArgs, argsDigest, ROLE_BRIDGE_PERMISSIONS} from './role-bridge-args.mjs';
|
|
@@ -743,6 +743,7 @@ export async function runSupervisor(options) {
|
|
|
743
743
|
control: await snapshotControlFiles({gitCommonDir: target.gitCommonDir, gitDir: target.gitDir, worktree: target.realpath, extra}),
|
|
744
744
|
});
|
|
745
745
|
let before;
|
|
746
|
+
const sinceMs = Date.now();
|
|
746
747
|
try { before = await snapshot(); } catch { return await failWithProfileCleanup('execution_failed'); }
|
|
747
748
|
|
|
748
749
|
if (invocation.promptFile) {
|
|
@@ -925,9 +926,22 @@ export async function runSupervisor(options) {
|
|
|
925
926
|
}
|
|
926
927
|
|
|
927
928
|
let after = null;
|
|
929
|
+
const otherOwners = await locked(async () => {
|
|
930
|
+
const worktree = target.realpath;
|
|
931
|
+
const own = await readWorktreeRecord(codexHome, dispatchId);
|
|
932
|
+
if (own?.segment !== lease.segment || own.worktree !== worktree) return [];
|
|
933
|
+
const leases = await listLeases(codexHome, {runtimePlatforms});
|
|
934
|
+
const records = new Map();
|
|
935
|
+
for (const item of leases) {
|
|
936
|
+
if (item.dispatchId !== dispatchId && item.route === 'bridge' && (item.role === 'arc_implementer' || item.role === 'arc_tester')) {
|
|
937
|
+
records.set(item.dispatchId, await readWorktreeRecord(codexHome, item.dispatchId));
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
return worktreeWriters({leases, records, dispatchId, worktree, terminalSinceMs: sinceMs, excludeUnknown: true});
|
|
941
|
+
}).catch(() => []);
|
|
928
942
|
try { after = await snapshot(); } catch { after = null; }
|
|
929
943
|
const headAdvance = after ? await observeHeadAdvance(target.realpath, before, after, lease.role, lease.allowedPaths) : null;
|
|
930
|
-
const violations = after ? detectViolations({role: lease.role, allowedPaths: lease.allowedPaths, before, after, headAdvance}) : {reason: null, changedPaths: [], headChanged: false, refsChanged: false, controlChanged: [], toleratedRefs: [], toleratedControl: [], toleratedCommitPaths: []};
|
|
944
|
+
const violations = after ? detectViolations({role: lease.role, allowedPaths: lease.allowedPaths, before, after, headAdvance, otherOwners}) : {reason: null, changedPaths: [], headChanged: false, refsChanged: false, controlChanged: [], toleratedRefs: [], toleratedControl: [], toleratedCommitPaths: [], attributedPaths: []};
|
|
931
945
|
const codes = [];
|
|
932
946
|
if (state.mismatch) codes.push(state.mismatch);
|
|
933
947
|
if (state.internal) codes.push(state.internal);
|
package/lib/tui/diagram.mjs
CHANGED
|
@@ -42,7 +42,6 @@ export function diagramRows(roleRows,{columns=80,rows=24,selectedRole,blink=true
|
|
|
42
42
|
return {mode:'compact',rows:[...values.map(roleRow),'']};
|
|
43
43
|
}
|
|
44
44
|
const center=Math.floor(boxWidth/2),middle=boxWidth+2+center,right=2*(boxWidth+2)+center;
|
|
45
|
-
const indent=Math.floor((total-(boxWidth*2+2))/2),bottomLeft=indent+center,bottomRight=bottomLeft+boxWidth+2;
|
|
46
45
|
const box=(value,index,up)=>{
|
|
47
46
|
const hidden=index===selectedRole&&!blink,edge=hidden?' ':'│',label=(index===selectedRole?'> ':'')+value.label;
|
|
48
47
|
const top=hidden?' '+label+' '.repeat(boxWidth-3-cells(label)):'┌─ '+label+' '+'─'.repeat(boxWidth-cells(label)-5)+'┐';
|
|
@@ -62,7 +61,7 @@ export function diagramRows(roleRows,{columns=80,rows=24,selectedRole,blink=true
|
|
|
62
61
|
};
|
|
63
62
|
return {mode:'full',rows:[
|
|
64
63
|
...group([0,1,2],0,false),bus(center,right,[center,middle,right],true),
|
|
65
|
-
' '.repeat(Math.max(0,middle-6))+'Orchestrator',bus(
|
|
66
|
-
...group([3,4],
|
|
64
|
+
' '.repeat(Math.max(0,middle-6))+'Orchestrator',bus(center,right,[center,middle,right]),
|
|
65
|
+
...group([3,4,5],0,true),
|
|
67
66
|
]};
|
|
68
67
|
}
|
package/lib/tui/setup.mjs
CHANGED
|
@@ -23,7 +23,7 @@ export function loadRoleDefaults({context,statuses,target,readText=filename=>rea
|
|
|
23
23
|
return resolved.roles;
|
|
24
24
|
}
|
|
25
25
|
const installSettingKeys=['runMode','language','maxTotalSubagents','maxConcurrentSubagents'];
|
|
26
|
-
const installRoleNames=['Scouter','Planner','Implementer','Tester','Reviewer'];
|
|
26
|
+
const installRoleNames=['Scouter','Architect','Planner','Implementer','Tester','Reviewer'];
|
|
27
27
|
export function roleDisplayName(role){return installRoleNames[ROLES.indexOf(role)]??role;}
|
|
28
28
|
|
|
29
29
|
export function installSettingsDraft(statuses,platforms){
|
|
@@ -153,10 +153,12 @@ export async function runInstallFlow({ui,statuses,draft,installState,currentConf
|
|
|
153
153
|
const label=name(settings[key]);
|
|
154
154
|
return state?arrowValue(label,state.frame,state.selected===index):label;
|
|
155
155
|
};
|
|
156
|
+
const hostsIndex=ROLES.length,runModeIndex=hostsIndex+1,languageIndex=hostsIndex+2;
|
|
157
|
+
const totalIndex=hostsIndex+3,concurrentIndex=hostsIndex+4,applyIndex=hostsIndex+5;
|
|
156
158
|
const controlsFor=state=>[
|
|
157
159
|
hostsRow,
|
|
158
|
-
'Run mode '+display('runMode',runModeName,state,
|
|
159
|
-
'Language '+display('language',languageName,state,
|
|
160
|
+
'Run mode '+display('runMode',runModeName,state,runModeIndex),
|
|
161
|
+
'Language '+display('language',languageName,state,languageIndex),
|
|
160
162
|
'Total subagents '+display('maxTotalSubagents'),
|
|
161
163
|
'Concurrent subagents '+display('maxConcurrentSubagents'),
|
|
162
164
|
`Apply - ${plan.modeLabel}`,'Back',
|
|
@@ -165,7 +167,7 @@ export async function runInstallFlow({ui,statuses,draft,installState,currentConf
|
|
|
165
167
|
const cycleLanguage=()=>{settings.language=settings.language==='ko'?'en':'ko';settings.touched.add('language');};
|
|
166
168
|
const choice=await ui.menu('Configure',[...installRoleNames,...controlsFor().slice(0,-1)],{
|
|
167
169
|
selected,backRow:true,refreshMs:600,notice:info,
|
|
168
|
-
onHorizontal:({selected})=>{if(selected===
|
|
170
|
+
onHorizontal:({selected})=>{if(selected===runModeIndex)cycleRunMode();else if(selected===languageIndex)cycleLanguage();},
|
|
169
171
|
renderBody:state=>{
|
|
170
172
|
const controls=controlsFor(state);
|
|
171
173
|
const notices=settings.runMode==='full-auto'&&!isMixed('runMode')?[...info,fullAutoNotice]:info;
|
|
@@ -188,21 +190,21 @@ export async function runInstallFlow({ui,statuses,draft,installState,currentConf
|
|
|
188
190
|
return {model:value.model,effort:value[field]};
|
|
189
191
|
},registry});
|
|
190
192
|
if(edited)draft.roles[role]=edited;
|
|
191
|
-
}else if(choice===
|
|
193
|
+
}else if(choice===hostsIndex){
|
|
192
194
|
const hosts=await editHosts({ui,hosts:draft.hosts,rolePlatforms:ROLES.map(role=>draft.roles[role].platform),availabilityOf:id=>availabilityOf(id,'host'),registry});
|
|
193
195
|
if(hosts!==null)draft.hosts=hosts;
|
|
194
|
-
}else if(choice===
|
|
195
|
-
else if(choice===
|
|
196
|
-
else if(choice===
|
|
197
|
-
const key=choice===
|
|
198
|
-
const title=choice===
|
|
196
|
+
}else if(choice===runModeIndex)cycleRunMode();
|
|
197
|
+
else if(choice===languageIndex)cycleLanguage();
|
|
198
|
+
else if(choice===totalIndex||choice===concurrentIndex){
|
|
199
|
+
const key=choice===totalIndex?'maxTotalSubagents':'maxConcurrentSubagents';
|
|
200
|
+
const title=choice===totalIndex?'Total subagents':'Concurrent subagents';
|
|
199
201
|
let raw=isMixed(key)?'':String(settings[key]);
|
|
200
202
|
while(true){
|
|
201
203
|
raw=await ui.text(title,raw);if(raw===null)break;
|
|
202
204
|
let value;try{value=parsePositiveLimit(raw);}catch{await ui.page('Invalid limit',['Enter a positive whole number.']);continue;}
|
|
203
205
|
settings[key]=value;settings.touched.add(key);break;
|
|
204
206
|
}
|
|
205
|
-
}else if(choice===
|
|
207
|
+
}else if(choice===applyIndex){
|
|
206
208
|
if(reason)continue;
|
|
207
209
|
if(plan.rule==='D1-f'){
|
|
208
210
|
await ui.page('Operation unavailable',[installState.reason??'Mixed routing configuration cannot be verified.',...(installState.residualPaths??[]).map(value=>'Residual path: '+value),'No changes were applied.']);continue;
|
package/lib/watch/labels.mjs
CHANGED
|
@@ -3,7 +3,7 @@ export function asciiToken(s) {
|
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export function roleFromName(name) {
|
|
6
|
-
const role = typeof name === 'string' ? /^arc[_-](?:routing[_-])?(scouter|planner|implementer|tester|reviewer|qa)$/.exec(name)?.[1] : undefined;
|
|
6
|
+
const role = typeof name === 'string' ? /^arc[_-](?:routing[_-])?(scouter|architect|planner|implementer|tester|reviewer|qa)$/.exec(name)?.[1] : undefined;
|
|
7
7
|
return role === 'qa' ? 'tester' : role ?? null;
|
|
8
8
|
}
|
|
9
9
|
|
package/lib/watch/model.mjs
CHANGED
|
@@ -5,7 +5,7 @@ export function classifyMessageKind(event) {
|
|
|
5
5
|
return event.kind === 'user' && (event.parentId || event.dispatchId) ? 'prompt' : event.kind;
|
|
6
6
|
}
|
|
7
7
|
export const VERBOSE_KINDS = Object.freeze(['settings','turn_start','reasoning','other']);
|
|
8
|
-
export const ROLE_NAMES = Object.freeze(['scouter','planner','implementer','tester','reviewer']);
|
|
8
|
+
export const ROLE_NAMES = Object.freeze(['scouter','architect','planner','implementer','tester','reviewer']);
|
|
9
9
|
|
|
10
10
|
export const WATCH_LIMITS = Object.freeze({
|
|
11
11
|
filePollMs:500, discoveryMs:2000, worktreeRefreshMs:30000, holdMs:2000,
|
|
@@ -37,7 +37,7 @@ export const WATCH_LIMITS = Object.freeze({
|
|
|
37
37
|
* @property {string} [parentId]
|
|
38
38
|
* @property {number} [depth]
|
|
39
39
|
* @property {string} label
|
|
40
|
-
* @property {'scouter'|'planner'|'implementer'|'tester'|'reviewer'|'orchestrator'} [role]
|
|
40
|
+
* @property {'scouter'|'architect'|'planner'|'implementer'|'tester'|'reviewer'|'orchestrator'} [role]
|
|
41
41
|
* @property {string} [dispatchId]
|
|
42
42
|
* @property {string} [workflowId]
|
|
43
43
|
* @property {'session'|'settings'|'turn_start'|'turn_end'|'turn_failed'|'user'|'prompt'|'agent'|'reasoning'|'command'|'tool'|'tool_failed'|'file_change'|'file_create'|'file_delete'|'spawn'|'approval'|'dispatch'|'error'|'other'|'notice'} kind
|
package/lib/watch/render.mjs
CHANGED
|
@@ -8,11 +8,11 @@ import {displayWidth, wrapLine} from './text-width.mjs';
|
|
|
8
8
|
export {displayWidth, wrapLine} from './text-width.mjs';
|
|
9
9
|
|
|
10
10
|
const roleLabels = new Map([
|
|
11
|
-
['scouter','SCOUTER'], ['planner','PLANNER'], ['implementer','IMPLEMENTER'],
|
|
11
|
+
['scouter','SCOUTER'], ['architect','ARCHITECT'], ['planner','PLANNER'], ['implementer','IMPLEMENTER'],
|
|
12
12
|
['tester','TESTER'], ['reviewer','REVIEWER'], ['orchestrator','ORCHESTRATOR'],
|
|
13
13
|
]);
|
|
14
14
|
const roleBadgeColors = new Map([
|
|
15
|
-
['scouter','1;38;5;16;48;5;117'], ['planner','1;38;5;231;48;5;98'],
|
|
15
|
+
['scouter','1;38;5;16;48;5;117'], ['architect','1;38;5;231;48;5;30'], ['planner','1;38;5;231;48;5;98'],
|
|
16
16
|
['implementer','1;38;5;16;48;5;214'], ['tester','1;38;5;16;48;5;228'],
|
|
17
17
|
['reviewer','1;38;5;231;48;5;161'], ['orchestrator','1;38;5;16;48;5;255'],
|
|
18
18
|
]);
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@ function visit(relative) {
|
|
|
17
17
|
} else if (stat.isFile() && !mutable.has(relative)) files.set(relative,fs.readFileSync(filename));
|
|
18
18
|
else if (!stat.isFile()) throw new Error(`Protected payload is not regular: ${relative}`);
|
|
19
19
|
}
|
|
20
|
-
for (const entry of ['
|
|
20
|
+
for (const entry of ['install.command', 'package.json', 'bin', 'lib', 'native/binding.c', 'native/binding.gyp', 'scripts', 'vendor', 'prebuilds', 'shared/skill', 'codex/skill', 'codex/agents', 'claude/skill', 'claude/agents', 'gemini', 'grok']) visit(entry);
|
|
21
21
|
const content = renderManifest(files);
|
|
22
22
|
const manifest = path.join(root, 'MANIFEST.sha256');
|
|
23
23
|
if (process.argv.includes('--check')) {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Visual companion — shared text
|
|
2
|
+
|
|
3
|
+
This file holds text shared by every platform's arc-visual-companion.md. Each part belongs to the section that links to it and has the same force there.
|
|
4
|
+
|
|
5
|
+
<a id="visual-companion"></a>
|
|
6
|
+
# Visual companion
|
|
7
|
+
|
|
8
|
+
Read before offering or operating the companion. Design discussion is distinct from Tester UI acceptance under an approved test brief.
|
|
9
|
+
|
|
10
|
+
Use visuals when they materially help design discussion or verification. Orchestrator determines actual capability/consent. Architect returns visualization needs only; DO NOT invent browser/shell access. Other depth-2 roles stay within their profile tool limits and cannot delegate visualization.
|
|
11
|
+
|
|
12
|
+
- Verify actual browser/preview capability; NEVER assume platform preview support.
|
|
13
|
+
- Use an available authorized local/browser flow only within Orchestrator scope.
|
|
14
|
+
- Separate preview artifacts from user files, record side effects and preserve unrelated work. Report unavailable capability without claiming visual verification.
|
|
15
|
+
- NEVER expose secrets or publish previews without authorization.
|
|
16
|
+
|
|
17
|
+
1. Architect returns a useful visual question, reason, options, user decision and complete content draft; no screen writing, server/browser operation or approval request.
|
|
18
|
+
2. Orchestrator offers in a separate message when visuals clarify the question, then waits for acceptance. After refusal, continue in text without reoffering unless the user raises it.
|
|
19
|
+
3. After acceptance, decide per question. A UI topic or companion consent does not route every question to a browser.
|
|
20
|
+
4. Orchestrator owns guide, server/browser, paths, live-session checks, complete keyed URL, screens/session state, feedback/events and cleanup. Clear stale screens when returning to text. Check the server before display. After replies, terminal text is primary and events supplemental.
|
|
21
|
+
|
|
22
|
+
Upstream guide/scripts: `<installed ARC>/references/visual-companion.md` and adjacent `scripts/`. ARC guide: `references/arc-visual-companion.md`. Orchestrator supplies absolute paths and owns approval/server/browser. Missing files stop dependent work; no global fallback.
|
|
23
|
+
|
|
24
|
+
1. Run upstream relative commands from installed ARC `references/`; Orchestrator supplies the absolute working directory.
|
|
25
|
+
2. Record `screen_dir`, `state_dir` and the complete keyed URL from the server or this session's `state/server-info`. NEVER guess another session path.
|
|
26
|
+
3. A/B highlighting proves selection display only. Separately inspect that session's exact `state_dir/events` for saved events. Clicking starts neither a chat turn nor an automatic response.
|
|
27
|
+
4. Tell the user to return to chat and send a follow-up after selection. On the actual next turn, reread the same events file and combine it with the current message. Current chat text is primary; events are supplemental. Chat wins conflicts; clarify missing/ambiguous feedback.
|
|
28
|
+
5. DO NOT infer storage from highlighting or next-turn consumption from an earlier Tester parse. Preserve imported guide/scripts.
|
|
29
|
+
|
|
30
|
+
<a id="follow-up-verification-of-approved-visual-sources"></a>
|
|
31
|
+
## Follow-up verification of approved visual sources
|
|
32
|
+
|
|
33
|
+
Each visual criterion requires the exact approved source location, version, approval and access state; criterion IDs, properties and comparison method; and evidence linking the actual output to its revision. Implementer reporting does not replace fresh Tester comparison.
|
|
34
|
+
|
|
35
|
+
- Record pass/mismatch/unverified and connect to proven/unmet/unverified criterion verdicts. Pass requires accessible evidence meeting the criterion; unsupported claims remain unverified.
|
|
36
|
+
- A missing revision link is unverified; a visible difference is a mismatch. Record them separately without inferring the current branch UI state.
|
|
37
|
+
- Hold comparison for inaccessible source/output or missing interpretation approval.
|
|
38
|
+
|
|
39
|
+
Static checks of policy, generated files and the manifest prove structure only, not actual role behavior, installed builds, platform CLI compliance or visual fidelity. Report changes, exclusions, checks run and omitted, criterion evidence and limits, and platform availability. Separate baseline failures. Independent progress never relaxes checks or criteria.
|