deepline 0.3.207 → 0.3.209

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.
@@ -200,7 +200,7 @@ export const SDK_RELEASE = {
200
200
  // getters keep their established compatibility behavior.
201
201
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
202
202
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
203
- version: '0.3.207',
203
+ version: '0.3.209',
204
204
  updateSummary:
205
205
  'Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.',
206
206
  packageCapabilities: {
@@ -126,6 +126,9 @@ export type PlayRunLedgerSnapshot = {
126
126
  runId: string;
127
127
  playName?: string | null;
128
128
  status: PlayRunLedgerStatus;
129
+ /** Typed scheduler wait, when a durable waiting event supplied it. */
130
+ waitKind?: string | null;
131
+ waitUntil?: number | null;
129
132
  error?: string | null;
130
133
  createdAt?: number | null;
131
134
  startedAt?: number | null;
@@ -201,6 +204,8 @@ export type PlayRunLedgerEvent =
201
204
  })
202
205
  | (PlayRunLedgerBaseEvent & {
203
206
  type: 'run.waiting';
207
+ waitKind?: string | null;
208
+ waitUntil?: number | null;
204
209
  })
205
210
  | (PlayRunLedgerBaseEvent & {
206
211
  type: 'run.resumed';
@@ -541,6 +546,8 @@ export function createEmptyPlayRunLedgerSnapshot(input: {
541
546
  runId: input.runId,
542
547
  playName: input.playName ?? null,
543
548
  status,
549
+ waitKind: null,
550
+ waitUntil: null,
544
551
  error: optionalNullableString(input.error) ?? null,
545
552
  createdAt: finiteNumber(input.createdAt) ?? null,
546
553
  startedAt,
@@ -677,6 +684,8 @@ export function normalizePlayRunLedgerSnapshot(
677
684
  playName:
678
685
  optionalNullableString(value.playName) ?? fallback.playName ?? null,
679
686
  status: normalizePlayRunLedgerStatus(value.status ?? fallback.status),
687
+ waitKind: optionalNullableString(value.waitKind),
688
+ waitUntil: finiteNumber(value.waitUntil),
680
689
  error,
681
690
  createdAt,
682
691
  startedAt,
@@ -1312,11 +1321,17 @@ export function reducePlayRunLedgerEvent(
1312
1321
  return withTiming({
1313
1322
  ...base,
1314
1323
  status: 'waiting',
1324
+ waitKind: event.waitKind ?? null,
1325
+ waitUntil: event.waitUntil ?? null,
1326
+ activeActivityId: null,
1315
1327
  });
1316
1328
  case 'run.resumed':
1317
1329
  return withTiming({
1318
1330
  ...base,
1319
1331
  status: 'running',
1332
+ waitKind: null,
1333
+ waitUntil: null,
1334
+ activeActivityId: null,
1320
1335
  });
1321
1336
  case 'run.completed':
1322
1337
  return (
@@ -1330,6 +1345,8 @@ export function reducePlayRunLedgerEvent(
1330
1345
  withTiming({
1331
1346
  ...settleRunningStepsOnTerminal(base, 'completed', occurredAt),
1332
1347
  status: 'completed',
1348
+ waitKind: null,
1349
+ waitUntil: null,
1333
1350
  error: null,
1334
1351
  startedAt: base.startedAt ?? occurredAt,
1335
1352
  finishedAt: terminalFinishedAt(base, event.type, occurredAt),
@@ -1358,6 +1375,8 @@ export function reducePlayRunLedgerEvent(
1358
1375
  withTiming({
1359
1376
  ...settleRunningStepsOnTerminal(base, 'failed', occurredAt),
1360
1377
  status: 'failed',
1378
+ waitKind: null,
1379
+ waitUntil: null,
1361
1380
  error:
1362
1381
  base.status === 'failed'
1363
1382
  ? (base.error ?? event.error ?? null)
@@ -1386,6 +1405,8 @@ export function reducePlayRunLedgerEvent(
1386
1405
  withTiming({
1387
1406
  ...settleRunningStepsOnTerminal(base, 'failed', occurredAt),
1388
1407
  status: 'cancelled',
1408
+ waitKind: null,
1409
+ waitUntil: null,
1389
1410
  error:
1390
1411
  base.status === 'cancelled'
1391
1412
  ? (base.error ?? event.error ?? null)
@@ -78,6 +78,7 @@ import {
78
78
  } from '../work-receipts';
79
79
  import type { PlayStaticPipeline } from '../../plays/static-pipeline';
80
80
  import {
81
+ isPlayRunLedgerOpaqueEvent,
81
82
  LOG_TAIL_LIMIT,
82
83
  type AcceptedPlayRunLedgerEvent,
83
84
  type PlayRunLedgerEvent,
@@ -15920,6 +15921,64 @@ async function appendRunLedgerOutboxFact(
15920
15921
 
15921
15922
  export { RunLedgerProjectionLeaseLostError } from '../run-ledger-projection-contract';
15922
15923
 
15924
+ /**
15925
+ * A newer app can receive a projection from a worker that predates optional
15926
+ * wait metadata. Treat only those absent fields as their canonical values;
15927
+ * lease identity, event ordering, and every field the worker did send remain
15928
+ * exact.
15929
+ */
15930
+ function normalizeLegacyRunWaitingProjectionFields(
15931
+ projectedEvents: readonly AcceptedPlayRunLedgerEvent[],
15932
+ expectedEvents: readonly (
15933
+ | AcceptedPlayRunLedgerEvent
15934
+ | PlayRunLedgerIngressEvent
15935
+ )[],
15936
+ ): AcceptedPlayRunLedgerEvent[] {
15937
+ return projectedEvents.map((event, index) => {
15938
+ const expected = expectedEvents[index];
15939
+ if (
15940
+ isPlayRunLedgerOpaqueEvent(event) ||
15941
+ event.type !== 'run.waiting' ||
15942
+ expected?.type !== 'run.waiting' ||
15943
+ ('opaque' in expected && expected.opaque === true)
15944
+ ) {
15945
+ return event;
15946
+ }
15947
+ const expectedEvent = expected as Record<string, unknown>;
15948
+ const expectedWaitKind = expectedEvent.waitKind;
15949
+ const expectedWaitUntil = expectedEvent.waitUntil;
15950
+ return {
15951
+ ...event,
15952
+ ...(event.waitKind === undefined &&
15953
+ (typeof expectedWaitKind === 'string' || expectedWaitKind === null)
15954
+ ? { waitKind: expectedWaitKind }
15955
+ : {}),
15956
+ ...(event.waitUntil === undefined &&
15957
+ (typeof expectedWaitUntil === 'number' || expectedWaitUntil === null)
15958
+ ? { waitUntil: expectedWaitUntil }
15959
+ : {}),
15960
+ };
15961
+ });
15962
+ }
15963
+
15964
+ function runLedgerProjectionMatchesCanonicalPrefix(
15965
+ projectedEvents: readonly AcceptedPlayRunLedgerEvent[],
15966
+ expectedEvents: readonly (
15967
+ | AcceptedPlayRunLedgerEvent
15968
+ | PlayRunLedgerIngressEvent
15969
+ )[],
15970
+ ): boolean {
15971
+ if (projectedEvents.length !== expectedEvents.length) return false;
15972
+ return (
15973
+ stableStringify(
15974
+ normalizeLegacyRunWaitingProjectionFields(
15975
+ projectedEvents,
15976
+ expectedEvents,
15977
+ ),
15978
+ ) === stableStringify(expectedEvents)
15979
+ );
15980
+ }
15981
+
15923
15982
  /** Extend only our still-live lease before another bounded transport piece. */
15924
15983
  export async function renewPostgresRunLedgerDelivery(
15925
15984
  client: PostgresSchedulerQueryClient,
@@ -16074,12 +16133,17 @@ export async function assertPostgresRunLedgerDelivery(
16074
16133
  }),
16075
16134
  );
16076
16135
  }
16077
- const comparablePrefixEvents = input.normalizeProjectedEvents
16136
+ const comparablePrefixEvents: readonly (
16137
+ | AcceptedPlayRunLedgerEvent
16138
+ | PlayRunLedgerIngressEvent
16139
+ )[] = input.normalizeProjectedEvents
16078
16140
  ? input.normalizeProjectedEvents(prefixEvents)
16079
16141
  : prefixEvents;
16080
16142
  if (
16081
- stableStringify(input.projectedEvents) ===
16082
- stableStringify(comparablePrefixEvents)
16143
+ runLedgerProjectionMatchesCanonicalPrefix(
16144
+ input.projectedEvents,
16145
+ comparablePrefixEvents,
16146
+ )
16083
16147
  ) {
16084
16148
  return;
16085
16149
  }
@@ -16965,6 +17029,9 @@ export function buildRunLedgerEventsFromPostgresSchedulerOutbox(
16965
17029
  runId: event.runId,
16966
17030
  occurredAt,
16967
17031
  source: 'system',
17032
+ ...(event.eventType === 'run.waiting' && waitKind !== null
17033
+ ? { waitKind }
17034
+ : {}),
16968
17035
  } as PlayRunLedgerEvent;
16969
17036
  if (
16970
17037
  waitKind !== null &&