deepline 0.1.182 → 0.1.183
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/bundling-sources/apps/play-runner-workers/src/child-play-await.ts +203 -6
- package/dist/bundling-sources/apps/play-runner-workers/src/child-play-submit.ts +8 -1
- package/dist/bundling-sources/apps/play-runner-workers/src/coordinator-entry.ts +633 -107
- package/dist/bundling-sources/apps/play-runner-workers/src/dedup-do.ts +3 -2
- package/dist/bundling-sources/apps/play-runner-workers/src/entry.ts +1747 -1890
- package/dist/bundling-sources/apps/play-runner-workers/src/runtime/harness-receipt-store.ts +116 -0
- package/dist/bundling-sources/apps/play-runner-workers/src/runtime/map-chunk-plan.ts +542 -78
- package/dist/bundling-sources/apps/play-runner-workers/src/runtime/receipts.ts +292 -11
- package/dist/bundling-sources/apps/play-runner-workers/src/runtime/run-work-dispatcher.ts +519 -0
- package/dist/bundling-sources/apps/play-runner-workers/src/runtime/tool-dispatch.ts +2381 -0
- package/dist/bundling-sources/apps/play-runner-workers/src/runtime/tool-receipts.ts +18 -5
- package/dist/bundling-sources/apps/play-runner-workers/src/runtime/work-budget.ts +130 -0
- package/dist/bundling-sources/apps/play-runner-workers/src/runtime/worker-platform-budget.ts +39 -0
- package/dist/bundling-sources/apps/play-runner-workers/src/workflow-retry-state.ts +2 -0
- package/dist/bundling-sources/sdk/src/client.ts +41 -0
- package/dist/bundling-sources/sdk/src/http.ts +23 -8
- package/dist/bundling-sources/sdk/src/plays/harness-stub.ts +56 -3
- package/dist/bundling-sources/sdk/src/release.ts +2 -2
- package/dist/bundling-sources/sdk/src/types.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +132 -10
- package/dist/bundling-sources/shared_libs/play-runtime/auth-scope-resolver.ts +92 -0
- package/dist/bundling-sources/shared_libs/play-runtime/batch-runtime.ts +4 -4
- package/dist/bundling-sources/shared_libs/play-runtime/batching-types.ts +8 -0
- package/dist/bundling-sources/shared_libs/play-runtime/child-run-id.ts +101 -0
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +1605 -281
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +105 -6
- package/dist/bundling-sources/shared_libs/play-runtime/dedup-backend.ts +0 -0
- package/dist/bundling-sources/shared_libs/play-runtime/default-batch-strategies.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/durability-store.ts +4 -0
- package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +116 -16
- package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +186 -20
- package/dist/bundling-sources/shared_libs/play-runtime/dynamic-worker-version.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/execution-ledger-store.ts +133 -0
- package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +245 -0
- package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +5 -5
- package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +14 -0
- package/dist/bundling-sources/shared_libs/play-runtime/lease-policy.ts +52 -0
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +41 -0
- package/dist/bundling-sources/shared_libs/play-runtime/providers.ts +3 -2
- package/dist/bundling-sources/shared_libs/play-runtime/receipt-sql.ts +124 -0
- package/dist/bundling-sources/shared_libs/play-runtime/receipt-status.ts +6 -2
- package/dist/bundling-sources/shared_libs/play-runtime/row-isolation.ts +48 -2
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +158 -15
- package/dist/bundling-sources/shared_libs/play-runtime/run-terminal-source.ts +45 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-actions.ts +9 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +2037 -262
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-contract.ts +42 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-attempt-state-machine.ts +183 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-errors.ts +88 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +8 -1
- package/dist/bundling-sources/shared_libs/play-runtime/sheet-attempt-sql.ts +103 -0
- package/dist/bundling-sources/shared_libs/play-runtime/suspension.ts +19 -1
- package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +343 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +43 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +11 -0
- package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-state-machine.ts +437 -0
- package/dist/bundling-sources/shared_libs/play-runtime/work-receipts.ts +83 -6
- package/dist/bundling-sources/shared_libs/security/safe-outbound-fetch.ts +24 -17
- package/dist/cli/index.js +76 -17
- package/dist/cli/index.mjs +76 -17
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +63 -9
- package/dist/index.mjs +63 -9
- package/dist/plays/bundle-play-file.mjs +2 -2
- package/package.json +1 -1
|
@@ -2,6 +2,11 @@ import {
|
|
|
2
2
|
normalizePlayRunFailure,
|
|
3
3
|
PLATFORM_DEPLOY_INTERRUPTED_MESSAGE,
|
|
4
4
|
} from './run-failure';
|
|
5
|
+
import {
|
|
6
|
+
isAuthoritativePlayRunTerminalSource,
|
|
7
|
+
nextPlayRunLedgerTerminalSource,
|
|
8
|
+
normalizePlayRunLedgerTerminalSource,
|
|
9
|
+
} from './run-terminal-source';
|
|
5
10
|
|
|
6
11
|
export type PlayRunLedgerStatus =
|
|
7
12
|
| 'queued'
|
|
@@ -88,6 +93,17 @@ export type PlayRunLedgerSnapshot = {
|
|
|
88
93
|
resultTableNamespace?: string | null;
|
|
89
94
|
resultSummary?: unknown;
|
|
90
95
|
result?: unknown;
|
|
96
|
+
/**
|
|
97
|
+
* Source of the event that made this snapshot terminal. Authoritative
|
|
98
|
+
* producers ('worker', 'temporal', scheduler-outbox 'system') carry the
|
|
99
|
+
* play's final result; a 'coordinator'-sourced terminal is a transport
|
|
100
|
+
* heal whose `result` came from the coordinator's live cache and may be a
|
|
101
|
+
* partial mid-execution snapshot. Read-side canonical checks treat
|
|
102
|
+
* 'coordinator'-sourced completeds as provisional (see
|
|
103
|
+
* `hasCanonicalTerminalRunSnapshot`). Absent on snapshots persisted before
|
|
104
|
+
* this field existed — those are treated as authoritative.
|
|
105
|
+
*/
|
|
106
|
+
terminalSource?: PlayRunLedgerEventSource | null;
|
|
91
107
|
};
|
|
92
108
|
|
|
93
109
|
type PlayRunLedgerBaseEvent = {
|
|
@@ -406,6 +422,85 @@ export function normalizePlayRunLedgerSnapshot(
|
|
|
406
422
|
resultTableNamespace: optionalNullableString(value.resultTableNamespace),
|
|
407
423
|
resultSummary: value.resultSummary,
|
|
408
424
|
result: value.result,
|
|
425
|
+
terminalSource: normalizePlayRunLedgerTerminalSource(value.terminalSource),
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Terminal-source transition for a (possibly repeated) terminal event.
|
|
431
|
+
* A transport heal ('coordinator') never overwrites an already-recorded
|
|
432
|
+
* authoritative source: when the producer's own terminal has landed, a late
|
|
433
|
+
* heal replay must not demote the snapshot back to provisional. Any
|
|
434
|
+
* authoritative source (worker/temporal/system/convex) always wins, so the
|
|
435
|
+
* worker's post-heal `run.completed` flips a healed snapshot to final.
|
|
436
|
+
*/
|
|
437
|
+
function nextTerminalSource(
|
|
438
|
+
base: PlayRunLedgerSnapshot,
|
|
439
|
+
eventSource: PlayRunLedgerEventSource,
|
|
440
|
+
): PlayRunLedgerEventSource {
|
|
441
|
+
return nextPlayRunLedgerTerminalSource({
|
|
442
|
+
currentSource: base.terminalSource,
|
|
443
|
+
eventSource,
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function shouldUpgradeFromCoordinatorTerminal(
|
|
448
|
+
base: PlayRunLedgerSnapshot,
|
|
449
|
+
eventSource: PlayRunLedgerEventSource,
|
|
450
|
+
): boolean {
|
|
451
|
+
return (
|
|
452
|
+
base.terminalSource === 'coordinator' &&
|
|
453
|
+
isAuthoritativePlayRunTerminalSource(eventSource)
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
function shouldIgnoreNonTerminalAfterStickyTerminal(
|
|
458
|
+
base: PlayRunLedgerSnapshot,
|
|
459
|
+
): boolean {
|
|
460
|
+
return isTerminalPlayRunLedgerStatus(base.status);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
function maxProgressNumber(
|
|
464
|
+
current: number | undefined,
|
|
465
|
+
next: number | undefined,
|
|
466
|
+
): number | undefined {
|
|
467
|
+
if (current === undefined) return next;
|
|
468
|
+
if (next === undefined) return current;
|
|
469
|
+
return Math.max(current, next);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function mergeMonotonicStepProgress(input: {
|
|
473
|
+
current?: PlayRunLedgerStepProgress | null;
|
|
474
|
+
next: PlayRunLedgerStepProgress;
|
|
475
|
+
}): PlayRunLedgerStepProgress {
|
|
476
|
+
const current = input.current ?? {};
|
|
477
|
+
const next = input.next;
|
|
478
|
+
return {
|
|
479
|
+
...current,
|
|
480
|
+
...next,
|
|
481
|
+
...(maxProgressNumber(current.completed, next.completed) !== undefined
|
|
482
|
+
? { completed: maxProgressNumber(current.completed, next.completed) }
|
|
483
|
+
: {}),
|
|
484
|
+
...(maxProgressNumber(current.total, next.total) !== undefined
|
|
485
|
+
? { total: maxProgressNumber(current.total, next.total) }
|
|
486
|
+
: {}),
|
|
487
|
+
...(maxProgressNumber(current.failed, next.failed) !== undefined
|
|
488
|
+
? { failed: maxProgressNumber(current.failed, next.failed) }
|
|
489
|
+
: {}),
|
|
490
|
+
...(maxProgressNumber(current.startedRows, next.startedRows) !== undefined
|
|
491
|
+
? {
|
|
492
|
+
startedRows: maxProgressNumber(current.startedRows, next.startedRows),
|
|
493
|
+
}
|
|
494
|
+
: {}),
|
|
495
|
+
...(maxProgressNumber(current.completedRows, next.completedRows) !==
|
|
496
|
+
undefined
|
|
497
|
+
? {
|
|
498
|
+
completedRows: maxProgressNumber(
|
|
499
|
+
current.completedRows,
|
|
500
|
+
next.completedRows,
|
|
501
|
+
),
|
|
502
|
+
}
|
|
503
|
+
: {}),
|
|
409
504
|
};
|
|
410
505
|
}
|
|
411
506
|
|
|
@@ -601,12 +696,28 @@ function conflictingTerminalSnapshot(
|
|
|
601
696
|
eventType: keyof typeof TERMINAL_STATUS_BY_EVENT_TYPE,
|
|
602
697
|
occurredAt: number,
|
|
603
698
|
eventError?: string | null,
|
|
604
|
-
options?: {
|
|
699
|
+
options?: {
|
|
700
|
+
allowStaleSameStatusPayloadMerge?: boolean;
|
|
701
|
+
allowCoordinatorTerminalUpgrade?: boolean;
|
|
702
|
+
},
|
|
605
703
|
): PlayRunLedgerSnapshot | null {
|
|
606
704
|
if (!isTerminalPlayRunLedgerStatus(base.status)) {
|
|
607
705
|
return null;
|
|
608
706
|
}
|
|
609
707
|
const terminalAt = base.finishedAt ?? base.updatedAt ?? 0;
|
|
708
|
+
if (base.status === 'cancelled' && eventType !== 'run.cancelled') {
|
|
709
|
+
if (occurredAt <= terminalAt) {
|
|
710
|
+
return withTiming(
|
|
711
|
+
appendLogLines(base, [
|
|
712
|
+
`[ledger] stale conflicting terminal event ${eventType} ignored; status already ${base.status}`,
|
|
713
|
+
]),
|
|
714
|
+
);
|
|
715
|
+
}
|
|
716
|
+
return withTiming(base);
|
|
717
|
+
}
|
|
718
|
+
if (options?.allowCoordinatorTerminalUpgrade === true) {
|
|
719
|
+
return null;
|
|
720
|
+
}
|
|
610
721
|
if (
|
|
611
722
|
base.status === 'completed' &&
|
|
612
723
|
eventType === 'run.failed' &&
|
|
@@ -727,9 +838,15 @@ export function reducePlayRunLedgerEvent(
|
|
|
727
838
|
...snapshot,
|
|
728
839
|
updatedAt: Math.max(snapshot.updatedAt ?? 0, occurredAt),
|
|
729
840
|
};
|
|
841
|
+
const ignoreNonTerminalAfterStickyTerminal =
|
|
842
|
+
(event.type === 'run.created' || event.type === 'run.started') &&
|
|
843
|
+
shouldIgnoreNonTerminalAfterStickyTerminal(base);
|
|
730
844
|
|
|
731
845
|
switch (event.type) {
|
|
732
846
|
case 'run.created': {
|
|
847
|
+
if (ignoreNonTerminalAfterStickyTerminal) {
|
|
848
|
+
return withTiming(base);
|
|
849
|
+
}
|
|
733
850
|
const createdStatus = event.status ?? base.status;
|
|
734
851
|
return withTiming({
|
|
735
852
|
...base,
|
|
@@ -742,6 +859,9 @@ export function reducePlayRunLedgerEvent(
|
|
|
742
859
|
});
|
|
743
860
|
}
|
|
744
861
|
case 'run.started':
|
|
862
|
+
if (ignoreNonTerminalAfterStickyTerminal) {
|
|
863
|
+
return withTiming(base);
|
|
864
|
+
}
|
|
745
865
|
return withTiming({
|
|
746
866
|
...base,
|
|
747
867
|
playName: event.playName ?? base.playName ?? null,
|
|
@@ -753,7 +873,12 @@ export function reducePlayRunLedgerEvent(
|
|
|
753
873
|
case 'run.completed':
|
|
754
874
|
return (
|
|
755
875
|
conflictingTerminalSnapshot(base, event.type, occurredAt, null, {
|
|
876
|
+
allowCoordinatorTerminalUpgrade: shouldUpgradeFromCoordinatorTerminal(
|
|
877
|
+
base,
|
|
878
|
+
event.source,
|
|
879
|
+
),
|
|
756
880
|
allowStaleSameStatusPayloadMerge:
|
|
881
|
+
shouldUpgradeFromCoordinatorTerminal(base, event.source) ||
|
|
757
882
|
(base.result === undefined && event.result !== undefined) ||
|
|
758
883
|
(base.resultSummary === undefined &&
|
|
759
884
|
event.resultSummary !== undefined),
|
|
@@ -768,6 +893,7 @@ export function reducePlayRunLedgerEvent(
|
|
|
768
893
|
activeArtifactTableNamespace: null,
|
|
769
894
|
result: event.result ?? base.result,
|
|
770
895
|
resultSummary: event.resultSummary ?? base.resultSummary,
|
|
896
|
+
terminalSource: nextTerminalSource(base, event.source),
|
|
771
897
|
})
|
|
772
898
|
);
|
|
773
899
|
case 'run.failed':
|
|
@@ -775,6 +901,7 @@ export function reducePlayRunLedgerEvent(
|
|
|
775
901
|
retryablePlatformDeployFailureSnapshot(base, event.error) ??
|
|
776
902
|
conflictingTerminalSnapshot(base, event.type, occurredAt, event.error, {
|
|
777
903
|
allowStaleSameStatusPayloadMerge:
|
|
904
|
+
shouldUpgradeFromCoordinatorTerminal(base, event.source) ||
|
|
778
905
|
(base.error == null && event.error != null) ||
|
|
779
906
|
(base.result === undefined && event.result !== undefined),
|
|
780
907
|
}) ??
|
|
@@ -790,12 +917,14 @@ export function reducePlayRunLedgerEvent(
|
|
|
790
917
|
activeStepId: null,
|
|
791
918
|
activeArtifactTableNamespace: null,
|
|
792
919
|
result: event.result ?? base.result,
|
|
920
|
+
terminalSource: nextTerminalSource(base, event.source),
|
|
793
921
|
})
|
|
794
922
|
);
|
|
795
923
|
case 'run.cancelled':
|
|
796
924
|
return (
|
|
797
925
|
conflictingTerminalSnapshot(base, event.type, occurredAt, event.error, {
|
|
798
926
|
allowStaleSameStatusPayloadMerge:
|
|
927
|
+
shouldUpgradeFromCoordinatorTerminal(base, event.source) ||
|
|
799
928
|
(base.error == null && event.error != null) ||
|
|
800
929
|
(base.result === undefined && event.result !== undefined),
|
|
801
930
|
}) ??
|
|
@@ -811,6 +940,7 @@ export function reducePlayRunLedgerEvent(
|
|
|
811
940
|
activeStepId: null,
|
|
812
941
|
activeArtifactTableNamespace: null,
|
|
813
942
|
result: event.result ?? base.result,
|
|
943
|
+
terminalSource: nextTerminalSource(base, event.source),
|
|
814
944
|
})
|
|
815
945
|
);
|
|
816
946
|
case 'log.appended':
|
|
@@ -824,6 +954,7 @@ export function reducePlayRunLedgerEvent(
|
|
|
824
954
|
);
|
|
825
955
|
case 'step.started': {
|
|
826
956
|
const current = base.stepsById[event.stepId];
|
|
957
|
+
const runTerminal = isTerminalPlayRunLedgerStatus(base.status);
|
|
827
958
|
const shouldRefineSyntheticStart =
|
|
828
959
|
current?.startedAt != null &&
|
|
829
960
|
current.completedAt != null &&
|
|
@@ -855,19 +986,26 @@ export function reducePlayRunLedgerEvent(
|
|
|
855
986
|
startedAt: base.startedAt ?? occurredAt,
|
|
856
987
|
orderedStepIds: appendOrderedStepId(base, event.stepId),
|
|
857
988
|
stepsById: { ...base.stepsById, [event.stepId]: nextStep },
|
|
858
|
-
activeStepId:
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
989
|
+
activeStepId: runTerminal
|
|
990
|
+
? base.activeStepId
|
|
991
|
+
: nextStep.status === 'running'
|
|
992
|
+
? event.stepId
|
|
993
|
+
: base.activeStepId,
|
|
994
|
+
activeArtifactTableNamespace: runTerminal
|
|
995
|
+
? (base.activeArtifactTableNamespace ?? null)
|
|
996
|
+
: nextStep.status === 'running'
|
|
862
997
|
? (nextStep.artifactTableNamespace ?? null)
|
|
863
998
|
: (base.activeArtifactTableNamespace ?? null),
|
|
864
999
|
});
|
|
865
1000
|
}
|
|
866
1001
|
case 'step.progress': {
|
|
867
1002
|
const current = base.stepsById[event.stepId];
|
|
1003
|
+
const runTerminal = isTerminalPlayRunLedgerStatus(base.status);
|
|
868
1004
|
const progress = {
|
|
869
|
-
...(
|
|
870
|
-
|
|
1005
|
+
...mergeMonotonicStepProgress({
|
|
1006
|
+
current: current?.progress,
|
|
1007
|
+
next: event.progress,
|
|
1008
|
+
}),
|
|
871
1009
|
updatedAt: event.progress.updatedAt ?? occurredAt,
|
|
872
1010
|
};
|
|
873
1011
|
const inferredStatus =
|
|
@@ -924,14 +1062,16 @@ export function reducePlayRunLedgerEvent(
|
|
|
924
1062
|
...base,
|
|
925
1063
|
orderedStepIds: appendOrderedStepId(base, event.stepId),
|
|
926
1064
|
stepsById: { ...base.stepsById, [event.stepId]: nextStep },
|
|
927
|
-
activeStepId:
|
|
928
|
-
|
|
1065
|
+
activeStepId: runTerminal
|
|
1066
|
+
? base.activeStepId
|
|
1067
|
+
: status === 'running'
|
|
929
1068
|
? event.stepId
|
|
930
1069
|
: base.activeStepId === event.stepId
|
|
931
1070
|
? null
|
|
932
1071
|
: base.activeStepId,
|
|
933
|
-
activeArtifactTableNamespace:
|
|
934
|
-
|
|
1072
|
+
activeArtifactTableNamespace: runTerminal
|
|
1073
|
+
? (base.activeArtifactTableNamespace ?? null)
|
|
1074
|
+
: status === 'running'
|
|
935
1075
|
? (nextStep.artifactTableNamespace ?? null)
|
|
936
1076
|
: base.activeStepId === event.stepId
|
|
937
1077
|
? null
|
|
@@ -942,6 +1082,7 @@ export function reducePlayRunLedgerEvent(
|
|
|
942
1082
|
case 'step.failed':
|
|
943
1083
|
case 'step.skipped': {
|
|
944
1084
|
const current = base.stepsById[event.stepId];
|
|
1085
|
+
const runTerminal = isTerminalPlayRunLedgerStatus(base.status);
|
|
945
1086
|
const preserveFailedStatus =
|
|
946
1087
|
current?.status === 'failed' && event.type !== 'step.failed';
|
|
947
1088
|
const status = preserveFailedStatus
|
|
@@ -983,10 +1124,12 @@ export function reducePlayRunLedgerEvent(
|
|
|
983
1124
|
...base,
|
|
984
1125
|
orderedStepIds: appendOrderedStepId(base, event.stepId),
|
|
985
1126
|
stepsById: { ...base.stepsById, [event.stepId]: nextStep },
|
|
986
|
-
activeStepId,
|
|
987
|
-
activeArtifactTableNamespace:
|
|
988
|
-
? (base.
|
|
989
|
-
:
|
|
1127
|
+
activeStepId: runTerminal ? base.activeStepId : activeStepId,
|
|
1128
|
+
activeArtifactTableNamespace: runTerminal
|
|
1129
|
+
? (base.activeArtifactTableNamespace ?? null)
|
|
1130
|
+
: activeStepId
|
|
1131
|
+
? (base.stepsById[activeStepId]?.artifactTableNamespace ?? null)
|
|
1132
|
+
: null,
|
|
990
1133
|
});
|
|
991
1134
|
}
|
|
992
1135
|
case 'sheet.summary.updated':
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { PlayRunLedgerEventSource } from './run-ledger';
|
|
2
|
+
|
|
3
|
+
const PLAY_RUN_LEDGER_EVENT_SOURCES: readonly PlayRunLedgerEventSource[] = [
|
|
4
|
+
'worker',
|
|
5
|
+
'temporal',
|
|
6
|
+
'convex',
|
|
7
|
+
'coordinator',
|
|
8
|
+
'system',
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Run terminal source state machine.
|
|
13
|
+
*
|
|
14
|
+
* Coordinator terminals are transport heals from a live cache and stay
|
|
15
|
+
* provisional. Producer terminals are authoritative and must win over heals.
|
|
16
|
+
*/
|
|
17
|
+
export function normalizePlayRunLedgerTerminalSource(
|
|
18
|
+
value: unknown,
|
|
19
|
+
): PlayRunLedgerEventSource | null {
|
|
20
|
+
return PLAY_RUN_LEDGER_EVENT_SOURCES.includes(
|
|
21
|
+
value as PlayRunLedgerEventSource,
|
|
22
|
+
)
|
|
23
|
+
? (value as PlayRunLedgerEventSource)
|
|
24
|
+
: null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function isAuthoritativePlayRunTerminalSource(
|
|
28
|
+
value: unknown,
|
|
29
|
+
): value is Exclude<PlayRunLedgerEventSource, 'coordinator'> {
|
|
30
|
+
const source = normalizePlayRunLedgerTerminalSource(value);
|
|
31
|
+
return source !== null && source !== 'coordinator';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function nextPlayRunLedgerTerminalSource(input: {
|
|
35
|
+
currentSource: unknown;
|
|
36
|
+
eventSource: PlayRunLedgerEventSource;
|
|
37
|
+
}): PlayRunLedgerEventSource {
|
|
38
|
+
if (input.eventSource !== 'coordinator') {
|
|
39
|
+
return input.eventSource;
|
|
40
|
+
}
|
|
41
|
+
const current = normalizePlayRunLedgerTerminalSource(input.currentSource);
|
|
42
|
+
return isAuthoritativePlayRunTerminalSource(current)
|
|
43
|
+
? current
|
|
44
|
+
: 'coordinator';
|
|
45
|
+
}
|
|
@@ -101,6 +101,7 @@ export type RuntimeReceiptAction =
|
|
|
101
101
|
key: string;
|
|
102
102
|
reclaimRunning?: boolean;
|
|
103
103
|
forceRefresh?: boolean;
|
|
104
|
+
forceFailedRefresh?: boolean;
|
|
104
105
|
}
|
|
105
106
|
| {
|
|
106
107
|
action: 'complete_runtime_step_receipt';
|
|
@@ -109,6 +110,14 @@ export type RuntimeReceiptAction =
|
|
|
109
110
|
key: string;
|
|
110
111
|
output: unknown;
|
|
111
112
|
}
|
|
113
|
+
| {
|
|
114
|
+
action: 'release_runtime_step_receipt';
|
|
115
|
+
playName: string;
|
|
116
|
+
runId: string;
|
|
117
|
+
key: string;
|
|
118
|
+
runAttempt?: number;
|
|
119
|
+
leaseId?: string | null;
|
|
120
|
+
}
|
|
112
121
|
| {
|
|
113
122
|
action: 'fail_runtime_step_receipt';
|
|
114
123
|
playName: string;
|