@atolis-hq/wake 0.4.1 → 0.4.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.
- package/dist/src/bootstrap/version.js +1 -1
- package/dist/src/control-plane/application/advance-once-dispatch.js +4 -1
- package/dist/src/integrations/github/application/inbound-comment-syntax.js +2 -0
- package/dist/src/integrations/github/application/inbound-review-signals.js +26 -1
- package/dist/src/integrations/github/contracts/vocabulary.js +3 -1
- package/dist/src/integrations/github/infrastructure/comment-source.js +2 -1
- package/dist/src/orchestration/application/advance-workflow.js +8 -2
- package/dist/src/orchestration/application/orchestration-service.js +3 -0
- package/dist/src/orchestration/domain/decision-events.js +1 -0
- package/dist/src/orchestration/domain/interpreter.js +1 -1
- package/dist/src/orchestration/domain/operator-retry-policy.js +8 -0
- package/dist/src/orchestration/domain/workflow-instance-events.js +1 -0
- package/package.json +1 -1
|
@@ -87,7 +87,10 @@ export async function runDispatchLoop(pending, ctx) {
|
|
|
87
87
|
workflowInstanceId: selected.workflow.workflowInstanceId,
|
|
88
88
|
orchestrationGroupId: selected.workflow.orchestrationGroupId,
|
|
89
89
|
resources: resourceViews,
|
|
90
|
-
sessionPolicy: selected.
|
|
90
|
+
sessionPolicy: selected.activation.sessionPolicy === 'fresh' ||
|
|
91
|
+
selected.workflow.parentWorkflowInstanceId !== undefined
|
|
92
|
+
? 'fresh'
|
|
93
|
+
: 'resume-stage',
|
|
91
94
|
awaitImmediateCompletion: true,
|
|
92
95
|
...(ineligible.size === 0 ? {} : { ineligibleRunners: ineligible }),
|
|
93
96
|
});
|
|
@@ -20,6 +20,8 @@ export function recognizedCommand(body) {
|
|
|
20
20
|
return GitHubBuiltInCommand.Changes;
|
|
21
21
|
if (matchesCommand(line, GitHubBuiltInCommand.Retry))
|
|
22
22
|
return GitHubBuiltInCommand.Retry;
|
|
23
|
+
if (matchesCommand(line, GitHubBuiltInCommand.Restart))
|
|
24
|
+
return GitHubBuiltInCommand.Restart;
|
|
23
25
|
if (line === GitHubBuiltInCommand.Extend)
|
|
24
26
|
return GitHubBuiltInCommand.Extend;
|
|
25
27
|
return null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable max-lines */
|
|
2
2
|
import { ActivityOutcomeKind, ReviewActorKind, ReviewDecisionKind, ReviewerAuthorizationSource, createPullRequestService, isReviewAuthorized, } from '../../../activities/index.js';
|
|
3
|
-
import { ApprovalAuthorityKind, isGroupBudgetExtensionEligible, selectOperatorRetryTarget, } from '../../../orchestration/index.js';
|
|
3
|
+
import { ApprovalAuthorityKind, isGroupBudgetExtensionEligible, isOperatorRetryEligible, selectOperatorRetryTarget, } from '../../../orchestration/index.js';
|
|
4
4
|
import { BuiltInResourceKind, ResourceCorrelationRole, ResourceStreamKind, resourceId, } from '../../../resources/index.js';
|
|
5
5
|
import { WorkStatus } from '../../../work/index.js';
|
|
6
6
|
import { GitHubBuiltInCommand, UnknownGitHubIdentity } from '../contracts/vocabulary.js';
|
|
@@ -121,6 +121,8 @@ async function applyIssueCommand(input) {
|
|
|
121
121
|
const { command, resource, resourceId: resourceIdValue } = input;
|
|
122
122
|
if (command === GitHubBuiltInCommand.Retry)
|
|
123
123
|
return applyIssueRetrySignal({ ...input, resourceId: resourceIdValue });
|
|
124
|
+
if (command === GitHubBuiltInCommand.Restart)
|
|
125
|
+
return applyIssueRestartSignal({ ...input, resourceId: resourceIdValue });
|
|
124
126
|
if (command === GitHubBuiltInCommand.Extend)
|
|
125
127
|
return applyIssueBudgetExtension({ ...input, resourceId: resourceIdValue });
|
|
126
128
|
if (resource?.kind === BuiltInResourceKind.PullRequest)
|
|
@@ -184,6 +186,29 @@ async function applyIssueRetrySignal(input) {
|
|
|
184
186
|
await ignoreIneligibleOperatorRetry(() => orchestration.retryBlockedFailedStage(target.workflowInstanceId, commandContext(event)));
|
|
185
187
|
}
|
|
186
188
|
}
|
|
189
|
+
async function applyIssueRestartSignal(input) {
|
|
190
|
+
const { event, resources, work, orchestration, resourceId: resourceIdValue } = input;
|
|
191
|
+
if (orchestration === undefined)
|
|
192
|
+
return;
|
|
193
|
+
if (!isReviewAuthorized({
|
|
194
|
+
actorId: event.payload.actor.id,
|
|
195
|
+
actorKind: event.payload.actor.kind,
|
|
196
|
+
resourceAuthorId: UnknownGitHubIdentity,
|
|
197
|
+
authorization: event.payload.authorization ?? { source: ReviewerAuthorizationSource.None },
|
|
198
|
+
}))
|
|
199
|
+
return;
|
|
200
|
+
const workItemIds = (await resources.correlations(resourceIdValue))
|
|
201
|
+
.filter((correlation) => correlation.role === ResourceCorrelationRole.Primary)
|
|
202
|
+
.map((correlation) => correlation.workItemId);
|
|
203
|
+
for (const workItemId of workItemIds) {
|
|
204
|
+
if (!(await isEligibleWorkItem(work, workItemId)))
|
|
205
|
+
continue;
|
|
206
|
+
const primary = (await orchestration.listForWorkItem(workItemId)).find((workflow) => workflow.parentWorkflowInstanceId === undefined);
|
|
207
|
+
if (primary === undefined || !isOperatorRetryEligible(primary))
|
|
208
|
+
continue;
|
|
209
|
+
await ignoreIneligibleOperatorRetry(() => orchestration.restartBlockedFailedStage(primary.workflowInstanceId, commandContext(event)));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
187
212
|
async function applyIssueApprovalSignal(input) {
|
|
188
213
|
const { event, command, resources, work, lookup, orchestration, adapter } = input;
|
|
189
214
|
if (resources === undefined || lookup === undefined || orchestration === undefined)
|
|
@@ -57,7 +57,8 @@ export const GitHubOutboundAction = {
|
|
|
57
57
|
// Comment-channel commands the GitHub adapter recognizes from human replies.
|
|
58
58
|
// /approved and /changes drive issue-review and PR-issue-comment signals;
|
|
59
59
|
// /accepted and /changes drive formal (native) PR review comments; /retry
|
|
60
|
-
// resumes a blocked/failed stage; /
|
|
60
|
+
// resumes a blocked/failed stage; /restart starts it in a fresh runner session;
|
|
61
|
+
// /extend grants one exhausted gate attempt.
|
|
61
62
|
// Kept as the single source of truth for both
|
|
62
63
|
// recognition (inbound-comment-syntax.ts, review-command-translator.ts) and
|
|
63
64
|
// the commands/instructions surface, so the two cannot drift.
|
|
@@ -66,5 +67,6 @@ export const GitHubBuiltInCommand = defineClosedVocabulary({
|
|
|
66
67
|
Accepted: '/accepted',
|
|
67
68
|
Changes: '/changes',
|
|
68
69
|
Retry: '/retry',
|
|
70
|
+
Restart: '/restart',
|
|
69
71
|
Extend: '/extend',
|
|
70
72
|
});
|
|
@@ -70,7 +70,8 @@ async function issueCommentEventsForComment(context, issue, comment) {
|
|
|
70
70
|
return event === null ? [] : [event];
|
|
71
71
|
}
|
|
72
72
|
async function retryAuthorization(context, comment) {
|
|
73
|
-
|
|
73
|
+
const command = comment.body?.trim().toLowerCase();
|
|
74
|
+
if (command !== GitHubBuiltInCommand.Retry && command !== GitHubBuiltInCommand.Restart)
|
|
74
75
|
return undefined;
|
|
75
76
|
const login = comment.user?.login;
|
|
76
77
|
if (login === undefined || context.client.collaboratorPermission === undefined)
|
|
@@ -3,7 +3,7 @@ import { OrchestrationEventType } from '../contracts/events.js';
|
|
|
3
3
|
import { commandName, workflowInstanceId, } from '../contracts/identifiers.js';
|
|
4
4
|
import { workflowInstanceStream } from '../contracts/streams.js';
|
|
5
5
|
import { WorkflowStatus } from '../contracts/vocabulary.js';
|
|
6
|
-
import { requestChangesResume as decideChangesResume, requestOperatorRetry as decideOperatorRetry, requestSupplementalActivity as decideSupplementalActivity, requestRunnerQuotaRetry, } from '../domain/interpreter.js';
|
|
6
|
+
import { requestChangesResume as decideChangesResume, requestFreshOperatorRetry as decideFreshOperatorRetry, requestOperatorRetry as decideOperatorRetry, requestSupplementalActivity as decideSupplementalActivity, requestRunnerQuotaRetry, } from '../domain/interpreter.js';
|
|
7
7
|
import { isAuthorisedActor } from '../domain/supplemental-policy.js';
|
|
8
8
|
import { appendWithIntentRecovery } from './durable-append.js';
|
|
9
9
|
import { acceptResourceTransition, matchResourceTransitions, } from './resource-transition-matching.js';
|
|
@@ -136,6 +136,12 @@ export class AdvanceWorkflow {
|
|
|
136
136
|
return (await this.repository.load(id)).view;
|
|
137
137
|
}
|
|
138
138
|
async retryBlockedFailedStage(id, context) {
|
|
139
|
+
return this.retryBlockedFailedStageWith(id, context, decideOperatorRetry);
|
|
140
|
+
}
|
|
141
|
+
async restartBlockedFailedStage(id, context) {
|
|
142
|
+
return this.retryBlockedFailedStageWith(id, context, decideFreshOperatorRetry);
|
|
143
|
+
}
|
|
144
|
+
async retryBlockedFailedStageWith(id, context, decide) {
|
|
139
145
|
const loaded = await this.repository.load(id);
|
|
140
146
|
if (loaded.view === null)
|
|
141
147
|
throw new OperatorRetryIneligibleError('WorkflowInstance does not exist');
|
|
@@ -144,7 +150,7 @@ export class AdvanceWorkflow {
|
|
|
144
150
|
const definition = await this.workflows.definitionForOperation(loaded.view, loaded.sequence, context);
|
|
145
151
|
if (definition === null)
|
|
146
152
|
return (await this.repository.loadRequired(id)).view;
|
|
147
|
-
const decision =
|
|
153
|
+
const decision = decide(definition, loaded.view, {
|
|
148
154
|
commandId: context.commandId,
|
|
149
155
|
occurredAt: context.occurredAt,
|
|
150
156
|
causationId: context.commandId,
|
|
@@ -84,6 +84,9 @@ export class OrchestrationService {
|
|
|
84
84
|
retryBlockedFailedStage(workflowInstanceId, context) {
|
|
85
85
|
return this.transitionWatchChildren(context, () => this.advanceWorkflow.retryBlockedFailedStage(workflowInstanceId, context));
|
|
86
86
|
}
|
|
87
|
+
restartBlockedFailedStage(workflowInstanceId, context) {
|
|
88
|
+
return this.transitionWatchChildren(context, () => this.advanceWorkflow.restartBlockedFailedStage(workflowInstanceId, context));
|
|
89
|
+
}
|
|
87
90
|
resumeBlockedStageForChanges(workflowInstanceId, context) {
|
|
88
91
|
return this.transitionWatchChildren(context, () => this.advanceWorkflow.resumeBlockedStageForChanges(workflowInstanceId, context));
|
|
89
92
|
}
|
|
@@ -15,6 +15,7 @@ export function activation(id, ordinal, activity, input, options) {
|
|
|
15
15
|
...(options.stage === undefined ? {} : { stage: options.stage }),
|
|
16
16
|
input,
|
|
17
17
|
execution: options.execution,
|
|
18
|
+
...(options.sessionPolicy === undefined ? {} : { sessionPolicy: options.sessionPolicy }),
|
|
18
19
|
...(options.followOnIndex === undefined ? {} : { followOnIndex: options.followOnIndex }),
|
|
19
20
|
...(options.supplemental === true ? { supplemental: true } : {}),
|
|
20
21
|
};
|
|
@@ -10,7 +10,7 @@ import { finishRoute } from './transition.js';
|
|
|
10
10
|
export { startInstance } from './activation-policy.js';
|
|
11
11
|
export { acceptSignal, waitForSignal } from './signal-policy.js';
|
|
12
12
|
export { requestSupplementalActivity } from './supplemental-policy.js';
|
|
13
|
-
export { isChangesResumeEligible, isGroupBudgetExtensionEligible, isOperatorRetryEligible, requestChangesResume, requestOperatorRetry, selectOperatorRetryTarget, } from './operator-retry-policy.js';
|
|
13
|
+
export { isChangesResumeEligible, isGroupBudgetExtensionEligible, isOperatorRetryEligible, requestChangesResume, requestFreshOperatorRetry, requestOperatorRetry, selectOperatorRetryTarget, } from './operator-retry-policy.js';
|
|
14
14
|
export { isRunnerQuotaRetryEligible, requestRunnerQuotaRetry, } from './runner-quota-retry-policy.js';
|
|
15
15
|
export function acceptActivityOutcome(definition, state, input) {
|
|
16
16
|
if (!isPendingOutcome(state, input))
|
|
@@ -69,6 +69,13 @@ export function isGroupBudgetExtensionEligible(view) {
|
|
|
69
69
|
view.waitingFor !== undefined);
|
|
70
70
|
}
|
|
71
71
|
export function requestOperatorRetry(definition, state, input) {
|
|
72
|
+
return requestRetry(definition, state, input);
|
|
73
|
+
}
|
|
74
|
+
/** Re-requests the failed stage while requiring a new runner session. */
|
|
75
|
+
export function requestFreshOperatorRetry(definition, state, input) {
|
|
76
|
+
return requestRetry(definition, state, input, 'fresh');
|
|
77
|
+
}
|
|
78
|
+
function requestRetry(definition, state, input, sessionPolicy) {
|
|
72
79
|
if (input.commandId.length === 0)
|
|
73
80
|
return { kind: 'ignored', reason: 'operator retry command id is required' };
|
|
74
81
|
if (!isOperatorRetryEligible(state))
|
|
@@ -82,6 +89,7 @@ export function requestOperatorRetry(definition, state, input) {
|
|
|
82
89
|
stateDraft(state, input, OrchestrationEventType.ActivityRequested, activation(state.workflowInstanceId, nextOrdinal(state), stage.activity, stage.with, {
|
|
83
90
|
execution: stage.execution,
|
|
84
91
|
stage: stageName(state.currentStage),
|
|
92
|
+
...(sessionPolicy === undefined ? {} : { sessionPolicy }),
|
|
85
93
|
}), 2),
|
|
86
94
|
];
|
|
87
95
|
return { kind: 'append', events };
|
|
@@ -203,6 +203,7 @@ function applyActivityRequested(state, payload) {
|
|
|
203
203
|
...(payload.stage === undefined ? {} : { stage: payload.stage }),
|
|
204
204
|
input: payload.input,
|
|
205
205
|
execution: payload.execution,
|
|
206
|
+
...(payload.sessionPolicy === undefined ? {} : { sessionPolicy: payload.sessionPolicy }),
|
|
206
207
|
status: ActivityActivationStatus.Pending,
|
|
207
208
|
...(payload.followOnIndex === undefined ? {} : { followOnIndex: payload.followOnIndex }),
|
|
208
209
|
...(payload.supplemental === true ? { supplemental: true } : {}),
|