deepline 0.3.228 → 0.3.230

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 (48) hide show
  1. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  2. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +18 -0
  3. package/dist/bundling-sources/shared_libs/play-data-plane/contracts.ts +12 -0
  4. package/dist/bundling-sources/shared_libs/play-data-plane/index.ts +1 -0
  5. package/dist/bundling-sources/shared_libs/play-data-plane/sheet-column-storage.ts +252 -0
  6. package/dist/bundling-sources/shared_libs/play-data-plane/sheet-contract.ts +29 -8
  7. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +19 -0
  8. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +297 -69
  9. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +5 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +38 -2
  11. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/gateway-adapter.ts +8 -3
  12. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +9 -0
  13. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +39 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +293 -4
  15. package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +29 -0
  16. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +56 -11
  17. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/progress-sidecar.ts +1 -0
  18. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/local-process.ts +4 -0
  19. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +4 -0
  20. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +380 -183
  21. package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +187 -14
  22. package/dist/bundling-sources/shared_libs/play-runtime/runtime-work-counters.ts +52 -2
  23. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +5 -0
  24. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +30 -2
  25. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +118 -6
  26. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +135 -21
  27. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +1 -0
  28. package/dist/bundling-sources/shared_libs/plays/dataset.ts +16 -2
  29. package/dist/bundling-sources/shared_libs/plays/execution-pipeline.ts +72 -0
  30. package/dist/bundling-sources/shared_libs/plays/launch/prepare.ts +1 -3
  31. package/dist/bundling-sources/shared_libs/plays/sheet-filter.ts +9 -13
  32. package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +28 -31
  33. package/dist/cli/index.js +102 -2
  34. package/dist/cli/index.mjs +102 -2
  35. package/dist/{compiler-manifest-Dpd2hEet.d.mts → compiler-manifest-n8ZtPv2h.d.mts} +31 -21
  36. package/dist/{compiler-manifest-Dpd2hEet.d.ts → compiler-manifest-n8ZtPv2h.d.ts} +31 -21
  37. package/dist/index.d.mts +2 -2
  38. package/dist/index.d.ts +2 -2
  39. package/dist/index.js +98 -2
  40. package/dist/index.mjs +98 -2
  41. package/dist/install-integrity.json +4 -2
  42. package/dist/plays/bundle-play-file.d.mts +2 -2
  43. package/dist/plays/bundle-play-file.d.ts +2 -2
  44. package/dist/release.d.mts +1 -1
  45. package/dist/release.d.ts +1 -1
  46. package/dist/release.js +1 -1
  47. package/dist/release.mjs +1 -1
  48. package/package.json +1 -1
@@ -2,7 +2,7 @@ import { appendFileSync, createReadStream, writeFileSync } from 'node:fs';
2
2
  import { readFile } from 'node:fs/promises';
3
3
  import { dirname, isAbsolute, resolve } from 'node:path';
4
4
  import { createRequire } from 'node:module';
5
- import { createHash } from 'node:crypto';
5
+ import { createHash, randomUUID } from 'node:crypto';
6
6
  import { formatWithOptions } from 'node:util';
7
7
  import { compileFunction } from 'node:vm';
8
8
  import { gunzipSync } from 'node:zlib';
@@ -41,6 +41,8 @@ import {
41
41
  runtimeLimitExceededFailure,
42
42
  } from '../run-failure';
43
43
  import { createPlayContext } from '../context';
44
+ import { augmentSheetContractWithDatasetFields } from '../../play-data-plane/sheet-contract';
45
+ import { nextWorkCounterInvocationSeq } from '../runtime-work-counters';
44
46
  import type { RuntimeApiResponseMeta } from '../app-runtime-api';
45
47
  import { onMemoryPressure } from '../memory-pressure-signal';
46
48
  import {
@@ -1893,6 +1895,16 @@ async function run(
1893
1895
  options?: ExecutePlayRunnerOptions,
1894
1896
  ): Promise<PlayRunnerResult> {
1895
1897
  const runStartedAt = Date.now();
1898
+ const runnerRunAttempt =
1899
+ typeof config.context.runAttempt === 'number' &&
1900
+ Number.isFinite(config.context.runAttempt)
1901
+ ? Math.max(0, Math.floor(config.context.runAttempt))
1902
+ : 0;
1903
+ const workCounterInvocationSeq = nextWorkCounterInvocationSeq(
1904
+ config.checkpoint,
1905
+ runnerRunAttempt,
1906
+ );
1907
+ const workCounterSegmentId = randomUUID();
1896
1908
  const persistenceSignal =
1897
1909
  options?.signal ??
1898
1910
  AbortSignal.timeout(
@@ -2009,11 +2021,6 @@ async function run(
2009
2021
  runId: string;
2010
2022
  tableNamespace: string;
2011
2023
  }) => `${input.playName}\u0000${input.runId}\u0000${input.tableNamespace}`;
2012
- const runnerRunAttempt =
2013
- typeof config.context.runAttempt === 'number' &&
2014
- Number.isFinite(config.context.runAttempt)
2015
- ? Math.max(0, Math.floor(config.context.runAttempt))
2016
- : 0;
2017
2024
  const cachePolicy = playRunnerContextCachePolicy(config.context);
2018
2025
  const rateStateBackend = createRateStateBackendForConfig(config);
2019
2026
  const runtimeInput = config.input ?? {};
@@ -2452,7 +2459,11 @@ async function run(
2452
2459
  playName,
2453
2460
  tableNamespace,
2454
2461
  playInput: runtimeInputObject,
2455
- sheetContract,
2462
+ sheetContract: augmentSheetContractWithDatasetFields({
2463
+ contract: sheetContract,
2464
+ rows: items,
2465
+ columnTypes: mapContext.columnTypes,
2466
+ }),
2456
2467
  rows: items,
2457
2468
  inputOffset: mapContext.inputOffset,
2458
2469
  mode: mapContext.mode,
@@ -2975,6 +2986,13 @@ async function run(
2975
2986
  );
2976
2987
  }
2977
2988
  };
2989
+ const runtimeStats = () => ({
2990
+ ...ctx.getStats(),
2991
+ runtimeWorkCounterSegment: {
2992
+ invocationSeq: workCounterInvocationSeq,
2993
+ segmentId: workCounterSegmentId,
2994
+ },
2995
+ });
2978
2996
  options?.onRuntimeReady?.({
2979
2997
  log: (line) => ctx.logRunnerDiagnostic(line),
2980
2998
  timeoutResult: (runtimeLimitSeconds) => {
@@ -2984,7 +3002,7 @@ async function run(
2984
3002
  error: runtimeLimitExceededCause(runtimeLimitSeconds),
2985
3003
  errors: [runtimeLimitExceededFailure(runtimeLimitSeconds)],
2986
3004
  logs: terminalLogsWithPhaseSummary(ctx),
2987
- stats: ctx.getStats(),
3005
+ stats: runtimeStats(),
2988
3006
  steps: ctx.getSteps(),
2989
3007
  tableNamespace: null,
2990
3008
  totalRows,
@@ -3002,6 +3020,30 @@ async function run(
3002
3020
  }
3003
3021
  : runtimeInput;
3004
3022
 
3023
+ // Sample scalar counters, not the potentially large resource snapshot. The
3024
+ // reporter coalesces transport updates; this timer emits no event if no
3025
+ // counter changed and cannot hold the runner process open.
3026
+ let lastWorkCounterKey: string | null = null;
3027
+ const emitWorkCounters = () => {
3028
+ const counters = ctx.getRuntimeWorkCounters();
3029
+ const key = `${counters.logicalCalls}:${counters.providerRequests}:${counters.provider429s}`;
3030
+ if (key === lastWorkCounterKey) return;
3031
+ lastWorkCounterKey = key;
3032
+ emitRunnerEvent(
3033
+ {
3034
+ type: 'work_counters',
3035
+ attempt: runnerRunAttempt,
3036
+ invocationSeq: workCounterInvocationSeq,
3037
+ segmentId: workCounterSegmentId,
3038
+ ...counters,
3039
+ },
3040
+ options,
3041
+ );
3042
+ };
3043
+ emitWorkCounters();
3044
+ const workCounterTimer = setInterval(emitWorkCounters, 1_500);
3045
+ workCounterTimer.unref();
3046
+
3005
3047
  try {
3006
3048
  emitWorkerLog('Play started', options);
3007
3049
  const rawResult = await executeRuntimePlayCode({
@@ -3205,7 +3247,7 @@ async function run(
3205
3247
  logs,
3206
3248
  ...(runtimeDiagnostics.length > 0 ? { runtimeDiagnostics } : {}),
3207
3249
  ...(rowOutcomes ? { rowOutcomes } : {}),
3208
- stats: ctx.getStats(),
3250
+ stats: runtimeStats(),
3209
3251
  steps: ctx.getSteps(),
3210
3252
  checkpoint,
3211
3253
  tableNamespace: resultTableNamespace,
@@ -3257,7 +3299,7 @@ async function run(
3257
3299
  status: 'suspended',
3258
3300
  suspension: error.suspension,
3259
3301
  logs: terminalLogsWithPhaseSummary(ctx),
3260
- stats: ctx.getStats(),
3302
+ stats: runtimeStats(),
3261
3303
  steps: ctx.getSteps(),
3262
3304
  checkpoint: ctx.getCheckpoint(),
3263
3305
  tableNamespace: null,
@@ -3293,7 +3335,7 @@ async function run(
3293
3335
  errors: [failure],
3294
3336
  logs: terminalLogsWithPhaseSummary(ctx),
3295
3337
  ...(rowOutcomes ? { rowOutcomes } : {}),
3296
- stats: ctx.getStats(),
3338
+ stats: runtimeStats(),
3297
3339
  steps: ctx.getSteps(),
3298
3340
  checkpoint,
3299
3341
  tableNamespace: null,
@@ -3301,6 +3343,9 @@ async function run(
3301
3343
  inserted,
3302
3344
  skipped,
3303
3345
  };
3346
+ } finally {
3347
+ clearInterval(workCounterTimer);
3348
+ emitWorkCounters();
3304
3349
  }
3305
3350
  }
3306
3351
 
@@ -24,6 +24,7 @@ function shouldEmitProgressSidecarLog(line: string): boolean {
24
24
  export function shouldEmitProgressSidecarEvent(
25
25
  event: PlayRunnerEvent,
26
26
  ): boolean {
27
+ if (event.type === 'work_counters') return true;
27
28
  if (event.type === 'execution_event') {
28
29
  return event.event.type !== 'map.row.updated';
29
30
  }
@@ -509,6 +509,10 @@ export const localProcessPlayRunnerBackend: PlayRunnerBackend = {
509
509
  }
510
510
  if (event.type === 'execution_event') {
511
511
  callbacks?.onExecutionEvent?.(event.event);
512
+ return;
513
+ }
514
+ if (event.type === 'work_counters') {
515
+ callbacks?.onWorkCounters?.(event);
512
516
  }
513
517
  },
514
518
  },
@@ -5,6 +5,7 @@ import type {
5
5
  } from '../ctx-types';
6
6
  import type {
7
7
  PlayRunnerExecutionConfig,
8
+ PlayRunnerEvent,
8
9
  PlayRunnerLogEvent,
9
10
  PlayRunnerResult,
10
11
  } from '../protocol';
@@ -155,6 +156,9 @@ export interface PlayRunnerCallbacks {
155
156
  onCheckpoint?: (checkpoint: PlayCheckpoint) => void;
156
157
  onRowUpdate?: (update: PlayRowUpdate) => void;
157
158
  onExecutionEvent?: (event: PlayExecutionEvent) => void;
159
+ onWorkCounters?: (
160
+ event: Extract<PlayRunnerEvent, { type: 'work_counters' }>,
161
+ ) => void;
158
162
  onRuntimeResourceAcquired?: (
159
163
  resource: PlayRunnerRuntimeResource,
160
164
  ) => void | Promise<void>;