deepline 0.3.582 → 0.4.0
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 +79 -36
- package/dist/bundling-sources/sdk/src/index.ts +2 -0
- package/dist/bundling-sources/sdk/src/release.ts +7 -3
- package/dist/bundling-sources/sdk/src/types.ts +37 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +22 -3
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +94 -5
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +66 -12
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +10 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-topology.ts +6 -1
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-tuple-recovery.ts +9 -3
- package/dist/bundling-sources/shared_libs/play-runtime/docflow-node-io.ts +86 -20
- package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +17 -6
- package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +22 -6
- package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +14 -0
- package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +54 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/postgres-adapter.ts +2 -1
- package/dist/bundling-sources/shared_libs/play-runtime/row-failure-summary.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +4 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +62 -6
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +14 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-store-adapter.ts +197 -19
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-writer.ts +25 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-scheduler-topology.ts +5 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +140 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-wake-policy.ts +419 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +47 -4
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-pool.ts +24 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-scope.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +36 -19
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +380 -51
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-gateway.ts +21 -10
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +32 -0
- package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +6 -0
- package/dist/bundling-sources/shared_libs/plays/deploy/api-client.ts +3 -1
- package/dist/bundling-sources/shared_libs/plays/deploy/run-deployment.ts +34 -4
- package/dist/bundling-sources/shared_libs/plays/docflow-recording-lint.ts +512 -0
- package/dist/bundling-sources/shared_libs/plays/docflow-requirement.ts +346 -0
- package/dist/bundling-sources/shared_libs/plays/docflow-rule-codes.ts +38 -0
- package/dist/bundling-sources/shared_libs/plays/docflow-unreached-reason.ts +42 -2
- package/dist/bundling-sources/shared_libs/plays/docflow.ts +223 -32
- package/dist/bundling-sources/shared_libs/plays/play-check-compact.ts +14 -1
- package/dist/bundling-sources/shared_libs/plays/run-result.ts +35 -0
- package/dist/cli/{agents-UAXDG4FS.mjs → agents-AHXB7N7Y.mjs} +68 -4
- package/dist/cli/{agents-2L73CJHH.js → agents-KBZ7OUZS.js} +95 -31
- package/dist/cli/{auth-3B2QB4UH.mjs → auth-3CACO52T.mjs} +5 -5
- package/dist/cli/auth-UOHCO5K6.js +44 -0
- package/dist/cli/{billing-E7FO622G.js → billing-5KXPGKMO.js} +105 -105
- package/dist/cli/{billing-CPBRWG3M.mjs → billing-TSTK63NB.mjs} +9 -9
- package/dist/cli/{chunk-3DVWSTAI.mjs → chunk-2GWKBQJZ.mjs} +1 -1
- package/dist/cli/{chunk-PNQVB4UD.mjs → chunk-3DJMPID5.mjs} +11 -11
- package/dist/cli/{chunk-FBSPHBAF.js → chunk-3ET6NRXP.js} +7 -3
- package/dist/cli/{chunk-NZR5PBNP.mjs → chunk-3MWTAM3F.mjs} +3 -3
- package/dist/cli/{chunk-ROUNT4NX.mjs → chunk-4ANDW2OT.mjs} +1 -1
- package/dist/cli/{chunk-ZH23XGJO.js → chunk-4BSCSQ6I.js} +4 -4
- package/dist/cli/{chunk-7QX5PCHP.mjs → chunk-4UEXAMDU.mjs} +2 -2
- package/dist/cli/{chunk-3EOET5UB.js → chunk-5XGLDVSD.js} +100 -100
- package/dist/cli/{chunk-MRSYC74T.js → chunk-7XXJJVSI.js} +5 -5
- package/dist/cli/{chunk-NJGXYYHN.js → chunk-7ZCD7OPO.js} +5 -5
- package/dist/cli/{chunk-JF4DUC2F.mjs → chunk-AJJSKKH4.mjs} +2 -2
- package/dist/cli/{chunk-XYQMOXP4.mjs → chunk-BHF5UW34.mjs} +1 -1
- package/dist/cli/{chunk-POYADK77.js → chunk-BO2TXH5Y.js} +20 -20
- package/dist/cli/{chunk-RNZXMOA6.mjs → chunk-BUC2TNF2.mjs} +2 -2
- package/dist/cli/{chunk-EGH4JNJP.js → chunk-BUUAFSSN.js} +68 -50
- package/dist/cli/{chunk-GZBXN56A.js → chunk-C45E47KC.js} +23 -23
- package/dist/cli/{chunk-HP6A3JCX.js → chunk-D4R3AL4F.js} +5 -5
- package/dist/cli/{chunk-ABJZQHON.mjs → chunk-DAZRIAXW.mjs} +4 -4
- package/dist/cli/{chunk-SKKRESFB.js → chunk-DNOZQGJF.js} +3 -3
- package/dist/cli/{chunk-DPLYQITT.js → chunk-DUL6UQ2T.js} +2 -2
- package/dist/cli/{chunk-U2QQQNWW.mjs → chunk-ES3S6UXR.mjs} +2 -2
- package/dist/cli/{chunk-4TTEAUZV.mjs → chunk-FDAYUP3M.mjs} +3 -3
- package/dist/cli/{chunk-V54YQHPV.js → chunk-FEVUIT2U.js} +6 -6
- package/dist/cli/{chunk-KDITCSPN.mjs → chunk-FSPEUU3V.mjs} +68 -6
- package/dist/cli/{chunk-OUFOJTEJ.mjs → chunk-FZZMCVOS.mjs} +5 -5
- package/dist/cli/{chunk-ISN4F6AY.js → chunk-GHOB72U6.js} +13 -13
- package/dist/cli/{chunk-LHA45DNY.mjs → chunk-GLYWRTEL.mjs} +3 -3
- package/dist/cli/{chunk-LDMCTV2Z.mjs → chunk-HNTIGYRT.mjs} +1 -1
- package/dist/cli/{chunk-EB2YLLZJ.js → chunk-IGPHYKEJ.js} +41 -41
- package/dist/cli/{chunk-VA35T3AF.js → chunk-ISSYN3DJ.js} +20 -20
- package/dist/cli/{chunk-DSHIB2XQ.mjs → chunk-JKQPITEE.mjs} +54 -36
- package/dist/cli/{chunk-ZARGHLZZ.mjs → chunk-KMLACXI2.mjs} +7 -3
- package/dist/cli/{chunk-DI5MULNX.js → chunk-KQXACHYA.js} +26 -26
- package/dist/cli/{chunk-CPZL6Z7D.js → chunk-LW2GKYZW.js} +2 -2
- package/dist/cli/{chunk-G5YU6RJ4.mjs → chunk-O2KSPI2M.mjs} +2 -2
- package/dist/cli/{chunk-H3KVMALU.js → chunk-O6GT6JD7.js} +9 -9
- package/dist/cli/{chunk-4ZAWRCB6.mjs → chunk-OCXWUWUI.mjs} +5 -5
- package/dist/cli/{chunk-YPP436NM.js → chunk-QKRDAJ3T.js} +53 -53
- package/dist/cli/{chunk-KQEW3EAU.js → chunk-QQESWF6D.js} +16 -16
- package/dist/cli/{chunk-CYZSHD66.js → chunk-REX5SUYU.js} +2 -2
- package/dist/cli/{chunk-Z3IAEHID.js → chunk-RXIQWG2N.js} +48 -48
- package/dist/cli/{chunk-5436ZJPH.js → chunk-S33BN7GZ.js} +3 -3
- package/dist/cli/{chunk-JD7P73ZW.mjs → chunk-SGRJJLNV.mjs} +1 -1
- package/dist/cli/{chunk-2K6EIL2D.mjs → chunk-TCNYSNVU.mjs} +1 -1
- package/dist/cli/{chunk-I5J6HGVR.mjs → chunk-TFPMVSGK.mjs} +2 -2
- package/dist/cli/{chunk-6NEMTKTA.mjs → chunk-V73WDQEA.mjs} +5 -5
- package/dist/cli/{chunk-Y36SQMSN.js → chunk-VYERVFGB.js} +68 -6
- package/dist/cli/{chunk-SYWLWTWM.mjs → chunk-WBRSVML3.mjs} +4 -4
- package/dist/cli/{chunk-NVHICORD.mjs → chunk-WW52ANX4.mjs} +2 -2
- package/dist/cli/{chunk-3HIJNXRB.js → chunk-XZS35M3Y.js} +10 -10
- package/dist/cli/{chunk-ZL3O7F5J.js → chunk-YNYHYL5C.js} +15 -15
- package/dist/cli/{chunk-FWB3QR7W.mjs → chunk-ZHE5E2WJ.mjs} +1 -1
- package/dist/cli/{chunk-D7J33HTK.mjs → chunk-ZJ2H77VV.mjs} +5 -5
- package/dist/cli/{chunk-JUZIMW4S.js → chunk-ZX6UVPGZ.js} +7 -7
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/concurrent-runs-help-H5SZUA5J.js +22 -0
- package/dist/cli/{concurrent-runs-help-UFNYQYU2.mjs → concurrent-runs-help-IYELSCHB.mjs} +6 -6
- package/dist/cli/{csv-QSDRGLQH.mjs → csv-ENEC3APZ.mjs} +4 -4
- package/dist/cli/{csv-ZI5LYFHF.js → csv-X6CP57R4.js} +13 -13
- package/dist/cli/{db-ZDL6Q53U.js → db-6HLRSE2M.js} +27 -27
- package/dist/cli/{db-WVWXNNMO.mjs → db-YGKRFK4T.mjs} +6 -6
- package/dist/cli/{describe-UUQBKUVL.mjs → describe-4SGQEX7K.mjs} +18 -18
- package/dist/cli/describe-Q2OYHDVZ.js +50 -0
- package/dist/cli/describe-core.d.mts +2 -2
- package/dist/cli/describe-core.d.ts +2 -2
- package/dist/cli/{executions-SCGHTWTC.js → executions-IC55YJ67.js} +8 -8
- package/dist/cli/{executions-QN3OYJKT.mjs → executions-PO2IOSZ7.mjs} +6 -6
- package/dist/cli/{feedback-7QPHLXGU.mjs → feedback-6BUD5F4I.mjs} +6 -6
- package/dist/cli/{feedback-6QQ7ONLW.js → feedback-BCGQLZ5T.js} +14 -14
- package/dist/cli/git-5X3MLBIP.js +26 -0
- package/dist/cli/{git-HFPJX573.mjs → git-IN4IBL2K.mjs} +5 -5
- package/dist/cli/index.js +148 -148
- package/dist/cli/index.mjs +47 -47
- package/dist/cli/{integrations-ND2HULSH.js → integrations-R2Z2MDO3.js} +29 -29
- package/dist/cli/{integrations-4SZ5O24P.mjs → integrations-ZMGB6NQA.mjs} +7 -7
- package/dist/cli/{legacy-noops-WUP3TBR2.mjs → legacy-noops-GIC5OZKP.mjs} +6 -6
- package/dist/cli/{legacy-noops-GQF6AYP5.js → legacy-noops-X4JPRPTJ.js} +9 -9
- package/dist/cli/{mcp-3GUFYGCQ.mjs → mcp-G4IRJIKK.mjs} +4 -4
- package/dist/cli/{mcp-L3YYVEU6.js → mcp-USZKTVL2.js} +24 -24
- package/dist/cli/{monitors-OFCVJSH5.mjs → monitors-SNFZPSCY.mjs} +7 -7
- package/dist/cli/{monitors-CVZZN5WG.js → monitors-T7LRP7OB.js} +100 -100
- package/dist/cli/{org-MQ5AUN7I.js → org-2L2ZZL2P.js} +121 -121
- package/dist/cli/{org-3DTAYA52.mjs → org-YTXLKW52.mjs} +6 -6
- package/dist/cli/{outcomes-42W24EXG.mjs → outcomes-CJWBIFTA.mjs} +6 -6
- package/dist/cli/{outcomes-MGDUYHUD.js → outcomes-O63F57JF.js} +14 -14
- package/dist/cli/{play-PD45RNYZ.mjs → play-6UWPUHC6.mjs} +331 -70
- package/dist/cli/{play-IMAD7QTV.js → play-T353SULJ.js} +930 -669
- package/dist/cli/{providers-DYKHG7NV.mjs → providers-LZABK2UW.mjs} +6 -6
- package/dist/cli/{providers-WONHPTRG.js → providers-XORJH2VW.js} +9 -9
- package/dist/cli/{quickstart-5QPGHLEX.mjs → quickstart-O4RF7J55.mjs} +4 -4
- package/dist/cli/{quickstart-6AAFULGC.js → quickstart-QBNUNPZR.js} +6 -6
- package/dist/cli/{run-WOW7QO3W.js → run-2CPMFC6W.js} +44 -44
- package/dist/cli/{run-4K6ZU7H7.mjs → run-GBRPFC6P.mjs} +23 -23
- package/dist/cli/{search-CKVFWVXQ.mjs → search-G7TS7OFB.mjs} +7 -7
- package/dist/cli/search-M3AHFCKQ.js +32 -0
- package/dist/cli/{search-output-WWB25JWA.mjs → search-output-BIIJRUCP.mjs} +4 -4
- package/dist/cli/{search-output-B5QE7ZNK.js → search-output-NRKLNWSD.js} +6 -6
- package/dist/cli/{secrets-SVZB6TSW.mjs → secrets-DN3XEZNH.mjs} +6 -6
- package/dist/cli/{secrets-WKIMR346.js → secrets-FUXYSEL5.js} +15 -15
- package/dist/cli/{sessions-P3QENG6T.mjs → sessions-PMUTPCTT.mjs} +6 -6
- package/dist/cli/sessions-VMBMBGVJ.js +23 -0
- package/dist/cli/{settings-V5ABL6D2.mjs → settings-N6GNS2KA.mjs} +12 -12
- package/dist/cli/{settings-UIFRGJW3.js → settings-ZDTWCQ6B.js} +85 -85
- package/dist/cli/{setup-E67NJTEF.mjs → setup-LJ3KWPSA.mjs} +9 -9
- package/dist/cli/{setup-A5MIJU3S.js → setup-PN5TSSJE.js} +49 -49
- package/dist/cli/{skills-WLHOQ4DO.mjs → skills-7J42K6VC.mjs} +7 -7
- package/dist/cli/skills-CXDENBLF.js +37 -0
- package/dist/cli/{tools-EG4KL3BB.mjs → tools-M3S6D6DA.mjs} +17 -17
- package/dist/cli/tools-WY2GMOC7.js +57 -0
- package/dist/cli/{update-IPFBE6SA.mjs → update-XTVFG74E.mjs} +9 -9
- package/dist/cli/update-ZB2IBGXG.js +37 -0
- package/dist/cli/{views-ZIBY2RVB.js → views-B4X2FWTF.js} +21 -21
- package/dist/cli/{views-XDN6SEWY.mjs → views-UFYRDO4X.mjs} +6 -6
- package/dist/cli/{workflow-BLKPBRBT.js → workflow-I2RM2J2J.js} +53 -29
- package/dist/cli/{workflow-O2XPMOVL.mjs → workflow-ZLMS3PDE.mjs} +42 -18
- package/dist/{client-QznpkWrk.d.ts → client-2QWMJInp.d.ts} +1 -1
- package/dist/{client-CmG8MT0x.d.mts → client-7H8TXmLa.d.mts} +1 -1
- package/dist/{client-core-CY0jNW0e.d.mts → client-core-BraEuxbg.d.mts} +67 -4
- package/dist/{client-core-CXDqfeiB.d.ts → client-core-DRglY5xa.d.ts} +67 -4
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -9
- package/dist/index.mjs +6 -6
- package/dist/install-integrity.json +125 -120
- package/dist/plays/bundle-play-file.mjs +5 -0
- package/dist/plays/play-description.d.mts +1 -1
- package/dist/plays/play-description.d.ts +1 -1
- package/dist/plays/run-request.d.mts +1 -1
- package/dist/plays/run-request.d.ts +1 -1
- package/dist/release.d.mts +3 -3
- package/dist/release.d.ts +3 -3
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +5 -5
- package/dist/server.mjs +3 -3
- package/package.json +1 -1
- package/dist/cli/auth-ALBG5LF4.js +0 -44
- package/dist/cli/concurrent-runs-help-E3YMAO5Q.js +0 -22
- package/dist/cli/describe-QB5T47B3.js +0 -50
- package/dist/cli/git-4FXTWHXT.js +0 -26
- package/dist/cli/search-YZIJS7QU.js +0 -32
- package/dist/cli/sessions-VQPGPXMU.js +0 -23
- package/dist/cli/skills-GTBK33MV.js +0 -37
- package/dist/cli/tools-GPAIPRPQ.js +0 -57
- package/dist/cli/update-QLWS32WR.js +0 -37
|
@@ -14,6 +14,9 @@ import type {
|
|
|
14
14
|
} from './ctx-types';
|
|
15
15
|
import {
|
|
16
16
|
RUNTIME_RECEIPT_GATEWAY_BATCH_MAX_BYTES,
|
|
17
|
+
RUNTIME_RECEIPT_MANIFEST_RESPONSE_BYTES,
|
|
18
|
+
RUNTIME_RECEIPT_READ_TARGET_RESPONSE_BYTES,
|
|
19
|
+
RUNTIME_RECEIPT_READ_UNKNOWN_OUTPUT_BYTES,
|
|
17
20
|
RUNTIME_RECEIPT_WRITER_TARGET_BATCH_BYTES,
|
|
18
21
|
} from './output-size-limits';
|
|
19
22
|
import {
|
|
@@ -50,7 +53,13 @@ type ReceiptOutput =
|
|
|
50
53
|
type ReceiptCommand =
|
|
51
54
|
| {
|
|
52
55
|
kind: 'get';
|
|
53
|
-
input: {
|
|
56
|
+
input: {
|
|
57
|
+
key: string;
|
|
58
|
+
runId: string;
|
|
59
|
+
hydrateOutput?: boolean;
|
|
60
|
+
/** Batch sizing only; never sent to the gateway. */
|
|
61
|
+
expectedOutputBytes?: number;
|
|
62
|
+
};
|
|
54
63
|
}
|
|
55
64
|
| {
|
|
56
65
|
kind: 'claim';
|
|
@@ -163,6 +172,8 @@ export class RuntimeReceiptStoreAdapter {
|
|
|
163
172
|
maxBatchSize?: number;
|
|
164
173
|
maxBatchBytes?: number;
|
|
165
174
|
targetBatchBytes?: number;
|
|
175
|
+
/** Expected decoded bytes one read request may return. */
|
|
176
|
+
maxReadResponseBytes?: number;
|
|
166
177
|
maxFlushMs?: number;
|
|
167
178
|
maxBufferedItems?: number;
|
|
168
179
|
maxBufferedBytes?: number;
|
|
@@ -232,6 +243,10 @@ export class RuntimeReceiptStoreAdapter {
|
|
|
232
243
|
options.maxBatchBytes ?? RUNTIME_RECEIPT_GATEWAY_BATCH_MAX_BYTES,
|
|
233
244
|
targetBatchBytes:
|
|
234
245
|
options.targetBatchBytes ?? RUNTIME_RECEIPT_WRITER_TARGET_BATCH_BYTES,
|
|
246
|
+
estimateResponseBytes: receiptCommandExpectedResponseBytes,
|
|
247
|
+
maxBatchResponseBytes:
|
|
248
|
+
options.maxReadResponseBytes ??
|
|
249
|
+
RUNTIME_RECEIPT_READ_TARGET_RESPONSE_BYTES,
|
|
235
250
|
maxFlushMs: options.maxFlushMs,
|
|
236
251
|
maxBufferedItems: options.maxBufferedItems,
|
|
237
252
|
maxBufferedBytes: options.maxBufferedBytes,
|
|
@@ -252,6 +267,13 @@ export class RuntimeReceiptStoreAdapter {
|
|
|
252
267
|
context: { ...context, signal },
|
|
253
268
|
playName: options.playName,
|
|
254
269
|
commands,
|
|
270
|
+
onReadSplit: (split) =>
|
|
271
|
+
emitReceiptReadSplitTelemetry({
|
|
272
|
+
...split,
|
|
273
|
+
playName: options.playName,
|
|
274
|
+
runId: options.runId,
|
|
275
|
+
onTelemetry: options.onRetryTelemetry,
|
|
276
|
+
}),
|
|
255
277
|
}),
|
|
256
278
|
});
|
|
257
279
|
|
|
@@ -279,25 +301,34 @@ export class RuntimeReceiptStoreAdapter {
|
|
|
279
301
|
input,
|
|
280
302
|
serial: this.#nextSerial(),
|
|
281
303
|
}),
|
|
282
|
-
getRuntimeStepReceipt: ({ key, hydrateOutput }) =>
|
|
304
|
+
getRuntimeStepReceipt: ({ key, hydrateOutput, expectedOutputBytes }) =>
|
|
283
305
|
write({
|
|
284
306
|
kind: 'get',
|
|
285
307
|
input: {
|
|
286
308
|
key,
|
|
287
309
|
runId: options.runId,
|
|
288
310
|
...(hydrateOutput === false ? { hydrateOutput: false } : {}),
|
|
311
|
+
...(expectedOutputBytes === undefined
|
|
312
|
+
? {}
|
|
313
|
+
: { expectedOutputBytes }),
|
|
289
314
|
},
|
|
290
315
|
}),
|
|
291
|
-
getRuntimeStepReceipts: ({ keys, hydrateOutput }) =>
|
|
316
|
+
getRuntimeStepReceipts: ({ keys, hydrateOutput, expectedOutputBytes }) =>
|
|
292
317
|
writeMany(
|
|
293
|
-
keys.map((key) =>
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
318
|
+
keys.map((key, index) => {
|
|
319
|
+
const expected = expectedOutputBytes?.[index];
|
|
320
|
+
return {
|
|
321
|
+
kind: 'get' as const,
|
|
322
|
+
input: {
|
|
323
|
+
key,
|
|
324
|
+
runId: options.runId,
|
|
325
|
+
...(hydrateOutput === false ? { hydrateOutput: false } : {}),
|
|
326
|
+
...(expected === undefined
|
|
327
|
+
? {}
|
|
328
|
+
: { expectedOutputBytes: expected }),
|
|
329
|
+
},
|
|
330
|
+
};
|
|
331
|
+
}),
|
|
301
332
|
),
|
|
302
333
|
claimRuntimeStepReceipt: (input) => write({ kind: 'claim', input }),
|
|
303
334
|
claimRuntimeStepReceipts: (input) =>
|
|
@@ -493,10 +524,63 @@ function emitReceiptWriterRetryTelemetry(input: {
|
|
|
493
524
|
}
|
|
494
525
|
}
|
|
495
526
|
|
|
527
|
+
/**
|
|
528
|
+
* What one read is expected to return, for read batch sizing. A manifest is
|
|
529
|
+
* small; a full read costs its known output size, or a conservative prior.
|
|
530
|
+
* Claims stay count-bounded: almost every claim is a miss that returns no
|
|
531
|
+
* body, and pricing them would split the hot path of every new row. Cache
|
|
532
|
+
* hits are read through manifests and priced full reads instead.
|
|
533
|
+
*/
|
|
534
|
+
function receiptCommandExpectedResponseBytes(command: ReceiptCommand): number {
|
|
535
|
+
if (command.kind !== 'get') return 0;
|
|
536
|
+
if (command.input.hydrateOutput === false) {
|
|
537
|
+
return RUNTIME_RECEIPT_MANIFEST_RESPONSE_BYTES;
|
|
538
|
+
}
|
|
539
|
+
const expected = command.input.expectedOutputBytes;
|
|
540
|
+
return (
|
|
541
|
+
RUNTIME_RECEIPT_MANIFEST_RESPONSE_BYTES +
|
|
542
|
+
(expected !== undefined && Number.isFinite(expected) && expected >= 0
|
|
543
|
+
? expected
|
|
544
|
+
: RUNTIME_RECEIPT_READ_UNKNOWN_OUTPUT_BYTES)
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
const RECEIPT_READ_SPLIT_TELEMETRY_TAG = '[runtime.receipt_read.split]';
|
|
549
|
+
|
|
550
|
+
function emitReceiptReadSplitTelemetry(input: {
|
|
551
|
+
keys: number;
|
|
552
|
+
halves: [number, number];
|
|
553
|
+
hydrateOutput: boolean;
|
|
554
|
+
playName: string;
|
|
555
|
+
runId: string;
|
|
556
|
+
onTelemetry?: (line: string) => void;
|
|
557
|
+
}): void {
|
|
558
|
+
try {
|
|
559
|
+
const serialized = JSON.stringify({
|
|
560
|
+
event: 'runtime.receipt_read.split',
|
|
561
|
+
playName: input.playName,
|
|
562
|
+
runId: input.runId,
|
|
563
|
+
keys: input.keys,
|
|
564
|
+
halves: input.halves,
|
|
565
|
+
hydrateOutput: input.hydrateOutput,
|
|
566
|
+
});
|
|
567
|
+
input.onTelemetry?.(`${RECEIPT_READ_SPLIT_TELEMETRY_TAG} ${serialized}`);
|
|
568
|
+
console.warn(RECEIPT_READ_SPLIT_TELEMETRY_TAG, serialized);
|
|
569
|
+
} catch {
|
|
570
|
+
// Telemetry must never affect a receipt read.
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
|
|
496
574
|
function receiptCommandBatchKey(command: ReceiptCommand): string {
|
|
497
575
|
switch (command.kind) {
|
|
498
576
|
case 'get':
|
|
499
|
-
|
|
577
|
+
// Manifest and full reads never share a request: one full read must not
|
|
578
|
+
// turn a batch of bounded manifests into a batch of bodies.
|
|
579
|
+
return JSON.stringify([
|
|
580
|
+
command.kind,
|
|
581
|
+
command.input.runId,
|
|
582
|
+
command.input.hydrateOutput !== false,
|
|
583
|
+
]);
|
|
500
584
|
case 'claim':
|
|
501
585
|
return JSON.stringify([
|
|
502
586
|
command.kind,
|
|
@@ -507,6 +591,7 @@ function receiptCommandBatchKey(command: ReceiptCommand): string {
|
|
|
507
591
|
command.input.forceRefresh === true,
|
|
508
592
|
command.input.forceFailedRefresh === true,
|
|
509
593
|
command.input.leaseId !== undefined,
|
|
594
|
+
command.input.hydrateOutput !== false,
|
|
510
595
|
]);
|
|
511
596
|
case 'settle':
|
|
512
597
|
return command.outcome === 'complete' ||
|
|
@@ -579,10 +664,101 @@ function classifyReceiptRetry(
|
|
|
579
664
|
return null;
|
|
580
665
|
}
|
|
581
666
|
|
|
667
|
+
/**
|
|
668
|
+
* A receipt read that ran past the store's query deadline. The gateway maps
|
|
669
|
+
* node-postgres's uncoded `Query read timeout` to a retryable 503 and keeps
|
|
670
|
+
* the message as the response detail. Retrying the same keys asks the store
|
|
671
|
+
* for the same bytes, so a multi-key read splits instead.
|
|
672
|
+
*/
|
|
673
|
+
export function isReceiptReadTimeoutError(error: unknown): boolean {
|
|
674
|
+
if (error instanceof AppRuntimeApiResponseError) {
|
|
675
|
+
return error.retryable && error.detail.includes('Query read timeout');
|
|
676
|
+
}
|
|
677
|
+
// Headers arrived but the body did not: the gateway is still assembling a
|
|
678
|
+
// response too large to deliver in time.
|
|
679
|
+
return (
|
|
680
|
+
error instanceof AppRuntimeApiTransportError &&
|
|
681
|
+
error.responseReceived === true
|
|
682
|
+
);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
export type ReceiptReadSplitEvent = {
|
|
686
|
+
/** Keys in the read that timed out, and in each half sent instead. */
|
|
687
|
+
keys: number;
|
|
688
|
+
halves: [number, number];
|
|
689
|
+
hydrateOutput: boolean;
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* Wall-clock budget for splitting one timed-out read. Past it, the timeout
|
|
694
|
+
* goes back to the writer, whose own retry deadline then governs, so a read
|
|
695
|
+
* that keeps timing out is bounded by time rather than by split depth.
|
|
696
|
+
*/
|
|
697
|
+
export const RUNTIME_RECEIPT_READ_SPLIT_BUDGET_MS = 90_000;
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Read receipts, halving any multi-key read that times out. Reads are pure,
|
|
701
|
+
* so a half can be sent without the other; results keep request order. A
|
|
702
|
+
* single key that times out, or any timeout after the split budget is spent,
|
|
703
|
+
* is left to the writer's ordinary retry budget.
|
|
704
|
+
*/
|
|
705
|
+
async function readReceiptsSplittingOnTimeout(input: {
|
|
706
|
+
context: WorkerRuntimeApiContext;
|
|
707
|
+
playName: string;
|
|
708
|
+
runId: string;
|
|
709
|
+
keys: readonly string[];
|
|
710
|
+
hydrateOutput: boolean;
|
|
711
|
+
onReadSplit?: (event: ReceiptReadSplitEvent) => void;
|
|
712
|
+
/** Epoch ms after which no further split starts; set by the first read. */
|
|
713
|
+
splitDeadlineMs?: number;
|
|
714
|
+
}): Promise<Array<RuntimeStepReceipt | null>> {
|
|
715
|
+
const splitDeadlineMs =
|
|
716
|
+
input.splitDeadlineMs ?? Date.now() + RUNTIME_RECEIPT_READ_SPLIT_BUDGET_MS;
|
|
717
|
+
try {
|
|
718
|
+
return await getRuntimeStepReceiptsViaAppRuntime(input.context, {
|
|
719
|
+
playName: input.playName,
|
|
720
|
+
runId: input.runId,
|
|
721
|
+
keys: [...input.keys],
|
|
722
|
+
...(input.hydrateOutput ? {} : { hydrateOutput: false }),
|
|
723
|
+
});
|
|
724
|
+
} catch (error) {
|
|
725
|
+
if (
|
|
726
|
+
input.keys.length < 2 ||
|
|
727
|
+
input.context.signal?.aborted ||
|
|
728
|
+
!isReceiptReadTimeoutError(error) ||
|
|
729
|
+
Date.now() >= splitDeadlineMs
|
|
730
|
+
) {
|
|
731
|
+
throw error;
|
|
732
|
+
}
|
|
733
|
+
const middle = Math.ceil(input.keys.length / 2);
|
|
734
|
+
const left = input.keys.slice(0, middle);
|
|
735
|
+
const right = input.keys.slice(middle);
|
|
736
|
+
input.onReadSplit?.({
|
|
737
|
+
keys: input.keys.length,
|
|
738
|
+
halves: [left.length, right.length],
|
|
739
|
+
hydrateOutput: input.hydrateOutput,
|
|
740
|
+
});
|
|
741
|
+
// Sequential: the halves share whatever made the whole read slow.
|
|
742
|
+
const first = await readReceiptsSplittingOnTimeout({
|
|
743
|
+
...input,
|
|
744
|
+
keys: left,
|
|
745
|
+
splitDeadlineMs,
|
|
746
|
+
});
|
|
747
|
+
if (Date.now() >= splitDeadlineMs) throw error;
|
|
748
|
+
const second = await readReceiptsSplittingOnTimeout({
|
|
749
|
+
...input,
|
|
750
|
+
keys: right,
|
|
751
|
+
splitDeadlineMs,
|
|
752
|
+
});
|
|
753
|
+
return [...first, ...second];
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
|
|
582
757
|
async function sendReceiptCommands(input: {
|
|
583
758
|
context: WorkerRuntimeApiContext;
|
|
584
759
|
playName: string;
|
|
585
760
|
commands: readonly ReceiptCommand[];
|
|
761
|
+
onReadSplit?: (event: ReceiptReadSplitEvent) => void;
|
|
586
762
|
}): Promise<readonly ReceiptOutput[]> {
|
|
587
763
|
const first = input.commands[0];
|
|
588
764
|
if (!first) return [];
|
|
@@ -592,16 +768,18 @@ async function sendReceiptCommands(input: {
|
|
|
592
768
|
ReceiptCommand,
|
|
593
769
|
{ kind: 'get' }
|
|
594
770
|
>[];
|
|
595
|
-
|
|
771
|
+
// The batch key separates manifest reads from full reads, so a batch is
|
|
772
|
+
// uniform. Keep the conservative check: a full read is never narrowed
|
|
773
|
+
// to a manifest because one command in its batch asked for one.
|
|
774
|
+
return await readReceiptsSplittingOnTimeout({
|
|
775
|
+
context: input.context,
|
|
596
776
|
playName: input.playName,
|
|
597
777
|
runId: first.input.runId,
|
|
598
778
|
keys: commands.map((command) => command.input.key),
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
...(
|
|
603
|
-
? { hydrateOutput: false }
|
|
604
|
-
: {}),
|
|
779
|
+
hydrateOutput: !commands.every(
|
|
780
|
+
(command) => command.input.hydrateOutput === false,
|
|
781
|
+
),
|
|
782
|
+
...(input.onReadSplit ? { onReadSplit: input.onReadSplit } : {}),
|
|
605
783
|
});
|
|
606
784
|
}
|
|
607
785
|
case 'claim': {
|
|
@@ -17,6 +17,8 @@ type PendingWrite<Input, Output> = {
|
|
|
17
17
|
lane: string;
|
|
18
18
|
keyIds: readonly unknown[];
|
|
19
19
|
bytes: number;
|
|
20
|
+
/** Expected response bytes; 0 unless `estimateResponseBytes` is set. */
|
|
21
|
+
responseBytes: number;
|
|
20
22
|
signal: AbortSignal | null;
|
|
21
23
|
state: 'queued' | 'active' | 'settled';
|
|
22
24
|
aborted: unknown;
|
|
@@ -168,6 +170,8 @@ export class RuntimeReceiptWriter<Input, Output> {
|
|
|
168
170
|
error: unknown,
|
|
169
171
|
) => RetryableReceiptError | null;
|
|
170
172
|
readonly #estimateBytes: (input: Input) => number;
|
|
173
|
+
readonly #estimateResponseBytes: ((input: Input) => number) | null;
|
|
174
|
+
readonly #maxBatchResponseBytes: number;
|
|
171
175
|
readonly #maxBatchSize: number;
|
|
172
176
|
readonly #maxBatchBytes: number;
|
|
173
177
|
readonly #targetBatchBytes: number;
|
|
@@ -239,6 +243,14 @@ export class RuntimeReceiptWriter<Input, Output> {
|
|
|
239
243
|
) => Promise<readonly Output[]>;
|
|
240
244
|
classifyRetryableError?: (error: unknown) => RetryableReceiptError | null;
|
|
241
245
|
estimateBytes?: (input: Input) => number;
|
|
246
|
+
/**
|
|
247
|
+
* Expected size of the response a command asks for. A read request is a
|
|
248
|
+
* few hundred bytes, but what it returns can be megabytes: request bytes
|
|
249
|
+
* alone cannot bound it. Batches close before their summed estimate passes
|
|
250
|
+
* `maxBatchResponseBytes`; a single command always forms a batch.
|
|
251
|
+
*/
|
|
252
|
+
estimateResponseBytes?: (input: Input) => number;
|
|
253
|
+
maxBatchResponseBytes?: number;
|
|
242
254
|
maxBatchSize?: number;
|
|
243
255
|
maxBatchBytes?: number;
|
|
244
256
|
targetBatchBytes?: number;
|
|
@@ -283,6 +295,11 @@ export class RuntimeReceiptWriter<Input, Output> {
|
|
|
283
295
|
this.#classifyRetryableError =
|
|
284
296
|
options.classifyRetryableError ?? (() => null);
|
|
285
297
|
this.#estimateBytes = options.estimateBytes ?? estimateJsonBytes;
|
|
298
|
+
this.#estimateResponseBytes = options.estimateResponseBytes ?? null;
|
|
299
|
+
this.#maxBatchResponseBytes = normalizePositiveInteger(
|
|
300
|
+
options.maxBatchResponseBytes,
|
|
301
|
+
Number.MAX_SAFE_INTEGER,
|
|
302
|
+
);
|
|
286
303
|
this.#maxBatchSize = normalizePositiveInteger(options.maxBatchSize, 100);
|
|
287
304
|
this.#maxBufferedBytes = normalizePositiveInteger(
|
|
288
305
|
options.maxBufferedBytes,
|
|
@@ -457,6 +474,9 @@ export class RuntimeReceiptWriter<Input, Output> {
|
|
|
457
474
|
...new Set(this.#orderingKeys(input).map(orderingKeyIdentity)),
|
|
458
475
|
],
|
|
459
476
|
bytes,
|
|
477
|
+
responseBytes: this.#estimateResponseBytes
|
|
478
|
+
? Math.max(0, Math.ceil(this.#estimateResponseBytes(input)))
|
|
479
|
+
: 0,
|
|
460
480
|
signal: options.signal ?? null,
|
|
461
481
|
state: 'queued',
|
|
462
482
|
aborted: null,
|
|
@@ -771,6 +791,7 @@ export class RuntimeReceiptWriter<Input, Output> {
|
|
|
771
791
|
let selectedBatchKey: unknown;
|
|
772
792
|
let selectedLane: string | null = null;
|
|
773
793
|
let batchBytes = 0;
|
|
794
|
+
let batchResponseBytes = 0;
|
|
774
795
|
|
|
775
796
|
for (;;) {
|
|
776
797
|
// The oldest command among the open lanes.
|
|
@@ -803,6 +824,7 @@ export class RuntimeReceiptWriter<Input, Output> {
|
|
|
803
824
|
selectedBatchKey = this.#batchKey(pending.input);
|
|
804
825
|
selectedLane = pending.lane;
|
|
805
826
|
batchBytes = pending.bytes;
|
|
827
|
+
batchResponseBytes = pending.responseBytes;
|
|
806
828
|
continue;
|
|
807
829
|
}
|
|
808
830
|
|
|
@@ -816,12 +838,14 @@ export class RuntimeReceiptWriter<Input, Output> {
|
|
|
816
838
|
selectedLane !== pending.lane ||
|
|
817
839
|
!Object.is(this.#batchKey(pending.input), selectedBatchKey) ||
|
|
818
840
|
selected.length >= this.#maxBatchSize ||
|
|
819
|
-
batchBytes + pending.bytes > this.#targetBatchBytes
|
|
841
|
+
batchBytes + pending.bytes > this.#targetBatchBytes ||
|
|
842
|
+
batchResponseBytes + pending.responseBytes > this.#maxBatchResponseBytes
|
|
820
843
|
) {
|
|
821
844
|
break;
|
|
822
845
|
}
|
|
823
846
|
selected.push(pending);
|
|
824
847
|
batchBytes += pending.bytes;
|
|
848
|
+
batchResponseBytes += pending.responseBytes;
|
|
825
849
|
}
|
|
826
850
|
return selected;
|
|
827
851
|
}
|
|
@@ -54,6 +54,11 @@ export function isIsolatedRuntimeSchedulerSchema(
|
|
|
54
54
|
* correctness. Isolated schemas deliberately share a small direct-connection
|
|
55
55
|
* budget across preview workers, so they use that polling path and leave
|
|
56
56
|
* direct sessions to the production topology.
|
|
57
|
+
*
|
|
58
|
+
* The same answer decides whether the schema sends NOTIFY at all
|
|
59
|
+
* (`postgresSchedulerNotifySql`, `absurd-wake-policy.ts`): every notifying
|
|
60
|
+
* commit serializes on one cluster-wide lock, heard or not, so a schema that
|
|
61
|
+
* nobody LISTENs on stays silent, and one that gains listeners notifies again.
|
|
57
62
|
*/
|
|
58
63
|
export function shouldUseRuntimeSchedulerDirectNotify(
|
|
59
64
|
schedulerSchema: string | null | undefined,
|
package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts
CHANGED
|
@@ -133,6 +133,7 @@ import {
|
|
|
133
133
|
selectRuntimeSandboxCanary,
|
|
134
134
|
} from '../runtime-sandbox-placement-policy';
|
|
135
135
|
import {
|
|
136
|
+
isIsolatedRuntimeSchedulerSchema,
|
|
136
137
|
resolvePreviewWorkerClaimAffinityReader,
|
|
137
138
|
resolvePreviewWorkerListenerElection,
|
|
138
139
|
shouldUseRuntimeSchedulerDirectNotify,
|
|
@@ -333,6 +334,12 @@ import {
|
|
|
333
334
|
withRuntimeSchedulerClient,
|
|
334
335
|
} from './postgres-pool';
|
|
335
336
|
import { runWithAbsurdSchedulerQuerySignal } from './absurd-pool';
|
|
337
|
+
import {
|
|
338
|
+
absurdWorkerWakeLeaderLockKey,
|
|
339
|
+
clearAbsurdQueueWakeUnheard,
|
|
340
|
+
clearAbsurdQueueWakeUnheardForListener,
|
|
341
|
+
markAbsurdQueueWakeUnheard,
|
|
342
|
+
} from './absurd-wake-policy';
|
|
336
343
|
import {
|
|
337
344
|
createEarlySandboxClaimGate,
|
|
338
345
|
EARLY_SANDBOX_CLAIM_AFFINITY_READER,
|
|
@@ -405,6 +412,7 @@ import {
|
|
|
405
412
|
reserveRuntimeSandboxOperation,
|
|
406
413
|
RUNTIME_SANDBOX_CAPACITY_LEASE_MS,
|
|
407
414
|
runtimeSandboxCapacityAdmissionMode,
|
|
415
|
+
type RuntimeSandboxCapacityAdmissionMode,
|
|
408
416
|
RuntimeSandboxCapacityLimitError,
|
|
409
417
|
} from './runtime-sandbox-capacity';
|
|
410
418
|
import {
|
|
@@ -11763,7 +11771,7 @@ export function createAbsurdWorkerWakeHook(input: {
|
|
|
11763
11771
|
url: input.poolOptions.url,
|
|
11764
11772
|
channel: ABSURD_WAKE_CHANNEL,
|
|
11765
11773
|
applicationName: 'deepline-absurd-worker-wake',
|
|
11766
|
-
leaderLockKey:
|
|
11774
|
+
leaderLockKey: absurdWorkerWakeLeaderLockKey(input.queue),
|
|
11767
11775
|
});
|
|
11768
11776
|
if (!lease) return () => wakeHandlers.delete(wake);
|
|
11769
11777
|
const unsubscribeNotify = lease.hub.subscribe((payload) => {
|
|
@@ -11969,6 +11977,9 @@ export function createAbsurdRuntimeWorkerHostLifecycle(input: {
|
|
|
11969
11977
|
return closing !== null || capacity.draining;
|
|
11970
11978
|
},
|
|
11971
11979
|
hasIdleSlot: () => closing === null && capacity.hasIdleSlot(),
|
|
11980
|
+
...(capacity.orgSandboxCapacity
|
|
11981
|
+
? { orgSandboxCapacity: capacity.orgSandboxCapacity }
|
|
11982
|
+
: {}),
|
|
11972
11983
|
},
|
|
11973
11984
|
}
|
|
11974
11985
|
: {}),
|
|
@@ -12023,6 +12034,46 @@ export function resolveAbsurdRuntimeWorkerReleaseIdentity(
|
|
|
12023
12034
|
};
|
|
12024
12035
|
}
|
|
12025
12036
|
|
|
12037
|
+
/** Bound on the early-sandbox org-capacity read before an early create. */
|
|
12038
|
+
export const EARLY_SANDBOX_ORG_CAPACITY_CHECK_TIMEOUT_MS = 1_000;
|
|
12039
|
+
|
|
12040
|
+
/**
|
|
12041
|
+
* The pool's signal bounds admission only, not the query, so the early create
|
|
12042
|
+
* waits on the read no longer than the bound: past it the check rejects and
|
|
12043
|
+
* the create proceeds as before (`create_gate_failed`).
|
|
12044
|
+
*/
|
|
12045
|
+
export function withEarlySandboxOrgCapacityDeadline<T>(
|
|
12046
|
+
read: Promise<T>,
|
|
12047
|
+
timeoutMs: number = EARLY_SANDBOX_ORG_CAPACITY_CHECK_TIMEOUT_MS,
|
|
12048
|
+
): Promise<T> {
|
|
12049
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
12050
|
+
const deadline = new Promise<never>((_, reject) => {
|
|
12051
|
+
timer = setTimeout(
|
|
12052
|
+
() =>
|
|
12053
|
+
reject(
|
|
12054
|
+
new Error(
|
|
12055
|
+
`early sandbox org capacity check exceeded ${timeoutMs} ms`,
|
|
12056
|
+
),
|
|
12057
|
+
),
|
|
12058
|
+
timeoutMs,
|
|
12059
|
+
);
|
|
12060
|
+
timer.unref?.();
|
|
12061
|
+
});
|
|
12062
|
+
return Promise.race([read, deadline]).finally(() => clearTimeout(timer));
|
|
12063
|
+
}
|
|
12064
|
+
|
|
12065
|
+
/**
|
|
12066
|
+
* Only `enforce` admission holds a run at its org's sandbox limit. In `observe`
|
|
12067
|
+
* an over-limit org still starts runs immediately, so a "full" read would skip
|
|
12068
|
+
* an early create the run would have adopted; install the check only then.
|
|
12069
|
+
*/
|
|
12070
|
+
export function earlySandboxOrgCapacityCheckForAdmissionMode<T>(
|
|
12071
|
+
mode: RuntimeSandboxCapacityAdmissionMode,
|
|
12072
|
+
check: T,
|
|
12073
|
+
): { orgSandboxCapacity: T } | Record<string, never> {
|
|
12074
|
+
return mode === 'enforce' ? { orgSandboxCapacity: check } : {};
|
|
12075
|
+
}
|
|
12076
|
+
|
|
12026
12077
|
/**
|
|
12027
12078
|
* Start one poll loop and slot pool. Event waits park the task in Postgres and
|
|
12028
12079
|
* release the slot until their own top-level play resumes.
|
|
@@ -12186,6 +12237,33 @@ export async function startRuntimeWorkerHost(
|
|
|
12186
12237
|
previewDirectNotifyWake: PREVIEW_WORKER_DIRECT_NOTIFY_WAKE,
|
|
12187
12238
|
previewListenerElection,
|
|
12188
12239
|
});
|
|
12240
|
+
// An isolated lane whose workers will not LISTEN marks its queue so the
|
|
12241
|
+
// engine stops sending wakes nobody hears (`absurd-wake-policy.ts`). A
|
|
12242
|
+
// listener that wins the election clears it below. Production never marks.
|
|
12243
|
+
const isolatedQueueWakePolicy = isIsolatedRuntimeSchedulerSchema(
|
|
12244
|
+
schedulerOptions.schema,
|
|
12245
|
+
);
|
|
12246
|
+
if (isolatedQueueWakePolicy && (!useDirectNotify || drainExit)) {
|
|
12247
|
+
// A failed mark leaves the queue notifying, which is today's behavior;
|
|
12248
|
+
// it must not stop the lane from serving.
|
|
12249
|
+
try {
|
|
12250
|
+
const outcome = await withRuntimeSchedulerClient(poolOptions, (client) =>
|
|
12251
|
+
markAbsurdQueueWakeUnheard(client, queue),
|
|
12252
|
+
);
|
|
12253
|
+
console.info('[absurd-runtime.worker] queue_wake_policy', {
|
|
12254
|
+
event: 'mark_unheard',
|
|
12255
|
+
queue,
|
|
12256
|
+
outcome,
|
|
12257
|
+
});
|
|
12258
|
+
} catch (error) {
|
|
12259
|
+
console.error('[absurd-runtime.worker] queue_wake_policy', {
|
|
12260
|
+
event: 'mark_unheard_failed',
|
|
12261
|
+
queue,
|
|
12262
|
+
error: error instanceof Error ? error.message : String(error),
|
|
12263
|
+
});
|
|
12264
|
+
}
|
|
12265
|
+
}
|
|
12266
|
+
let restoreQueueWakesForListener: (() => void) | null = null;
|
|
12189
12267
|
// LH: this process's listener generations for its queue (in memory).
|
|
12190
12268
|
const listenerLeadership = createEarlySandboxListenerLeadership({ queue });
|
|
12191
12269
|
const onWake = createAbsurdWorkerWakeHook({
|
|
@@ -12205,8 +12283,33 @@ export async function startRuntimeWorkerHost(
|
|
|
12205
12283
|
queue,
|
|
12206
12284
|
generation: listening ? listenerLeadership.generation() : ended,
|
|
12207
12285
|
});
|
|
12286
|
+
if (listening) restoreQueueWakesForListener?.();
|
|
12208
12287
|
},
|
|
12209
12288
|
});
|
|
12289
|
+
if (isolatedQueueWakePolicy && onWake) {
|
|
12290
|
+
restoreQueueWakesForListener = () => {
|
|
12291
|
+
void clearAbsurdQueueWakeUnheardForListener({
|
|
12292
|
+
clear: () =>
|
|
12293
|
+
withRuntimeSchedulerClient(poolOptions, (client) =>
|
|
12294
|
+
clearAbsurdQueueWakeUnheard(client, queue),
|
|
12295
|
+
),
|
|
12296
|
+
stillListening: () => onWake.isListening(),
|
|
12297
|
+
wake: () => onWake.wake(),
|
|
12298
|
+
onError: (error) =>
|
|
12299
|
+
console.error('[absurd-runtime.worker] queue_wake_policy', {
|
|
12300
|
+
event: 'clear_unheard_failed',
|
|
12301
|
+
queue,
|
|
12302
|
+
error: error instanceof Error ? error.message : String(error),
|
|
12303
|
+
}),
|
|
12304
|
+
}).then((outcome) =>
|
|
12305
|
+
console.info('[absurd-runtime.worker] queue_wake_policy', {
|
|
12306
|
+
event: 'clear_unheard',
|
|
12307
|
+
queue,
|
|
12308
|
+
outcome,
|
|
12309
|
+
}),
|
|
12310
|
+
);
|
|
12311
|
+
};
|
|
12312
|
+
}
|
|
12210
12313
|
claimAffinityWake = onWake ? () => onWake.wake() : null;
|
|
12211
12314
|
let ownerProbeStopped = false;
|
|
12212
12315
|
const earlySandboxClaimOwner: RuntimeWorkerHost['earlySandboxClaimOwner'] =
|
|
@@ -12570,6 +12673,42 @@ export async function startRuntimeWorkerHost(
|
|
|
12570
12673
|
earlySandboxCapacity: {
|
|
12571
12674
|
draining: drainExit,
|
|
12572
12675
|
hasIdleSlot: claimLoop.hasIdleSlot,
|
|
12676
|
+
// One bounded read: a slow or failed check creates as before.
|
|
12677
|
+
...earlySandboxOrgCapacityCheckForAdmissionMode(
|
|
12678
|
+
runtimeSandboxCapacityAdmissionMode(),
|
|
12679
|
+
({
|
|
12680
|
+
orgId,
|
|
12681
|
+
runId,
|
|
12682
|
+
entitlementLimit,
|
|
12683
|
+
}: {
|
|
12684
|
+
orgId: string;
|
|
12685
|
+
runId: string;
|
|
12686
|
+
entitlementLimit: number | null;
|
|
12687
|
+
}) =>
|
|
12688
|
+
withEarlySandboxOrgCapacityDeadline(
|
|
12689
|
+
withRuntimeSchedulerClient(
|
|
12690
|
+
poolOptions,
|
|
12691
|
+
(client) =>
|
|
12692
|
+
precheckRuntimeSandboxCapacity(
|
|
12693
|
+
client,
|
|
12694
|
+
// The hint's carried entitlement, as the launch passes
|
|
12695
|
+
// `concurrentRunsLimit`: a plan-limited org has no cache
|
|
12696
|
+
// row, so without it the check would judge the default.
|
|
12697
|
+
{ orgId, runId, entitlementLimit },
|
|
12698
|
+
schedulerOptions.schema
|
|
12699
|
+
? { schema: schedulerOptions.schema }
|
|
12700
|
+
: {},
|
|
12701
|
+
),
|
|
12702
|
+
{ runId, phase: 'early_sandbox_org_capacity' },
|
|
12703
|
+
{
|
|
12704
|
+
maxAttempts: 1,
|
|
12705
|
+
signal: AbortSignal.timeout(
|
|
12706
|
+
EARLY_SANDBOX_ORG_CAPACITY_CHECK_TIMEOUT_MS,
|
|
12707
|
+
),
|
|
12708
|
+
},
|
|
12709
|
+
),
|
|
12710
|
+
),
|
|
12711
|
+
),
|
|
12573
12712
|
},
|
|
12574
12713
|
// Release LISTEN before joining accepted work, so a replacement can elect
|
|
12575
12714
|
// its listener without exhausting primary scheduler sessions.
|