@atolis-hq/wake 0.3.40 → 0.3.42
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.js +3 -2
- package/dist/src/control-plane/application/execution-reconciliation.js +8 -0
- package/dist/src/orchestration/application/start-workflow.js +7 -2
- package/dist/src/orchestration/application/watch-matching.js +2 -0
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { WorkflowStatus } from '../../orchestration/index.js';
|
|
|
4
4
|
import { WorkStatus } from '../../work/index.js';
|
|
5
5
|
import { ControlStreamKind } from '../contracts/streams.js';
|
|
6
6
|
import { DispatchPolicy } from '../domain/dispatch-policy.js';
|
|
7
|
-
import { findUnresolvedTerminal, isExecutionFailureTerminal } from './execution-reconciliation.js';
|
|
7
|
+
import { findUnresolvedSucceededTerminal, findUnresolvedTerminal, isExecutionFailureTerminal, } from './execution-reconciliation.js';
|
|
8
8
|
export function createAdvanceOnce(orchestration, execution, resources, clock, dependencies) {
|
|
9
9
|
const runnerIneligibility = dependencies.runnerIneligibility ?? (async () => new Set());
|
|
10
10
|
const isDispatchPaused = dependencies.isDispatchPaused ?? (async () => false);
|
|
@@ -84,7 +84,8 @@ export function createAdvanceOnce(orchestration, execution, resources, clock, de
|
|
|
84
84
|
(options.workItemId === undefined || workflow.workItemId === options.workItemId)
|
|
85
85
|
? [{ workflow, activation: workflow.pendingActivation }]
|
|
86
86
|
: []);
|
|
87
|
-
const recovery = await findUnresolvedTerminal(
|
|
87
|
+
const recovery = (await findUnresolvedTerminal(pending, execution)) ??
|
|
88
|
+
(await findUnresolvedSucceededTerminal(blocked, execution));
|
|
88
89
|
if (recovery !== undefined) {
|
|
89
90
|
if (await isDispatchPaused())
|
|
90
91
|
return { kind: 'paused' };
|
|
@@ -8,6 +8,14 @@ export async function findUnresolvedTerminal(pending, execution) {
|
|
|
8
8
|
}
|
|
9
9
|
return undefined;
|
|
10
10
|
}
|
|
11
|
+
export async function findUnresolvedSucceededTerminal(pending, execution) {
|
|
12
|
+
for (const item of pending) {
|
|
13
|
+
const run = (await execution.list(item.activation.activationId)).find((candidate) => candidate.status === RunStatus.Succeeded && candidate.outcome !== undefined);
|
|
14
|
+
if (run !== undefined && !item.workflow.acceptedOutcomes.includes(item.activation.activationId))
|
|
15
|
+
return { item, run };
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
11
19
|
export function isExecutionFailureTerminal(status) {
|
|
12
20
|
return (status === RunStatus.Failed || status === RunStatus.Cancelled || status === RunStatus.Ambiguous);
|
|
13
21
|
}
|
|
@@ -23,8 +23,7 @@ export class StartWorkflow {
|
|
|
23
23
|
this.definitions = definitions;
|
|
24
24
|
}
|
|
25
25
|
async execute(command, context) {
|
|
26
|
-
|
|
27
|
-
if (item === null || item.state !== WorkStatus.Open)
|
|
26
|
+
if (!(await this.isWorkItemOpen(command.workItemId)))
|
|
28
27
|
throw new Error('WorkItem must exist and be open');
|
|
29
28
|
const { definition, fingerprint } = this.definitions.currentDefinition(command.workflowName);
|
|
30
29
|
const existing = await this.repository.load(command.workflowInstanceId);
|
|
@@ -53,6 +52,12 @@ export class StartWorkflow {
|
|
|
53
52
|
await this.repository.append(command.workflowInstanceId, 0, decision.events);
|
|
54
53
|
return (await this.repository.loadRequired(command.workflowInstanceId)).view;
|
|
55
54
|
}
|
|
55
|
+
async isWorkItemOpen(workItemId) {
|
|
56
|
+
const item = await this.work.get(workItemId);
|
|
57
|
+
if (item === null || item.state !== WorkStatus.Open)
|
|
58
|
+
return false;
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
56
61
|
definitionFor(view) {
|
|
57
62
|
return this.definitions.resolve(view);
|
|
58
63
|
}
|
|
@@ -4,6 +4,8 @@ import { ActivityEventType, PullRequestCheckState, selectActivityEvent, } from '
|
|
|
4
4
|
// status, and predicate all agree with the incoming event.
|
|
5
5
|
export async function matchWatches(loaded, event, workflows, context) {
|
|
6
6
|
const matches = await Promise.all(loaded.map(async ({ view: parent, sequence }) => {
|
|
7
|
+
if (!(await workflows.isWorkItemOpen(parent.workItemId)))
|
|
8
|
+
return [];
|
|
7
9
|
const definition = context === undefined
|
|
8
10
|
? await workflows.definitionFor(parent)
|
|
9
11
|
: await workflows.definitionForOperation(parent, sequence, context);
|