@gobing-ai/ts-dual-workflow-engine 0.4.68 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -1
- package/dist/events.d.ts +11 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/persistence.d.ts +9 -1
- package/dist/persistence.d.ts.map +1 -1
- package/dist/persistence.js +60 -1
- package/dist/run-lifecycle.d.ts +0 -2
- package/dist/run-lifecycle.d.ts.map +1 -1
- package/dist/run-lifecycle.js +0 -10
- package/dist/schema-sql.d.ts +2 -0
- package/dist/schema-sql.d.ts.map +1 -1
- package/dist/schema-sql.js +10 -1
- package/dist/schema.d.ts +4 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +4 -0
- package/dist/service.d.ts +9 -0
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +54 -7
- package/dist/state-machine.d.ts.map +1 -1
- package/dist/state-machine.js +14 -3
- package/dist/transition-flow.d.ts.map +1 -1
- package/dist/transition-flow.js +13 -3
- package/dist/types.d.ts +63 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/events.ts +11 -1
- package/src/index.ts +2 -0
- package/src/persistence.ts +81 -1
- package/src/run-lifecycle.ts +0 -11
- package/src/schema-sql.ts +11 -1
- package/src/schema.ts +4 -0
- package/src/service.ts +69 -7
- package/src/state-machine.ts +16 -3
- package/src/transition-flow.ts +15 -3
- package/src/types.ts +69 -1
package/dist/types.d.ts
CHANGED
|
@@ -3,7 +3,27 @@ export type OnErrorPolicy = 'fail' | 'continue';
|
|
|
3
3
|
import type { EventBus } from '@gobing-ai/ts-infra';
|
|
4
4
|
import type { WorkflowEngineEvents } from './events';
|
|
5
5
|
/** Workflow execution status persisted for runs and phases. */
|
|
6
|
-
export type WorkflowStatus = 'running' | 'done' | 'failed' | 'paused';
|
|
6
|
+
export type WorkflowStatus = 'running' | 'done' | 'failed' | 'paused' | 'interrupted';
|
|
7
|
+
/**
|
|
8
|
+
* How a resume re-enters the current state (task 0902 R1):
|
|
9
|
+
* - `skip-enter`: on-enter actions are NOT re-executed (pause semantics — they
|
|
10
|
+
* completed before the pause was declared).
|
|
11
|
+
* - `rerun-enter`: on-enter actions ARE re-executed (interrupt semantics — they
|
|
12
|
+
* may have half-completed at the interruption point). Only legal into states
|
|
13
|
+
* explicitly marked `resumeRerun: true`.
|
|
14
|
+
*/
|
|
15
|
+
export type WorkflowResumeMode = 'skip-enter' | 'rerun-enter';
|
|
16
|
+
/**
|
|
17
|
+
* Ownership claim for a resume (task 0902 R3). The adapter CAS records the
|
|
18
|
+
* attempt at the actual status mutation, so stale/concurrent resumers lose the
|
|
19
|
+
* claim deterministically instead of double-driving one run.
|
|
20
|
+
*/
|
|
21
|
+
export interface ResumeOwnership {
|
|
22
|
+
/** Unique id for this resume attempt (crypto.randomUUID() when caller omits it). */
|
|
23
|
+
readonly attemptId: string;
|
|
24
|
+
/** Optional OS pid of the resuming process, for crash-reconciliation diagnostics. */
|
|
25
|
+
readonly pid?: number;
|
|
26
|
+
}
|
|
7
27
|
/** Runtime variables and user variables available to workflow definitions. */
|
|
8
28
|
export type Vars = Record<string, string>;
|
|
9
29
|
/** Environment allowlist carried by a workflow definition. */
|
|
@@ -41,6 +61,13 @@ export interface StateDef {
|
|
|
41
61
|
readonly onExit?: readonly ActionDef[];
|
|
42
62
|
/** When true, the engine pauses the run at this state instead of auto-advancing. */
|
|
43
63
|
readonly pause?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Author declaration that this state's on-enter actions are safe to re-run
|
|
66
|
+
* after an interruption (idempotent, or deduped by runId+state context).
|
|
67
|
+
* Required for `rerun-enter` resume; unmarked states are refused loudly
|
|
68
|
+
* before any action executes (task 0902 R1/R2).
|
|
69
|
+
*/
|
|
70
|
+
readonly resumeRerun?: boolean;
|
|
44
71
|
}
|
|
45
72
|
/** One transition in a state-machine workflow. */
|
|
46
73
|
export interface TransitionDef {
|
|
@@ -84,6 +111,8 @@ export interface FlowNodeDef {
|
|
|
84
111
|
readonly action?: ActionDef;
|
|
85
112
|
/** When true, the engine pauses the run at this node instead of auto-advancing. */
|
|
86
113
|
readonly pause?: boolean;
|
|
114
|
+
/** Author declaration that this node's action is safe to re-run after an interruption. See StateDef.resumeRerun. */
|
|
115
|
+
readonly resumeRerun?: boolean;
|
|
87
116
|
}
|
|
88
117
|
/** Transition-flow edge definition. */
|
|
89
118
|
export interface FlowEdgeDef {
|
|
@@ -181,6 +210,19 @@ export interface WorkflowRunOptions {
|
|
|
181
210
|
readonly dryRun?: boolean;
|
|
182
211
|
/** Optional caller-supplied external key, unique per workflow definition. */
|
|
183
212
|
readonly externalKey?: string;
|
|
213
|
+
/**
|
|
214
|
+
* Resume semantics override (task 0902). Only meaningful on driver/service
|
|
215
|
+
* resume paths; fresh runs ignore it. Defaults derive from run status:
|
|
216
|
+
* paused → 'skip-enter', interrupted → 'rerun-enter'. Interrupted runs may
|
|
217
|
+
* downgrade to 'skip-enter' explicitly when re-execution is provably unsafe.
|
|
218
|
+
*/
|
|
219
|
+
readonly resumeMode?: WorkflowResumeMode;
|
|
220
|
+
/**
|
|
221
|
+
* Ownership claim recorded atomically at the resume status flip (task 0902 R3).
|
|
222
|
+
* Omitted → a fresh attemptId is generated. Concurrent resumers: exactly one
|
|
223
|
+
* wins the CAS, the rest receive a typed resume error.
|
|
224
|
+
*/
|
|
225
|
+
readonly resumeOwner?: ResumeOwnership;
|
|
184
226
|
}
|
|
185
227
|
/** Result returned by both driver loops. */
|
|
186
228
|
export interface WorkflowRunResult {
|
|
@@ -203,6 +245,12 @@ export interface WorkflowRunRecord {
|
|
|
203
245
|
readonly metadata_json: string;
|
|
204
246
|
/** Optional caller-supplied external key, unique per workflow definition. */
|
|
205
247
|
readonly external_key?: string | null;
|
|
248
|
+
/** Attempt id of the last resume that won the ownership claim (task 0902 R3). */
|
|
249
|
+
readonly owner_attempt?: string | null;
|
|
250
|
+
/** OS pid recorded alongside the winning resume attempt, when supplied. */
|
|
251
|
+
readonly owner_pid?: number | null;
|
|
252
|
+
/** Reason recorded by the last interruption (task 0902 R2). */
|
|
253
|
+
readonly interrupt_reason?: string | null;
|
|
206
254
|
}
|
|
207
255
|
/** Result of force-setting the current state of a run. */
|
|
208
256
|
export interface WorkflowReseedResult {
|
|
@@ -300,5 +348,19 @@ export interface WorkflowPersistenceAdapter {
|
|
|
300
348
|
workflowName?: string;
|
|
301
349
|
limit?: number;
|
|
302
350
|
}): Promise<readonly WorkflowRunRecord[]>;
|
|
351
|
+
/**
|
|
352
|
+
* Atomically claim ownership of a resumable run (task 0902 R3). CAS: flips
|
|
353
|
+
* the run from one of `expectedStatuses` to 'running' and records the owner
|
|
354
|
+
* in the same update. Returns the claimed record, or undefined when the run
|
|
355
|
+
* is missing, already running/done, or was claimed by a competing resume —
|
|
356
|
+
* callers must treat undefined as a lost race, never retry blindly.
|
|
357
|
+
*/
|
|
358
|
+
claimRunOwnership(runId: string, owner: ResumeOwnership, expectedStatuses: readonly ('paused' | 'interrupted')[]): Promise<WorkflowRunRecord | undefined>;
|
|
359
|
+
/**
|
|
360
|
+
* Mark a running run as interrupted with a reason (task 0902 R2) —
|
|
361
|
+
* crash/lost-owner reconciliation. CAS running → 'interrupted'; returns the
|
|
362
|
+
* updated record, or undefined when the run is missing or not running.
|
|
363
|
+
*/
|
|
364
|
+
interruptRun(runId: string, reason: string): Promise<WorkflowRunRecord | undefined>;
|
|
303
365
|
}
|
|
304
366
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,UAAU,CAAC;AAEhD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC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|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gobing-ai/ts-dual-workflow-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "@gobing-ai/ts-dual-workflow-engine — State-machine and transition-flow workflow runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"release": "echo 'Manual publish is disabled. Releases go through GitHub Actions via Trusted Publishing — push a tag: git tag @gobing-ai/ts-dual-workflow-engine-v<version> && git push --tags' && exit 1"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@gobing-ai/ts-db": "^0.
|
|
52
|
-
"@gobing-ai/ts-infra": "^0.
|
|
53
|
-
"@gobing-ai/ts-runtime": "^0.
|
|
51
|
+
"@gobing-ai/ts-db": "^0.5.0",
|
|
52
|
+
"@gobing-ai/ts-infra": "^0.5.0",
|
|
53
|
+
"@gobing-ai/ts-runtime": "^0.5.0",
|
|
54
54
|
"zod": "^4.1.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
package/src/events.ts
CHANGED
|
@@ -120,10 +120,20 @@ export type WorkflowEngineEvents = {
|
|
|
120
120
|
externalKey?: string;
|
|
121
121
|
severity: EventSeverity;
|
|
122
122
|
}) => void;
|
|
123
|
-
/** Emitted when a
|
|
123
|
+
/** Emitted when a run is resumed. */
|
|
124
124
|
'workflow.run.resumed': (data: {
|
|
125
125
|
runId: string;
|
|
126
126
|
node: string;
|
|
127
|
+
resumeMode: 'skip-enter' | 'rerun-enter';
|
|
128
|
+
ownerAttemptId: string;
|
|
129
|
+
externalKey?: string;
|
|
130
|
+
severity: EventSeverity;
|
|
131
|
+
}) => void;
|
|
132
|
+
/** Emitted when a running run is marked interrupted (crash/lost-owner reconciliation). */
|
|
133
|
+
'workflow.run.interrupted': (data: {
|
|
134
|
+
runId: string;
|
|
135
|
+
node?: string;
|
|
136
|
+
reason: string;
|
|
127
137
|
externalKey?: string;
|
|
128
138
|
severity: EventSeverity;
|
|
129
139
|
}) => void;
|
package/src/index.ts
CHANGED
|
@@ -58,6 +58,7 @@ export type {
|
|
|
58
58
|
GuardEvaluationResult,
|
|
59
59
|
GuardRunner,
|
|
60
60
|
OnErrorPolicy,
|
|
61
|
+
ResumeOwnership,
|
|
61
62
|
StateDef,
|
|
62
63
|
StateMachineWorkflowDef,
|
|
63
64
|
TransitionAllowed,
|
|
@@ -70,6 +71,7 @@ export type {
|
|
|
70
71
|
WorkflowDef,
|
|
71
72
|
WorkflowExtensions,
|
|
72
73
|
WorkflowPersistenceAdapter,
|
|
74
|
+
WorkflowResumeMode,
|
|
73
75
|
WorkflowRunOptions,
|
|
74
76
|
WorkflowRunRecord,
|
|
75
77
|
WorkflowRunResult,
|
package/src/persistence.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { DbAdapter, DbBatchOp } from '@gobing-ai/ts-db';
|
|
2
2
|
import { RunCollisionError } from './errors';
|
|
3
|
-
import { WORKFLOW_ENGINE_SCHEMA_SQL } from './schema-sql';
|
|
3
|
+
import { WORKFLOW_ENGINE_MIGRATIONS_SQL, WORKFLOW_ENGINE_SCHEMA_SQL } from './schema-sql';
|
|
4
4
|
import type {
|
|
5
5
|
ActionRedactor,
|
|
6
|
+
ResumeOwnership,
|
|
6
7
|
WorkflowPersistenceAdapter,
|
|
7
8
|
WorkflowReseedResult,
|
|
8
9
|
WorkflowRunRecord,
|
|
@@ -15,6 +16,17 @@ export async function applyWorkflowEngineSchema(db: DbAdapter): Promise<void> {
|
|
|
15
16
|
const sql = statement.trim();
|
|
16
17
|
if (sql.length > 0) await db.exec(sql);
|
|
17
18
|
}
|
|
19
|
+
// Fresh databases already have the new columns (duplicate-column error → ignored);
|
|
20
|
+
// pre-0.5.0 databases get them via these guarded ALTERs.
|
|
21
|
+
for (const statement of WORKFLOW_ENGINE_MIGRATIONS_SQL.split(';')) {
|
|
22
|
+
const sql = statement.trim();
|
|
23
|
+
if (sql.length === 0) continue;
|
|
24
|
+
try {
|
|
25
|
+
await db.exec(sql);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
if (!/duplicate column/i.test(String(error))) throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
18
30
|
}
|
|
19
31
|
|
|
20
32
|
/** Narrow to a non-array object record. */
|
|
@@ -96,6 +108,40 @@ export class DbWorkflowPersistenceAdapter implements WorkflowPersistenceAdapter
|
|
|
96
108
|
);
|
|
97
109
|
}
|
|
98
110
|
|
|
111
|
+
/** CAS-claim a resumable run to running, recording the owner at the mutation. */
|
|
112
|
+
async claimRunOwnership(
|
|
113
|
+
runId: string,
|
|
114
|
+
owner: ResumeOwnership,
|
|
115
|
+
expectedStatuses: readonly ('paused' | 'interrupted')[],
|
|
116
|
+
): Promise<WorkflowRunRecord | undefined> {
|
|
117
|
+
await this.ensureSchema();
|
|
118
|
+
const placeholders = expectedStatuses.map(() => '?').join(', ');
|
|
119
|
+
await this.db.run(
|
|
120
|
+
`UPDATE runs SET status = 'running', completed_at = NULL, owner_attempt = ?, owner_pid = ?, updated_at = ?
|
|
121
|
+
WHERE id = ? AND status IN (${placeholders})`,
|
|
122
|
+
owner.attemptId,
|
|
123
|
+
owner.pid ?? null,
|
|
124
|
+
Date.now(),
|
|
125
|
+
runId,
|
|
126
|
+
...expectedStatuses,
|
|
127
|
+
);
|
|
128
|
+
const run = await this.loadRun(runId);
|
|
129
|
+
return run !== undefined && run.status === 'running' && run.owner_attempt === owner.attemptId ? run : undefined;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** CAS running → interrupted with a reason (lost-owner / crash reconciliation). */
|
|
133
|
+
async interruptRun(runId: string, reason: string): Promise<WorkflowRunRecord | undefined> {
|
|
134
|
+
await this.ensureSchema();
|
|
135
|
+
await this.db.run(
|
|
136
|
+
"UPDATE runs SET status = 'interrupted', interrupt_reason = ?, completed_at = NULL, updated_at = ? WHERE id = ? AND status = 'running'",
|
|
137
|
+
reason,
|
|
138
|
+
Date.now(),
|
|
139
|
+
runId,
|
|
140
|
+
);
|
|
141
|
+
const run = await this.loadRun(runId);
|
|
142
|
+
return run !== undefined && run.status === 'interrupted' ? run : undefined;
|
|
143
|
+
}
|
|
144
|
+
|
|
99
145
|
/** Save one phase/state execution record. */
|
|
100
146
|
async savePhase(runId: string, phase: string, status: WorkflowStatus): Promise<void> {
|
|
101
147
|
const op = this.phaseRow(runId, phase, status, Date.now());
|
|
@@ -352,6 +398,40 @@ export class MemoryWorkflowPersistenceAdapter implements WorkflowPersistenceAdap
|
|
|
352
398
|
if (run !== undefined) this.runs.set(runId, { ...run, status, completed_at: completedAt });
|
|
353
399
|
}
|
|
354
400
|
|
|
401
|
+
/** CAS-claim a resumable run to running, recording the owner at the mutation. */
|
|
402
|
+
async claimRunOwnership(
|
|
403
|
+
runId: string,
|
|
404
|
+
owner: ResumeOwnership,
|
|
405
|
+
expectedStatuses: readonly ('paused' | 'interrupted')[],
|
|
406
|
+
): Promise<WorkflowRunRecord | undefined> {
|
|
407
|
+
const run = this.runs.get(runId);
|
|
408
|
+
if (run === undefined || !expectedStatuses.includes(run.status as 'paused' | 'interrupted')) {
|
|
409
|
+
return undefined;
|
|
410
|
+
}
|
|
411
|
+
const claimed: WorkflowRunRecord = {
|
|
412
|
+
...run,
|
|
413
|
+
status: 'running',
|
|
414
|
+
completed_at: null,
|
|
415
|
+
owner_attempt: owner.attemptId,
|
|
416
|
+
owner_pid: owner.pid ?? null,
|
|
417
|
+
};
|
|
418
|
+
this.runs.set(runId, claimed);
|
|
419
|
+
return claimed;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/** CAS running → interrupted with a reason (lost-owner / crash reconciliation). */
|
|
423
|
+
async interruptRun(runId: string, reason: string): Promise<WorkflowRunRecord | undefined> {
|
|
424
|
+
const run = this.runs.get(runId);
|
|
425
|
+
if (run === undefined || run.status !== 'running') return undefined;
|
|
426
|
+
const interrupted: WorkflowRunRecord = {
|
|
427
|
+
...run,
|
|
428
|
+
status: 'interrupted',
|
|
429
|
+
interrupt_reason: reason,
|
|
430
|
+
};
|
|
431
|
+
this.runs.set(runId, interrupted);
|
|
432
|
+
return interrupted;
|
|
433
|
+
}
|
|
434
|
+
|
|
355
435
|
readonly actionRuns: Array<{
|
|
356
436
|
id: string;
|
|
357
437
|
runId: string;
|
package/src/run-lifecycle.ts
CHANGED
|
@@ -331,17 +331,6 @@ export class RunLifecycle {
|
|
|
331
331
|
return this.result('paused', stateOrNodeId, transitionsTaken);
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
/** Emit the resumed event (called by WorkflowService after re-creating a lifecycle for resume). */
|
|
335
|
-
emitResumed(node: string): void {
|
|
336
|
-
addSpanEvent('workflow.run.resumed', { runId: this.runId, node });
|
|
337
|
-
void this.events?.emit('workflow.run.resumed', {
|
|
338
|
-
runId: this.runId,
|
|
339
|
-
node,
|
|
340
|
-
externalKey: this.externalKey,
|
|
341
|
-
severity: 'info',
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
|
|
345
334
|
/** Emit action-level observability before a host action is invoked. */
|
|
346
335
|
actionStart(stateOrNodeId: string, kind: string): void {
|
|
347
336
|
addSpanEvent('workflow.action.start', { runId: this.runId, node: stateOrNodeId, kind });
|
package/src/schema-sql.ts
CHANGED
|
@@ -11,7 +11,10 @@ CREATE TABLE IF NOT EXISTS runs (
|
|
|
11
11
|
completed_at TEXT,
|
|
12
12
|
metadata_json TEXT NOT NULL DEFAULT '{}',
|
|
13
13
|
created_at INTEGER NOT NULL DEFAULT 0,
|
|
14
|
-
updated_at INTEGER NOT NULL DEFAULT 0
|
|
14
|
+
updated_at INTEGER NOT NULL DEFAULT 0,
|
|
15
|
+
owner_attempt TEXT,
|
|
16
|
+
owner_pid INTEGER,
|
|
17
|
+
interrupt_reason TEXT
|
|
15
18
|
);
|
|
16
19
|
|
|
17
20
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_runs_external_key
|
|
@@ -67,3 +70,10 @@ CREATE TABLE IF NOT EXISTS action_runs (
|
|
|
67
70
|
FOREIGN KEY (run_id) REFERENCES runs(id)
|
|
68
71
|
);
|
|
69
72
|
`.trim();
|
|
73
|
+
|
|
74
|
+
/** Guarded ALTERs adding the 0.5.0 ownership/interruption columns for databases created before them. */
|
|
75
|
+
export const WORKFLOW_ENGINE_MIGRATIONS_SQL = `
|
|
76
|
+
ALTER TABLE runs ADD COLUMN owner_attempt TEXT;
|
|
77
|
+
ALTER TABLE runs ADD COLUMN owner_pid INTEGER;
|
|
78
|
+
ALTER TABLE runs ADD COLUMN interrupt_reason TEXT;
|
|
79
|
+
`.trim();
|
package/src/schema.ts
CHANGED
|
@@ -94,6 +94,8 @@ export const StateMachineWorkflowDefSchema = z
|
|
|
94
94
|
onExit: z.array(ActionDefSchema).optional(),
|
|
95
95
|
/** When true, the engine pauses the run at this state instead of auto-advancing. */
|
|
96
96
|
pause: z.boolean().optional(),
|
|
97
|
+
/** Author declaration that re-running this state's on-enter actions after an interruption is safe. */
|
|
98
|
+
resumeRerun: z.boolean().optional(),
|
|
97
99
|
})
|
|
98
100
|
.strict(),
|
|
99
101
|
),
|
|
@@ -136,6 +138,8 @@ export const TransitionFlowWorkflowDefSchema = z
|
|
|
136
138
|
action: ActionDefSchema.optional(),
|
|
137
139
|
/** When true, the engine pauses the run at this node instead of auto-advancing. */
|
|
138
140
|
pause: z.boolean().optional(),
|
|
141
|
+
/** Author declaration that re-running this node's action after an interruption is safe. */
|
|
142
|
+
resumeRerun: z.boolean().optional(),
|
|
139
143
|
})
|
|
140
144
|
.strict(),
|
|
141
145
|
),
|
package/src/service.ts
CHANGED
|
@@ -7,12 +7,14 @@ import { RunLifecycle } from './run-lifecycle';
|
|
|
7
7
|
import { StateMachineDriver } from './state-machine';
|
|
8
8
|
import { TransitionFlowDriver } from './transition-flow';
|
|
9
9
|
import type {
|
|
10
|
+
ResumeOwnership,
|
|
10
11
|
StateMachineWorkflowDef,
|
|
11
12
|
TransitionDenied,
|
|
12
13
|
TransitionRequestResult,
|
|
13
14
|
Vars,
|
|
14
15
|
WorkflowDef,
|
|
15
16
|
WorkflowPersistenceAdapter,
|
|
17
|
+
WorkflowResumeMode,
|
|
16
18
|
WorkflowRunOptions,
|
|
17
19
|
WorkflowRunRecord,
|
|
18
20
|
WorkflowRunResult,
|
|
@@ -157,34 +159,55 @@ export class WorkflowService {
|
|
|
157
159
|
if (run === undefined) {
|
|
158
160
|
throw new WorkflowResumeError(`Run "${runId}" not found`);
|
|
159
161
|
}
|
|
160
|
-
if (run.status !== 'paused') {
|
|
161
|
-
throw new WorkflowResumeError(`Run "${runId}" is not
|
|
162
|
+
if (run.status !== 'paused' && run.status !== 'interrupted') {
|
|
163
|
+
throw new WorkflowResumeError(`Run "${runId}" is not resumable (status: ${run.status})`);
|
|
162
164
|
}
|
|
163
165
|
const currentState = await this.persistence.loadCurrentState(runId);
|
|
164
166
|
if (currentState === undefined) {
|
|
165
167
|
throw new WorkflowResumeError(`Run "${runId}" has no persisted state to resume from`);
|
|
166
168
|
}
|
|
167
169
|
|
|
170
|
+
// Resolve recovery semantics (task 0902): interrupted runs default to re-running
|
|
171
|
+
// the current state's actions (they may have half-completed at the interruption);
|
|
172
|
+
// paused runs default to skipping them (pause is declared after actions complete).
|
|
173
|
+
// An explicit `resumeMode` option overrides either default.
|
|
174
|
+
const resumeMode: WorkflowResumeMode =
|
|
175
|
+
options?.resumeMode ?? (run.status === 'interrupted' ? 'rerun-enter' : 'skip-enter');
|
|
176
|
+
this.assertResumeRerunAllowed(workflow, currentState, resumeMode);
|
|
177
|
+
|
|
168
178
|
// Restore effectiveVars persisted in the last state snapshot so resume
|
|
169
179
|
// continues with the same runtime variables (e.g. `__hitlAnswer`). Caller
|
|
170
180
|
// overrides in `options.vars` win over the persisted snapshot (R3 of 0366).
|
|
171
181
|
const snapshot = await this.persistence.loadLatestStateSnapshot(runId);
|
|
172
182
|
const persistedVars = extractEffectiveVars(snapshot?.data);
|
|
173
183
|
const restoredVars = mergeVars(persistedVars, options?.vars);
|
|
174
|
-
const
|
|
184
|
+
const owner: ResumeOwnership = options?.resumeOwner ?? { attemptId: crypto.randomUUID() };
|
|
185
|
+
const mergedOptions: WorkflowRunOptions = { ...options, vars: restoredVars, resumeMode };
|
|
186
|
+
|
|
187
|
+
// Atomically claim ownership (task 0902 R3): the status flip and owner recording
|
|
188
|
+
// happen in one CAS update, so exactly one concurrent resume wins; losers and
|
|
189
|
+
// stale owners get a typed error instead of double-driving the run.
|
|
190
|
+
const claimed = await this.persistence.claimRunOwnership(runId, owner, ['paused', 'interrupted']);
|
|
191
|
+
if (claimed === undefined) {
|
|
192
|
+
const current = await this.persistence.loadRun(runId);
|
|
193
|
+
throw new WorkflowResumeError(
|
|
194
|
+
`Run "${runId}" could not be claimed for resume ` +
|
|
195
|
+
`(status: ${current?.status ?? 'unknown'}, owner: ${current?.owner_attempt ?? 'none'})`,
|
|
196
|
+
);
|
|
197
|
+
}
|
|
175
198
|
|
|
176
|
-
|
|
177
|
-
const extKey = run.external_key ?? undefined;
|
|
178
|
-
await this.persistence.finalizeRun(runId, 'running', '');
|
|
199
|
+
const extKey = claimed.external_key ?? undefined;
|
|
179
200
|
const events = this.resolveEvents(mergedOptions.events);
|
|
180
201
|
void events?.emit('workflow.run.resumed', {
|
|
181
202
|
runId,
|
|
182
203
|
node: currentState,
|
|
204
|
+
resumeMode,
|
|
205
|
+
ownerAttemptId: owner.attemptId,
|
|
183
206
|
externalKey: extKey,
|
|
184
207
|
severity: 'info',
|
|
185
208
|
});
|
|
186
209
|
|
|
187
|
-
// Resume through the appropriate driver, starting from the
|
|
210
|
+
// Resume through the appropriate driver, starting from the persisted state.
|
|
188
211
|
if (workflow.kind === 'transition-flow') {
|
|
189
212
|
return await new TransitionFlowDriver({
|
|
190
213
|
host: this.host,
|
|
@@ -197,6 +220,45 @@ export class WorkflowService {
|
|
|
197
220
|
}).resume(workflow as StateMachineWorkflowDef, runId, currentState, extKey, mergedOptions);
|
|
198
221
|
}
|
|
199
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Mark a running run as interrupted (task 0902 R2) — crash/lost-owner
|
|
225
|
+
* reconciliation so an abandoned run can later be rerun-resumed instead of
|
|
226
|
+
* wedging in 'running' forever. CAS: returns undefined when the run is
|
|
227
|
+
* missing or not running (already terminal/paused/claimed).
|
|
228
|
+
*/
|
|
229
|
+
async interruptRun(runId: string, reason: string): Promise<WorkflowRunRecord | undefined> {
|
|
230
|
+
const interrupted = await this.persistence.interruptRun(runId, reason);
|
|
231
|
+
if (interrupted !== undefined) {
|
|
232
|
+
const events = this.resolveEvents(undefined);
|
|
233
|
+
void events?.emit('workflow.run.interrupted', {
|
|
234
|
+
runId,
|
|
235
|
+
reason,
|
|
236
|
+
externalKey: interrupted.external_key ?? undefined,
|
|
237
|
+
severity: 'warning',
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
return interrupted;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** Refuse rerun-resume into states the author has not declared safe to re-run (task 0902 R1/R2). */
|
|
244
|
+
private assertResumeRerunAllowed(
|
|
245
|
+
workflow: WorkflowDef,
|
|
246
|
+
currentState: string,
|
|
247
|
+
resumeMode: WorkflowResumeMode,
|
|
248
|
+
): void {
|
|
249
|
+
if (resumeMode !== 'rerun-enter') return;
|
|
250
|
+
const node =
|
|
251
|
+
workflow.kind === 'transition-flow'
|
|
252
|
+
? workflow.nodes.find((candidate) => candidate.id === currentState)
|
|
253
|
+
: (workflow as StateMachineWorkflowDef).states.find((candidate) => candidate.id === currentState);
|
|
254
|
+
if (node !== undefined && node.resumeRerun !== true) {
|
|
255
|
+
throw new FSMError(
|
|
256
|
+
`Cannot rerun-resume into "${currentState}": not marked resumeRerun: true ` +
|
|
257
|
+
'(mark its actions as safe to re-run — idempotent or deduped by runId+state — or resume with resumeMode: "skip-enter")',
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
200
262
|
/** List runs currently paused. Optional filters and ordering. */
|
|
201
263
|
async listPausedRuns(options?: { workflowName?: string; limit?: number }): Promise<readonly WorkflowRunRecord[]> {
|
|
202
264
|
return await this.persistence.listPausedRuns(options);
|
package/src/state-machine.ts
CHANGED
|
@@ -67,7 +67,7 @@ export class StateMachineDriver {
|
|
|
67
67
|
let lastActionResult: ActionResult | undefined;
|
|
68
68
|
const iterationBound = workflow.iterationBound ?? 50;
|
|
69
69
|
const defaultOnError = workflow.defaultOnError;
|
|
70
|
-
let
|
|
70
|
+
let resumeMode = resumeFromState !== undefined ? (options.resumeMode ?? 'skip-enter') : undefined;
|
|
71
71
|
// When `commitHop` has already persisted the new state's snapshot +
|
|
72
72
|
// phase atomically (every iteration after the first), `enter` must skip
|
|
73
73
|
// the persist half to avoid duplicate INSERT rows (ADR-020).
|
|
@@ -79,11 +79,24 @@ export class StateMachineDriver {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
while (true) {
|
|
82
|
-
if (
|
|
82
|
+
if (resumeMode === 'skip-enter') {
|
|
83
83
|
// Resume: skip enter actions on the first iteration (already ran before pause).
|
|
84
|
-
|
|
84
|
+
resumeMode = undefined;
|
|
85
85
|
persistedViaHop = true; // state already persisted before the pause
|
|
86
86
|
} else {
|
|
87
|
+
if (resumeMode === 'rerun-enter') {
|
|
88
|
+
// Rerun-resume re-executes on-enter actions; only states the author marked
|
|
89
|
+
// resumable may be re-entered (0902: loud refusal before any action runs,
|
|
90
|
+
// never a silent replay of unclassified side effects).
|
|
91
|
+
if (current.resumeRerun !== true) {
|
|
92
|
+
throw new FSMError(
|
|
93
|
+
`Cannot rerun-resume into state "${current.id}": not marked resumeRerun: true ` +
|
|
94
|
+
'(mark its on-enter actions as safe to re-run, or resume with resumeMode: "skip-enter")',
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
resumeMode = undefined;
|
|
98
|
+
persistedViaHop = true; // snapshot exists from the pre-interruption enter
|
|
99
|
+
}
|
|
87
100
|
// 1. Persist current state snapshot before work starts (skipped when
|
|
88
101
|
// commitHop already persisted it atomically on the previous hop).
|
|
89
102
|
await lifecycle.enter(current.id, transitionsTaken, !persistedViaHop, vars);
|
package/src/transition-flow.ts
CHANGED
|
@@ -66,7 +66,7 @@ export class TransitionFlowDriver {
|
|
|
66
66
|
let lastActionResult: ActionResult | undefined;
|
|
67
67
|
const iterationBound = workflow.iterationBound ?? 50;
|
|
68
68
|
const defaultOnError = workflow.defaultOnError;
|
|
69
|
-
let
|
|
69
|
+
let resumeMode = resumeFromNode !== undefined ? (options.resumeMode ?? 'skip-enter') : undefined;
|
|
70
70
|
// When `commitHop` has already persisted the new node's snapshot +
|
|
71
71
|
// phase atomically (every iteration after the first), `enter` must skip
|
|
72
72
|
// the persist half to avoid duplicate INSERT rows (ADR-020).
|
|
@@ -78,11 +78,23 @@ export class TransitionFlowDriver {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
while (true) {
|
|
81
|
-
if (
|
|
81
|
+
if (resumeMode === 'skip-enter') {
|
|
82
82
|
// Resume: skip enter + node action on the first iteration (already ran before pause).
|
|
83
|
-
|
|
83
|
+
resumeMode = undefined;
|
|
84
84
|
persistedViaHop = true; // node already persisted before the pause
|
|
85
85
|
} else {
|
|
86
|
+
if (resumeMode === 'rerun-enter') {
|
|
87
|
+
// Rerun-resume re-executes the node action; only nodes the author marked
|
|
88
|
+
// resumable may be re-entered (0902: loud refusal before any action runs).
|
|
89
|
+
if (current.resumeRerun !== true) {
|
|
90
|
+
throw new FSMError(
|
|
91
|
+
`Cannot rerun-resume into node "${current.id}": not marked resumeRerun: true ` +
|
|
92
|
+
'(mark its action as safe to re-run, or resume with resumeMode: "skip-enter")',
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
resumeMode = undefined;
|
|
96
|
+
persistedViaHop = true; // snapshot exists from the pre-interruption enter
|
|
97
|
+
}
|
|
86
98
|
// 1. Persist current node snapshot before action execution (skipped when
|
|
87
99
|
// commitHop already persisted it atomically on the previous hop).
|
|
88
100
|
await lifecycle.enter(current.id, transitionsTaken, !persistedViaHop, vars);
|