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
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import type { PlayRunnerResult } from './protocol';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Automatic recovery after customer code has started.
|
|
5
|
+
*
|
|
6
|
+
* A platform failure retries the same run: its next attempt replays the Play
|
|
7
|
+
* from its checkpoint, and every call recorded in the run's history returns
|
|
8
|
+
* its result instead of executing again. Only evidence gathered outside the
|
|
9
|
+
* sandbox can classify a failure as the platform's, because customer code
|
|
10
|
+
* shares the runner's process and could otherwise fake one.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Ladder for post-code platform failures; pre-code keeps its own policy. */
|
|
14
|
+
export const POST_CODE_RECOVERY_BUDGET = {
|
|
15
|
+
baseMs: 60_000,
|
|
16
|
+
maxMs: 5 * 60 * 60_000,
|
|
17
|
+
horizonMs: 24 * 60 * 60_000,
|
|
18
|
+
/** Spread wakes after a shared outage by ±20%. */
|
|
19
|
+
jitterRatio: 0.2,
|
|
20
|
+
/** Hard cap independent of the horizon. */
|
|
21
|
+
maxDefers: 20,
|
|
22
|
+
/**
|
|
23
|
+
* Attempts in a row that may record no new history before the run fails.
|
|
24
|
+
* The first unproductive attempt still earns a retry, because a crash can
|
|
25
|
+
* land before the attempt's first call completes; the second ends the run.
|
|
26
|
+
*/
|
|
27
|
+
maxUnproductiveAttempts: 2,
|
|
28
|
+
} as const;
|
|
29
|
+
|
|
30
|
+
export type PostCodeRecoveryReason =
|
|
31
|
+
/** The provider has no sandbox for the attempt any more. */
|
|
32
|
+
| 'runner_lost_sandbox_missing'
|
|
33
|
+
/** The sandbox stopped without an exit, or on a signal (128 or above). */
|
|
34
|
+
| 'runner_lost_sandbox_stopped'
|
|
35
|
+
/** The runner gave up on the gateway while the worker saw it go silent. */
|
|
36
|
+
| 'control_plane_unreachable'
|
|
37
|
+
/**
|
|
38
|
+
* The retry was held back because an earlier attempt's sandbox deletion is
|
|
39
|
+
* not confirmed yet. Never an attempt outcome; only the start gate records it.
|
|
40
|
+
*/
|
|
41
|
+
| 'earlier_sandbox_deletion_unconfirmed';
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Reasons for which the provider has NOT confirmed the lost attempt's sandbox
|
|
45
|
+
* gone. The next attempt (and any release of the lost attempt's receipt
|
|
46
|
+
* claims) waits for its cleanup to be confirmed deleted.
|
|
47
|
+
*/
|
|
48
|
+
export function postCodeRecoveryRequiresSandboxDeletion(
|
|
49
|
+
reason: PostCodeRecoveryReason,
|
|
50
|
+
): boolean {
|
|
51
|
+
return (
|
|
52
|
+
reason === 'runner_lost_sandbox_stopped' ||
|
|
53
|
+
reason === 'control_plane_unreachable'
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Stable machine-detectable prefix of an exhausted post-code recovery. */
|
|
58
|
+
export const PLATFORM_RECOVERY_EXHAUSTED_PREFIX =
|
|
59
|
+
'PLATFORM_RECOVERY_EXHAUSTED:';
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The customer-facing failure once automatic recovery is spent. It stands
|
|
63
|
+
* alone: it never embeds the first attempt's "not retried" explanation, which
|
|
64
|
+
* would contradict the retries that happened.
|
|
65
|
+
*/
|
|
66
|
+
export function platformRecoveryExhaustedMessage(input: {
|
|
67
|
+
retries: number | null;
|
|
68
|
+
savedCalls: number | null;
|
|
69
|
+
}): string {
|
|
70
|
+
const tries =
|
|
71
|
+
input.retries === null
|
|
72
|
+
? 'Deepline retried this run automatically'
|
|
73
|
+
: `Deepline retried this run automatically ${input.retries} ${input.retries === 1 ? 'time' : 'times'}`;
|
|
74
|
+
const saved =
|
|
75
|
+
input.savedCalls === null
|
|
76
|
+
? ''
|
|
77
|
+
: ` ${input.savedCalls} completed ${input.savedCalls === 1 ? 'call was' : 'calls were'} saved, so they are not repeated.`;
|
|
78
|
+
return `${PLATFORM_RECOVERY_EXHAUSTED_PREFIX} Deepline's infrastructure interrupted this run before it finished. ${tries}, but it did not recover.${saved} Start the run again to continue. If this keeps happening, contact support.`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type PostCodeAttemptOutcome =
|
|
82
|
+
| { kind: 'play' }
|
|
83
|
+
| {
|
|
84
|
+
kind: 'platform';
|
|
85
|
+
reason: PostCodeRecoveryReason;
|
|
86
|
+
/**
|
|
87
|
+
* Whether an attempt that recorded nothing counts against the run. An
|
|
88
|
+
* outage stops progress through no fault of the Play.
|
|
89
|
+
*/
|
|
90
|
+
countsTowardProgress: boolean;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* What the worker itself observed about an attempt that ended after customer
|
|
95
|
+
* code started. Only the worker's detached-runner resolver writes it, and
|
|
96
|
+
* {@link withoutWorkerEvidence} removes it from anything the sandbox
|
|
97
|
+
* produced, so it never carries the sandbox's own claims.
|
|
98
|
+
*/
|
|
99
|
+
export type WorkerAttemptEvidence = {
|
|
100
|
+
source: 'runner_lost' | 'salvaged_after_heartbeat_lapse';
|
|
101
|
+
heartbeatAgeMs: number;
|
|
102
|
+
heartbeatTimeoutMs: number;
|
|
103
|
+
inspectionStage: string | null;
|
|
104
|
+
/** The runner's exit code as the sandbox provider reported it. */
|
|
105
|
+
exitCode: number | null;
|
|
106
|
+
/** The sandbox's own return code (Modal reports it for a stopped sandbox). */
|
|
107
|
+
providerReturnCode: number | null;
|
|
108
|
+
reachedRuntimeCeiling: boolean;
|
|
109
|
+
/** Independent worker probe, never inferred from sandbox output or silence. */
|
|
110
|
+
controlPlaneOutageObserved?: boolean;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/** Stats keys only the worker may write. */
|
|
114
|
+
const WORKER_ONLY_STATS_KEYS = ['workerEvidence', 'runnerLiveness'] as const;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Remove worker-only evidence from a result the sandbox produced: a pushed
|
|
118
|
+
* terminal, or one salvaged from the sandbox's captured output.
|
|
119
|
+
*/
|
|
120
|
+
export function withoutWorkerEvidence<T extends { stats?: unknown }>(
|
|
121
|
+
result: T,
|
|
122
|
+
): T {
|
|
123
|
+
const stats = result.stats;
|
|
124
|
+
if (!stats || typeof stats !== 'object' || Array.isArray(stats)) {
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
if (!WORKER_ONLY_STATS_KEYS.some((key) => Object.hasOwn(stats, key))) {
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
const kept = { ...(stats as Record<string, unknown>) };
|
|
131
|
+
for (const key of WORKER_ONLY_STATS_KEYS) delete kept[key];
|
|
132
|
+
return { ...result, stats: kept };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function workerEvidence(
|
|
136
|
+
result: PlayRunnerResult,
|
|
137
|
+
): WorkerAttemptEvidence | null {
|
|
138
|
+
const evidence = (result.stats as { workerEvidence?: unknown } | undefined)
|
|
139
|
+
?.workerEvidence;
|
|
140
|
+
if (!evidence || typeof evidence !== 'object') return null;
|
|
141
|
+
const value = evidence as Partial<WorkerAttemptEvidence>;
|
|
142
|
+
return value.source === 'runner_lost' ||
|
|
143
|
+
value.source === 'salvaged_after_heartbeat_lapse'
|
|
144
|
+
? (value as WorkerAttemptEvidence)
|
|
145
|
+
: null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Decide whether an attempt that ended after customer code started failed
|
|
150
|
+
* because of the platform. Everything that is not proven to be the
|
|
151
|
+
* platform's is the Play's: a Play that exits, crashes or throws fails.
|
|
152
|
+
*
|
|
153
|
+
* - The provider has no sandbox: platform.
|
|
154
|
+
* - The sandbox stopped with no exit code, or on a signal (128 or above):
|
|
155
|
+
* platform. Out-of-memory exits look the same; the no-progress rule bounds
|
|
156
|
+
* them.
|
|
157
|
+
* - The runner reported the gateway unreachable after its heartbeat lapsed,
|
|
158
|
+
* and an independent worker probe observed an outage: platform, and the
|
|
159
|
+
* attempt is not held against the run's progress.
|
|
160
|
+
* - Reaching the runtime ceiling is always the Play's.
|
|
161
|
+
*/
|
|
162
|
+
export function classifyPostCodeAttemptOutcome(
|
|
163
|
+
result: PlayRunnerResult,
|
|
164
|
+
): PostCodeAttemptOutcome {
|
|
165
|
+
if (result.status !== 'failed') return { kind: 'play' };
|
|
166
|
+
const evidence = workerEvidence(result);
|
|
167
|
+
if (!evidence || evidence.reachedRuntimeCeiling) return { kind: 'play' };
|
|
168
|
+
if (evidence.source === 'runner_lost') {
|
|
169
|
+
if (evidence.inspectionStage === 'sandbox_missing') {
|
|
170
|
+
return {
|
|
171
|
+
kind: 'platform',
|
|
172
|
+
reason: 'runner_lost_sandbox_missing',
|
|
173
|
+
countsTowardProgress: true,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
if (evidence.inspectionStage === 'sandbox_stopped') {
|
|
177
|
+
const code = evidence.exitCode ?? evidence.providerReturnCode;
|
|
178
|
+
return code === null || code >= 128
|
|
179
|
+
? {
|
|
180
|
+
kind: 'platform',
|
|
181
|
+
reason: 'runner_lost_sandbox_stopped',
|
|
182
|
+
countsTowardProgress: true,
|
|
183
|
+
}
|
|
184
|
+
: { kind: 'play' };
|
|
185
|
+
}
|
|
186
|
+
return { kind: 'play' };
|
|
187
|
+
}
|
|
188
|
+
return result.error.startsWith('RUNTIME_CONTROL_PLANE_UNAVAILABLE:') &&
|
|
189
|
+
evidence.controlPlaneOutageObserved === true &&
|
|
190
|
+
evidence.heartbeatAgeMs >= evidence.heartbeatTimeoutMs
|
|
191
|
+
? {
|
|
192
|
+
kind: 'platform',
|
|
193
|
+
reason: 'control_plane_unreachable',
|
|
194
|
+
countsTowardProgress: false,
|
|
195
|
+
}
|
|
196
|
+
: { kind: 'play' };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** Delay before the next attempt, in milliseconds, with jitter applied. */
|
|
200
|
+
export function postCodeRecoveryDelayMs(
|
|
201
|
+
deferCount: number,
|
|
202
|
+
random: () => number = Math.random,
|
|
203
|
+
): number {
|
|
204
|
+
const exponent = Math.max(0, Math.floor(deferCount) - 1);
|
|
205
|
+
const base = Math.min(
|
|
206
|
+
POST_CODE_RECOVERY_BUDGET.maxMs,
|
|
207
|
+
POST_CODE_RECOVERY_BUDGET.baseMs * 2 ** exponent,
|
|
208
|
+
);
|
|
209
|
+
const spread = 1 + (random() * 2 - 1) * POST_CODE_RECOVERY_BUDGET.jitterRatio;
|
|
210
|
+
return Math.max(1_000, Math.round(base * spread));
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Receipt key that marks a run as not replay-safe: some call ran without a
|
|
215
|
+
* history row (an inline child authored before call history existed). The
|
|
216
|
+
* runtime writes it, awaited, before that call goes out, and the worker never
|
|
217
|
+
* replays a run that has it.
|
|
218
|
+
*/
|
|
219
|
+
export function replayTrackedMarkerReceiptKey(
|
|
220
|
+
orgId: string,
|
|
221
|
+
runId: string,
|
|
222
|
+
): string {
|
|
223
|
+
return `ctx:${orgId}:run-replay-tracked:${runId}`;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export function replayUnsafeMarkerReceiptKey(
|
|
227
|
+
orgId: string,
|
|
228
|
+
runId: string,
|
|
229
|
+
): string {
|
|
230
|
+
return `ctx:${orgId}:run-replay-unsafe:${runId}`;
|
|
231
|
+
}
|
|
@@ -303,6 +303,10 @@ export interface PlayRunnerContextConfig extends RetainedPipelineCarrier {
|
|
|
303
303
|
runId?: string;
|
|
304
304
|
/** Original run for an explicit user-requested replay. */
|
|
305
305
|
replayedFromRunId?: string | null;
|
|
306
|
+
/** Launch fact; see `PlaySchedulerSubmitInput.runScopedKeys`. */
|
|
307
|
+
runScopedKeys?: boolean;
|
|
308
|
+
/** How many times `runs resume` continued this run (absent means 0). */
|
|
309
|
+
resumeEpoch?: number;
|
|
306
310
|
/** Shared governance/billing root. Differs from runId for async children. */
|
|
307
311
|
rootRunId?: string;
|
|
308
312
|
runAttempt?: number | null;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbox event IDs for a run's endings.
|
|
3
|
+
*
|
|
4
|
+
* A run that was never resumed has one ending, `run-terminal:{runId}`, as it
|
|
5
|
+
* always has. Each `runs resume` bumps the run's epoch, and the ending of that
|
|
6
|
+
* epoch is `run-ended:{runId}:{epoch}`: a new event, ordered after the earlier
|
|
7
|
+
* one, rather than a duplicate the outbox would drop. The SQL writer is
|
|
8
|
+
* `runEndingEventIdSql` in `scheduler-backends/postgres.ts`.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** The ending event ID for a run at its current resume epoch. */
|
|
12
|
+
export function runEndingEventId(
|
|
13
|
+
runId: string,
|
|
14
|
+
resumeEpoch?: number | null,
|
|
15
|
+
): string {
|
|
16
|
+
const epoch = normalizeResumeEpoch(resumeEpoch);
|
|
17
|
+
return epoch === 0 ? `run-terminal:${runId}` : `run-ended:${runId}:${epoch}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Whether `eventId` is an ending of `runId`, from any epoch. */
|
|
21
|
+
export function isRunEndingEventId(eventId: string, runId: string): boolean {
|
|
22
|
+
return runEndingEventEpoch(eventId, runId) !== null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The epoch of an ending event of `runId`, or null if it is not one. */
|
|
26
|
+
export function runEndingEventEpoch(
|
|
27
|
+
eventId: string,
|
|
28
|
+
runId: string,
|
|
29
|
+
): number | null {
|
|
30
|
+
if (eventId === `run-terminal:${runId}`) return 0;
|
|
31
|
+
const prefix = `run-ended:${runId}:`;
|
|
32
|
+
if (!eventId.startsWith(prefix)) return null;
|
|
33
|
+
const epoch = Number(eventId.slice(prefix.length));
|
|
34
|
+
return Number.isSafeInteger(epoch) && epoch > 0 ? epoch : null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** A missing or malformed epoch is 0: the run was never resumed. */
|
|
38
|
+
/**
|
|
39
|
+
* Compute billing session for one epoch of a run. Each resumed epoch is
|
|
40
|
+
* billed as its own session over its own attempts, since the earlier
|
|
41
|
+
* epoch's session is already finalized.
|
|
42
|
+
*/
|
|
43
|
+
export function computeBillingSessionId(
|
|
44
|
+
runId: string,
|
|
45
|
+
resumeEpoch: unknown,
|
|
46
|
+
): string {
|
|
47
|
+
const epoch = normalizeResumeEpoch(resumeEpoch);
|
|
48
|
+
return epoch > 0 ? `${runId}:resume:${epoch}` : runId;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function normalizeResumeEpoch(value: unknown): number {
|
|
52
|
+
return typeof value === 'number' && Number.isSafeInteger(value) && value > 0
|
|
53
|
+
? value
|
|
54
|
+
: 0;
|
|
55
|
+
}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
type TerminalRuntimePerformance,
|
|
5
5
|
type TerminalRuntimePerformanceUnavailableReason,
|
|
6
6
|
} from './terminal-runtime-performance';
|
|
7
|
+
import { normalizeResumeEpoch } from './run-ending-event';
|
|
7
8
|
import {
|
|
8
9
|
normalizePlayRunFailure,
|
|
9
10
|
PLATFORM_DEPLOY_INTERRUPTED_MESSAGE,
|
|
@@ -20,6 +21,8 @@ import {
|
|
|
20
21
|
} from './docflow-node-io';
|
|
21
22
|
import {
|
|
22
23
|
isPlayActivityObservation,
|
|
24
|
+
PLATFORM_RECOVERY_ACTIVITY_ID,
|
|
25
|
+
CANCELLATION_CLEANUP_ACTIVITY_ID,
|
|
23
26
|
type PlayActivityObservation,
|
|
24
27
|
} from './activity-observation';
|
|
25
28
|
import {
|
|
@@ -235,6 +238,11 @@ export type PlayRunLedgerSnapshot = {
|
|
|
235
238
|
* this field existed — those are treated as authoritative.
|
|
236
239
|
*/
|
|
237
240
|
terminalSource?: PlayRunLedgerEventSource | null;
|
|
241
|
+
/**
|
|
242
|
+
* How many times `runs resume` continued this run (absent means 0). Events
|
|
243
|
+
* from an earlier epoch are stale; a resume from a later one reopens it.
|
|
244
|
+
*/
|
|
245
|
+
resumeEpoch?: number;
|
|
238
246
|
};
|
|
239
247
|
|
|
240
248
|
type PlayRunLedgerBaseEvent = {
|
|
@@ -248,6 +256,11 @@ type PlayRunLedgerBaseEvent = {
|
|
|
248
256
|
* reducer understands.
|
|
249
257
|
*/
|
|
250
258
|
payload?: unknown;
|
|
259
|
+
/**
|
|
260
|
+
* Epoch of the run this lifecycle fact belongs to (absent means 0). Endings
|
|
261
|
+
* carry the epoch encoded in their outbox event ID.
|
|
262
|
+
*/
|
|
263
|
+
resumeEpoch?: number;
|
|
251
264
|
};
|
|
252
265
|
|
|
253
266
|
export type PlayRunLedgerEvent =
|
|
@@ -1012,7 +1025,21 @@ export function normalizePlayRunLedgerSnapshot(
|
|
|
1012
1025
|
? ('invalid_terminal_performance' as const)
|
|
1013
1026
|
: undefined))
|
|
1014
1027
|
: undefined;
|
|
1028
|
+
// Preserve fields written by a newer reader. `logs` is the known legacy
|
|
1029
|
+
// alias already normalized into logTail, not a second retained log body.
|
|
1030
|
+
const {
|
|
1031
|
+
logs: _legacyLogs,
|
|
1032
|
+
workCounters: _rawWorkCounters,
|
|
1033
|
+
terminalWorkCounterSegment: _rawTerminalSegment,
|
|
1034
|
+
terminalRuntimePerformance: _rawPerformance,
|
|
1035
|
+
terminalRuntimePerformanceUnavailableReason: _rawPerformanceReason,
|
|
1036
|
+
...preserved
|
|
1037
|
+
} = value;
|
|
1015
1038
|
return {
|
|
1039
|
+
...preserved,
|
|
1040
|
+
...(value.resumeEpoch !== undefined
|
|
1041
|
+
? { resumeEpoch: normalizeResumeEpoch(value.resumeEpoch) }
|
|
1042
|
+
: {}),
|
|
1016
1043
|
runId: optionalString(value.runId) ?? fallback.runId,
|
|
1017
1044
|
playName:
|
|
1018
1045
|
optionalNullableString(value.playName) ?? fallback.playName ?? null,
|
|
@@ -1794,6 +1821,23 @@ function refineTerminalSyntheticStepStart(
|
|
|
1794
1821
|
};
|
|
1795
1822
|
}
|
|
1796
1823
|
|
|
1824
|
+
function isRunEndingEvent(event: AcceptedPlayRunLedgerEvent): boolean {
|
|
1825
|
+
return (
|
|
1826
|
+
event.type === RUN_EVENT_KIND.runCompleted ||
|
|
1827
|
+
event.type === RUN_EVENT_KIND.runFailed ||
|
|
1828
|
+
event.type === RUN_EVENT_KIND.runCancelled
|
|
1829
|
+
);
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
function isEpochScopedLedgerEvent(event: AcceptedPlayRunLedgerEvent): boolean {
|
|
1833
|
+
// Logs retain the whole story; work counters reconcile their own attempt
|
|
1834
|
+
// segments. All other projections describe the current execution epoch.
|
|
1835
|
+
return (
|
|
1836
|
+
event.type !== RUN_EVENT_KIND.logAppended &&
|
|
1837
|
+
event.type !== RUN_EVENT_KIND.workCounters
|
|
1838
|
+
);
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1797
1841
|
export function reducePlayRunLedgerEvent(
|
|
1798
1842
|
snapshot: PlayRunLedgerSnapshot,
|
|
1799
1843
|
event: AcceptedPlayRunLedgerEvent,
|
|
@@ -1807,6 +1851,88 @@ export function reducePlayRunLedgerEvent(
|
|
|
1807
1851
|
if (event.runId !== snapshot.runId) {
|
|
1808
1852
|
return snapshot;
|
|
1809
1853
|
}
|
|
1854
|
+
// `runs resume` continues a stopped run as the same run under a new epoch.
|
|
1855
|
+
// Lifecycle facts from an earlier epoch are stale whatever the run's state
|
|
1856
|
+
// (a late redelivery of the earlier ending must not end the resumed run),
|
|
1857
|
+
// and a resume from a later epoch reopens a finished run.
|
|
1858
|
+
const snapshotEpoch = normalizeResumeEpoch(snapshot.resumeEpoch);
|
|
1859
|
+
const eventEpoch = normalizeResumeEpoch(event.resumeEpoch);
|
|
1860
|
+
// Endings and resumes always carry their epoch (an ending's is in its
|
|
1861
|
+
// event id); a stale one must not end or reopen the current epoch. Waits,
|
|
1862
|
+
// wakes and starts carry none, so they describe the current epoch.
|
|
1863
|
+
if (
|
|
1864
|
+
eventEpoch < snapshotEpoch &&
|
|
1865
|
+
(isRunEndingEvent(event) ||
|
|
1866
|
+
(isEpochScopedLedgerEvent(event) && event.resumeEpoch !== undefined))
|
|
1867
|
+
) {
|
|
1868
|
+
return snapshot;
|
|
1869
|
+
}
|
|
1870
|
+
if (event.type === RUN_EVENT_KIND.runResumed && eventEpoch > snapshotEpoch) {
|
|
1871
|
+
const occurredAt = Math.max(0, event.occurredAt);
|
|
1872
|
+
const stepsById = Object.fromEntries(
|
|
1873
|
+
Object.entries(snapshot.stepsById).map(([id, step]) => {
|
|
1874
|
+
if (step.status !== 'failed') return [id, step];
|
|
1875
|
+
const { stoppedBy: _stoppedBy, ...unfinished } = step;
|
|
1876
|
+
return [
|
|
1877
|
+
id,
|
|
1878
|
+
{
|
|
1879
|
+
...unfinished,
|
|
1880
|
+
status: 'running' as const,
|
|
1881
|
+
error: null,
|
|
1882
|
+
completedAt: null,
|
|
1883
|
+
updatedAt: occurredAt,
|
|
1884
|
+
progress: step.progress
|
|
1885
|
+
? {
|
|
1886
|
+
...step.progress,
|
|
1887
|
+
error: undefined,
|
|
1888
|
+
completedAt: null,
|
|
1889
|
+
updatedAt: occurredAt,
|
|
1890
|
+
}
|
|
1891
|
+
: step.progress,
|
|
1892
|
+
},
|
|
1893
|
+
];
|
|
1894
|
+
}),
|
|
1895
|
+
);
|
|
1896
|
+
const activeStepId =
|
|
1897
|
+
snapshot.orderedStepIds
|
|
1898
|
+
.filter((id) => stepsById[id]?.status === 'running')
|
|
1899
|
+
.at(-1) ?? null;
|
|
1900
|
+
return {
|
|
1901
|
+
...snapshot,
|
|
1902
|
+
stepsById,
|
|
1903
|
+
activeStepId,
|
|
1904
|
+
activeArtifactTableNamespace: activeStepId
|
|
1905
|
+
? (stepsById[activeStepId]?.artifactTableNamespace ?? null)
|
|
1906
|
+
: null,
|
|
1907
|
+
resumeEpoch: eventEpoch,
|
|
1908
|
+
status: 'running',
|
|
1909
|
+
waitKind: null,
|
|
1910
|
+
waitUntil: null,
|
|
1911
|
+
error: null,
|
|
1912
|
+
finishedAt: null,
|
|
1913
|
+
durationMs: null,
|
|
1914
|
+
result: undefined,
|
|
1915
|
+
resultSummary: undefined,
|
|
1916
|
+
terminalSource: null,
|
|
1917
|
+
terminalWorkCounterSegment: undefined,
|
|
1918
|
+
terminalRuntimePerformance: undefined,
|
|
1919
|
+
terminalRuntimePerformanceUnavailableReason: undefined,
|
|
1920
|
+
activeActivityId: null,
|
|
1921
|
+
activitiesById: Object.fromEntries(
|
|
1922
|
+
Object.entries(snapshot.activitiesById).filter(
|
|
1923
|
+
([id]) =>
|
|
1924
|
+
id !== PLATFORM_RECOVERY_ACTIVITY_ID &&
|
|
1925
|
+
id !== CANCELLATION_CLEANUP_ACTIVITY_ID,
|
|
1926
|
+
),
|
|
1927
|
+
),
|
|
1928
|
+
orderedActivityIds: snapshot.orderedActivityIds.filter(
|
|
1929
|
+
(id) =>
|
|
1930
|
+
id !== PLATFORM_RECOVERY_ACTIVITY_ID &&
|
|
1931
|
+
id !== CANCELLATION_CLEANUP_ACTIVITY_ID,
|
|
1932
|
+
),
|
|
1933
|
+
updatedAt: Math.max(snapshot.updatedAt ?? 0, occurredAt),
|
|
1934
|
+
};
|
|
1935
|
+
}
|
|
1810
1936
|
// A terminal Run Snapshot is immutable with respect to step lifecycle.
|
|
1811
1937
|
// Detached runners can race their best-effort progress transport against the
|
|
1812
1938
|
// terminal outbox, and gateway processes can restart or split that traffic.
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
readRowFailureCounts,
|
|
9
9
|
type RowFailureCounts,
|
|
10
10
|
} from '../row-failure-summary';
|
|
11
|
+
import { createFixtureEgressFetch } from '../fixture-egress-fetch';
|
|
11
12
|
import { RUN_EVENT_KIND } from '../run-event-catalog';
|
|
12
13
|
import { hydratePlayRunnerConfig } from '../protocol';
|
|
13
14
|
import { appendFileSync, createReadStream, writeFileSync } from 'node:fs';
|
|
@@ -234,6 +235,26 @@ const safeNodeOutboundFetch = sandboxRuntimeAppFetch((async (
|
|
|
234
235
|
return safeOutboundFetch(input, init);
|
|
235
236
|
}) as typeof fetch);
|
|
236
237
|
|
|
238
|
+
function fixtureCtxFetch(
|
|
239
|
+
config: Pick<PlayRunnerExecutionConfig, 'context'>,
|
|
240
|
+
): ReturnType<typeof createFixtureEgressFetch> {
|
|
241
|
+
const baseUrl =
|
|
242
|
+
config.context.executionGatewayBaseUrl?.trim() || config.context.baseUrl;
|
|
243
|
+
const executorToken = config.context.executorToken;
|
|
244
|
+
if (!baseUrl || !executorToken) {
|
|
245
|
+
return async (input) => {
|
|
246
|
+
throw new Error(
|
|
247
|
+
`Fixture ctx.fetch(${String(input)}) requires executorToken and baseUrl.`,
|
|
248
|
+
);
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
return createFixtureEgressFetch({
|
|
252
|
+
baseUrl,
|
|
253
|
+
executorToken,
|
|
254
|
+
extraHeaders: () => vercelBypassHeaders(config),
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
237
258
|
const safeNodeStreamingOutboundFetch = sandboxRuntimeAppFetch((async (
|
|
238
259
|
input: string | URL,
|
|
239
260
|
init?: RequestInit,
|
|
@@ -1400,6 +1421,15 @@ function emitSystemLog(line: string, options?: ExecutePlayRunnerOptions): void {
|
|
|
1400
1421
|
export function playRunnerContextCachePolicy(
|
|
1401
1422
|
context: PlayRunnerExecutionConfig['context'],
|
|
1402
1423
|
): ContextOptions['cachePolicy'] | undefined {
|
|
1424
|
+
// A person resumed this run after fixing what made it stop, so calls that
|
|
1425
|
+
// failed before the resume run again. Successes stay recorded: only failed
|
|
1426
|
+
// receipts are re-claimable, and completed calls return from history.
|
|
1427
|
+
// Automatic retries within one epoch keep failed calls failed.
|
|
1428
|
+
const resumed =
|
|
1429
|
+
typeof context.resumeEpoch === 'number' && context.resumeEpoch > 0;
|
|
1430
|
+
if (resumed && !context.force && !context.forceToolRefresh) {
|
|
1431
|
+
return { forceFailedToolRefresh: true };
|
|
1432
|
+
}
|
|
1403
1433
|
if (context.forceToolRefresh) {
|
|
1404
1434
|
return {
|
|
1405
1435
|
...(context.force ? { forceStepRefresh: true } : {}),
|
|
@@ -2523,7 +2553,12 @@ async function run(
|
|
|
2523
2553
|
abortSignal: persistenceSignal,
|
|
2524
2554
|
scope,
|
|
2525
2555
|
}),
|
|
2526
|
-
|
|
2556
|
+
// A fixture run answers ctx.fetch from the fixture egress route; it must
|
|
2557
|
+
// never reach the network.
|
|
2558
|
+
fetchImpl:
|
|
2559
|
+
config.context.integrationMode === 'fixture'
|
|
2560
|
+
? fixtureCtxFetch(config)
|
|
2561
|
+
: safeNodeStreamingOutboundFetch,
|
|
2527
2562
|
vercelProtectionBypassToken: config.context.vercelProtectionBypassToken,
|
|
2528
2563
|
orgId: config.context.orgId,
|
|
2529
2564
|
userEmail: config.context.userEmail,
|
|
@@ -2592,6 +2627,7 @@ async function run(
|
|
|
2592
2627
|
config.context.runId ??
|
|
2593
2628
|
config.context.workflowId,
|
|
2594
2629
|
runAttempt: runnerRunAttempt,
|
|
2630
|
+
...(config.context.runScopedKeys === true ? { runScopedKeys: true } : {}),
|
|
2595
2631
|
staticPipeline: config.context.staticPipeline,
|
|
2596
2632
|
checkpoint: config.checkpoint ?? undefined,
|
|
2597
2633
|
durableBoundaries: true,
|
|
@@ -3550,6 +3586,7 @@ async function run(
|
|
|
3550
3586
|
workCounterTimer.unref();
|
|
3551
3587
|
|
|
3552
3588
|
try {
|
|
3589
|
+
await ctx.markRunReplayTracked();
|
|
3553
3590
|
emitWorkerLog('Play started', options);
|
|
3554
3591
|
const rawResult = await executeRuntimePlayCode({
|
|
3555
3592
|
artifact: config.artifact,
|
|
@@ -21,10 +21,7 @@ import axios, { type InternalAxiosRequestConfig } from 'axios';
|
|
|
21
21
|
import { Readable } from 'node:stream';
|
|
22
22
|
import type { DaytonaClientOptions } from '../../daytona-runtime-config';
|
|
23
23
|
import type { CreateSandboxFromSnapshotParams } from '@daytonaio/sdk';
|
|
24
|
-
import type {
|
|
25
|
-
DaytonaDeleteRetryAuthorization,
|
|
26
|
-
DaytonaDomainAllowListParam,
|
|
27
|
-
} from './daytona-lifecycle';
|
|
24
|
+
import type { DaytonaDeleteRetryAuthorization } from './daytona-lifecycle';
|
|
28
25
|
import {
|
|
29
26
|
DAYTONA_CONTROL_TIMEOUT_MS,
|
|
30
27
|
DaytonaControlTimeoutError,
|
|
@@ -561,7 +558,7 @@ export function createDaytonaLaunchClient(
|
|
|
561
558
|
resolvedDomains.set(sandbox, organizationId.trim());
|
|
562
559
|
},
|
|
563
560
|
async create(
|
|
564
|
-
params: CreateSandboxFromSnapshotParams
|
|
561
|
+
params: CreateSandboxFromSnapshotParams,
|
|
565
562
|
options: { timeout?: number } = {},
|
|
566
563
|
) {
|
|
567
564
|
const timeoutMs = (options.timeout ?? 60) * 1_000;
|
|
@@ -600,10 +597,6 @@ export function createDaytonaLaunchClient(
|
|
|
600
597
|
volumes: params.volumes,
|
|
601
598
|
networkBlockAll: params.networkBlockAll,
|
|
602
599
|
networkAllowList: params.networkAllowList,
|
|
603
|
-
// Pinned Runtime gateway host only; absent on every other run.
|
|
604
|
-
...(params.domainAllowList
|
|
605
|
-
? { domainAllowList: params.domainAllowList }
|
|
606
|
-
: {}),
|
|
607
600
|
linkedSandbox: params.linkedSandbox,
|
|
608
601
|
},
|
|
609
602
|
undefined,
|