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
|
@@ -2,10 +2,6 @@ export const PLAY_RUNTIME_API_COMPAT_PATH = '/api/v2/plays/internal/runtime';
|
|
|
2
2
|
export const PLAY_RUNTIME_API_CURRENT_PATH = '/api/v2/internal/play-runtime';
|
|
3
3
|
export const PLAY_RUNTIME_ATTEMPT_EXECUTOR_TOKEN_PATH =
|
|
4
4
|
'/api/v2/internal/play-runtime/executor-token';
|
|
5
|
-
export const PLAY_RUNTIME_CHILD_EXECUTOR_TOKEN_COMPAT_PATH =
|
|
6
|
-
'/api/v2/plays/internal/child-executor-token';
|
|
7
|
-
export const PLAY_RUNTIME_CHILD_EXECUTOR_TOKEN_CURRENT_PATH =
|
|
8
|
-
'/api/v2/internal/play-runtime/child-executor-token';
|
|
9
5
|
export const PLAY_RUNTIME_TAIL_LOG_COMPAT_PATH =
|
|
10
6
|
'/api/v2/plays/internal/tail-log';
|
|
11
7
|
export const PLAY_RUNTIME_TAIL_LOG_CURRENT_PATH =
|
|
@@ -371,7 +371,22 @@ export type ResolvedRuntimePlay = {
|
|
|
371
371
|
sourceCode?: string | null;
|
|
372
372
|
artifact?: PlayBundleArtifact | null;
|
|
373
373
|
codeFormat?: 'function' | 'cjs_module' | 'esm_module';
|
|
374
|
+
/**
|
|
375
|
+
* The runtime must receive the child contract with its artifact. Inline
|
|
376
|
+
* composition rejects unresolved or dataset-backed children before running
|
|
377
|
+
* their code, so dropping this field at the API boundary makes valid scalar
|
|
378
|
+
* children indistinguishable from unknown ones.
|
|
379
|
+
*/
|
|
380
|
+
staticPipeline?: PlayStaticPipeline | null;
|
|
374
381
|
contractSnapshot?: Record<string, unknown> | null;
|
|
382
|
+
/** Preview-only contract propagation evidence, emitted by the server and
|
|
383
|
+
* logged by the runner while diagnosing a cross-runtime child resolution
|
|
384
|
+
* failure. It intentionally contains no source, inputs, or credentials. */
|
|
385
|
+
resolutionDiagnostics?: {
|
|
386
|
+
serverPlayPipeline: boolean;
|
|
387
|
+
manifestPipeline: boolean;
|
|
388
|
+
responsePipeline: boolean;
|
|
389
|
+
} | null;
|
|
375
390
|
};
|
|
376
391
|
|
|
377
392
|
export type PrepareRuntimeSheetResult = {
|
|
@@ -2951,15 +2966,28 @@ export async function resolveRuntimeReferencedPlay(
|
|
|
2951
2966
|
playRef: string,
|
|
2952
2967
|
options?: { artifactKind?: PlayArtifactKind },
|
|
2953
2968
|
): Promise<ResolvedRuntimePlay | null> {
|
|
2954
|
-
const response = await postRuntimeApi<{
|
|
2955
|
-
|
|
2956
|
-
{
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
},
|
|
2961
|
-
);
|
|
2962
|
-
|
|
2969
|
+
const response = await postRuntimeApi<{
|
|
2970
|
+
play: ResolvedRuntimePlay | null;
|
|
2971
|
+
manifest?: { staticPipeline?: PlayStaticPipeline | null } | null;
|
|
2972
|
+
}>(context, {
|
|
2973
|
+
action: 'resolve_play',
|
|
2974
|
+
playRef,
|
|
2975
|
+
...(options?.artifactKind ? { artifactKind: options.artifactKind } : {}),
|
|
2976
|
+
});
|
|
2977
|
+
if (!response.play) {
|
|
2978
|
+
return null;
|
|
2979
|
+
}
|
|
2980
|
+
|
|
2981
|
+
// The server builds the manifest and child artifact together. Its manifest
|
|
2982
|
+
// carries the canonical empty scalar contract when a published scalar's
|
|
2983
|
+
// revision snapshot has no pipeline. Keep that contract on the object the
|
|
2984
|
+
// runner passes to ctx.runPlay; otherwise a valid scalar leaf arrives as an
|
|
2985
|
+
// indistinguishable "missing static contract" at runtime.
|
|
2986
|
+
return {
|
|
2987
|
+
...response.play,
|
|
2988
|
+
staticPipeline:
|
|
2989
|
+
response.play.staticPipeline ?? response.manifest?.staticPipeline ?? null,
|
|
2990
|
+
};
|
|
2963
2991
|
}
|
|
2964
2992
|
|
|
2965
2993
|
export async function ensureRuntimeSheet(
|
|
@@ -17,7 +17,6 @@ import type {
|
|
|
17
17
|
PlayRowUpdate,
|
|
18
18
|
} from './ctx-types';
|
|
19
19
|
import type { ExecutionPlan } from './execution-plan';
|
|
20
|
-
import type { PlayRuntimeManifestMap } from '../plays/compiler-manifest';
|
|
21
20
|
import type { PreloadedRuntimeDbSession } from './db-session';
|
|
22
21
|
import type { RuntimeAuthorityDescriptor } from './execution-capabilities';
|
|
23
22
|
import type { PlayRunnerRuntimeTiming } from './protocol';
|
|
@@ -42,39 +41,6 @@ export type PlaySchedulerBackendId =
|
|
|
42
41
|
|
|
43
42
|
export type { PlayRunInputPayload };
|
|
44
43
|
|
|
45
|
-
export type PlayCallGovernanceSnapshot = {
|
|
46
|
-
rootRunId: string;
|
|
47
|
-
parentRunId: string;
|
|
48
|
-
parentPlayName: string;
|
|
49
|
-
key: string;
|
|
50
|
-
ancestryPlayIds: string[];
|
|
51
|
-
callDepth: number;
|
|
52
|
-
/**
|
|
53
|
-
* Cumulative lineage-global budget counters consumed by ancestors at the
|
|
54
|
-
* moment this child was launched. The child seeds its own counters from these
|
|
55
|
-
* so the corresponding budgets (`maxPlayCallCount`, `maxToolCallCount`,
|
|
56
|
-
* `maxRetryCount`, `maxDescendants`, `maxWaterfallStepExecutions`) accumulate
|
|
57
|
-
* down the dispatch lineage instead of resetting to 0 in each worker isolate —
|
|
58
|
-
* matching the cjs forkChild path, which threads all of them. The Governor
|
|
59
|
-
* documents these budgets as global across the nested-play tree, not
|
|
60
|
-
* per-worker (see policy.ts / rate-state-backend.ts); threading them here is
|
|
61
|
-
* what makes that true on `esm_workers`.
|
|
62
|
-
*
|
|
63
|
-
* `descendantCount` is load-bearing for fan-out: forkChild charges
|
|
64
|
-
* `descendant` on every child launch, so without threading it a deep/wide tree
|
|
65
|
-
* would reset descendant accounting at each isolate and never converge on the
|
|
66
|
-
* lineage-global cap.
|
|
67
|
-
*
|
|
68
|
-
* All optional and fail-safe: if absent (older callers / dropped in transit)
|
|
69
|
-
* the child falls back to 0, i.e. prior behavior.
|
|
70
|
-
*/
|
|
71
|
-
playCallCount?: number;
|
|
72
|
-
toolCallCount?: number;
|
|
73
|
-
retryCount?: number;
|
|
74
|
-
descendantCount?: number;
|
|
75
|
-
waterfallStepExecutions?: number;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
44
|
export type PlaySchedulerSubmitInput = {
|
|
79
45
|
runId: string;
|
|
80
46
|
playId: string;
|
|
@@ -122,8 +88,6 @@ export type PlaySchedulerSubmitInput = {
|
|
|
122
88
|
}> | null;
|
|
123
89
|
contractSnapshot?: unknown;
|
|
124
90
|
executionPlan?: ExecutionPlan | null;
|
|
125
|
-
childPlayManifests?: PlayRuntimeManifestMap | null;
|
|
126
|
-
playCallGovernance?: PlayCallGovernanceSnapshot | null;
|
|
127
91
|
preloadedDbSessions?: PreloadedRuntimeDbSession[] | null;
|
|
128
92
|
/**
|
|
129
93
|
* Secret that decrypts `preloadedDbSessions` postgres URLs. Equals the run's
|
|
@@ -18,20 +18,6 @@ export type PlayExecutionSuspension =
|
|
|
18
18
|
timeoutMs: number;
|
|
19
19
|
}>;
|
|
20
20
|
}
|
|
21
|
-
| {
|
|
22
|
-
kind: 'child_play';
|
|
23
|
-
boundaryId: string;
|
|
24
|
-
childRunId: string;
|
|
25
|
-
childPlayName: string;
|
|
26
|
-
}
|
|
27
|
-
| {
|
|
28
|
-
kind: 'child_play_batch';
|
|
29
|
-
boundaries: Array<{
|
|
30
|
-
boundaryId: string;
|
|
31
|
-
childRunId: string;
|
|
32
|
-
childPlayName: string;
|
|
33
|
-
}>;
|
|
34
|
-
}
|
|
35
21
|
| {
|
|
36
22
|
/**
|
|
37
23
|
* Push-execution park (B2-final): the Daytona runner command was started
|
|
@@ -72,13 +58,9 @@ export class PlayExecutionSuspendedError extends Error {
|
|
|
72
58
|
? `Play execution suspended for durable sleep (${suspension.delayMs}ms).`
|
|
73
59
|
: suspension.kind === 'integration_event_batch'
|
|
74
60
|
? `Play execution suspended waiting for ${suspension.boundaries.length} integration events.`
|
|
75
|
-
: suspension.kind === '
|
|
76
|
-
? `Play execution
|
|
77
|
-
: suspension.
|
|
78
|
-
? `Play execution suspended waiting for child play ${JSON.stringify(suspension.childPlayName)}.`
|
|
79
|
-
: suspension.kind === 'detached_runner'
|
|
80
|
-
? `Play execution parked on detached runner ${suspension.cmdId} (sandbox ${suspension.sandboxId}).`
|
|
81
|
-
: `Play execution suspended waiting for integration event ${JSON.stringify(suspension.eventKey)}.`,
|
|
61
|
+
: suspension.kind === 'detached_runner'
|
|
62
|
+
? `Play execution parked on detached runner ${suspension.cmdId} (sandbox ${suspension.sandboxId}).`
|
|
63
|
+
: `Play execution suspended waiting for integration event ${JSON.stringify(suspension.eventKey)}.`,
|
|
82
64
|
);
|
|
83
65
|
this.name = 'PlayExecutionSuspendedError';
|
|
84
66
|
this.suspension = suspension;
|
|
@@ -5,7 +5,14 @@ export const PLAY_RUNTIME_TEST_FAULT_HEADER = 'x-deepline-test-fault';
|
|
|
5
5
|
export type RuntimeTestFaultName =
|
|
6
6
|
| 'receipt_complete_write_fail'
|
|
7
7
|
| 'receipt_fail_write_fail'
|
|
8
|
-
| 'worker_receipt_complete_write_fail'
|
|
8
|
+
| 'worker_receipt_complete_write_fail'
|
|
9
|
+
/**
|
|
10
|
+
* Holds an already checked-out receipt-gateway scheduler client for the
|
|
11
|
+
* supplied bounded millisecond value. Preview/CI only: this creates a
|
|
12
|
+
* deterministic real-Pg-pool pressure window without changing an action's
|
|
13
|
+
* SQL or outcome.
|
|
14
|
+
*/
|
|
15
|
+
| 'receipt_gateway_hold_ms';
|
|
9
16
|
|
|
10
17
|
export type RuntimeTestFaultRegistry = {
|
|
11
18
|
consume(name: RuntimeTestFaultName): boolean;
|
|
@@ -63,6 +70,7 @@ const SUPPORTED_RUNTIME_TEST_FAULTS = new Set<RuntimeTestFaultName>([
|
|
|
63
70
|
'receipt_complete_write_fail',
|
|
64
71
|
'receipt_fail_write_fail',
|
|
65
72
|
'worker_receipt_complete_write_fail',
|
|
73
|
+
'receipt_gateway_hold_ms',
|
|
66
74
|
]);
|
|
67
75
|
|
|
68
76
|
const RUNTIME_TEST_POLICY_MS_FIELDS = new Set([
|
|
@@ -586,6 +586,8 @@ export type PlayStaticSubstep = PlayStaticSubstepMetadata &
|
|
|
586
586
|
type: 'play_call';
|
|
587
587
|
playId: string;
|
|
588
588
|
execution?: 'inline' | 'child-workflow';
|
|
589
|
+
timeoutMs?: number;
|
|
590
|
+
hasExplicitTimeout?: boolean;
|
|
589
591
|
field: string;
|
|
590
592
|
inLoop?: boolean;
|
|
591
593
|
pipeline?: PlayStaticPipeline | null;
|
package/dist/cli/index.js
CHANGED
|
@@ -625,10 +625,10 @@ var SDK_RELEASE = {
|
|
|
625
625
|
// 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
|
|
626
626
|
// 0.1.220 deprecates SDK CLI versions below 0.1.219 and updates them
|
|
627
627
|
// automatically without blocking their current command.
|
|
628
|
-
version: "0.1.
|
|
628
|
+
version: "0.1.229",
|
|
629
629
|
apiContract: "2026-06-dataset-handle-results-hard-cutover",
|
|
630
630
|
supportPolicy: {
|
|
631
|
-
latest: "0.1.
|
|
631
|
+
latest: "0.1.229",
|
|
632
632
|
minimumSupported: "0.1.53",
|
|
633
633
|
deprecatedBelow: "0.1.219",
|
|
634
634
|
commandMinimumSupported: [
|
package/dist/cli/index.mjs
CHANGED
|
@@ -610,10 +610,10 @@ var SDK_RELEASE = {
|
|
|
610
610
|
// 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
|
|
611
611
|
// 0.1.220 deprecates SDK CLI versions below 0.1.219 and updates them
|
|
612
612
|
// automatically without blocking their current command.
|
|
613
|
-
version: "0.1.
|
|
613
|
+
version: "0.1.229",
|
|
614
614
|
apiContract: "2026-06-dataset-handle-results-hard-cutover",
|
|
615
615
|
supportPolicy: {
|
|
616
|
-
latest: "0.1.
|
|
616
|
+
latest: "0.1.229",
|
|
617
617
|
minimumSupported: "0.1.53",
|
|
618
618
|
deprecatedBelow: "0.1.219",
|
|
619
619
|
commandMinimumSupported: [
|
|
@@ -182,6 +182,8 @@ type PlayStaticSubstep = PlayStaticSubstepMetadata & ({
|
|
|
182
182
|
type: 'play_call';
|
|
183
183
|
playId: string;
|
|
184
184
|
execution?: 'inline' | 'child-workflow';
|
|
185
|
+
timeoutMs?: number;
|
|
186
|
+
hasExplicitTimeout?: boolean;
|
|
185
187
|
field: string;
|
|
186
188
|
inLoop?: boolean;
|
|
187
189
|
pipeline?: PlayStaticPipeline | null;
|
|
@@ -182,6 +182,8 @@ type PlayStaticSubstep = PlayStaticSubstepMetadata & ({
|
|
|
182
182
|
type: 'play_call';
|
|
183
183
|
playId: string;
|
|
184
184
|
execution?: 'inline' | 'child-workflow';
|
|
185
|
+
timeoutMs?: number;
|
|
186
|
+
hasExplicitTimeout?: boolean;
|
|
185
187
|
field: string;
|
|
186
188
|
inLoop?: boolean;
|
|
187
189
|
pipeline?: PlayStaticPipeline | null;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as PlayCompilerManifest } from './compiler-manifest-
|
|
1
|
+
import { a as PlayCompilerManifest } from './compiler-manifest-CYcwzSOJ.mjs';
|
|
2
2
|
|
|
3
3
|
declare const DEEPLINE_TOOL_CATEGORIES: readonly ["company_search", "people_search", "people_enrich", "email_finder", "email_verify", "phone_finder", "phone_verify", "identity_resolution", "reverse_lookup", "enrichment", "batch", "premium", "free"];
|
|
4
4
|
type DeeplineToolCategory = (typeof DEEPLINE_TOOL_CATEGORIES)[number] | (string & {});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as PlayCompilerManifest } from './compiler-manifest-
|
|
1
|
+
import { a as PlayCompilerManifest } from './compiler-manifest-CYcwzSOJ.js';
|
|
2
2
|
|
|
3
3
|
declare const DEEPLINE_TOOL_CATEGORIES: readonly ["company_search", "people_search", "people_enrich", "email_finder", "email_verify", "phone_finder", "phone_verify", "identity_resolution", "reverse_lookup", "enrichment", "batch", "premium", "free"];
|
|
4
4
|
type DeeplineToolCategory = (typeof DEEPLINE_TOOL_CATEGORIES)[number] | (string & {});
|
package/dist/index.js
CHANGED
|
@@ -424,10 +424,10 @@ var SDK_RELEASE = {
|
|
|
424
424
|
// 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
|
|
425
425
|
// 0.1.220 deprecates SDK CLI versions below 0.1.219 and updates them
|
|
426
426
|
// automatically without blocking their current command.
|
|
427
|
-
version: "0.1.
|
|
427
|
+
version: "0.1.229",
|
|
428
428
|
apiContract: "2026-06-dataset-handle-results-hard-cutover",
|
|
429
429
|
supportPolicy: {
|
|
430
|
-
latest: "0.1.
|
|
430
|
+
latest: "0.1.229",
|
|
431
431
|
minimumSupported: "0.1.53",
|
|
432
432
|
deprecatedBelow: "0.1.219",
|
|
433
433
|
commandMinimumSupported: [
|
package/dist/index.mjs
CHANGED
|
@@ -354,10 +354,10 @@ var SDK_RELEASE = {
|
|
|
354
354
|
// 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
|
|
355
355
|
// 0.1.220 deprecates SDK CLI versions below 0.1.219 and updates them
|
|
356
356
|
// automatically without blocking their current command.
|
|
357
|
-
version: "0.1.
|
|
357
|
+
version: "0.1.229",
|
|
358
358
|
apiContract: "2026-06-dataset-handle-results-hard-cutover",
|
|
359
359
|
supportPolicy: {
|
|
360
|
-
latest: "0.1.
|
|
360
|
+
latest: "0.1.229",
|
|
361
361
|
minimumSupported: "0.1.53",
|
|
362
362
|
deprecatedBelow: "0.1.219",
|
|
363
363
|
commandMinimumSupported: [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PlayArtifactKind$1, a as PlayCompilerManifest } from '../compiler-manifest-
|
|
2
|
-
export { b as PLAY_ARTIFACT_KINDS } from '../compiler-manifest-
|
|
1
|
+
import { P as PlayArtifactKind$1, a as PlayCompilerManifest } from '../compiler-manifest-CYcwzSOJ.mjs';
|
|
2
|
+
export { b as PLAY_ARTIFACT_KINDS } from '../compiler-manifest-CYcwzSOJ.mjs';
|
|
3
3
|
|
|
4
4
|
type PlayPackageImport = {
|
|
5
5
|
name: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PlayArtifactKind$1, a as PlayCompilerManifest } from '../compiler-manifest-
|
|
2
|
-
export { b as PLAY_ARTIFACT_KINDS } from '../compiler-manifest-
|
|
1
|
+
import { P as PlayArtifactKind$1, a as PlayCompilerManifest } from '../compiler-manifest-CYcwzSOJ.js';
|
|
2
|
+
export { b as PLAY_ARTIFACT_KINDS } from '../compiler-manifest-CYcwzSOJ.js';
|
|
3
3
|
|
|
4
4
|
type PlayPackageImport = {
|
|
5
5
|
name: string;
|
package/package.json
CHANGED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
PlayRuntimeManifest,
|
|
3
|
-
PlayRuntimeManifestMap,
|
|
4
|
-
} from '../../../shared_libs/plays/compiler-manifest';
|
|
5
|
-
import { createSingleFlight } from '../../../shared_libs/play-runtime/single-flight';
|
|
6
|
-
|
|
7
|
-
type ChildManifestResolverInput = {
|
|
8
|
-
preloaded?: PlayRuntimeManifestMap | null;
|
|
9
|
-
resolveManifest: (playRef: string) => Promise<PlayRuntimeManifest | null>;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
type ChildManifestResolutionState = {
|
|
13
|
-
resolved: Map<string, PlayRuntimeManifest>;
|
|
14
|
-
flights: ReturnType<
|
|
15
|
-
typeof createSingleFlight<string, PlayRuntimeManifest | null>
|
|
16
|
-
>;
|
|
17
|
-
lastAccessedAt: number;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const RUN_RESOLUTION_CACHE_TTL_MS = 10 * 60_000;
|
|
21
|
-
const RUN_RESOLUTION_CACHE_MAX_ENTRIES = 128;
|
|
22
|
-
const runResolutionStates = new Map<string, ChildManifestResolutionState>();
|
|
23
|
-
|
|
24
|
-
function seedPreloadedManifests(
|
|
25
|
-
resolved: Map<string, PlayRuntimeManifest>,
|
|
26
|
-
preloaded?: PlayRuntimeManifestMap | null,
|
|
27
|
-
): void {
|
|
28
|
-
for (const [playRef, manifest] of Object.entries(preloaded ?? {})) {
|
|
29
|
-
resolved.set(playRef, manifest);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function createResolutionState(
|
|
34
|
-
preloaded?: PlayRuntimeManifestMap | null,
|
|
35
|
-
): ChildManifestResolutionState {
|
|
36
|
-
const resolved = new Map<string, PlayRuntimeManifest>(
|
|
37
|
-
Object.entries(preloaded ?? {}),
|
|
38
|
-
);
|
|
39
|
-
return {
|
|
40
|
-
resolved,
|
|
41
|
-
flights: createSingleFlight<string, PlayRuntimeManifest | null>(),
|
|
42
|
-
lastAccessedAt: Date.now(),
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function resolveWithState(
|
|
47
|
-
state: ChildManifestResolutionState,
|
|
48
|
-
input: ChildManifestResolverInput,
|
|
49
|
-
playRef: string,
|
|
50
|
-
): Promise<PlayRuntimeManifest | null> {
|
|
51
|
-
state.lastAccessedAt = Date.now();
|
|
52
|
-
seedPreloadedManifests(state.resolved, input.preloaded);
|
|
53
|
-
const cached = state.resolved.get(playRef);
|
|
54
|
-
if (cached) return Promise.resolve(cached);
|
|
55
|
-
|
|
56
|
-
return state.flights.run(playRef, async () => {
|
|
57
|
-
const cachedAfterAdmission = state.resolved.get(playRef);
|
|
58
|
-
if (cachedAfterAdmission) return cachedAfterAdmission;
|
|
59
|
-
|
|
60
|
-
const manifest = await input.resolveManifest(playRef);
|
|
61
|
-
if (manifest) state.resolved.set(playRef, manifest);
|
|
62
|
-
return manifest;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function pruneRunResolutionStates(now: number): void {
|
|
67
|
-
for (const [scopeKey, state] of runResolutionStates) {
|
|
68
|
-
if (
|
|
69
|
-
state.flights.activeCount() === 0 &&
|
|
70
|
-
now - state.lastAccessedAt >= RUN_RESOLUTION_CACHE_TTL_MS
|
|
71
|
-
) {
|
|
72
|
-
runResolutionStates.delete(scopeKey);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (runResolutionStates.size <= RUN_RESOLUTION_CACHE_MAX_ENTRIES) return;
|
|
76
|
-
|
|
77
|
-
const evictable = [...runResolutionStates.entries()]
|
|
78
|
-
.filter(([, state]) => state.flights.activeCount() === 0)
|
|
79
|
-
.sort((a, b) => a[1].lastAccessedAt - b[1].lastAccessedAt);
|
|
80
|
-
for (const [scopeKey] of evictable) {
|
|
81
|
-
if (runResolutionStates.size <= RUN_RESOLUTION_CACHE_MAX_ENTRIES) break;
|
|
82
|
-
runResolutionStates.delete(scopeKey);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export function createChildManifestResolver(
|
|
87
|
-
input: ChildManifestResolverInput,
|
|
88
|
-
): (playRef: string) => Promise<PlayRuntimeManifest | null> {
|
|
89
|
-
const state = createResolutionState(input.preloaded);
|
|
90
|
-
|
|
91
|
-
return (playRef) => resolveWithState(state, input, playRef);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export function createRunScopedChildManifestResolver(
|
|
95
|
-
input: ChildManifestResolverInput & { scopeKey: string },
|
|
96
|
-
): (playRef: string) => Promise<PlayRuntimeManifest | null> {
|
|
97
|
-
const now = Date.now();
|
|
98
|
-
pruneRunResolutionStates(now);
|
|
99
|
-
let state = runResolutionStates.get(input.scopeKey);
|
|
100
|
-
if (!state) {
|
|
101
|
-
state = createResolutionState(input.preloaded);
|
|
102
|
-
runResolutionStates.set(input.scopeKey, state);
|
|
103
|
-
pruneRunResolutionStates(now);
|
|
104
|
-
}
|
|
105
|
-
state.lastAccessedAt = now;
|
|
106
|
-
|
|
107
|
-
return (playRef) => resolveWithState(state, input, playRef);
|
|
108
|
-
}
|