deepline 0.3.534 → 0.3.535
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 -0
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/call-requeue-state-machine.ts +420 -0
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +658 -25
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +26 -0
- package/dist/bundling-sources/shared_libs/play-runtime/durable-retry-policy.ts +624 -0
- package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +51 -1
- package/dist/bundling-sources/shared_libs/play-runtime/map-memory-limits.ts +245 -1
- package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +21 -0
- package/dist/bundling-sources/shared_libs/play-runtime/provider-no-progress.ts +6 -2
- package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +10 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-tool-hooks.ts +55 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +6 -0
- package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +101 -0
- package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +63 -13
- package/dist/cli/auth-VDCU3T6A.js +43 -0
- package/dist/cli/{auth-MHQYIMVX.mjs → auth-ZCTMB5RA.mjs} +5 -5
- package/dist/cli/{billing-YQLNP4S5.js → billing-GVFKZQH3.js} +82 -82
- package/dist/cli/{billing-LX2PSBJ4.mjs → billing-OU2ZHL72.mjs} +7 -7
- package/dist/cli/{chunk-MQX363YF.js → chunk-243O3FH5.js} +5 -5
- package/dist/cli/{chunk-MYSKWJMA.js → chunk-2D6SWQTK.js} +13 -13
- package/dist/cli/{chunk-NDFNBJGL.js → chunk-4NLRWKZB.js} +26 -26
- package/dist/cli/{chunk-5LZ5VSOK.mjs → chunk-4QELPWUW.mjs} +2 -2
- package/dist/cli/{chunk-GTXSUPCJ.js → chunk-5EKNDNFQ.js} +2 -2
- package/dist/cli/{chunk-V7SCRUFQ.js → chunk-6LHX33VN.js} +6 -6
- package/dist/cli/{chunk-ENCA6O2D.mjs → chunk-6TYRRNXY.mjs} +2 -2
- package/dist/cli/{chunk-AK622KIG.mjs → chunk-7CWSAEYS.mjs} +1 -1
- package/dist/cli/{chunk-DZS4JC7I.js → chunk-7PXP2FQK.js} +2 -2
- package/dist/cli/{chunk-KJVY7V2X.mjs → chunk-7R5DAANG.mjs} +1 -1
- package/dist/cli/{chunk-6IFZPEJE.mjs → chunk-AUEUAPVS.mjs} +1 -1
- package/dist/cli/{chunk-XRZJKHUA.mjs → chunk-BF65LB7X.mjs} +3 -3
- package/dist/cli/{chunk-B2AS3R5W.js → chunk-CIDATNTY.js} +16 -16
- package/dist/cli/{chunk-UWNVFAFN.js → chunk-D4MHCCIR.js} +4 -4
- package/dist/cli/{chunk-GVGQ6NZW.js → chunk-DAPKLYST.js} +41 -41
- package/dist/cli/{chunk-BDWZBMGV.mjs → chunk-DFJODFMC.mjs} +5 -5
- package/dist/cli/{chunk-7GFR5Y4J.mjs → chunk-DWPY6ZID.mjs} +1 -1
- package/dist/cli/{chunk-KSA2XE4T.js → chunk-DYIWDUY4.js} +104 -104
- package/dist/cli/{chunk-5FXMEEF4.mjs → chunk-E3CLOVG5.mjs} +17 -5
- package/dist/cli/{chunk-DGKTHWWH.js → chunk-FGN75ZN6.js} +23 -7
- package/dist/cli/{chunk-MG6YL4M7.mjs → chunk-FZKPPB5P.mjs} +17 -1
- package/dist/cli/{chunk-2P3NVX65.mjs → chunk-G2DLG32W.mjs} +10 -10
- package/dist/cli/{chunk-O53LHONF.mjs → chunk-H6SWS5CG.mjs} +2 -2
- package/dist/cli/{chunk-XBK6WCVA.js → chunk-HWPOXCCK.js} +3 -3
- package/dist/cli/{chunk-HCD36BP6.js → chunk-HYBZWSSH.js} +44 -44
- package/dist/cli/{chunk-BXIUZM5N.mjs → chunk-J75DANZY.mjs} +2 -2
- package/dist/cli/{chunk-KXQCUX3X.mjs → chunk-JQQG4QL4.mjs} +3 -3
- package/dist/cli/{chunk-62SOZ67Y.mjs → chunk-JWWYLGUT.mjs} +2 -2
- package/dist/cli/{chunk-IX45S5VC.js → chunk-K3IPGMGP.js} +11 -11
- package/dist/cli/{chunk-OMVVHX4U.mjs → chunk-K53NKWZO.mjs} +5 -5
- package/dist/cli/{chunk-WR4WETRU.mjs → chunk-K76AEBFY.mjs} +4 -4
- package/dist/cli/{chunk-HPJAE6PP.js → chunk-KA6ZERJL.js} +6 -6
- package/dist/cli/{chunk-MQORQ7WL.js → chunk-KOZBZPRM.js} +53 -53
- package/dist/cli/{chunk-EGTUOYYG.js → chunk-KWGXHPHL.js} +7 -7
- package/dist/cli/{chunk-WDNRPZED.mjs → chunk-LVISZFYO.mjs} +2 -2
- package/dist/cli/{chunk-TVINIDHB.js → chunk-OM732MGV.js} +9 -9
- package/dist/cli/{chunk-JBBJDFUJ.js → chunk-PHLNYBAA.js} +5 -5
- package/dist/cli/{chunk-RH3YRMUY.js → chunk-PI5R65OQ.js} +1 -1
- package/dist/cli/{chunk-NNAE7E23.mjs → chunk-QYBAHYP4.mjs} +6 -6
- package/dist/cli/{chunk-TQH3533L.mjs → chunk-R2KKEHJN.mjs} +5 -5
- package/dist/cli/{chunk-6CEUQYMB.js → chunk-RFQWSH6I.js} +3 -3
- package/dist/cli/{chunk-TG2UB3A5.mjs → chunk-RKY4LBX3.mjs} +1 -1
- package/dist/cli/{chunk-D3J2Y2BP.js → chunk-T7RBM2WX.js} +14 -14
- package/dist/cli/{chunk-DQ5ADV2J.mjs → chunk-TCVCFZP6.mjs} +1 -1
- package/dist/cli/{chunk-LGRZCHKC.js → chunk-UUQ2OXMH.js} +16 -16
- package/dist/cli/{chunk-E7TP25I2.mjs → chunk-W5YJYU4G.mjs} +1 -1
- package/dist/cli/{chunk-VAG5YKP6.mjs → chunk-W6T23EUC.mjs} +1 -1
- package/dist/cli/{chunk-EYXUAJAU.mjs → chunk-WAIBM6KX.mjs} +5 -5
- package/dist/cli/{chunk-VE7ZPLN2.js → chunk-WNNA4L6Z.js} +22 -22
- package/dist/cli/{chunk-SUWTLXCV.js → chunk-XSOTEVOB.js} +17 -5
- package/dist/cli/{chunk-6GTGWZJG.mjs → chunk-YFZLZNTH.mjs} +2 -2
- package/dist/cli/{chunk-A6HNT4EE.js → chunk-ZUVE63Y7.js} +2 -2
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/{csv-U3M2G76R.js → csv-CD55KEIO.js} +13 -13
- package/dist/cli/{csv-4ID4E5W3.mjs → csv-CLPVMIRF.mjs} +4 -4
- package/dist/cli/{db-LHX5BBCZ.mjs → db-AU4SMWUN.mjs} +6 -6
- package/dist/cli/{db-IHAQIKEQ.js → db-MQKLDAEO.js} +27 -27
- package/dist/cli/describe-5BFNHT5V.js +50 -0
- package/dist/cli/{describe-CI4MREFF.mjs → describe-AWJUXE2U.mjs} +18 -18
- package/dist/cli/describe-core.d.mts +3 -3
- package/dist/cli/describe-core.d.ts +3 -3
- package/dist/cli/{executions-CJ5LV23G.js → executions-77GOLWRM.js} +8 -8
- package/dist/cli/{executions-UJ6JZUL5.mjs → executions-TFIJPUX7.mjs} +6 -6
- package/dist/cli/{feedback-YGTPJBRJ.mjs → feedback-2WRSZ5WL.mjs} +6 -6
- package/dist/cli/{feedback-TGUBVGRP.js → feedback-OV5YAL3A.js} +14 -14
- package/dist/cli/git-HGMX52XU.js +25 -0
- package/dist/cli/{git-3DOTQHJO.mjs → git-VNS4ATLZ.mjs} +5 -5
- package/dist/cli/index.js +145 -145
- package/dist/cli/index.mjs +44 -44
- package/dist/cli/{legacy-noops-RBBYRVLG.mjs → legacy-noops-C732QDCY.mjs} +6 -6
- package/dist/cli/{legacy-noops-BHEHVFHI.js → legacy-noops-HDOB5C6F.js} +9 -9
- package/dist/cli/{monitors-5AJCG6IV.mjs → monitors-2LYEFXOU.mjs} +7 -7
- package/dist/cli/{monitors-XECKLAXA.js → monitors-5IUMHH3E.js} +100 -100
- package/dist/cli/{org-DOBAIYWG.js → org-ADW2EVAC.js} +86 -86
- package/dist/cli/{org-ZAAIEZKB.mjs → org-G4YGZPHS.mjs} +6 -6
- package/dist/cli/{pages-FUOSF6BE.mjs → pages-KXKWSCEV.mjs} +6 -6
- package/dist/cli/{pages-TLC2N6L7.js → pages-VTJGAI2D.js} +18 -18
- package/dist/cli/{play-KLYRMQPF.mjs → play-7GQ56C2D.mjs} +69 -22
- package/dist/cli/{play-E74VN6B7.js → play-EHSOSSHT.js} +367 -320
- package/dist/cli/{providers-APZ6SOSK.js → providers-PWCF6OOO.js} +9 -9
- package/dist/cli/{providers-XTQXV5LB.mjs → providers-WL3YTCSV.mjs} +6 -6
- package/dist/cli/{quickstart-X7RHHQCH.mjs → quickstart-323XOPGI.mjs} +4 -4
- package/dist/cli/{quickstart-S6WN6NWW.js → quickstart-ZKI5MURA.js} +6 -6
- package/dist/cli/{run-3YLIJJ57.js → run-XZPWA6JS.js} +41 -41
- package/dist/cli/{run-TZPBBSPX.mjs → run-ZCNZU3K2.mjs} +23 -23
- package/dist/cli/{search-VLHE2CMZ.mjs → search-CVLVSFMJ.mjs} +8 -8
- package/dist/cli/search-J6EY7DQN.js +33 -0
- package/dist/cli/{search-output-73BYB7UE.mjs → search-output-6PY6RN2R.mjs} +4 -4
- package/dist/cli/{search-output-GCT7PQIT.js → search-output-7HRSSRBS.js} +6 -6
- package/dist/cli/{secrets-RLOTGKQZ.mjs → secrets-6S2ZWDIM.mjs} +6 -6
- package/dist/cli/{secrets-J6CEKXKQ.js → secrets-IYD5VKY4.js} +15 -15
- package/dist/cli/sessions-7HPIVSQ4.js +22 -0
- package/dist/cli/{sessions-7HZ7OZ62.mjs → sessions-GVEX5TUJ.mjs} +6 -6
- package/dist/cli/{settings-72K5YCIS.mjs → settings-BN5MJZ3C.mjs} +13 -13
- package/dist/cli/{settings-WRV5XEZC.js → settings-CANK4HJQ.js} +86 -86
- package/dist/cli/{setup-KQFY6WT4.mjs → setup-JNMSCCU4.mjs} +10 -10
- package/dist/cli/{setup-QVXWT2EQ.js → setup-YSGKGLSJ.js} +50 -50
- package/dist/cli/{skills-C3K3E473.mjs → skills-QCQN2UM2.mjs} +8 -8
- package/dist/cli/skills-WDGSSKJZ.js +37 -0
- package/dist/cli/{tools-4A2OH6MB.mjs → tools-CDPOID7V.mjs} +17 -17
- package/dist/cli/tools-URNVXSTZ.js +57 -0
- package/dist/cli/{update-BS6USKPR.mjs → update-D3ZERUQ3.mjs} +10 -10
- package/dist/cli/update-Q6JW32IA.js +35 -0
- package/dist/cli/{views-4NZGAXHL.js → views-4NV2KQKA.js} +18 -18
- package/dist/cli/{views-WB6GFTRX.mjs → views-RDZRWQBQ.mjs} +6 -6
- package/dist/cli/{workflow-2D4WX55R.mjs → workflow-2CG3TVCG.mjs} +7 -7
- package/dist/cli/{workflow-L2QTQZYV.js → workflow-RABJCAZC.js} +17 -17
- package/dist/{client-DoUVSkqC.d.mts → client-DhSvMO3A.d.mts} +1 -1
- package/dist/{client-core-CPlwsC1Q.d.mts → client-core-CVG1Et-4.d.mts} +9 -1
- package/dist/{client-core-C7KkUIE_.d.ts → client-core-CdWH6Sii.d.ts} +9 -1
- package/dist/{client-DQm56zMs.d.ts → client-oGNJMQFd.d.ts} +1 -1
- package/dist/{compiler-manifest-DsxsQP-T.d.mts → compiler-manifest-D2ZlBGxj.d.mts} +44 -0
- package/dist/{compiler-manifest-DsxsQP-T.d.ts → compiler-manifest-D2ZlBGxj.d.ts} +44 -0
- package/dist/{errors-qdJUVQ3g.d.mts → errors-B-gOQdj-.d.mts} +1 -1
- package/dist/{errors-Bk5h1D-C.d.ts → errors-CB0KAmmV.d.ts} +1 -1
- package/dist/{index-PaupwX1B.d.mts → index-BbJADro4.d.mts} +1 -1
- package/dist/{index-bL66eHYz.d.ts → index-c3nvUGCS.d.ts} +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +9 -9
- package/dist/index.mjs +6 -6
- package/dist/install-integrity.json +118 -116
- package/dist/plays/bundle-play-file.d.mts +3 -3
- package/dist/plays/bundle-play-file.d.ts +3 -3
- package/dist/plays/bundle-play-file.mjs +52 -0
- 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-UP2RGPI6.js +0 -43
- package/dist/cli/describe-IVTSD7ST.js +0 -50
- package/dist/cli/git-R3W25XIF.js +0 -25
- package/dist/cli/search-NB5CBALV.js +0 -33
- package/dist/cli/sessions-SFCZSB77.js +0 -22
- package/dist/cli/skills-WIJEHVLA.js +0 -37
- package/dist/cli/tools-VMMERMLO.js +0 -57
- package/dist/cli/update-54WZQDTS.js +0 -35
|
@@ -206,6 +206,16 @@ export interface PlayExecutionGovernor {
|
|
|
206
206
|
*/
|
|
207
207
|
tryAcquireProviderPermit(toolId: string): ProviderPermit | null;
|
|
208
208
|
|
|
209
|
+
/**
|
|
210
|
+
* Calls waiting now for one of the run's external-call slots, calls holding
|
|
211
|
+
* one, and the run's configured slot count. Synchronous and local.
|
|
212
|
+
*/
|
|
213
|
+
externalExecutionBacklog?(): {
|
|
214
|
+
waiting: number;
|
|
215
|
+
slots: number;
|
|
216
|
+
inFlight: number;
|
|
217
|
+
};
|
|
218
|
+
|
|
209
219
|
/**
|
|
210
220
|
* Suggested batch parallelism for a tool: the provider's own rate hints
|
|
211
221
|
* tightened to the policy's suggested ceiling. No hints → the fallback.
|
|
@@ -282,6 +292,15 @@ interface GovernorInput {
|
|
|
282
292
|
maxConcurrentRows?: number | null;
|
|
283
293
|
}
|
|
284
294
|
|
|
295
|
+
/**
|
|
296
|
+
* Share of the run's external-call slots that stays open while a map reports
|
|
297
|
+
* memory or event-loop pressure. Dropping to one slot stopped every new call
|
|
298
|
+
* until the slowest call already in flight returned: calls-10 (43305298615)
|
|
299
|
+
* started no call for about 44 s while 16 calls of up to 42.8 s finished.
|
|
300
|
+
* Half the slots still sheds load on pressure without that barrier.
|
|
301
|
+
*/
|
|
302
|
+
export const EXTERNAL_EXECUTION_PRESSURE_SLOT_SHARE = 0.5;
|
|
303
|
+
|
|
285
304
|
class Semaphore {
|
|
286
305
|
private inFlight = 0;
|
|
287
306
|
private readonly waiters: Array<(reserved: boolean) => void> = [];
|
|
@@ -298,6 +317,15 @@ class Semaphore {
|
|
|
298
317
|
: this.limit;
|
|
299
318
|
}
|
|
300
319
|
|
|
320
|
+
/** Waiters queued now, against the configured (not pressure-reduced) limit. */
|
|
321
|
+
backlog(): { waiting: number; limit: number; inFlight: number } {
|
|
322
|
+
return {
|
|
323
|
+
waiting: this.waiters.length,
|
|
324
|
+
limit: this.limit,
|
|
325
|
+
inFlight: this.inFlight,
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
|
|
301
329
|
/** Re-read policy before reserving each FIFO handoff. */
|
|
302
330
|
refresh(): void {
|
|
303
331
|
while (this.waiters.length > 0 && this.inFlight < this.capacity()) {
|
|
@@ -426,7 +454,14 @@ export function createPlayExecutionGovernor(
|
|
|
426
454
|
const externalPressureReaders = new Set<() => boolean>();
|
|
427
455
|
const readExternalCapacity = (): number => {
|
|
428
456
|
for (const read of externalPressureReaders) {
|
|
429
|
-
if (read())
|
|
457
|
+
if (read())
|
|
458
|
+
return Math.max(
|
|
459
|
+
1,
|
|
460
|
+
Math.floor(
|
|
461
|
+
policy.concurrency.toolCalls *
|
|
462
|
+
EXTERNAL_EXECUTION_PRESSURE_SLOT_SHARE,
|
|
463
|
+
),
|
|
464
|
+
);
|
|
430
465
|
}
|
|
431
466
|
return policy.concurrency.toolCalls;
|
|
432
467
|
};
|
|
@@ -780,6 +815,15 @@ export function createPlayExecutionGovernor(
|
|
|
780
815
|
return providerPermitFrom(provider, rateLease, localConcurrencySlot);
|
|
781
816
|
},
|
|
782
817
|
|
|
818
|
+
externalExecutionBacklog() {
|
|
819
|
+
const backlog = toolSlots.backlog();
|
|
820
|
+
return {
|
|
821
|
+
waiting: backlog.waiting,
|
|
822
|
+
slots: backlog.limit,
|
|
823
|
+
inFlight: backlog.inFlight,
|
|
824
|
+
};
|
|
825
|
+
},
|
|
826
|
+
|
|
783
827
|
async suggestedParallelism(toolId, fallback) {
|
|
784
828
|
const pacing = await resolveAdaptivePacing(toolId);
|
|
785
829
|
const concurrencyLimits = pacing.rules.flatMap((rule) =>
|
|
@@ -961,6 +1005,12 @@ function createInlineChildGovernor(
|
|
|
961
1005
|
acquireProviderPermit: (toolId, opts) =>
|
|
962
1006
|
root.acquireProviderPermit(toolId, opts),
|
|
963
1007
|
tryAcquireProviderPermit: (toolId) => root.tryAcquireProviderPermit(toolId),
|
|
1008
|
+
externalExecutionBacklog: () =>
|
|
1009
|
+
root.externalExecutionBacklog?.() ?? {
|
|
1010
|
+
waiting: 0,
|
|
1011
|
+
slots: 0,
|
|
1012
|
+
inFlight: 0,
|
|
1013
|
+
},
|
|
964
1014
|
suggestedParallelism: (toolId, fallback) =>
|
|
965
1015
|
root.suggestedParallelism(toolId, fallback),
|
|
966
1016
|
suggestedDirectToolParallelism: (toolId, fallback) =>
|
|
@@ -195,6 +195,13 @@ export type RuntimeMapHeapSnapshot = {
|
|
|
195
195
|
residentBytes?: number;
|
|
196
196
|
};
|
|
197
197
|
|
|
198
|
+
export type RuntimeMapAdmissionHoldCause =
|
|
199
|
+
| 'unpricedRows'
|
|
200
|
+
| 'width'
|
|
201
|
+
| 'memory'
|
|
202
|
+
| 'eventLoop'
|
|
203
|
+
| 'callSlots';
|
|
204
|
+
|
|
198
205
|
export type RuntimeMapHeapAdmissionSnapshot = {
|
|
199
206
|
activeRows: number;
|
|
200
207
|
activeRowPeak: number;
|
|
@@ -306,6 +313,30 @@ export type RuntimeMapHeapAdmissionSnapshot = {
|
|
|
306
313
|
eventLoopPressureEvents: number;
|
|
307
314
|
/** Row ceiling set by event-loop lag; maxConcurrency when it never lagged. */
|
|
308
315
|
eventLoopCeiling: number;
|
|
316
|
+
/**
|
|
317
|
+
* The per-row reserve the last probe measured while every admitted row was
|
|
318
|
+
* still waiting on a provider (a queued or in-flight call per row) with no
|
|
319
|
+
* body held; null when the prior or the ledger priced rows instead.
|
|
320
|
+
*/
|
|
321
|
+
probedWaitingRowReserveBytes: number | null;
|
|
322
|
+
/**
|
|
323
|
+
* Wall time at least one row waited for admission, and that time by what
|
|
324
|
+
* held it: the unknown full-row prior (`unpricedRows`), a window full of
|
|
325
|
+
* priced rows (`width`), memory or event-loop pressure, or the run's
|
|
326
|
+
* call-slot backlog. Lets a readout state time lost, not only count holds.
|
|
327
|
+
*/
|
|
328
|
+
admissionHoldMs: number;
|
|
329
|
+
admissionHoldMsByCause: Record<RuntimeMapAdmissionHoldCause, number>;
|
|
330
|
+
/**
|
|
331
|
+
* Whether the run's call-slot backlog ever held new rows. From then on,
|
|
332
|
+
* settlement paces admission: each settled row lets in at most
|
|
333
|
+
* `rowsPerSettledRow` more plus its own replacement.
|
|
334
|
+
*/
|
|
335
|
+
limitedByCallSlots: boolean;
|
|
336
|
+
/** Episodes in which that backlog held new rows. */
|
|
337
|
+
callSlotBacklogHolds: number;
|
|
338
|
+
/** Wall time rows waited because that backlog held them. */
|
|
339
|
+
callSlotBacklogHoldMs: number;
|
|
309
340
|
/** The last event-loop lag reading admission acted on, if it had one. */
|
|
310
341
|
eventLoopLagMs: number | null;
|
|
311
342
|
memoryPressureEvents: number;
|
|
@@ -453,6 +484,32 @@ const RUNTIME_MAP_ROW_FOOTPRINT_SAMPLE_MIN_ACTIVE_ROWS_DIVISOR = 4;
|
|
|
453
484
|
// ~490 agent calls queued on a 30-permit lane). Rows keep arriving for as long
|
|
454
485
|
// as rows keep finishing, so a map of any size still runs to completion.
|
|
455
486
|
const RUNTIME_MAP_ROWS_PER_SETTLED_ROW = 4;
|
|
487
|
+
/**
|
|
488
|
+
* Calls already waiting for the run's call slots, in multiples of its slot
|
|
489
|
+
* count, past which a map admits no new row. A row admitted then can only add
|
|
490
|
+
* calls to that queue, while its state, receipt hydration and dispatch work
|
|
491
|
+
* still load the runner: calls-10 at 64 and 256 slots (43305298615) admitted
|
|
492
|
+
* about 800 of 1,000 rows, held 270-400 MB live, and the event-loop and heap
|
|
493
|
+
* pressure that followed stopped new calls for about 44 s. Four slot-counts
|
|
494
|
+
* keep about four call times of work queued, so a new row still reaches
|
|
495
|
+
* dispatch before the queue runs dry.
|
|
496
|
+
*/
|
|
497
|
+
export const RUNTIME_MAP_CALL_SLOT_BACKLOG_MULTIPLE = 4;
|
|
498
|
+
/**
|
|
499
|
+
* Multiple of the live growth a probe measures per admitted row that prices
|
|
500
|
+
* one more waiting row before any row has settled. The unknown full-row prior
|
|
501
|
+
* otherwise charges every waiting row 3 MiB until 16 rows settle, so a map
|
|
502
|
+
* whose calls stay open for minutes never grows past its opening wave:
|
|
503
|
+
* primitives-residence hold-120s (43305298615) sat at 86 rows for 120 s with
|
|
504
|
+
* 102 MB live of a 280 MB target and rows that settled at 5 KB. The probe
|
|
505
|
+
* counts garbage between collections, which errs high; this factor covers the
|
|
506
|
+
* rest. It applies only while no provider body is held and the run's slot
|
|
507
|
+
* queue holds a call for every admitted row, so a body that lands returns
|
|
508
|
+
* every unpriced row to the prior, a probe of rows still reading receipts
|
|
509
|
+
* never prices them, and bodies themselves still pass the byte-admitted
|
|
510
|
+
* response-body gate before they are read.
|
|
511
|
+
*/
|
|
512
|
+
export const RUNTIME_MAP_PROBED_WAITING_ROW_RESERVE_FACTOR = 2;
|
|
456
513
|
|
|
457
514
|
/**
|
|
458
515
|
* The runner's real heap, rather than input JSON size, is the authority for
|
|
@@ -998,6 +1055,17 @@ export function createRuntimeMapHeapAdmission(input: {
|
|
|
998
1055
|
*/
|
|
999
1056
|
getEventLoopLagMs?: () => number | null;
|
|
1000
1057
|
eventLoopLagHoldMs?: number;
|
|
1058
|
+
/**
|
|
1059
|
+
* The run's call slots: how many calls are waiting for one, and how many
|
|
1060
|
+
* slots the run has. Admission holds new rows while more than
|
|
1061
|
+
* `RUNTIME_MAP_CALL_SLOT_BACKLOG_MULTIPLE` slot-counts of calls wait.
|
|
1062
|
+
*/
|
|
1063
|
+
callSlotBacklog?: () => {
|
|
1064
|
+
waiting: number;
|
|
1065
|
+
slots: number;
|
|
1066
|
+
/** Calls holding a slot; absent, the probed reserve never applies. */
|
|
1067
|
+
inFlight?: number;
|
|
1068
|
+
} | null;
|
|
1001
1069
|
eventLoopAdjustIntervalMs?: number;
|
|
1002
1070
|
/** Publishes the snapshot the watchdog attaches to a memory abort. */
|
|
1003
1071
|
reportLedger?: (snapshot: RuntimeMapHeapAdmissionSnapshot) => void;
|
|
@@ -1178,6 +1246,88 @@ export function createRuntimeMapHeapAdmission(input: {
|
|
|
1178
1246
|
: RUNTIME_MAP_EVENT_LOOP_ADJUST_INTERVAL_MS;
|
|
1179
1247
|
let eventLoopCeiling = maxConcurrency;
|
|
1180
1248
|
let lastEventLoopAdjustAtMs: number | null = null;
|
|
1249
|
+
let probedWaitingRowReserveBytes: number | null = null;
|
|
1250
|
+
let admissionHoldMs = 0;
|
|
1251
|
+
const admissionHoldMsByCause: Record<RuntimeMapAdmissionHoldCause, number> = {
|
|
1252
|
+
unpricedRows: 0,
|
|
1253
|
+
width: 0,
|
|
1254
|
+
memory: 0,
|
|
1255
|
+
eventLoop: 0,
|
|
1256
|
+
callSlots: 0,
|
|
1257
|
+
};
|
|
1258
|
+
let holdCause: RuntimeMapAdmissionHoldCause | null = null;
|
|
1259
|
+
let holdTickAtMs: number | null = null;
|
|
1260
|
+
let limitedByCallSlots = false;
|
|
1261
|
+
let callSlotBacklogHolds = 0;
|
|
1262
|
+
let callSlotBacklogHoldMs = 0;
|
|
1263
|
+
let callSlotBacklogHeldSinceMs: number | null = null;
|
|
1264
|
+
// A held map must not refill its window in one drain when the backlog
|
|
1265
|
+
// clears. Its width kept growing with every row that settled during the
|
|
1266
|
+
// hold, and a row admitted now reaches the slot queue only after its
|
|
1267
|
+
// receipt reads, so the backlog cannot see the refill until it is done:
|
|
1268
|
+
// calls-10 at 64 slots (43328763172) admitted all 744 waiting rows in one
|
|
1269
|
+
// drain, 7,440 receipt hydrations at once, and its event loop lagged 57 s
|
|
1270
|
+
// until receipt persistence gave up. From the first hold on, each settled
|
|
1271
|
+
// row lets in at most `rowsPerSettledRow` more plus its own replacement,
|
|
1272
|
+
// the pace an unheld map's width grows at; a probe adds one row (see
|
|
1273
|
+
// `reconcile`).
|
|
1274
|
+
let settlePacedAdmission = false;
|
|
1275
|
+
let settledAdmissionCredit = 0;
|
|
1276
|
+
// A row admitted while the run's calls already queue for slots can only
|
|
1277
|
+
// lengthen that queue. The last progress row is always admitted.
|
|
1278
|
+
const callSlotsBackedUp = (): boolean => {
|
|
1279
|
+
const backlog = input.callSlotBacklog?.() ?? null;
|
|
1280
|
+
return (
|
|
1281
|
+
backlog !== null &&
|
|
1282
|
+
backlog.slots > 0 &&
|
|
1283
|
+
backlog.waiting > backlog.slots * RUNTIME_MAP_CALL_SLOT_BACKLOG_MULTIPLE
|
|
1284
|
+
);
|
|
1285
|
+
};
|
|
1286
|
+
const trackCallSlotHold = (held: boolean): void => {
|
|
1287
|
+
if (held) {
|
|
1288
|
+
if (callSlotBacklogHeldSinceMs === null) {
|
|
1289
|
+
callSlotBacklogHeldSinceMs = now();
|
|
1290
|
+
callSlotBacklogHolds += 1;
|
|
1291
|
+
limitedByCallSlots = true;
|
|
1292
|
+
}
|
|
1293
|
+
return;
|
|
1294
|
+
}
|
|
1295
|
+
if (callSlotBacklogHeldSinceMs !== null) {
|
|
1296
|
+
callSlotBacklogHoldMs += Math.max(0, now() - callSlotBacklogHeldSinceMs);
|
|
1297
|
+
callSlotBacklogHeldSinceMs = null;
|
|
1298
|
+
}
|
|
1299
|
+
};
|
|
1300
|
+
// Credit the time since the last tick to what held rows then, and record
|
|
1301
|
+
// what holds them now. Every admission decision ticks, so a cause is never
|
|
1302
|
+
// charged for more than one probe interval past its end.
|
|
1303
|
+
const tickHold = (): void => {
|
|
1304
|
+
const tickAtMs = now();
|
|
1305
|
+
if (holdCause !== null && holdTickAtMs !== null) {
|
|
1306
|
+
const heldMs = Math.max(0, tickAtMs - holdTickAtMs);
|
|
1307
|
+
admissionHoldMs += heldMs;
|
|
1308
|
+
admissionHoldMsByCause[holdCause] += heldMs;
|
|
1309
|
+
}
|
|
1310
|
+
holdTickAtMs = tickAtMs;
|
|
1311
|
+
holdCause =
|
|
1312
|
+
closed || waiters.length === 0
|
|
1313
|
+
? null
|
|
1314
|
+
: admissionPaused
|
|
1315
|
+
? eventLoopPressureActive
|
|
1316
|
+
? 'eventLoop'
|
|
1317
|
+
: 'memory'
|
|
1318
|
+
: callSlotBacklogHeldSinceMs !== null ||
|
|
1319
|
+
(settlePacedAdmission &&
|
|
1320
|
+
settledAdmissionCredit === 0 &&
|
|
1321
|
+
activeRows > 0 &&
|
|
1322
|
+
activeRows < concurrency)
|
|
1323
|
+
? 'callSlots'
|
|
1324
|
+
: activeRows >= concurrency
|
|
1325
|
+
? measuredRowBytes === null &&
|
|
1326
|
+
probedWaitingRowReserveBytes === null
|
|
1327
|
+
? 'unpricedRows'
|
|
1328
|
+
: 'width'
|
|
1329
|
+
: null;
|
|
1330
|
+
};
|
|
1181
1331
|
let memoryPressureEvents = 0;
|
|
1182
1332
|
let closed = false;
|
|
1183
1333
|
let closeError: unknown = null;
|
|
@@ -1292,6 +1442,31 @@ export function createRuntimeMapHeapAdmission(input: {
|
|
|
1292
1442
|
eventLoopPressureEvents,
|
|
1293
1443
|
eventLoopCeiling,
|
|
1294
1444
|
eventLoopLagMs,
|
|
1445
|
+
probedWaitingRowReserveBytes,
|
|
1446
|
+
...(() => {
|
|
1447
|
+
const openMs =
|
|
1448
|
+
holdCause === null || holdTickAtMs === null
|
|
1449
|
+
? 0
|
|
1450
|
+
: Math.max(0, now() - holdTickAtMs);
|
|
1451
|
+
return {
|
|
1452
|
+
admissionHoldMs: admissionHoldMs + openMs,
|
|
1453
|
+
admissionHoldMsByCause: {
|
|
1454
|
+
...admissionHoldMsByCause,
|
|
1455
|
+
...(holdCause === null
|
|
1456
|
+
? {}
|
|
1457
|
+
: {
|
|
1458
|
+
[holdCause]: admissionHoldMsByCause[holdCause] + openMs,
|
|
1459
|
+
}),
|
|
1460
|
+
},
|
|
1461
|
+
};
|
|
1462
|
+
})(),
|
|
1463
|
+
limitedByCallSlots,
|
|
1464
|
+
callSlotBacklogHolds,
|
|
1465
|
+
callSlotBacklogHoldMs:
|
|
1466
|
+
callSlotBacklogHoldMs +
|
|
1467
|
+
(callSlotBacklogHeldSinceMs === null
|
|
1468
|
+
? 0
|
|
1469
|
+
: Math.max(0, now() - callSlotBacklogHeldSinceMs)),
|
|
1295
1470
|
};
|
|
1296
1471
|
};
|
|
1297
1472
|
|
|
@@ -1300,6 +1475,19 @@ export function createRuntimeMapHeapAdmission(input: {
|
|
|
1300
1475
|
allowWhilePaused = false,
|
|
1301
1476
|
) => {
|
|
1302
1477
|
let admissions = 0;
|
|
1478
|
+
const backedUp = waiters.length > 0 && callSlotsBackedUp();
|
|
1479
|
+
trackCallSlotHold(
|
|
1480
|
+
backedUp &&
|
|
1481
|
+
!admissionPaused &&
|
|
1482
|
+
activeRows > 0 &&
|
|
1483
|
+
activeRows < concurrency,
|
|
1484
|
+
);
|
|
1485
|
+
if (backedUp && activeRows > 0) {
|
|
1486
|
+
// From the first hold on, settlement paces admission, and a hold spends
|
|
1487
|
+
// whatever settlement credit it finds instead of banking it.
|
|
1488
|
+
settlePacedAdmission = true;
|
|
1489
|
+
settledAdmissionCredit = 0;
|
|
1490
|
+
}
|
|
1303
1491
|
while (
|
|
1304
1492
|
!closed &&
|
|
1305
1493
|
// A pressure pause retains exactly one progress row after the active
|
|
@@ -1307,12 +1495,18 @@ export function createRuntimeMapHeapAdmission(input: {
|
|
|
1307
1495
|
// noticed the zero width, so make the allowance in drain rather than
|
|
1308
1496
|
// relying on a waiter already existing at that instant.
|
|
1309
1497
|
(allowWhilePaused || !admissionPaused || activeRows === 0) &&
|
|
1498
|
+
(!backedUp || activeRows === 0) &&
|
|
1499
|
+
(!settlePacedAdmission ||
|
|
1500
|
+
activeRows === 0 ||
|
|
1501
|
+
settledAdmissionCredit > 0) &&
|
|
1310
1502
|
admissions < maximumAdmissions &&
|
|
1311
1503
|
activeRows < concurrency &&
|
|
1312
1504
|
waiters.length > 0
|
|
1313
1505
|
) {
|
|
1314
1506
|
const waiter = waiters.shift();
|
|
1315
1507
|
if (!waiter) return;
|
|
1508
|
+
if (activeRows > 0 && settledAdmissionCredit > 0)
|
|
1509
|
+
settledAdmissionCredit -= 1;
|
|
1316
1510
|
activeRows += 1;
|
|
1317
1511
|
activeRowPeak = Math.max(activeRowPeak, activeRows);
|
|
1318
1512
|
admittedRows += 1;
|
|
@@ -1324,6 +1518,8 @@ export function createRuntimeMapHeapAdmission(input: {
|
|
|
1324
1518
|
released = true;
|
|
1325
1519
|
activeRows = Math.max(0, activeRows - 1);
|
|
1326
1520
|
settledRows += 1;
|
|
1521
|
+
if (settlePacedAdmission)
|
|
1522
|
+
settledAdmissionCredit = rowsPerSettledRow + 1;
|
|
1327
1523
|
// Re-pricing here is deliberate and load-bearing: a settling row is
|
|
1328
1524
|
// the only evidence the ledger gets about what a row of this shape
|
|
1329
1525
|
// actually cost, and `probeIntervalMs` may be far longer than a row
|
|
@@ -1334,9 +1530,12 @@ export function createRuntimeMapHeapAdmission(input: {
|
|
|
1334
1530
|
},
|
|
1335
1531
|
});
|
|
1336
1532
|
}
|
|
1533
|
+
tickHold();
|
|
1337
1534
|
};
|
|
1338
1535
|
|
|
1339
1536
|
const pauseAdmission = () => {
|
|
1537
|
+
// Memory or event-loop pressure is the hold from here, not the backlog.
|
|
1538
|
+
trackCallSlotHold(false);
|
|
1340
1539
|
externalExecutionPressure = true;
|
|
1341
1540
|
admissionHolds += 1;
|
|
1342
1541
|
admissionPaused = true;
|
|
@@ -1714,7 +1913,42 @@ export function createRuntimeMapHeapAdmission(input: {
|
|
|
1714
1913
|
// per-row peak scaled by its calibration factor, or the unmeasured prior
|
|
1715
1914
|
// until enough rows have settled to state one. It is floored so a run of
|
|
1716
1915
|
// light rows cannot authorize a launch wave for a heavy one.
|
|
1717
|
-
|
|
1916
|
+
// Before 16 rows have settled the reserve is the unknown full-row prior.
|
|
1917
|
+
// While no provider body is held anywhere and the slot queue holds at
|
|
1918
|
+
// least one call per admitted row, those rows have done their receipt
|
|
1919
|
+
// reads and are waiting on providers, and what they cost is in the probe:
|
|
1920
|
+
// price the next one by that measurement, times a safety factor, instead.
|
|
1921
|
+
// A probe taken before rows queue their calls measures rows that have
|
|
1922
|
+
// done nothing yet: calls-10 (43328763172) opened 256 rows on such a
|
|
1923
|
+
// probe instead of the prior's 86, and 2,560 receipt hydrations at once
|
|
1924
|
+
// lagged the event loop 7-12 s before the first call left.
|
|
1925
|
+
const providerBodiesHeld =
|
|
1926
|
+
(memorySnapshot?.bytesByCategory.providerBody ?? 0) > 0;
|
|
1927
|
+
const slotBacklog = activeRows > 0 ? input.callSlotBacklog?.() : null;
|
|
1928
|
+
const admittedRowsQueuedCalls =
|
|
1929
|
+
slotBacklog?.inFlight !== undefined &&
|
|
1930
|
+
slotBacklog.waiting + slotBacklog.inFlight >= activeRows;
|
|
1931
|
+
probedWaitingRowReserveBytes =
|
|
1932
|
+
providerBodyReservationDeferred &&
|
|
1933
|
+
memorySnapshot !== null &&
|
|
1934
|
+
occupancy.measuredOwnerBytes === null &&
|
|
1935
|
+
!providerBodiesHeld &&
|
|
1936
|
+
admittedRowsQueuedCalls &&
|
|
1937
|
+
activeRows > 0
|
|
1938
|
+
? Math.min(
|
|
1939
|
+
defaultRowReserveBytes,
|
|
1940
|
+
Math.max(
|
|
1941
|
+
waitingRowReserveBytes ?? rowReserveMinBytes,
|
|
1942
|
+
Math.ceil(
|
|
1943
|
+
(Math.max(0, reading.liveBytes - reading.liveBaselineBytes) /
|
|
1944
|
+
activeRows) *
|
|
1945
|
+
RUNTIME_MAP_PROBED_WAITING_ROW_RESERVE_FACTOR,
|
|
1946
|
+
),
|
|
1947
|
+
),
|
|
1948
|
+
)
|
|
1949
|
+
: null;
|
|
1950
|
+
rowReserveBytes =
|
|
1951
|
+
probedWaitingRowReserveBytes ?? reserveForAdmittedRow(occupancy);
|
|
1718
1952
|
// Rows already admitted may not have shown their bodies yet. Charge them
|
|
1719
1953
|
// the reserve minus whatever growth occupancy already reflects, so a
|
|
1720
1954
|
// static reading between probes cannot be mistaken for free headroom.
|
|
@@ -1735,9 +1969,15 @@ export function createRuntimeMapHeapAdmission(input: {
|
|
|
1735
1969
|
|
|
1736
1970
|
const reconcile = () => {
|
|
1737
1971
|
if (closed) return;
|
|
1972
|
+
// A paced map still admits one row per probe once its backlog clears, so
|
|
1973
|
+
// rows that settle slowly cannot strand it. A probe runs at most every
|
|
1974
|
+
// probe interval and slows with the event loop, so this cannot burst.
|
|
1975
|
+
if (settlePacedAdmission)
|
|
1976
|
+
settledAdmissionCredit = Math.max(settledAdmissionCredit, 1);
|
|
1738
1977
|
try {
|
|
1739
1978
|
reconcileState();
|
|
1740
1979
|
} finally {
|
|
1980
|
+
tickHold();
|
|
1741
1981
|
// Only a current complete healthy observation may clear a known hold.
|
|
1742
1982
|
if (
|
|
1743
1983
|
admissionPaused ||
|
|
@@ -1823,6 +2063,10 @@ export function createRuntimeMapHeapAdmission(input: {
|
|
|
1823
2063
|
},
|
|
1824
2064
|
close(error) {
|
|
1825
2065
|
if (!closed) {
|
|
2066
|
+
tickHold();
|
|
2067
|
+
holdCause = null;
|
|
2068
|
+
// A closed map holds no row, so an open backlog hold ends here too.
|
|
2069
|
+
trackCallSlotHold(false);
|
|
1826
2070
|
closed = true;
|
|
1827
2071
|
closeError = error ?? new Error('Runtime map row admission is closed.');
|
|
1828
2072
|
clearInterval(timer);
|
|
@@ -402,6 +402,8 @@ export type LedgerTerminalResultRef = {
|
|
|
402
402
|
responsePreview?: LedgerStoredRunOutputPreview;
|
|
403
403
|
/** Failure ownership retained when the full failed result is out of line. */
|
|
404
404
|
failure?: LedgerTerminalFailureSummary;
|
|
405
|
+
/** The Play explicitly declined an MCP completion notification. */
|
|
406
|
+
suppressMcpCompletionEvent?: true;
|
|
405
407
|
};
|
|
406
408
|
|
|
407
409
|
export const LEDGER_TERMINAL_RESULT_STORED_WARNING =
|
|
@@ -1175,6 +1177,18 @@ export function isLedgerTerminalResultRef(
|
|
|
1175
1177
|
);
|
|
1176
1178
|
}
|
|
1177
1179
|
|
|
1180
|
+
/** A top-level boolean decision is independent of the output preview budget. */
|
|
1181
|
+
export function shouldSuppressMcpCompletionEvent(value: unknown): boolean {
|
|
1182
|
+
if (isLedgerTerminalResultRef(value)) {
|
|
1183
|
+
return value.suppressMcpCompletionEvent === true;
|
|
1184
|
+
}
|
|
1185
|
+
return (
|
|
1186
|
+
isPlainObject(value) &&
|
|
1187
|
+
Object.hasOwn(value, 'notifyWork') &&
|
|
1188
|
+
value.notifyWork === false
|
|
1189
|
+
);
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1178
1192
|
export function stripReplayOnlyTerminalResult(value: unknown): unknown {
|
|
1179
1193
|
if (!isPlainObject(value) || isLedgerTerminalResultRef(value)) return value;
|
|
1180
1194
|
const stripped: Record<string, unknown> = {};
|
|
@@ -1216,6 +1230,7 @@ function ledgerTerminalResultRef(
|
|
|
1216
1230
|
preview?: BoundedRunListOutputPreview;
|
|
1217
1231
|
responsePreview?: LedgerStoredRunOutputPreview;
|
|
1218
1232
|
failure?: LedgerTerminalFailureSummary;
|
|
1233
|
+
suppressMcpCompletionEvent?: true;
|
|
1219
1234
|
} = {},
|
|
1220
1235
|
): LedgerTerminalResultRef {
|
|
1221
1236
|
return {
|
|
@@ -1231,6 +1246,9 @@ function ledgerTerminalResultRef(
|
|
|
1231
1246
|
? { responsePreview: options.responsePreview }
|
|
1232
1247
|
: {}),
|
|
1233
1248
|
...(options.failure ? { failure: options.failure } : {}),
|
|
1249
|
+
...(options.suppressMcpCompletionEvent
|
|
1250
|
+
? { suppressMcpCompletionEvent: true }
|
|
1251
|
+
: {}),
|
|
1234
1252
|
warning: options.content
|
|
1235
1253
|
? LEDGER_TERMINAL_RESULT_STORED_WARNING
|
|
1236
1254
|
: LEDGER_TERMINAL_RESULT_OMITTED_WARNING,
|
|
@@ -1347,6 +1365,9 @@ export function ledgerTerminalResultRefForValue(
|
|
|
1347
1365
|
preview,
|
|
1348
1366
|
responsePreview,
|
|
1349
1367
|
failure,
|
|
1368
|
+
...(shouldSuppressMcpCompletionEvent(value)
|
|
1369
|
+
? { suppressMcpCompletionEvent: true }
|
|
1370
|
+
: {}),
|
|
1350
1371
|
});
|
|
1351
1372
|
}
|
|
1352
1373
|
|
|
@@ -11,6 +11,8 @@ export function observeProviderNoProgress(input: {
|
|
|
11
11
|
scope: string;
|
|
12
12
|
retryAtMs: number;
|
|
13
13
|
nowMs: number;
|
|
14
|
+
/** The no-progress limit; absent is `PROVIDER_NO_PROGRESS_MAX_MS`. */
|
|
15
|
+
maxMs?: number;
|
|
14
16
|
}): { exhausted: boolean; startedAtMs: number; deadlineMs: number } {
|
|
15
17
|
const saved = input.startedAtMsByScope[input.scope];
|
|
16
18
|
const startedAtMs =
|
|
@@ -18,7 +20,7 @@ export function observeProviderNoProgress(input: {
|
|
|
18
20
|
? saved
|
|
19
21
|
: input.nowMs;
|
|
20
22
|
input.startedAtMsByScope[input.scope] = startedAtMs;
|
|
21
|
-
const deadlineMs = startedAtMs + PROVIDER_NO_PROGRESS_MAX_MS;
|
|
23
|
+
const deadlineMs = startedAtMs + (input.maxMs ?? PROVIDER_NO_PROGRESS_MAX_MS);
|
|
22
24
|
return {
|
|
23
25
|
exhausted: input.nowMs >= deadlineMs || input.retryAtMs > deadlineMs,
|
|
24
26
|
startedAtMs,
|
|
@@ -30,11 +32,13 @@ export function providerNoProgressExpired(input: {
|
|
|
30
32
|
startedAtMsByScope: Record<string, number> | undefined;
|
|
31
33
|
scope: string;
|
|
32
34
|
nowMs: number;
|
|
35
|
+
/** The no-progress limit; absent is `PROVIDER_NO_PROGRESS_MAX_MS`. */
|
|
36
|
+
maxMs?: number;
|
|
33
37
|
}): boolean {
|
|
34
38
|
const startedAtMs = input.startedAtMsByScope?.[input.scope];
|
|
35
39
|
return (
|
|
36
40
|
typeof startedAtMs === 'number' &&
|
|
37
41
|
Number.isFinite(startedAtMs) &&
|
|
38
|
-
input.nowMs >= startedAtMs + PROVIDER_NO_PROGRESS_MAX_MS
|
|
42
|
+
input.nowMs >= startedAtMs + (input.maxMs ?? PROVIDER_NO_PROGRESS_MAX_MS)
|
|
39
43
|
);
|
|
40
44
|
}
|
|
@@ -918,6 +918,12 @@ export interface RuntimeResourceGovernor {
|
|
|
918
918
|
tryAcquireProviderPermit(input: {
|
|
919
919
|
toolId: string;
|
|
920
920
|
}): RuntimeProviderPermit | null;
|
|
921
|
+
/** Calls waiting now for the run's external-call slots, and its slot count. */
|
|
922
|
+
externalExecutionBacklog?(): {
|
|
923
|
+
waiting: number;
|
|
924
|
+
slots: number;
|
|
925
|
+
inFlight: number;
|
|
926
|
+
} | null;
|
|
921
927
|
/**
|
|
922
928
|
* Observe one physical provider request's run-local residence. This is not
|
|
923
929
|
* a permit: it cannot block, queue, or widen capacity. Callers must release
|
|
@@ -1961,6 +1967,10 @@ export function createRuntimeResourceGovernor(input: {
|
|
|
1961
1967
|
return lease;
|
|
1962
1968
|
},
|
|
1963
1969
|
|
|
1970
|
+
externalExecutionBacklog() {
|
|
1971
|
+
return input.executionGovernor.externalExecutionBacklog?.() ?? null;
|
|
1972
|
+
},
|
|
1973
|
+
|
|
1964
1974
|
tryAcquireProviderPermit(providerInput) {
|
|
1965
1975
|
const lease = input.executionGovernor.tryAcquireProviderPermit(
|
|
1966
1976
|
providerInput.toolId,
|
|
@@ -3,6 +3,7 @@ import { isIntegrationEventWaitToolId } from '../event-wait-tools';
|
|
|
3
3
|
import type { PlayQueueHint } from '../governor/rate-state-backend';
|
|
4
4
|
import { getPlayRuntimeBatchStrategy } from '../play-runtime-batching-registry';
|
|
5
5
|
import type { ToolResultMetadataInput } from '../tool-result';
|
|
6
|
+
import { resolveDurableRetryPolicy } from '../durable-retry-policy';
|
|
6
7
|
|
|
7
8
|
/** The app's runtime tool metadata as the runner receives it over HTTP. */
|
|
8
9
|
export type RuntimeToolMetadata = {
|
|
@@ -20,6 +21,28 @@ export type RuntimeToolMetadata = {
|
|
|
20
21
|
requiresExecutionFence?: boolean;
|
|
21
22
|
providerServerErrorReplay?: 'idempotent_key' | 'read_safe' | 'never';
|
|
22
23
|
};
|
|
24
|
+
/** Optional (reader-first): absent from an older app; treated as a write. */
|
|
25
|
+
effect?: 'read' | 'write' | 'destructive' | null;
|
|
26
|
+
/** Optional (reader-first): absent counts as non-idempotent. */
|
|
27
|
+
writeIdempotency?: 'idempotent_write' | 'non_idempotent_write' | null;
|
|
28
|
+
/**
|
|
29
|
+
* Optional (reader-first): the stored Durable retry policy the app read for
|
|
30
|
+
* this attempt. Absent, null, or with `readError`, the compiled defaults
|
|
31
|
+
* apply and say so.
|
|
32
|
+
*/
|
|
33
|
+
durableRetryPolicy?: {
|
|
34
|
+
stored: {
|
|
35
|
+
sequence: number;
|
|
36
|
+
policyJson: string;
|
|
37
|
+
/**
|
|
38
|
+
* Optional (reader-first): set when the policy is the run workspace's
|
|
39
|
+
* override rather than the global policy. Attribution only; the
|
|
40
|
+
* sequence already names exactly one stored version.
|
|
41
|
+
*/
|
|
42
|
+
orgId?: string;
|
|
43
|
+
} | null;
|
|
44
|
+
readError?: string;
|
|
45
|
+
} | null;
|
|
23
46
|
targetGetters?: Record<string, string[]>;
|
|
24
47
|
listExtractorPaths?: string[];
|
|
25
48
|
listExtractorAliases?: ToolResultMetadataInput['listExtractorAliases'];
|
|
@@ -42,6 +65,7 @@ export type RuntimeToolHooks = Required<
|
|
|
42
65
|
| 'getToolIdempotencyScope'
|
|
43
66
|
| 'getToolReusableResultSupport'
|
|
44
67
|
| 'getToolRetryPolicy'
|
|
68
|
+
| 'getToolDurableRetryContext'
|
|
45
69
|
| 'getToolActionCacheVersion'
|
|
46
70
|
| 'getToolActionCacheReadVersions'
|
|
47
71
|
| 'getToolTargetGetters'
|
|
@@ -109,6 +133,37 @@ export function createRuntimeToolHooks(input: {
|
|
|
109
133
|
metadata.retry?.providerServerErrorReplay ?? 'never',
|
|
110
134
|
};
|
|
111
135
|
},
|
|
136
|
+
getToolDurableRetryContext: async (toolId) => {
|
|
137
|
+
const metadata = await getRuntimeToolMetadata(toolId);
|
|
138
|
+
const wire = metadata.durableRetryPolicy;
|
|
139
|
+
// An app that predates the policy sends no field: keep the old
|
|
140
|
+
// behaviour (never park). A sent field with no stored policy, or an
|
|
141
|
+
// unreadable one, resolves to the compiled defaults, loudly.
|
|
142
|
+
if (wire === undefined || wire === null) return null;
|
|
143
|
+
const policy = resolveDurableRetryPolicy(wire.stored ?? null);
|
|
144
|
+
return {
|
|
145
|
+
effect:
|
|
146
|
+
metadata.effect === 'read' ||
|
|
147
|
+
metadata.effect === 'write' ||
|
|
148
|
+
metadata.effect === 'destructive'
|
|
149
|
+
? metadata.effect
|
|
150
|
+
: null,
|
|
151
|
+
writeIdempotency:
|
|
152
|
+
metadata.writeIdempotency === 'idempotent_write' ||
|
|
153
|
+
metadata.writeIdempotency === 'non_idempotent_write'
|
|
154
|
+
? metadata.writeIdempotency
|
|
155
|
+
: null,
|
|
156
|
+
policy: wire.readError
|
|
157
|
+
? {
|
|
158
|
+
...policy,
|
|
159
|
+
warnings: [
|
|
160
|
+
`The app could not read the Durable retry policy: ${wire.readError}`,
|
|
161
|
+
...policy.warnings,
|
|
162
|
+
],
|
|
163
|
+
}
|
|
164
|
+
: policy,
|
|
165
|
+
};
|
|
166
|
+
},
|
|
112
167
|
getToolActionCacheVersion: async (toolId) => {
|
|
113
168
|
const metadata = await getRuntimeToolMetadata(toolId);
|
|
114
169
|
const version = metadata.actionCacheVersion.trim();
|
|
@@ -79,6 +79,12 @@ export const TOOL_EXECUTE_PROVIDER_PACING_WAIT_MAX_ATTEMPTS = 65;
|
|
|
79
79
|
// 429, which bounds the wire value before fingerprints or history queries, so
|
|
80
80
|
// malformed executor traffic cannot turn one request into unbounded work.
|
|
81
81
|
export const EXECUTION_GATEWAY_MAX_LOGICAL_ATTEMPT = 32;
|
|
82
|
+
// A Durable requeue (`call-requeue-state-machine.ts`) resumes a fenced call
|
|
83
|
+
// after a park. The gateway then bounds each park segment by the ceiling
|
|
84
|
+
// above, and the parks themselves by this constant: the longest default
|
|
85
|
+
// policy window (48 h for 429) at the 60-minute ladder ceiling is under 64
|
|
86
|
+
// parks. A claim beyond it is refused before any history query.
|
|
87
|
+
export const EXECUTION_GATEWAY_MAX_REQUEUE_PARKS = 64;
|
|
82
88
|
// Every fenced retry other than a shed or follower poll opens the next logical
|
|
83
89
|
// attempt. A Deepline refusal made before dispatch gets the attempts the other
|
|
84
90
|
// advancing reasons leave under the gateway ceiling: idempotency in progress,
|