deepline 0.3.537 → 0.3.538
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 +22 -5
- package/dist/bundling-sources/sdk/src/index.ts +2 -0
- package/dist/bundling-sources/sdk/src/plays/client-core.ts +18 -1
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +33 -4
- package/dist/bundling-sources/shared_libs/integration-contracts/billing-entitlements.ts +1 -1
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +18 -0
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/baked-runner-image.ts +330 -0
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +717 -133
- package/dist/bundling-sources/shared_libs/play-runtime/coordinator-headers.ts +7 -0
- package/dist/bundling-sources/shared_libs/play-runtime/daytona-payload-contract.ts +22 -1
- package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +123 -0
- package/dist/bundling-sources/shared_libs/play-runtime/experiment-switches.ts +480 -0
- package/dist/bundling-sources/shared_libs/play-runtime/fixture-egress-fetch.ts +24 -16
- package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +293 -53
- package/dist/bundling-sources/shared_libs/play-runtime/governor/block-reserving-budget-state-backend.ts +57 -2
- package/dist/bundling-sources/shared_libs/play-runtime/governor/budget-state-backend.ts +43 -0
- package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +141 -9
- package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/modal-runtime-config.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/modal-supervisor-sidecar.ts +556 -0
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +27 -0
- package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +19 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +54 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +5 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +155 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/relay-connection-counter.ts +103 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-heartbeat.ts +75 -6
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-terminal-push.ts +59 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +544 -73
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-runtime-watchdog.ts +8 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/detached-runner-readiness-pacing.ts +19 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +2390 -110
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-flow.ts +42 -8
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-read-through.ts +287 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-finish.ts +606 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-writer.ts +274 -119
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-traffic-policy.ts +54 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-work-counters.ts +10 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +15 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-run-task.ts +18 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +18 -4
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +219 -7
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +3 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-claim-affinity.ts +340 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/play-run-recovery.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +10 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +623 -7
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +340 -5
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runner-push.ts +61 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +2 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-ledger-reconciliation.ts +269 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +238 -5
- package/dist/bundling-sources/shared_libs/play-runtime/startup-read-tool-ids.ts +47 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-call/runtime-step-receipts-adapter.ts +5 -4
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/transient-service-error.ts +11 -0
- package/dist/cli/auth-4WEVLYK4.js +43 -0
- package/dist/cli/{auth-4SUPGDIM.mjs → auth-KYH7N7RQ.mjs} +5 -5
- package/dist/cli/{billing-SQU726P7.js → billing-4KTUVZ4S.js} +114 -90
- package/dist/cli/{billing-5JUA3ZM3.mjs → billing-WK346KAI.mjs} +31 -7
- package/dist/cli/{chunk-KULT6O5K.js → chunk-25RGHJQL.js} +15 -15
- package/dist/cli/{chunk-PJ4ZGZAN.js → chunk-34PLG5OE.js} +13 -13
- package/dist/cli/{chunk-37AZHCTP.mjs → chunk-35OCRH5C.mjs} +5 -5
- package/dist/cli/{chunk-JMHYDDBQ.js → chunk-3I5TU5XE.js} +292 -279
- package/dist/cli/{chunk-Y6AMMXWS.mjs → chunk-4KZF6OYY.mjs} +3 -3
- package/dist/cli/{chunk-BRRCWUOW.mjs → chunk-4NEOGPKD.mjs} +1 -1
- package/dist/cli/{chunk-NU7B5X6J.mjs → chunk-4WQR4DG4.mjs} +1 -1
- package/dist/cli/{chunk-AVQET3NR.js → chunk-5VSPRRTI.js} +7 -7
- package/dist/cli/{chunk-EEFSUCYP.mjs → chunk-6JG3MRTM.mjs} +2 -2
- package/dist/cli/{chunk-D77W6Q67.js → chunk-6SLQLWWL.js} +26 -26
- package/dist/cli/{chunk-ZUAMXZXC.mjs → chunk-7XDJKIM2.mjs} +4 -4
- package/dist/cli/{chunk-C37VELBR.mjs → chunk-A6E7TCK2.mjs} +5 -5
- package/dist/cli/{chunk-JS2SBCWD.js → chunk-ADLDU2QG.js} +6 -6
- package/dist/cli/{chunk-VP2K5B3R.mjs → chunk-ALARRSMZ.mjs} +3 -3
- package/dist/cli/{chunk-CHIGEDAE.js → chunk-B2BTBHX2.js} +3 -3
- package/dist/cli/{chunk-CFND2ACL.js → chunk-BBS2BLPV.js} +16 -16
- package/dist/cli/{chunk-QDBGPRR2.mjs → chunk-CLO562KG.mjs} +3 -1
- package/dist/cli/{chunk-CXTW7SRW.mjs → chunk-E7D37PLM.mjs} +8 -0
- package/dist/cli/{chunk-UGA5KI4A.js → chunk-ESX3H7Q7.js} +22 -22
- package/dist/cli/{chunk-BFHR7IC2.mjs → chunk-FJ5KPGCS.mjs} +10 -10
- package/dist/cli/{chunk-R7JYG6XO.mjs → chunk-FWE37N2P.mjs} +1 -1
- package/dist/cli/{chunk-K4WJ4BYO.mjs → chunk-ICTA5ICE.mjs} +1 -1
- package/dist/cli/{chunk-PU42VOBI.js → chunk-IMLFB66A.js} +3 -3
- package/dist/cli/{chunk-GI3V4D7K.mjs → chunk-IP3XJTWA.mjs} +2 -2
- package/dist/cli/{chunk-WBFOV5HT.js → chunk-JCLRSMUP.js} +5 -5
- package/dist/cli/{chunk-L3JVGNAT.mjs → chunk-JPEBKN3K.mjs} +2 -2
- package/dist/cli/{chunk-Z2PPB3IO.mjs → chunk-JTOV5RUA.mjs} +1 -1
- package/dist/cli/{chunk-WBTYWJLN.js → chunk-KCUQNH4K.js} +2 -2
- package/dist/cli/{chunk-C3XD2WHM.mjs → chunk-KNIYEZVV.mjs} +2 -2
- package/dist/cli/{chunk-3PMCQ3LK.js → chunk-LPTBHNGB.js} +7 -5
- package/dist/cli/{chunk-KH27B2HJ.mjs → chunk-M3NCXGNN.mjs} +2 -2
- package/dist/cli/{chunk-XDS26J7Z.js → chunk-MNBIGX6O.js} +10 -10
- package/dist/cli/{chunk-L6QAIZNZ.js → chunk-MYSPQUAO.js} +44 -44
- package/dist/cli/{chunk-W3J3LT22.mjs → chunk-N2BCPZVR.mjs} +5 -5
- package/dist/cli/{chunk-ZFSB7GXF.js → chunk-N5HSG4OV.js} +5 -5
- package/dist/cli/{chunk-2Q7VXTMS.js → chunk-O765M4LT.js} +2 -2
- package/dist/cli/{chunk-QPDLG7DQ.js → chunk-OOLBE6FR.js} +53 -53
- package/dist/cli/{chunk-IQOIT6E3.js → chunk-P3DP56HB.js} +41 -41
- package/dist/cli/{chunk-BGXEMTIG.js → chunk-PQKD5DMT.js} +19 -19
- package/dist/cli/{chunk-V5IIBG2E.mjs → chunk-T6GPTJ5F.mjs} +1 -1
- package/dist/cli/{chunk-GPMS6OPX.mjs → chunk-TWWYCJJW.mjs} +5 -5
- package/dist/cli/{chunk-ZHPSJ3LJ.mjs → chunk-UE7JHAZ2.mjs} +29 -16
- package/dist/cli/{chunk-VRYX2BR4.js → chunk-UEZNIPFO.js} +107 -107
- package/dist/cli/{chunk-AX2OAXDL.mjs → chunk-VCHV4LS3.mjs} +1 -1
- package/dist/cli/{chunk-NXGLJGPB.js → chunk-VIFLWQXS.js} +2 -2
- package/dist/cli/{chunk-6BBGUQJJ.js → chunk-XTYHZEJ2.js} +8 -0
- package/dist/cli/{chunk-5EOEJKSV.js → chunk-YQURGSRB.js} +1 -1
- package/dist/cli/{chunk-ALHKB3AE.js → chunk-YZ2ZPHWR.js} +9 -9
- package/dist/cli/{chunk-CGDW2CRR.mjs → chunk-ZDLDCXY3.mjs} +2 -2
- package/dist/cli/{chunk-RMVZTBI5.mjs → chunk-ZU6JBRV5.mjs} +4 -4
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/{csv-HZP6QMG7.mjs → csv-2YKLUKDR.mjs} +4 -4
- package/dist/cli/{csv-JITYN27L.js → csv-LM7FBECI.js} +13 -13
- package/dist/cli/{db-QRIRTOMM.mjs → db-234UBWJH.mjs} +6 -6
- package/dist/cli/{db-FYSRB7O4.js → db-5PMA4IVW.js} +27 -27
- package/dist/cli/describe-C7GOSGYB.js +49 -0
- package/dist/cli/{describe-REXJVJC3.mjs → describe-W26LW5O7.mjs} +17 -17
- package/dist/cli/describe-core.d.mts +3 -3
- package/dist/cli/describe-core.d.ts +3 -3
- package/dist/cli/{executions-BSTF4DDS.js → executions-3S736GXX.js} +8 -8
- package/dist/cli/{executions-53KJAFOW.mjs → executions-GD7GXTJM.mjs} +6 -6
- package/dist/cli/{feedback-6MW3QOXX.js → feedback-BUWTDY4R.js} +14 -14
- package/dist/cli/{feedback-CWUJJF3J.mjs → feedback-GBV5HJJZ.mjs} +6 -6
- package/dist/cli/git-YG36MROC.js +25 -0
- package/dist/cli/{git-CKVZTJFS.mjs → git-YXJGTDQL.mjs} +5 -5
- package/dist/cli/index.js +143 -143
- package/dist/cli/index.mjs +42 -42
- package/dist/cli/{legacy-noops-USTBRFRX.mjs → legacy-noops-UJM6GBNP.mjs} +6 -6
- package/dist/cli/{legacy-noops-QBL4PNGB.js → legacy-noops-ZSF64V2U.js} +9 -9
- package/dist/cli/{monitors-6UCG5D7W.mjs → monitors-UERUQ6CT.mjs} +7 -7
- package/dist/cli/{monitors-VCR6SUZD.js → monitors-XQ2GNH6D.js} +100 -100
- package/dist/cli/{org-GSRBOJVO.mjs → org-CP4VLH6M.mjs} +6 -6
- package/dist/cli/{org-HPILTEG4.js → org-IF6MPVNR.js} +86 -86
- package/dist/cli/{play-TK7WOP5H.js → play-2NHQO5MO.js} +317 -317
- package/dist/cli/{play-QRTYQNG4.mjs → play-ZWDYYVPI.mjs} +17 -17
- package/dist/cli/{providers-OAQJWVBS.mjs → providers-2CVIATU4.mjs} +6 -6
- package/dist/cli/{providers-HEXNJ5QC.js → providers-LOPXQN56.js} +9 -9
- package/dist/cli/{quickstart-FFVHTPSP.mjs → quickstart-KVCFXLID.mjs} +4 -4
- package/dist/cli/{quickstart-PYZTFXZX.js → quickstart-N4WDEQZY.js} +6 -6
- package/dist/cli/{run-4DWJXJRO.js → run-BDT5LK3I.js} +42 -42
- package/dist/cli/{run-HLN6YYZH.mjs → run-RUXHYWLF.mjs} +22 -22
- package/dist/cli/search-ATDDVADT.js +32 -0
- package/dist/cli/{search-ZHRCXGEL.mjs → search-BFUTNPA5.mjs} +7 -7
- package/dist/cli/{search-output-2KY6PFDH.js → search-output-CTXI2QZU.js} +6 -6
- package/dist/cli/{search-output-N7QXACVK.mjs → search-output-WUGH4PZA.mjs} +4 -4
- package/dist/cli/{secrets-WXQ7XO5C.js → secrets-BZJZYFOU.js} +15 -15
- package/dist/cli/{secrets-FKMWBLHU.mjs → secrets-Z4XQVTC6.mjs} +6 -6
- package/dist/cli/sessions-HNU35AFM.js +22 -0
- package/dist/cli/{sessions-3YDTEDA5.mjs → sessions-VZXR3MQZ.mjs} +6 -6
- package/dist/cli/{settings-JTPASUZN.mjs → settings-VYEZFR4L.mjs} +12 -12
- package/dist/cli/{settings-67TWLQ6E.js → settings-WBYA4JMM.js} +85 -85
- package/dist/cli/{setup-KUERQJUX.js → setup-FS2RMSS2.js} +49 -49
- package/dist/cli/{setup-VYNGXUJ6.mjs → setup-H7KCI4SO.mjs} +9 -9
- package/dist/cli/skills-VPIURCAZ.js +36 -0
- package/dist/cli/{skills-KI4KYHH6.mjs → skills-YQNSJUUG.mjs} +7 -7
- package/dist/cli/tools-273GS5HU.js +56 -0
- package/dist/cli/{tools-UQDJS2RS.mjs → tools-ZF6SVEGW.mjs} +16 -16
- package/dist/cli/{update-7FQQUBOD.mjs → update-RKQNNJM4.mjs} +9 -9
- package/dist/cli/update-TOD3XY55.js +34 -0
- package/dist/cli/{views-JAM4MNNV.mjs → views-JHHOTWDU.mjs} +6 -6
- package/dist/cli/{views-MJK7JGZG.js → views-KN7FEDGT.js} +21 -21
- package/dist/cli/{workflow-AQPRIWQX.js → workflow-2WHSKTTV.js} +17 -17
- package/dist/cli/{workflow-TQRV5FGO.mjs → workflow-AAYLCLWA.mjs} +7 -7
- package/dist/{client-BlLYQDNo.d.mts → client-D0uDBybG.d.mts} +1 -1
- package/dist/{client-DSQlkIDO.d.ts → client-DZTnAv4B.d.ts} +1 -1
- package/dist/{client-core-rX7n2H8U.d.mts → client-core-BhWf8Y1b.d.mts} +15 -2
- package/dist/{client-core-CDwapXy5.d.ts → client-core-og3AP1LL.d.ts} +15 -2
- package/dist/{compiler-manifest-BHNC4RL-.d.ts → compiler-manifest-Bes3OVA3.d.mts} +1 -1
- package/dist/{compiler-manifest-BHNC4RL-.d.mts → compiler-manifest-Bes3OVA3.d.ts} +1 -1
- package/dist/{errors-lhtIWG5Z.d.ts → errors-BJm4lLWc.d.ts} +1 -1
- package/dist/{errors-D7sPXrvB.d.mts → errors-Dc5r42ks.d.mts} +1 -1
- package/dist/{index-CQTBHXHr.d.ts → index-BfV7mRPF.d.ts} +1 -1
- package/dist/{index-NaDZq2xf.d.mts → index-DTkiz_Ur.d.mts} +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 +120 -112
- package/dist/plays/bundle-play-file.d.mts +3 -3
- package/dist/plays/bundle-play-file.d.ts +3 -3
- 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-Y2K2ZYYA.js +0 -43
- package/dist/cli/describe-LSOHOLFI.js +0 -49
- package/dist/cli/git-S7SWUZ3T.js +0 -25
- package/dist/cli/search-WERQBC6V.js +0 -32
- package/dist/cli/sessions-LXQ4Q6BS.js +0 -22
- package/dist/cli/skills-EFRLHY3F.js +0 -36
- package/dist/cli/tools-C3EIGFFP.js +0 -56
- package/dist/cli/update-KCY72RXH.js +0 -34
|
@@ -167,6 +167,9 @@ export type PlayRunLedgerWorkCounters = {
|
|
|
167
167
|
providerRequests: number;
|
|
168
168
|
provider429s: number;
|
|
169
169
|
final: boolean;
|
|
170
|
+
reusableResultCalls?: number;
|
|
171
|
+
completedReusableResultCalls?: number;
|
|
172
|
+
reuseConsistent?: boolean;
|
|
170
173
|
completedLogicalCalls: number;
|
|
171
174
|
completedProviderRequests: number;
|
|
172
175
|
completedProvider429s: number;
|
|
@@ -395,6 +398,7 @@ export type PlayRunLedgerEvent =
|
|
|
395
398
|
attempt: number;
|
|
396
399
|
invocationSeq: number;
|
|
397
400
|
segmentId: string;
|
|
401
|
+
reusableResultCalls?: number;
|
|
398
402
|
logicalCalls: number;
|
|
399
403
|
providerRequests: number;
|
|
400
404
|
provider429s: number;
|
|
@@ -550,6 +554,23 @@ export function hasConfirmedPlayRunLedgerWorkCounters(
|
|
|
550
554
|
);
|
|
551
555
|
}
|
|
552
556
|
|
|
557
|
+
/** Verified new retained-result consumers; missing/gapped reports stay unknown. */
|
|
558
|
+
export function confirmedReusableResultCalls(
|
|
559
|
+
snapshot: PlayRunLedgerSnapshot,
|
|
560
|
+
): number | null {
|
|
561
|
+
const counters = snapshot.workCounters;
|
|
562
|
+
if (
|
|
563
|
+
!hasConfirmedPlayRunLedgerWorkCounters(snapshot) ||
|
|
564
|
+
counters?.reuseConsistent !== true ||
|
|
565
|
+
!nonnegativeSafeInteger(counters.reusableResultCalls) ||
|
|
566
|
+
!nonnegativeSafeInteger(counters.completedReusableResultCalls)
|
|
567
|
+
)
|
|
568
|
+
return null;
|
|
569
|
+
const total =
|
|
570
|
+
counters.reusableResultCalls! + counters.completedReusableResultCalls!;
|
|
571
|
+
return Number.isSafeInteger(total) ? total : null;
|
|
572
|
+
}
|
|
573
|
+
|
|
553
574
|
function normalizeWorkCounters(
|
|
554
575
|
value: unknown,
|
|
555
576
|
): PlayRunLedgerWorkCounters | undefined {
|
|
@@ -621,6 +642,20 @@ function advanceNextWorkCounterSegment(
|
|
|
621
642
|
logicalCalls: event.logicalCalls,
|
|
622
643
|
providerRequests: event.providerRequests,
|
|
623
644
|
provider429s: event.provider429s,
|
|
645
|
+
reusableResultCalls: nonnegativeSafeInteger(event.reusableResultCalls)
|
|
646
|
+
? event.reusableResultCalls
|
|
647
|
+
: undefined,
|
|
648
|
+
completedReusableResultCalls:
|
|
649
|
+
nonnegativeSafeInteger(current.completedReusableResultCalls) &&
|
|
650
|
+
nonnegativeSafeInteger(current.reusableResultCalls) &&
|
|
651
|
+
Number.isSafeInteger(
|
|
652
|
+
current.completedReusableResultCalls! + current.reusableResultCalls!,
|
|
653
|
+
)
|
|
654
|
+
? current.completedReusableResultCalls! + current.reusableResultCalls!
|
|
655
|
+
: undefined,
|
|
656
|
+
reuseConsistent:
|
|
657
|
+
current.reuseConsistent === true &&
|
|
658
|
+
nonnegativeSafeInteger(event.reusableResultCalls),
|
|
624
659
|
final: event.final === true,
|
|
625
660
|
completedLogicalCalls: Math.min(
|
|
626
661
|
completedLogicalCalls,
|
|
@@ -667,6 +702,11 @@ function advanceWorkCounters(
|
|
|
667
702
|
logicalCalls: event.logicalCalls,
|
|
668
703
|
providerRequests: event.providerRequests,
|
|
669
704
|
provider429s: event.provider429s,
|
|
705
|
+
reusableResultCalls: nonnegativeSafeInteger(event.reusableResultCalls)
|
|
706
|
+
? event.reusableResultCalls
|
|
707
|
+
: undefined,
|
|
708
|
+
completedReusableResultCalls: 0,
|
|
709
|
+
reuseConsistent: nonnegativeSafeInteger(event.reusableResultCalls),
|
|
670
710
|
final: event.final === true,
|
|
671
711
|
completedLogicalCalls: 0,
|
|
672
712
|
completedProviderRequests: 0,
|
|
@@ -698,6 +738,20 @@ function advanceWorkCounters(
|
|
|
698
738
|
event.providerRequests,
|
|
699
739
|
),
|
|
700
740
|
provider429s: Math.max(current.provider429s, event.provider429s),
|
|
741
|
+
reusableResultCalls: nonnegativeSafeInteger(event.reusableResultCalls)
|
|
742
|
+
? Math.max(current.reusableResultCalls ?? 0, event.reusableResultCalls!)
|
|
743
|
+
: current.reusableResultCalls,
|
|
744
|
+
reuseConsistent:
|
|
745
|
+
current.reuseConsistent === true &&
|
|
746
|
+
nonnegativeSafeInteger(event.reusableResultCalls) &&
|
|
747
|
+
!(
|
|
748
|
+
event.final &&
|
|
749
|
+
event.reusableResultCalls! < (current.reusableResultCalls ?? 0)
|
|
750
|
+
) &&
|
|
751
|
+
!(
|
|
752
|
+
current.final &&
|
|
753
|
+
event.reusableResultCalls! > (current.reusableResultCalls ?? 0)
|
|
754
|
+
),
|
|
701
755
|
final: current.final || event.final === true,
|
|
702
756
|
consistent:
|
|
703
757
|
current.consistent &&
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
LOG_TAIL_LIMIT,
|
|
8
8
|
hasConfirmedPlayRunLedgerWorkCounters,
|
|
9
|
+
confirmedReusableResultCalls,
|
|
9
10
|
normalizePlayRunLedgerSnapshot,
|
|
10
11
|
summarizeRunRowOutcomes,
|
|
11
12
|
type PlayRunLedgerSnapshot,
|
|
@@ -128,6 +129,8 @@ export type PlayRunLiveSnapshot = {
|
|
|
128
129
|
providerRequests: number;
|
|
129
130
|
provider429s: number;
|
|
130
131
|
confirmed: boolean;
|
|
132
|
+
/** Present only when this metric has complete accepted-terminal evidence. */
|
|
133
|
+
reusableResultCalls?: number;
|
|
131
134
|
};
|
|
132
135
|
};
|
|
133
136
|
|
|
@@ -273,6 +276,7 @@ function buildSnapshotFromLedger(
|
|
|
273
276
|
? terminalRowOutcomes
|
|
274
277
|
: null;
|
|
275
278
|
const workCounters = snapshot.workCounters;
|
|
279
|
+
const reusableResultCalls = confirmedReusableResultCalls(snapshot);
|
|
276
280
|
const calls = workCounters
|
|
277
281
|
? {
|
|
278
282
|
logicalCalls:
|
|
@@ -285,6 +289,7 @@ function buildSnapshotFromLedger(
|
|
|
285
289
|
confirmed:
|
|
286
290
|
isTerminalPlayRunLiveStatus(liveStatus) &&
|
|
287
291
|
hasConfirmedPlayRunLedgerWorkCounters(snapshot),
|
|
292
|
+
...(reusableResultCalls !== null ? { reusableResultCalls } : {}),
|
|
288
293
|
}
|
|
289
294
|
: null;
|
|
290
295
|
return {
|
|
@@ -10,6 +10,11 @@ import {
|
|
|
10
10
|
import { createFixtureEgressFetch } from '../fixture-egress-fetch';
|
|
11
11
|
import { RUN_EVENT_KIND } from '../run-event-catalog';
|
|
12
12
|
import { hydratePlayRunnerConfig } from '../protocol';
|
|
13
|
+
import { DURABLE_RUNS_ROLLOUT } from '../durable-runs-rollout';
|
|
14
|
+
import {
|
|
15
|
+
readStartupReadToolIds,
|
|
16
|
+
staticPipelineStartupReadToolIds,
|
|
17
|
+
} from '../startup-read-tool-ids';
|
|
13
18
|
import { appendFileSync, createReadStream, writeFileSync } from 'node:fs';
|
|
14
19
|
import { readFile } from 'node:fs/promises';
|
|
15
20
|
import { dirname, isAbsolute, resolve } from 'node:path';
|
|
@@ -87,6 +92,10 @@ import {
|
|
|
87
92
|
type RunnerProgressPusher,
|
|
88
93
|
} from './runtime-progress-push';
|
|
89
94
|
import { collectStartupEgressProbeLines } from './egress-probe';
|
|
95
|
+
import {
|
|
96
|
+
startRelayConnectionCounter,
|
|
97
|
+
type RelayConnectionCounter,
|
|
98
|
+
} from './relay-connection-counter';
|
|
90
99
|
import {
|
|
91
100
|
pushRunnerTerminal,
|
|
92
101
|
runnerTerminalResultForTransport,
|
|
@@ -230,6 +239,7 @@ async function safeNodeOutboundFetch(
|
|
|
230
239
|
|
|
231
240
|
function fixtureCtxFetch(
|
|
232
241
|
config: Pick<PlayRunnerExecutionConfig, 'context'>,
|
|
242
|
+
envelope: 'fixture' | 'broker' = 'fixture',
|
|
233
243
|
): ReturnType<typeof createFixtureEgressFetch> {
|
|
234
244
|
const baseUrl =
|
|
235
245
|
config.context.executionGatewayBaseUrl?.trim() || config.context.baseUrl;
|
|
@@ -245,6 +255,7 @@ function fixtureCtxFetch(
|
|
|
245
255
|
baseUrl,
|
|
246
256
|
executorToken,
|
|
247
257
|
extraHeaders: () => vercelBypassHeaders(config),
|
|
258
|
+
envelope,
|
|
248
259
|
});
|
|
249
260
|
}
|
|
250
261
|
|
|
@@ -596,6 +607,91 @@ export class RunnerRuntimeControlRedirectError extends Error {
|
|
|
596
607
|
}
|
|
597
608
|
}
|
|
598
609
|
|
|
610
|
+
/**
|
|
611
|
+
* Read-only startup lookups issued during the park fence
|
|
612
|
+
* (`DURABLE_RUNS_ROLLOUT.runnerStartupReadPrefetch`). Keyed by exact URL; a
|
|
613
|
+
* GET for that URL consumes one successful (200) answer once. Anything else,
|
|
614
|
+
* including a failed or non-200 prefetch, falls through to the unchanged
|
|
615
|
+
* request path with its own retries and errors.
|
|
616
|
+
*/
|
|
617
|
+
const runnerStartupReadPrefetch = new Map<
|
|
618
|
+
string,
|
|
619
|
+
Promise<{ status: number; headers: [string, string][]; body: string } | null>
|
|
620
|
+
>();
|
|
621
|
+
|
|
622
|
+
export function prefetchRunnerRuntimeControlGet(
|
|
623
|
+
url: string,
|
|
624
|
+
headers: Record<string, string>,
|
|
625
|
+
fetchImpl: typeof fetch = fetch,
|
|
626
|
+
): void {
|
|
627
|
+
if (runnerStartupReadPrefetch.has(url)) return;
|
|
628
|
+
runnerStartupReadPrefetch.set(
|
|
629
|
+
url,
|
|
630
|
+
fetchImpl(url, {
|
|
631
|
+
method: 'GET',
|
|
632
|
+
headers,
|
|
633
|
+
redirect: 'manual',
|
|
634
|
+
signal: AbortSignal.timeout(RUNNER_RUNTIME_CONTROL_REQUEST_TIMEOUT_MS),
|
|
635
|
+
}).then(
|
|
636
|
+
async (response) =>
|
|
637
|
+
response.status === 200
|
|
638
|
+
? {
|
|
639
|
+
status: response.status,
|
|
640
|
+
headers: [...response.headers.entries()],
|
|
641
|
+
body: await response.text(),
|
|
642
|
+
}
|
|
643
|
+
: (await response.text().catch(() => ''), null),
|
|
644
|
+
() => null,
|
|
645
|
+
),
|
|
646
|
+
);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
async function takeRunnerStartupRead(
|
|
650
|
+
url: string,
|
|
651
|
+
init: RequestInit,
|
|
652
|
+
): Promise<Response | null> {
|
|
653
|
+
if ((init.method ?? 'GET').toUpperCase() !== 'GET') return null;
|
|
654
|
+
const pending = runnerStartupReadPrefetch.get(url);
|
|
655
|
+
if (!pending) return null;
|
|
656
|
+
runnerStartupReadPrefetch.delete(url);
|
|
657
|
+
const answer = await pending;
|
|
658
|
+
return answer
|
|
659
|
+
? new Response(answer.body, {
|
|
660
|
+
status: answer.status,
|
|
661
|
+
headers: answer.headers,
|
|
662
|
+
})
|
|
663
|
+
: null;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* Prefetch the read-only metadata and auth-scope lookups for the tools the
|
|
668
|
+
* worker named (`startupReadToolIds`) or, absent that, the static plan names.
|
|
669
|
+
*/
|
|
670
|
+
export async function prefetchStaticToolStartupReads(
|
|
671
|
+
config: PlayRunnerExecutionConfig,
|
|
672
|
+
): Promise<void> {
|
|
673
|
+
const baseUrl = config.context.baseUrl;
|
|
674
|
+
const token = config.context.executorToken;
|
|
675
|
+
const pipeline = config.context.staticPipeline;
|
|
676
|
+
const namedToolIds = readStartupReadToolIds(
|
|
677
|
+
config.context.startupReadToolIds,
|
|
678
|
+
);
|
|
679
|
+
if (!baseUrl || !token || (!pipeline && !namedToolIds)) return;
|
|
680
|
+
const toolIds = new Set(
|
|
681
|
+
namedToolIds ?? staticPipelineStartupReadToolIds(pipeline),
|
|
682
|
+
);
|
|
683
|
+
if (toolIds.size === 0) return;
|
|
684
|
+
const headers = {
|
|
685
|
+
Authorization: `Bearer ${token}`,
|
|
686
|
+
...(await vercelBypassHeaders(config)),
|
|
687
|
+
};
|
|
688
|
+
for (const id of toolIds) {
|
|
689
|
+
const base = `${baseUrl}/api/v2/plays/runtime-tools/${encodeURIComponent(id)}`;
|
|
690
|
+
prefetchRunnerRuntimeControlGet(base, headers);
|
|
691
|
+
prefetchRunnerRuntimeControlGet(`${base}/auth-scope`, headers);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
|
|
599
695
|
export async function fetchRunnerRuntimeControl(input: {
|
|
600
696
|
url: string;
|
|
601
697
|
init: RequestInit;
|
|
@@ -610,6 +706,10 @@ export async function fetchRunnerRuntimeControl(input: {
|
|
|
610
706
|
}): Promise<Response> {
|
|
611
707
|
const fetchImpl = input.fetchImpl ?? fetch;
|
|
612
708
|
const sleepImpl = input.sleepImpl ?? sleepRunnerRuntimeControlRetry;
|
|
709
|
+
if (!input.fetchImpl) {
|
|
710
|
+
const prefetched = await takeRunnerStartupRead(input.url, input.init);
|
|
711
|
+
if (prefetched) return prefetched;
|
|
712
|
+
}
|
|
613
713
|
const startedAt = Date.now();
|
|
614
714
|
// Header/body retries and no-response retries use independent ordinary
|
|
615
715
|
// budgets. Classified network cuts can also use the bounded outage budget.
|
|
@@ -2547,11 +2647,14 @@ async function run(
|
|
|
2547
2647
|
scope,
|
|
2548
2648
|
}),
|
|
2549
2649
|
// A fixture run answers ctx.fetch from the fixture egress route; it must
|
|
2550
|
-
// never reach the network.
|
|
2650
|
+
// never reach the network. A runner without outbound network
|
|
2651
|
+
// (`modal_sidecar`) sends ctx.fetch through its gateway to the broker.
|
|
2551
2652
|
fetchImpl:
|
|
2552
2653
|
config.context.integrationMode === 'fixture'
|
|
2553
2654
|
? fixtureCtxFetch(config)
|
|
2554
|
-
:
|
|
2655
|
+
: config.context.egressViaRuntimeBroker === true
|
|
2656
|
+
? fixtureCtxFetch(config, 'broker')
|
|
2657
|
+
: safeNodeStreamingOutboundFetch,
|
|
2555
2658
|
vercelProtectionBypassToken: config.context.vercelProtectionBypassToken,
|
|
2556
2659
|
orgId: config.context.orgId,
|
|
2557
2660
|
userEmail: config.context.userEmail,
|
|
@@ -4171,6 +4274,9 @@ export async function materializeTransportedArtifact(
|
|
|
4171
4274
|
|
|
4172
4275
|
async function main() {
|
|
4173
4276
|
const runnerPhaseTimingsMs: RunnerPhaseTimingsMs = {};
|
|
4277
|
+
if (DURABLE_RUNS_ROLLOUT.runnerTerminalDiagnostics) {
|
|
4278
|
+
runnerTerminalPhaseTimingsMs = runnerPhaseTimingsMs;
|
|
4279
|
+
}
|
|
4174
4280
|
const emitStartupRunnerTiming = (line: string) => {
|
|
4175
4281
|
recordRunnerPhaseTiming(runnerPhaseTimingsMs, line);
|
|
4176
4282
|
emitWorkerLog(line);
|
|
@@ -4206,6 +4312,14 @@ async function main() {
|
|
|
4206
4312
|
// artifact materialization can then report its terminal whenever the gateway
|
|
4207
4313
|
// is reachable instead of relying only on the detached ceiling salvage.
|
|
4208
4314
|
runnerTerminalPushContext = terminalPushContextFromConfig(parsedConfig);
|
|
4315
|
+
// Internal diagnostic for the terminal push: count relay connections from
|
|
4316
|
+
// the first customer request onward. Never written to customer run logs.
|
|
4317
|
+
runnerRelayConnectionCounter =
|
|
4318
|
+
runnerTerminalPushContext && DURABLE_RUNS_ROLLOUT.runnerTerminalDiagnostics
|
|
4319
|
+
? startRelayConnectionCounter(
|
|
4320
|
+
parsedConfig.context.executionGatewayBaseUrl ?? null,
|
|
4321
|
+
)
|
|
4322
|
+
: null;
|
|
4209
4323
|
const executionController = new AbortController();
|
|
4210
4324
|
const rowAdmissionController = new AbortController();
|
|
4211
4325
|
let runtimeState:
|
|
@@ -4273,7 +4387,8 @@ async function main() {
|
|
|
4273
4387
|
let executionError: unknown = undefined;
|
|
4274
4388
|
try {
|
|
4275
4389
|
result = await executePlayRunner(config, {
|
|
4276
|
-
...(
|
|
4390
|
+
...(DURABLE_RUNS_ROLLOUT.runnerTerminalDiagnostics ||
|
|
4391
|
+
config.context.runtimeLogIdentity === 'origin'
|
|
4277
4392
|
? { runnerPhaseTimingsMs }
|
|
4278
4393
|
: {}),
|
|
4279
4394
|
signal: executionController.signal,
|
|
@@ -4458,6 +4573,12 @@ export async function materializeTransportedArtifactWhileRunnerParks(
|
|
|
4458
4573
|
// The first gateway heartbeat is the durable readiness fence. The worker
|
|
4459
4574
|
// observes that same Postgres fact directly. It still gates every call to
|
|
4460
4575
|
// executePlayRunner; only file I/O overlaps the handoff.
|
|
4576
|
+
if (DURABLE_RUNS_ROLLOUT.runnerStartupReadPrefetch) {
|
|
4577
|
+
void materialization.then((outcome) => {
|
|
4578
|
+
if ('config' in outcome)
|
|
4579
|
+
void prefetchStaticToolStartupReads(outcome.config);
|
|
4580
|
+
});
|
|
4581
|
+
}
|
|
4461
4582
|
await heartbeat?.firstHeartbeat;
|
|
4462
4583
|
await waitForRunnerExecutionAcknowledgement(heartbeat);
|
|
4463
4584
|
|
|
@@ -4529,6 +4650,13 @@ export function writeRunnerStartupDiagnostic(
|
|
|
4529
4650
|
}
|
|
4530
4651
|
}
|
|
4531
4652
|
|
|
4653
|
+
/** Phase timings for the terminal push's internal diagnostic (set in main). */
|
|
4654
|
+
let runnerTerminalPhaseTimingsMs: Readonly<Record<string, number>> | null =
|
|
4655
|
+
null;
|
|
4656
|
+
|
|
4657
|
+
/** Relay connection counter for the terminal push (set once in main). */
|
|
4658
|
+
let runnerRelayConnectionCounter: RelayConnectionCounter | null = null;
|
|
4659
|
+
|
|
4532
4660
|
/** Terminal push wiring (set once in main after the config loads). */
|
|
4533
4661
|
let runnerTerminalPushContext: {
|
|
4534
4662
|
gatewayBaseUrl: string;
|
|
@@ -4563,11 +4691,19 @@ async function pushRunnerTerminalIfConfigured(
|
|
|
4563
4691
|
): Promise<void> {
|
|
4564
4692
|
const context = runnerTerminalPushContext;
|
|
4565
4693
|
if (!context) return;
|
|
4694
|
+
const relayConnectionsOpened = runnerRelayConnectionCounter?.read() ?? null;
|
|
4566
4695
|
await pushRunnerTerminal({
|
|
4567
4696
|
gatewayBaseUrl: context.gatewayBaseUrl,
|
|
4568
4697
|
executorToken: context.executorToken,
|
|
4569
4698
|
runId: context.runId,
|
|
4570
4699
|
result,
|
|
4700
|
+
...(relayConnectionsOpened !== null ? { relayConnectionsOpened } : {}),
|
|
4701
|
+
...(runnerTerminalPhaseTimingsMs
|
|
4702
|
+
? { runnerPhaseTimingsMs: runnerTerminalPhaseTimingsMs }
|
|
4703
|
+
: {}),
|
|
4704
|
+
...(DURABLE_RUNS_ROLLOUT.runnerTerminalDiagnostics
|
|
4705
|
+
? { runnerProcessStartedAtMs: performance.timeOrigin }
|
|
4706
|
+
: {}),
|
|
4571
4707
|
runtimeCompletedPath:
|
|
4572
4708
|
process.env.DEEPLINE_PLAY_RUNNER_RUNTIME_COMPLETED_PATH,
|
|
4573
4709
|
...options,
|
|
@@ -4614,12 +4750,28 @@ function startRunnerPushHeartbeatFromConfig(
|
|
|
4614
4750
|
if (!push || !gatewayBaseUrl || !executorToken) {
|
|
4615
4751
|
return null;
|
|
4616
4752
|
}
|
|
4753
|
+
const executionGatewayBaseUrl =
|
|
4754
|
+
config.context.executionGatewayBaseUrl?.trim();
|
|
4617
4755
|
return startRunnerHeartbeatLoop({
|
|
4618
4756
|
gatewayBaseUrl,
|
|
4619
4757
|
executorToken,
|
|
4620
4758
|
runId: push.runId,
|
|
4621
4759
|
leaseSeconds: push.leaseSeconds,
|
|
4622
4760
|
waitForSchedulerPark: true,
|
|
4761
|
+
// The supervisor sidecar starts beside the runner; wait for both roles.
|
|
4762
|
+
...(config.context.awaitRuntimeSupervisor === true
|
|
4763
|
+
? {
|
|
4764
|
+
awaitGatewayListening: {
|
|
4765
|
+
urls: [
|
|
4766
|
+
gatewayBaseUrl,
|
|
4767
|
+
...(executionGatewayBaseUrl ? [executionGatewayBaseUrl] : []),
|
|
4768
|
+
],
|
|
4769
|
+
deadlineMs: 30_000,
|
|
4770
|
+
probeTimeoutMs:
|
|
4771
|
+
config.context.runtimeSupervisorProbeTimeoutMs ?? 100,
|
|
4772
|
+
},
|
|
4773
|
+
}
|
|
4774
|
+
: {}),
|
|
4623
4775
|
onSelfTerminate: (stop) => {
|
|
4624
4776
|
onSelfTerminate?.(stop);
|
|
4625
4777
|
void terminateRunnerForHeartbeatStop(stop);
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as diagnosticsChannel from 'node:diagnostics_channel';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Counts the TCP/TLS connections the runner opens to its execution relay, from
|
|
5
|
+
* undici's `undici:client:connected` diagnostics channel (the same source the
|
|
6
|
+
* opt-in egress probe uses). The total travels as the optional internal
|
|
7
|
+
* `relayConnectionsOpened` scalar on the terminal push, where the gateway's
|
|
8
|
+
* internal lifecycle line records it. It never reaches customer run logs.
|
|
9
|
+
*
|
|
10
|
+
* Diagnostics only: a counter that cannot subscribe reports `null`, and no
|
|
11
|
+
* failure here may affect the run.
|
|
12
|
+
*/
|
|
13
|
+
export type RelayConnectionCounter = {
|
|
14
|
+
/** Connections opened to the relay so far, or null when unobservable. */
|
|
15
|
+
read: () => number | null;
|
|
16
|
+
stop: () => void;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type UndiciConnectedMessage = {
|
|
20
|
+
connectParams?: {
|
|
21
|
+
protocol?: unknown;
|
|
22
|
+
hostname?: unknown;
|
|
23
|
+
host?: unknown;
|
|
24
|
+
port?: unknown;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function defaultPort(protocol: string): string {
|
|
29
|
+
return protocol === 'http:' ? '80' : protocol === 'https:' ? '443' : '';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function relayOrigin(
|
|
33
|
+
baseUrl: string,
|
|
34
|
+
): { protocol: string; hostname: string; port: string } | null {
|
|
35
|
+
try {
|
|
36
|
+
const url = new URL(baseUrl);
|
|
37
|
+
return {
|
|
38
|
+
protocol: url.protocol,
|
|
39
|
+
hostname: url.hostname.toLowerCase(),
|
|
40
|
+
port: url.port || defaultPort(url.protocol),
|
|
41
|
+
};
|
|
42
|
+
} catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** True when an undici connect message names the relay's origin. */
|
|
48
|
+
export function undiciConnectionTargetsOrigin(
|
|
49
|
+
message: unknown,
|
|
50
|
+
origin: { protocol: string; hostname: string; port: string },
|
|
51
|
+
): boolean {
|
|
52
|
+
const params = (message as UndiciConnectedMessage | null)?.connectParams;
|
|
53
|
+
if (!params || typeof params !== 'object') return false;
|
|
54
|
+
const protocol = typeof params.protocol === 'string' ? params.protocol : '';
|
|
55
|
+
if (protocol !== origin.protocol) return false;
|
|
56
|
+
const hostname =
|
|
57
|
+
typeof params.hostname === 'string'
|
|
58
|
+
? params.hostname
|
|
59
|
+
: typeof params.host === 'string'
|
|
60
|
+
? params.host.replace(/:\d+$/, '')
|
|
61
|
+
: '';
|
|
62
|
+
if (hostname.toLowerCase() !== origin.hostname) return false;
|
|
63
|
+
const rawPort =
|
|
64
|
+
typeof params.port === 'string' || typeof params.port === 'number'
|
|
65
|
+
? String(params.port)
|
|
66
|
+
: '';
|
|
67
|
+
return (rawPort || defaultPort(protocol)) === origin.port;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function startRelayConnectionCounter(
|
|
71
|
+
relayBaseUrl: string | null | undefined,
|
|
72
|
+
): RelayConnectionCounter | null {
|
|
73
|
+
const trimmed = relayBaseUrl?.trim();
|
|
74
|
+
if (!trimmed) return null;
|
|
75
|
+
const origin = relayOrigin(trimmed);
|
|
76
|
+
if (!origin) return null;
|
|
77
|
+
let connections = 0;
|
|
78
|
+
const onConnect = (message: unknown) => {
|
|
79
|
+
try {
|
|
80
|
+
if (undiciConnectionTargetsOrigin(message, origin)) connections += 1;
|
|
81
|
+
} catch {
|
|
82
|
+
// Diagnostics must not affect a customer run.
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
try {
|
|
86
|
+
diagnosticsChannel.subscribe('undici:client:connected', onConnect);
|
|
87
|
+
} catch {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
let live = true;
|
|
91
|
+
return {
|
|
92
|
+
read: () => connections,
|
|
93
|
+
stop: () => {
|
|
94
|
+
if (!live) return;
|
|
95
|
+
live = false;
|
|
96
|
+
try {
|
|
97
|
+
diagnosticsChannel.unsubscribe('undici:client:connected', onConnect);
|
|
98
|
+
} catch {
|
|
99
|
+
// Diagnostics teardown must not affect a customer run.
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RUNTIME_CLAIM_HEARTBEAT_DIVISOR } from '../runtime-constants';
|
|
2
|
+
import { DURABLE_RUNS_ROLLOUT } from '../durable-runs-rollout';
|
|
2
3
|
import { PLAY_RUNTIME_TRANSPORT_ATTEMPT_HEADER } from '../runtime-contract';
|
|
3
4
|
import {
|
|
4
5
|
createRunnerGatewayTransportAttemptId,
|
|
@@ -61,6 +62,17 @@ export interface RunnerHeartbeatLoopOptions {
|
|
|
61
62
|
leaseSeconds: number;
|
|
62
63
|
/** Keep managed startup heartbeats active until the scheduler parks the attempt. */
|
|
63
64
|
waitForSchedulerPark?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Sandbox-local gateway origins (the `modal_sidecar` supervisor) that may
|
|
67
|
+
* still be starting when the runner starts. The first heartbeat waits until
|
|
68
|
+
* each answers any HTTP request, polling every 10 ms up to the deadline,
|
|
69
|
+
* then the loop runs exactly as without it. Absent: start immediately.
|
|
70
|
+
*/
|
|
71
|
+
awaitGatewayListening?: {
|
|
72
|
+
urls: string[];
|
|
73
|
+
deadlineMs: number;
|
|
74
|
+
probeTimeoutMs?: number;
|
|
75
|
+
};
|
|
64
76
|
/**
|
|
65
77
|
* Invoked once when the loop decides the runner must self-terminate (terminal
|
|
66
78
|
* cancellation channel, or gateway unreachable past the lease window). The
|
|
@@ -74,6 +86,8 @@ export interface RunnerHeartbeatLoopOptions {
|
|
|
74
86
|
runId: string;
|
|
75
87
|
leaseSeconds: number;
|
|
76
88
|
attempt?: number;
|
|
89
|
+
/** Optional park-ack long-poll bound (runnerParkAckLongPoll). */
|
|
90
|
+
awaitSchedulerWaitingMs?: number;
|
|
77
91
|
}) => Promise<RunnerHeartbeatResponse>;
|
|
78
92
|
/** Injectable timer for tests. Defaults to setInterval. */
|
|
79
93
|
setIntervalImpl?: (fn: () => void, ms: number) => { unref?: () => void };
|
|
@@ -112,6 +126,8 @@ export const RUNNER_HEARTBEAT_REQUEST_TIMEOUT_MS = 10_000;
|
|
|
112
126
|
// Retry initial transport failures while customer execution remains fenced.
|
|
113
127
|
const RUNNER_STARTUP_HEARTBEAT_INTERVAL_MS = 1_000;
|
|
114
128
|
const RUNNER_PARK_ACK_INTERVAL_MS = 100;
|
|
129
|
+
/** Park-ack long-poll bound requested from the gateway (runnerParkAckLongPoll). */
|
|
130
|
+
const RUNNER_PARK_ACK_LONG_POLL_REQUEST_MS = 500;
|
|
115
131
|
const RUNNER_PARK_ACK_FAST_WINDOW_MS = 1_000;
|
|
116
132
|
|
|
117
133
|
export async function sendRunnerHeartbeat(
|
|
@@ -121,6 +137,7 @@ export async function sendRunnerHeartbeat(
|
|
|
121
137
|
runId: string;
|
|
122
138
|
leaseSeconds: number;
|
|
123
139
|
attempt?: number;
|
|
140
|
+
awaitSchedulerWaitingMs?: number;
|
|
124
141
|
},
|
|
125
142
|
options: {
|
|
126
143
|
fetchImpl?: typeof fetch;
|
|
@@ -174,6 +191,9 @@ export async function sendRunnerHeartbeat(
|
|
|
174
191
|
body: JSON.stringify({
|
|
175
192
|
action: 'runner_heartbeat',
|
|
176
193
|
runId: input.runId,
|
|
194
|
+
...(input.awaitSchedulerWaitingMs
|
|
195
|
+
? { awaitSchedulerWaitingMs: input.awaitSchedulerWaitingMs }
|
|
196
|
+
: {}),
|
|
177
197
|
}),
|
|
178
198
|
redirect: 'manual',
|
|
179
199
|
signal: controller.signal,
|
|
@@ -269,6 +289,34 @@ export async function sendRunnerHeartbeat(
|
|
|
269
289
|
}
|
|
270
290
|
}
|
|
271
291
|
|
|
292
|
+
/**
|
|
293
|
+
* Resolve once every origin answers any HTTP response, or at the deadline
|
|
294
|
+
* (then the ordinary loop surfaces the failure). Each probe gives up after
|
|
295
|
+
* 100 ms, so a connect that hangs while the sandbox network comes up costs
|
|
296
|
+
* one short probe, not a second. The pending timer keeps the process alive
|
|
297
|
+
* while waiting.
|
|
298
|
+
*/
|
|
299
|
+
async function awaitGatewaysListening(
|
|
300
|
+
input: { urls: string[]; deadlineMs: number; probeTimeoutMs?: number },
|
|
301
|
+
now: () => number,
|
|
302
|
+
): Promise<number> {
|
|
303
|
+
const startedAt = now();
|
|
304
|
+
for (const url of input.urls) {
|
|
305
|
+
for (;;) {
|
|
306
|
+
try {
|
|
307
|
+
await fetch(`${url.replace(/\/$/, '')}/healthz`, {
|
|
308
|
+
signal: AbortSignal.timeout(input.probeTimeoutMs ?? 100),
|
|
309
|
+
});
|
|
310
|
+
break;
|
|
311
|
+
} catch {
|
|
312
|
+
if (now() - startedAt > input.deadlineMs) return now() - startedAt;
|
|
313
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return now() - startedAt;
|
|
318
|
+
}
|
|
319
|
+
|
|
272
320
|
export function startRunnerHeartbeatLoop(
|
|
273
321
|
options: RunnerHeartbeatLoopOptions,
|
|
274
322
|
): RunnerHeartbeatLoopHandle {
|
|
@@ -315,6 +363,7 @@ export function startRunnerHeartbeatLoop(
|
|
|
315
363
|
runId: string;
|
|
316
364
|
leaseSeconds: number;
|
|
317
365
|
attempt?: number;
|
|
366
|
+
awaitSchedulerWaitingMs?: number;
|
|
318
367
|
}) => sendRunnerHeartbeat(input, { onTransport }));
|
|
319
368
|
|
|
320
369
|
const leaseMs = Math.max(1_000, Math.floor(options.leaseSeconds * 1_000));
|
|
@@ -373,6 +422,13 @@ export function startRunnerHeartbeatLoop(
|
|
|
373
422
|
runId: options.runId,
|
|
374
423
|
leaseSeconds: options.leaseSeconds,
|
|
375
424
|
attempt: heartbeatAttempt,
|
|
425
|
+
// Optional, switch off: while still fenced, ask the gateway to hold the
|
|
426
|
+
// answer until the scheduler reports the durable park (bounded).
|
|
427
|
+
...(DURABLE_RUNS_ROLLOUT.runnerParkAckLongPoll &&
|
|
428
|
+
options.waitForSchedulerPark &&
|
|
429
|
+
resolveExecutionAcknowledged
|
|
430
|
+
? { awaitSchedulerWaitingMs: RUNNER_PARK_ACK_LONG_POLL_REQUEST_MS }
|
|
431
|
+
: {}),
|
|
376
432
|
})
|
|
377
433
|
.finally(() => {
|
|
378
434
|
// A caller may request the park acknowledgement as soon as the first
|
|
@@ -435,12 +491,25 @@ export function startRunnerHeartbeatLoop(
|
|
|
435
491
|
});
|
|
436
492
|
};
|
|
437
493
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
494
|
+
const startLoop = () => {
|
|
495
|
+
if (stopped) return;
|
|
496
|
+
// Keep this timer referenced until the first accepted heartbeat: a pending
|
|
497
|
+
// Promise alone does not keep Node alive after an initial transport failure.
|
|
498
|
+
setCadence(intervalMs);
|
|
499
|
+
// Fire one immediately so a cancel that landed before the first interval is
|
|
500
|
+
// observed within a cadence, not a full lease window.
|
|
501
|
+
tick();
|
|
502
|
+
};
|
|
503
|
+
if (options.awaitGatewayListening?.urls.length) {
|
|
504
|
+
void awaitGatewaysListening(options.awaitGatewayListening, now).then(
|
|
505
|
+
(waitedMs) => {
|
|
506
|
+
warn('gateway_listening', { runId: options.runId, waitedMs });
|
|
507
|
+
startLoop();
|
|
508
|
+
},
|
|
509
|
+
);
|
|
510
|
+
} else {
|
|
511
|
+
startLoop();
|
|
512
|
+
}
|
|
444
513
|
|
|
445
514
|
return {
|
|
446
515
|
stop: stopLoop,
|