@entifix/workflow 0.16.0 → 0.17.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.
|
@@ -65,7 +65,7 @@ export declare class InterpreterOptionsTag extends InterpreterOptionsTag_base {
|
|
|
65
65
|
export declare const SlipWorkflow: Workflow.Workflow<"entifix/slip", Schema.Struct<{
|
|
66
66
|
key: Schema.String;
|
|
67
67
|
slip: Schema.Struct<{
|
|
68
|
-
readonly slipVersion: Schema.
|
|
68
|
+
readonly slipVersion: Schema.Literals<readonly [1, 2]>;
|
|
69
69
|
readonly flowId: Schema.String;
|
|
70
70
|
readonly recipe: Schema.String;
|
|
71
71
|
readonly requiresCommitPoint: Schema.optionalKey<Schema.Boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slip-workflow.d.ts","sourceRoot":"","sources":["../../src/interpreter/slip-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,IAAI,EAGL,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,KAAK,cAAc,EAMpB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,WAAW,EACX,iBAAiB,EAIjB,SAAS,EACT,oBAAoB,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,KAAK,EACL,OAAO,EACP,MAAM,EAIN,MAAM,EAEP,MAAM,QAAQ,CAAC;AAChB,OAAO,EAGL,eAAe,EACf,QAAQ,EACT,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAGL,kBAAkB,EACnB,MAAM,gCAAgC,CAAC;AAGxC;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,KAAK,CAAC,cAAc,EAAE,OAAO,CAShE,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,WAAW,8EAKtB,CAAC;;;;AAqCH,uEAAuE;AACvE,qBAAa,gBAAiB,SAAQ,qBAKrC;CAAG;AAEJ,6EAA6E;A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M,kEAC+B,CAAC;AA+XpE,4EAA4E;AAC5E,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EACd,CAAC;AAExC,eAAO,MAAM,aAAa,GAAI,MAAM,IAAI,waACF,CAAC;AAEvC,6EAA6E;AAC7E,eAAO,MAAM,iBAAiB,GAAI,SAAS,kBAAkB,mPAK1D,CAAC"}
|
|
@@ -114,32 +114,7 @@ const segmentOf = (step)=>step.segment === undefined ? undefined : [
|
|
|
114
114
|
...groups.values()
|
|
115
115
|
];
|
|
116
116
|
};
|
|
117
|
-
|
|
118
|
-
* Interprets a pinned slip of grammar version 1
|
|
119
|
-
* ([ADR 0016](../../../../../docs/adr/0016-a-flow-engine-port-and-a-durable-workflow-adapter.md)):
|
|
120
|
-
* each step is an Activity named after it and keyed `<flowId>:<step>`, so a
|
|
121
|
-
* resumed flow replays what already ran and calls a participant at most once
|
|
122
|
-
* per step. Inside the Activity the call runs under the participant's
|
|
123
|
-
* breaker and bulkhead and the retry budget, each attempt bounded and the
|
|
124
|
-
* step as a whole bounded; nothing retries outside it.
|
|
125
|
-
*
|
|
126
|
-
* - Before and at the commit point, a failure — a breaker already open
|
|
127
|
-
* included, which fails fast — compensates what succeeded, in reverse, and
|
|
128
|
-
* the flow ends `compensated`.
|
|
129
|
-
* - After it, a failure suspends the flow at that step: the money is taken,
|
|
130
|
-
* so the flow rolls forward when the participant comes back, never back.
|
|
131
|
-
* - A `wait` step parks the flow on a durable deferred its signal completes,
|
|
132
|
-
* raced with a durable clock when it names `timeoutMs`; it may name a
|
|
133
|
-
* `correlation`, so a sender that knows the order rather than the flow can
|
|
134
|
-
* complete it.
|
|
135
|
-
* - The segments of a stage run at once, bounded, and join before the next.
|
|
136
|
-
*
|
|
137
|
-
* Every transition is announced as a `flow.*` event through the outbox, by an
|
|
138
|
-
* Activity, so it is written once whatever replays. Compensation is explicit
|
|
139
|
-
* rather than a workflow finalizer, so the record says `compensated` only
|
|
140
|
-
* after the last undoing has run — and an undoing that fails stops the flow
|
|
141
|
-
* `failed` at that step instead of pretending.
|
|
142
|
-
*/ const interpretV1 = (slip)=>Effect.gen(function*() {
|
|
117
|
+
const walkSlip = (slip, grammar)=>Effect.gen(function*() {
|
|
143
118
|
const options = yield* InterpreterOptionsTag;
|
|
144
119
|
const dials = _extends({}, DEFAULT_FLOW_DIALS, options.dials);
|
|
145
120
|
const { catalog } = options;
|
|
@@ -241,6 +216,11 @@ const segmentOf = (step)=>step.segment === undefined ? undefined : [
|
|
|
241
216
|
} : {}, accepts === undefined ? {} : {
|
|
242
217
|
accepts
|
|
243
218
|
}));
|
|
219
|
+
// Past the commit point the caller's write has landed, and the wait is
|
|
220
|
+
// for someone else — a courier, a person — so the flow says so and a
|
|
221
|
+
// browser holding the write pending can let it go. Before it, nothing
|
|
222
|
+
// has landed, and the flow stays silent.
|
|
223
|
+
if (grammar.announcesCommittedWaits && commitPoint !== -1 && steps.indexOf(step) > commitPoint) yield* announce('flow.waiting', step.step, ordinalOf(step));
|
|
244
224
|
const signalled = DurableDeferred.await(waitFor(step.step));
|
|
245
225
|
const timeoutMs = (_step_parameters1 = step.parameters) == null ? void 0 : _step_parameters1['timeoutMs'];
|
|
246
226
|
// A durable race, so a replay answers the branch that won rather than
|
|
@@ -363,7 +343,12 @@ const segmentOf = (step)=>step.segment === undefined ? undefined : [
|
|
|
363
343
|
* edit to an existing one; the journal replay holds every entry to its
|
|
364
344
|
* recorded command sequence.
|
|
365
345
|
*/ const INTERPRETERS = {
|
|
366
|
-
1:
|
|
346
|
+
1: (slip)=>walkSlip(slip, {
|
|
347
|
+
announcesCommittedWaits: false
|
|
348
|
+
}),
|
|
349
|
+
2: (slip)=>walkSlip(slip, {
|
|
350
|
+
announcesCommittedWaits: true
|
|
351
|
+
})
|
|
367
352
|
};
|
|
368
353
|
/** Every `slipVersion` the interpreter walks — each must have a journal. */ export const interpretedSlipVersions = Object.keys(INTERPRETERS).map(Number);
|
|
369
354
|
export const interpretSlip = (slip)=>INTERPRETERS[slip.slipVersion](slip);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/interpreter/slip-workflow.ts"],"sourcesContent":["import {\n type FragmentCatalog,\n Slip,\n type SlipStep,\n slipSteps,\n} from '@entifix/business/flow';\nimport {\n decodeProblem,\n type EntifixFailure,\n Failure,\n isFailure,\n JsonBody,\n problemOf,\n Timeout,\n} from '@entifix/core';\nimport {\n BulkheadTag,\n CircuitBreakerTag,\n flowEvent,\n type FlowEventName,\n On,\n OutboxTag,\n ParticipantClientTag,\n} from '@entifix/transactions';\nimport {\n Cause,\n Context,\n Effect,\n Exit,\n Metric,\n Schedule,\n Schema,\n SchemaTransformation,\n} from 'effect';\nimport {\n Activity,\n DurableClock,\n DurableDeferred,\n Workflow,\n} from 'effect/workflow';\n\nimport {\n type FlowRecordPatch,\n flowStates,\n FlowStatusStoreTag,\n} from '../status/flow-status-store.js';\nimport { makeBindings } from './bindings.js';\n\n/**\n * A failure as an Activity journals it: the problem body on the way in, the\n * failure its code names on the way out, so a resumed flow sees the typed\n * refusal a participant sent rather than a cast.\n */\nexport const JournaledFailure: Schema.Codec<EntifixFailure, unknown> =\n Schema.Unknown.pipe(\n Schema.decodeTo(\n Schema.declare((value): value is EntifixFailure => isFailure(value)),\n SchemaTransformation.transform({\n decode: body => decodeProblem(body),\n encode: failure => problemOf(failure),\n }),\n ),\n );\n\n/**\n * How a flow ended, as the workflow's own result: every step ran, or a\n * refusal before the commit point was undone, or an undoing itself failed and\n * the flow stopped where it was — which a person has to look at — or a wait\n * that strands on its timeout ran out, which a person has to look at too.\n */\nexport const FlowOutcome = Schema.Literals([\n 'completed',\n 'compensated',\n 'failed',\n 'stranded',\n]);\n\n/**\n * What a wait does when its `timeoutMs` runs out, from its `onTimeout`\n * parameter: answer as if signalled with an outcome a later guard branches\n * on, strand the flow for an operator, or — named neither — fail as any step\n * does, which past the commit point suspends it.\n */\ntype OnTimeout =\n | { readonly kind: 'outcome'; readonly outcome: string }\n | { readonly kind: 'strand' }\n | { readonly kind: 'fail' };\n\nconst onTimeoutOf = (step: SlipStep): OnTimeout => {\n const named = step.parameters?.['onTimeout'];\n if (named === 'strand') return { kind: 'strand' };\n const outcome =\n typeof named === 'object' && named !== null\n ? (named as { readonly outcome?: unknown }).outcome\n : undefined;\n return typeof outcome === 'string'\n ? { kind: 'outcome', outcome }\n : { kind: 'fail' };\n};\n\n/** The outcome a wait was answered with: its signal's `outcome`, when a string. */\nconst outcomeOf = (answer: unknown): string | undefined => {\n const named =\n typeof answer === 'object' && answer !== null\n ? (answer as { readonly outcome?: unknown }).outcome\n : undefined;\n return typeof named === 'string' ? named : undefined;\n};\n\n/** The race's answer when a wait that strands on its timeout ran out. */\nconst STRANDED = Symbol.for('@entifix/workflow/stranded');\n\n/** A durable wait that outlived its timeout before its signal came. */\nexport class FlowWaitTimedOut extends Failure.timeout<FlowWaitTimedOut>()(\n 'FlowWaitTimedOut',\n 'flowWaitTimedOut',\n { step: Schema.String },\n { message: ({ step }) => `the wait at '${step}' timed out` },\n) {}\n\n/** How long a flow gives each participant call, and each step as a whole. */\nexport interface FlowDials {\n /** One attempt at a call. */\n readonly attemptTimeoutMs: number;\n /** Every attempt at a step together, retries included. */\n readonly stepTimeoutMs: number;\n /** Segments of one stage run at once. */\n readonly concurrency: number;\n}\n\nexport const DEFAULT_FLOW_DIALS: FlowDials = {\n attemptTimeoutMs: 10_000,\n stepTimeoutMs: 60_000,\n concurrency: 4,\n};\n\n/** What the interpreter runs a slip with: the catalog, who announces, the dials. */\nexport interface InterpreterOptions {\n readonly catalog: FragmentCatalog;\n /** The slice the `flow.*` events are announced from. */\n readonly source: string;\n readonly dials?: Partial<FlowDials>;\n /**\n * One participant's own attempt and step bounds, over `dials` — the same\n * shape the breaker's `dialsFor` and the bulkhead's `permitsFor` take, so a\n * participant's dials are one row set however many guards read them.\n */\n readonly dialsFor?: (\n participant: string,\n ) => Partial<Omit<FlowDials, 'concurrency'>> | undefined;\n}\n\n/**\n * The interpreter's options, provided to the workflow it is registered with —\n * the payload is the slip; the catalog and dials are the deployment's.\n */\nexport class InterpreterOptionsTag extends Context.Service<\n InterpreterOptionsTag,\n InterpreterOptions\n>()('@entifix/workflow/InterpreterOptions') {}\n\n/**\n * The one workflow every flow runs as: its payload is the pinned slip and the\n * idempotency key that started it\n * ([ADR 0016](../../../../../docs/adr/0016-a-flow-engine-port-and-a-durable-workflow-adapter.md)).\n * The execution id derives from the key, so the same key is the same flow.\n *\n * A flow suspended past its commit point is resumed on the retry schedule:\n * a participant that comes back gets the step again, idempotently.\n */\nexport const SlipWorkflow = Workflow.make('entifix/slip', {\n payload: { key: Schema.String, slip: Slip },\n idempotencyKey: payload => payload.key,\n success: FlowOutcome,\n // Its failure is what suspends it past the commit point; it is never the\n // flow's result.\n error: JournaledFailure,\n // Doubling from a second, never more than a minute apart.\n suspendedRetrySchedule: Schedule.min([\n Schedule.exponential('1 second'),\n Schedule.spaced('1 minute'),\n ]),\n});\n\n/** The durable wait a `wait` step parks on, addressed by the step's name. */\nexport const waitFor = (step: string) =>\n DurableDeferred.make(`wait:${step}`, { success: Schema.Unknown });\n\n/** A step's failure, with the step it happened at. */\ninterface StepFailed {\n readonly step: SlipStep;\n readonly failure: EntifixFailure;\n}\n\nconst segmentOf = (step: SlipStep) =>\n step.segment === undefined\n ? undefined\n : [step.segment.vendor, step.segment.paymentMethod]\n .filter(Boolean)\n .join('/');\n\n/**\n * A stage's steps as the groups that run at once: one group per segment when\n * every step names one — a basket's vendors, joined before the shared pivot —\n * and otherwise one group, in order.\n */\nconst groupsOf = (steps: readonly SlipStep[]): readonly SlipStep[][] => {\n if (steps.some(step => segmentOf(step) === undefined)) return [[...steps]];\n const groups = new Map<string, SlipStep[]>();\n for (const step of steps) {\n const key = segmentOf(step) as string;\n groups.set(key, [...(groups.get(key) ?? []), step]);\n }\n return [...groups.values()];\n};\n\n/**\n * Interprets a pinned slip of grammar version 1\n * ([ADR 0016](../../../../../docs/adr/0016-a-flow-engine-port-and-a-durable-workflow-adapter.md)):\n * each step is an Activity named after it and keyed `<flowId>:<step>`, so a\n * resumed flow replays what already ran and calls a participant at most once\n * per step. Inside the Activity the call runs under the participant's\n * breaker and bulkhead and the retry budget, each attempt bounded and the\n * step as a whole bounded; nothing retries outside it.\n *\n * - Before and at the commit point, a failure — a breaker already open\n * included, which fails fast — compensates what succeeded, in reverse, and\n * the flow ends `compensated`.\n * - After it, a failure suspends the flow at that step: the money is taken,\n * so the flow rolls forward when the participant comes back, never back.\n * - A `wait` step parks the flow on a durable deferred its signal completes,\n * raced with a durable clock when it names `timeoutMs`; it may name a\n * `correlation`, so a sender that knows the order rather than the flow can\n * complete it.\n * - The segments of a stage run at once, bounded, and join before the next.\n *\n * Every transition is announced as a `flow.*` event through the outbox, by an\n * Activity, so it is written once whatever replays. Compensation is explicit\n * rather than a workflow finalizer, so the record says `compensated` only\n * after the last undoing has run — and an undoing that fails stops the flow\n * `failed` at that step instead of pretending.\n */\nconst interpretV1 = (slip: Slip) =>\n Effect.gen(function* () {\n const options = yield* InterpreterOptionsTag;\n const dials = { ...DEFAULT_FLOW_DIALS, ...options.dials };\n const { catalog } = options;\n const steps = slipSteps(slip);\n const ordinalOf = (step: SlipStep) => steps.indexOf(step) + 1;\n const commitPoint = steps.findIndex(\n step => catalog.get(step.ref)?.kind === 'pivot',\n );\n const bindings = makeBindings();\n const done: SlipStep[] = [];\n /** What each wait was answered with, by step name — what a guard reads. */\n const answered = new Map<string, string | undefined>();\n /** Steps a guard passed over; a step guarded on one of them is skipped too. */\n const skipped = new Set<string>();\n /** The wait whose timeout stranded the flow, once one has. */\n let stranded: SlipStep | undefined;\n\n const record = (name: string, patch: FlowRecordPatch) =>\n Activity.make({\n name,\n execute: Effect.flatMap(FlowStatusStoreTag, store =>\n store.update(slip.flowId, patch),\n ).pipe(\n Effect.andThen(\n Metric.update(\n Metric.withAttributes(flowStates, {\n state: patch.state,\n source: options.source,\n }),\n 1,\n ),\n ),\n Effect.orDie,\n ),\n });\n\n const announce = (\n name: FlowEventName,\n step: string,\n ordinal: number,\n failure?: EntifixFailure,\n ) =>\n Activity.make({\n name: `announce:${name}:${step}`,\n execute: Effect.flatMap(OutboxTag, outbox =>\n outbox.enqueue(\n flowEvent({\n name,\n source: options.source,\n at: new Date().toISOString(),\n step: `${name}:${step}`,\n ordinal,\n audience: [\n { kind: 'flow', id: slip.flowId },\n ...(slip.audience ?? []),\n ],\n data: {\n flowId: slip.flowId,\n definition: slip.recipe,\n slipVersion: slip.slipVersion,\n step,\n ...(failure === undefined\n ? {}\n : {\n failure: {\n code: failure.code,\n category: failure.category,\n },\n }),\n },\n }),\n ),\n ).pipe(Effect.orDie),\n });\n\n /** One call, bounded, under the participant's breaker, bulkhead and budget. */\n const guarded = (\n step: SlipStep,\n attempt: Effect.Effect<unknown, EntifixFailure>,\n ) =>\n Effect.gen(function* () {\n const key = step.participant ?? 'participant';\n const bounds = { ...dials, ...options.dialsFor?.(key) };\n const breaker = yield* CircuitBreakerTag;\n const bulkhead = yield* BulkheadTag;\n const timedOut = () => Effect.fail(new Timeout({ dependency: key }));\n return yield* breaker\n .guard(key)(\n bulkhead.withPermit(key)(\n attempt.pipe(\n Effect.timeoutOrElse({\n duration: bounds.attemptTimeoutMs,\n orElse: timedOut,\n }),\n ),\n ),\n )\n .pipe(\n On(Failure.isFamily('technical')).retry({\n key: { dependency: key },\n idempotent: true,\n }),\n Effect.timeoutOrElse({\n duration: bounds.stepTimeoutMs,\n orElse: timedOut,\n }),\n );\n });\n\n const call = (step: SlipStep, kind: 'action' | 'compensation') =>\n Activity.make({\n name: `${step.step}:${kind}`,\n // Whatever the participant answered, as JSON — `undefined` included,\n // which a journal cannot otherwise hold.\n success: JsonBody,\n error: JournaledFailure,\n execute: Effect.flatMap(ParticipantClientTag, participant =>\n guarded(\n step,\n participant.call({\n step,\n kind,\n idempotencyKey:\n kind === 'action'\n ? `${slip.flowId}:${step.step}`\n : `${slip.flowId}:${step.step}:compensation`,\n inputs: bindings.inputsFor(step, catalog.get(step.ref), kind),\n }),\n ),\n ),\n });\n\n const wait = (step: SlipStep) =>\n Effect.gen(function* () {\n const correlation = step.parameters?.['correlation'];\n const accepts = catalog.get(step.ref)?.outcomes;\n const onTimeout = onTimeoutOf(step);\n yield* record(`status:${step.step}:waiting`, {\n state: 'waiting',\n step: step.step,\n waitingFor: step.step,\n ...(typeof correlation === 'string' ? { correlation } : {}),\n ...(accepts === undefined ? {} : { accepts }),\n });\n const signalled = DurableDeferred.await(waitFor(step.step));\n const timeoutMs = step.parameters?.['timeoutMs'];\n // A durable race, so a replay answers the branch that won rather than\n // racing again.\n const answer =\n typeof timeoutMs === 'number'\n ? yield* DurableDeferred.raceAll({\n name: `race:${step.step}`,\n success: Schema.Unknown,\n error: FlowWaitTimedOut,\n effects: [\n signalled,\n DurableClock.sleep({\n name: `timeout:${step.step}`,\n duration: timeoutMs,\n }).pipe(\n Effect.andThen(\n // An outcome answers as a signal would; a strand and a\n // plain failure both fail the race, and are told apart\n // below — so the journaled race is the same either way.\n onTimeout.kind === 'outcome'\n ? Effect.succeed<unknown>({\n outcome: onTimeout.outcome,\n })\n : Effect.fail(\n new FlowWaitTimedOut({ step: step.step }),\n ),\n ),\n ),\n ],\n }).pipe(\n Effect.catchTag('FlowWaitTimedOut', timedOut =>\n onTimeout.kind === 'strand'\n ? Effect.succeed<unknown>(STRANDED)\n : Effect.fail(timedOut),\n ),\n )\n : yield* signalled;\n if (answer === STRANDED) {\n stranded = step;\n return;\n }\n answered.set(step.step, outcomeOf(answer));\n bindings.record(step, catalog.get(step.ref), answer);\n yield* record(`status:${step.step}:resumed`, {\n state: 'running',\n step: step.step,\n });\n });\n\n /** One step, its failure tagged with where it happened. */\n const run = (step: SlipStep) =>\n Effect.gen(function* () {\n // A stranded flow runs nothing more, in any group of the stage.\n if (stranded !== undefined) return;\n if (step.guard !== undefined) {\n const { wait: guardedOn, outcomes } = step.guard;\n const outcome = answered.get(guardedOn);\n if (\n skipped.has(guardedOn) ||\n outcome === undefined ||\n !outcomes.includes(outcome)\n ) {\n skipped.add(step.step);\n return;\n }\n }\n if (catalog.get(step.ref)?.kind === 'wait')\n return yield* wait(step).pipe(\n Effect.mapError((failure): StepFailed => ({ step, failure })),\n );\n yield* record(`status:${step.step}:running`, {\n state: 'running',\n step: step.step,\n });\n const answer = yield* call(step, 'action').pipe(\n Effect.mapError((failure): StepFailed => ({ step, failure })),\n );\n bindings.record(step, catalog.get(step.ref), answer);\n if (catalog.get(step.ref)?.kind === 'compensatable') done.push(step);\n });\n\n yield* announce('flow.started', 'started', 0);\n\n for (const stage of slip.stages) {\n const exits = yield* Effect.forEach(\n groupsOf(stage.steps),\n group => Effect.exit(Effect.forEach(group, run, { discard: true })),\n { concurrency: dials.concurrency },\n );\n // The earliest step that failed decides; a group's failure is its own.\n const [first] = exits\n .flatMap(exit =>\n Exit.isFailure(exit)\n ? // A durable race fails with its losers' interruptions beside\n // the failure that won, so the failure is looked for.\n exit.cause.reasons\n .filter(Cause.isFailReason)\n .map(reason => reason.error)\n : [],\n )\n .sort((a, b) => ordinalOf(a.step) - ordinalOf(b.step));\n if (first === undefined) {\n if (stranded === undefined) continue;\n yield* record(`status:${stranded.step}:stranded`, {\n state: 'stranded',\n step: stranded.step,\n });\n yield* announce('flow.stranded', stranded.step, ordinalOf(stranded));\n return 'stranded' as const;\n }\n\n const { step, failure } = first;\n if (commitPoint === -1 || steps.indexOf(step) <= commitPoint) {\n for (const undone of [...done].reverse()) {\n const undoing = yield* Effect.exit(call(undone, 'compensation'));\n if (Exit.isFailure(undoing)) {\n yield* record(`status:${undone.step}:failed`, {\n state: 'failed',\n step: undone.step,\n });\n yield* announce(\n 'flow.failed',\n undone.step,\n ordinalOf(undone),\n failure,\n );\n return 'failed' as const;\n }\n }\n yield* record(`status:${step.step}:compensated`, {\n state: 'compensated',\n step: step.step,\n });\n yield* announce('flow.failed', step.step, ordinalOf(step), failure);\n return 'compensated' as const;\n }\n\n yield* record(`status:${step.step}:suspended`, {\n state: 'suspended',\n step: step.step,\n });\n yield* announce('flow.suspended', step.step, ordinalOf(step), failure);\n return yield* Effect.fail(failure).pipe(\n Effect.provideService(Workflow.SuspendOnFailure, true),\n );\n }\n\n yield* record('status:completed', { state: 'completed' });\n yield* announce('flow.completed', 'completed', steps.length + 1);\n return 'completed' as const;\n });\n\n/**\n * One interpreter per grammar version a slip can be written in. A flow runs\n * to its end under the grammar it started with, so a change to how steps are\n * walked — their order, their Activity names — is a new entry here, never an\n * edit to an existing one; the journal replay holds every entry to its\n * recorded command sequence.\n */\nconst INTERPRETERS = { 1: interpretV1 } as const satisfies Record<\n Slip['slipVersion'],\n (slip: Slip) => unknown\n>;\n\n/** Every `slipVersion` the interpreter walks — each must have a journal. */\nexport const interpretedSlipVersions: readonly number[] =\n Object.keys(INTERPRETERS).map(Number);\n\nexport const interpretSlip = (slip: Slip) =>\n INTERPRETERS[slip.slipVersion](slip);\n\n/** The interpreter registered with the workflow engine, with its options. */\nexport const SlipWorkflowLayer = (options: InterpreterOptions) =>\n SlipWorkflow.toLayer(payload =>\n interpretSlip(payload.slip).pipe(\n Effect.provideService(InterpreterOptionsTag, options),\n ),\n );\n"],"names":["Slip","slipSteps","decodeProblem","Failure","isFailure","JsonBody","problemOf","Timeout","BulkheadTag","CircuitBreakerTag","flowEvent","On","OutboxTag","ParticipantClientTag","Cause","Context","Effect","Exit","Metric","Schedule","Schema","SchemaTransformation","Activity","DurableClock","DurableDeferred","Workflow","flowStates","FlowStatusStoreTag","makeBindings","JournaledFailure","Unknown","pipe","decodeTo","declare","value","transform","decode","body","encode","failure","FlowOutcome","Literals","onTimeoutOf","step","named","parameters","kind","outcome","undefined","outcomeOf","answer","STRANDED","Symbol","for","FlowWaitTimedOut","timeout","String","message","DEFAULT_FLOW_DIALS","attemptTimeoutMs","stepTimeoutMs","concurrency","InterpreterOptionsTag","Service","SlipWorkflow","make","payload","key","slip","idempotencyKey","success","error","suspendedRetrySchedule","min","exponential","spaced","waitFor","segmentOf","segment","vendor","paymentMethod","filter","Boolean","join","groupsOf","steps","some","groups","Map","set","get","values","interpretV1","gen","options","dials","catalog","ordinalOf","indexOf","commitPoint","findIndex","ref","bindings","done","answered","skipped","Set","stranded","record","name","patch","execute","flatMap","store","update","flowId","andThen","withAttributes","state","source","orDie","announce","ordinal","outbox","enqueue","at","Date","toISOString","audience","id","data","definition","recipe","slipVersion","code","category","guarded","attempt","participant","bounds","dialsFor","breaker","bulkhead","timedOut","fail","dependency","guard","withPermit","timeoutOrElse","duration","orElse","isFamily","retry","idempotent","call","inputs","inputsFor","wait","correlation","accepts","outcomes","onTimeout","waitingFor","signalled","await","timeoutMs","raceAll","effects","sleep","succeed","catchTag","run","guardedOn","has","includes","add","mapError","push","stage","stages","exits","forEach","group","exit","discard","first","cause","reasons","isFailReason","map","reason","sort","a","b","undone","reverse","undoing","provideService","SuspendOnFailure","length","INTERPRETERS","interpretedSlipVersions","Object","keys","Number","interpretSlip","SlipWorkflowLayer","toLayer"],"mappings":";AAAA,SAEEA,IAAI,EAEJC,SAAS,QACJ,yBAAyB;AAChC,SACEC,aAAa,EAEbC,OAAO,EACPC,SAAS,EACTC,QAAQ,EACRC,SAAS,EACTC,OAAO,QACF,gBAAgB;AACvB,SACEC,WAAW,EACXC,iBAAiB,EACjBC,SAAS,EAETC,EAAE,EACFC,SAAS,EACTC,oBAAoB,QACf,wBAAwB;AAC/B,SACEC,KAAK,EACLC,OAAO,EACPC,MAAM,EACNC,IAAI,EACJC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,oBAAoB,QACf,SAAS;AAChB,SACEC,QAAQ,EACRC,YAAY,EACZC,eAAe,EACfC,QAAQ,QACH,kBAAkB;AAEzB,SAEEC,UAAU,EACVC,kBAAkB,QACb,iCAAiC;AACxC,SAASC,YAAY,QAAQ,gBAAgB;AAE7C;;;;CAIC,GACD,OAAO,MAAMC,mBACXT,OAAOU,OAAO,CAACC,IAAI,CACjBX,OAAOY,QAAQ,CACbZ,OAAOa,OAAO,CAAC,C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UiG,SACV3J;wBAEF,OAAO;oBACT;gBACF;gBACA,OAAOqE,OAAO,CAAC,OAAO,EAAEjE,KAAKA,IAAI,CAAC,YAAY,CAAC,EAAE;oBAC/C2E,OAAO;oBACP3E,MAAMA,KAAKA,IAAI;gBACjB;gBACA,OAAO8E,SAAS,eAAe9E,KAAKA,IAAI,EAAEsD,UAAUtD,OAAOJ;gBAC3D,OAAO;YACT;YAEA,OAAOqE,OAAO,CAAC,OAAO,EAAEjE,KAAKA,IAAI,CAAC,UAAU,CAAC,EAAE;gBAC7C2E,OAAO;gBACP3E,MAAMA,KAAKA,IAAI;YACjB;YACA,OAAO8E,SAAS,kBAAkB9E,KAAKA,IAAI,EAAEsD,UAAUtD,OAAOJ;YAC9D,OAAO,OAAOvB,OAAOgI,IAAI,CAACzG,SAASR,IAAI,CACrCf,OAAOqL,cAAc,CAAC5K,SAAS6K,gBAAgB,EAAE;QAErD;QAEA,OAAO1F,OAAO,oBAAoB;YAAEU,OAAO;QAAY;QACvD,OAAOG,SAAS,kBAAkB,aAAapC,MAAMkH,MAAM,GAAG;QAC9D,OAAO;IACT;AAEF;;;;;;CAMC,GACD,MAAMC,eAAe;IAAE,GAAG5G;AAAY;AAKtC,0EAA0E,GAC1E,OAAO,MAAM6G,0BACXC,OAAOC,IAAI,CAACH,cAAcX,GAAG,CAACe,QAAQ;AAExC,OAAO,MAAMC,gBAAgB,CAACzI,OAC5BoI,YAAY,CAACpI,KAAKiE,WAAW,CAAC,CAACjE,MAAM;AAEvC,2EAA2E,GAC3E,OAAO,MAAM0I,oBAAoB,CAAChH,UAChC9B,aAAa+I,OAAO,CAAC7I,CAAAA,UACnB2I,cAAc3I,QAAQE,IAAI,EAAErC,IAAI,CAC9Bf,OAAOqL,cAAc,CAACvI,uBAAuBgC,WAE/C"}
|
|
1
|
+
{"version":3,"sources":["../../src/interpreter/slip-workflow.ts"],"sourcesContent":["import {\n type FragmentCatalog,\n Slip,\n type SlipStep,\n slipSteps,\n} from '@entifix/business/flow';\nimport {\n decodeProblem,\n type EntifixFailure,\n Failure,\n isFailure,\n JsonBody,\n problemOf,\n Timeout,\n} from '@entifix/core';\nimport {\n BulkheadTag,\n CircuitBreakerTag,\n flowEvent,\n type FlowEventName,\n On,\n OutboxTag,\n ParticipantClientTag,\n} from '@entifix/transactions';\nimport {\n Cause,\n Context,\n Effect,\n Exit,\n Metric,\n Schedule,\n Schema,\n SchemaTransformation,\n} from 'effect';\nimport {\n Activity,\n DurableClock,\n DurableDeferred,\n Workflow,\n} from 'effect/workflow';\n\nimport {\n type FlowRecordPatch,\n flowStates,\n FlowStatusStoreTag,\n} from '../status/flow-status-store.js';\nimport { makeBindings } from './bindings.js';\n\n/**\n * A failure as an Activity journals it: the problem body on the way in, the\n * failure its code names on the way out, so a resumed flow sees the typed\n * refusal a participant sent rather than a cast.\n */\nexport const JournaledFailure: Schema.Codec<EntifixFailure, unknown> =\n Schema.Unknown.pipe(\n Schema.decodeTo(\n Schema.declare((value): value is EntifixFailure => isFailure(value)),\n SchemaTransformation.transform({\n decode: body => decodeProblem(body),\n encode: failure => problemOf(failure),\n }),\n ),\n );\n\n/**\n * How a flow ended, as the workflow's own result: every step ran, or a\n * refusal before the commit point was undone, or an undoing itself failed and\n * the flow stopped where it was — which a person has to look at — or a wait\n * that strands on its timeout ran out, which a person has to look at too.\n */\nexport const FlowOutcome = Schema.Literals([\n 'completed',\n 'compensated',\n 'failed',\n 'stranded',\n]);\n\n/**\n * What a wait does when its `timeoutMs` runs out, from its `onTimeout`\n * parameter: answer as if signalled with an outcome a later guard branches\n * on, strand the flow for an operator, or — named neither — fail as any step\n * does, which past the commit point suspends it.\n */\ntype OnTimeout =\n | { readonly kind: 'outcome'; readonly outcome: string }\n | { readonly kind: 'strand' }\n | { readonly kind: 'fail' };\n\nconst onTimeoutOf = (step: SlipStep): OnTimeout => {\n const named = step.parameters?.['onTimeout'];\n if (named === 'strand') return { kind: 'strand' };\n const outcome =\n typeof named === 'object' && named !== null\n ? (named as { readonly outcome?: unknown }).outcome\n : undefined;\n return typeof outcome === 'string'\n ? { kind: 'outcome', outcome }\n : { kind: 'fail' };\n};\n\n/** The outcome a wait was answered with: its signal's `outcome`, when a string. */\nconst outcomeOf = (answer: unknown): string | undefined => {\n const named =\n typeof answer === 'object' && answer !== null\n ? (answer as { readonly outcome?: unknown }).outcome\n : undefined;\n return typeof named === 'string' ? named : undefined;\n};\n\n/** The race's answer when a wait that strands on its timeout ran out. */\nconst STRANDED = Symbol.for('@entifix/workflow/stranded');\n\n/** A durable wait that outlived its timeout before its signal came. */\nexport class FlowWaitTimedOut extends Failure.timeout<FlowWaitTimedOut>()(\n 'FlowWaitTimedOut',\n 'flowWaitTimedOut',\n { step: Schema.String },\n { message: ({ step }) => `the wait at '${step}' timed out` },\n) {}\n\n/** How long a flow gives each participant call, and each step as a whole. */\nexport interface FlowDials {\n /** One attempt at a call. */\n readonly attemptTimeoutMs: number;\n /** Every attempt at a step together, retries included. */\n readonly stepTimeoutMs: number;\n /** Segments of one stage run at once. */\n readonly concurrency: number;\n}\n\nexport const DEFAULT_FLOW_DIALS: FlowDials = {\n attemptTimeoutMs: 10_000,\n stepTimeoutMs: 60_000,\n concurrency: 4,\n};\n\n/** What the interpreter runs a slip with: the catalog, who announces, the dials. */\nexport interface InterpreterOptions {\n readonly catalog: FragmentCatalog;\n /** The slice the `flow.*` events are announced from. */\n readonly source: string;\n readonly dials?: Partial<FlowDials>;\n /**\n * One participant's own attempt and step bounds, over `dials` — the same\n * shape the breaker's `dialsFor` and the bulkhead's `permitsFor` take, so a\n * participant's dials are one row set however many guards read them.\n */\n readonly dialsFor?: (\n participant: string,\n ) => Partial<Omit<FlowDials, 'concurrency'>> | undefined;\n}\n\n/**\n * The interpreter's options, provided to the workflow it is registered with —\n * the payload is the slip; the catalog and dials are the deployment's.\n */\nexport class InterpreterOptionsTag extends Context.Service<\n InterpreterOptionsTag,\n InterpreterOptions\n>()('@entifix/workflow/InterpreterOptions') {}\n\n/**\n * The one workflow every flow runs as: its payload is the pinned slip and the\n * idempotency key that started it\n * ([ADR 0016](../../../../../docs/adr/0016-a-flow-engine-port-and-a-durable-workflow-adapter.md)).\n * The execution id derives from the key, so the same key is the same flow.\n *\n * A flow suspended past its commit point is resumed on the retry schedule:\n * a participant that comes back gets the step again, idempotently.\n */\nexport const SlipWorkflow = Workflow.make('entifix/slip', {\n payload: { key: Schema.String, slip: Slip },\n idempotencyKey: payload => payload.key,\n success: FlowOutcome,\n // Its failure is what suspends it past the commit point; it is never the\n // flow's result.\n error: JournaledFailure,\n // Doubling from a second, never more than a minute apart.\n suspendedRetrySchedule: Schedule.min([\n Schedule.exponential('1 second'),\n Schedule.spaced('1 minute'),\n ]),\n});\n\n/** The durable wait a `wait` step parks on, addressed by the step's name. */\nexport const waitFor = (step: string) =>\n DurableDeferred.make(`wait:${step}`, { success: Schema.Unknown });\n\n/** A step's failure, with the step it happened at. */\ninterface StepFailed {\n readonly step: SlipStep;\n readonly failure: EntifixFailure;\n}\n\nconst segmentOf = (step: SlipStep) =>\n step.segment === undefined\n ? undefined\n : [step.segment.vendor, step.segment.paymentMethod]\n .filter(Boolean)\n .join('/');\n\n/**\n * A stage's steps as the groups that run at once: one group per segment when\n * every step names one — a basket's vendors, joined before the shared pivot —\n * and otherwise one group, in order.\n */\nconst groupsOf = (steps: readonly SlipStep[]): readonly SlipStep[][] => {\n if (steps.some(step => segmentOf(step) === undefined)) return [[...steps]];\n const groups = new Map<string, SlipStep[]>();\n for (const step of steps) {\n const key = segmentOf(step) as string;\n groups.set(key, [...(groups.get(key) ?? []), step]);\n }\n return [...groups.values()];\n};\n\n/**\n * Interprets a pinned slip of grammar version 1\n * ([ADR 0016](../../../../../docs/adr/0016-a-flow-engine-port-and-a-durable-workflow-adapter.md)):\n * each step is an Activity named after it and keyed `<flowId>:<step>`, so a\n * resumed flow replays what already ran and calls a participant at most once\n * per step. Inside the Activity the call runs under the participant's\n * breaker and bulkhead and the retry budget, each attempt bounded and the\n * step as a whole bounded; nothing retries outside it.\n *\n * - Before and at the commit point, a failure — a breaker already open\n * included, which fails fast — compensates what succeeded, in reverse, and\n * the flow ends `compensated`.\n * - After it, a failure suspends the flow at that step: the money is taken,\n * so the flow rolls forward when the participant comes back, never back.\n * - A `wait` step parks the flow on a durable deferred its signal completes,\n * raced with a durable clock when it names `timeoutMs`; it may name a\n * `correlation`, so a sender that knows the order rather than the flow can\n * complete it.\n * - The segments of a stage run at once, bounded, and join before the next.\n *\n * Every transition is announced as a `flow.*` event through the outbox, by an\n * Activity, so it is written once whatever replays. Compensation is explicit\n * rather than a workflow finalizer, so the record says `compensated` only\n * after the last undoing has run — and an undoing that fails stops the flow\n * `failed` at that step instead of pretending.\n */\n/** What differs between grammar versions as the walk is interpreted. */\ninterface Grammar {\n /** Whether a wait past the commit point announces `flow.waiting` (v2). */\n readonly announcesCommittedWaits: boolean;\n}\n\nconst walkSlip = (slip: Slip, grammar: Grammar) =>\n Effect.gen(function* () {\n const options = yield* InterpreterOptionsTag;\n const dials = { ...DEFAULT_FLOW_DIALS, ...options.dials };\n const { catalog } = options;\n const steps = slipSteps(slip);\n const ordinalOf = (step: SlipStep) => steps.indexOf(step) + 1;\n const commitPoint = steps.findIndex(\n step => catalog.get(step.ref)?.kind === 'pivot',\n );\n const bindings = makeBindings();\n const done: SlipStep[] = [];\n /** What each wait was answered with, by step name — what a guard reads. */\n const answered = new Map<string, string | undefined>();\n /** Steps a guard passed over; a step guarded on one of them is skipped too. */\n const skipped = new Set<string>();\n /** The wait whose timeout stranded the flow, once one has. */\n let stranded: SlipStep | undefined;\n\n const record = (name: string, patch: FlowRecordPatch) =>\n Activity.make({\n name,\n execute: Effect.flatMap(FlowStatusStoreTag, store =>\n store.update(slip.flowId, patch),\n ).pipe(\n Effect.andThen(\n Metric.update(\n Metric.withAttributes(flowStates, {\n state: patch.state,\n source: options.source,\n }),\n 1,\n ),\n ),\n Effect.orDie,\n ),\n });\n\n const announce = (\n name: FlowEventName,\n step: string,\n ordinal: number,\n failure?: EntifixFailure,\n ) =>\n Activity.make({\n name: `announce:${name}:${step}`,\n execute: Effect.flatMap(OutboxTag, outbox =>\n outbox.enqueue(\n flowEvent({\n name,\n source: options.source,\n at: new Date().toISOString(),\n step: `${name}:${step}`,\n ordinal,\n audience: [\n { kind: 'flow', id: slip.flowId },\n ...(slip.audience ?? []),\n ],\n data: {\n flowId: slip.flowId,\n definition: slip.recipe,\n slipVersion: slip.slipVersion,\n step,\n ...(failure === undefined\n ? {}\n : {\n failure: {\n code: failure.code,\n category: failure.category,\n },\n }),\n },\n }),\n ),\n ).pipe(Effect.orDie),\n });\n\n /** One call, bounded, under the participant's breaker, bulkhead and budget. */\n const guarded = (\n step: SlipStep,\n attempt: Effect.Effect<unknown, EntifixFailure>,\n ) =>\n Effect.gen(function* () {\n const key = step.participant ?? 'participant';\n const bounds = { ...dials, ...options.dialsFor?.(key) };\n const breaker = yield* CircuitBreakerTag;\n const bulkhead = yield* BulkheadTag;\n const timedOut = () => Effect.fail(new Timeout({ dependency: key }));\n return yield* breaker\n .guard(key)(\n bulkhead.withPermit(key)(\n attempt.pipe(\n Effect.timeoutOrElse({\n duration: bounds.attemptTimeoutMs,\n orElse: timedOut,\n }),\n ),\n ),\n )\n .pipe(\n On(Failure.isFamily('technical')).retry({\n key: { dependency: key },\n idempotent: true,\n }),\n Effect.timeoutOrElse({\n duration: bounds.stepTimeoutMs,\n orElse: timedOut,\n }),\n );\n });\n\n const call = (step: SlipStep, kind: 'action' | 'compensation') =>\n Activity.make({\n name: `${step.step}:${kind}`,\n // Whatever the participant answered, as JSON — `undefined` included,\n // which a journal cannot otherwise hold.\n success: JsonBody,\n error: JournaledFailure,\n execute: Effect.flatMap(ParticipantClientTag, participant =>\n guarded(\n step,\n participant.call({\n step,\n kind,\n idempotencyKey:\n kind === 'action'\n ? `${slip.flowId}:${step.step}`\n : `${slip.flowId}:${step.step}:compensation`,\n inputs: bindings.inputsFor(step, catalog.get(step.ref), kind),\n }),\n ),\n ),\n });\n\n const wait = (step: SlipStep) =>\n Effect.gen(function* () {\n const correlation = step.parameters?.['correlation'];\n const accepts = catalog.get(step.ref)?.outcomes;\n const onTimeout = onTimeoutOf(step);\n yield* record(`status:${step.step}:waiting`, {\n state: 'waiting',\n step: step.step,\n waitingFor: step.step,\n ...(typeof correlation === 'string' ? { correlation } : {}),\n ...(accepts === undefined ? {} : { accepts }),\n });\n // Past the commit point the caller's write has landed, and the wait is\n // for someone else — a courier, a person — so the flow says so and a\n // browser holding the write pending can let it go. Before it, nothing\n // has landed, and the flow stays silent.\n if (\n grammar.announcesCommittedWaits &&\n commitPoint !== -1 &&\n steps.indexOf(step) > commitPoint\n )\n yield* announce('flow.waiting', step.step, ordinalOf(step));\n const signalled = DurableDeferred.await(waitFor(step.step));\n const timeoutMs = step.parameters?.['timeoutMs'];\n // A durable race, so a replay answers the branch that won rather than\n // racing again.\n const answer =\n typeof timeoutMs === 'number'\n ? yield* DurableDeferred.raceAll({\n name: `race:${step.step}`,\n success: Schema.Unknown,\n error: FlowWaitTimedOut,\n effects: [\n signalled,\n DurableClock.sleep({\n name: `timeout:${step.step}`,\n duration: timeoutMs,\n }).pipe(\n Effect.andThen(\n // An outcome answers as a signal would; a strand and a\n // plain failure both fail the race, and are told apart\n // below — so the journaled race is the same either way.\n onTimeout.kind === 'outcome'\n ? Effect.succeed<unknown>({\n outcome: onTimeout.outcome,\n })\n : Effect.fail(\n new FlowWaitTimedOut({ step: step.step }),\n ),\n ),\n ),\n ],\n }).pipe(\n Effect.catchTag('FlowWaitTimedOut', timedOut =>\n onTimeout.kind === 'strand'\n ? Effect.succeed<unknown>(STRANDED)\n : Effect.fail(timedOut),\n ),\n )\n : yield* signalled;\n if (answer === STRANDED) {\n stranded = step;\n return;\n }\n answered.set(step.step, outcomeOf(answer));\n bindings.record(step, catalog.get(step.ref), answer);\n yield* record(`status:${step.step}:resumed`, {\n state: 'running',\n step: step.step,\n });\n });\n\n /** One step, its failure tagged with where it happened. */\n const run = (step: SlipStep) =>\n Effect.gen(function* () {\n // A stranded flow runs nothing more, in any group of the stage.\n if (stranded !== undefined) return;\n if (step.guard !== undefined) {\n const { wait: guardedOn, outcomes } = step.guard;\n const outcome = answered.get(guardedOn);\n if (\n skipped.has(guardedOn) ||\n outcome === undefined ||\n !outcomes.includes(outcome)\n ) {\n skipped.add(step.step);\n return;\n }\n }\n if (catalog.get(step.ref)?.kind === 'wait')\n return yield* wait(step).pipe(\n Effect.mapError((failure): StepFailed => ({ step, failure })),\n );\n yield* record(`status:${step.step}:running`, {\n state: 'running',\n step: step.step,\n });\n const answer = yield* call(step, 'action').pipe(\n Effect.mapError((failure): StepFailed => ({ step, failure })),\n );\n bindings.record(step, catalog.get(step.ref), answer);\n if (catalog.get(step.ref)?.kind === 'compensatable') done.push(step);\n });\n\n yield* announce('flow.started', 'started', 0);\n\n for (const stage of slip.stages) {\n const exits = yield* Effect.forEach(\n groupsOf(stage.steps),\n group => Effect.exit(Effect.forEach(group, run, { discard: true })),\n { concurrency: dials.concurrency },\n );\n // The earliest step that failed decides; a group's failure is its own.\n const [first] = exits\n .flatMap(exit =>\n Exit.isFailure(exit)\n ? // A durable race fails with its losers' interruptions beside\n // the failure that won, so the failure is looked for.\n exit.cause.reasons\n .filter(Cause.isFailReason)\n .map(reason => reason.error)\n : [],\n )\n .sort((a, b) => ordinalOf(a.step) - ordinalOf(b.step));\n if (first === undefined) {\n if (stranded === undefined) continue;\n yield* record(`status:${stranded.step}:stranded`, {\n state: 'stranded',\n step: stranded.step,\n });\n yield* announce('flow.stranded', stranded.step, ordinalOf(stranded));\n return 'stranded' as const;\n }\n\n const { step, failure } = first;\n if (commitPoint === -1 || steps.indexOf(step) <= commitPoint) {\n for (const undone of [...done].reverse()) {\n const undoing = yield* Effect.exit(call(undone, 'compensation'));\n if (Exit.isFailure(undoing)) {\n yield* record(`status:${undone.step}:failed`, {\n state: 'failed',\n step: undone.step,\n });\n yield* announce(\n 'flow.failed',\n undone.step,\n ordinalOf(undone),\n failure,\n );\n return 'failed' as const;\n }\n }\n yield* record(`status:${step.step}:compensated`, {\n state: 'compensated',\n step: step.step,\n });\n yield* announce('flow.failed', step.step, ordinalOf(step), failure);\n return 'compensated' as const;\n }\n\n yield* record(`status:${step.step}:suspended`, {\n state: 'suspended',\n step: step.step,\n });\n yield* announce('flow.suspended', step.step, ordinalOf(step), failure);\n return yield* Effect.fail(failure).pipe(\n Effect.provideService(Workflow.SuspendOnFailure, true),\n );\n }\n\n yield* record('status:completed', { state: 'completed' });\n yield* announce('flow.completed', 'completed', steps.length + 1);\n return 'completed' as const;\n });\n\n/**\n * One interpreter per grammar version a slip can be written in. A flow runs\n * to its end under the grammar it started with, so a change to how steps are\n * walked — their order, their Activity names — is a new entry here, never an\n * edit to an existing one; the journal replay holds every entry to its\n * recorded command sequence.\n */\nconst INTERPRETERS = {\n 1: (slip: Slip) => walkSlip(slip, { announcesCommittedWaits: false }),\n 2: (slip: Slip) => walkSlip(slip, { announcesCommittedWaits: true }),\n} as const satisfies Record<Slip['slipVersion'], (slip: Slip) => unknown>;\n\n/** Every `slipVersion` the interpreter walks — each must have a journal. */\nexport const interpretedSlipVersions: readonly number[] =\n Object.keys(INTERPRETERS).map(Number);\n\nexport const interpretSlip = (slip: Slip) =>\n INTERPRETERS[slip.slipVersion](slip);\n\n/** The interpreter registered with the workflow engine, with its options. */\nexport const SlipWorkflowLayer = (options: InterpreterOptions) =>\n SlipWorkflow.toLayer(payload =>\n interpretSlip(payload.slip).pipe(\n Effect.provideService(InterpreterOptionsTag, options),\n ),\n );\n"],"names":["Slip","slipSteps","decodeProblem","Failure","isFailure","JsonBody","problemOf","Timeout","BulkheadTag","CircuitBreakerTag","flowEvent","On","OutboxTag","ParticipantClientTag","Cause","Context","Effect","Exit","Metric","Schedule","Schema","SchemaTransformation","Activity","DurableClock","DurableDeferred","Workflow","flowStates","FlowStatusStoreTag","makeBindings","JournaledFailure","Unknown","pipe","decodeTo","declare","value","transform","decode","body","encode","failure","FlowOutcome","Literals","onTimeoutOf","step","named","parameters","kind","outcome","undefined","outcomeOf","answer","STRANDED","Symbol","for","FlowWaitTimedOut","timeout","String","message","DEFAULT_FLOW_DIALS","attemptTimeoutMs","stepTimeoutMs","concurrency","InterpreterOptionsTag","Service","SlipWorkflow","make","payload","key","slip","idempotencyKey","success","error","suspendedRetrySchedule","min","exponential","spaced","waitFor","segmentOf","segment","vendor","paymentMethod","filter","Boolean","join","groupsOf","steps","some","groups","Map","set","get","values","walkSlip","grammar","gen","options","dials","catalog","ordinalOf","indexOf","commitPoint","findIndex","ref","bindings","done","answered","skipped","Set","stranded","record","name","patch","execute","flatMap","store","update","flowId","andThen","withAttributes","state","source","orDie","announce","ordinal","outbox","enqueue","at","Date","toISOString","audience","id","data","definition","recipe","slipVersion","code","category","guarded","attempt","participant","bounds","dialsFor","breaker","bulkhead","timedOut","fail","dependency","guard","withPermit","timeoutOrElse","duration","orElse","isFamily","retry","idempotent","call","inputs","inputsFor","wait","correlation","accepts","outcomes","onTimeout","waitingFor","announcesCommittedWaits","signalled","await","timeoutMs","raceAll","effects","sleep","succeed","catchTag","run","guardedOn","has","includes","add","mapError","push","stage","stages","exits","forEach","group","exit","discard","first","cause","reasons","isFailReason","map","reason","sort","a","b","undone","reverse","undoing","provideService","SuspendOnFailure","length","INTERPRETERS","interpretedSlipVersions","Object","keys","Number","interpretSlip","SlipWorkflowLayer","toLayer"],"mappings":";AAAA,SAEEA,IAAI,EAEJC,SAAS,QACJ,yBAAyB;AAChC,SACEC,aAAa,EAEbC,OAAO,EACPC,SAAS,EACTC,QAAQ,EACRC,SAAS,EACTC,OAAO,QACF,gBAAgB;AACvB,SACEC,WAAW,EACXC,iBAAiB,EACjBC,SAAS,EAETC,EAAE,EACFC,SAAS,EACTC,oBAAoB,QACf,wBAAwB;AAC/B,SACEC,KAAK,EACLC,OAAO,EACPC,MAAM,EACNC,IAAI,EACJC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,oBAAoB,QACf,SAAS;AACh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AAM;IACnE,GAAG,CAAChG,OAAewB,SAASxB,MAAM;YAAEgG,yBAAyB;QAAK;AACpE;AAEA,0EAA0E,GAC1E,OAAO,MAAMuC,0BACXC,OAAOC,IAAI,CAACH,cAAcX,GAAG,CAACe,QAAQ;AAExC,OAAO,MAAMC,gBAAgB,CAAC3I,OAC5BsI,YAAY,CAACtI,KAAKkE,WAAW,CAAC,CAAClE,MAAM;AAEvC,2EAA2E,GAC3E,OAAO,MAAM4I,oBAAoB,CAACjH,UAChC/B,aAAaiJ,OAAO,CAAC/I,CAAAA,UACnB6I,cAAc7I,QAAQE,IAAI,EAAErC,IAAI,CAC9Bf,OAAOuL,cAAc,CAACzI,uBAAuBiC,WAE/C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entifix/workflow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Durable flows: the slip interpreter on Effect Workflow, behind the flow engine port, with Postgres storage and socket runners.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -89,16 +89,16 @@
|
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
91
|
"@swc/helpers": "0.5.23",
|
|
92
|
-
"@entifix/
|
|
93
|
-
"@entifix/
|
|
94
|
-
"@entifix/sql": "0.
|
|
95
|
-
"@entifix/transactions": "0.
|
|
92
|
+
"@entifix/business": "0.17.0",
|
|
93
|
+
"@entifix/core": "0.17.0",
|
|
94
|
+
"@entifix/sql": "0.17.0",
|
|
95
|
+
"@entifix/transactions": "0.17.0"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
98
|
"@effect/platform-node": "4.0.7",
|
|
99
99
|
"@effect/sql-pg": "4.0.7",
|
|
100
100
|
"effect": "4.0.7",
|
|
101
|
-
"@entifix/testing-unit": "0.
|
|
101
|
+
"@entifix/testing-unit": "0.17.0"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
104
|
"@effect/platform-node": "^4.0.7",
|