deepline 0.3.252 → 0.3.253

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.252',
203
+ version: '0.3.253',
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: {
@@ -7,7 +7,19 @@
7
7
  */
8
8
  export const SCHEDULED_WORK_CONTROL_CONTRACT_VERSION = 1 as const;
9
9
 
10
- export type ScheduledWorkControlAction = 'run';
10
+ export const SCHEDULED_WORK_CONTROL_ACTIONS = [
11
+ 'run',
12
+ 'start',
13
+ 'pause',
14
+ 'resume',
15
+ 'retry',
16
+ 'verify',
17
+ 'activate',
18
+ 'rollback',
19
+ ] as const;
20
+
21
+ export type ScheduledWorkControlAction =
22
+ (typeof SCHEDULED_WORK_CONTROL_ACTIONS)[number];
11
23
 
12
24
  export type ScheduledWorkControlContext = {
13
25
  readonly jobId: string;
@@ -38,6 +50,10 @@ export type ScheduledWorkControlConnector = {
38
50
  run?: (
39
51
  context: ScheduledWorkControlContext,
40
52
  ) => Promise<ScheduledWorkRunResult>;
53
+ execute?: (
54
+ context: ScheduledWorkControlContext,
55
+ action: Exclude<ScheduledWorkControlAction, 'run'>,
56
+ ) => Promise<ScheduledWorkRunResult>;
41
57
  };
42
58
 
43
59
  export type ScheduledWorkControlRegisterOptions = {
@@ -88,6 +104,14 @@ export class ScheduledWorkControlRegistry {
88
104
  `Scheduled-work connector ${connector.id} declares run without an implementation.`,
89
105
  );
90
106
  }
107
+ if (
108
+ connector.actions.some((action) => action !== 'run') &&
109
+ typeof connector.execute !== 'function'
110
+ ) {
111
+ throw new Error(
112
+ `Scheduled-work connector ${connector.id} declares lifecycle controls without an implementation.`,
113
+ );
114
+ }
91
115
  if (
92
116
  connector.actions.length === 0 &&
93
117
  Object.keys(connector.unavailableActions ?? {}).length === 0
@@ -18091,6 +18091,9 @@ export async function listPostgresSchedulerOutboxMaterializationPlans(
18091
18091
  */
18092
18092
  export type RunLedgerOutboxTokenAuthority = 'local_mint' | 'gateway';
18093
18093
 
18094
+ /** Cross-run service policy; causal order within a run is always unchanged. */
18095
+ export type RunLedgerOutboxHeadPriority = 'admission_first' | 'oldest_ready';
18096
+
18094
18097
  const POSTGRES_SCHEDULER_CANCELLATION_OUTBOX_LEASE_SECONDS =
18095
18098
  // The direct projection can run for the full app-runtime request deadline.
18096
18099
  // Keep another 30 seconds for dispatch setup and acknowledgement so a
@@ -18132,6 +18135,8 @@ export type RunLedgerOutboxDispatchInput = {
18132
18135
  runId?: string | null;
18133
18136
  leaseOwner?: string | null;
18134
18137
  leaseSeconds?: number;
18138
+ /** Defaults to the compatible admission-first claim order. */
18139
+ headPriority?: RunLedgerOutboxHeadPriority;
18135
18140
  /**
18136
18141
  * Token authority for the outbox dispatch. Defaults to `local_mint` for the
18137
18142
  * app-side authoritative projector. The Fly worker MUST pass `gateway`.
@@ -18393,7 +18398,11 @@ export async function dispatchRunLedgerOutboxToLedgerBatchOnceWithClientScope(
18393
18398
  AND active.lease_owner IS NOT NULL
18394
18399
  AND active.lease_expires_at > now()
18395
18400
  )
18396
- ORDER BY CASE WHEN head.event_type = 'run.created' THEN 0 ELSE 1 END,
18401
+ ORDER BY ${
18402
+ input.headPriority === 'oldest_ready'
18403
+ ? ''
18404
+ : "CASE WHEN head.event_type = 'run.created' THEN 0 ELSE 1 END,"
18405
+ }
18397
18406
  head.created_at, runs.run_id
18398
18407
  FOR UPDATE OF runs SKIP LOCKED LIMIT 1
18399
18408
  `);
@@ -14,6 +14,7 @@ import {
14
14
  readPostgresSchedulerOutboxNextDueAt,
15
15
  type PostgresSchedulerOptions,
16
16
  type PostgresSchedulerOutboxProjectionResult,
17
+ type RunLedgerOutboxHeadPriority,
17
18
  } from './postgres';
18
19
  import {
19
20
  acquirePgNotifyHub,
@@ -59,6 +60,11 @@ export const RUN_LEDGER_OUTBOX_RECOVERY_MAX_IN_FLIGHT = 32;
59
60
  // The higher exported ceiling remains available to isolated recovery callers,
60
61
  // but it is not the steady-state production setting.
61
62
  const RUN_LEDGER_OUTBOX_RECOVERY_PRODUCTION_IN_FLIGHT = 8;
63
+ // Admissions retain three of four claim opportunities. The fourth selects
64
+ // the oldest eligible causal head across all runs, preventing terminal work
65
+ // from starving behind continuous new admissions. An empty class never costs
66
+ // another query: either order can select any eligible run.
67
+ const ADMISSION_TURNS_PER_OLDEST_READY_TURN = 3;
62
68
 
63
69
  type RecoveryTimer = ReturnType<typeof setTimeout>;
64
70
 
@@ -66,7 +72,9 @@ export type RunLedgerOutboxRecoveryLogger = Pick<Console, 'info' | 'warn'>;
66
72
 
67
73
  export type RunLedgerOutboxRecoveryDeps = {
68
74
  /** One bounded durable claim/delivery attempt. */
69
- dispatchOnce: () => Promise<PostgresSchedulerOutboxProjectionResult>;
75
+ dispatchOnce: (
76
+ headPriority: RunLedgerOutboxHeadPriority,
77
+ ) => Promise<PostgresSchedulerOutboxProjectionResult>;
70
78
  /** Earliest pending retry time or active lease expiry in the durable outbox. */
71
79
  readNextDueAt: () => Promise<Date | null>;
72
80
  /** A direct LISTEN connection. It is a hint only; a null lease is safe. */
@@ -131,6 +139,14 @@ export function startRunLedgerOutboxRecovery(
131
139
  let unsubscribeNotify: (() => void) | undefined;
132
140
  let unsubscribeState: (() => void) | undefined;
133
141
  let requestDrain: (reason: string) => void = () => undefined;
142
+ let admissionTurns = 0;
143
+
144
+ const dispatchOnce = () => {
145
+ const oldestReady =
146
+ admissionTurns === ADMISSION_TURNS_PER_OLDEST_READY_TURN;
147
+ admissionTurns = oldestReady ? 0 : admissionTurns + 1;
148
+ return deps.dispatchOnce(oldestReady ? 'oldest_ready' : 'admission_first');
149
+ };
134
150
 
135
151
  const clearWakeTimer = () => {
136
152
  if (!timer) return;
@@ -254,7 +270,9 @@ export function startRunLedgerOutboxRecovery(
254
270
  const drain = async (reason: string): Promise<void> => {
255
271
  type Delivery = {
256
272
  id: symbol;
257
- result: PromiseSettledResult<PostgresSchedulerOutboxProjectionResult> | { status: 'skipped' };
273
+ result:
274
+ | PromiseSettledResult<PostgresSchedulerOutboxProjectionResult>
275
+ | { status: 'skipped' };
258
276
  };
259
277
  const pending = new Set<symbol>();
260
278
  const deliveries: Delivery[] = [];
@@ -303,7 +321,7 @@ export function startRunLedgerOutboxRecovery(
303
321
  return;
304
322
  }
305
323
  try {
306
- settle({ status: 'fulfilled', value: await deps.dispatchOnce() });
324
+ settle({ status: 'fulfilled', value: await dispatchOnce() });
307
325
  } catch (reason) {
308
326
  settle({ status: 'rejected', reason });
309
327
  }
@@ -410,10 +428,10 @@ export function startRunLedgerOutboxRecoveryController(input: {
410
428
  schedulerOptions,
411
429
  }),
412
430
  ),
413
- dispatchOnce: () =>
431
+ dispatchOnce: (headPriority) =>
414
432
  dispatchRunLedgerOutboxToLedgerBatchOnceWithClientScope(
415
433
  (operation) => withRuntimeSchedulerClient(input.poolOptions, operation),
416
- { tokenAuthority: 'gateway', limit: 8 },
434
+ { tokenAuthority: 'gateway', limit: 8, headPriority },
417
435
  schedulerOptions,
418
436
  ),
419
437
  // `dispatchRunLedgerOutboxToLedgerBatchOnceWithClientScope` releases each
package/dist/cli/index.js CHANGED
@@ -3507,7 +3507,7 @@ var SDK_RELEASE = {
3507
3507
  // getters keep their established compatibility behavior.
3508
3508
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
3509
3509
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
3510
- version: "0.3.252",
3510
+ version: "0.3.253",
3511
3511
  updateSummary: "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.",
3512
3512
  packageCapabilities: {
3513
3513
  updatePreferences: 1
@@ -3502,7 +3502,7 @@ var SDK_RELEASE = {
3502
3502
  // getters keep their established compatibility behavior.
3503
3503
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
3504
3504
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
3505
- version: "0.3.252",
3505
+ version: "0.3.253",
3506
3506
  updateSummary: "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.",
3507
3507
  packageCapabilities: {
3508
3508
  updatePreferences: 1
package/dist/index.js CHANGED
@@ -1320,7 +1320,7 @@ var SDK_RELEASE = {
1320
1320
  // getters keep their established compatibility behavior.
1321
1321
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
1322
1322
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
1323
- version: "0.3.252",
1323
+ version: "0.3.253",
1324
1324
  updateSummary: "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.",
1325
1325
  packageCapabilities: {
1326
1326
  updatePreferences: 1
package/dist/index.mjs CHANGED
@@ -1224,7 +1224,7 @@ var SDK_RELEASE = {
1224
1224
  // getters keep their established compatibility behavior.
1225
1225
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
1226
1226
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
1227
- version: "0.3.252",
1227
+ version: "0.3.253",
1228
1228
  updateSummary: "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.",
1229
1229
  packageCapabilities: {
1230
1230
  updatePreferences: 1
@@ -149,7 +149,7 @@ type SdkRelease = {
149
149
  supportPolicy: SdkSupportPolicy;
150
150
  };
151
151
  declare const SDK_RELEASE: {
152
- readonly version: "0.3.252";
152
+ readonly version: "0.3.253";
153
153
  readonly updateSummary: "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.";
154
154
  readonly packageCapabilities: {
155
155
  readonly updatePreferences: 1;
package/dist/release.d.ts CHANGED
@@ -149,7 +149,7 @@ type SdkRelease = {
149
149
  supportPolicy: SdkSupportPolicy;
150
150
  };
151
151
  declare const SDK_RELEASE: {
152
- readonly version: "0.3.252";
152
+ readonly version: "0.3.253";
153
153
  readonly updateSummary: "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.";
154
154
  readonly packageCapabilities: {
155
155
  readonly updatePreferences: 1;
package/dist/release.js CHANGED
@@ -74,7 +74,7 @@ var SDK_RELEASE = {
74
74
  // getters keep their established compatibility behavior.
75
75
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
76
76
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
77
- version: "0.3.252",
77
+ version: "0.3.253",
78
78
  updateSummary: "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.",
79
79
  packageCapabilities: {
80
80
  updatePreferences: 1
package/dist/release.mjs CHANGED
@@ -48,7 +48,7 @@ var SDK_RELEASE = {
48
48
  // getters keep their established compatibility behavior.
49
49
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
50
50
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
51
- version: "0.3.252",
51
+ version: "0.3.253",
52
52
  updateSummary: "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.",
53
53
  packageCapabilities: {
54
54
  updatePreferences: 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.3.252",
3
+ "version": "0.3.253",
4
4
  "description": "GTM data CLI and TypeScript SDK for coding agents",
5
5
  "license": "MIT",
6
6
  "homepage": "https://code.deepline.com",