@yunhozz/arc 0.5.1 → 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 (144) hide show
  1. package/MANIFEST.sha256 +139 -136
  2. package/README.md +2 -2
  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 +6 -6
  9. package/claude/skill/models.toml +2 -2
  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 -21
  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 +67 -35
  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 +7 -7
  27. package/codex/skill/models.toml +2 -2
  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 -20
  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 +68 -36
  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 +7 -7
  40. package/gemini/agents/arc-planner.md +5 -5
  41. package/gemini/agents/arc-reviewer.md +6 -6
  42. package/gemini/agents/arc-scouter.md +5 -5
  43. package/gemini/agents/{arc-qa.md → arc-tester.md} +10 -10
  44. package/gemini/skill/SKILL.md +6 -6
  45. package/gemini/skill/models.toml +2 -2
  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 -21
  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 +67 -35
  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 +6 -6
  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 -21
  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 +67 -35
  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 +1 -0
  82. package/lib/installer/targets.mjs +1 -1
  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 +10 -10
  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/operations.mjs +41 -3
  108. package/lib/runtime/role-bridge-args.mjs +5 -5
  109. package/lib/runtime/role-bridge.mjs +10 -2
  110. package/lib/runtime/role-dispatch-policy.mjs +6 -4
  111. package/lib/runtime/role-dispatch-store.mjs +3 -0
  112. package/lib/runtime/role-observe.mjs +5 -5
  113. package/lib/runtime/role-routing-config.mjs +20 -6
  114. package/lib/runtime/role-routing.mjs +4 -3
  115. package/lib/runtime/schema.mjs +8 -5
  116. package/lib/runtime/scope.mjs +1 -1
  117. package/lib/runtime/store.mjs +2 -2
  118. package/lib/runtime/verification.mjs +15 -7
  119. package/lib/tui/setup.mjs +1 -1
  120. package/lib/watch/labels.mjs +2 -1
  121. package/lib/watch/model.mjs +2 -2
  122. package/lib/watch/render.mjs +2 -2
  123. package/package.json +1 -1
  124. package/shared/skill/runtime/acceptance.mjs +4 -3
  125. package/shared/skill/runtime/bootstrap.mjs +3 -1
  126. package/shared/skill/runtime/command.mjs +27 -1
  127. package/shared/skill/runtime/cooperative-schema.mjs +16 -5
  128. package/shared/skill/runtime/cooperative.mjs +6 -3
  129. package/shared/skill/runtime/evaluate.mjs +10 -7
  130. package/shared/skill/runtime/handoff-record.mjs +58 -0
  131. package/shared/skill/runtime/identity.mjs +10 -7
  132. package/shared/skill/runtime/operations.mjs +41 -3
  133. package/shared/skill/runtime/role-bridge-args.mjs +5 -5
  134. package/shared/skill/runtime/role-bridge.mjs +10 -2
  135. package/shared/skill/runtime/role-dispatch-policy.mjs +6 -4
  136. package/shared/skill/runtime/role-dispatch-store.mjs +3 -0
  137. package/shared/skill/runtime/role-observe.mjs +5 -5
  138. package/shared/skill/runtime/role-policy.json +28 -28
  139. package/shared/skill/runtime/role-routing-config.mjs +20 -6
  140. package/shared/skill/runtime/role-routing.mjs +4 -3
  141. package/shared/skill/runtime/schema.mjs +8 -5
  142. package/shared/skill/runtime/scope.mjs +1 -1
  143. package/shared/skill/runtime/store.mjs +2 -2
  144. package/shared/skill/runtime/verification.mjs +15 -7
@@ -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)});}
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','QA','Reviewer'];
26
+ const installRoleNames=['Scouter','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){
@@ -3,7 +3,8 @@ export function asciiToken(s) {
3
3
  }
4
4
 
5
5
  export function roleFromName(name) {
6
- return typeof name === 'string' ? /^arc[_-](?:routing[_-])?(scouter|planner|implementer|qa|reviewer)$/.exec(name)?.[1] ?? null : null;
6
+ const role = typeof name === 'string' ? /^arc[_-](?:routing[_-])?(scouter|planner|implementer|tester|reviewer|qa)$/.exec(name)?.[1] : undefined;
7
+ return role === 'qa' ? 'tester' : role ?? null;
7
8
  }
8
9
 
9
10
  export function topLabel({platform, origin, sessionId}) {
@@ -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','qa','reviewer']);
8
+ export const ROLE_NAMES = Object.freeze(['scouter','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'|'qa'|'reviewer'|'orchestrator'} [role]
40
+ * @property {'scouter'|'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
@@ -9,11 +9,11 @@ export {displayWidth, wrapLine} from './text-width.mjs';
9
9
 
10
10
  const roleLabels = new Map([
11
11
  ['scouter','SCOUTER'], ['planner','PLANNER'], ['implementer','IMPLEMENTER'],
12
- ['qa','QA'], ['reviewer','REVIEWER'], ['orchestrator','ORCHESTRATOR'],
12
+ ['tester','TESTER'], ['reviewer','REVIEWER'], ['orchestrator','ORCHESTRATOR'],
13
13
  ]);
14
14
  const roleBadgeColors = new Map([
15
15
  ['scouter','1;38;5;16;48;5;117'], ['planner','1;38;5;231;48;5;98'],
16
- ['implementer','1;38;5;16;48;5;214'], ['qa','1;38;5;16;48;5;228'],
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
  ]);
19
19
  export const PLATFORM_COLORS = Object.freeze({codex:'36', claude:'38;5;208', gemini:'38;5;135', other:'2'});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yunhozz/arc",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"
@@ -2,6 +2,7 @@ import path from 'node:path';
2
2
  import {fingerprintRequest} from './store.mjs';
3
3
  import {validateGitPreflight,validateGitCommitResult} from './git-evidence.mjs';
4
4
  import {within} from './scope.mjs';
5
+ import {canonicalCooperativeRole} from './operations.mjs';
5
6
  const reconciliations=new WeakMap();
6
7
  export function verifiedCooperativeReconciliation(decision,state){const proof=reconciliations.get(decision);return !!proof&&proof.before===fingerprintRequest(state)&&proof.after===fingerprintRequest(decision.proposedTransition);}
7
8
  const completed=(state,id)=>state.tasks?.some(t=>t.id===id&&t.status==='committed'&&!t.invalidated)&&state.commits?.some(c=>c.taskId===id&&c.observationSource==='local-git'&&state.intents.some(i=>i.operation==='commit'&&i.requestId===c.requestId&&i.taskId===id&&i.status==='succeeded'));
@@ -20,9 +21,9 @@ function checkEvidence(state,task,a,changes){
20
21
  if(!same(a.criteria,task.criteria)||!task.criteria.length||!list(a.checkIds)||!list(a.findingIds)||a.changeFingerprint!==changes?.tasks?.[task.id])return false;
21
22
  const checks=state.checks.filter(c=>c.scope==='task'&&c.taskId===task.id);
22
23
  const latest=task.requiredChecks.map(d=>checks.filter(c=>same(c.descriptor,d)).at(-1));
23
- if(!task.requiredChecks.length||latest.some(c=>!c||c.stale||c.status!=='passed'||c.verdict!=='proven'||!text(c.resultRef)||c.source!=='operator-attested'||c.verificationActor?.role!=='qa'||!text(c.verificationActor.id)||state.assignments.some(a=>a.agentId===c.verificationActor.id)||c.changeFingerprint!==a.changeFingerprint)||!exact(a.checkIds,latest.map(c=>c?.id)))return false;
24
+ if(!task.requiredChecks.length||latest.some(c=>!c||c.stale||c.status!=='passed'||c.verdict!=='proven'||!text(c.resultRef)||c.source!=='operator-attested'||canonicalCooperativeRole(c.verificationActor?.role)!=='tester'||!text(c.verificationActor.id)||state.assignments.some(a=>a.agentId===c.verificationActor.id)||c.changeFingerprint!==a.changeFingerprint)||!exact(a.checkIds,latest.map(c=>c?.id)))return false;
24
25
  const findings=state.findings.filter(f=>f.scope==='task'&&f.taskId===task.id);
25
- return exact(a.findingIds,findings.map(f=>f.id))&&findings.every(f=>f.status==='closed'&&text(f.resolutionRef)&&text(f.recheckRef)&&f.resolutionActor?.role==='implementer'&&f.recheckActor?.role==='qa'&&f.changeFingerprint===a.changeFingerprint);
26
+ return exact(a.findingIds,findings.map(f=>f.id))&&findings.every(f=>f.status==='closed'&&text(f.resolutionRef)&&text(f.recheckRef)&&f.resolutionActor?.role==='implementer'&&canonicalCooperativeRole(f.recheckActor?.role)==='tester'&&f.changeFingerprint===a.changeFingerprint);
26
27
  }
27
28
  function waitingFor(state,task,predecessor){
28
29
  if(task.status!=='pending'||state.intents.some(i=>i.taskId===task.id&&i.operation==='assign-agent'&&['prepared','unknown','mismatch','succeeded'].includes(i.status)))return false;
@@ -34,7 +35,7 @@ function freshAcceptance(state,task,acceptance,changes){return acceptance&&!acce
34
35
  export function evaluateCooperativeAcceptance({state,request,evidence}={}){
35
36
  const task=state?.tasks?.find(t=>t.id===request?.taskId),a=request?.arguments,g=evidence?.git;
36
37
  if(request?.expectedRevision!==state?.revision||request.actor?.role!=='orchestrator'||!authorized(state,task)||task.status!=='pending'||state.acceptances.some(v=>v.taskId===task.id&&!v.stale)||state.commits.some(v=>v.taskId===task.id))return hold(state,'Current pending approved task and Orchestrator acceptance required');
37
- if(!fields(a,['messageRef','criteria','checkIds','findingIds','changeFingerprint'])||!text(a.messageRef)||!checkEvidence(state,task,a,evidence?.changes)||state.checks.some(c=>a.checkIds?.includes(c.id)&&c.verificationActor?.id===request.actor.id))return hold(state,'Exact criteria, current required QA checks and closed findings required');
38
+ if(!fields(a,['messageRef','criteria','checkIds','findingIds','changeFingerprint'])||!text(a.messageRef)||!checkEvidence(state,task,a,evidence?.changes)||state.checks.some(c=>a.checkIds?.includes(c.id)&&c.verificationActor?.id===request.actor.id))return hold(state,'Exact criteria, current required Tester checks and closed findings required');
38
39
  const descriptor={kind:'task',parent:state.target.head,indexTree:g?.indexTree,fingerprint:g?.stagedFingerprint,paths:g?.stagedPaths};
39
40
  const invalid=validateGitPreflight({target:state.target,descriptor,scope:task.paths,gitEvidence:g});
40
41
  if(invalid||dirtyOtherTask(state,task,g))return hold(state,invalid??'Index includes another task changes');
@@ -1,7 +1,7 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import crypto from 'node:crypto';
4
- import {validateCooperativeCommand,validateCooperativeState} from './cooperative-schema.mjs';
4
+ import {legacyCooperativeRoleDenial,validateCooperativeCommand,validateCooperativeState} from './cooperative-schema.mjs';
5
5
  import {observeCooperativeTarget,validateObservedTarget,validateWorkflowId,workflowStatePath,inspectPath} from './scope.mjs';
6
6
  import {saveDurableState} from './store.mjs';
7
7
  export const COOPERATIVE_RUNTIME_MODULES=Object.freeze([
@@ -22,6 +22,8 @@ export async function cooperativeVersions(){
22
22
  }
23
23
  export async function initializeCooperativeWorkflow({cwd,workflowId,input,observe=observeCooperativeTarget,storage={}}){
24
24
  validateWorkflowId(workflowId);validateCooperativeCommand({command:'init',input});
25
+ const denial=legacyCooperativeRoleDenial(input);
26
+ if(denial)return commandResult({workflowId,input,...denial});
25
27
  if(input.mode!=='plan')return commandResult({workflowId,input,decision:'hold',ruleId:'cooperative.unsupported'});
26
28
  const target=await validateObservedTarget(cwd,await observe(cwd));const statePath=await workflowStatePath(target,workflowId);
27
29
  const parent=path.dirname(statePath);await fs.mkdir(parent,{recursive:true,mode:0o700});await inspectPath(parent,{directory:true});
@@ -3,11 +3,37 @@ import path from 'node:path';
3
3
  import os from 'node:os';
4
4
  import {initializeCooperativeWorkflow,commandResult} from './bootstrap.mjs';
5
5
  import {runCooperativeCommand} from './cooperative.mjs';
6
- import {validateWorkflowId} from './scope.mjs';
6
+ import {absolute,validateWorkflowId} from './scope.mjs';
7
+ import {writeHandoffRecord} from './handoff-record.mjs';
7
8
  import {prepareRoleDispatch,routingStatus,invalidRoutingRequest} from './role-routing.mjs';
8
9
  import {runBridgeDispatch,recordRoleObservation,resumeRoleDispatch,cancelRoleDispatch,heldRoutingResult} from './role-bridge.mjs';
10
+ async function runHandoffRecordCommand([command,...args],io,output){
11
+ const options={};
12
+ try{
13
+ if(command!=='write')throw Error('Expected handoff-record write');
14
+ for(let i=0;i<args.length;i+=2){
15
+ const key=args[i];
16
+ if(!['--cwd','--slug','--input'].includes(key)||options[key]!==undefined||typeof args[i+1]!=='string')throw Error('Invalid handoff-record option');
17
+ options[key]=args[i+1];
18
+ }
19
+ const cwd=options['--cwd'],slug=options['--slug'];
20
+ if(!absolute(cwd))throw Error('Absolute workspace required');
21
+ if(slug===undefined||options['--input']!=='-')throw Error('Handoff record write requires --slug and --input -');
22
+ const rawInput=io.input??fs.readFileSync(0,'utf8');
23
+ let input;
24
+ try{input=JSON.parse(rawInput);}catch{throw Error('Expected JSON handoff input');}
25
+ if(typeof input?.content!=='string'||!input.content.length)throw Error('Expected nonempty handoff content');
26
+ const result=await writeHandoffRecord({cwd,slug,content:input.content});
27
+ output.write(JSON.stringify(result)+'\n');
28
+ return result.decision==='deny'?2:result.decision==='hold'?3:0;
29
+ }catch(error){
30
+ output.write(JSON.stringify({decision:'hold',reasonCode:'handoff_write_failed',message:error.message,fallback:'inline'})+'\n');
31
+ return 1;
32
+ }
33
+ }
9
34
  export async function runWorkflowCommand(args,io={}){
10
35
  const output=io.output??process.stdout;let workflowId=null,isRouting=false;
36
+ if(args[0]==='handoff-record')return runHandoffRecordCommand(args.slice(1),io,output);
11
37
  try{
12
38
  const [command,...rest]=args,options={};
13
39
  isRouting=['routing-status','prepare-dispatch','run-dispatch','observe','resume','cancel'].includes(command);
@@ -1,4 +1,4 @@
1
- import {ROLES} from './operations.mjs';
1
+ import {ROLES,canonicalCooperativeRole,hasNewStoredOperationAliases,isLegacyOperation,normalizeStoredOperations} from './operations.mjs';
2
2
  import {assertSecretFree} from './external.mjs';
3
3
  import {object,text,validatePlannerLedger} from './schema.mjs';
4
4
  import {absolute,validateWorkflowId} from './scope.mjs';
@@ -6,10 +6,17 @@ import {validateTargetPreparationRecord} from './target-preparation.mjs';
6
6
  const fail=message=>{throw Error('Cooperative schema: '+message);};
7
7
  const hash=value=>typeof value==='string'&&/^sha256:[a-f0-9]{64}$/.test(value);
8
8
  const revision=value=>Number.isSafeInteger(value)&&value>=0;
9
- const actor=value=>object(value)&&text(value.id)&&Object.keys(value).every(k=>['id','role'].includes(k))&&(value.role===undefined||ROLES.includes(value.role));
9
+ const actor=value=>object(value)&&text(value.id)&&Object.keys(value).every(k=>['id','role'].includes(k))&&(value.role===undefined||ROLES.includes(canonicalCooperativeRole(value.role)));
10
10
  const statement=value=>object(value)&&text(value.messageRef)&&object(value.data);
11
11
  function fields(value,allowed){if(!object(value)||Object.keys(value).some(k=>!allowed.includes(k)))fail('unexpected input field');}
12
12
  function json(value){try{const encoded=JSON.stringify(value);if(encoded===undefined)fail('JSON input');}catch{fail('JSON input');}}
13
+ export function legacyCooperativeRoleDenial(input){
14
+ let ruleId;
15
+ if(input?.actor?.role==='qa')ruleId='cooperative.verification-actor';
16
+ else if(input?.arguments?.actor?.role==='qa'||input?.result?.data?.actor?.role==='qa')ruleId='cooperative.verification-independence';
17
+ else if(input?.evidence?.kind==='finding'&&input.evidence.data?.actor?.role==='qa')ruleId='cooperative.finding-resolution';
18
+ if(ruleId)return {decision:'deny',ruleIds:[ruleId],reason:'legacy_role_qa'};
19
+ }
13
20
  export function validateCooperativeCommand(command){
14
21
  assertSecretFree(command);fields(command,['command','input']);const {input,command:name}=command;
15
22
  if(!['init','record','status','reconcile','prepare','result'].includes(name))fail('command');
@@ -17,6 +24,7 @@ export function validateCooperativeCommand(command){
17
24
  const resultStatement=name==='reconcile'||name==='result'&&input?.operation===undefined;
18
25
  const allowed=name==='init'?['mode','actor','selection']:name==='record'?['requestId','expectedRevision','actor','evidence']:resultStatement?['requestId','expectedRevision','actor','intentId','result']:['requestId','expectedRevision','actor','operation','taskId','arguments'];
19
26
  fields(input,allowed);json(input);
27
+ // Recognize this input shape so command entry points can return the role denial.
20
28
  if(!actor(input.actor))fail('actor attestation');
21
29
  if(name==='init'){
22
30
  if(!['plan','no-plan','small-task'].includes(input.mode)||!object(input.selection)||!text(input.selection.messageRef)||!hash(input.selection.contentHash)||Object.keys(input.selection).some(k=>!['messageRef','contentHash'].includes(k)))fail('target selection');
@@ -33,10 +41,10 @@ export function validateCooperativeCommand(command){
33
41
  if(!text(input.intentId)||!statement(input.result)||!['succeeded','failed','unknown','mismatch','cancelled'].includes(input.result.status))fail('result evidence');
34
42
  if(input.result.status==='cancelled'&&(!object(input.result.notExecutedEvidence)||!text(input.result.notExecutedEvidence.messageRef)))fail('cancel requires not-executed evidence');
35
43
  }
36
- if((name==='prepare'||name==='result'&&!resultStatement)&&!text(input.operation))fail('operation');
44
+ if((name==='prepare'||name==='result'&&!resultStatement)&&(!text(input.operation)||isLegacyOperation(input.operation)))fail('operation');
37
45
  return command;
38
46
  }
39
- export function validateCooperativeState(state){
47
+ export function validateCooperativeState(state,{allowLegacyOperations=true,preserveStoredOperations=false,legacyOperationsFrom}={}){
40
48
  if(!object(state)||state.workflowKind!=='cooperative'||state.contractVersion!==1||state.schemaVersion!==1||!revision(state.revision)||state.mode!=='plan')fail('explicit cooperative contract');
41
49
  validateWorkflowId(state.workflowId);
42
50
  if(!object(state.target)||!absolute(state.target.realpath)||!absolute(state.target.gitCommonDir)||!absolute(state.target.gitDir)||!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(state.target.head)||!(state.target.branch===null||text(state.target.branch)))fail('target');
@@ -60,5 +68,8 @@ export function validateCooperativeState(state){
60
68
  for(const checkpoint of checkpoints){try{validateTargetPreparationRecord('checkpoint',{type:'checkpoint',...checkpoint});}catch{fail('target checkpoint');}if(checkpoint.source!=='operator-attested'||!text(checkpoint.messageRef)||!preparationIntents.some(i=>i.id===checkpoint.intentId&&i.firstStageId===checkpoint.stageId)||!state.records.some(r=>r.kind==='target-preparation'&&r.messageRef===checkpoint.messageRef&&r.source==='operator-attested'))fail('target checkpoint provenance');}
61
69
  for(const transition of transitions){const request=transition.validation?.request;try{validateTargetPreparationRecord('transition',request);}catch{fail('target transition');}if(!object(transition.target)||!text(transition.messageRef)||!Number.isSafeInteger(transition.targetVersion)||transition.targetVersion!==transition.sourceTargetVersion+1||request.intentId!==transition.intentId||request.checkpointRef!==transition.checkpointRef||!preparationIntents.some(i=>i.id===transition.intentId)||!checkpoints.some(c=>c.intentId===transition.intentId&&c.messageRef===transition.checkpointRef)||!state.records.some(r=>r.kind==='target-preparation'&&r.messageRef===transition.messageRef&&r.source==='operator-attested'))fail('target transition provenance');}
62
70
  for(const document of documents){try{validateTargetPreparationRecord('destination',document);}catch{fail('target document');}if(document.sourceLink!=='operator-attested'||document.verification?.status!=='verified'||document.verification?.source!=='local-bytes'||!text(document.messageRef)||!transitions.some(t=>t.intentId===document.intentId&&t.messageRef===document.transitionRef&&t.targetVersion===document.targetVersion)||!state.records.some(r=>r.kind==='target-preparation'&&r.messageRef===document.messageRef&&r.source==='operator-attested'))fail('target document provenance');}
63
- assertSecretFree(state);json(state);return state;
71
+ assertSecretFree(state);json(state);
72
+ const normalized=normalizeStoredOperations(state);
73
+ if(!allowLegacyOperations&&normalized!==state&&(!legacyOperationsFrom||hasNewStoredOperationAliases(state,legacyOperationsFrom)))fail('legacy operation in new state');
74
+ return preserveStoredOperations?state:normalized;
64
75
  }
@@ -7,7 +7,7 @@ import fs from 'node:fs/promises';
7
7
  import {constants} from 'node:fs';
8
8
  import path from 'node:path';
9
9
  import {createHash} from 'node:crypto';
10
- import {validateCooperativeCommand,validateCooperativeState} from './cooperative-schema.mjs';
10
+ import {legacyCooperativeRoleDenial,validateCooperativeCommand,validateCooperativeState} from './cooperative-schema.mjs';
11
11
  import {observeCooperativeTarget,validateObservedTarget,validateWorkflowId,workflowStatePath,inspectPath,absolute,within} from './scope.mjs';
12
12
  import {fingerprintRequest,saveDurableState,applyCooperativeCommitTransition,applyCooperativeTargetTransition} from './store.mjs';
13
13
  import {commandResult,cooperativeVersions} from './bootstrap.mjs';
@@ -18,9 +18,11 @@ const sameCheckout=(a,b)=>['realpath','gitCommonDir','gitDir'].every(k=>a[k]===b
18
18
  /** Only trusted code may inject observation/storage. CLI JSON cannot set either. */
19
19
  export async function runCooperativeCommand({cwd,workflowId,command,input,observe=observeCooperativeTarget,storage={},readGit=readAssignmentGitEvidence,readChanges=readCooperativeChanges,readCommitGit=readCooperativeCommitGitEvidence}){
20
20
  validateWorkflowId(workflowId);validateCooperativeCommand({command,input});
21
+ const denial=legacyCooperativeRoleDenial(input);
22
+ if(denial)return commandResult({workflowId,input,...denial});
21
23
  if(command==='init')throw Error('Use initializeCooperativeWorkflow for init');
22
24
  const target=await validateObservedTarget(cwd,await observe(cwd)),statePath=await workflowStatePath(target,workflowId);
23
- const read=async()=>{await inspectPath(statePath);const state=validateCooperativeState(JSON.parse(await fs.readFile(statePath,'utf8')));if(state.workflowId!==workflowId)throw Error('Workflow identity mismatch');return state;};
25
+ const read=async()=>{await inspectPath(statePath);const state=validateCooperativeState(JSON.parse(await fs.readFile(statePath,'utf8')),{preserveStoredOperations:command!=='status'});if(state.workflowId!==workflowId)throw Error('Workflow identity mismatch');return state;};
24
26
  const result=(state,decision,extra={})=>commandResult({workflowId,state,input,...decision,...extra});
25
27
  const removedDecision=state=>{const decision=evaluateCooperative({state,request:{command,input}});return decision.ruleIds[0]==='cooperative.plan-amend-removed'?decision:null;};
26
28
  if(command==='status'){
@@ -35,6 +37,7 @@ export async function runCooperativeCommand({cwd,workflowId,command,input,observ
35
37
  let lock,plannerLock;
36
38
  try{
37
39
  lock=await fs.open(statePath+'.lock','wx',0o600);let state=await read();
40
+ const previousOperations={approvals:[...state.approvals],assignments:[...state.assignments],audit:[...state.audit]};
38
41
  const removed=removedDecision(state);if(removed)return result(state,removed);
39
42
  const plannerWork=command==='prepare'&&input.operation==='planner-call'||command==='record'&&input.evidence.kind.startsWith('planner-');
40
43
  if(plannerWork)plannerLock=await fs.open(path.join(target.gitCommonDir,'arc','planner.lock'),'wx',0o600);
@@ -182,7 +185,7 @@ export async function runCooperativeCommand({cwd,workflowId,command,input,observ
182
185
  const output=result(state,decision,{persisted:true});
183
186
  state.requests.push({requestId:input.requestId,requestFingerprint,request:structuredClone({command,input}),decision:output});
184
187
  state.audit.push({command,requestId:input.requestId,revision:state.revision,decision:output.decision,ruleIds:output.ruleIds,source:'operator-attested',actor:input.actor,...(input.intentId?{intentId:input.intentId,resolution:state.results.at(-1)?.status}:{}),...(input.operation?{operation:input.operation}:{})});
185
- validateCooperativeState(state);await inspectPath(statePath);await saveDurableState({statePath,state,storage});return output;
188
+ validateCooperativeState(state,{allowLegacyOperations:false,legacyOperationsFrom:previousOperations});await inspectPath(statePath);await saveDurableState({statePath,state,storage});return output;
186
189
  }finally{if(plannerLock){await plannerLock.close();await fs.unlink(path.join(target.gitCommonDir,'arc','planner.lock'));}if(lock){await lock.close();await fs.unlink(statePath+'.lock');}}
187
190
  }
188
191
 
@@ -14,20 +14,21 @@ import {prepareCooperativeAssignment} from './assignment.mjs';
14
14
  * @property {object} coverage
15
15
  */
16
16
  import path from 'node:path';
17
- import {validateCooperativeState,validateCooperativeCommand} from './cooperative-schema.mjs';
17
+ import {legacyCooperativeRoleDenial,validateCooperativeState,validateCooperativeCommand} from './cooperative-schema.mjs';
18
18
  import {validateWorkflowState, validateRequest, validateEvidence,validatePlannerStage} from './schema.mjs';
19
- import {ROLES, ROLE_OPERATIONS, GIT_OPERATIONS, EXTERNAL_OPERATIONS} from './operations.mjs';
19
+ import {ROLES, ROLE_OPERATIONS, GIT_OPERATIONS, EXTERNAL_OPERATIONS, canonicalCooperativeRole} from './operations.mjs';
20
20
  const same=(a,b)=>JSON.stringify(a)===JSON.stringify(b);
21
21
  const within=(base,file)=>{const relative=path.relative(base,file);return relative===''||(!relative.startsWith('..'+path.sep)&&relative!=='..'&&!path.isAbsolute(relative));};
22
22
  /** Pure policy decision. Evidence is supplied by a trusted adapter/provider, never tool arguments. */
23
23
  export function evaluate(policy, state, request, evidence){
24
+ const stored=state;
24
25
  const result=(decision,id,reason,requiredEvidence=[])=>({decision,ruleIds:[id],reason,requiredEvidence,expectedRevision:state?.revision??0,proposedTransition:null,coverage:{platform:request?.platform??'unknown',enforcement:'decision-only'}});
25
- try{validateWorkflowState(state);validateRequest(request);validateEvidence(evidence);}catch(error){return result('hold','runtime.schema',error.message,['valid-state-request-evidence']);}
26
+ try{state=validateWorkflowState(state);validateRequest(request);validateEvidence(evidence);}catch(error){return result('hold','runtime.schema',error.message,['valid-state-request-evidence']);}
26
27
  if(policy?.runtime?.schemaVersion!==1||!same(policy.runtime.roles,ROLES)||!Array.isArray(policy.runtime.ruleIds)||!Array.isArray(policy.runtime.requiredEvidence)||policy.runtime.status!=='decision-only')return result('hold','runtime.policy','runtime policy unavailable',['runtime-policy']);
27
28
  const actor=state.identities.find(i=>i.actorRef===request.actorRef);
28
29
  if(!actor)return result('hold','runtime.identity','platform identity unresolved',['platform-identity']);
29
30
  const role=actor.role;
30
- const roleRule={orchestrator:'role.orchestrator-boundary',scouter:'role.scouter-read-only',planner:'role.planner-draft-only',implementer:'role.implementer-implementation',qa:'role.qa-verification',reviewer:'role.reviewer-independent'}[role];
31
+ const roleRule={orchestrator:'role.orchestrator-boundary',scouter:'role.scouter-read-only',planner:'role.planner-draft-only',implementer:'role.implementer-implementation',tester:'role.tester-verification',reviewer:'role.reviewer-independent'}[role]??'runtime.identity';
31
32
  if(!ROLE_OPERATIONS[role]?.includes(request.operation))return result('deny',GIT_OPERATIONS.includes(request.operation)?'git.specialists-deny':roleRule,'operation forbidden for assigned role');
32
33
  const lease=state.leases.find(l=>l.actorRef===actor.actorRef);
33
34
  if(lease?.status==='retired')return result('deny','runtime.identity','retired identity');
@@ -53,7 +54,7 @@ export function evaluate(policy, state, request, evidence){
53
54
  if(role==='implementer'&&['accepted','committed'].includes(task.status))return result('deny','runtime.identity','task execution ended');
54
55
  if(request.operation==='temporary-write'){
55
56
  const temporary=assignment.temporary;
56
- if(!temporary||temporary.cleanupOwner!==request.actorRef||!Number.isFinite(Date.parse(temporary.expiresAt))||!Number.isFinite(Date.parse(evidence.observedAt))||Date.parse(temporary.expiresAt)<=Date.parse(evidence.observedAt)||!request.paths.every(p=>temporary.paths?.some(base=>within(base,p))))return result('hold','role.qa-verification','temporary scope lifetime and cleanup ownership required',['temporary-assignment']);
57
+ if(!temporary||temporary.cleanupOwner!==request.actorRef||!Number.isFinite(Date.parse(temporary.expiresAt))||!Number.isFinite(Date.parse(evidence.observedAt))||Date.parse(temporary.expiresAt)<=Date.parse(evidence.observedAt)||!request.paths.every(p=>temporary.paths?.some(base=>within(base,p))))return result('hold','role.tester-verification','temporary scope lifetime and cleanup ownership required',['temporary-assignment']);
57
58
  }
58
59
  if(request.operation==='check'){
59
60
  if(!assignment.checks?.some(c=>same(c,request.descriptor)))return result('hold',roleRule,'exact assigned check descriptor required',['check-descriptor']);
@@ -82,7 +83,7 @@ export function evaluate(policy, state, request, evidence){
82
83
  if(d.checks&&(!Array.isArray(approval.scope.checks)||d.checks.some(c=>!approval.scope.checks.some(approved=>same(approved,c)))))return result('hold','runtime.assignment','delegated checks not approved',['delegated-checks']);
83
84
  if(d.temporary&&!same(d.temporary,approval.scope.temporary))return result('hold','runtime.assignment','delegated temporary scope not approved',['delegated-temporary-scope']);
84
85
  if(state.assignments.some(a=>a.assignmentId===request.requestId||a.correlationRef===d.correlationRef))return result('hold','runtime.identity','assignment correlation already registered',['new-assignment-correlation']);
85
- const next=structuredClone(state);
86
+ const next=structuredClone(stored);
86
87
  if(d.role==='planner'){
87
88
  const stage=state.plannerLedger?.stages.find(s=>s.id===d.plannerCall?.stageId),proof=fact('planner-call');
88
89
  const contract=stage&&{document:stage.document,inputVersion:stage.inputVersion,criteriaVersion:stage.criteriaVersion,scopeVersion:stage.scopeVersion};
@@ -98,7 +99,7 @@ export function evaluate(policy, state, request, evidence){
98
99
  }
99
100
  if(request.operation==='accept'){
100
101
  const d=request.descriptor;const observed=fact('acceptance')?.data;
101
- const checks=Array.isArray(d.checkIds)&&task.requiredChecks?.every(id=>d.checkIds?.includes(id)&&state.checks.some(c=>c.id===id&&c.taskId===task.id&&c.status==='passed'&&c.fingerprint===d.fingerprint&&c.resultRef&&c.actorRef!==actor.actorRef&&state.identities.some(i=>i.actorRef===c.actorRef&&i.taskId===task.id&&i.role==='qa')));
102
+ const checks=Array.isArray(d.checkIds)&&task.requiredChecks?.every(id=>d.checkIds?.includes(id)&&state.checks.some(c=>c.id===id&&c.taskId===task.id&&c.status==='passed'&&c.fingerprint===d.fingerprint&&c.resultRef&&c.actorRef!==actor.actorRef&&state.identities.some(i=>i.actorRef===c.actorRef&&i.taskId===task.id&&canonicalCooperativeRole(i.role)==='tester')));
102
103
  const findings=state.findings.filter(f=>f.taskId===task.id);
103
104
  if(!observed||!same(observed,d)||!d.fingerprint||!task.criteria?.length||!same(task.criteria,d.criteria)||!checks||findings.some(f=>!Array.isArray(d.findingIds)||!d.findingIds.includes(f.id)||!f.resolutionRef))return result('hold','git.orchestrator-accept-commit','criteria checks findings and fingerprint verification required',['acceptance-evidence']);
104
105
  }
@@ -123,6 +124,8 @@ export function evaluateCooperative({policy,state,request,evidence}={}){
123
124
  const base={expectedRevision:state?.revision??0,coverage:{enforcement:'cooperative',provenance:'operator-attested',nativeVerified:false}};
124
125
  const hold=(id,reason)=>({...base,decision:'hold',ruleIds:[id],reason,requiredEvidence:[],nextActions:[],proposedTransition:null});
125
126
  try{validateCooperativeState(state);validateCooperativeCommand(request);}catch(error){return hold('cooperative.schema',error.message);}
127
+ const denial=legacyCooperativeRoleDenial(request.input);
128
+ if(denial)return {...base,...denial,requiredEvidence:[],nextActions:[],proposedTransition:null};
126
129
  if(state.intents.some(i=>i.operation==='plan-amend'&&['prepared','unknown','mismatch','failed'].includes(i.status)))return {...hold('cooperative.plan-amend-removed','Legacy plan-amend intent is no longer supported; inspect Git history and any refs/arc/recovery/* refs manually, then start a new workflow'),nextActions:['inspect-legacy-plan-amend','start-new-workflow']};
127
130
  if(request.command==='prepare'&&request.input?.operation==='plan-amend')return hold('cooperative.plan-amend-removed','Plan-amend operation is no longer supported');
128
131
  if(policy!==undefined&&policy.workflowKind!=='cooperative')return hold('cooperative.contract','Explicit cooperative policy required');