deepline 0.1.243 → 0.1.245

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.
Files changed (71) hide show
  1. package/README.md +1 -1
  2. package/dist/bundling-sources/sdk/src/plays/bundle-play-file.ts +5 -25
  3. package/dist/bundling-sources/sdk/src/release.ts +25 -26
  4. package/dist/bundling-sources/sdk/src/types.ts +1 -1
  5. package/dist/bundling-sources/shared_libs/play-runtime/backend.ts +2 -21
  6. package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +5 -6
  7. package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +6 -13
  8. package/dist/bundling-sources/shared_libs/play-runtime/governor/rate-state-backend.ts +9 -26
  9. package/dist/bundling-sources/shared_libs/play-runtime/internal-step-ids.ts +1 -2
  10. package/dist/bundling-sources/shared_libs/play-runtime/map-row-identity.ts +1 -1
  11. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +191 -29
  12. package/dist/bundling-sources/shared_libs/play-runtime/play-latency-trace.ts +1 -1
  13. package/dist/bundling-sources/shared_libs/play-runtime/providers.ts +1 -36
  14. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +2 -3
  15. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/index.ts +0 -7
  16. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +1 -12
  17. package/dist/bundling-sources/shared_libs/play-runtime/runtime-pg-driver-pg.ts +2 -3
  18. package/dist/bundling-sources/shared_libs/play-runtime/runtime-pg-driver.ts +5 -15
  19. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +6 -21
  20. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +3 -4
  21. package/dist/bundling-sources/shared_libs/plays/artifact-kind-guard.ts +16 -29
  22. package/dist/bundling-sources/shared_libs/plays/artifact-types.ts +4 -8
  23. package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +21 -712
  24. package/dist/bundling-sources/shared_libs/plays/bundling/limits.ts +1 -18
  25. package/dist/cli/index.js +28 -71
  26. package/dist/cli/index.mjs +28 -71
  27. package/dist/{compiler-manifest-CYcwzSOJ.d.ts → compiler-manifest-DlE7dnRm.d.mts} +2 -8
  28. package/dist/{compiler-manifest-CYcwzSOJ.d.mts → compiler-manifest-DlE7dnRm.d.ts} +2 -8
  29. package/dist/index.d.mts +2 -2
  30. package/dist/index.d.ts +2 -2
  31. package/dist/index.js +23 -22
  32. package/dist/index.mjs +23 -22
  33. package/dist/plays/bundle-play-file.d.mts +7 -22
  34. package/dist/plays/bundle-play-file.d.ts +7 -22
  35. package/dist/plays/bundle-play-file.mjs +26 -614
  36. package/package.json +2 -2
  37. package/dist/bundling-sources/apps/play-runner-workers/src/coordinator-entry.ts +0 -4504
  38. package/dist/bundling-sources/apps/play-runner-workers/src/dedup-do.ts +0 -1386
  39. package/dist/bundling-sources/apps/play-runner-workers/src/durable-object-deploy-handoff.ts +0 -30
  40. package/dist/bundling-sources/apps/play-runner-workers/src/entry.ts +0 -8385
  41. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/README.md +0 -21
  42. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/batching.ts +0 -251
  43. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/coordinator-progress.ts +0 -289
  44. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/csv-rows.ts +0 -85
  45. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/customer-console.ts +0 -23
  46. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/dataset-handles.ts +0 -528
  47. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/harness-receipt-store.ts +0 -229
  48. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/ledger-event-batches.ts +0 -81
  49. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/live-progress.ts +0 -22
  50. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/map-chunk-plan.ts +0 -920
  51. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/map-latency-profile.ts +0 -90
  52. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/output-datasets.ts +0 -475
  53. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/receipts.ts +0 -570
  54. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/result-dataset-persistence.ts +0 -50
  55. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/row-isolation.ts +0 -5
  56. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/run-work-dispatcher.ts +0 -519
  57. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/tool-batch.ts +0 -107
  58. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/tool-dispatch.ts +0 -2541
  59. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/tool-http-errors.ts +0 -7
  60. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/tool-receipts.ts +0 -227
  61. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/work-budget.ts +0 -130
  62. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/worker-platform-budget.ts +0 -39
  63. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/workflow-preview.ts +0 -26
  64. package/dist/bundling-sources/apps/play-runner-workers/src/runtime-api-retry.ts +0 -23
  65. package/dist/bundling-sources/apps/play-runner-workers/src/workflow-instance-create.ts +0 -47
  66. package/dist/bundling-sources/apps/play-runner-workers/src/workflow-retry-state.ts +0 -167
  67. package/dist/bundling-sources/apps/play-runner-workers/src/workflow-retry.ts +0 -91
  68. package/dist/bundling-sources/sdk/src/plays/harness-stub.ts +0 -329
  69. package/dist/bundling-sources/sdk/src/worker-play-entry.ts +0 -240
  70. package/dist/bundling-sources/shared_libs/play-runtime/governor/coordinator-rate-state-backend.ts +0 -252
  71. package/dist/bundling-sources/shared_libs/play-runtime/runtime-pg-driver-neon-serverless.ts +0 -217
@@ -1,229 +0,0 @@
1
- import {
2
- harnessClaimRuntimeReceipt,
3
- harnessClaimRuntimeReceipts,
4
- harnessCompleteRuntimeReceipt,
5
- harnessCompleteRuntimeReceipts,
6
- harnessFailRuntimeReceipt,
7
- harnessFailRuntimeReceipts,
8
- harnessGetRuntimeReceipt,
9
- harnessHeartbeatRuntimeReceipts,
10
- harnessMarkRuntimeReceiptsRunning,
11
- harnessReleaseRuntimeReceipt,
12
- } from '../../../../sdk/src/plays/harness-stub';
13
- import type { PreloadedRuntimeDbSessionInput } from '../../../play-harness-worker/src/rpc-types';
14
- import { PLAY_RUNTIME_CONTRACT } from '../../../../shared_libs/play-runtime/runtime-contract';
15
- import type { WorkerRuntimeReceiptStore } from './receipts';
16
-
17
- const RUNTIME_TEST_FAULT_NAMES = new Set([
18
- 'receipt_complete_write_fail',
19
- 'receipt_fail_write_fail',
20
- 'worker_receipt_complete_write_fail',
21
- ]);
22
-
23
- function createReceiptCompletionFaultForwarder(
24
- header: string | null | undefined,
25
- ): () => string | null {
26
- const value = header?.trim();
27
- if (!value) return () => null;
28
- const counts = new Map<string, number>();
29
- for (const rawPart of value.split(',')) {
30
- const part = rawPart.trim();
31
- if (!part) continue;
32
- const [rawName, rawCount] = part.split(':');
33
- const name = rawName?.trim();
34
- if (!name) continue;
35
- if (!RUNTIME_TEST_FAULT_NAMES.has(name)) {
36
- throw new Error(`Unsupported runtime test fault "${name}".`);
37
- }
38
- const count =
39
- rawCount === undefined || rawCount.trim() === '' ? 1 : Number(rawCount);
40
- if (!Number.isInteger(count) || count < 1) {
41
- throw new Error(
42
- `Runtime test fault "${name}" count must be a positive integer.`,
43
- );
44
- }
45
- counts.set(name, (counts.get(name) ?? 0) + count);
46
- }
47
- return () => {
48
- const forwarded: string[] = [];
49
- for (const [name, count] of counts) {
50
- if (name !== 'worker_receipt_complete_write_fail') {
51
- forwarded.push(`${name}:${count}`);
52
- continue;
53
- }
54
- if (count <= 0) continue;
55
- forwarded.push('receipt_complete_write_fail:1');
56
- // Keep repeated worker-scoped fault forwards distinct for the direct
57
- // runtime fault consumer, whose state is keyed by runId + header value.
58
- forwarded.push(`${name}:${count}`);
59
- if (count === 1) {
60
- counts.delete(name);
61
- } else {
62
- counts.set(name, count - 1);
63
- }
64
- }
65
- return forwarded.length > 0 ? forwarded.join(',') : null;
66
- };
67
- }
68
-
69
- export function createHarnessWorkerReceiptStore(input: {
70
- executorToken: string;
71
- orgId: string;
72
- preloadedDbSessions?: PreloadedRuntimeDbSessionInput[] | null;
73
- userEmail?: string | null;
74
- runtimeTestFaultHeader?: string | null;
75
- runAttempt?: number | null;
76
- receiptLeaseTtlMs?: number | null;
77
- }): WorkerRuntimeReceiptStore {
78
- const runAttempt =
79
- typeof input.runAttempt === 'number' && Number.isFinite(input.runAttempt)
80
- ? Math.max(0, Math.floor(input.runAttempt))
81
- : null;
82
- const runAttemptField = runAttempt == null ? {} : { runAttempt };
83
- const runtimeContractField = { contract: PLAY_RUNTIME_CONTRACT };
84
- const leaseTtlField =
85
- typeof input.receiptLeaseTtlMs === 'number' &&
86
- Number.isFinite(input.receiptLeaseTtlMs) &&
87
- input.receiptLeaseTtlMs > 0
88
- ? { leaseTtlMs: Math.floor(input.receiptLeaseTtlMs) }
89
- : {};
90
- const receiptCompletionFaultHeader = createReceiptCompletionFaultForwarder(
91
- input.runtimeTestFaultHeader,
92
- );
93
- return {
94
- getReceipt(command) {
95
- return harnessGetRuntimeReceipt({
96
- executorToken: input.executorToken,
97
- ...runtimeContractField,
98
- orgId: input.orgId,
99
- preloadedDbSessions: input.preloadedDbSessions ?? null,
100
- userEmail: input.userEmail ?? null,
101
- runtimeTestFaultHeader: input.runtimeTestFaultHeader ?? null,
102
- runId: '',
103
- ...runAttemptField,
104
- ...command,
105
- });
106
- },
107
- claimReceipt(command) {
108
- return harnessClaimRuntimeReceipt({
109
- executorToken: input.executorToken,
110
- ...runtimeContractField,
111
- orgId: input.orgId,
112
- preloadedDbSessions: input.preloadedDbSessions ?? null,
113
- userEmail: input.userEmail ?? null,
114
- runtimeTestFaultHeader: input.runtimeTestFaultHeader ?? null,
115
- ...runAttemptField,
116
- ...leaseTtlField,
117
- ...command,
118
- });
119
- },
120
- claimReceipts(command) {
121
- return harnessClaimRuntimeReceipts({
122
- executorToken: input.executorToken,
123
- ...runtimeContractField,
124
- orgId: input.orgId,
125
- preloadedDbSessions: input.preloadedDbSessions ?? null,
126
- userEmail: input.userEmail ?? null,
127
- runtimeTestFaultHeader: input.runtimeTestFaultHeader ?? null,
128
- ...runAttemptField,
129
- ...leaseTtlField,
130
- ...command,
131
- });
132
- },
133
- markReceiptsRunning(command) {
134
- return harnessMarkRuntimeReceiptsRunning({
135
- executorToken: input.executorToken,
136
- ...runtimeContractField,
137
- orgId: input.orgId,
138
- preloadedDbSessions: input.preloadedDbSessions ?? null,
139
- userEmail: input.userEmail ?? null,
140
- runtimeTestFaultHeader: input.runtimeTestFaultHeader ?? null,
141
- ...leaseTtlField,
142
- ...command,
143
- receipts: command.receipts.map((receipt) => ({
144
- ...runAttemptField,
145
- ...receipt,
146
- })),
147
- });
148
- },
149
- completeReceipt(command) {
150
- return harnessCompleteRuntimeReceipt({
151
- executorToken: input.executorToken,
152
- ...runtimeContractField,
153
- orgId: input.orgId,
154
- preloadedDbSessions: input.preloadedDbSessions ?? null,
155
- userEmail: input.userEmail ?? null,
156
- runtimeTestFaultHeader: receiptCompletionFaultHeader(),
157
- ...runAttemptField,
158
- ...command,
159
- });
160
- },
161
- completeReceipts(command) {
162
- return harnessCompleteRuntimeReceipts({
163
- executorToken: input.executorToken,
164
- ...runtimeContractField,
165
- orgId: input.orgId,
166
- preloadedDbSessions: input.preloadedDbSessions ?? null,
167
- userEmail: input.userEmail ?? null,
168
- runtimeTestFaultHeader: receiptCompletionFaultHeader(),
169
- ...command,
170
- receipts: command.receipts.map((receipt) => ({
171
- ...runAttemptField,
172
- ...receipt,
173
- })),
174
- });
175
- },
176
- failReceipt(command) {
177
- return harnessFailRuntimeReceipt({
178
- executorToken: input.executorToken,
179
- ...runtimeContractField,
180
- orgId: input.orgId,
181
- preloadedDbSessions: input.preloadedDbSessions ?? null,
182
- userEmail: input.userEmail ?? null,
183
- runtimeTestFaultHeader: input.runtimeTestFaultHeader ?? null,
184
- ...runAttemptField,
185
- ...command,
186
- });
187
- },
188
- releaseReceipt(command) {
189
- return harnessReleaseRuntimeReceipt({
190
- executorToken: input.executorToken,
191
- ...runtimeContractField,
192
- orgId: input.orgId,
193
- preloadedDbSessions: input.preloadedDbSessions ?? null,
194
- userEmail: input.userEmail ?? null,
195
- runtimeTestFaultHeader: input.runtimeTestFaultHeader ?? null,
196
- ...runAttemptField,
197
- ...command,
198
- });
199
- },
200
- failReceipts(command) {
201
- return harnessFailRuntimeReceipts({
202
- executorToken: input.executorToken,
203
- ...runtimeContractField,
204
- orgId: input.orgId,
205
- preloadedDbSessions: input.preloadedDbSessions ?? null,
206
- userEmail: input.userEmail ?? null,
207
- runtimeTestFaultHeader: input.runtimeTestFaultHeader ?? null,
208
- ...command,
209
- receipts: command.receipts.map((receipt) => ({
210
- ...runAttemptField,
211
- ...receipt,
212
- })),
213
- });
214
- },
215
- heartbeatReceipts(command) {
216
- return harnessHeartbeatRuntimeReceipts({
217
- executorToken: input.executorToken,
218
- ...runtimeContractField,
219
- orgId: input.orgId,
220
- preloadedDbSessions: input.preloadedDbSessions ?? null,
221
- userEmail: input.userEmail ?? null,
222
- runtimeTestFaultHeader: input.runtimeTestFaultHeader ?? null,
223
- ...runAttemptField,
224
- ...leaseTtlField,
225
- ...command,
226
- });
227
- },
228
- };
229
- }
@@ -1,81 +0,0 @@
1
- import {
2
- MAX_LEDGER_LOG_LINE_LENGTH,
3
- MAX_LEDGER_LOG_LINES_PER_EVENT,
4
- } from '../../../../shared_libs/play-runtime/ledger-safe-payload';
5
- import type { PlayRunLedgerEvent } from '../../../../shared_libs/play-runtime/run-ledger';
6
-
7
- /** Keep a Worker-to-runtime append comfortably below the API and Convex limits. */
8
- export const WORKER_LEDGER_EVENT_BATCH_MAX_BYTES = 128 * 1024;
9
- export const WORKER_LEDGER_EVENTS_PER_APPEND_MAX = 100;
10
-
11
- const encoder = new TextEncoder();
12
-
13
- function encodedJsonBytes(value: unknown): number {
14
- return encoder.encode(JSON.stringify(value)).length;
15
- }
16
-
17
- function splitLogEvent(
18
- event: Extract<PlayRunLedgerEvent, { type: 'log.appended' }>,
19
- ): PlayRunLedgerEvent[] {
20
- const events: PlayRunLedgerEvent[] = [];
21
- const lines = event.lines.map((line) =>
22
- line.slice(0, MAX_LEDGER_LOG_LINE_LENGTH),
23
- );
24
- let start = 0;
25
- while (start < lines.length) {
26
- let end = start;
27
- let bytes = encodedJsonBytes({ ...event, lines: [] });
28
- while (end < lines.length && end - start < MAX_LEDGER_LOG_LINES_PER_EVENT) {
29
- const lineBytes = encodedJsonBytes(lines[end]!);
30
- if (
31
- end > start &&
32
- bytes + lineBytes + 1 > WORKER_LEDGER_EVENT_BATCH_MAX_BYTES
33
- ) {
34
- break;
35
- }
36
- bytes += lineBytes + 1;
37
- end += 1;
38
- }
39
- events.push({
40
- ...event,
41
- lines: lines.slice(start, end),
42
- ...(typeof event.channelOffset === 'number'
43
- ? { channelOffset: event.channelOffset + start }
44
- : {}),
45
- });
46
- start = end;
47
- }
48
- return events;
49
- }
50
-
51
- /**
52
- * Partition ledger delivery without dropping positional log lines. The worker
53
- * retries only unacknowledged batches, so each batch must be independently
54
- * valid for the app-runtime and Convex boundaries.
55
- */
56
- export function partitionWorkerLedgerEvents(
57
- events: readonly PlayRunLedgerEvent[],
58
- ): PlayRunLedgerEvent[][] {
59
- const batches: PlayRunLedgerEvent[][] = [];
60
- let batch: PlayRunLedgerEvent[] = [];
61
- let batchBytes = 2;
62
-
63
- for (const event of events.flatMap((event) =>
64
- event.type === 'log.appended' ? splitLogEvent(event) : [event],
65
- )) {
66
- const eventBytes = encodedJsonBytes(event);
67
- if (
68
- batch.length > 0 &&
69
- (batch.length >= WORKER_LEDGER_EVENTS_PER_APPEND_MAX ||
70
- batchBytes + eventBytes + 1 > WORKER_LEDGER_EVENT_BATCH_MAX_BYTES)
71
- ) {
72
- batches.push(batch);
73
- batch = [];
74
- batchBytes = 2;
75
- }
76
- batch.push(event);
77
- batchBytes += eventBytes + 1;
78
- }
79
- if (batch.length > 0) batches.push(batch);
80
- return batches;
81
- }
@@ -1,22 +0,0 @@
1
- export type LiveNodeProgressSnapshot = {
2
- completed?: number;
3
- total?: number;
4
- failed?: number;
5
- startedRows?: number;
6
- activeRows?: number;
7
- waitingRows?: number;
8
- completedRows?: number;
9
- message?: string;
10
- updatedAt?: number;
11
- startedAt?: number;
12
- completedAt?: number;
13
- artifactTableNamespace?: string | null;
14
- };
15
-
16
- export type LiveNodeProgressMap = Record<string, LiveNodeProgressSnapshot>;
17
-
18
- export function sanitizeLiveLogLines(value: unknown): string[] | null {
19
- return Array.isArray(value)
20
- ? value.filter((line): line is string => typeof line === 'string')
21
- : null;
22
- }