deepline 0.1.212 → 0.1.214
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/entry.ts +167 -329
- package/dist/bundling-sources/sdk/src/client.ts +2 -2
- package/dist/bundling-sources/sdk/src/index.ts +2 -0
- package/dist/bundling-sources/sdk/src/play.ts +8 -1
- package/dist/bundling-sources/sdk/src/plays/harness-stub.ts +11 -1
- package/dist/bundling-sources/sdk/src/release.ts +2 -2
- package/dist/bundling-sources/sdk/src/types.ts +3 -3
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +49 -0
- package/dist/bundling-sources/shared_libs/play-runtime/child-execution-placement.ts +14 -0
- package/dist/bundling-sources/shared_libs/play-runtime/child-execution-strategy.ts +57 -23
- package/dist/bundling-sources/shared_libs/play-runtime/completed-receipt-cache.ts +166 -0
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +209 -123
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-contract.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +30 -1
- package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +160 -2
- package/dist/bundling-sources/shared_libs/play-runtime/gateway-auth-session.ts +93 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-call-execution.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/providers.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/receipt-completion-sink.ts +16 -1
- package/dist/bundling-sources/shared_libs/play-runtime/receipt-state-sink.ts +10 -0
- package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +80 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-session-execution.ts +94 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +54 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +477 -85
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-postgres-admission.ts +162 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +2 -2
- package/dist/bundling-sources/shared_libs/play-runtime/sheet-attempt-sql.ts +16 -17
- package/dist/bundling-sources/shared_libs/play-runtime/work-receipts.ts +1 -0
- package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +2 -4
- package/dist/cli/index.js +50 -436
- package/dist/cli/index.mjs +50 -436
- package/dist/{compiler-manifest-j6z8qzpd.d.mts → compiler-manifest-BhgZ23A4.d.mts} +1 -0
- package/dist/{compiler-manifest-j6z8qzpd.d.ts → compiler-manifest-BhgZ23A4.d.ts} +1 -0
- package/dist/index.d.mts +11 -8
- package/dist/index.d.ts +11 -8
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/plays/bundle-play-file.d.mts +2 -2
- package/dist/plays/bundle-play-file.d.ts +2 -2
- package/dist/plays/bundle-play-file.mjs +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
export type RuntimePostgresLane = 'receipts' | 'sheets';
|
|
2
|
+
|
|
3
|
+
export type RuntimePostgresLaneTelemetry = {
|
|
4
|
+
active: number;
|
|
5
|
+
queued: number;
|
|
6
|
+
acquired: number;
|
|
7
|
+
waited: number;
|
|
8
|
+
timedOut: number;
|
|
9
|
+
rejected: number;
|
|
10
|
+
totalWaitMs: number;
|
|
11
|
+
maxWaitMs: number;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type RuntimePostgresAdmissionSnapshot = Record<
|
|
15
|
+
RuntimePostgresLane,
|
|
16
|
+
RuntimePostgresLaneTelemetry
|
|
17
|
+
>;
|
|
18
|
+
|
|
19
|
+
export class RuntimePostgresAdmissionTimeoutError extends Error {
|
|
20
|
+
constructor(
|
|
21
|
+
readonly lane: RuntimePostgresLane,
|
|
22
|
+
readonly queueDepth: number,
|
|
23
|
+
readonly timeoutMs: number,
|
|
24
|
+
) {
|
|
25
|
+
super(
|
|
26
|
+
`Runtime Postgres ${lane} admission timed out after ${timeoutMs}ms (${queueDepth} queued).`,
|
|
27
|
+
);
|
|
28
|
+
this.name = 'RuntimePostgresAdmissionTimeoutError';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class RuntimePostgresAdmissionQueueFullError extends Error {
|
|
33
|
+
constructor(
|
|
34
|
+
readonly lane: RuntimePostgresLane,
|
|
35
|
+
readonly queueDepth: number,
|
|
36
|
+
) {
|
|
37
|
+
super(
|
|
38
|
+
`Runtime Postgres ${lane} admission queue is full (${queueDepth} queued).`,
|
|
39
|
+
);
|
|
40
|
+
this.name = 'RuntimePostgresAdmissionQueueFullError';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
type Waiter = {
|
|
45
|
+
enqueuedAt: number;
|
|
46
|
+
timeout: ReturnType<typeof setTimeout>;
|
|
47
|
+
resolve: (release: () => void) => void;
|
|
48
|
+
reject: (error: Error) => void;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
type LaneState = RuntimePostgresLaneTelemetry & { waiters: Waiter[] };
|
|
52
|
+
|
|
53
|
+
function createLaneState(): LaneState {
|
|
54
|
+
return {
|
|
55
|
+
active: 0,
|
|
56
|
+
queued: 0,
|
|
57
|
+
acquired: 0,
|
|
58
|
+
waited: 0,
|
|
59
|
+
timedOut: 0,
|
|
60
|
+
rejected: 0,
|
|
61
|
+
totalWaitMs: 0,
|
|
62
|
+
maxWaitMs: 0,
|
|
63
|
+
waiters: [],
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class RuntimePostgresAdmission {
|
|
68
|
+
readonly #maxActivePerLane: number;
|
|
69
|
+
readonly #maxQueuedPerLane: number;
|
|
70
|
+
readonly #acquireTimeoutMs: number;
|
|
71
|
+
readonly #lanes: Record<RuntimePostgresLane, LaneState> = {
|
|
72
|
+
receipts: createLaneState(),
|
|
73
|
+
sheets: createLaneState(),
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
constructor(input: {
|
|
77
|
+
maxActivePerLane: number;
|
|
78
|
+
maxQueuedPerLane: number;
|
|
79
|
+
acquireTimeoutMs: number;
|
|
80
|
+
}) {
|
|
81
|
+
this.#maxActivePerLane = Math.max(1, Math.floor(input.maxActivePerLane));
|
|
82
|
+
this.#maxQueuedPerLane = Math.max(0, Math.floor(input.maxQueuedPerLane));
|
|
83
|
+
this.#acquireTimeoutMs = Math.max(1, Math.floor(input.acquireTimeoutMs));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async acquire(lane: RuntimePostgresLane): Promise<() => void> {
|
|
87
|
+
const state = this.#lanes[lane];
|
|
88
|
+
if (state.active < this.#maxActivePerLane && state.waiters.length === 0) {
|
|
89
|
+
state.active += 1;
|
|
90
|
+
state.acquired += 1;
|
|
91
|
+
return this.#releaseFor(lane);
|
|
92
|
+
}
|
|
93
|
+
if (state.waiters.length >= this.#maxQueuedPerLane) {
|
|
94
|
+
state.rejected += 1;
|
|
95
|
+
throw new RuntimePostgresAdmissionQueueFullError(
|
|
96
|
+
lane,
|
|
97
|
+
state.waiters.length,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
state.waited += 1;
|
|
101
|
+
return await new Promise<() => void>((resolve, reject) => {
|
|
102
|
+
const waiter: Waiter = {
|
|
103
|
+
enqueuedAt: Date.now(),
|
|
104
|
+
timeout: setTimeout(() => {
|
|
105
|
+
const index = state.waiters.indexOf(waiter);
|
|
106
|
+
if (index < 0) return;
|
|
107
|
+
state.waiters.splice(index, 1);
|
|
108
|
+
state.queued = state.waiters.length;
|
|
109
|
+
state.timedOut += 1;
|
|
110
|
+
reject(
|
|
111
|
+
new RuntimePostgresAdmissionTimeoutError(
|
|
112
|
+
lane,
|
|
113
|
+
state.waiters.length,
|
|
114
|
+
this.#acquireTimeoutMs,
|
|
115
|
+
),
|
|
116
|
+
);
|
|
117
|
+
}, this.#acquireTimeoutMs),
|
|
118
|
+
resolve,
|
|
119
|
+
reject,
|
|
120
|
+
};
|
|
121
|
+
state.waiters.push(waiter);
|
|
122
|
+
state.queued = state.waiters.length;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
snapshot(): RuntimePostgresAdmissionSnapshot {
|
|
127
|
+
const snapshotLane = (state: LaneState): RuntimePostgresLaneTelemetry => ({
|
|
128
|
+
active: state.active,
|
|
129
|
+
queued: state.waiters.length,
|
|
130
|
+
acquired: state.acquired,
|
|
131
|
+
waited: state.waited,
|
|
132
|
+
timedOut: state.timedOut,
|
|
133
|
+
rejected: state.rejected,
|
|
134
|
+
totalWaitMs: state.totalWaitMs,
|
|
135
|
+
maxWaitMs: state.maxWaitMs,
|
|
136
|
+
});
|
|
137
|
+
return {
|
|
138
|
+
receipts: snapshotLane(this.#lanes.receipts),
|
|
139
|
+
sheets: snapshotLane(this.#lanes.sheets),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
#releaseFor(lane: RuntimePostgresLane): () => void {
|
|
144
|
+
let released = false;
|
|
145
|
+
return () => {
|
|
146
|
+
if (released) return;
|
|
147
|
+
released = true;
|
|
148
|
+
const state = this.#lanes[lane];
|
|
149
|
+
state.active -= 1;
|
|
150
|
+
const waiter = state.waiters.shift();
|
|
151
|
+
state.queued = state.waiters.length;
|
|
152
|
+
if (!waiter) return;
|
|
153
|
+
clearTimeout(waiter.timeout);
|
|
154
|
+
const waitMs = Math.max(0, Date.now() - waiter.enqueuedAt);
|
|
155
|
+
state.totalWaitMs += waitMs;
|
|
156
|
+
state.maxWaitMs = Math.max(state.maxWaitMs, waitMs);
|
|
157
|
+
state.active += 1;
|
|
158
|
+
state.acquired += 1;
|
|
159
|
+
waiter.resolve(this.#releaseFor(lane));
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* One of three pluggable axes (alongside runner-backends and dedup-backends).
|
|
5
5
|
* Selected per-run via PlayExecutionProfile.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Absurd is the default production scheduler through the absurd profile.
|
|
8
|
+
* Cloudflare Workflows remains available through the workers_edge profile.
|
|
9
9
|
*
|
|
10
10
|
* Customer plays are unaffected — this is purely the orchestration layer.
|
|
11
11
|
*/
|
|
@@ -5,23 +5,14 @@ export function activeRuntimeSheetAttemptFenceSql(
|
|
|
5
5
|
attemptExpiresAtExpression: string,
|
|
6
6
|
attemptSeqExpression?: string,
|
|
7
7
|
): string {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return
|
|
16
|
-
/* owner: runtime; remove null-attempt compat after ledger cutover M1 */
|
|
17
|
-
${tableAlias}._attempt_id IS NULL
|
|
18
|
-
OR ${tableAlias}._attempt_id = ${attemptIdExpression}
|
|
19
|
-
OR ${tableAlias}._attempt_expires_at <= now()
|
|
20
|
-
OR (
|
|
21
|
-
coalesce(${tableAlias}._attempt_owner_run_id, ${tableAlias}._run_id) = ${attemptOwnerRunIdExpression}
|
|
22
|
-
AND ${activeSameOwnerNewerAttempt}
|
|
23
|
-
)
|
|
24
|
-
)`;
|
|
8
|
+
void tableAlias;
|
|
9
|
+
void attemptIdExpression;
|
|
10
|
+
void attemptOwnerRunIdExpression;
|
|
11
|
+
void attemptExpiresAtExpression;
|
|
12
|
+
void attemptSeqExpression;
|
|
13
|
+
// Legacy attempt columns remain during the rolling migration only. They are
|
|
14
|
+
// not row admission or correctness state; schedule-time write versions are.
|
|
15
|
+
return 'TRUE';
|
|
25
16
|
}
|
|
26
17
|
|
|
27
18
|
/**
|
|
@@ -68,6 +59,13 @@ export function newerTerminalRuntimeSheetRowSql(
|
|
|
68
59
|
attemptIdExpression?: string,
|
|
69
60
|
attemptOwnerRunIdExpression?: string,
|
|
70
61
|
): string {
|
|
62
|
+
void tableAlias;
|
|
63
|
+
void attemptExpiresAtExpression;
|
|
64
|
+
void attemptSeqExpression;
|
|
65
|
+
void attemptIdExpression;
|
|
66
|
+
void attemptOwnerRunIdExpression;
|
|
67
|
+
return 'FALSE';
|
|
68
|
+
/* legacy implementation intentionally unreachable during rolling cleanup
|
|
71
69
|
if (attemptSeqExpression !== undefined) {
|
|
72
70
|
const sameSeqDifferentAttemptSql = attemptOwnerRunIdExpression
|
|
73
71
|
? `OR (
|
|
@@ -100,4 +98,5 @@ export function newerTerminalRuntimeSheetRowSql(
|
|
|
100
98
|
AND ${attemptExpiresAtExpression} IS NOT NULL
|
|
101
99
|
AND ${tableAlias}._attempt_expires_at > ${attemptExpiresAtExpression}
|
|
102
100
|
)`;
|
|
101
|
+
*/
|
|
103
102
|
}
|
|
@@ -308,10 +308,7 @@ function truncateStaticSubstepsForStorage(
|
|
|
308
308
|
return truncateStaticSubstepShallowForStorage(base);
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
-
if (
|
|
312
|
-
base.type !== 'play_call' &&
|
|
313
|
-
'pipeline' in substepWithoutSourceText
|
|
314
|
-
) {
|
|
311
|
+
if (base.type !== 'play_call' && 'pipeline' in substepWithoutSourceText) {
|
|
315
312
|
const nestedPipeline = substepWithoutSourceText.pipeline;
|
|
316
313
|
(base as { pipeline?: PlayStaticPipeline | null }).pipeline =
|
|
317
314
|
nestedPipeline
|
|
@@ -588,6 +585,7 @@ export type PlayStaticSubstep = PlayStaticSubstepMetadata &
|
|
|
588
585
|
| {
|
|
589
586
|
type: 'play_call';
|
|
590
587
|
playId: string;
|
|
588
|
+
execution?: 'inline' | 'child-workflow';
|
|
591
589
|
field: string;
|
|
592
590
|
inLoop?: boolean;
|
|
593
591
|
pipeline?: PlayStaticPipeline | null;
|