deepline 0.3.533 → 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 +68 -7
- 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 +677 -26
- 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/execution-capabilities.ts +26 -0
- package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +32 -14
- package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +51 -1
- package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +9 -0
- 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/runtime-authority.ts +8 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +21 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-cache-policy.ts +12 -1
- package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +2 -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-2TZNPIJQ.mjs → auth-ZCTMB5RA.mjs} +5 -5
- package/dist/cli/{billing-HQYTRIV3.js → billing-GVFKZQH3.js} +82 -82
- package/dist/cli/{billing-LR4WJIHO.mjs → billing-OU2ZHL72.mjs} +7 -7
- package/dist/cli/{chunk-HOTJSXLY.js → chunk-243O3FH5.js} +5 -5
- package/dist/cli/{chunk-TU56J4OV.js → chunk-2D6SWQTK.js} +13 -13
- package/dist/cli/{chunk-4YP2YAIZ.js → chunk-4NLRWKZB.js} +26 -26
- package/dist/cli/{chunk-NW736SOD.mjs → chunk-4QELPWUW.mjs} +2 -2
- package/dist/cli/{chunk-LTF2J3JM.js → chunk-5EKNDNFQ.js} +2 -2
- package/dist/cli/{chunk-VPQDKL5O.js → chunk-6LHX33VN.js} +6 -6
- package/dist/cli/{chunk-LZMRCUVD.mjs → chunk-6TYRRNXY.mjs} +2 -2
- package/dist/cli/{chunk-YZK5RSUL.mjs → chunk-7CWSAEYS.mjs} +1 -1
- package/dist/cli/{chunk-A4JP6RPX.js → chunk-7PXP2FQK.js} +2 -2
- package/dist/cli/{chunk-2TMNRF5R.mjs → chunk-7R5DAANG.mjs} +1 -1
- package/dist/cli/{chunk-NKVW552R.mjs → chunk-AUEUAPVS.mjs} +1 -1
- package/dist/cli/{chunk-3KQBV2CG.mjs → chunk-BF65LB7X.mjs} +3 -3
- package/dist/cli/{chunk-33SNTG5F.js → chunk-CIDATNTY.js} +16 -16
- package/dist/cli/{chunk-O7RSUW75.js → chunk-D4MHCCIR.js} +4 -4
- package/dist/cli/{chunk-5XTXC45Z.js → chunk-DAPKLYST.js} +41 -41
- package/dist/cli/{chunk-USAQ42OG.mjs → chunk-DFJODFMC.mjs} +5 -5
- package/dist/cli/{chunk-KKUOIVQO.mjs → chunk-DWPY6ZID.mjs} +1 -1
- package/dist/cli/{chunk-MNAEALPG.js → chunk-DYIWDUY4.js} +182 -127
- package/dist/cli/{chunk-EVXRQXNV.mjs → chunk-E3CLOVG5.mjs} +47 -0
- package/dist/cli/{chunk-SVVUC3B4.js → chunk-FGN75ZN6.js} +138 -104
- package/dist/cli/{chunk-XZN3DBTP.mjs → chunk-FZKPPB5P.mjs} +40 -6
- package/dist/cli/{chunk-NFDYVMGC.mjs → chunk-G2DLG32W.mjs} +68 -13
- package/dist/cli/{chunk-LZ3PBEQH.mjs → chunk-H6SWS5CG.mjs} +2 -2
- package/dist/cli/{chunk-EYWES7F5.js → chunk-HWPOXCCK.js} +3 -3
- package/dist/cli/{chunk-425ERNBL.js → chunk-HYBZWSSH.js} +44 -44
- package/dist/cli/{chunk-CANHB6DH.mjs → chunk-J75DANZY.mjs} +2 -2
- package/dist/cli/{chunk-CWIGRIIX.mjs → chunk-JQQG4QL4.mjs} +3 -3
- package/dist/cli/{chunk-2UYERVXF.mjs → chunk-JWWYLGUT.mjs} +2 -2
- package/dist/cli/{chunk-735ZOYQN.js → chunk-K3IPGMGP.js} +11 -11
- package/dist/cli/{chunk-VKGNQC2S.mjs → chunk-K53NKWZO.mjs} +5 -5
- package/dist/cli/{chunk-3O3AL5RI.mjs → chunk-K76AEBFY.mjs} +4 -4
- package/dist/cli/{chunk-BWZHMWM5.js → chunk-KA6ZERJL.js} +6 -6
- package/dist/cli/{chunk-4CYNH47Y.js → chunk-KOZBZPRM.js} +53 -53
- package/dist/cli/{chunk-QZWURUBP.js → chunk-KWGXHPHL.js} +7 -7
- package/dist/cli/{chunk-XUX5KGCQ.mjs → chunk-LVISZFYO.mjs} +2 -2
- package/dist/cli/{chunk-B4ZNWXUW.js → chunk-OM732MGV.js} +9 -9
- package/dist/cli/{chunk-352XVCGE.js → chunk-PHLNYBAA.js} +5 -5
- package/dist/cli/{chunk-ZH5HCAN3.js → chunk-PI5R65OQ.js} +1 -1
- package/dist/cli/{chunk-JZ7LJS3P.mjs → chunk-QYBAHYP4.mjs} +6 -6
- package/dist/cli/{chunk-G3GJ3IGU.mjs → chunk-R2KKEHJN.mjs} +5 -5
- package/dist/cli/{chunk-R7YDZSN7.js → chunk-RFQWSH6I.js} +3 -3
- package/dist/cli/{chunk-MKUYZ7LR.mjs → chunk-RKY4LBX3.mjs} +1 -1
- package/dist/cli/{chunk-WF652G74.js → chunk-T7RBM2WX.js} +14 -14
- package/dist/cli/{chunk-G3RVDRYL.mjs → chunk-TCVCFZP6.mjs} +1 -1
- package/dist/cli/{chunk-E4VWBU2E.js → chunk-UUQ2OXMH.js} +16 -16
- package/dist/cli/{chunk-IETLUG4C.mjs → chunk-W5YJYU4G.mjs} +1 -1
- package/dist/cli/{chunk-HPOVAUQF.mjs → chunk-W6T23EUC.mjs} +1 -1
- package/dist/cli/{chunk-BSI7UHQZ.mjs → chunk-WAIBM6KX.mjs} +5 -5
- package/dist/cli/{chunk-4UADZTU5.js → chunk-WNNA4L6Z.js} +22 -22
- package/dist/cli/{chunk-V6LUMGVI.js → chunk-XSOTEVOB.js} +47 -0
- package/dist/cli/{chunk-PIACHLYY.mjs → chunk-YFZLZNTH.mjs} +2 -2
- package/dist/cli/{chunk-274Y66HP.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-MBSCHS4H.js → csv-CD55KEIO.js} +13 -13
- package/dist/cli/{csv-CJKKHGNQ.mjs → csv-CLPVMIRF.mjs} +4 -4
- package/dist/cli/{db-EAFR6N45.mjs → db-AU4SMWUN.mjs} +6 -6
- package/dist/cli/{db-45HNPCY3.js → db-MQKLDAEO.js} +27 -27
- package/dist/cli/describe-5BFNHT5V.js +50 -0
- package/dist/cli/{describe-IXW3LDGC.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-SZAES2S4.js → executions-77GOLWRM.js} +8 -8
- package/dist/cli/{executions-ZATZV7O6.mjs → executions-TFIJPUX7.mjs} +6 -6
- package/dist/cli/{feedback-NY63KEK2.mjs → feedback-2WRSZ5WL.mjs} +6 -6
- package/dist/cli/{feedback-KXLF4GR4.js → feedback-OV5YAL3A.js} +14 -14
- package/dist/cli/git-HGMX52XU.js +25 -0
- package/dist/cli/{git-BSSSTR6N.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-CYF6DJBF.mjs → legacy-noops-C732QDCY.mjs} +6 -6
- package/dist/cli/{legacy-noops-XQANGML3.js → legacy-noops-HDOB5C6F.js} +9 -9
- package/dist/cli/{monitors-ABJVLWIP.mjs → monitors-2LYEFXOU.mjs} +7 -7
- package/dist/cli/{monitors-F3PTNP45.js → monitors-5IUMHH3E.js} +100 -100
- package/dist/cli/{org-WQAPZI5Q.js → org-ADW2EVAC.js} +86 -86
- package/dist/cli/{org-BHF6Y5R7.mjs → org-G4YGZPHS.mjs} +6 -6
- package/dist/cli/{pages-W4HWVJUG.mjs → pages-KXKWSCEV.mjs} +6 -6
- package/dist/cli/{pages-U3EJ2NPL.js → pages-VTJGAI2D.js} +18 -18
- package/dist/cli/{play-3T4X3ZKH.mjs → play-7GQ56C2D.mjs} +69 -22
- package/dist/cli/{play-2UHKONON.js → play-EHSOSSHT.js} +367 -320
- package/dist/cli/{providers-LUK5LIUA.js → providers-PWCF6OOO.js} +9 -9
- package/dist/cli/{providers-2G2VTNDG.mjs → providers-WL3YTCSV.mjs} +6 -6
- package/dist/cli/{quickstart-XP4PJZ7N.mjs → quickstart-323XOPGI.mjs} +4 -4
- package/dist/cli/{quickstart-76P6PGID.js → quickstart-ZKI5MURA.js} +6 -6
- package/dist/cli/{run-S2KHGBCM.js → run-XZPWA6JS.js} +41 -41
- package/dist/cli/{run-ACIHA53A.mjs → run-ZCNZU3K2.mjs} +23 -23
- package/dist/cli/{search-VFIJCUZL.mjs → search-CVLVSFMJ.mjs} +8 -8
- package/dist/cli/search-J6EY7DQN.js +33 -0
- package/dist/cli/{search-output-2KFLZS5F.mjs → search-output-6PY6RN2R.mjs} +4 -4
- package/dist/cli/{search-output-GV7NNB4X.js → search-output-7HRSSRBS.js} +6 -6
- package/dist/cli/{secrets-MAQLBVC4.mjs → secrets-6S2ZWDIM.mjs} +6 -6
- package/dist/cli/{secrets-KJSFEW2F.js → secrets-IYD5VKY4.js} +15 -15
- package/dist/cli/sessions-7HPIVSQ4.js +22 -0
- package/dist/cli/{sessions-G5MWNJ75.mjs → sessions-GVEX5TUJ.mjs} +6 -6
- package/dist/cli/{settings-MR6UFOK5.mjs → settings-BN5MJZ3C.mjs} +13 -13
- package/dist/cli/{settings-VXGRPFXP.js → settings-CANK4HJQ.js} +86 -86
- package/dist/cli/{setup-ZOBXMONM.mjs → setup-JNMSCCU4.mjs} +10 -10
- package/dist/cli/{setup-C74BRK7N.js → setup-YSGKGLSJ.js} +50 -50
- package/dist/cli/{skills-4CG3MHOY.mjs → skills-QCQN2UM2.mjs} +8 -8
- package/dist/cli/skills-WDGSSKJZ.js +37 -0
- package/dist/cli/{tools-YXCXZ4ZD.mjs → tools-CDPOID7V.mjs} +17 -17
- package/dist/cli/tools-URNVXSTZ.js +57 -0
- package/dist/cli/{update-Z3C5W3I4.mjs → update-D3ZERUQ3.mjs} +10 -10
- package/dist/cli/update-Q6JW32IA.js +35 -0
- package/dist/cli/{views-XGP2GZ52.js → views-4NV2KQKA.js} +18 -18
- package/dist/cli/{views-45B2FZQT.mjs → views-RDZRWQBQ.mjs} +6 -6
- package/dist/cli/{workflow-KQRWSNBH.mjs → workflow-2CG3TVCG.mjs} +7 -7
- package/dist/cli/{workflow-DWO35XHZ.js → workflow-RABJCAZC.js} +17 -17
- package/dist/{client-Bd2meveV.d.mts → client-DhSvMO3A.d.mts} +1 -1
- package/dist/{client-core-CGj8V9mw.d.mts → client-core-CVG1Et-4.d.mts} +41 -2
- package/dist/{client-core-CsRRWCFy.d.ts → client-core-CdWH6Sii.d.ts} +41 -2
- package/dist/{client-CBCVhL8U.d.ts → client-oGNJMQFd.d.ts} +1 -1
- package/dist/{compiler-manifest-DsxsQP-T.d.ts → compiler-manifest-D2ZlBGxj.d.mts} +44 -0
- package/dist/{compiler-manifest-DsxsQP-T.d.mts → 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-KE6RFHUE.js +0 -43
- package/dist/cli/describe-PYLZAVRI.js +0 -50
- package/dist/cli/git-T5JTVBYZ.js +0 -25
- package/dist/cli/search-5MD65V43.js +0 -33
- package/dist/cli/sessions-FDMO7PAA.js +0 -22
- package/dist/cli/skills-KRUL7QCT.js +0 -37
- package/dist/cli/tools-CGHOSCPS.js +0 -57
- package/dist/cli/update-S2TILEHZ.js +0 -35
|
@@ -41,6 +41,28 @@ export const RUNTIME_EXECUTION_CAPABILITIES = [
|
|
|
41
41
|
export type RuntimeExecutionCapability =
|
|
42
42
|
(typeof RUNTIME_EXECUTION_CAPABILITIES)[number];
|
|
43
43
|
|
|
44
|
+
export type CalendarBookingBinding = {
|
|
45
|
+
connectionId: string;
|
|
46
|
+
grantGeneration: number;
|
|
47
|
+
apiKeyId: string;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export function isCalendarBookingBinding(
|
|
51
|
+
value: unknown,
|
|
52
|
+
): value is CalendarBookingBinding {
|
|
53
|
+
if (!value || typeof value !== 'object') return false;
|
|
54
|
+
const binding = value as Partial<CalendarBookingBinding>;
|
|
55
|
+
return (
|
|
56
|
+
typeof binding.connectionId === 'string' &&
|
|
57
|
+
/^[a-z0-9]{16,64}$/.test(binding.connectionId) &&
|
|
58
|
+
typeof binding.apiKeyId === 'string' &&
|
|
59
|
+
/^[a-z0-9]{16,64}$/.test(binding.apiKeyId) &&
|
|
60
|
+
typeof binding.grantGeneration === 'number' &&
|
|
61
|
+
Number.isSafeInteger(binding.grantGeneration) &&
|
|
62
|
+
binding.grantGeneration > 0
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
44
66
|
const CAPABILITY_SET = new Set<string>(RUNTIME_EXECUTION_CAPABILITIES);
|
|
45
67
|
|
|
46
68
|
/**
|
|
@@ -50,6 +72,8 @@ const CAPABILITY_SET = new Set<string>(RUNTIME_EXECUTION_CAPABILITIES);
|
|
|
50
72
|
export type RuntimeAuthorityDescriptor = {
|
|
51
73
|
/** Server-owned restriction inherited by every descendant and attempt. */
|
|
52
74
|
operationPolicy?: ExecutionOperationPolicy;
|
|
75
|
+
/** Exact workspace Calendar connection authorized at root run admission. */
|
|
76
|
+
calendarBookingBinding?: CalendarBookingBinding;
|
|
53
77
|
orgId: string;
|
|
54
78
|
workflowId: string;
|
|
55
79
|
runId: string;
|
|
@@ -181,6 +205,8 @@ export function requireRuntimeAuthorityDescriptor(
|
|
|
181
205
|
capabilities.length === 0 ||
|
|
182
206
|
(descriptor.operationPolicy !== undefined &&
|
|
183
207
|
!isExecutionOperationPolicy(descriptor.operationPolicy)) ||
|
|
208
|
+
(descriptor.calendarBookingBinding !== undefined &&
|
|
209
|
+
!isCalendarBookingBinding(descriptor.calendarBookingBinding)) ||
|
|
184
210
|
!fixtureBehavior.ok ||
|
|
185
211
|
(fixtureBehavior.behavior !== null &&
|
|
186
212
|
descriptor.integrationMode !== 'fixture')
|
|
@@ -89,11 +89,31 @@ export type FreshExecutionReplay = { freshInvocation: true };
|
|
|
89
89
|
/** recoverUnbound's answer when the call should execute instead. */
|
|
90
90
|
const EXECUTE: unique symbol = Symbol('execute');
|
|
91
91
|
|
|
92
|
+
/** The author-facing message for each replay refusal reason. */
|
|
93
|
+
function durableReplayInputMismatchMessage(
|
|
94
|
+
operation: string,
|
|
95
|
+
callId: string,
|
|
96
|
+
reason: ReplayRefusal['reason'],
|
|
97
|
+
): string {
|
|
98
|
+
switch (reason) {
|
|
99
|
+
case 'input_changed':
|
|
100
|
+
return `DURABLE_REPLAY_INPUT_MISMATCH: ctx.${operation}("${callId}") was replayed with a different input than the call recorded in this run. Deepline did not return the recorded result or repeat the call, because it may write. Make the input deterministic (no current time or random values), or give each distinct call its own id.`;
|
|
101
|
+
case 'credential_or_action_changed':
|
|
102
|
+
return `DURABLE_REPLAY_INPUT_MISMATCH: ctx.${operation}("${callId}") was replayed with the same input but a different credential or action revision than the call recorded in this run. Deepline did not return the recorded result or repeat the call, because it may write.`;
|
|
103
|
+
case 'recorded_identity_mismatch':
|
|
104
|
+
return `DURABLE_REPLAY_INPUT_MISMATCH: ctx.${operation}("${callId}") could not be matched to its recorded result. This run started on an older Deepline build whose saved history cannot prove which call this was, and the recorded result belongs to a different request. Deepline did not return that result or repeat the call, because it may write. Start a new run.`;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
92
108
|
/**
|
|
93
109
|
* A replay reached a recorded operation of a different request and the call
|
|
94
110
|
* may write. Returning the recorded result would hand back another request's
|
|
95
|
-
* output; executing could repeat a write. Not retryable
|
|
96
|
-
* must be made deterministic, or each distinct call
|
|
111
|
+
* output; executing could repeat a write. Not retryable. For a binding
|
|
112
|
+
* refusal the Play's input must be made deterministic, or each distinct call
|
|
113
|
+
* given its own id. For `recorded_identity_mismatch` (pre-binding history)
|
|
114
|
+
* nothing proves the input changed: an older build numbered identical calls
|
|
115
|
+
* in tool-layer entry order, so the slot may hold a sibling's result, and
|
|
116
|
+
* the run must be started again.
|
|
97
117
|
*/
|
|
98
118
|
export class DurableReplayInputMismatchError extends Error {
|
|
99
119
|
readonly code = 'DURABLE_REPLAY_INPUT_MISMATCH';
|
|
@@ -102,13 +122,9 @@ export class DurableReplayInputMismatchError extends Error {
|
|
|
102
122
|
constructor(
|
|
103
123
|
readonly operation: string,
|
|
104
124
|
readonly callId: string,
|
|
105
|
-
readonly reason: '
|
|
125
|
+
readonly reason: ReplayRefusal['reason'],
|
|
106
126
|
) {
|
|
107
|
-
super(
|
|
108
|
-
reason === 'input_changed'
|
|
109
|
-
? `DURABLE_REPLAY_INPUT_MISMATCH: ctx.${operation}("${callId}") was replayed with a different input than the call recorded in this run. Deepline did not return the recorded result or repeat the call, because it may write. Make the input deterministic (no current time or random values), or give each distinct call its own id.`
|
|
110
|
-
: `DURABLE_REPLAY_INPUT_MISMATCH: ctx.${operation}("${callId}") was replayed with the same input but a different credential or action revision than the call recorded in this run. Deepline did not return the recorded result or repeat the call, because it may write.`,
|
|
111
|
-
);
|
|
127
|
+
super(durableReplayInputMismatchMessage(operation, callId, reason));
|
|
112
128
|
this.name = 'DurableReplayInputMismatchError';
|
|
113
129
|
}
|
|
114
130
|
}
|
|
@@ -313,9 +329,11 @@ function recordedIdentitySources(
|
|
|
313
329
|
: null;
|
|
314
330
|
const execution = result?._metadata?.execution;
|
|
315
331
|
if (
|
|
316
|
-
[
|
|
317
|
-
|
|
318
|
-
|
|
332
|
+
[
|
|
333
|
+
execution?.cacheKey,
|
|
334
|
+
execution?.receiptKey,
|
|
335
|
+
execution?.resultReceiptKey,
|
|
336
|
+
].some((key) => typeof key === 'string' && key.trim())
|
|
319
337
|
) {
|
|
320
338
|
sources.push('result_metadata');
|
|
321
339
|
}
|
|
@@ -744,8 +762,8 @@ export async function executeWithFreshnessReceipt<T>(input: {
|
|
|
744
762
|
if (stored?.status !== 'completed' && stored?.status !== 'skipped') {
|
|
745
763
|
throw new Error(
|
|
746
764
|
key === operationKey ||
|
|
747
|
-
|
|
748
|
-
|
|
765
|
+
key === exactRequestOperationKey ||
|
|
766
|
+
key.startsWith(`${cachePrefix}:reusable:`)
|
|
749
767
|
? 'Completed freshness receipt publication failed.'
|
|
750
768
|
: `Tool Result Receipt ${key} could not publish a completed result.`,
|
|
751
769
|
);
|
|
@@ -891,7 +909,7 @@ export async function executeWithFreshnessReceipt<T>(input: {
|
|
|
891
909
|
throw new DurableReplayInputMismatchError(
|
|
892
910
|
input.operation ?? 'call',
|
|
893
911
|
input.callId ?? 'unknown',
|
|
894
|
-
'
|
|
912
|
+
'recorded_identity_mismatch',
|
|
895
913
|
);
|
|
896
914
|
};
|
|
897
915
|
/**
|
|
@@ -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) =>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { WORKFLOW_EXECUTOR_TOKEN_TTL_SECONDS } from './/runtime-constants';
|
|
2
2
|
import {
|
|
3
3
|
isExecutionOperationPolicy,
|
|
4
|
+
isCalendarBookingBinding,
|
|
5
|
+
type CalendarBookingBinding,
|
|
4
6
|
type ExecutionOperationPolicy,
|
|
5
7
|
DEFAULT_RUNTIME_EXECUTION_CAPABILITIES,
|
|
6
8
|
isRuntimeExecutionCapability,
|
|
@@ -306,6 +308,7 @@ export type WorkflowRunExecutionTokenClaims =
|
|
|
306
308
|
WorkflowInternalTokenBaseClaims & {
|
|
307
309
|
purpose: typeof INTERNAL_WORKFLOW_EXECUTION_PURPOSE;
|
|
308
310
|
operation_policy?: ExecutionOperationPolicy;
|
|
311
|
+
calendar_booking_binding?: CalendarBookingBinding;
|
|
309
312
|
workflow_id: string;
|
|
310
313
|
run_id: string;
|
|
311
314
|
// Billing owner for this execution. Defaults to run_id on older tokens and
|
|
@@ -652,6 +655,8 @@ function isValidWorkflowClaimsShape(
|
|
|
652
655
|
validateFixtureBehavior(claims.fixture_behavior).ok)) &&
|
|
653
656
|
(claims.operation_policy === undefined ||
|
|
654
657
|
isExecutionOperationPolicy(claims.operation_policy)) &&
|
|
658
|
+
(claims.calendar_booking_binding === undefined ||
|
|
659
|
+
isCalendarBookingBinding(claims.calendar_booking_binding)) &&
|
|
655
660
|
(claims.synthetic === undefined || claims.synthetic === true) &&
|
|
656
661
|
(claims.actor_user_id === undefined ||
|
|
657
662
|
typeof claims.actor_user_id === 'string') &&
|
|
@@ -752,6 +757,7 @@ export async function mintIngestionSubscriptionExecutionToken(input: {
|
|
|
752
757
|
|
|
753
758
|
export async function mintWorkflowRunExecutionToken(input: {
|
|
754
759
|
operationPolicy?: ExecutionOperationPolicy;
|
|
760
|
+
calendarBookingBinding?: CalendarBookingBinding;
|
|
755
761
|
orgId: string;
|
|
756
762
|
workflowId: string;
|
|
757
763
|
runId: string;
|
|
@@ -800,6 +806,9 @@ export async function mintWorkflowRunExecutionToken(input: {
|
|
|
800
806
|
...(input.operationPolicy
|
|
801
807
|
? { operation_policy: input.operationPolicy }
|
|
802
808
|
: {}),
|
|
809
|
+
...(input.calendarBookingBinding
|
|
810
|
+
? { calendar_booking_binding: input.calendarBookingBinding }
|
|
811
|
+
: {}),
|
|
803
812
|
org_id: input.orgId,
|
|
804
813
|
workflow_id: input.workflowId,
|
|
805
814
|
run_id: input.runId,
|
|
@@ -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
|
|