deepline 0.3.527 → 0.3.528
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/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +141 -211
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +5 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +66 -1
- package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +135 -161
- package/dist/bundling-sources/shared_libs/play-runtime/play-run-recovery-policy.ts +56 -1
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/contracts.ts +11 -1
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/job.ts +36 -6
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +35 -5
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-start-admission.ts +12 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +16 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +25 -5
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-telemetry.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-claim-loop-timing.ts +145 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +48 -5
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +281 -66
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +13 -5
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/play-run-recovery.ts +30 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +105 -13
- package/dist/bundling-sources/shared_libs/play-runtime/tool-call/result-receipt-policy.ts +10 -1
- package/dist/cli/auth-CWJZYLTB.js +43 -0
- package/dist/cli/{auth-LRMMQFJ4.mjs → auth-PPOTNK4T.mjs} +5 -5
- package/dist/cli/{billing-M76MMWZB.js → billing-3C7T7CUQ.js} +79 -79
- package/dist/cli/{billing-WZZDXVRJ.mjs → billing-OEZUQ2K6.mjs} +6 -6
- package/dist/cli/{chunk-R6IWWPY7.js → chunk-237PKFIQ.js} +14 -14
- package/dist/cli/{chunk-YSDPYQBH.js → chunk-36UD7H7Y.js} +41 -41
- package/dist/cli/{chunk-M45S7JAY.mjs → chunk-42ZSDTOC.mjs} +2 -2
- package/dist/cli/{chunk-YJ4YVFXC.js → chunk-4SBUXDKZ.js} +13 -13
- package/dist/cli/{chunk-HB3YUHEL.js → chunk-5MJ4CDAQ.js} +44 -44
- package/dist/cli/{chunk-UJHS2O5O.mjs → chunk-6OLQWQU5.mjs} +3 -3
- package/dist/cli/{chunk-EOL7PXLW.js → chunk-7WZXUAQW.js} +7 -7
- package/dist/cli/{chunk-YUYDP2EG.js → chunk-7X3NLHI7.js} +6 -6
- package/dist/cli/{chunk-XYG4IOJK.js → chunk-ADZGTMLU.js} +98 -98
- package/dist/cli/{chunk-MIL5YDKZ.mjs → chunk-AFIAVG5T.mjs} +2 -2
- package/dist/cli/{chunk-3L2DNG5X.js → chunk-B3HQF2CA.js} +11 -11
- package/dist/cli/{chunk-HA2J2OAS.mjs → chunk-B6YWCGVC.mjs} +10 -10
- package/dist/cli/{chunk-NVII3RWQ.mjs → chunk-CMTY6SVY.mjs} +2 -2
- package/dist/cli/{chunk-AXFHQWGA.mjs → chunk-DCVNL5XN.mjs} +1 -1
- package/dist/cli/{chunk-RTPLRMEB.mjs → chunk-FPHAUP55.mjs} +5 -5
- package/dist/cli/{chunk-JSEISVAZ.js → chunk-FXYWEKUK.js} +4 -4
- package/dist/cli/{chunk-HQZLTK3P.js → chunk-G7RTPKRJ.js} +2 -2
- package/dist/cli/{chunk-OKRBGXDI.js → chunk-GCBFSFLA.js} +5 -5
- package/dist/cli/{chunk-VTXBV4AX.mjs → chunk-GFGFAAY2.mjs} +1 -1
- package/dist/cli/{chunk-JSVHBJE2.mjs → chunk-GP7E4TE4.mjs} +2 -2
- package/dist/cli/{chunk-4YN7DZEA.mjs → chunk-GSBKODMU.mjs} +2 -2
- package/dist/cli/{chunk-RMCKTV4R.mjs → chunk-HJVNCRXY.mjs} +1 -1
- package/dist/cli/{chunk-7DPWGAOU.js → chunk-IJAEYEJM.js} +3 -3
- package/dist/cli/{chunk-VV2AFJ3I.mjs → chunk-IM5XQ4DG.mjs} +5 -5
- package/dist/cli/{chunk-XI47UAVU.js → chunk-IXEEXYE2.js} +9 -9
- package/dist/cli/{chunk-JEIGNX3G.mjs → chunk-IYCRX34W.mjs} +5 -5
- package/dist/cli/{chunk-ZHY7AY5V.js → chunk-KHVCHFE3.js} +16 -16
- package/dist/cli/{chunk-KDFUQRVU.mjs → chunk-KLGYBOGZ.mjs} +1 -1
- package/dist/cli/{chunk-UKOG6PCB.mjs → chunk-KWIKFR7Y.mjs} +1 -1
- package/dist/cli/{chunk-ETXQZGQU.js → chunk-LT4IEJ6V.js} +16 -16
- package/dist/cli/{chunk-RGL2YGJZ.js → chunk-LU4EA3ET.js} +2 -2
- package/dist/cli/{chunk-UAQ7ZWRP.js → chunk-MLNH4DK2.js} +22 -22
- package/dist/cli/{chunk-YKPMIJJ2.mjs → chunk-NCOTOGTK.mjs} +2 -2
- package/dist/cli/{chunk-MMM2WMTF.mjs → chunk-NZM4KWWV.mjs} +5 -5
- package/dist/cli/{chunk-C7A44BZ7.js → chunk-OEI7YUEF.js} +3 -3
- package/dist/cli/{chunk-LHMHUA5D.js → chunk-OGVUT2KM.js} +7 -7
- package/dist/cli/{chunk-OXHY3LD3.js → chunk-OVZSNBDJ.js} +53 -53
- package/dist/cli/{chunk-5YR6CDJ2.mjs → chunk-PS2UYVAE.mjs} +6 -6
- package/dist/cli/{chunk-66YLAQ2X.js → chunk-R5ZQVQ3K.js} +26 -26
- package/dist/cli/{chunk-QKY3H3HA.mjs → chunk-RC5CG5SE.mjs} +4 -4
- package/dist/cli/{chunk-SRQQAUXN.js → chunk-RFTBMEWL.js} +2 -2
- package/dist/cli/{chunk-P5ZU5ZHA.mjs → chunk-RML3VSTN.mjs} +1 -1
- package/dist/cli/{chunk-2L3HVEBM.mjs → chunk-SP2KZ7SH.mjs} +1 -1
- package/dist/cli/{chunk-QKKT5G4K.mjs → chunk-T4QPRL3P.mjs} +3 -3
- package/dist/cli/{chunk-GIRMVMXP.mjs → chunk-ULUI2FEM.mjs} +1 -1
- package/dist/cli/{chunk-3PQDEBO6.js → chunk-WXHBD6H7.js} +1 -1
- package/dist/cli/{chunk-OLSATEDQ.js → chunk-XD2DRBPH.js} +6 -6
- package/dist/cli/{chunk-77VNC2KF.mjs → chunk-Z25KC5V2.mjs} +1 -1
- package/dist/cli/{chunk-E4TEZE62.mjs → chunk-Z44S7VWO.mjs} +2 -2
- package/dist/cli/{chunk-2A6IRSE6.js → chunk-ZFD5FJCZ.js} +5 -5
- package/dist/cli/{csv-FEFNXZF7.mjs → csv-K7TRWOFJ.mjs} +4 -4
- package/dist/cli/{csv-IRP6VT7Q.js → csv-OTRVTHD2.js} +13 -13
- package/dist/cli/{db-IHECMWZ3.mjs → db-C7GQU3TZ.mjs} +6 -6
- package/dist/cli/{db-Y5VNPNRD.js → db-UO2ZFLFN.js} +27 -27
- package/dist/cli/describe-IK4UYJ5M.js +50 -0
- package/dist/cli/{describe-XCVC2WLL.mjs → describe-LG4CPTIV.mjs} +18 -18
- package/dist/cli/{executions-QH3KJ6MA.js → executions-LHFVPO7E.js} +8 -8
- package/dist/cli/{executions-3FWZYUJV.mjs → executions-P3INNVZE.mjs} +6 -6
- package/dist/cli/{feedback-F3OZXOPM.mjs → feedback-H22FWG63.mjs} +6 -6
- package/dist/cli/{feedback-BGHWMOLH.js → feedback-M3HZQAWX.js} +14 -14
- package/dist/cli/git-72ADWRUQ.js +25 -0
- package/dist/cli/{git-RWPH3D75.mjs → git-G2N7PVFI.mjs} +5 -5
- package/dist/cli/index.js +141 -141
- package/dist/cli/index.mjs +43 -43
- package/dist/cli/{legacy-noops-G6CYD5LM.js → legacy-noops-2RVROWBY.js} +9 -9
- package/dist/cli/{legacy-noops-5ADSTBJ5.mjs → legacy-noops-LDYSWTL2.mjs} +6 -6
- package/dist/cli/{monitors-AFNAU3A2.mjs → monitors-IYT3VON7.mjs} +7 -7
- package/dist/cli/{monitors-VZCBZO26.js → monitors-U4RE6KN5.js} +100 -100
- package/dist/cli/{org-JVLYTU24.mjs → org-R3JE22GS.mjs} +6 -6
- package/dist/cli/{org-X4QRYBC4.js → org-SO52ZGRP.js} +86 -86
- package/dist/cli/{pages-VELKZKBL.mjs → pages-5RLT5YTF.mjs} +6 -6
- package/dist/cli/{pages-YMM4KBW5.js → pages-SWXJQJXH.js} +18 -18
- package/dist/cli/{play-MIY6BYRB.mjs → play-2ELYCSXZ.mjs} +18 -18
- package/dist/cli/{play-J7DEBHI7.js → play-J4UXOQOJ.js} +317 -317
- package/dist/cli/{providers-2H3W3W7G.mjs → providers-IXITXHTS.mjs} +6 -6
- package/dist/cli/{providers-TOUB7Y2A.js → providers-VVUDGV2D.js} +9 -9
- package/dist/cli/{quickstart-GKAS5265.mjs → quickstart-HQCGDPPL.mjs} +4 -4
- package/dist/cli/{quickstart-LHY2LN3P.js → quickstart-XPH6MT47.js} +6 -6
- package/dist/cli/{run-KYGNOWYD.mjs → run-H2HQPWC4.mjs} +23 -23
- package/dist/cli/{run-QCAVDPE5.js → run-OR646AC6.js} +41 -41
- package/dist/cli/search-D27DZH2D.js +33 -0
- package/dist/cli/{search-YPGAIFDX.mjs → search-MBPI5SBW.mjs} +8 -8
- package/dist/cli/{search-output-OOC3VK4T.mjs → search-output-CYOMJNRV.mjs} +4 -4
- package/dist/cli/{search-output-ASELNQ2U.js → search-output-YGNSHBXX.js} +6 -6
- package/dist/cli/{secrets-KX3TQB4R.js → secrets-HVZKNNLZ.js} +15 -15
- package/dist/cli/{secrets-VJ4XYSMZ.mjs → secrets-NK2CN7WI.mjs} +6 -6
- package/dist/cli/sessions-MTISSOZ4.js +22 -0
- package/dist/cli/{sessions-KUN7H7E5.mjs → sessions-NY4G427U.mjs} +6 -6
- package/dist/cli/{settings-5NIF4BU7.js → settings-PVJRDEN2.js} +86 -86
- package/dist/cli/{settings-JKFYZ2IT.mjs → settings-RC4FGYY2.mjs} +13 -13
- package/dist/cli/{setup-MYV3IHPS.js → setup-B7QB4YV2.js} +50 -50
- package/dist/cli/{setup-5AX3TN6G.mjs → setup-YT3XSY6X.mjs} +10 -10
- package/dist/cli/{skills-JLS4CINQ.mjs → skills-5ILFNAHR.mjs} +8 -8
- package/dist/cli/skills-BHF35NLX.js +37 -0
- package/dist/cli/{tools-VBYKD3MJ.mjs → tools-7PAY32OZ.mjs} +17 -17
- package/dist/cli/tools-W5BZ37L6.js +57 -0
- package/dist/cli/update-M65CGK42.js +35 -0
- package/dist/cli/{update-QWAIVJRI.mjs → update-Z27QYB6O.mjs} +10 -10
- package/dist/cli/{views-TBWGZAVZ.mjs → views-2IANF6KR.mjs} +6 -6
- package/dist/cli/{views-ZW56JZB5.js → views-NP2SCMOV.js} +18 -18
- package/dist/cli/{workflow-EKSZST6M.js → workflow-2GNQL646.js} +17 -17
- package/dist/cli/{workflow-X7UQPJMQ.mjs → workflow-CAMEZLLY.mjs} +7 -7
- package/dist/index.js +9 -9
- package/dist/index.mjs +6 -6
- package/dist/install-integrity.json +105 -104
- 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.js +5 -5
- package/dist/server.mjs +3 -3
- package/package.json +1 -1
- package/dist/cli/auth-C7BBYIQD.js +0 -43
- package/dist/cli/describe-MNJVJHRE.js +0 -50
- package/dist/cli/git-MDOHEW5J.js +0 -25
- package/dist/cli/search-G67CEHR7.js +0 -33
- package/dist/cli/sessions-QILPX4XQ.js +0 -22
- package/dist/cli/skills-NG32XTZI.js +0 -37
- package/dist/cli/tools-OZG3V77R.js +0 -57
- package/dist/cli/update-YL5WVSKU.js +0 -35
package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts
CHANGED
|
@@ -29,6 +29,7 @@ export { DAYTONA_SNAPSHOT_BY_PLAY_SANDBOX_SIZE } from '../../daytona-runtime-con
|
|
|
29
29
|
import type {
|
|
30
30
|
PlayRunnerDaytonaCleanupIntent,
|
|
31
31
|
PlayRunnerRuntimeLifecycleEvent,
|
|
32
|
+
PlayRunnerWorkerSlot,
|
|
32
33
|
} from '../types';
|
|
33
34
|
import {
|
|
34
35
|
daytonaSandboxMatchesOperationIdentity,
|
|
@@ -1369,6 +1370,8 @@ async function acquireOneShotDaytonaSandbox(input: {
|
|
|
1369
1370
|
nextProviderAttempt: () => number;
|
|
1370
1371
|
startedAt: number;
|
|
1371
1372
|
startAdmission?: DaytonaSandboxStartAdmission;
|
|
1373
|
+
/** Lent to the worker while this create holds a start permit. */
|
|
1374
|
+
workerSlot?: PlayRunnerWorkerSlot;
|
|
1372
1375
|
cancellationSignal?: AbortSignal;
|
|
1373
1376
|
}): Promise<AcquiredDaytonaSandbox> {
|
|
1374
1377
|
const limits = validatePlaySandboxRuntimeLimits(
|
|
@@ -1387,11 +1390,34 @@ async function acquireOneShotDaytonaSandbox(input: {
|
|
|
1387
1390
|
}
|
|
1388
1391
|
return createRetriedOneShotDaytonaSandbox(input);
|
|
1389
1392
|
};
|
|
1393
|
+
// The time the run waited to get its worker slot back after the create. It
|
|
1394
|
+
// is not create time: billing and the create:done timing leave it out.
|
|
1395
|
+
let slotWaitMs = 0;
|
|
1396
|
+
const lendingSlot = input.workerSlot;
|
|
1397
|
+
const workerSlot: PlayRunnerWorkerSlot | undefined = lendingSlot && {
|
|
1398
|
+
lend: () => {
|
|
1399
|
+
const loan = lendingSlot.lend();
|
|
1400
|
+
if (!loan) return null;
|
|
1401
|
+
return {
|
|
1402
|
+
reclaim: async () => {
|
|
1403
|
+
const waitStartedAt = Date.now();
|
|
1404
|
+
await loan.reclaim();
|
|
1405
|
+
slotWaitMs = Date.now() - waitStartedAt;
|
|
1406
|
+
input.emitStage('create:slot_reclaimed', { slotWaitMs });
|
|
1407
|
+
},
|
|
1408
|
+
};
|
|
1409
|
+
},
|
|
1410
|
+
};
|
|
1390
1411
|
const result = input.startAdmission
|
|
1391
|
-
? await input.startAdmission.run(
|
|
1392
|
-
|
|
1393
|
-
input.
|
|
1394
|
-
|
|
1412
|
+
? await input.startAdmission.run(
|
|
1413
|
+
create,
|
|
1414
|
+
input.cancellationSignal,
|
|
1415
|
+
() => {
|
|
1416
|
+
admissionQueued = true;
|
|
1417
|
+
input.emitStage('create:admission_wait');
|
|
1418
|
+
},
|
|
1419
|
+
workerSlot,
|
|
1420
|
+
)
|
|
1395
1421
|
: await create();
|
|
1396
1422
|
// The runner's egress probe measures the sandbox-to-estate round trip; the
|
|
1397
1423
|
// sandbox's target names the region that round trip crosses.
|
|
@@ -1479,13 +1505,15 @@ async function acquireOneShotDaytonaSandbox(input: {
|
|
|
1479
1505
|
result.sandbox,
|
|
1480
1506
|
daytonaOrganizationId,
|
|
1481
1507
|
);
|
|
1482
|
-
|
|
1508
|
+
// The sandbox was ready before the slot wait, so billing starts there.
|
|
1509
|
+
const billingStartedAt = Date.now() - slotWaitMs;
|
|
1483
1510
|
const sandbox = result.sandbox;
|
|
1484
1511
|
input.emitStage('create:done', {
|
|
1485
1512
|
sandboxId: sandbox.id,
|
|
1486
1513
|
attempt: result.attempt,
|
|
1487
1514
|
elapsedMs: billingStartedAt - input.startedAt,
|
|
1488
1515
|
admissionWaitMs,
|
|
1516
|
+
slotWaitMs,
|
|
1489
1517
|
attemptElapsedMs: result.attemptElapsedMs,
|
|
1490
1518
|
// Record the resolved immutable snapshot identifier so slow acquisition
|
|
1491
1519
|
// can be distinguished from a bad profile snapshot without logging
|
|
@@ -1548,6 +1576,7 @@ export function createOneShotDaytonaSandboxLifecycle(input: {
|
|
|
1548
1576
|
intent: PlayRunnerDaytonaCleanupIntent,
|
|
1549
1577
|
) => Promise<void>;
|
|
1550
1578
|
startAdmission?: DaytonaSandboxStartAdmission;
|
|
1579
|
+
workerSlot?: PlayRunnerWorkerSlot;
|
|
1551
1580
|
cancellationSignal?: AbortSignal;
|
|
1552
1581
|
startedAt?: number;
|
|
1553
1582
|
}): OneShotDaytonaSandboxLifecycle {
|
|
@@ -1568,6 +1597,7 @@ export function createOneShotDaytonaSandboxLifecycle(input: {
|
|
|
1568
1597
|
releaseSandboxCapacity: input.releaseSandboxCapacity,
|
|
1569
1598
|
recordCleanupIntent: input.recordCleanupIntent,
|
|
1570
1599
|
startAdmission: input.startAdmission,
|
|
1600
|
+
workerSlot: input.workerSlot,
|
|
1571
1601
|
cancellationSignal: input.cancellationSignal,
|
|
1572
1602
|
nextProviderAttempt: () => {
|
|
1573
1603
|
providerAttempt += 1;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { RUNTIME_CAPACITY_POLICY } from '../../runtime-capacity-policy';
|
|
2
|
+
import type { PlayRunnerWorkerSlot } from '../types';
|
|
2
3
|
|
|
3
4
|
export type DaytonaSandboxStartAdmission = {
|
|
4
5
|
run<T>(
|
|
5
6
|
operation: () => Promise<T>,
|
|
6
7
|
signal?: AbortSignal,
|
|
7
8
|
onQueued?: () => void,
|
|
9
|
+
workerSlot?: PlayRunnerWorkerSlot,
|
|
8
10
|
): Promise<T>;
|
|
9
11
|
};
|
|
10
12
|
|
|
@@ -15,6 +17,12 @@ export type DaytonaSandboxStartAdmission = {
|
|
|
15
17
|
* transition. A permit covers timeout reconciliation too: releasing it when
|
|
16
18
|
* `create` times out would admit another create while the first named sandbox
|
|
17
19
|
* is still transitioning, recreating the unsafe overlap this gate prevents.
|
|
20
|
+
*
|
|
21
|
+
* A run lends its worker slot when it takes a permit, so the worker can claim
|
|
22
|
+
* another run during the create, and keeps the loan until it gets a slot back.
|
|
23
|
+
* The permit is released before the slot is reclaimed: a run waiting here for
|
|
24
|
+
* a permit holds a slot, so reclaiming first could leave each side waiting on
|
|
25
|
+
* the other.
|
|
18
26
|
*/
|
|
19
27
|
export function createDaytonaSandboxStartAdmission(
|
|
20
28
|
concurrency = RUNTIME_CAPACITY_POLICY.sandboxAcquisition
|
|
@@ -50,6 +58,7 @@ export function createDaytonaSandboxStartAdmission(
|
|
|
50
58
|
operation: () => Promise<T>,
|
|
51
59
|
signal?: AbortSignal,
|
|
52
60
|
onQueued?: () => void,
|
|
61
|
+
workerSlot?: PlayRunnerWorkerSlot,
|
|
53
62
|
): Promise<T> {
|
|
54
63
|
signal?.throwIfAborted();
|
|
55
64
|
// Preserve eager prepare semantics when capacity is free: the provider
|
|
@@ -76,11 +85,14 @@ export function createDaytonaSandboxStartAdmission(
|
|
|
76
85
|
signal?.addEventListener('abort', abort, { once: true });
|
|
77
86
|
if (signal?.aborted) abort();
|
|
78
87
|
});
|
|
88
|
+
let loan: { reclaim(): Promise<void> } | null = null;
|
|
79
89
|
try {
|
|
80
90
|
signal?.throwIfAborted();
|
|
91
|
+
loan = workerSlot?.lend() ?? null;
|
|
81
92
|
return await operation();
|
|
82
93
|
} finally {
|
|
83
94
|
release();
|
|
95
|
+
if (loan) await loan.reclaim();
|
|
84
96
|
}
|
|
85
97
|
},
|
|
86
98
|
};
|
|
@@ -1669,6 +1669,7 @@ function prepareDaytonaExecution(
|
|
|
1669
1669
|
releaseSandboxCapacity: callbacks?.releaseSandboxCapacity,
|
|
1670
1670
|
recordCleanupIntent: callbacks?.recordDaytonaCleanupIntent,
|
|
1671
1671
|
startAdmission: daytonaSandboxStartAdmission,
|
|
1672
|
+
workerSlot: callbacks?.workerSlot,
|
|
1672
1673
|
cancellationSignal: callbacks?.cancellationSignal,
|
|
1673
1674
|
});
|
|
1674
1675
|
return {
|
|
@@ -164,6 +164,16 @@ export function isRuntimeSandboxCapacityLimitError(
|
|
|
164
164
|
);
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
/**
|
|
168
|
+
* A scheduler worker slot that can be lent. `lend()` returns null when the
|
|
169
|
+
* worker does not lend slots or its lending budget is spent; the attempt then
|
|
170
|
+
* keeps its slot. A loan keeps the attempt's claim and lease; the attempt must
|
|
171
|
+
* await `reclaim()` before it does more work.
|
|
172
|
+
*/
|
|
173
|
+
export type PlayRunnerWorkerSlot = {
|
|
174
|
+
lend(): { reclaim(): Promise<void> } | null;
|
|
175
|
+
};
|
|
176
|
+
|
|
167
177
|
export interface PlayRunnerCallbacks {
|
|
168
178
|
onLog?: (event: PlayRunnerLogEvent) => void;
|
|
169
179
|
onCheckpoint?: (checkpoint: PlayCheckpoint) => void;
|
|
@@ -200,6 +210,12 @@ export interface PlayRunnerCallbacks {
|
|
|
200
210
|
intent: PlayRunnerAmbiguousModalCreateIntent,
|
|
201
211
|
) => void | Promise<void>;
|
|
202
212
|
onAmbiguousModalCreateResolved?: () => void | Promise<void>;
|
|
213
|
+
/**
|
|
214
|
+
* The scheduler worker slot this attempt runs in. A backend may lend it
|
|
215
|
+
* while the attempt only waits on a provider sandbox create, so the worker
|
|
216
|
+
* can claim another run meanwhile.
|
|
217
|
+
*/
|
|
218
|
+
workerSlot?: PlayRunnerWorkerSlot;
|
|
203
219
|
/** Reserve one physical-sandbox slot immediately before a provider create. */
|
|
204
220
|
reserveSandboxCapacity?: (
|
|
205
221
|
provider: 'daytona' | 'modal' | 'agentcore_runtime',
|
|
@@ -38,6 +38,18 @@ export const RUNTIME_CAPACITY_POLICY = {
|
|
|
38
38
|
maxScaleUpMachinesPerReconcile: 4,
|
|
39
39
|
/** Do not tear down burst capacity on the first empty observation. */
|
|
40
40
|
scaleDownQuietMs: 120_000,
|
|
41
|
+
/**
|
|
42
|
+
* Stopped active-lane workers kept for restart instead of deleted. A
|
|
43
|
+
* restart reuses the Machine's Fly egress wiring and image: Production
|
|
44
|
+
* boots it in about 1.3 s, against about 12 s for a new Machine, which
|
|
45
|
+
* waits for its app-scoped static egress IP before it can reach the
|
|
46
|
+
* database (16% of fresh boots crashed on that wait, 2026-11-10/11).
|
|
47
|
+
* Six is the whole burst headroom (maxFleetMachines - activeLaneMachines);
|
|
48
|
+
* 99% of 161 Production bursts added at most six Machines in their first
|
|
49
|
+
* minute. More could never start at once inside the fleet budget. Fly
|
|
50
|
+
* bills a stopped Machine's rootfs at $0.15 per GB-month.
|
|
51
|
+
*/
|
|
52
|
+
retainedStoppedActiveLaneMachines: 6,
|
|
41
53
|
},
|
|
42
54
|
executionRelay: {
|
|
43
55
|
/** Keep two relay Machines available for deploys and one-machine faults. */
|
|
@@ -78,12 +90,20 @@ export const RUNTIME_CAPACITY_POLICY = {
|
|
|
78
90
|
sandboxAcquisition: {
|
|
79
91
|
/**
|
|
80
92
|
* Starting a Daytona sandbox is a provider control-plane transition, not
|
|
81
|
-
* an Absurd execution slot.
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
93
|
+
* an Absurd execution slot. The fleet-wide limiter paces lifecycle
|
|
94
|
+
* admissions; this semaphore bounds concurrent create/retry ladders in one
|
|
95
|
+
* worker process. A run lends its execution slot from taking a permit
|
|
96
|
+
* until it gets a slot back after its create, so a worker holds at most
|
|
97
|
+
* 8 slots + twice this many runs (`ABSURD_RUNTIME_WORKER_MAX_LENT_SLOTS`).
|
|
98
|
+
*
|
|
99
|
+
* Ten lets the two warm workers reach the limiter's 10 starts a second on
|
|
100
|
+
* their own: a create took 1.5-2.2 s mean in the 2026-11-12 bursts, so
|
|
101
|
+
* 5 a second per worker needs 8-11 in flight. At five, a worker's creates
|
|
102
|
+
* topped out near 5 / 1.8 s = 2.8 a second, and 40% of warm-phase runs
|
|
103
|
+
* waited for a permit. Across 8 workers the limiter, not this bound, caps
|
|
104
|
+
* new creates.
|
|
85
105
|
*/
|
|
86
|
-
daytonaConcurrentStartsPerProcess:
|
|
106
|
+
daytonaConcurrentStartsPerProcess: 10,
|
|
87
107
|
/** Fleet-wide AIMD lifecycle-admission pacing. */
|
|
88
108
|
daytonaInitialStartsPerMinute: 120,
|
|
89
109
|
daytonaMaximumStartsPerMinute: 600,
|
|
@@ -277,6 +277,11 @@ export type PlayRunRecoveryDecision = {
|
|
|
277
277
|
deferCount: number | null;
|
|
278
278
|
/** Deferred only: how long until the retry is due. */
|
|
279
279
|
delayMs: number | null;
|
|
280
|
+
/**
|
|
281
|
+
* Deferred only: compiled start pacing, uncounted, which shares its reason
|
|
282
|
+
* with an operator throttle. Omitted means not paced.
|
|
283
|
+
*/
|
|
284
|
+
paced?: boolean;
|
|
280
285
|
};
|
|
281
286
|
|
|
282
287
|
/**
|
|
@@ -303,6 +308,7 @@ export function emitPlayRunRecoveryDecision(
|
|
|
303
308
|
input.outcome === 'deferred'
|
|
304
309
|
? durabilityDecisionCount(input.delayMs)
|
|
305
310
|
: null,
|
|
311
|
+
paced: input.outcome === 'deferred' && input.paced === true,
|
|
306
312
|
},
|
|
307
313
|
});
|
|
308
314
|
}
|
package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type {
|
|
|
3
3
|
PlayRunnerCallbacks,
|
|
4
4
|
PlayRunnerRuntimeLifecycleEvent,
|
|
5
5
|
PlayRunnerRuntimeResource,
|
|
6
|
+
PlayRunnerWorkerSlot,
|
|
6
7
|
} from '../runner-backends/types';
|
|
7
8
|
import { SandboxRunnerPreCodeDeferralError } from '../runner-backends/types';
|
|
8
9
|
import type {
|
|
@@ -61,6 +62,8 @@ export type SandboxRunnerBackendAdapterDependencies = {
|
|
|
61
62
|
interpretResult: SandboxRunnerResultInterpreter;
|
|
62
63
|
cancellationSignal?: AbortSignal;
|
|
63
64
|
progress?: SandboxRunnerProgress;
|
|
65
|
+
/** The scheduler worker slot this attempt runs in, lendable during a create. */
|
|
66
|
+
workerSlot?: PlayRunnerWorkerSlot;
|
|
64
67
|
};
|
|
65
68
|
|
|
66
69
|
/**
|
|
@@ -97,6 +100,7 @@ export function createPlayRunnerBackendSandboxExecutionAdapter(
|
|
|
97
100
|
readiness: dependencies.readiness,
|
|
98
101
|
cancellationSignal: dependencies.cancellationSignal,
|
|
99
102
|
progress: dependencies.progress,
|
|
103
|
+
workerSlot: dependencies.workerSlot,
|
|
100
104
|
});
|
|
101
105
|
let result: PlayRunnerResult;
|
|
102
106
|
try {
|
|
@@ -126,6 +130,7 @@ function createRunnerCallbacks(input: {
|
|
|
126
130
|
readiness: SandboxRunnerReadiness;
|
|
127
131
|
cancellationSignal?: AbortSignal;
|
|
128
132
|
progress?: SandboxRunnerProgress;
|
|
133
|
+
workerSlot?: PlayRunnerWorkerSlot;
|
|
129
134
|
}): PlayRunnerCallbacks {
|
|
130
135
|
const remember = (resource: PlayRunnerRuntimeResource) => {
|
|
131
136
|
const converted = toSandboxResource(resource);
|
|
@@ -147,6 +152,7 @@ function createRunnerCallbacks(input: {
|
|
|
147
152
|
|
|
148
153
|
return {
|
|
149
154
|
cancellationSignal: input.cancellationSignal,
|
|
155
|
+
...(input.workerSlot ? { workerSlot: input.workerSlot } : {}),
|
|
150
156
|
onLog: input.progress?.onLog,
|
|
151
157
|
onCheckpoint: input.progress?.onCheckpoint,
|
|
152
158
|
onRowUpdate: input.progress?.onRowUpdate,
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CancelledTask,
|
|
3
|
+
SuspendTask,
|
|
4
|
+
type WorkerClaimSnapshot,
|
|
5
|
+
} from '@deepline/absurd/sdk';
|
|
6
|
+
import type {
|
|
7
|
+
AbsurdClaimQueryTiming,
|
|
8
|
+
AbsurdSchedulerQueryObserver,
|
|
9
|
+
} from './absurd-pool';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Timing for the parts of a worker slot's hold that no other line logs: the
|
|
13
|
+
* engine's claim query, the `afterClaim` hook that runs after every claim
|
|
14
|
+
* before the claimed tasks start, the task setup before a handler starts,
|
|
15
|
+
* and the end of the handler once its run parks. On the two warm workers of
|
|
16
|
+
* round 43371126678-1 about 0.4 s of the 1.9 s each run held a slot fell
|
|
17
|
+
* there. Logging only: no claim, slot, lease or durable state changes.
|
|
18
|
+
*
|
|
19
|
+
* Lines (one physical line each):
|
|
20
|
+
* - `[absurd-runtime.worker.claim_cycle]` per claim that returned tasks:
|
|
21
|
+
* pool wait and query time of the claim, the `afterClaim` time,
|
|
22
|
+
* `heldTasks`, and `handlersRunning`. `heldTasks` is the engine's count of
|
|
23
|
+
* every task the worker holds once the claim's tasks start (in a slot or
|
|
24
|
+
* with it lent, any task name, setup and finalization included), bounded by
|
|
25
|
+
* slots + lent slots. `handlersRunning` is the play-run handlers already
|
|
26
|
+
* running in this process, a subset of it.
|
|
27
|
+
* - `[absurd-runtime.worker.phase]` `task_setup`: claim returned -> handler
|
|
28
|
+
* started (the `afterClaim` hook plus the engine's task context load).
|
|
29
|
+
* - `[absurd-runtime.worker.phase]` `handler_end`: handler started -> ended,
|
|
30
|
+
* with `outcome` `parked` when the run suspended (its slot frees then).
|
|
31
|
+
*/
|
|
32
|
+
export type AbsurdClaimLoopTiming = {
|
|
33
|
+
/** Pass to `createAbsurdRuntimeClient` so claim queries are timed. */
|
|
34
|
+
observer: AbsurdSchedulerQueryObserver;
|
|
35
|
+
/** Wraps the worker's `afterClaim` hook. */
|
|
36
|
+
afterClaim(
|
|
37
|
+
hook: () => Promise<void>,
|
|
38
|
+
): (claim: WorkerClaimSnapshot) => Promise<void>;
|
|
39
|
+
/** Wraps one play-run handler invocation. */
|
|
40
|
+
playRunHandler<T>(
|
|
41
|
+
run: { runId: string; taskId: string },
|
|
42
|
+
handler: () => Promise<T>,
|
|
43
|
+
): Promise<T>;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** A claimed task whose handler never started is forgotten after this. */
|
|
47
|
+
const CLAIMED_TASK_RETENTION_MS = 60_000;
|
|
48
|
+
|
|
49
|
+
export function createAbsurdClaimLoopTiming(input: {
|
|
50
|
+
queue: string;
|
|
51
|
+
log?: (line: string) => void;
|
|
52
|
+
now?: () => number;
|
|
53
|
+
}): AbsurdClaimLoopTiming {
|
|
54
|
+
const log = input.log ?? ((line: string) => console.info(line));
|
|
55
|
+
const now = input.now ?? (() => performance.now());
|
|
56
|
+
// The engine awaits `afterClaim` right after each claim query, one claim at
|
|
57
|
+
// a time, so the latest claim is the one the hook follows.
|
|
58
|
+
let lastClaim: AbsurdClaimQueryTiming | null = null;
|
|
59
|
+
const claimReturnedAt = new Map<string, number>();
|
|
60
|
+
let handlersRunning = 0;
|
|
61
|
+
return {
|
|
62
|
+
observer: {
|
|
63
|
+
onClaimTask(timing) {
|
|
64
|
+
lastClaim = timing;
|
|
65
|
+
for (const [taskId, returnedAt] of claimReturnedAt) {
|
|
66
|
+
if (timing.returnedAt - returnedAt > CLAIMED_TASK_RETENTION_MS) {
|
|
67
|
+
claimReturnedAt.delete(taskId);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
for (const taskId of timing.taskIds) {
|
|
71
|
+
claimReturnedAt.set(taskId, timing.returnedAt);
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
afterClaim: (hook) => async (snapshot) => {
|
|
76
|
+
const claim = lastClaim;
|
|
77
|
+
lastClaim = null;
|
|
78
|
+
const startedAt = now();
|
|
79
|
+
let ok = false;
|
|
80
|
+
try {
|
|
81
|
+
await hook();
|
|
82
|
+
ok = true;
|
|
83
|
+
} finally {
|
|
84
|
+
if (claim && claim.taskIds.length > 0) {
|
|
85
|
+
log(
|
|
86
|
+
'[absurd-runtime.worker.claim_cycle] ' +
|
|
87
|
+
JSON.stringify({
|
|
88
|
+
queue: input.queue,
|
|
89
|
+
claimed: claim.taskIds.length,
|
|
90
|
+
taskIds: claim.taskIds,
|
|
91
|
+
claimPoolWaitMs: claim.poolWaitMs,
|
|
92
|
+
claimQueryMs: claim.queryMs,
|
|
93
|
+
claimMs: claim.totalMs,
|
|
94
|
+
afterClaimMs: now() - startedAt,
|
|
95
|
+
afterClaimOk: ok,
|
|
96
|
+
heldTasks: snapshot.heldTasks,
|
|
97
|
+
handlersRunning,
|
|
98
|
+
}),
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
async playRunHandler(run, handler) {
|
|
104
|
+
const startedAt = now();
|
|
105
|
+
const returnedAt = claimReturnedAt.get(run.taskId);
|
|
106
|
+
claimReturnedAt.delete(run.taskId);
|
|
107
|
+
if (returnedAt !== undefined) {
|
|
108
|
+
log(
|
|
109
|
+
'[absurd-runtime.worker.phase] ' +
|
|
110
|
+
JSON.stringify({
|
|
111
|
+
runId: run.runId,
|
|
112
|
+
taskId: run.taskId,
|
|
113
|
+
phase: 'task_setup',
|
|
114
|
+
totalMs: startedAt - returnedAt,
|
|
115
|
+
ok: true,
|
|
116
|
+
}),
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
let outcome: 'returned' | 'parked' | 'cancelled' | 'threw' = 'threw';
|
|
120
|
+
handlersRunning += 1;
|
|
121
|
+
try {
|
|
122
|
+
const result = await handler();
|
|
123
|
+
outcome = 'returned';
|
|
124
|
+
return result;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
if (error instanceof SuspendTask) outcome = 'parked';
|
|
127
|
+
else if (error instanceof CancelledTask) outcome = 'cancelled';
|
|
128
|
+
throw error;
|
|
129
|
+
} finally {
|
|
130
|
+
handlersRunning -= 1;
|
|
131
|
+
log(
|
|
132
|
+
'[absurd-runtime.worker.phase] ' +
|
|
133
|
+
JSON.stringify({
|
|
134
|
+
runId: run.runId,
|
|
135
|
+
taskId: run.taskId,
|
|
136
|
+
phase: 'handler_end',
|
|
137
|
+
totalMs: now() - startedAt,
|
|
138
|
+
ok: outcome !== 'threw',
|
|
139
|
+
outcome,
|
|
140
|
+
}),
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
@@ -44,13 +44,35 @@ export function runWithAbsurdSchedulerQuerySignal<T>(
|
|
|
44
44
|
return absurdSchedulerQuerySignal.run(signal, operation);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/** One `absurd.claim_task` call made by the engine's claim loop. */
|
|
48
|
+
export type AbsurdClaimQueryTiming = {
|
|
49
|
+
/** From the call until the pool handed over a client. */
|
|
50
|
+
poolWaitMs: number;
|
|
51
|
+
/** From then until the claim returned, including any pool retry. */
|
|
52
|
+
queryMs: number;
|
|
53
|
+
totalMs: number;
|
|
54
|
+
taskIds: string[];
|
|
55
|
+
/** `performance.now()` when the claim returned. */
|
|
56
|
+
returnedAt: number;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/** Observes the engine's scheduler queries; measurement only. */
|
|
60
|
+
export type AbsurdSchedulerQueryObserver = {
|
|
61
|
+
onClaimTask(timing: AbsurdClaimQueryTiming): void;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// The vendored engine's claim statement (`Absurd.claimTasks`).
|
|
65
|
+
const ABSURD_CLAIM_TASK_SQL = 'absurd.claim_task(';
|
|
66
|
+
|
|
47
67
|
/**
|
|
48
68
|
* Builds an SDK `Queryable` backed by the hardened runtime scheduler pool.
|
|
49
69
|
* Every query runs on a freshly checked-out pooled client and releases it,
|
|
50
|
-
* inheriting the pool's backpressure/breaker/retry guarantees.
|
|
70
|
+
* inheriting the pool's backpressure/breaker/retry guarantees. An observer
|
|
71
|
+
* is told the timing of each claim query.
|
|
51
72
|
*/
|
|
52
73
|
export function absurdQueryableForRuntimeScheduler(
|
|
53
74
|
poolOptions: RuntimeSchedulerPoolOptions,
|
|
75
|
+
observer?: AbsurdSchedulerQueryObserver,
|
|
54
76
|
): Queryable {
|
|
55
77
|
return {
|
|
56
78
|
query: async <Row = Record<string, unknown>>(
|
|
@@ -58,18 +80,38 @@ export function absurdQueryableForRuntimeScheduler(
|
|
|
58
80
|
params?: unknown[],
|
|
59
81
|
): Promise<QueryResult<Row>> => {
|
|
60
82
|
const signal = absurdSchedulerQuerySignal.getStore();
|
|
61
|
-
|
|
83
|
+
const timed =
|
|
84
|
+
observer !== undefined && sql.includes(ABSURD_CLAIM_TASK_SQL);
|
|
85
|
+
const startedAt = timed ? performance.now() : 0;
|
|
86
|
+
let clientAt: number | undefined;
|
|
87
|
+
const result = await withRuntimeSchedulerClient(
|
|
62
88
|
poolOptions,
|
|
63
89
|
async (client) => {
|
|
64
|
-
|
|
90
|
+
if (timed) clientAt ??= performance.now();
|
|
91
|
+
const queried = await client.query<Row & Record<string, unknown>>(
|
|
65
92
|
sql,
|
|
66
93
|
params,
|
|
67
94
|
);
|
|
68
|
-
return { rows:
|
|
95
|
+
return { rows: queried.rows as Row[] };
|
|
69
96
|
},
|
|
70
97
|
undefined,
|
|
71
98
|
{ signal },
|
|
72
99
|
);
|
|
100
|
+
if (timed) {
|
|
101
|
+
const returnedAt = performance.now();
|
|
102
|
+
const queryStartedAt = clientAt ?? returnedAt;
|
|
103
|
+
observer.onClaimTask({
|
|
104
|
+
poolWaitMs: queryStartedAt - startedAt,
|
|
105
|
+
queryMs: returnedAt - queryStartedAt,
|
|
106
|
+
totalMs: returnedAt - startedAt,
|
|
107
|
+
taskIds: result.rows.flatMap((row) => {
|
|
108
|
+
const taskId = (row as { task_id?: unknown }).task_id;
|
|
109
|
+
return typeof taskId === 'string' ? [taskId] : [];
|
|
110
|
+
}),
|
|
111
|
+
returnedAt,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
73
115
|
},
|
|
74
116
|
};
|
|
75
117
|
}
|
|
@@ -80,10 +122,11 @@ export function absurdQueryableForRuntimeScheduler(
|
|
|
80
122
|
export function createAbsurdForRuntimeScheduler(
|
|
81
123
|
poolOptions: RuntimeSchedulerPoolOptions,
|
|
82
124
|
options: Omit<AbsurdOptions, 'db'> = {},
|
|
125
|
+
observer?: AbsurdSchedulerQueryObserver,
|
|
83
126
|
): Absurd {
|
|
84
127
|
return new Absurd({
|
|
85
128
|
...options,
|
|
86
|
-
db: absurdQueryableForRuntimeScheduler(poolOptions),
|
|
129
|
+
db: absurdQueryableForRuntimeScheduler(poolOptions, observer),
|
|
87
130
|
});
|
|
88
131
|
}
|
|
89
132
|
|