agents-relay 2.0.203 → 2.0.204

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.
@@ -5,7 +5,7 @@ import { WORKFLOW_EFFECT_NAMES, WORKFLOW_EVENT_NAMES, WORKFLOW_MUTATION_NAMES, }
5
5
  const TASK_STATES = ['DRAFT', 'QUEUED', 'RUNNING', 'BLOCKED', 'SUCCEEDED', 'FAILED', 'CANCELLED'];
6
6
  const JOB_STATES = ['DRAFT', 'ACTIVE', 'COMPLETED', 'CANCELLED'];
7
7
  const conditionRegistry = new ConditionRegistry([
8
- ...new Set(['dependenciesSatisfied', 'dependenciesUnsatisfied', 'runnable', 'dispatchable', 'recoverableExecution', 'troubleshooterRecovery', 'troubleshooterTask', 'awaitingInteractiveDecision', 'retryAvailable', 'notMerged', 'autoMerge', 'prOpen', 'reviewDisabled', 'implementationComplete', 'headAvailable', 'mergeCapable', 'localCompletionAllowed', 'localMergeReady'])
8
+ ...new Set(['dependenciesSatisfied', 'dependenciesUnsatisfied', 'runnable', 'dispatchable', 'recoverableExecution', 'troubleshooterRecovery', 'troubleshooterTask', 'awaitingInteractiveDecision', 'retryAvailable', 'notMerged', 'autoMerge', 'prOpen', 'reviewDisabled', 'implementationComplete', 'headAvailable', 'mergeCapable', 'localCompletionAllowed', 'localMergeReady', 'shortcutCompletionAllowed'])
9
9
  ].map(booleanCondition));
10
10
  const boolGuard = (name) => conditionRegistry.guard(name);
11
11
  export const lifecycleConditions = conditionRegistry;
@@ -29,6 +29,11 @@ export const taskLifecycleV2 = load('task-lifecycle', TASK_STATES, {
29
29
  dependenciesUnsatisfied: boolGuard('dependenciesUnsatisfied'),
30
30
  runnable: boolGuard('runnable'),
31
31
  dispatchable: boolGuard('dispatchable'),
32
+ shortcutExecution: facts => facts.durableFacts.shortcutExecution === true,
33
+ shortcutFallback: facts => facts.durableFacts.shortcutFallback === true,
34
+ shortcutHasGraph: facts => facts.durableFacts.shortcutHasGraph === true,
35
+ shortcutEffectsSafe: facts => facts.durableFacts.shortcutEffectsSafe === true,
36
+ shortcutResultCorrelated: facts => facts.durableFacts.shortcutResultCorrelated === true,
32
37
  recoverableExecution: boolGuard('recoverableExecution'),
33
38
  troubleshooterRecovery: boolGuard('troubleshooterRecovery'),
34
39
  troubleshooterTask: boolGuard('troubleshooterTask'),
@@ -56,6 +61,7 @@ export const jobLifecycleV2 = load('job-lifecycle', JOB_STATES, {
56
61
  && values.reviewSatisfied === true && values.localMergePresent === true
57
62
  && values.reviewHeadCurrent === true && values.mergeAttemptReady === true;
58
63
  },
64
+ shortcutCompletionAllowed: facts => facts.durableFacts.shortcutCompletionAllowed === true,
59
65
  });
60
66
  function topologyTargets(graph, from) {
61
67
  const source = [...graph.nodes.values()].find(node => node.kind === 'state' && node.semanticId === from);
@@ -38,6 +38,15 @@ export function applyTaskMutation(task, mutation) {
38
38
  }
39
39
  if (mutation === 'mutation.markPlannerUnavailable')
40
40
  task.error = 'No objective planner configured';
41
+ if (mutation === 'mutation.markShortcutWorkerFallback') {
42
+ const data = task.result?.data ?? {};
43
+ const shortcut = data.shortcut && typeof data.shortcut === 'object' ? data.shortcut : {};
44
+ task.result = { summary: task.result?.summary ?? 'Shortcut fallback selected', data: { ...data, shortcut: { ...shortcut, workerFallback: true } } };
45
+ task.failureReason = 'shortcut_fallback';
46
+ }
47
+ if (mutation === 'mutation.markShortcutRecoveryRequired') {
48
+ task.failureReason = 'shortcut_requires_recovery';
49
+ }
41
50
  if (mutation === 'mutation.preparePlatformFallback') {
42
51
  task.error = null;
43
52
  task.failureReason = undefined;
@@ -11,6 +11,7 @@ export const taskResolutionV2 = new GraphRuntime(source, {
11
11
  guards: {
12
12
  recoveryOwnerAvailable: boolGuard('recoveryOwnerAvailable'), plannerOwnerAvailable: boolGuard('plannerOwnerAvailable'),
13
13
  exactOriginalRetry: boolGuard('exactOriginalRetry'), sameJobDependency: boolGuard('sameJobDependency'),
14
+ shortcutInterrupted: boolGuard('shortcutInterrupted'),
14
15
  blockerJobDependency: boolGuard('blockerJobDependency'), escalationGate: boolGuard('escalationGate'), genuinelyObsolete: boolGuard('genuinelyObsolete'),
15
16
  freshRecoveryExecution: boolGuard('freshRecoveryExecution'),
16
17
  classifiableFailure: boolGuard('classifiableFailure'),
@@ -18,7 +19,7 @@ export const taskResolutionV2 = new GraphRuntime(source, {
18
19
  supersededEvidenceComplete: boolGuard('supersededEvidenceComplete'),
19
20
  invalidEvidenceComplete: boolGuard('invalidEvidenceComplete'),
20
21
  },
21
- actions: Object.fromEntries(['resolution.activateRecovery', 'resolution.attachSameJobDependency', 'resolution.registerBlockerDependency', 'resolution.createEscalationGate', 'resolution.cancelSupersede', 'resolution.classifySuperseded', 'resolution.classifyInvalid'].map(id => [id, { id }])),
22
+ actions: Object.fromEntries(['resolution.activateRecovery', 'resolution.activateShortcutWorkerFallback', 'resolution.attachSameJobDependency', 'resolution.registerBlockerDependency', 'resolution.createEscalationGate', 'resolution.cancelSupersede', 'resolution.classifySuperseded', 'resolution.classifyInvalid'].map(id => [id, { id }])),
22
23
  events: { 'resolution.propose': { id: 'resolution.propose' }, 'resolution.classify': { id: 'resolution.classify' } },
23
24
  });
24
25
  export function classifyTaskResolution(task, classification, now = new Date().toISOString()) {
@@ -64,7 +65,9 @@ export function validateResolutionProposal(job, original, proposal) {
64
65
  export function resolutionFacts(task, proposal, owner) {
65
66
  const freshRecoveryExecution = owner !== 'troubleshooter' || proposal.path !== 'exact_original_retry' || (Boolean(proposal.recoveryExecutionId)
66
67
  && proposal.recoveryExecutionId !== task.resolution?.recoveryExecutionId);
67
- return { recoveryOwnerAvailable: owner === 'troubleshooter', plannerOwnerAvailable: owner !== null && owner !== 'troubleshooter', exactOriginalRetry: proposal.path === 'exact_original_retry' && task.state === 'FAILED', sameJobDependency: proposal.path === 'same_job_dependency' && owner !== null && proposal.targetTaskId !== task.id, blockerJobDependency: proposal.path === 'blocker_job_dependency' && owner !== null && Boolean(proposal.targetJobId && proposal.mode), escalationGate: proposal.path === 'escalation_gate' && owner === 'troubleshooter' && Boolean(proposal.rootCause && proposal.solution), genuinelyObsolete: proposal.path === 'cancel_supersede' && Boolean(proposal.rootCause), freshRecoveryExecution, unresolved: unresolvedTask(task) };
68
+ const shortcut = task.result?.data?.shortcut;
69
+ const shortcutInterrupted = owner === 'troubleshooter' && Boolean(shortcut && typeof shortcut === 'object' && Object.keys(shortcut.inFlight ?? {}).length > 0);
70
+ return { recoveryOwnerAvailable: owner === 'troubleshooter', plannerOwnerAvailable: owner !== null && owner !== 'troubleshooter', exactOriginalRetry: proposal.path === 'exact_original_retry' && task.state === 'FAILED', shortcutInterrupted, sameJobDependency: proposal.path === 'same_job_dependency' && owner !== null && proposal.targetTaskId !== task.id, blockerJobDependency: proposal.path === 'blocker_job_dependency' && owner !== null && Boolean(proposal.targetJobId && proposal.mode), escalationGate: proposal.path === 'escalation_gate' && owner === 'troubleshooter' && Boolean(proposal.rootCause && proposal.solution), genuinelyObsolete: proposal.path === 'cancel_supersede' && Boolean(proposal.rootCause), freshRecoveryExecution, unresolved: unresolvedTask(task) };
68
71
  }
69
72
  export function decideTaskResolution(task, proposal, owner) {
70
73
  return checkedResolutionDecision(dispatchWorkflowGraphSync(taskResolutionV2, { initialState: 'unresolved', input: { transport: 'event', id: 'resolution.propose', payload: proposal }, durableFacts: resolutionFacts(task, proposal, owner), graphName: 'task-resolution', isTransientState: state => ['check_owner', 'check_path', 'check_fresh_execution'].includes(state), maxSteps: 8 }));
@@ -75,6 +78,7 @@ function checkedResolutionDecision(decision) {
75
78
  export function dispatchTaskResolutionSync(task, proposal, owner, effects) {
76
79
  const handlers = {
77
80
  'resolution.activateRecovery': effects.activateRecovery,
81
+ 'resolution.activateShortcutWorkerFallback': effects.activateShortcutWorkerFallback,
78
82
  'resolution.attachSameJobDependency': effects.attachSameJobDependency,
79
83
  'resolution.registerBlockerDependency': effects.registerBlockerDependency,
80
84
  'resolution.createEscalationGate': effects.createEscalationGate,
@@ -91,6 +95,7 @@ export function dispatchTaskResolutionSync(task, proposal, owner, effects) {
91
95
  export async function dispatchTaskResolution(task, proposal, owner, effects) {
92
96
  const handlers = {
93
97
  'resolution.activateRecovery': effects.activateRecovery,
98
+ 'resolution.activateShortcutWorkerFallback': effects.activateShortcutWorkerFallback,
94
99
  'resolution.attachSameJobDependency': effects.attachSameJobDependency,
95
100
  'resolution.registerBlockerDependency': effects.registerBlockerDependency,
96
101
  'resolution.createEscalationGate': effects.createEscalationGate,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agents-relay",
3
- "version": "2.0.203",
3
+ "version": "2.0.204",
4
4
  "description": "Durable async agent jobs coordinated through GitHub pull requests",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,6 +13,7 @@ cancelDraft["action: effect.cancelActiveTasks"]
13
13
  cancelActive["action: effect.cancelActiveTasks"]
14
14
  localCompletionGuard["guard: localCompletionAllowed"]
15
15
  localMergeReadyGuard["guard: localMergeReady"]
16
+ shortcutCompletionGuard["guard: shortcutCompletionAllowed"]
16
17
  localMergeDelivery["action: effect.deliverLocalMerge"]
17
18
 
18
19
  draft -->|on: activate| active
@@ -28,6 +29,9 @@ cancelActive --> cancelled
28
29
  active -->|on: local.completed| localCompletionGuard
29
30
  localCompletionGuard -->|true| completed
30
31
  localCompletionGuard -->|false| active
32
+ active -->|on: shortcut.completed| shortcutCompletionGuard
33
+ shortcutCompletionGuard -->|true| completed
34
+ shortcutCompletionGuard -->|false| active
31
35
 
32
36
  active -->|on: local.merge.requested| localMergeReadyGuard
33
37
  localMergeReadyGuard -->|true| localMergeDelivery
@@ -23,6 +23,10 @@ depSat["guard: dependenciesSatisfied"]
23
23
  depUnsat["guard: dependenciesUnsatisfied"]
24
24
  runnable["guard: runnable"]
25
25
  dispatchable["guard: dispatchable"]
26
+ shortcutExecution["guard: shortcutExecution"]
27
+ shortcutFallback["guard: shortcutFallback"]
28
+ shortcutHasGraph["guard: shortcutHasGraph"]
29
+ shortcutEffectsSafe["guard: shortcutEffectsSafe"]
26
30
  recoverStart["guard: recoverableExecution"]
27
31
  recoverComplete["guard: recoverableExecution"]
28
32
  recoverBlocked["guard: recoverableExecution"]
@@ -33,6 +37,8 @@ recoveryReopenClearError["action: mutation.clearError"]
33
37
  recoveryReopenClearReason["action: mutation.clearFailureReason"]
34
38
  recoveryReopenClearLease["action: mutation.clearLease"]
35
39
  recoveryReopenClearExecution["action: mutation.clearExecution"]
40
+ shortcutWorkerFallback["action: mutation.markShortcutWorkerFallback"]
41
+ shortcutRecoveryRequired["action: mutation.markShortcutRecoveryRequired"]
36
42
 
37
43
  plannerRetryAvailable["guard: retryAvailable"]
38
44
  platformFallbackSafe["guard: platformFallbackSafe"]
@@ -60,6 +66,9 @@ reconcileDraftClearReason["action: mutation.clearFailureReason"]
60
66
  reconcileQueuedClearError["action: mutation.clearError"]
61
67
  reconcileQueuedClearReason["action: mutation.clearFailureReason"]
62
68
  dispatchLaunch["action: effect.launchTask"]
69
+ shortcutLaunch["action: effect.launchShortcut"]
70
+ shortcutResultCorrelated["guard: shortcutResultCorrelated"]
71
+ shortcutResume["action: effect.resumeShortcut"]
63
72
  startClearError["action: mutation.clearError"]
64
73
  startClearReason["action: mutation.clearFailureReason"]
65
74
  reviewStartClearError["action: mutation.clearError"]
@@ -103,9 +112,16 @@ queued -->|on: reconcile| runnable
103
112
  runnable -->|true| reconcileQueuedClearError
104
113
  reconcileQueuedClearError --> reconcileQueuedClearReason
105
114
  reconcileQueuedClearReason --> queued
106
- queued -->|on: dispatch| dispatchable
115
+ queued -->|on: dispatch| shortcutExecution
116
+ shortcutExecution -->|true| shortcutFallback
117
+ shortcutExecution -->|false| dispatchable
118
+ shortcutFallback -->|true| dispatchable
119
+ shortcutFallback -->|false| shortcutHasGraph
120
+ shortcutHasGraph -->|true| shortcutLaunch
121
+ shortcutHasGraph -->|false| dispatchable
107
122
  dispatchable -->|true| dispatchLaunch
108
123
  dispatchLaunch --> queued
124
+ shortcutLaunch --> queued
109
125
  queued -->|on: task.started| startClearError
110
126
  startClearError --> startClearReason
111
127
  startClearReason --> running
@@ -126,6 +142,7 @@ queuedBlockAllowed -->|true| blocked
126
142
  queuedBlockAllowed -->|false| failed
127
143
  queued -->|on: fail| failed
128
144
  queued -->|on: effect.launchTask.failed| failed
145
+ queued -->|on: effect.launchShortcut.failed| failed
129
146
  queued -->|on: watchdog.failed| failed
130
147
  queued -->|on: worker.delivery_failed| failed
131
148
  queued -->|on: worker.start_ack_failed| failed
@@ -157,6 +174,14 @@ running -->|on: task.blocked| runningBlockAllowed
157
174
  runningBlockAllowed -->|true| blocked
158
175
  runningBlockAllowed -->|false| failed
159
176
  running -->|on: task.progress| running
177
+ running -->|on: shortcut.waiting| shortcutWaitReleaseLease
178
+ shortcutWaitReleaseLease["action: mutation.clearLease"]
179
+ shortcutWaitReleaseLease --> running
180
+ running -->|on: shortcut.result| shortcutResultCorrelated
181
+ shortcutResultCorrelated -->|true| shortcutResume
182
+ shortcutResultCorrelated -->|false| running
183
+ shortcutResume --> running
184
+ running -->|on: effect.resumeShortcut.failed| failed
160
185
  running -->|on: review.approved| reviewApproveRunningClearError
161
186
  reviewApproveRunningClearError --> reviewApproveRunningClearReason
162
187
  reviewApproveRunningClearReason --> succeeded
@@ -168,6 +193,11 @@ running -->|on: task.completed| completeClearError
168
193
  completeClearError --> completeClearReason
169
194
  completeClearReason --> succeeded
170
195
  running -->|on: task.failed| failed
196
+ running -->|on: shortcut.failed| shortcutEffectsSafe
197
+ shortcutEffectsSafe -->|true| shortcutWorkerFallback
198
+ shortcutWorkerFallback --> failed
199
+ shortcutEffectsSafe -->|false| shortcutRecoveryRequired
200
+ shortcutRecoveryRequired --> failed
171
201
  running -->|on: worker.platform_failure| runningPlatformFailureQuarantine
172
202
  runningPlatformFailureQuarantine["action: mutation.quarantinePlatformFailure"]
173
203
  runningPlatformFailureQuarantine --> failed
@@ -9,6 +9,7 @@ checkOwner["state: check_owner"]
9
9
  checkPath["state: check_path"]
10
10
  checkFreshExecution["state: check_fresh_execution"]
11
11
  activeRecovery["action: resolution.activateRecovery"]
12
+ shortcutWorkerFallback["action: resolution.activateShortcutWorkerFallback"]
12
13
  sameJob["action: resolution.attachSameJobDependency"]
13
14
  blockerJob["action: resolution.registerBlockerDependency"]
14
15
  escalate["action: resolution.createEscalationGate"]
@@ -18,6 +19,7 @@ rejected["state: rejected"]
18
19
  recoveryOwner["guard: recoveryOwnerAvailable"]
19
20
  plannerOwner["guard: plannerOwnerAvailable"]
20
21
  exact["guard: exactOriginalRetry"]
22
+ shortcutInterrupted["guard: shortcutInterrupted"]
21
23
  same["guard: sameJobDependency"]
22
24
  fresh["guard: freshRecoveryExecution"]
23
25
  blocker["guard: blockerJobDependency"]
@@ -40,7 +42,9 @@ checkPath -->|on: resolution.propose| fresh
40
42
  fresh -->|true| checkFreshExecution
41
43
  fresh -->|false| rejected
42
44
  checkFreshExecution -->|on: resolution.propose| exact
43
- exact -->|true| activeRecovery
45
+ exact -->|true| shortcutInterrupted
46
+ shortcutInterrupted -->|true| shortcutWorkerFallback
47
+ shortcutInterrupted -->|false| activeRecovery
44
48
  exact -->|false| same
45
49
  same -->|true| sameJob
46
50
  same -->|false| blocker
@@ -51,6 +55,7 @@ gate -->|false| obsoleteGuard
51
55
  obsoleteGuard -->|true| obsolete
52
56
  obsoleteGuard -->|false| rejected
53
57
  activeRecovery -->|to: resolved| resolved
58
+ shortcutWorkerFallback -->|to: resolved| resolved
54
59
  sameJob -->|to: resolved| resolved
55
60
  blockerJob -->|to: resolved| resolved
56
61
  escalate -->|to: resolved| resolved