deepline 0.1.228 → 0.1.229
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/apps/play-runner-workers/src/coordinator-entry.ts +76 -1842
- package/dist/bundling-sources/apps/play-runner-workers/src/dedup-do.ts +0 -113
- package/dist/bundling-sources/apps/play-runner-workers/src/entry.ts +81 -968
- package/dist/bundling-sources/apps/play-runner-workers/src/workflow-retry-state.ts +1 -50
- package/dist/bundling-sources/sdk/src/release.ts +2 -2
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +67 -15
- package/dist/bundling-sources/shared_libs/play-runtime/child-execution-strategy.ts +84 -79
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +152 -688
- package/dist/bundling-sources/shared_libs/play-runtime/coordinator-headers.ts +3 -10
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-contract.ts +2 -2
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +12 -47
- package/dist/bundling-sources/shared_libs/play-runtime/governor/block-reserving-budget-state-backend.ts +0 -2
- package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +12 -200
- package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +2 -17
- package/dist/bundling-sources/shared_libs/play-runtime/play-call-execution.ts +6 -1
- package/dist/bundling-sources/shared_libs/play-runtime/play-latency-trace.ts +28 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-execution-scope.ts +16 -64
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-paths.ts +0 -4
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +37 -9
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +0 -36
- package/dist/bundling-sources/shared_libs/play-runtime/suspension.ts +3 -21
- package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +9 -1
- package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +2 -0
- package/dist/cli/index.js +2 -2
- package/dist/cli/index.mjs +2 -2
- package/dist/{compiler-manifest-BhgZ23A4.d.ts → compiler-manifest-CYcwzSOJ.d.mts} +2 -0
- package/dist/{compiler-manifest-BhgZ23A4.d.mts → compiler-manifest-CYcwzSOJ.d.ts} +2 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/plays/bundle-play-file.d.mts +2 -2
- package/dist/plays/bundle-play-file.d.ts +2 -2
- package/package.json +1 -1
- package/dist/bundling-sources/apps/play-runner-workers/src/child-manifest-resolver.ts +0 -108
- package/dist/bundling-sources/apps/play-runner-workers/src/child-play-await.ts +0 -374
- package/dist/bundling-sources/apps/play-runner-workers/src/child-play-submit.ts +0 -203
- package/dist/bundling-sources/shared_libs/play-runtime/child-execution-placement.ts +0 -14
- package/dist/bundling-sources/shared_libs/play-runtime/child-run-id.ts +0 -121
|
@@ -29,16 +29,9 @@ export const WORKER_CALLBACK_URL_OVERRIDE_HEADER =
|
|
|
29
29
|
export const RUNTIME_SCHEDULER_SCHEMA_OVERRIDE_HEADER =
|
|
30
30
|
'x-deepline-runtime-scheduler-schema';
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* the resolver's schema-derived default, so a child always finishes on the
|
|
36
|
-
* release that launched its parent. Honored ONLY for internal `internalRunPlay`
|
|
37
|
-
* child launches (executor-token authed, lineage-validated), plus internally
|
|
38
|
-
* authenticated root `profile=absurd` launches used by deploy canaries to pin
|
|
39
|
-
* an exact candidate release before activation. Public API keys cannot use
|
|
40
|
-
* this override. Absent =>
|
|
41
|
-
* inherit-when-absent back-compat: the resolver default applies unchanged.
|
|
32
|
+
* Internal top-level `profile=absurd` launches, including deploy canaries, use
|
|
33
|
+
* this header to pin an exact candidate release before activation. Public API
|
|
34
|
+
* keys cannot use it. When absent, the resolver chooses the registered lane.
|
|
42
35
|
*/
|
|
43
36
|
export const ABSURD_RELEASE_OVERRIDE_HEADER = 'x-deepline-absurd-release';
|
|
44
37
|
/**
|
|
@@ -214,7 +214,7 @@ export type PlayStep =
|
|
|
214
214
|
| {
|
|
215
215
|
type: 'play_call';
|
|
216
216
|
playId: string;
|
|
217
|
-
execution?: 'inline'
|
|
217
|
+
execution?: 'inline';
|
|
218
218
|
results?: PlayStepRowResult[];
|
|
219
219
|
nestedSteps: PlayStep[];
|
|
220
220
|
description?: string;
|
|
@@ -253,7 +253,7 @@ export type PlayDatasetSubstep =
|
|
|
253
253
|
| {
|
|
254
254
|
type: 'play_call';
|
|
255
255
|
playId: string;
|
|
256
|
-
execution?: 'inline'
|
|
256
|
+
execution?: 'inline';
|
|
257
257
|
results?: PlayStepRowResult[];
|
|
258
258
|
nestedSteps: PlayStep[];
|
|
259
259
|
description?: string;
|
|
@@ -307,7 +307,17 @@ export type CustomerDbQueryHandler = (
|
|
|
307
307
|
|
|
308
308
|
export interface PlayCallOptions {
|
|
309
309
|
description?: string;
|
|
310
|
-
|
|
310
|
+
/**
|
|
311
|
+
* `child-workflow` is accepted only so the checker/runtime can emit the
|
|
312
|
+
* canonical CTX_RUN_PLAY_INLINE_ONLY migration diagnostic. It never starts a
|
|
313
|
+
* child workflow.
|
|
314
|
+
*/
|
|
315
|
+
execution?: PlayCallExecution | 'child-workflow';
|
|
316
|
+
/**
|
|
317
|
+
* Parsed so source preflight and an untyped runtime call can return the
|
|
318
|
+
* canonical CTX_RUN_PLAY_INLINE_ONLY migration error. It is never honored.
|
|
319
|
+
*/
|
|
320
|
+
timeoutMs?: number;
|
|
311
321
|
}
|
|
312
322
|
|
|
313
323
|
export interface StepOptions {
|
|
@@ -331,38 +341,6 @@ export interface ResolvedPlayExecution {
|
|
|
331
341
|
contractSnapshot?: PlayRunContractSnapshot | null;
|
|
332
342
|
}
|
|
333
343
|
|
|
334
|
-
export interface PlayExecutionGovernanceLimits {
|
|
335
|
-
maxPlayCallDepth: number;
|
|
336
|
-
maxPlayCallCount: number;
|
|
337
|
-
maxToolCallCount: number;
|
|
338
|
-
maxWaterfallStepExecutions: number | null;
|
|
339
|
-
maxRetryCount: number;
|
|
340
|
-
maxDescendants: number;
|
|
341
|
-
maxChildPlayCallsPerParent: number;
|
|
342
|
-
maxConcurrentPlayCalls: number;
|
|
343
|
-
maxConcurrentToolCalls: number;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
export interface PlayExecutionGovernanceState {
|
|
347
|
-
rootPlayId: string;
|
|
348
|
-
rootRunId: string;
|
|
349
|
-
currentPlayId: string;
|
|
350
|
-
currentRunId: string;
|
|
351
|
-
ancestryPlayIds: string[];
|
|
352
|
-
ancestryRunIds: string[];
|
|
353
|
-
callDepth: number;
|
|
354
|
-
playCallCount: number;
|
|
355
|
-
toolCallCount: number;
|
|
356
|
-
waterfallStepExecutions: number;
|
|
357
|
-
retryCount: number;
|
|
358
|
-
descendantCount: number;
|
|
359
|
-
parentChildCalls: Record<string, number>;
|
|
360
|
-
inFlightPlayCalls: number;
|
|
361
|
-
inFlightPlayCallsByPlayId?: Record<string, number>;
|
|
362
|
-
inFlightToolCalls: number;
|
|
363
|
-
limits: PlayExecutionGovernanceLimits;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
344
|
export interface BatchRequest {
|
|
367
345
|
provider: string;
|
|
368
346
|
toolName: string;
|
|
@@ -763,11 +741,7 @@ export interface ContextOptions {
|
|
|
763
741
|
skipRuntimeStepReceipt?: (
|
|
764
742
|
input: SkipRuntimeStepReceiptInput,
|
|
765
743
|
) => Promise<RuntimeStepReceipt | null> | RuntimeStepReceipt | null;
|
|
766
|
-
/**
|
|
767
|
-
* Lineage governance snapshot to resume a child play run from. Produced by the
|
|
768
|
-
* parent's Play Execution Governor `forkChild(...)` so budgets/depth/cycle
|
|
769
|
-
* guards accumulate across the nested-play tree. Only set on child contexts.
|
|
770
|
-
*/
|
|
744
|
+
/** Inline composition scope used for recursion and shared-resource governance. */
|
|
771
745
|
governance?: GovernanceSnapshot;
|
|
772
746
|
/** Internal in-process child view sharing the root run's resource governor. */
|
|
773
747
|
executionGovernor?: PlayExecutionGovernor;
|
|
@@ -821,15 +795,6 @@ export interface PlayCheckpoint {
|
|
|
821
795
|
output?: unknown;
|
|
822
796
|
completedAt?: number;
|
|
823
797
|
}
|
|
824
|
-
| {
|
|
825
|
-
kind: 'child_play';
|
|
826
|
-
childRunId: string;
|
|
827
|
-
childPlayName: string;
|
|
828
|
-
status: 'completed' | 'failed' | 'cancelled';
|
|
829
|
-
output?: unknown;
|
|
830
|
-
error?: string;
|
|
831
|
-
completedAt?: number;
|
|
832
|
-
}
|
|
833
798
|
>;
|
|
834
799
|
/** Per-map execution frames keyed by invocation id. */
|
|
835
800
|
mapFrames?: Record<string, MapExecutionFrame>;
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* "may I, and how many at once" policy. See ADR 0007 + CONTEXT.md.
|
|
9
9
|
*
|
|
10
10
|
* Surface (small, by design):
|
|
11
|
-
* - acquireRowSlot /
|
|
11
|
+
* - acquireRowSlot / acquireToolSlot → blocking leases
|
|
12
12
|
* - chargeBudget → throws on breach
|
|
13
|
-
* -
|
|
13
|
+
* - forkInlineChild → inline recursion scope
|
|
14
14
|
* - resolveRowConcurrency / reportProviderBackpressure / snapshot
|
|
15
15
|
*/
|
|
16
16
|
import {
|
|
@@ -35,14 +35,9 @@ export interface WorkLease {
|
|
|
35
35
|
release(): void;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export type BudgetKind =
|
|
39
|
-
| 'playCall'
|
|
40
|
-
| 'toolCall'
|
|
41
|
-
| 'retry'
|
|
42
|
-
| 'descendant'
|
|
43
|
-
| 'waterfallStep';
|
|
38
|
+
export type BudgetKind = 'toolCall' | 'retry' | 'waterfallStep';
|
|
44
39
|
|
|
45
|
-
/**
|
|
40
|
+
/** Runtime identity and counters shared by inline composition. */
|
|
46
41
|
export interface GovernanceSnapshot {
|
|
47
42
|
rootRunId: string;
|
|
48
43
|
currentRunId: string;
|
|
@@ -50,18 +45,14 @@ export interface GovernanceSnapshot {
|
|
|
50
45
|
ancestryPlayIds: string[];
|
|
51
46
|
ancestryRunIds: string[];
|
|
52
47
|
callDepth: number;
|
|
53
|
-
playCallCount: number;
|
|
54
48
|
toolCallCount: number;
|
|
55
49
|
retryCount: number;
|
|
56
|
-
descendantCount: number;
|
|
57
50
|
waterfallStepExecutions: number;
|
|
58
|
-
/** Direct child plays launched, keyed by parent play id. */
|
|
59
|
-
parentChildCalls: Record<string, number>;
|
|
60
51
|
}
|
|
61
52
|
|
|
62
53
|
export class GovernorBudgetError extends Error {
|
|
63
54
|
constructor(
|
|
64
|
-
readonly budget: BudgetKind | 'playDepth'
|
|
55
|
+
readonly budget: BudgetKind | 'playDepth',
|
|
65
56
|
readonly observed: number,
|
|
66
57
|
readonly limit: number,
|
|
67
58
|
) {
|
|
@@ -104,8 +95,6 @@ export interface PlayExecutionGovernor {
|
|
|
104
95
|
|
|
105
96
|
/** Block until a map-row slot is free. */
|
|
106
97
|
acquireRowSlot(opts?: { signal?: AbortSignal }): Promise<WorkLease>;
|
|
107
|
-
/** Block until a child-play submit slot is free. Released after submit, not terminal. */
|
|
108
|
-
acquireChildSubmitSlot(opts?: { signal?: AbortSignal }): Promise<WorkLease>;
|
|
109
98
|
/**
|
|
110
99
|
* Block until a global tool-concurrency slot AND the per-(org,provider) pacer
|
|
111
100
|
* permit are free, then charge the tool-call budget and return a lease. Order:
|
|
@@ -129,28 +118,8 @@ export interface PlayExecutionGovernor {
|
|
|
129
118
|
chargeBudget(kind: BudgetKind, amount?: number): Promise<void>;
|
|
130
119
|
|
|
131
120
|
/**
|
|
132
|
-
*
|
|
133
|
-
* the
|
|
134
|
-
* lineage (and across isolates on `esm_workers`). Throws on breach.
|
|
135
|
-
*
|
|
136
|
-
* Unlike {@link acquireToolSlot} (which charges last so an aborted acquire
|
|
137
|
-
* never consumes budget), child-lineage counters are charged here at fork
|
|
138
|
-
* time, BEFORE the caller acquires a child-submit slot. A slot acquire that then
|
|
139
|
-
* fails (e.g. abort) does NOT refund these counters. This is intentional and
|
|
140
|
-
* safe given the 100k child caps: the charge reserves lineage-global capacity
|
|
141
|
-
* for a launch the caller has committed to, and forkChild must return the
|
|
142
|
-
* threaded snapshot synchronously, so the charge cannot be deferred behind the
|
|
143
|
-
* async slot acquire.
|
|
144
|
-
*/
|
|
145
|
-
forkChild(input: {
|
|
146
|
-
childPlayName: string;
|
|
147
|
-
childRunId: string;
|
|
148
|
-
}): Promise<GovernanceSnapshot>;
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Fork an in-process child view. The child gets its own lineage while sharing
|
|
152
|
-
* the parent's row/tool/child semaphores, adaptive admission, and global
|
|
153
|
-
* budget counters.
|
|
121
|
+
* Fork an inline child view. The child gets its own recursion lineage while
|
|
122
|
+
* sharing the parent's row/tool semaphores, adaptive admission, and budgets.
|
|
154
123
|
*/
|
|
155
124
|
forkInlineChild(input: {
|
|
156
125
|
childPlayName: string;
|
|
@@ -254,12 +223,9 @@ export function createDefaultGovernanceSnapshot(scope: {
|
|
|
254
223
|
ancestryPlayIds: scope.rootPlayId ? [scope.rootPlayId] : [],
|
|
255
224
|
ancestryRunIds: [scope.rootRunId],
|
|
256
225
|
callDepth: scope.rootPlayId ? 1 : 0,
|
|
257
|
-
playCallCount: 0,
|
|
258
226
|
toolCallCount: 0,
|
|
259
227
|
retryCount: 0,
|
|
260
|
-
descendantCount: 0,
|
|
261
228
|
waterfallStepExecutions: 0,
|
|
262
|
-
parentChildCalls: {},
|
|
263
229
|
};
|
|
264
230
|
}
|
|
265
231
|
|
|
@@ -271,7 +237,6 @@ export function createPlayExecutionGovernor(
|
|
|
271
237
|
input.resume ?? createDefaultGovernanceSnapshot(input.scope);
|
|
272
238
|
|
|
273
239
|
const rowSlots = new Semaphore(policy.concurrency.rowMax);
|
|
274
|
-
const childPlaySlots = new Semaphore(policy.concurrency.childPlay);
|
|
275
240
|
const toolSlots = new Semaphore(policy.concurrency.toolCalls);
|
|
276
241
|
const adaptiveAdmission =
|
|
277
242
|
input.adaptiveAdmission ??
|
|
@@ -320,14 +285,10 @@ export function createPlayExecutionGovernor(
|
|
|
320
285
|
|
|
321
286
|
const budgetLimit = (kind: BudgetKind): number => {
|
|
322
287
|
switch (kind) {
|
|
323
|
-
case 'playCall':
|
|
324
|
-
return policy.budgets.maxPlayCallCount;
|
|
325
288
|
case 'toolCall':
|
|
326
289
|
return policy.budgets.maxToolCallCount;
|
|
327
290
|
case 'retry':
|
|
328
291
|
return policy.budgets.maxRetryCount;
|
|
329
|
-
case 'descendant':
|
|
330
|
-
return policy.budgets.maxDescendants;
|
|
331
292
|
case 'waterfallStep':
|
|
332
293
|
return policy.budgets.maxWaterfallStepExecutions;
|
|
333
294
|
}
|
|
@@ -359,32 +320,22 @@ export function createPlayExecutionGovernor(
|
|
|
359
320
|
|
|
360
321
|
async function chargeBudget(kind: BudgetKind, amount = 1): Promise<void> {
|
|
361
322
|
const current =
|
|
362
|
-
kind === '
|
|
363
|
-
? state.
|
|
364
|
-
: kind === '
|
|
365
|
-
? state.
|
|
366
|
-
:
|
|
367
|
-
? state.retryCount
|
|
368
|
-
: kind === 'descendant'
|
|
369
|
-
? state.descendantCount
|
|
370
|
-
: state.waterfallStepExecutions;
|
|
323
|
+
kind === 'toolCall'
|
|
324
|
+
? state.toolCallCount
|
|
325
|
+
: kind === 'retry'
|
|
326
|
+
? state.retryCount
|
|
327
|
+
: state.waterfallStepExecutions;
|
|
371
328
|
if (current + amount > budgetLimit(kind)) {
|
|
372
329
|
throw new GovernorBudgetError(kind, current + amount, budgetLimit(kind));
|
|
373
330
|
}
|
|
374
331
|
await reserveBudgets([{ kind, amount }]);
|
|
375
332
|
switch (kind) {
|
|
376
|
-
case 'playCall':
|
|
377
|
-
state.playCallCount += amount;
|
|
378
|
-
return;
|
|
379
333
|
case 'toolCall':
|
|
380
334
|
state.toolCallCount += amount;
|
|
381
335
|
return;
|
|
382
336
|
case 'retry':
|
|
383
337
|
state.retryCount += amount;
|
|
384
338
|
return;
|
|
385
|
-
case 'descendant':
|
|
386
|
-
state.descendantCount += amount;
|
|
387
|
-
return;
|
|
388
339
|
case 'waterfallStep':
|
|
389
340
|
state.waterfallStepExecutions += amount;
|
|
390
341
|
return;
|
|
@@ -396,8 +347,6 @@ export function createPlayExecutionGovernor(
|
|
|
396
347
|
policy,
|
|
397
348
|
|
|
398
349
|
acquireRowSlot: (opts) => rowSlots.acquire(opts?.signal),
|
|
399
|
-
acquireChildSubmitSlot: (opts) => childPlaySlots.acquire(opts?.signal),
|
|
400
|
-
|
|
401
350
|
async acquireToolSlot(toolId, opts) {
|
|
402
351
|
// 1. global tool-concurrency slot.
|
|
403
352
|
const slot = await toolSlots.acquire(opts?.signal);
|
|
@@ -450,93 +399,6 @@ export function createPlayExecutionGovernor(
|
|
|
450
399
|
|
|
451
400
|
chargeBudget,
|
|
452
401
|
|
|
453
|
-
async forkChild(childInput) {
|
|
454
|
-
if (state.ancestryPlayIds.includes(childInput.childPlayName)) {
|
|
455
|
-
const chain = [...state.ancestryPlayIds, childInput.childPlayName].join(
|
|
456
|
-
' -> ',
|
|
457
|
-
);
|
|
458
|
-
throw new Error(`Recursive play graph detected: ${chain}`);
|
|
459
|
-
}
|
|
460
|
-
const nextDepth = state.callDepth + 1;
|
|
461
|
-
if (nextDepth > policy.budgets.maxPlayCallDepth)
|
|
462
|
-
throw new GovernorBudgetError(
|
|
463
|
-
'playDepth',
|
|
464
|
-
nextDepth,
|
|
465
|
-
policy.budgets.maxPlayCallDepth,
|
|
466
|
-
);
|
|
467
|
-
const parentKey = state.currentPlayId;
|
|
468
|
-
const nextParent = (state.parentChildCalls[parentKey] ?? 0) + 1;
|
|
469
|
-
if (nextParent > policy.budgets.maxChildPlayCallsPerParent)
|
|
470
|
-
throw new GovernorBudgetError(
|
|
471
|
-
'childPerParent',
|
|
472
|
-
nextParent,
|
|
473
|
-
policy.budgets.maxChildPlayCallsPerParent,
|
|
474
|
-
);
|
|
475
|
-
if (state.playCallCount + 1 > policy.budgets.maxPlayCallCount)
|
|
476
|
-
throw new GovernorBudgetError(
|
|
477
|
-
'playCall',
|
|
478
|
-
state.playCallCount + 1,
|
|
479
|
-
policy.budgets.maxPlayCallCount,
|
|
480
|
-
);
|
|
481
|
-
if (state.descendantCount + 1 > policy.budgets.maxDescendants)
|
|
482
|
-
throw new GovernorBudgetError(
|
|
483
|
-
'descendant',
|
|
484
|
-
state.descendantCount + 1,
|
|
485
|
-
policy.budgets.maxDescendants,
|
|
486
|
-
);
|
|
487
|
-
// Charge the run-wide play/descendant budgets on the parent. Charged at
|
|
488
|
-
// fork time (not after the caller's child-play slot acquire) and never
|
|
489
|
-
// refunded if that acquire fails — see the forkChild interface doc.
|
|
490
|
-
try {
|
|
491
|
-
await budgetState.charge({
|
|
492
|
-
rootRunId: state.rootRunId,
|
|
493
|
-
charges: [
|
|
494
|
-
{
|
|
495
|
-
key: 'playCall',
|
|
496
|
-
amount: 1,
|
|
497
|
-
limit: policy.budgets.maxPlayCallCount,
|
|
498
|
-
},
|
|
499
|
-
{
|
|
500
|
-
key: 'descendant',
|
|
501
|
-
amount: 1,
|
|
502
|
-
limit: policy.budgets.maxDescendants,
|
|
503
|
-
},
|
|
504
|
-
{
|
|
505
|
-
key: `childPerParent:${state.currentRunId}`,
|
|
506
|
-
amount: 1,
|
|
507
|
-
limit: policy.budgets.maxChildPlayCallsPerParent,
|
|
508
|
-
},
|
|
509
|
-
],
|
|
510
|
-
});
|
|
511
|
-
} catch (error) {
|
|
512
|
-
if (error instanceof BudgetStateLimitError) {
|
|
513
|
-
const budget = error.key.startsWith('childPerParent:')
|
|
514
|
-
? 'childPerParent'
|
|
515
|
-
: (error.key as BudgetKind);
|
|
516
|
-
throw new GovernorBudgetError(budget, error.observed, error.limit);
|
|
517
|
-
}
|
|
518
|
-
throw error;
|
|
519
|
-
}
|
|
520
|
-
state.playCallCount += 1;
|
|
521
|
-
state.descendantCount += 1;
|
|
522
|
-
state.parentChildCalls[parentKey] = nextParent;
|
|
523
|
-
// Child seeds from the parent's accumulated counters → lineage-global budget.
|
|
524
|
-
return {
|
|
525
|
-
rootRunId: state.rootRunId,
|
|
526
|
-
currentRunId: childInput.childRunId,
|
|
527
|
-
currentPlayId: childInput.childPlayName,
|
|
528
|
-
ancestryPlayIds: [...state.ancestryPlayIds, childInput.childPlayName],
|
|
529
|
-
ancestryRunIds: [...state.ancestryRunIds, childInput.childRunId],
|
|
530
|
-
callDepth: nextDepth,
|
|
531
|
-
playCallCount: state.playCallCount,
|
|
532
|
-
toolCallCount: state.toolCallCount,
|
|
533
|
-
retryCount: state.retryCount,
|
|
534
|
-
descendantCount: state.descendantCount,
|
|
535
|
-
waterfallStepExecutions: state.waterfallStepExecutions,
|
|
536
|
-
parentChildCalls: {},
|
|
537
|
-
};
|
|
538
|
-
},
|
|
539
|
-
|
|
540
402
|
async forkInlineChild(childInput) {
|
|
541
403
|
return createInlineChildGovernor(
|
|
542
404
|
governor,
|
|
@@ -587,7 +449,6 @@ export function createPlayExecutionGovernor(
|
|
|
587
449
|
...state,
|
|
588
450
|
ancestryPlayIds: [...state.ancestryPlayIds],
|
|
589
451
|
ancestryRunIds: [...state.ancestryRunIds],
|
|
590
|
-
parentChildCalls: { ...state.parentChildCalls },
|
|
591
452
|
}),
|
|
592
453
|
};
|
|
593
454
|
return governor;
|
|
@@ -621,7 +482,6 @@ function deriveInlineChildSnapshot(
|
|
|
621
482
|
ancestryPlayIds: [...parent.ancestryPlayIds, input.childPlayName],
|
|
622
483
|
ancestryRunIds: [...parent.ancestryRunIds, input.childRunId],
|
|
623
484
|
callDepth: nextDepth,
|
|
624
|
-
parentChildCalls: {},
|
|
625
485
|
};
|
|
626
486
|
}
|
|
627
487
|
|
|
@@ -636,14 +496,12 @@ function createInlineChildGovernor(
|
|
|
636
496
|
ancestryPlayIds: [...initial.ancestryPlayIds],
|
|
637
497
|
ancestryRunIds: [...initial.ancestryRunIds],
|
|
638
498
|
callDepth: initial.callDepth,
|
|
639
|
-
parentChildCalls: { ...initial.parentChildCalls },
|
|
640
499
|
};
|
|
641
500
|
|
|
642
501
|
const child: PlayExecutionGovernor = {
|
|
643
502
|
adapter: root.adapter,
|
|
644
503
|
policy: root.policy,
|
|
645
504
|
acquireRowSlot: (opts) => root.acquireRowSlot(opts),
|
|
646
|
-
acquireChildSubmitSlot: (opts) => root.acquireChildSubmitSlot(opts),
|
|
647
505
|
acquireToolSlot: (toolId, opts) => root.acquireToolSlot(toolId, opts),
|
|
648
506
|
suggestedParallelism: (toolId, fallback) =>
|
|
649
507
|
root.suggestedParallelism(toolId, fallback),
|
|
@@ -653,51 +511,6 @@ function createInlineChildGovernor(
|
|
|
653
511
|
root.reportProviderBackpressure(input),
|
|
654
512
|
observeProviderSuccess: (input) => root.observeProviderSuccess(input),
|
|
655
513
|
observeToolSuccess: (input) => root.observeToolSuccess(input),
|
|
656
|
-
async forkChild(input) {
|
|
657
|
-
if (lineage.ancestryPlayIds.includes(input.childPlayName)) {
|
|
658
|
-
throw new Error(
|
|
659
|
-
`Recursive play graph detected: ${[
|
|
660
|
-
...lineage.ancestryPlayIds,
|
|
661
|
-
input.childPlayName,
|
|
662
|
-
].join(' -> ')}`,
|
|
663
|
-
);
|
|
664
|
-
}
|
|
665
|
-
const nextDepth = lineage.callDepth + 1;
|
|
666
|
-
if (nextDepth > child.policy.budgets.maxPlayCallDepth) {
|
|
667
|
-
throw new GovernorBudgetError(
|
|
668
|
-
'playDepth',
|
|
669
|
-
nextDepth,
|
|
670
|
-
child.policy.budgets.maxPlayCallDepth,
|
|
671
|
-
);
|
|
672
|
-
}
|
|
673
|
-
const nextParent =
|
|
674
|
-
(lineage.parentChildCalls[lineage.currentPlayId] ?? 0) + 1;
|
|
675
|
-
if (nextParent > child.policy.budgets.maxChildPlayCallsPerParent) {
|
|
676
|
-
throw new GovernorBudgetError(
|
|
677
|
-
'childPerParent',
|
|
678
|
-
nextParent,
|
|
679
|
-
child.policy.budgets.maxChildPlayCallsPerParent,
|
|
680
|
-
);
|
|
681
|
-
}
|
|
682
|
-
await root.chargeBudget('playCall');
|
|
683
|
-
await root.chargeBudget('descendant');
|
|
684
|
-
lineage.parentChildCalls[lineage.currentPlayId] = nextParent;
|
|
685
|
-
const counters = root.snapshot();
|
|
686
|
-
return {
|
|
687
|
-
rootRunId: lineage.rootRunId,
|
|
688
|
-
currentRunId: input.childRunId,
|
|
689
|
-
currentPlayId: input.childPlayName,
|
|
690
|
-
ancestryPlayIds: [...lineage.ancestryPlayIds, input.childPlayName],
|
|
691
|
-
ancestryRunIds: [...lineage.ancestryRunIds, input.childRunId],
|
|
692
|
-
callDepth: nextDepth,
|
|
693
|
-
playCallCount: counters.playCallCount,
|
|
694
|
-
toolCallCount: counters.toolCallCount,
|
|
695
|
-
retryCount: counters.retryCount,
|
|
696
|
-
descendantCount: counters.descendantCount,
|
|
697
|
-
waterfallStepExecutions: counters.waterfallStepExecutions,
|
|
698
|
-
parentChildCalls: {},
|
|
699
|
-
};
|
|
700
|
-
},
|
|
701
514
|
async forkInlineChild(input) {
|
|
702
515
|
return createInlineChildGovernor(
|
|
703
516
|
child,
|
|
@@ -711,7 +524,6 @@ function createInlineChildGovernor(
|
|
|
711
524
|
...lineage,
|
|
712
525
|
ancestryPlayIds: [...lineage.ancestryPlayIds],
|
|
713
526
|
ancestryRunIds: [...lineage.ancestryRunIds],
|
|
714
|
-
parentChildCalls: { ...lineage.parentChildCalls },
|
|
715
527
|
};
|
|
716
528
|
},
|
|
717
529
|
};
|
|
@@ -28,26 +28,18 @@ export interface ExecutionConcurrencyPolicy {
|
|
|
28
28
|
readonly rowDefault: number;
|
|
29
29
|
/** Hard ceiling for an explicit map `concurrency` value; larger is clamped. */
|
|
30
30
|
readonly rowMax: number;
|
|
31
|
-
/** Concurrently in-flight child plays (`ctx.runPlay`). Excess launches block. */
|
|
32
|
-
readonly childPlay: number;
|
|
33
31
|
/** Global backstop on concurrently in-flight tool calls across all providers. */
|
|
34
32
|
readonly toolCalls: number;
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
/**
|
|
38
36
|
* Per-run budgets — total attempts allowed before a run is treated as runaway.
|
|
39
|
-
*
|
|
40
|
-
*
|
|
37
|
+
* Applied inside one run. Inline `ctx.runPlay` composition has a separate
|
|
38
|
+
* recursion-depth guard; it never creates a second scheduled run.
|
|
41
39
|
*/
|
|
42
40
|
export interface ExecutionBudgetPolicy {
|
|
43
41
|
/** Max nesting depth of `ctx.runPlay` chains. Deeper is almost certainly a cycle. */
|
|
44
42
|
readonly maxPlayCallDepth: number;
|
|
45
|
-
/** Max total `ctx.runPlay` calls along a lineage. */
|
|
46
|
-
readonly maxPlayCallCount: number;
|
|
47
|
-
/** Max direct child plays one play may launch. */
|
|
48
|
-
readonly maxChildPlayCallsPerParent: number;
|
|
49
|
-
/** Max nested-play descendants created during a run. */
|
|
50
|
-
readonly maxDescendants: number;
|
|
51
43
|
/** Max total tool calls in a run. */
|
|
52
44
|
readonly maxToolCallCount: number;
|
|
53
45
|
/** Max total retries across all steps/tools. */
|
|
@@ -99,10 +91,6 @@ export const SHARED_EXECUTION_POLICY: ResolvedExecutionPolicy = {
|
|
|
99
91
|
// matches the default: throughput grows through provider pacing/batching,
|
|
100
92
|
// while row payload size can only reduce admission through the byte budget.
|
|
101
93
|
rowMax: 1_000,
|
|
102
|
-
// Concurrent child-play launches. Generous; each child is a real launch, so
|
|
103
|
-
// this is the one value most likely to need a documented esm_workers
|
|
104
|
-
// override if isolate pressure shows up in E2E.
|
|
105
|
-
childPlay: 32,
|
|
106
94
|
// Global all-provider backstop. Per-provider pacing is the real limit; this
|
|
107
95
|
// just stops a single run from opening an absurd number of sockets at once.
|
|
108
96
|
toolCalls: 256,
|
|
@@ -111,9 +99,6 @@ export const SHARED_EXECUTION_POLICY: ResolvedExecutionPolicy = {
|
|
|
111
99
|
// Runaway guards, not workload limits. A 5,000-row map calling several tools
|
|
112
100
|
// per row is normal and must fit comfortably under these.
|
|
113
101
|
maxPlayCallDepth: 8,
|
|
114
|
-
maxPlayCallCount: 100_000,
|
|
115
|
-
maxChildPlayCallsPerParent: 100_000,
|
|
116
|
-
maxDescendants: 100_000,
|
|
117
102
|
maxToolCallCount: 5_000_000,
|
|
118
103
|
maxRetryCount: 100_000,
|
|
119
104
|
maxWaterfallStepExecutions: 5_000_000,
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* ctx.runPlay is inline function composition. The static analyser still
|
|
3
|
+
* recognizes the historical `child-workflow` spelling so preflight can return
|
|
4
|
+
* CTX_RUN_PLAY_INLINE_ONLY, but it is no longer a supported runtime option.
|
|
5
|
+
*/
|
|
6
|
+
export type PlayCallExecution = 'inline';
|
|
@@ -129,6 +129,34 @@ export const PLAY_LATENCY_SUMMARY_COLUMNS: PlayLatencyPhaseDefinition[] = [
|
|
|
129
129
|
description:
|
|
130
130
|
'Start route Runtime Sheet Data Plane readiness check; active tenants use the cached or record fast path, new tenants may provision here.',
|
|
131
131
|
},
|
|
132
|
+
{
|
|
133
|
+
header: 'ready_plane',
|
|
134
|
+
phase: 'server.runtime_data_plane_ensure_plane',
|
|
135
|
+
source: 'server',
|
|
136
|
+
description:
|
|
137
|
+
'Runtime Sheet readiness control-plane record lookup or first-workspace provisioning.',
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
header: 'ready_markers',
|
|
141
|
+
phase: 'server.runtime_data_plane_read_markers',
|
|
142
|
+
source: 'server',
|
|
143
|
+
description:
|
|
144
|
+
'Single pooled tenant-Postgres read of the storage-contract fingerprint and runtime migration version.',
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
header: 'ready_repair',
|
|
148
|
+
phase: 'server.runtime_data_plane_repair_contract',
|
|
149
|
+
source: 'server',
|
|
150
|
+
description:
|
|
151
|
+
'Exceptional stale storage-contract repair; absent from the healthy path.',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
header: 'ready_migrate',
|
|
155
|
+
phase: 'server.runtime_data_plane_migrate',
|
|
156
|
+
source: 'server',
|
|
157
|
+
description:
|
|
158
|
+
'Exceptional stale Runtime Sheet migration; absent from the healthy path.',
|
|
159
|
+
},
|
|
132
160
|
{
|
|
133
161
|
header: 'route_wait',
|
|
134
162
|
phase: 'server.start_route_wait_completion',
|
|
@@ -3,10 +3,7 @@ import {
|
|
|
3
3
|
type RuntimeExecutionCapability,
|
|
4
4
|
} from './execution-capabilities';
|
|
5
5
|
|
|
6
|
-
export type RunExecutionPlacementKind =
|
|
7
|
-
| 'root'
|
|
8
|
-
| 'inline_child'
|
|
9
|
-
| 'scheduled_child';
|
|
6
|
+
export type RunExecutionPlacementKind = 'root' | 'inline_child';
|
|
10
7
|
|
|
11
8
|
export type RunExecutionAuthorityInput = {
|
|
12
9
|
readonly orgId: string;
|
|
@@ -59,21 +56,12 @@ export type RootRunExecutionScopeInput = {
|
|
|
59
56
|
readonly authority: RunExecutionAuthorityInput;
|
|
60
57
|
};
|
|
61
58
|
|
|
62
|
-
export type ChildRunExecutionScopeInput =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
| {
|
|
70
|
-
readonly placement: 'scheduled';
|
|
71
|
-
readonly runId: string;
|
|
72
|
-
readonly playId: string;
|
|
73
|
-
readonly attempt: number;
|
|
74
|
-
readonly receiptNamespace: string;
|
|
75
|
-
readonly authority?: Partial<Omit<RunExecutionAuthorityInput, 'orgId'>>;
|
|
76
|
-
};
|
|
59
|
+
export type ChildRunExecutionScopeInput = {
|
|
60
|
+
readonly placement: 'inline';
|
|
61
|
+
readonly runId: string;
|
|
62
|
+
readonly playId: string;
|
|
63
|
+
readonly receiptNamespace: string;
|
|
64
|
+
};
|
|
77
65
|
|
|
78
66
|
function requireIdentity(value: string, field: string): string {
|
|
79
67
|
if (
|
|
@@ -203,54 +191,18 @@ export function deriveChildRunExecutionScope(
|
|
|
203
191
|
rootPlayId: parent.logical.rootPlayId,
|
|
204
192
|
};
|
|
205
193
|
|
|
206
|
-
if (input.placement === 'inline') {
|
|
207
|
-
return freezeScope({
|
|
208
|
-
logical,
|
|
209
|
-
receipt: {
|
|
210
|
-
ownerRunId: parent.receipt.ownerRunId,
|
|
211
|
-
ownerAttempt: parent.receipt.ownerAttempt,
|
|
212
|
-
namespace,
|
|
213
|
-
},
|
|
214
|
-
placement: {
|
|
215
|
-
kind: 'inline_child',
|
|
216
|
-
executorRunId: parent.placement.executorRunId,
|
|
217
|
-
executorPlayId: parent.placement.executorPlayId,
|
|
218
|
-
},
|
|
219
|
-
authority: parent.authority,
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
const attempt = requireAttempt(input.attempt, 'attempt');
|
|
224
194
|
return freezeScope({
|
|
225
195
|
logical,
|
|
226
|
-
receipt: {
|
|
196
|
+
receipt: {
|
|
197
|
+
ownerRunId: parent.receipt.ownerRunId,
|
|
198
|
+
ownerAttempt: parent.receipt.ownerAttempt,
|
|
199
|
+
namespace,
|
|
200
|
+
},
|
|
227
201
|
placement: {
|
|
228
|
-
kind: '
|
|
229
|
-
executorRunId:
|
|
230
|
-
executorPlayId:
|
|
202
|
+
kind: 'inline_child',
|
|
203
|
+
executorRunId: parent.placement.executorRunId,
|
|
204
|
+
executorPlayId: parent.placement.executorPlayId,
|
|
231
205
|
},
|
|
232
|
-
authority:
|
|
233
|
-
runId,
|
|
234
|
-
playId,
|
|
235
|
-
orgId: parent.authority.orgId,
|
|
236
|
-
authority: {
|
|
237
|
-
workflowId: input.authority?.workflowId,
|
|
238
|
-
billingRunId:
|
|
239
|
-
input.authority?.billingRunId === undefined
|
|
240
|
-
? parent.authority.billingRunId
|
|
241
|
-
: input.authority.billingRunId,
|
|
242
|
-
maxCreditsPerRun:
|
|
243
|
-
input.authority?.maxCreditsPerRun === undefined
|
|
244
|
-
? parent.authority.maxCreditsPerRun
|
|
245
|
-
: input.authority.maxCreditsPerRun,
|
|
246
|
-
integrationMode:
|
|
247
|
-
input.authority?.integrationMode === undefined
|
|
248
|
-
? parent.authority.integrationMode
|
|
249
|
-
: input.authority.integrationMode,
|
|
250
|
-
synthetic: input.authority?.synthetic ?? parent.authority.synthetic,
|
|
251
|
-
capabilities:
|
|
252
|
-
input.authority?.capabilities ?? parent.authority.capabilities,
|
|
253
|
-
},
|
|
254
|
-
}),
|
|
206
|
+
authority: parent.authority,
|
|
255
207
|
});
|
|
256
208
|
}
|