deepline 0.3.502 → 0.3.504
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/sdk/src/client-core.ts +26 -0
- package/dist/bundling-sources/sdk/src/index.ts +1 -0
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/types.ts +9 -0
- package/dist/bundling-sources/shared_libs/monitors/http-error-response.ts +35 -0
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +1 -1
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-public-aliases.ts +13 -0
- package/dist/bundling-sources/shared_libs/monitors/starter-templates.ts +0 -8
- package/dist/bundling-sources/shared_libs/observability/dlq.ts +174 -0
- package/dist/bundling-sources/shared_libs/observability/queue-health.ts +9 -0
- package/dist/bundling-sources/shared_libs/observability/queue-item-connectors.ts +1 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +18 -0
- package/dist/bundling-sources/shared_libs/play-runtime/activity-observation.ts +20 -0
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +62 -2
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +667 -62
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +55 -0
- package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +20 -2
- package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +46 -0
- package/dist/bundling-sources/shared_libs/play-runtime/execution-gateway-invocation-fence.ts +80 -4
- package/dist/bundling-sources/shared_libs/play-runtime/fixture-egress-fetch.ts +95 -0
- package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +292 -45
- package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +15 -0
- package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +3 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-http-request.ts +7 -3
- package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-semantics.ts +31 -1
- package/dist/bundling-sources/shared_libs/play-runtime/post-code-recovery-policy.ts +231 -0
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +4 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-ending-event.ts +55 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +126 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +38 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-launch-transport.ts +2 -9
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +51 -19
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/local-process.ts +9 -4
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/runtime-sandbox-reconciliation.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-actions.ts +12 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +3 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-incident-drills.ts +42 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +7 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-store-adapter.ts +26 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +13 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-deadline-reconciliation.ts +53 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +631 -19
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/durable-run-inventory.ts +719 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/durable-run-sql.ts +206 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/latest-cache-result.ts +83 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +1432 -157
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-gateway.ts +61 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +29 -8
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-queue-health.ts +27 -2
- package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +45 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-cache-policy.ts +18 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +129 -14
- package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +2 -0
- package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +10 -1
- package/dist/cli/{auth-EFHLOVG4.mjs → auth-3L5AA5AX.mjs} +5 -5
- package/dist/cli/auth-UPK4IIIN.js +43 -0
- package/dist/cli/{billing-Q5XKEYPP.mjs → billing-E7EASVPO.mjs} +19 -12
- package/dist/cli/{billing-SKT2VE34.js → billing-HOGXVE2V.js} +92 -85
- package/dist/cli/{chunk-L5CTJY74.mjs → chunk-22OCKCYS.mjs} +2 -2
- package/dist/cli/{chunk-YWOQYYYS.mjs → chunk-2ABRDH3B.mjs} +2 -2
- package/dist/cli/{chunk-IL666WJE.js → chunk-2W77YCKH.js} +5 -5
- package/dist/cli/{chunk-2MVIS2UI.mjs → chunk-3MLFFWDM.mjs} +2 -2
- package/dist/cli/{chunk-HMZF2CSP.mjs → chunk-4CC67XH5.mjs} +2 -2
- package/dist/cli/{chunk-NXVYLX3F.mjs → chunk-5CHBIJIM.mjs} +10 -6
- package/dist/cli/chunk-5LUF4LAR.mjs +209 -0
- package/dist/cli/{chunk-JL6H4H3G.js → chunk-5Z6EULD5.js} +6 -6
- package/dist/cli/{chunk-32YQBJON.js → chunk-67OI26OE.js} +7 -7
- package/dist/cli/{chunk-LA3UYRVZ.js → chunk-6JNBMTCZ.js} +1 -1
- package/dist/cli/{chunk-DYHTXGLX.js → chunk-6SMR7LU7.js} +2 -2
- package/dist/cli/{chunk-OFBLT2LQ.mjs → chunk-7F4OEHQK.mjs} +1 -1
- package/dist/cli/{chunk-DRBD4IYQ.mjs → chunk-7MJYZ33I.mjs} +2 -6
- package/dist/cli/{chunk-UOANF3DR.js → chunk-7P2QVMBP.js} +26 -7
- package/dist/cli/{chunk-GINKIZ7S.js → chunk-A6LA42JY.js} +16 -16
- package/dist/cli/{chunk-FVM4PS5Q.js → chunk-BN5VKY4X.js} +25 -12
- package/dist/cli/{chunk-Z2H7OQ6E.mjs → chunk-BTWUNKKX.mjs} +2 -2
- package/dist/cli/{chunk-R5F7JXT4.mjs → chunk-BX45XMXZ.mjs} +2 -2
- package/dist/cli/{chunk-NKLM4J4X.mjs → chunk-DEAJVQEG.mjs} +1 -1
- package/dist/cli/{chunk-JFBJLNBI.js → chunk-FISP4LCK.js} +53 -53
- package/dist/cli/{chunk-OEUMXKR5.js → chunk-FTRVCIGC.js} +26 -26
- package/dist/cli/{chunk-YL2CCF6T.mjs → chunk-GGBXNQCR.mjs} +4 -4
- package/dist/cli/{chunk-YPTZJ7LO.js → chunk-GJ2DA35C.js} +100 -17
- package/dist/cli/{chunk-2S2F6YSI.js → chunk-GRAGUYIE.js} +41 -41
- package/dist/cli/{chunk-2JS3H6H6.mjs → chunk-HUX5DZO6.mjs} +3 -3
- package/dist/cli/{chunk-4CCMD7QM.mjs → chunk-IGNQKOWT.mjs} +32 -15
- package/dist/cli/{chunk-WKFAX2K7.js → chunk-IPAMOMGP.js} +21 -21
- package/dist/cli/{chunk-SAW3FBCA.mjs → chunk-ITJ7NB2D.mjs} +6 -0
- package/dist/cli/{chunk-Q3NM6ZL3.js → chunk-JPR2546F.js} +23 -21
- package/dist/cli/{chunk-X5MGQ7UT.js → chunk-KCKAFTPY.js} +10 -10
- package/dist/cli/{chunk-TAK3MVXY.js → chunk-KGUGNEKL.js} +284 -267
- package/dist/cli/{chunk-OVZOMSH2.js → chunk-LHXYCZYO.js} +8 -8
- package/dist/cli/{chunk-QOJBRCAS.js → chunk-MJTK6Q3G.js} +3 -3
- package/dist/cli/{chunk-MYUISF3P.mjs → chunk-MLMWM5DV.mjs} +5 -5
- package/dist/cli/{chunk-JO5FFSR7.js → chunk-NTLBZUHD.js} +6 -0
- package/dist/cli/{chunk-MP5QY4A2.mjs → chunk-NZ7Z7WNM.mjs} +2 -2
- package/dist/cli/{chunk-HIVRCTDR.mjs → chunk-OX2D6BG4.mjs} +20 -1
- package/dist/cli/{chunk-YDXEXVBV.js → chunk-QKKU2FH4.js} +7 -7
- package/dist/cli/{chunk-3KEZVGGV.mjs → chunk-QOLX2O2S.mjs} +4 -4
- package/dist/cli/{chunk-JFUXUSKB.mjs → chunk-R2VZVHJP.mjs} +15 -2
- package/dist/cli/chunk-R7J7CJPZ.js +209 -0
- package/dist/cli/{chunk-XMKUJ44Z.js → chunk-SMSQVRHE.js} +5 -5
- package/dist/cli/{chunk-54QXWK3C.mjs → chunk-SVFTZTCI.mjs} +1 -1
- package/dist/cli/{chunk-FWDAEWCD.js → chunk-TMQUMILM.js} +19 -23
- package/dist/cli/{chunk-TFFJ2PRN.mjs → chunk-UFYJTRSF.mjs} +98 -15
- package/dist/cli/{chunk-EUWRKWT4.js → chunk-UJMBG5JU.js} +5 -4
- package/dist/cli/{chunk-DKAMCJIT.js → chunk-USTJEEND.js} +17 -13
- package/dist/cli/{chunk-AJL2Q6IQ.js → chunk-UXQQPMYO.js} +2 -2
- package/dist/cli/{chunk-7ZYSXSJJ.mjs → chunk-VJVJWZ6I.mjs} +5 -5
- package/dist/cli/{chunk-JLYDLK6X.js → chunk-WBIDPDKJ.js} +3 -3
- package/dist/cli/{chunk-QNELA7SX.js → chunk-WZSFIJMG.js} +53 -53
- package/dist/cli/{chunk-NZXB27TP.mjs → chunk-XHZSPMNC.mjs} +4 -4
- package/dist/cli/{chunk-W5CHE5Q2.mjs → chunk-Y6XKCEPK.mjs} +1 -1
- package/dist/cli/{chunk-4WTC5SSN.mjs → chunk-Y7VEHKID.mjs} +10 -8
- package/dist/cli/{chunk-3MJSWVQ2.mjs → chunk-YOQ2NNDO.mjs} +2 -1
- package/dist/cli/{chunk-ZNB6GR3P.mjs → chunk-Z6FXUDIL.mjs} +1 -1
- package/dist/cli/command-docs.d.mts +2 -1
- package/dist/cli/command-docs.d.ts +2 -1
- package/dist/cli/command-docs.js +6 -2
- package/dist/cli/command-docs.mjs +5 -1
- package/dist/cli/{csv-OXGSCV75.js → csv-2XWGPITO.js} +13 -13
- package/dist/cli/{csv-6AEPKKCO.mjs → csv-433JEHLQ.mjs} +4 -4
- package/dist/cli/{db-K3KRK4CZ.mjs → db-K747DH43.mjs} +6 -6
- package/dist/cli/{db-6NVHDUZY.js → db-PJJMD4VH.js} +27 -27
- package/dist/cli/describe-OYS7LZJD.js +49 -0
- package/dist/cli/{describe-P3ZJS7TQ.mjs → describe-VEDDYW4P.mjs} +20 -20
- package/dist/cli/describe-core.d.mts +8 -4
- package/dist/cli/describe-core.d.ts +8 -4
- package/dist/cli/describe-core.js +4 -4
- package/dist/cli/describe-core.mjs +3 -3
- package/dist/cli/{executions-2C2FFG52.js → executions-HM5T72H6.js} +8 -8
- package/dist/cli/{executions-I7XW6WWK.mjs → executions-JWRX3XCT.mjs} +6 -6
- package/dist/cli/{feedback-47B57A5Y.js → feedback-34UG4BO3.js} +8 -8
- package/dist/cli/{feedback-RSTNBJAI.mjs → feedback-MNSIA63Y.mjs} +4 -4
- package/dist/cli/git-5YQJSJFR.js +25 -0
- package/dist/cli/{git-3G5AFKBT.mjs → git-ZKEOXV3A.mjs} +5 -5
- package/dist/cli/index.js +144 -142
- package/dist/cli/index.mjs +44 -42
- package/dist/cli/{legacy-noops-NQ262TKL.mjs → legacy-noops-5M4T4ZVT.mjs} +5 -5
- package/dist/cli/{legacy-noops-P665PBG4.js → legacy-noops-YXSI4FVU.js} +8 -8
- package/dist/cli/{monitors-KUPZODZS.mjs → monitors-C65OC4AW.mjs} +7 -7
- package/dist/cli/{monitors-IPWAD7LS.js → monitors-O25GDOYE.js} +95 -95
- package/dist/cli/{org-WFC3N672.js → org-2GSPLY2A.js} +72 -72
- package/dist/cli/{org-ZCQGEM3L.mjs → org-ZRMG5NS2.mjs} +6 -6
- package/dist/cli/{pages-N5BNC67L.js → pages-45DPADK6.js} +18 -18
- package/dist/cli/{pages-VE66IU7B.mjs → pages-TZZUFBRO.mjs} +6 -6
- package/dist/cli/{play-EIMDIAJB.mjs → play-3D7HH273.mjs} +138 -226
- package/dist/cli/{play-NKIRJSKX.js → play-RCGMND6X.js} +454 -542
- package/dist/cli/{providers-XU3AGY2F.js → providers-3N3ECMTY.js} +9 -9
- package/dist/cli/{providers-KDTJ63ED.mjs → providers-PSAKV6CJ.mjs} +6 -6
- package/dist/cli/{quickstart-TXFXUODF.mjs → quickstart-2A35SMGC.mjs} +4 -4
- package/dist/cli/{quickstart-OSCHOSXU.js → quickstart-6R6AIXM6.js} +6 -6
- package/dist/cli/{run-ODGML35U.mjs → run-F3TLDGUO.mjs} +25 -25
- package/dist/cli/{run-ET2KVTPK.js → run-F6ZXTASZ.js} +44 -44
- package/dist/cli/{search-DK67K6PR.mjs → search-CZLCY3D2.mjs} +7 -7
- package/dist/cli/search-R5VEWJO2.js +32 -0
- package/dist/cli/{search-output-6SOKQTCW.mjs → search-output-MQTSTLN5.mjs} +5 -5
- package/dist/cli/{search-output-KXP4FA62.js → search-output-R5XDNILW.js} +7 -7
- package/dist/cli/{secrets-C6SYTMU7.mjs → secrets-D3GF4B2Z.mjs} +6 -6
- package/dist/cli/{secrets-WPS6NMNK.js → secrets-DCJYHDSY.js} +15 -15
- package/dist/cli/{sessions-PXVOH34X.mjs → sessions-QGEQ2UYZ.mjs} +5 -5
- package/dist/cli/{sessions-IP562J5Z.js → sessions-Z4JYJSDP.js} +6 -6
- package/dist/cli/{settings-FBUQGYVJ.mjs → settings-G7QEXA4N.mjs} +11 -11
- package/dist/cli/{settings-SUDUIVMY.js → settings-UVXXAT4A.js} +78 -78
- package/dist/cli/{setup-I5H6IOEY.js → setup-5I42W7D4.js} +49 -49
- package/dist/cli/{setup-JSIMTR73.mjs → setup-QHJU3DUI.mjs} +9 -9
- package/dist/cli/{skills-FJQ3LX6N.mjs → skills-5LRF4UKX.mjs} +7 -7
- package/dist/cli/skills-FB6TV52O.js +36 -0
- package/dist/cli/tools-L2364RPA.js +56 -0
- package/dist/cli/{tools-IGBK4BVE.mjs → tools-PUT6STVG.mjs} +18 -18
- package/dist/cli/{update-7MTT6F5K.mjs → update-CJ2GA64X.mjs} +9 -9
- package/dist/cli/update-ESYJGYVZ.js +34 -0
- package/dist/cli/{workflow-PM2J2OU3.mjs → workflow-HVEWRTXD.mjs} +7 -7
- package/dist/cli/{workflow-UX3ZX6BQ.js → workflow-O67MEBCP.js} +17 -17
- package/dist/{client-Bn8FwKGO.d.ts → client-CIwenMFS.d.ts} +1 -1
- package/dist/{client-CfNRmjLK.d.mts → client-DYAfJpaN.d.mts} +1 -1
- package/dist/{client-core-B91EV0WS.d.ts → client-core-CRjtyMAI.d.ts} +25 -2
- package/dist/{client-core-BG8Cgrmk.d.mts → client-core-DlzP8vEs.d.mts} +25 -2
- package/dist/{compiler-manifest-DlXDyndN.d.mts → compiler-manifest-DaJrA2KV.d.mts} +1 -1
- package/dist/{compiler-manifest-DlXDyndN.d.ts → compiler-manifest-DaJrA2KV.d.ts} +1 -1
- package/dist/{errors-BtriA2ld.d.mts → errors-BKnSYueU.d.mts} +1 -1
- package/dist/{errors-DmcLykM7.d.ts → errors-KLga4bLr.d.ts} +1 -1
- package/dist/{index-DI0sR_fX.d.mts → index-C-8AFpWy.d.mts} +1 -1
- package/dist/{index--Jw-slHY.d.ts → index-C5nAZ-VS.d.ts} +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +9 -9
- package/dist/index.mjs +6 -6
- package/dist/install-integrity.json +125 -116
- package/dist/plays/bundle-play-file.d.mts +3 -3
- package/dist/plays/bundle-play-file.d.ts +3 -3
- package/dist/plays/bundle-play-file.mjs +12 -5
- package/dist/plays/play-description.d.mts +2 -2
- package/dist/plays/play-description.d.ts +2 -2
- package/dist/plays/run-request.d.mts +2 -2
- package/dist/plays/run-request.d.ts +2 -2
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +5 -5
- package/dist/server.mjs +3 -3
- package/package.json +1 -1
- package/dist/cli/auth-VM3IKP5F.js +0 -43
- package/dist/cli/describe-JOUAXXPE.js +0 -49
- package/dist/cli/git-OPKIC6JQ.js +0 -25
- package/dist/cli/search-6U54Y3OK.js +0 -32
- package/dist/cli/skills-VHININXC.js +0 -36
- package/dist/cli/tools-XMBMHVKF.js +0 -56
- package/dist/cli/update-H7JVW43I.js +0 -34
package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isImmutableRuntimeExecutionRecoveryOrigin } from './runtime-api-origin';
|
|
1
2
|
import type { DaytonaDeleteRetryAuthorization } from '../runner-backends/backends/daytona-lifecycle';
|
|
2
3
|
/**
|
|
3
4
|
* `absurd` durable task handler + worker startup.
|
|
@@ -21,6 +22,11 @@ import type { DaytonaDeleteRetryAuthorization } from '../runner-backends/backend
|
|
|
21
22
|
* generation with a matching lease token writes terminals; a reclaimed or
|
|
22
23
|
* lease-lost handler observes `idle` and abandons WITHOUT writing a terminal.
|
|
23
24
|
*/
|
|
25
|
+
import {
|
|
26
|
+
computeBillingSessionId,
|
|
27
|
+
normalizeResumeEpoch,
|
|
28
|
+
runEndingEventId,
|
|
29
|
+
} from '../run-ending-event';
|
|
24
30
|
import { hostname } from 'node:os';
|
|
25
31
|
import { randomUUID } from 'node:crypto';
|
|
26
32
|
import { setTimeout as sleep } from 'node:timers/promises';
|
|
@@ -85,7 +91,10 @@ import type {
|
|
|
85
91
|
PlayRunnerExecutionConfig,
|
|
86
92
|
PlayRunnerResult,
|
|
87
93
|
} from '../protocol';
|
|
88
|
-
import {
|
|
94
|
+
import {
|
|
95
|
+
resolveRunnerHeartbeatSilenceMs,
|
|
96
|
+
resolveRunnerSandboxDeleteMs,
|
|
97
|
+
} from '../test-runtime-seams';
|
|
89
98
|
import {
|
|
90
99
|
RuntimeResourceFenceLostError,
|
|
91
100
|
type PlayRunnerRuntimeResource,
|
|
@@ -167,12 +176,19 @@ import {
|
|
|
167
176
|
claimPostgresSchedulerSignal,
|
|
168
177
|
cleanupPostgresSchedulerMaterializedFiles,
|
|
169
178
|
completePostgresSchedulerComputeBillingJob,
|
|
179
|
+
claimPostgresSchedulerComputeBillingReconciliation,
|
|
170
180
|
completePostgresSchedulerComputeBillingSessionBootstrap,
|
|
171
181
|
claimPostgresSchedulerWaitingDetachedAttemptForTerminal,
|
|
172
182
|
deferPostgresSchedulerAttemptForCapacity,
|
|
173
183
|
deferPostgresSchedulerAttemptForExecutorTokenOutage,
|
|
174
184
|
detachedRunnerCeilingDeadlineMsFromSuspension,
|
|
175
185
|
enqueuePostgresSchedulerSandboxCleanupForAttempt,
|
|
186
|
+
deferPostgresSchedulerAttemptForPostCodeRecovery,
|
|
187
|
+
getPostgresSchedulerReceipt,
|
|
188
|
+
hasPostgresSchedulerPostCodeRecoveryDeferral,
|
|
189
|
+
releasePostgresSchedulerReceiptsThroughAttempt,
|
|
190
|
+
hasPendingPostgresSchedulerSandboxDeletionThroughAttempt,
|
|
191
|
+
readPostgresSchedulerPostCodeRecoveryOpen,
|
|
176
192
|
enqueuePostgresSchedulerSandboxCleanupForRun,
|
|
177
193
|
hasPostgresSchedulerRecoverableDetachedRunner,
|
|
178
194
|
executePostgresSchedulerClaim,
|
|
@@ -250,6 +266,18 @@ import {
|
|
|
250
266
|
type PlayRunAttemptWorkerTerminalProjectionPort,
|
|
251
267
|
} from '../play-runs/attempts';
|
|
252
268
|
import { transitionPreCodePlayRunRecovery } from './play-run-recovery';
|
|
269
|
+
import { DURABLE_RUNS_ROLLOUT } from '../durable-runs-rollout';
|
|
270
|
+
import {
|
|
271
|
+
POST_CODE_RECOVERY_BUDGET,
|
|
272
|
+
classifyPostCodeAttemptOutcome,
|
|
273
|
+
platformRecoveryExhaustedMessage,
|
|
274
|
+
postCodeRecoveryDelayMs,
|
|
275
|
+
postCodeRecoveryRequiresSandboxDeletion,
|
|
276
|
+
replayTrackedMarkerReceiptKey,
|
|
277
|
+
replayUnsafeMarkerReceiptKey,
|
|
278
|
+
withoutWorkerEvidence,
|
|
279
|
+
type WorkerAttemptEvidence,
|
|
280
|
+
} from '../post-code-recovery-policy';
|
|
253
281
|
import {
|
|
254
282
|
acquirePostgresRateState,
|
|
255
283
|
penalizePostgresRateState,
|
|
@@ -1284,7 +1312,8 @@ export async function requestAttemptExecutorToken(input: {
|
|
|
1284
1312
|
}
|
|
1285
1313
|
if (
|
|
1286
1314
|
input.initializeComputeSession === true &&
|
|
1287
|
-
body.computeSessionInitialized?.sessionId ===
|
|
1315
|
+
body.computeSessionInitialized?.sessionId ===
|
|
1316
|
+
computeBillingSessionId(input.launch.runId, input.launch.resumeEpoch) &&
|
|
1288
1317
|
body.computeSessionInitialized.attempt === input.attempt
|
|
1289
1318
|
) {
|
|
1290
1319
|
input.onComputeSessionInitialized?.();
|
|
@@ -1476,11 +1505,69 @@ const detachedRunnerProvenGone = new WeakMap<
|
|
|
1476
1505
|
DetachedRunnerInspection | null
|
|
1477
1506
|
>();
|
|
1478
1507
|
|
|
1508
|
+
const testSandboxDeletesScheduled = new Set<string>();
|
|
1509
|
+
|
|
1510
|
+
/**
|
|
1511
|
+
* Test fault `runner_sandbox_delete_ms`: delete a parked runner's sandbox the
|
|
1512
|
+
* way a provider outage would, once per run, so a scenario can prove the
|
|
1513
|
+
* platform retries the same run. A run already retried for post-code
|
|
1514
|
+
* recovery is left alone, whichever worker parks it.
|
|
1515
|
+
*/
|
|
1516
|
+
function scheduleTestRunnerSandboxDelete(input: {
|
|
1517
|
+
runId: string;
|
|
1518
|
+
suspension: DetachedRunnerSuspension;
|
|
1519
|
+
delayMs: number;
|
|
1520
|
+
deps: Pick<
|
|
1521
|
+
AbsurdRuntimeWorkerDeps,
|
|
1522
|
+
'runWithClient' | 'deleteRuntimeSandboxRef'
|
|
1523
|
+
>;
|
|
1524
|
+
options: Pick<PostgresSchedulerOptions, 'schema'>;
|
|
1525
|
+
}): void {
|
|
1526
|
+
if (input.delayMs <= 0) return;
|
|
1527
|
+
const key = `${input.runId}:${input.suspension.runnerAttempt}`;
|
|
1528
|
+
if (testSandboxDeletesScheduled.has(key)) return;
|
|
1529
|
+
testSandboxDeletesScheduled.add(key);
|
|
1530
|
+
setTimeout(() => {
|
|
1531
|
+
void (async () => {
|
|
1532
|
+
const retried = await input.deps.runWithClient((client) =>
|
|
1533
|
+
hasPostgresSchedulerPostCodeRecoveryDeferral(
|
|
1534
|
+
client,
|
|
1535
|
+
{ runId: input.runId },
|
|
1536
|
+
input.options,
|
|
1537
|
+
),
|
|
1538
|
+
);
|
|
1539
|
+
if (retried) return;
|
|
1540
|
+
const deleteRef = input.deps.deleteRuntimeSandboxRef;
|
|
1541
|
+
if (!deleteRef) {
|
|
1542
|
+
throw new Error('This worker cannot delete sandboxes by reference.');
|
|
1543
|
+
}
|
|
1544
|
+
const outcome = await deleteRef(
|
|
1545
|
+
runtimeSandboxRefFromSuspension(input.suspension),
|
|
1546
|
+
);
|
|
1547
|
+
console.warn('[absurd-runtime.worker] test_fault_sandbox_deleted', {
|
|
1548
|
+
runId: input.runId,
|
|
1549
|
+
runnerAttempt: input.suspension.runnerAttempt,
|
|
1550
|
+
sandboxId: input.suspension.sandboxId,
|
|
1551
|
+
outcome: outcome.kind,
|
|
1552
|
+
});
|
|
1553
|
+
})().catch((error: unknown) => {
|
|
1554
|
+
console.error(
|
|
1555
|
+
'[absurd-runtime.worker] test_fault_sandbox_delete_failed',
|
|
1556
|
+
{
|
|
1557
|
+
runId: input.runId,
|
|
1558
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1559
|
+
},
|
|
1560
|
+
);
|
|
1561
|
+
});
|
|
1562
|
+
}, input.delayMs).unref?.();
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1479
1565
|
type DetachedRunnerInspection = {
|
|
1480
1566
|
exitCode: number | null;
|
|
1481
1567
|
result: PlayRunnerResult | null;
|
|
1482
1568
|
// Written by the runner, possibly an older build: readers default it.
|
|
1483
1569
|
diagnosis?: { stage: string; detail: string | null };
|
|
1570
|
+
providerReturnCode?: number | null;
|
|
1484
1571
|
};
|
|
1485
1572
|
|
|
1486
1573
|
/**
|
|
@@ -1526,6 +1613,8 @@ async function confirmDetachedRunnerSilence(input: {
|
|
|
1526
1613
|
suspension: DetachedRunnerSuspension,
|
|
1527
1614
|
) => Promise<DetachedRunnerInspection | null>;
|
|
1528
1615
|
suspension: DetachedRunnerSuspension;
|
|
1616
|
+
/** Trusted worker probe, run once per durable slice of the silence window. */
|
|
1617
|
+
probeControlPlaneOutage?: (stepName: string) => Promise<void>;
|
|
1529
1618
|
}): Promise<'responded' | 'gone' | 'ceiling'> {
|
|
1530
1619
|
if (!(await confirmSilenceWindow(input))) return 'responded';
|
|
1531
1620
|
if (Date.now() >= input.ceilingDeadlineMs) return 'ceiling';
|
|
@@ -1540,6 +1629,7 @@ async function confirmDetachedRunnerSilence(input: {
|
|
|
1540
1629
|
);
|
|
1541
1630
|
for (let round = 1; ; round += 1) {
|
|
1542
1631
|
const stepName = `${input.stepPrefix}:evidence:${round}`;
|
|
1632
|
+
await input.probeControlPlaneOutage?.(`${stepName}:outage`);
|
|
1543
1633
|
let inspected: DetachedRunnerInspection | null = null;
|
|
1544
1634
|
const gone = await input.ctx.step(`${stepName}:gone`, async () => {
|
|
1545
1635
|
// Deferred so a synchronous throw, such as an unreadable persisted
|
|
@@ -1595,6 +1685,7 @@ async function confirmSilenceWindow(input: {
|
|
|
1595
1685
|
cadenceMs: number;
|
|
1596
1686
|
ceilingDeadlineMs: number;
|
|
1597
1687
|
runnerResponded: () => Promise<boolean>;
|
|
1688
|
+
probeControlPlaneOutage?: (stepName: string) => Promise<void>;
|
|
1598
1689
|
}): Promise<boolean> {
|
|
1599
1690
|
const sliceMs = Math.floor(
|
|
1600
1691
|
input.cadenceMs / LIVENESS_CONFIRMATION_SLICES_PER_CADENCE,
|
|
@@ -1607,6 +1698,7 @@ async function confirmSilenceWindow(input: {
|
|
|
1607
1698
|
);
|
|
1608
1699
|
await input.ctx.sleepUntil(stepName, new Date(wakeAtMs));
|
|
1609
1700
|
if (await input.runnerResponded()) return false;
|
|
1701
|
+
await input.probeControlPlaneOutage?.(`${stepName}:outage`);
|
|
1610
1702
|
if (wakeAtMs >= input.ceilingDeadlineMs) return true;
|
|
1611
1703
|
const lateMs = await input.ctx.step(
|
|
1612
1704
|
`${stepName}:late`,
|
|
@@ -1650,6 +1742,13 @@ export async function parkAndResolveSuspension(input: {
|
|
|
1650
1742
|
inspectDetachedRunner?: (
|
|
1651
1743
|
suspension: DetachedRunnerSuspension,
|
|
1652
1744
|
) => Promise<DetachedRunnerInspection | null>;
|
|
1745
|
+
/**
|
|
1746
|
+
* Trusted worker probe for a platform outage (never sandbox output). While
|
|
1747
|
+
* a runner's heartbeat is lapsed, it runs inside each durable slice of the
|
|
1748
|
+
* silence window, so an outage that ends before the run resolves is still
|
|
1749
|
+
* on record, bound to the heartbeat it follows.
|
|
1750
|
+
*/
|
|
1751
|
+
observeControlPlaneOutage?: () => Promise<boolean>;
|
|
1653
1752
|
}): Promise<PlayCheckpoint> {
|
|
1654
1753
|
const { ctx, suspension, checkpoint, runId } = input;
|
|
1655
1754
|
|
|
@@ -1678,6 +1777,9 @@ export async function parkAndResolveSuspension(input: {
|
|
|
1678
1777
|
const heartbeatTimeoutMs = detachedRunnerHeartbeatTimeoutMs(suspension);
|
|
1679
1778
|
const ceilingDeadlineMs = suspension.startedAtMs + suspension.ceilingMs;
|
|
1680
1779
|
let silenceConfirmation: PlayCheckpoint['detachedRunnerSilenceConfirmation'];
|
|
1780
|
+
// Latest probe, in this park, that saw the platform down. Each probe is a
|
|
1781
|
+
// memoized step, so replay reproduces it.
|
|
1782
|
+
let outageObservedAtMs: number | null = null;
|
|
1681
1783
|
const readRunnerTerminal = input.readRunnerTerminal;
|
|
1682
1784
|
const readRunnerLiveness = input.readRunnerLiveness;
|
|
1683
1785
|
let rearms = 0;
|
|
@@ -1750,6 +1852,19 @@ export async function parkAndResolveSuspension(input: {
|
|
|
1750
1852
|
ceilingDeadlineMs,
|
|
1751
1853
|
inspectDetachedRunner: input.inspectDetachedRunner,
|
|
1752
1854
|
suspension,
|
|
1855
|
+
probeControlPlaneOutage:
|
|
1856
|
+
input.observeControlPlaneOutage
|
|
1857
|
+
? async (probeStepName) => {
|
|
1858
|
+
const observedAtMs = await ctx.step(
|
|
1859
|
+
`${suspension.boundaryId}:liveness-confirm-heartbeat:${renewed?.heartbeatIdentity ?? renewed?.heartbeatAt ?? 'none'}:${probeStepName}`,
|
|
1860
|
+
async () =>
|
|
1861
|
+
(await input.observeControlPlaneOutage?.())
|
|
1862
|
+
? Date.now()
|
|
1863
|
+
: 0,
|
|
1864
|
+
);
|
|
1865
|
+
if (observedAtMs > 0) outageObservedAtMs = observedAtMs;
|
|
1866
|
+
}
|
|
1867
|
+
: undefined,
|
|
1753
1868
|
runnerResponded: async () => {
|
|
1754
1869
|
// A wake replays every finished slice. One read per replay is enough.
|
|
1755
1870
|
if (Date.now() < quietUntilMs) return false;
|
|
@@ -1772,6 +1887,9 @@ export async function parkAndResolveSuspension(input: {
|
|
|
1772
1887
|
runnerAttempt: suspension.runnerAttempt,
|
|
1773
1888
|
heartbeatIdentity:
|
|
1774
1889
|
renewed?.heartbeatIdentity ?? renewed?.heartbeatAt ?? null,
|
|
1890
|
+
...(outageObservedAtMs === null
|
|
1891
|
+
? {}
|
|
1892
|
+
: { controlPlaneOutageObservedAtMs: outageObservedAtMs }),
|
|
1775
1893
|
};
|
|
1776
1894
|
}
|
|
1777
1895
|
break;
|
|
@@ -1885,6 +2003,7 @@ export function createAbsurdEngineSuspensionAdapter(input: {
|
|
|
1885
2003
|
inspectDetachedRunner?: (
|
|
1886
2004
|
suspension: DetachedRunnerSuspension,
|
|
1887
2005
|
) => Promise<DetachedRunnerInspection | null>;
|
|
2006
|
+
observeControlPlaneOutage?: () => Promise<boolean>;
|
|
1888
2007
|
}): PlayRunAttemptEngineSuspensionPort {
|
|
1889
2008
|
let parkedSignal: SuspendTask | null = null;
|
|
1890
2009
|
return {
|
|
@@ -1901,6 +2020,7 @@ export function createAbsurdEngineSuspensionAdapter(input: {
|
|
|
1901
2020
|
readRunnerTerminal: input.readRunnerTerminal,
|
|
1902
2021
|
readRunnerLiveness: input.readRunnerLiveness,
|
|
1903
2022
|
inspectDetachedRunner: input.inspectDetachedRunner,
|
|
2023
|
+
observeControlPlaneOutage: input.observeControlPlaneOutage,
|
|
1904
2024
|
}),
|
|
1905
2025
|
};
|
|
1906
2026
|
} catch (error) {
|
|
@@ -2472,7 +2592,8 @@ type ObservedTerminalSource =
|
|
|
2472
2592
|
| 'terminal_fence'
|
|
2473
2593
|
| 'pre_park_fence'
|
|
2474
2594
|
| 'post_wake_fence'
|
|
2475
|
-
| 'capacity_admission'
|
|
2595
|
+
| 'capacity_admission'
|
|
2596
|
+
| 'platform_recovery_exhausted';
|
|
2476
2597
|
|
|
2477
2598
|
/**
|
|
2478
2599
|
* Make one immediate, best-effort delivery attempt for a terminal fact.
|
|
@@ -2503,7 +2624,7 @@ function requestTerminalOutboxProjection(
|
|
|
2503
2624
|
function dispatchTerminalOutboxProjection(
|
|
2504
2625
|
input: TerminalOutboxProjectionRequest,
|
|
2505
2626
|
): Promise<void> {
|
|
2506
|
-
const targetEventId =
|
|
2627
|
+
const targetEventId = runEndingEventId(input.runId, input.launch.resumeEpoch);
|
|
2507
2628
|
const requestedAtMs = Date.now();
|
|
2508
2629
|
// Terminal-visibility evidence: the request itself, and how long the
|
|
2509
2630
|
// post-commit work before it took, so a slow first claim is attributable.
|
|
@@ -2617,7 +2738,160 @@ async function terminalizeSandboxCapacityRejection(input: {
|
|
|
2617
2738
|
leaseToken: string;
|
|
2618
2739
|
error: RuntimeSandboxCapacityLimitError;
|
|
2619
2740
|
}): Promise<AbsurdRuntimeResult> {
|
|
2620
|
-
|
|
2741
|
+
console.info('[absurd-runtime.worker] sandbox_capacity_rejected', {
|
|
2742
|
+
runId: input.runId,
|
|
2743
|
+
orgId: input.error.orgId,
|
|
2744
|
+
triggerSource: input.launch.triggerSource ?? 'api',
|
|
2745
|
+
activeLeases: input.error.activeLeases,
|
|
2746
|
+
limit: input.error.limit,
|
|
2747
|
+
});
|
|
2748
|
+
return terminalizeAttemptWithFailure({
|
|
2749
|
+
...input,
|
|
2750
|
+
cause: sandboxCapacityExceededCause(),
|
|
2751
|
+
source: 'capacity_admission',
|
|
2752
|
+
});
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2755
|
+
/**
|
|
2756
|
+
* A post-code retry starts no sandbox until every earlier attempt's sandbox
|
|
2757
|
+
* cleanup is confirmed deleted (A11). While one is unconfirmed the attempt is
|
|
2758
|
+
* deferred again: that counts against the recovery horizon and defer cap but
|
|
2759
|
+
* never against the no-progress streak. When the budget is spent the run ends
|
|
2760
|
+
* as platform recovery exhausted. Returns a terminal result, or null to
|
|
2761
|
+
* proceed; it throws DeferTask to wait.
|
|
2762
|
+
*/
|
|
2763
|
+
async function gatePostCodeRetryOnEarlierSandboxDeletion(input: {
|
|
2764
|
+
deps: AbsurdRuntimeWorkerDeps;
|
|
2765
|
+
options: Pick<PostgresSchedulerOptions, 'schema'>;
|
|
2766
|
+
launch: PlaySchedulerSubmitInput;
|
|
2767
|
+
runId: string;
|
|
2768
|
+
generation: number;
|
|
2769
|
+
leaseToken: string;
|
|
2770
|
+
}): Promise<AbsurdRuntimeResult | null> {
|
|
2771
|
+
if (!DURABLE_RUNS_ROLLOUT.automaticPostCodeRecovery) return null;
|
|
2772
|
+
const { deps, options, launch, runId, generation, leaseToken } = input;
|
|
2773
|
+
const gate = await deps.runWithClient(async (client) => {
|
|
2774
|
+
if (
|
|
2775
|
+
!(await readPostgresSchedulerPostCodeRecoveryOpen(
|
|
2776
|
+
client,
|
|
2777
|
+
{ runId },
|
|
2778
|
+
options,
|
|
2779
|
+
))
|
|
2780
|
+
) {
|
|
2781
|
+
return { recovering: false, pending: false };
|
|
2782
|
+
}
|
|
2783
|
+
return {
|
|
2784
|
+
recovering: true,
|
|
2785
|
+
pending: await hasPendingPostgresSchedulerSandboxDeletionThroughAttempt(
|
|
2786
|
+
client,
|
|
2787
|
+
{ runId, throughAttempt: generation - 1 },
|
|
2788
|
+
options,
|
|
2789
|
+
),
|
|
2790
|
+
};
|
|
2791
|
+
});
|
|
2792
|
+
if (!gate.recovering) return null;
|
|
2793
|
+
if (!gate.pending) {
|
|
2794
|
+
// Deletion is confirmed, so the earlier attempts' claims may be released
|
|
2795
|
+
// for the retry (idempotent when already released at the defer).
|
|
2796
|
+
const released = await deps.runWithClient((client) =>
|
|
2797
|
+
releasePostgresSchedulerReceiptsThroughAttempt(
|
|
2798
|
+
client,
|
|
2799
|
+
{ runId, throughAttempt: generation - 1 },
|
|
2800
|
+
{ ...options, orgId: launch.orgId },
|
|
2801
|
+
),
|
|
2802
|
+
);
|
|
2803
|
+
console.info('[absurd-runtime.worker] post_code_receipts_released', {
|
|
2804
|
+
runId,
|
|
2805
|
+
generation,
|
|
2806
|
+
releasedReceipts: released.released,
|
|
2807
|
+
atRetryStart: true,
|
|
2808
|
+
});
|
|
2809
|
+
return null;
|
|
2810
|
+
}
|
|
2811
|
+
const deferral = await deps.runWithClient((client) =>
|
|
2812
|
+
deferPostgresSchedulerAttemptForPostCodeRecovery(
|
|
2813
|
+
client,
|
|
2814
|
+
{
|
|
2815
|
+
runId,
|
|
2816
|
+
orgId: launch.orgId,
|
|
2817
|
+
attempt: generation,
|
|
2818
|
+
leaseToken,
|
|
2819
|
+
reason: 'earlier_sandbox_deletion_unconfirmed',
|
|
2820
|
+
nowMs: Date.now(),
|
|
2821
|
+
maxDefers: POST_CODE_RECOVERY_BUDGET.maxDefers,
|
|
2822
|
+
horizonMs: POST_CODE_RECOVERY_BUDGET.horizonMs,
|
|
2823
|
+
maxUnproductiveAttempts:
|
|
2824
|
+
POST_CODE_RECOVERY_BUDGET.maxUnproductiveAttempts,
|
|
2825
|
+
countsTowardProgress: false,
|
|
2826
|
+
delayMsForDeferCount: (deferCount) =>
|
|
2827
|
+
postCodeRecoveryDelayMs(deferCount),
|
|
2828
|
+
replayTrackedMarkerKey: replayTrackedMarkerReceiptKey(
|
|
2829
|
+
launch.orgId,
|
|
2830
|
+
runId,
|
|
2831
|
+
),
|
|
2832
|
+
replayUnsafeMarkerKey: replayUnsafeMarkerReceiptKey(
|
|
2833
|
+
launch.orgId,
|
|
2834
|
+
runId,
|
|
2835
|
+
),
|
|
2836
|
+
},
|
|
2837
|
+
options,
|
|
2838
|
+
),
|
|
2839
|
+
);
|
|
2840
|
+
console.warn(
|
|
2841
|
+
'[absurd-runtime.worker] post_code_retry_awaiting_sandbox_deletion',
|
|
2842
|
+
{
|
|
2843
|
+
runId,
|
|
2844
|
+
generation,
|
|
2845
|
+
deferred: deferral.deferred,
|
|
2846
|
+
exhausted: deferral.exhausted,
|
|
2847
|
+
deferCount: deferral.deferCount,
|
|
2848
|
+
delayMs: deferral.delayMs,
|
|
2849
|
+
},
|
|
2850
|
+
);
|
|
2851
|
+
if (deferral.deferred && deferral.delayMs !== null) {
|
|
2852
|
+
throw new DeferTask(
|
|
2853
|
+
"Platform recovery waiting for the earlier attempt's sandbox to be confirmed deleted",
|
|
2854
|
+
Math.max(1, Math.ceil(deferral.delayMs / 1_000)),
|
|
2855
|
+
);
|
|
2856
|
+
}
|
|
2857
|
+
if (deferral.exhausted || !deferral.replaySafe) {
|
|
2858
|
+
return terminalizeAttemptWithFailure({
|
|
2859
|
+
deps,
|
|
2860
|
+
options,
|
|
2861
|
+
launch,
|
|
2862
|
+
runId,
|
|
2863
|
+
generation,
|
|
2864
|
+
leaseToken,
|
|
2865
|
+
cause: platformRecoveryExhaustedMessage({
|
|
2866
|
+
retries: deferral.deferCount,
|
|
2867
|
+
savedCalls: deferral.historyRows,
|
|
2868
|
+
}),
|
|
2869
|
+
source: 'platform_recovery_exhausted',
|
|
2870
|
+
});
|
|
2871
|
+
}
|
|
2872
|
+
// The attempt's fence was lost: another worker owns the run now.
|
|
2873
|
+
await settleObservedTerminal({
|
|
2874
|
+
deps,
|
|
2875
|
+
launch,
|
|
2876
|
+
runId,
|
|
2877
|
+
options,
|
|
2878
|
+
source: 'assignment_fence',
|
|
2879
|
+
});
|
|
2880
|
+
return { ok: true, runId, schedulerStatus: 'idle' };
|
|
2881
|
+
}
|
|
2882
|
+
|
|
2883
|
+
/** Fail the run under this attempt's fence with a customer-facing cause. */
|
|
2884
|
+
async function terminalizeAttemptWithFailure(input: {
|
|
2885
|
+
deps: AbsurdRuntimeWorkerDeps;
|
|
2886
|
+
options: Pick<PostgresSchedulerOptions, 'schema'>;
|
|
2887
|
+
launch: PlaySchedulerSubmitInput;
|
|
2888
|
+
runId: string;
|
|
2889
|
+
generation: number;
|
|
2890
|
+
leaseToken: string;
|
|
2891
|
+
cause: string;
|
|
2892
|
+
source: ObservedTerminalSource;
|
|
2893
|
+
}): Promise<AbsurdRuntimeResult> {
|
|
2894
|
+
const cause = input.cause;
|
|
2621
2895
|
const failedResult: PlayRunnerResult = {
|
|
2622
2896
|
status: 'failed',
|
|
2623
2897
|
error: cause,
|
|
@@ -2632,13 +2906,6 @@ async function terminalizeSandboxCapacityRejection(input: {
|
|
|
2632
2906
|
launch: input.launch,
|
|
2633
2907
|
leaseToken: input.leaseToken,
|
|
2634
2908
|
};
|
|
2635
|
-
console.info('[absurd-runtime.worker] sandbox_capacity_rejected', {
|
|
2636
|
-
runId: input.runId,
|
|
2637
|
-
orgId: input.error.orgId,
|
|
2638
|
-
triggerSource: input.launch.triggerSource ?? 'api',
|
|
2639
|
-
activeLeases: input.error.activeLeases,
|
|
2640
|
-
limit: input.error.limit,
|
|
2641
|
-
});
|
|
2642
2909
|
const terminal = await input.deps.runWithClient((client) =>
|
|
2643
2910
|
executePostgresSchedulerClaim(client, claim, async () => failedResult, {
|
|
2644
2911
|
...input.options,
|
|
@@ -2666,7 +2933,7 @@ async function terminalizeSandboxCapacityRejection(input: {
|
|
|
2666
2933
|
launch: input.launch,
|
|
2667
2934
|
runId: input.runId,
|
|
2668
2935
|
options: input.options,
|
|
2669
|
-
source:
|
|
2936
|
+
source: input.source,
|
|
2670
2937
|
});
|
|
2671
2938
|
}
|
|
2672
2939
|
return {
|
|
@@ -3259,6 +3526,17 @@ async function executeAbsurdAttemptAdapter(
|
|
|
3259
3526
|
let computeSessionInitialized = false;
|
|
3260
3527
|
let runtimeTrafficPolicy: RuntimeTrafficPolicy | null = null;
|
|
3261
3528
|
try {
|
|
3529
|
+
if (prepared.kind === 'fresh_claimed') {
|
|
3530
|
+
const gated = await gatePostCodeRetryOnEarlierSandboxDeletion({
|
|
3531
|
+
deps,
|
|
3532
|
+
options,
|
|
3533
|
+
launch,
|
|
3534
|
+
runId,
|
|
3535
|
+
generation,
|
|
3536
|
+
leaseToken,
|
|
3537
|
+
});
|
|
3538
|
+
if (gated) return gated;
|
|
3539
|
+
}
|
|
3262
3540
|
const tokenStartedAt = performance.now();
|
|
3263
3541
|
const executorToken = await runWithAbsurdExecutionLeaseHeartbeat({
|
|
3264
3542
|
ctx,
|
|
@@ -3803,6 +4081,170 @@ async function executeAssignedAbsurdAttempt(input: {
|
|
|
3803
4081
|
: { ok: true, runId, schedulerStatus: 'failed', error: result.error };
|
|
3804
4082
|
};
|
|
3805
4083
|
|
|
4084
|
+
// An attempt that ended after customer code started: when the worker's own
|
|
4085
|
+
// evidence shows the platform failed it, retry the same run from its
|
|
4086
|
+
// checkpoint instead of failing it. Recorded calls return their results on
|
|
4087
|
+
// the next attempt. Returns the result to finalize, or throws DeferTask.
|
|
4088
|
+
const observeControlPlaneOutage = async (): Promise<boolean> => {
|
|
4089
|
+
if (!DURABLE_RUNS_ROLLOUT.automaticPostCodeRecovery) return false;
|
|
4090
|
+
const gateway = process.env.DEEPLINE_RUNTIME_RECEIPT_GATEWAY_URL?.trim();
|
|
4091
|
+
// This URL belongs to the worker's release, never the sandbox's result.
|
|
4092
|
+
let gatewayUnavailable = false;
|
|
4093
|
+
if (gateway) {
|
|
4094
|
+
const endpoint = new URL('/readyz', gateway);
|
|
4095
|
+
try {
|
|
4096
|
+
const response = await fetch(endpoint, {
|
|
4097
|
+
signal: AbortSignal.timeout(5_000),
|
|
4098
|
+
redirect: 'manual',
|
|
4099
|
+
});
|
|
4100
|
+
gatewayUnavailable = response.status >= 500;
|
|
4101
|
+
if (response.ok) {
|
|
4102
|
+
const readiness = (await response.json()) as {
|
|
4103
|
+
schedulerBreakerOpen?: unknown;
|
|
4104
|
+
};
|
|
4105
|
+
gatewayUnavailable = readiness.schedulerBreakerOpen === true;
|
|
4106
|
+
} else {
|
|
4107
|
+
await response.body?.cancel();
|
|
4108
|
+
}
|
|
4109
|
+
} catch (error) {
|
|
4110
|
+
// Authentication, malformed configuration and invalid JSON are not
|
|
4111
|
+
// evidence of an outage. Fetch transport failures and timeouts are.
|
|
4112
|
+
gatewayUnavailable =
|
|
4113
|
+
error instanceof TypeError ||
|
|
4114
|
+
(error instanceof Error &&
|
|
4115
|
+
['TimeoutError', 'AbortError'].includes(error.name));
|
|
4116
|
+
}
|
|
4117
|
+
}
|
|
4118
|
+
let receiptStoreUnavailable = false;
|
|
4119
|
+
try {
|
|
4120
|
+
await deps.runWithClient((client) =>
|
|
4121
|
+
getPostgresSchedulerReceipt(
|
|
4122
|
+
client,
|
|
4123
|
+
{ key: replayTrackedMarkerReceiptKey(launch.orgId, runId) },
|
|
4124
|
+
{ ...options, orgId: launch.orgId },
|
|
4125
|
+
),
|
|
4126
|
+
);
|
|
4127
|
+
} catch (error) {
|
|
4128
|
+
receiptStoreUnavailable =
|
|
4129
|
+
isConnectionCategoryError(error) ||
|
|
4130
|
+
isRuntimeSchedulerServerUnavailableError(error) ||
|
|
4131
|
+
isRuntimeSchedulerCapacityError(error);
|
|
4132
|
+
if (!receiptStoreUnavailable) throw error;
|
|
4133
|
+
}
|
|
4134
|
+
return gatewayUnavailable || receiptStoreUnavailable;
|
|
4135
|
+
};
|
|
4136
|
+
|
|
4137
|
+
const deferPostCodePlatformFailure = async (
|
|
4138
|
+
runnerResult: PlayRunnerResult,
|
|
4139
|
+
detachedSuspension: DetachedRunnerSuspension,
|
|
4140
|
+
): Promise<PlayRunnerResult> => {
|
|
4141
|
+
if (!DURABLE_RUNS_ROLLOUT.automaticPostCodeRecovery) return runnerResult;
|
|
4142
|
+
const outcome = classifyPostCodeAttemptOutcome(runnerResult);
|
|
4143
|
+
if (outcome.kind !== 'platform') return runnerResult;
|
|
4144
|
+
// The lost sandbox's cleanup obligation is persisted first, as on every
|
|
4145
|
+
// other retry.
|
|
4146
|
+
const cleanupPersisted =
|
|
4147
|
+
await persistAttemptSandboxCleanupBeforeBestEffortGc({
|
|
4148
|
+
deps,
|
|
4149
|
+
runId,
|
|
4150
|
+
attempt: detachedSuspension.runnerAttempt,
|
|
4151
|
+
options,
|
|
4152
|
+
});
|
|
4153
|
+
const throughAttempt = Math.max(
|
|
4154
|
+
generation,
|
|
4155
|
+
detachedSuspension.runnerAttempt,
|
|
4156
|
+
);
|
|
4157
|
+
const deferral = await deps.runWithClient((client) =>
|
|
4158
|
+
deferPostgresSchedulerAttemptForPostCodeRecovery(
|
|
4159
|
+
client,
|
|
4160
|
+
{
|
|
4161
|
+
runId,
|
|
4162
|
+
orgId: launch.orgId,
|
|
4163
|
+
attempt: generation,
|
|
4164
|
+
leaseToken,
|
|
4165
|
+
reason: outcome.reason,
|
|
4166
|
+
nowMs: Date.now(),
|
|
4167
|
+
maxDefers: POST_CODE_RECOVERY_BUDGET.maxDefers,
|
|
4168
|
+
horizonMs: POST_CODE_RECOVERY_BUDGET.horizonMs,
|
|
4169
|
+
maxUnproductiveAttempts:
|
|
4170
|
+
POST_CODE_RECOVERY_BUDGET.maxUnproductiveAttempts,
|
|
4171
|
+
countsTowardProgress: outcome.countsTowardProgress,
|
|
4172
|
+
delayMsForDeferCount: (deferCount) =>
|
|
4173
|
+
postCodeRecoveryDelayMs(deferCount),
|
|
4174
|
+
replayTrackedMarkerKey: replayTrackedMarkerReceiptKey(
|
|
4175
|
+
launch.orgId,
|
|
4176
|
+
runId,
|
|
4177
|
+
),
|
|
4178
|
+
replayUnsafeMarkerKey: replayUnsafeMarkerReceiptKey(
|
|
4179
|
+
launch.orgId,
|
|
4180
|
+
runId,
|
|
4181
|
+
),
|
|
4182
|
+
},
|
|
4183
|
+
options,
|
|
4184
|
+
),
|
|
4185
|
+
);
|
|
4186
|
+
console.warn('[absurd-runtime.worker] post_code_recovery', {
|
|
4187
|
+
runId,
|
|
4188
|
+
generation,
|
|
4189
|
+
reason: outcome.reason,
|
|
4190
|
+
deferred: deferral.deferred,
|
|
4191
|
+
exhausted: deferral.exhausted,
|
|
4192
|
+
replaySafe: deferral.replaySafe,
|
|
4193
|
+
deferCount: deferral.deferCount,
|
|
4194
|
+
delayMs: deferral.delayMs,
|
|
4195
|
+
historyRows: deferral.historyRows,
|
|
4196
|
+
});
|
|
4197
|
+
if (deferral.deferred && deferral.delayMs !== null) {
|
|
4198
|
+
// The lost attempts' receipt claims would otherwise hold their calls
|
|
4199
|
+
// until the leases expire; the retried attempt must claim them now.
|
|
4200
|
+
// Only a provider-confirmed loss may release them at once. For a
|
|
4201
|
+
// stopped sandbox or an unreachable control plane the old runner may
|
|
4202
|
+
// still be alive, so its claims stay until its sandbox cleanup is
|
|
4203
|
+
// confirmed deleted; the retried attempt's start gate releases them.
|
|
4204
|
+
const deletionRequired = postCodeRecoveryRequiresSandboxDeletion(
|
|
4205
|
+
outcome.reason,
|
|
4206
|
+
);
|
|
4207
|
+
const deletionUnconfirmed =
|
|
4208
|
+
deletionRequired &&
|
|
4209
|
+
(!cleanupPersisted ||
|
|
4210
|
+
(await deps.runWithClient((client) =>
|
|
4211
|
+
hasPendingPostgresSchedulerSandboxDeletionThroughAttempt(
|
|
4212
|
+
client,
|
|
4213
|
+
{ runId, throughAttempt },
|
|
4214
|
+
options,
|
|
4215
|
+
),
|
|
4216
|
+
)));
|
|
4217
|
+
if (!deletionUnconfirmed) {
|
|
4218
|
+
const released = await deps.runWithClient((client) =>
|
|
4219
|
+
releasePostgresSchedulerReceiptsThroughAttempt(
|
|
4220
|
+
client,
|
|
4221
|
+
{ runId, throughAttempt },
|
|
4222
|
+
{ ...options, orgId: launch.orgId },
|
|
4223
|
+
),
|
|
4224
|
+
);
|
|
4225
|
+
console.info('[absurd-runtime.worker] post_code_receipts_released', {
|
|
4226
|
+
runId,
|
|
4227
|
+
generation,
|
|
4228
|
+
releasedReceipts: released.released,
|
|
4229
|
+
});
|
|
4230
|
+
}
|
|
4231
|
+
throw new DeferTask(
|
|
4232
|
+
`Platform recovery deferred after the runner was lost: ${outcome.reason}`,
|
|
4233
|
+
Math.max(1, Math.ceil(deferral.delayMs / 1_000)),
|
|
4234
|
+
);
|
|
4235
|
+
}
|
|
4236
|
+
if (deferral.exhausted && runnerResult.status === 'failed') {
|
|
4237
|
+
return {
|
|
4238
|
+
...runnerResult,
|
|
4239
|
+
error: platformRecoveryExhaustedMessage({
|
|
4240
|
+
retries: deferral.deferCount,
|
|
4241
|
+
savedCalls: deferral.historyRows,
|
|
4242
|
+
}),
|
|
4243
|
+
};
|
|
4244
|
+
}
|
|
4245
|
+
return runnerResult;
|
|
4246
|
+
};
|
|
4247
|
+
|
|
3806
4248
|
const resolveRunnerSuspension = async (input: {
|
|
3807
4249
|
runnerResult: Extract<PlayRunnerResult, { status: 'suspended' }>;
|
|
3808
4250
|
progressReporter: ReturnType<
|
|
@@ -3826,6 +4268,15 @@ async function executeAssignedAbsurdAttempt(input: {
|
|
|
3826
4268
|
`absurd runtime worker: suspended runner result for ${runId} carried no suspension.`,
|
|
3827
4269
|
);
|
|
3828
4270
|
}
|
|
4271
|
+
if (suspension.kind === 'detached_runner') {
|
|
4272
|
+
scheduleTestRunnerSandboxDelete({
|
|
4273
|
+
runId,
|
|
4274
|
+
suspension,
|
|
4275
|
+
delayMs: resolveRunnerSandboxDeleteMs(launch.runtimeTestFaultHeader),
|
|
4276
|
+
deps,
|
|
4277
|
+
options,
|
|
4278
|
+
});
|
|
4279
|
+
}
|
|
3829
4280
|
const suspendedCheckpoint = absurdCheckpointBase(
|
|
3830
4281
|
input.runnerResult.checkpoint ?? checkpoint ?? null,
|
|
3831
4282
|
);
|
|
@@ -3868,6 +4319,10 @@ async function executeAssignedAbsurdAttempt(input: {
|
|
|
3868
4319
|
),
|
|
3869
4320
|
),
|
|
3870
4321
|
inspectDetachedRunner: deps.inspectDetachedRunner,
|
|
4322
|
+
// Off, the park keeps its exact step identities.
|
|
4323
|
+
observeControlPlaneOutage: DURABLE_RUNS_ROLLOUT.automaticPostCodeRecovery
|
|
4324
|
+
? observeControlPlaneOutage
|
|
4325
|
+
: undefined,
|
|
3871
4326
|
});
|
|
3872
4327
|
const finalizeSuspensionProgress = () =>
|
|
3873
4328
|
runWithAbsurdExecutionLeaseHeartbeat({
|
|
@@ -4075,6 +4530,10 @@ async function executeAssignedAbsurdAttempt(input: {
|
|
|
4075
4530
|
),
|
|
4076
4531
|
),
|
|
4077
4532
|
inspectDetachedRunner: deps.inspectDetachedRunner,
|
|
4533
|
+
// Off, the park keeps its exact step identities.
|
|
4534
|
+
observeControlPlaneOutage: DURABLE_RUNS_ROLLOUT.automaticPostCodeRecovery
|
|
4535
|
+
? observeControlPlaneOutage
|
|
4536
|
+
: undefined,
|
|
4078
4537
|
});
|
|
4079
4538
|
const running = await deps.runWithClient((client) =>
|
|
4080
4539
|
markPostgresSchedulerAttemptRunning(
|
|
@@ -4380,6 +4839,7 @@ async function executeAssignedAbsurdAttempt(input: {
|
|
|
4380
4839
|
),
|
|
4381
4840
|
),
|
|
4382
4841
|
inspectDetachedRunner: deps.inspectDetachedRunner,
|
|
4842
|
+
observeControlPlaneOutage,
|
|
4383
4843
|
}),
|
|
4384
4844
|
});
|
|
4385
4845
|
} catch (error) {
|
|
@@ -4429,6 +4889,9 @@ async function executeAssignedAbsurdAttempt(input: {
|
|
|
4429
4889
|
}
|
|
4430
4890
|
continue;
|
|
4431
4891
|
}
|
|
4892
|
+
// A prior leg may have recorded the lost runner and stopped before
|
|
4893
|
+
// deciding; decide here the same way.
|
|
4894
|
+
runnerResult = await deferPostCodePlatformFailure(runnerResult, detached);
|
|
4432
4895
|
return finalizeTerminal({
|
|
4433
4896
|
claim,
|
|
4434
4897
|
runnerResult,
|
|
@@ -4484,6 +4947,7 @@ async function executeAssignedAbsurdAttempt(input: {
|
|
|
4484
4947
|
),
|
|
4485
4948
|
),
|
|
4486
4949
|
inspectDetachedRunner: deps.inspectDetachedRunner,
|
|
4950
|
+
observeControlPlaneOutage,
|
|
4487
4951
|
readDetachedRunnerRuntimeCompletion:
|
|
4488
4952
|
deps.readDetachedRunnerRuntimeCompletion,
|
|
4489
4953
|
});
|
|
@@ -4542,7 +5006,10 @@ async function executeAssignedAbsurdAttempt(input: {
|
|
|
4542
5006
|
upsertComputeBillingSessionViaAppRuntime(
|
|
4543
5007
|
deps.runtimeApiFromLaunch(launch),
|
|
4544
5008
|
{
|
|
4545
|
-
sessionId:
|
|
5009
|
+
sessionId: computeBillingSessionId(
|
|
5010
|
+
launch.runId,
|
|
5011
|
+
launch.resumeEpoch,
|
|
5012
|
+
),
|
|
4546
5013
|
orgId: launch.orgId,
|
|
4547
5014
|
...(launch.userId ? { userId: launch.userId } : {}),
|
|
4548
5015
|
operation: 'workflow_run',
|
|
@@ -4748,7 +5215,10 @@ async function executeAssignedAbsurdAttempt(input: {
|
|
|
4748
5215
|
provider,
|
|
4749
5216
|
mode,
|
|
4750
5217
|
attempt: generation,
|
|
4751
|
-
environment:
|
|
5218
|
+
environment:
|
|
5219
|
+
process.env.DEEPLINE_RUNTIME_ENVIRONMENT === 'preview'
|
|
5220
|
+
? ('preview' as const)
|
|
5221
|
+
: ('production' as const),
|
|
4752
5222
|
resumePendingDaytonaOperation: provider === 'daytona',
|
|
4753
5223
|
operationKey: `sandbox-operation:${runId}:${generation}:${provider}:${providerAttempt ?? 1}`,
|
|
4754
5224
|
};
|
|
@@ -5262,6 +5732,13 @@ async function executeAssignedAbsurdAttempt(input: {
|
|
|
5262
5732
|
continue;
|
|
5263
5733
|
}
|
|
5264
5734
|
|
|
5735
|
+
if (terminalResultFromDetachedRunner && terminalDetachedSuspension) {
|
|
5736
|
+
runnerResult = await deferPostCodePlatformFailure(
|
|
5737
|
+
runnerResult,
|
|
5738
|
+
terminalDetachedSuspension,
|
|
5739
|
+
);
|
|
5740
|
+
}
|
|
5741
|
+
|
|
5265
5742
|
return finalizeTerminal({
|
|
5266
5743
|
claim,
|
|
5267
5744
|
runnerResult,
|
|
@@ -5700,6 +6177,8 @@ export async function resolveDetachedRunnerOutcome(input: {
|
|
|
5700
6177
|
status: string;
|
|
5701
6178
|
} | null>;
|
|
5702
6179
|
inspectDetachedRunner?: AbsurdRuntimeWorkerDeps['inspectDetachedRunner'];
|
|
6180
|
+
/** Trusted worker read-only probe; absence never establishes an outage. */
|
|
6181
|
+
observeControlPlaneOutage?: () => Promise<boolean>;
|
|
5703
6182
|
readDetachedRunnerRuntimeCompletion?: AbsurdRuntimeWorkerDeps['readDetachedRunnerRuntimeCompletion'];
|
|
5704
6183
|
}): Promise<PlayRunnerResult> {
|
|
5705
6184
|
const { suspension } = input;
|
|
@@ -5873,7 +6352,42 @@ export async function resolveDetachedRunnerOutcome(input: {
|
|
|
5873
6352
|
resultStatus: inspection.result.status,
|
|
5874
6353
|
}),
|
|
5875
6354
|
);
|
|
5876
|
-
|
|
6355
|
+
// Salvaged output is the sandbox's own; only what the worker saw
|
|
6356
|
+
// (the heartbeat had lapsed) may say the platform failed it.
|
|
6357
|
+
const salvaged = withoutWorkerEvidence(inspection.result);
|
|
6358
|
+
if (salvaged.status !== 'failed') {
|
|
6359
|
+
return settleFirstWriteWinner(salvaged);
|
|
6360
|
+
}
|
|
6361
|
+
return settleFirstWriteWinner({
|
|
6362
|
+
...salvaged,
|
|
6363
|
+
stats: {
|
|
6364
|
+
...salvaged.stats,
|
|
6365
|
+
workerEvidence: {
|
|
6366
|
+
source: 'salvaged_after_heartbeat_lapse',
|
|
6367
|
+
heartbeatAgeMs: heartbeatAgeMs ?? 0,
|
|
6368
|
+
heartbeatTimeoutMs,
|
|
6369
|
+
controlPlaneOutageObserved:
|
|
6370
|
+
salvaged.error.startsWith(
|
|
6371
|
+
'RUNTIME_CONTROL_PLANE_UNAVAILABLE:',
|
|
6372
|
+
) &&
|
|
6373
|
+
heartbeatAgeMs !== null &&
|
|
6374
|
+
heartbeatAgeMs >= heartbeatTimeoutMs
|
|
6375
|
+
? controlPlaneOutageDuringLapse({
|
|
6376
|
+
confirmation,
|
|
6377
|
+
heartbeatIdentity,
|
|
6378
|
+
suspension,
|
|
6379
|
+
lastHeartbeatAtMs: heartbeatAtMs,
|
|
6380
|
+
resolvedAtMs: now,
|
|
6381
|
+
}) || (await input.observeControlPlaneOutage?.()) === true
|
|
6382
|
+
: false,
|
|
6383
|
+
inspectionStage: inspection.diagnosis?.stage ?? null,
|
|
6384
|
+
exitCode: inspection.exitCode,
|
|
6385
|
+
providerReturnCode: inspection.providerReturnCode ?? null,
|
|
6386
|
+
reachedRuntimeCeiling:
|
|
6387
|
+
now >= suspension.startedAtMs + suspension.ceilingMs,
|
|
6388
|
+
} satisfies WorkerAttemptEvidence,
|
|
6389
|
+
},
|
|
6390
|
+
});
|
|
5877
6391
|
}
|
|
5878
6392
|
if (inspection) {
|
|
5879
6393
|
console.warn(
|
|
@@ -5941,6 +6455,37 @@ export async function resolveDetachedRunnerOutcome(input: {
|
|
|
5941
6455
|
);
|
|
5942
6456
|
}
|
|
5943
6457
|
|
|
6458
|
+
/**
|
|
6459
|
+
* Whether the worker's own probes saw the platform down between the
|
|
6460
|
+
* runner's last heartbeat and now. The observation was recorded by the park
|
|
6461
|
+
* for this exact heartbeat, so it cannot predate it; the bounds are checked
|
|
6462
|
+
* again here and a missing or out-of-window record is no evidence.
|
|
6463
|
+
*/
|
|
6464
|
+
function controlPlaneOutageDuringLapse(input: {
|
|
6465
|
+
confirmation: PlayCheckpoint['detachedRunnerSilenceConfirmation'];
|
|
6466
|
+
heartbeatIdentity: string | null;
|
|
6467
|
+
suspension: DetachedRunnerSuspension;
|
|
6468
|
+
lastHeartbeatAtMs: number;
|
|
6469
|
+
resolvedAtMs: number;
|
|
6470
|
+
}): boolean {
|
|
6471
|
+
const { confirmation, suspension } = input;
|
|
6472
|
+
const observedAtMs = confirmation?.controlPlaneOutageObservedAtMs;
|
|
6473
|
+
if (
|
|
6474
|
+
!confirmation ||
|
|
6475
|
+
confirmation.boundaryId !== suspension.boundaryId ||
|
|
6476
|
+
confirmation.runnerAttempt !== suspension.runnerAttempt ||
|
|
6477
|
+
confirmation.heartbeatIdentity !== input.heartbeatIdentity ||
|
|
6478
|
+
typeof observedAtMs !== 'number' ||
|
|
6479
|
+
!Number.isFinite(observedAtMs)
|
|
6480
|
+
) {
|
|
6481
|
+
return false;
|
|
6482
|
+
}
|
|
6483
|
+
const lapseStartMs = Number.isFinite(input.lastHeartbeatAtMs)
|
|
6484
|
+
? input.lastHeartbeatAtMs
|
|
6485
|
+
: suspension.startedAtMs;
|
|
6486
|
+
return observedAtMs >= lapseStartMs && observedAtMs <= input.resolvedAtMs;
|
|
6487
|
+
}
|
|
6488
|
+
|
|
5944
6489
|
/** Legacy parked rows predate heartbeatTimeoutMs, and the field is durable JSON. */
|
|
5945
6490
|
function detachedRunnerHeartbeatTimeoutMs(
|
|
5946
6491
|
suspension: DetachedRunnerSuspension,
|
|
@@ -6025,12 +6570,21 @@ function detachedRunnerLostResult(input: {
|
|
|
6025
6570
|
inspectionExitCode: inspection?.exitCode ?? null,
|
|
6026
6571
|
inspectedResultStatus: inspection?.result?.status ?? null,
|
|
6027
6572
|
};
|
|
6573
|
+
const workerEvidence: WorkerAttemptEvidence = {
|
|
6574
|
+
source: 'runner_lost',
|
|
6575
|
+
heartbeatAgeMs: input.heartbeatAgeMs ?? 0,
|
|
6576
|
+
heartbeatTimeoutMs: runnerLiveness.heartbeatTimeoutMs,
|
|
6577
|
+
inspectionStage: inspection ? runnerLiveness.inspectionStage : null,
|
|
6578
|
+
exitCode: inspection?.exitCode ?? null,
|
|
6579
|
+
providerReturnCode: inspection?.providerReturnCode ?? null,
|
|
6580
|
+
reachedRuntimeCeiling: runnerLiveness.reachedRuntimeCeiling,
|
|
6581
|
+
};
|
|
6028
6582
|
return {
|
|
6029
6583
|
status: 'failed',
|
|
6030
6584
|
error: `RUNTIME_RUNNER_LOST: Detached runner heartbeat expired after ${input.heartbeatAgeMs ?? 'unknown'}ms without a terminal result. Deepline did not automatically retry because external actions may already have completed.`,
|
|
6031
6585
|
// The diagnostic is structured `stats`; the Run Log carries no copy.
|
|
6032
6586
|
logs: [],
|
|
6033
|
-
stats: { runnerLiveness },
|
|
6587
|
+
stats: { runnerLiveness, workerEvidence },
|
|
6034
6588
|
steps: [],
|
|
6035
6589
|
checkpoint: null,
|
|
6036
6590
|
tableNamespace: null,
|
|
@@ -7014,6 +7568,18 @@ export async function recoverAbsurdRuntimeCompletedRunnerTerminals(input: {
|
|
|
7014
7568
|
queue: input.queue,
|
|
7015
7569
|
schedulerRunId: terminal.runId,
|
|
7016
7570
|
});
|
|
7571
|
+
// A platform failure retries the same run. While its engine task is open,
|
|
7572
|
+
// the parked worker decides that when it wakes; committing the terminal
|
|
7573
|
+
// here would end the run. A run with no open task has no one to wake it,
|
|
7574
|
+
// so it still ends here.
|
|
7575
|
+
if (
|
|
7576
|
+
absurdRun &&
|
|
7577
|
+
DURABLE_RUNS_ROLLOUT.automaticPostCodeRecovery &&
|
|
7578
|
+
classifyPostCodeAttemptOutcome(runnerResult).kind === 'platform'
|
|
7579
|
+
) {
|
|
7580
|
+
skipped += 1;
|
|
7581
|
+
continue;
|
|
7582
|
+
}
|
|
7017
7583
|
const launch = await readPostgresSchedulerLaunch(
|
|
7018
7584
|
input.client,
|
|
7019
7585
|
terminal.runId,
|
|
@@ -8533,6 +9099,7 @@ async function processPostgresSchedulerComputeBillingJob(input: {
|
|
|
8533
9099
|
runWithClient: AbsurdRuntimeWorkerDeps['runWithClient'];
|
|
8534
9100
|
leaseOwner: string;
|
|
8535
9101
|
schedulerOptions: Pick<PostgresSchedulerOptions, 'schema'>;
|
|
9102
|
+
tokenIssuerOrigin?: string;
|
|
8536
9103
|
}): Promise<'settled' | 'retried' | 'blocked' | 'lease_lost'> {
|
|
8537
9104
|
try {
|
|
8538
9105
|
const launch = await input.runWithClient((client) =>
|
|
@@ -8547,10 +9114,17 @@ async function processPostgresSchedulerComputeBillingJob(input: {
|
|
|
8547
9114
|
),
|
|
8548
9115
|
);
|
|
8549
9116
|
if (!launch) return 'lease_lost';
|
|
9117
|
+
// A resumed epoch is its own billing session over its own attempts.
|
|
8550
9118
|
const runtimeResources = await input.runWithClient((client) =>
|
|
8551
9119
|
readPostgresSchedulerRuntimeResourcesForRun(
|
|
8552
9120
|
client,
|
|
8553
|
-
{
|
|
9121
|
+
{
|
|
9122
|
+
runId: input.job.runId,
|
|
9123
|
+
...(normalizeResumeEpoch(launch.resumeEpoch) > 0 &&
|
|
9124
|
+
typeof launch.resumeEpochFirstAttempt === 'number'
|
|
9125
|
+
? { fromAttempt: launch.resumeEpochFirstAttempt }
|
|
9126
|
+
: {}),
|
|
9127
|
+
},
|
|
8554
9128
|
input.schedulerOptions,
|
|
8555
9129
|
),
|
|
8556
9130
|
);
|
|
@@ -8560,6 +9134,7 @@ async function processPostgresSchedulerComputeBillingJob(input: {
|
|
|
8560
9134
|
leaseOwner: input.leaseOwner,
|
|
8561
9135
|
attemptCount: input.job.attemptCount,
|
|
8562
9136
|
schedulerSchema: input.schedulerOptions.schema ?? null,
|
|
9137
|
+
tokenIssuerOrigin: input.tokenIssuerOrigin,
|
|
8563
9138
|
});
|
|
8564
9139
|
// A compute-billing dispatch token is never pinned to a gateway.
|
|
8565
9140
|
const runtimeApi = {
|
|
@@ -8573,7 +9148,7 @@ async function processPostgresSchedulerComputeBillingJob(input: {
|
|
|
8573
9148
|
};
|
|
8574
9149
|
if (input.job.bootstrapSessionPending) {
|
|
8575
9150
|
await upsertComputeBillingSessionViaAppRuntime(runtimeApi, {
|
|
8576
|
-
sessionId: launch.runId,
|
|
9151
|
+
sessionId: computeBillingSessionId(launch.runId, launch.resumeEpoch),
|
|
8577
9152
|
orgId: launch.orgId,
|
|
8578
9153
|
...(launch.userId ? { userId: launch.userId } : {}),
|
|
8579
9154
|
operation: 'workflow_run',
|
|
@@ -8663,6 +9238,43 @@ async function processPostgresSchedulerComputeBillingJob(input: {
|
|
|
8663
9238
|
}
|
|
8664
9239
|
}
|
|
8665
9240
|
|
|
9241
|
+
/** Explicit Preview operator repair; normal background controllers never use it. */
|
|
9242
|
+
export async function reconcilePostgresSchedulerComputeBillingOnce(input: {
|
|
9243
|
+
runId: string;
|
|
9244
|
+
orgId: string;
|
|
9245
|
+
reason: string;
|
|
9246
|
+
leaseOwner: string;
|
|
9247
|
+
tokenIssuerOrigin: string;
|
|
9248
|
+
runWithClient: AbsurdRuntimeWorkerDeps['runWithClient'];
|
|
9249
|
+
schedulerOptions: Pick<PostgresSchedulerOptions, 'schema'>;
|
|
9250
|
+
}): Promise<'settled' | 'retried' | 'blocked' | 'lease_lost' | 'not_eligible'> {
|
|
9251
|
+
if (!isImmutableRuntimeExecutionRecoveryOrigin(input.tokenIssuerOrigin)) {
|
|
9252
|
+
throw new Error(
|
|
9253
|
+
'Compute billing recovery requires an immutable Deepline token issuer.',
|
|
9254
|
+
);
|
|
9255
|
+
}
|
|
9256
|
+
const job = await input.runWithClient((client) =>
|
|
9257
|
+
claimPostgresSchedulerComputeBillingReconciliation(
|
|
9258
|
+
client,
|
|
9259
|
+
{
|
|
9260
|
+
runId: input.runId,
|
|
9261
|
+
orgId: input.orgId,
|
|
9262
|
+
reason: input.reason,
|
|
9263
|
+
leaseOwner: input.leaseOwner,
|
|
9264
|
+
},
|
|
9265
|
+
input.schedulerOptions,
|
|
9266
|
+
),
|
|
9267
|
+
);
|
|
9268
|
+
if (!job) return 'not_eligible';
|
|
9269
|
+
return await processPostgresSchedulerComputeBillingJob({
|
|
9270
|
+
job,
|
|
9271
|
+
runWithClient: input.runWithClient,
|
|
9272
|
+
leaseOwner: input.leaseOwner,
|
|
9273
|
+
schedulerOptions: input.schedulerOptions,
|
|
9274
|
+
tokenIssuerOrigin: input.tokenIssuerOrigin,
|
|
9275
|
+
});
|
|
9276
|
+
}
|
|
9277
|
+
|
|
8666
9278
|
export async function drainPostgresSchedulerComputeBillingOnce(input: {
|
|
8667
9279
|
runWithClient: AbsurdRuntimeWorkerDeps['runWithClient'];
|
|
8668
9280
|
leaseOwner: string;
|