deepline 0.3.300 → 0.3.302

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 (95) hide show
  1. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  2. package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +1 -1
  3. package/dist/bundling-sources/shared_libs/play-runtime/live-state-contract.ts +2 -0
  4. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/gateway-adapter.ts +2 -4
  5. package/dist/bundling-sources/shared_libs/play-runtime/run-log-buffer.ts +60 -0
  6. package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +13 -0
  7. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +16 -5
  8. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-start-admission.ts +7 -1
  9. package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +6 -4
  10. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +2 -2
  11. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +229 -98
  12. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +2 -4
  13. package/dist/cli/{auth-RVK23SLA.mjs → auth-WHKDFARX.mjs} +4 -4
  14. package/dist/cli/auth-ZJDK7HFJ.js +31 -0
  15. package/dist/cli/{billing-CBWRPMBG.mjs → billing-7C66HEMK.mjs} +4 -4
  16. package/dist/cli/{billing-6LEQNTUS.js → billing-IMFI76GS.js} +70 -70
  17. package/dist/cli/{chunk-YLYVPHEG.mjs → chunk-2TCHWWRP.mjs} +1 -1
  18. package/dist/cli/{chunk-M5SHROFS.js → chunk-5FKCLTLS.js} +14 -7
  19. package/dist/cli/{chunk-OCKGMK6B.js → chunk-7AXKBZWF.js} +2 -2
  20. package/dist/cli/{chunk-NXOML2N6.mjs → chunk-A4UUUINX.mjs} +1 -1
  21. package/dist/cli/{chunk-6CLYAWXK.js → chunk-AAZBNN6N.js} +4 -4
  22. package/dist/cli/{chunk-6AUI2MS4.mjs → chunk-AIIVF62D.mjs} +1 -1
  23. package/dist/cli/{chunk-BLANZQG2.mjs → chunk-DTGPHQFC.mjs} +2 -2
  24. package/dist/cli/{chunk-BFGSCAZ7.mjs → chunk-GHYU5YWJ.mjs} +1 -1
  25. package/dist/cli/{chunk-MFGPKFJC.mjs → chunk-GWIY7C7U.mjs} +1 -1
  26. package/dist/cli/{chunk-YR26QBMJ.js → chunk-GXYR7DV4.js} +1 -1
  27. package/dist/cli/{chunk-NMTG3N2J.js → chunk-J2PPXZE4.js} +6 -6
  28. package/dist/cli/{chunk-XUA3QCZU.js → chunk-JX3CNS4W.js} +26 -26
  29. package/dist/cli/{chunk-N5A3LWPC.js → chunk-KEPIGAJS.js} +57 -57
  30. package/dist/cli/{chunk-OKKAFDXS.js → chunk-KI5DPDF2.js} +15 -15
  31. package/dist/cli/{chunk-DRLNWL4W.js → chunk-NRIVXKMQ.js} +6 -6
  32. package/dist/cli/{chunk-BW3WGFLG.js → chunk-OTAGK5MS.js} +48 -48
  33. package/dist/cli/{chunk-2C5H32YE.js → chunk-OUREAAOT.js} +6 -6
  34. package/dist/cli/{chunk-LH7IBCW2.mjs → chunk-PZOHVTQ3.mjs} +3 -3
  35. package/dist/cli/{chunk-Z3RMVRCQ.mjs → chunk-S6XS2ABF.mjs} +9 -2
  36. package/dist/cli/{chunk-E6S4RTMG.mjs → chunk-TVBPWUII.mjs} +4 -4
  37. package/dist/cli/{chunk-GQISQAAZ.mjs → chunk-V4WVYW3G.mjs} +2 -2
  38. package/dist/cli/{chunk-RLDEQJQQ.mjs → chunk-YLVIJZ2W.mjs} +2 -2
  39. package/dist/cli/client-FVPE6PB4.js +20 -0
  40. package/dist/cli/{client-6D6UBKDX.mjs → client-M7OBRULN.mjs} +3 -3
  41. package/dist/cli/{csv-VK327Z63.mjs → csv-AKVUO3PP.mjs} +3 -3
  42. package/dist/cli/{csv-O4HDE34Y.js → csv-SAJB2PYV.js} +12 -12
  43. package/dist/cli/{db-IL35EIOE.js → db-AASVDGJB.js} +20 -20
  44. package/dist/cli/{db-TRNRYJL6.mjs → db-KREGQID3.mjs} +4 -4
  45. package/dist/cli/{executions-CFWDNHOQ.js → executions-XSKRZWVG.js} +6 -6
  46. package/dist/cli/{executions-JEUBKNUA.mjs → executions-YL5UM6BY.mjs} +4 -4
  47. package/dist/cli/{feedback-BSSEEXR2.mjs → feedback-ITNK5A5V.mjs} +3 -3
  48. package/dist/cli/{feedback-F7HXHQY3.js → feedback-XZNAGHZ4.js} +6 -6
  49. package/dist/cli/git-IOUJDZDJ.js +23 -0
  50. package/dist/cli/{git-I3AAHTCJ.mjs → git-IXYZ5H7T.mjs} +4 -4
  51. package/dist/cli/index.js +73 -73
  52. package/dist/cli/index.mjs +30 -30
  53. package/dist/cli/{legacy-noops-HNN7WPWF.js → legacy-noops-BJZ3P455.js} +7 -7
  54. package/dist/cli/{legacy-noops-KTRWO7NA.mjs → legacy-noops-MT5VFDXS.mjs} +4 -4
  55. package/dist/cli/{monitors-D64KB7G2.mjs → monitors-QL4XDOQT.mjs} +4 -4
  56. package/dist/cli/{monitors-4Y4M3ZJ3.js → monitors-XU62FCBX.js} +85 -85
  57. package/dist/cli/{org-ELLMCZRC.js → org-6WSIPHVV.js} +60 -60
  58. package/dist/cli/{org-UGIVFU7B.mjs → org-NKFPS763.mjs} +4 -4
  59. package/dist/cli/{play-LUNGZ5ZJ.mjs → play-CKL7RDIS.mjs} +6 -6
  60. package/dist/cli/{play-NXV5UJYW.js → play-RZO7CZKL.js} +200 -200
  61. package/dist/cli/{providers-AL6YIZVA.js → providers-PQPH374E.js} +7 -7
  62. package/dist/cli/{providers-YCNHAEFJ.mjs → providers-UKNXDCPJ.mjs} +4 -4
  63. package/dist/cli/{quickstart-LK5IBLYY.js → quickstart-3FFTESEL.js} +5 -5
  64. package/dist/cli/{quickstart-R6AOCVA2.mjs → quickstart-JUTTMWIC.mjs} +3 -3
  65. package/dist/cli/{search-PGW2ZEZ3.js → search-TKLHBKKK.js} +6 -6
  66. package/dist/cli/{search-77YOO5TG.mjs → search-WGBQ5LE5.mjs} +5 -5
  67. package/dist/cli/{secrets-OWNCPA6L.mjs → secrets-EV6IOJLN.mjs} +4 -4
  68. package/dist/cli/{secrets-5OV4C2UI.js → secrets-GGQRCGLA.js} +13 -13
  69. package/dist/cli/{sessions-RVJHCSYH.mjs → sessions-HL3Q22O5.mjs} +4 -4
  70. package/dist/cli/{sessions-NOLZ4NAQ.js → sessions-VZJ23U7E.js} +5 -5
  71. package/dist/cli/{settings-326S34JQ.js → settings-LJB5VZWM.js} +74 -74
  72. package/dist/cli/{settings-LEYUQDYL.mjs → settings-M5MSM7U6.mjs} +7 -7
  73. package/dist/cli/{setup-7RTEC2RE.js → setup-ASOUDNYM.js} +41 -41
  74. package/dist/cli/{setup-CNE25BAJ.mjs → setup-ZURYYFBI.mjs} +6 -6
  75. package/dist/cli/{skills-R4EC4IXL.mjs → skills-4SRVGVA6.mjs} +4 -4
  76. package/dist/cli/skills-KMGB73LN.js +28 -0
  77. package/dist/cli/{tools-BEBLJVVA.mjs → tools-UEFB5OPX.mjs} +5 -5
  78. package/dist/cli/{tools-ZVTN62JI.js → tools-UNDZCH7R.js} +50 -50
  79. package/dist/cli/update-4AZ7S666.js +28 -0
  80. package/dist/cli/{update-5JG7TQZ4.mjs → update-WUIQXM5B.mjs} +6 -6
  81. package/dist/cli/{workflow-FQVZBGT3.mjs → workflow-BCXLF24Z.mjs} +5 -5
  82. package/dist/cli/{workflow-VTDHF75U.js → workflow-FUXRNNWD.js} +15 -15
  83. package/dist/index.js +6 -6
  84. package/dist/index.mjs +3 -3
  85. package/dist/install-integrity.json +68 -68
  86. package/dist/release.d.mts +1 -1
  87. package/dist/release.d.ts +1 -1
  88. package/dist/release.js +2 -2
  89. package/dist/release.mjs +1 -1
  90. package/package.json +1 -1
  91. package/dist/cli/auth-6JUPJXSW.js +0 -31
  92. package/dist/cli/client-HAGQESNI.js +0 -20
  93. package/dist/cli/git-T5WWT3DW.js +0 -23
  94. package/dist/cli/skills-SE54MI6I.js +0 -28
  95. package/dist/cli/update-IQYOCMLG.js +0 -28
@@ -642,6 +642,8 @@ export type PostgresSchedulerRunStatusSnapshot = {
642
642
  error: string | null;
643
643
  suspension: unknown | null;
644
644
  staticPipeline: PlayStaticPipeline | null;
645
+ /** Included only when requested by the admission-projection read path. */
646
+ createdProjectionPending?: boolean;
645
647
  };
646
648
 
647
649
  type RunStatusRow = RunRow & {
@@ -651,6 +653,7 @@ type RunStatusRow = RunRow & {
651
653
  runtime_profile: string | null;
652
654
  launch_json: unknown;
653
655
  definition_scope?: string | null;
656
+ created_projection_pending?: boolean;
654
657
  suspension_json: unknown | null;
655
658
  updated_at: Date | null;
656
659
  };
@@ -17380,11 +17383,23 @@ export async function readPostgresSchedulerRunStatus(
17380
17383
  options?: Pick<PostgresSchedulerOptions, 'schema'> & {
17381
17384
  includeDetails?: boolean;
17382
17385
  includeAdmissionScope?: boolean;
17386
+ includeCreatedProjectionPending?: boolean;
17383
17387
  },
17384
17388
  ): Promise<PostgresSchedulerRunStatusSnapshot | null> {
17385
17389
  const admissionScopeSelection = options?.includeAdmissionScope
17386
- ? ", launch_json ->> 'definitionScope' AS definition_scope"
17390
+ ? ", scheduler_run.launch_json ->> 'definitionScope' AS definition_scope"
17387
17391
  : '';
17392
+ const createdProjectionJoin = options?.includeCreatedProjectionPending
17393
+ ? `LEFT JOIN ${tableName('outbox', options)} AS created_event
17394
+ ON created_event.run_id = scheduler_run.run_id
17395
+ AND created_event.event_id = $2`
17396
+ : '';
17397
+ const createdProjectionSelection = options?.includeCreatedProjectionPending
17398
+ ? ', (created_event.event_id IS NOT NULL AND created_event.delivered_at IS NULL) AS created_projection_pending'
17399
+ : '';
17400
+ const values = options?.includeCreatedProjectionPending
17401
+ ? [runId, `run-created:${runId}`]
17402
+ : [runId];
17388
17403
  if (options?.includeDetails === false) {
17389
17404
  // An admission projection gap needs lifecycle truth only. Launch, result,
17390
17405
  // suspension and error JSON may contain row/call-sized detail: never even
@@ -17403,15 +17418,20 @@ export async function readPostgresSchedulerRunStatus(
17403
17418
  | 'started_at'
17404
17419
  | 'finished_at'
17405
17420
  | 'definition_scope'
17421
+ | 'created_projection_pending'
17406
17422
  >
17407
17423
  >(
17408
17424
  `
17409
- SELECT run_id, org_id, status, play_name, graph_hash, runtime_profile,
17410
- created_at, updated_at, started_at, finished_at${admissionScopeSelection}
17411
- FROM ${tableName('runs', options)}
17412
- WHERE run_id = $1
17425
+ SELECT scheduler_run.run_id, scheduler_run.org_id, scheduler_run.status,
17426
+ scheduler_run.play_name, scheduler_run.graph_hash,
17427
+ scheduler_run.runtime_profile, scheduler_run.created_at,
17428
+ scheduler_run.updated_at, scheduler_run.started_at,
17429
+ scheduler_run.finished_at${admissionScopeSelection}${createdProjectionSelection}
17430
+ FROM ${tableName('runs', options)} AS scheduler_run
17431
+ ${createdProjectionJoin}
17432
+ WHERE scheduler_run.run_id = $1
17413
17433
  `,
17414
- [runId],
17434
+ values,
17415
17435
  );
17416
17436
  const row = result.rows[0];
17417
17437
  if (!row) return null;
@@ -17441,17 +17461,25 @@ export async function readPostgresSchedulerRunStatus(
17441
17461
  error: null,
17442
17462
  suspension: null,
17443
17463
  staticPipeline: null,
17464
+ ...(options.includeCreatedProjectionPending
17465
+ ? { createdProjectionPending: row.created_projection_pending === true }
17466
+ : {}),
17444
17467
  };
17445
17468
  }
17446
17469
  const result = await client.query<RunStatusRow>(
17447
17470
  `
17448
- SELECT run_id, org_id, status, play_name, graph_hash, runtime_profile,
17449
- launch_json, suspension_json, terminal_result_json, terminal_error_json,
17450
- runtime_timing_json, created_at, updated_at, started_at, finished_at${admissionScopeSelection}
17451
- FROM ${tableName('runs', options)}
17452
- WHERE run_id = $1
17471
+ SELECT scheduler_run.run_id, scheduler_run.org_id, scheduler_run.status,
17472
+ scheduler_run.play_name, scheduler_run.graph_hash,
17473
+ scheduler_run.runtime_profile, scheduler_run.launch_json,
17474
+ scheduler_run.suspension_json, scheduler_run.terminal_result_json,
17475
+ scheduler_run.terminal_error_json, scheduler_run.runtime_timing_json,
17476
+ scheduler_run.created_at, scheduler_run.updated_at,
17477
+ scheduler_run.started_at, scheduler_run.finished_at${admissionScopeSelection}${createdProjectionSelection}
17478
+ FROM ${tableName('runs', options)} AS scheduler_run
17479
+ ${createdProjectionJoin}
17480
+ WHERE scheduler_run.run_id = $1
17453
17481
  `,
17454
- [runId],
17482
+ values,
17455
17483
  );
17456
17484
  const row = result.rows[0] ?? null;
17457
17485
  if (!row) return null;
@@ -17487,6 +17515,9 @@ export async function readPostgresSchedulerRunStatus(
17487
17515
  : null,
17488
17516
  suspension: row.suspension_json ?? null,
17489
17517
  staticPipeline: staticPipelineFromContractSnapshot(launch.contractSnapshot),
17518
+ ...(options?.includeCreatedProjectionPending
17519
+ ? { createdProjectionPending: row.created_projection_pending === true }
17520
+ : {}),
17490
17521
  };
17491
17522
  }
17492
17523
 
@@ -19526,6 +19557,40 @@ export type RunLedgerOutboxDeliveredRow = {
19526
19557
  lagMs: number;
19527
19558
  };
19528
19559
 
19560
+ export type RunLedgerOutboxClientTrace = {
19561
+ runId: string;
19562
+ phase: string;
19563
+ priority?: 'ordinary' | 'critical';
19564
+ };
19565
+
19566
+ export type RunLedgerOutboxWithClient = <T>(
19567
+ operation: (client: PostgresSchedulerQueryClient) => Promise<T>,
19568
+ trace?: RunLedgerOutboxClientTrace,
19569
+ ) => Promise<T>;
19570
+
19571
+ function logRunLedgerOutboxSettlementFailure(input: {
19572
+ runId: string;
19573
+ eventIds: readonly string[];
19574
+ stage: 'continuation_release' | 'aborted_release' | 'failure_settlement';
19575
+ settlementError: unknown;
19576
+ deliveryError?: unknown;
19577
+ }): void {
19578
+ const errorMessage = (error: unknown) =>
19579
+ (error instanceof Error ? error.message : String(error)).slice(0, 500);
19580
+ console.error('[run-ledger-outbox.settlement_failed]', {
19581
+ runId: input.runId,
19582
+ stage: input.stage,
19583
+ eventCount: input.eventIds.length,
19584
+ eventIds: input.eventIds.slice(0, 8),
19585
+ settlementError: errorMessage(input.settlementError),
19586
+ deliveryError:
19587
+ input.deliveryError === undefined
19588
+ ? null
19589
+ : errorMessage(input.deliveryError),
19590
+ recovery: 'lease_expiry',
19591
+ });
19592
+ }
19593
+
19529
19594
  export async function dispatchRunLedgerOutboxToLedgerOnce(
19530
19595
  client: PostgresSchedulerQueryClient,
19531
19596
  input: RunLedgerOutboxDispatchInput,
@@ -19570,9 +19635,7 @@ export async function dispatchRunLedgerOutboxToLedgerThroughEvent(
19570
19635
  * network calls. Each callback owns only the claim or settlement query phase.
19571
19636
  */
19572
19637
  export async function dispatchRunLedgerOutboxToLedgerThroughEventWithClientScope(
19573
- withClient: <T>(
19574
- operation: (client: PostgresSchedulerQueryClient) => Promise<T>,
19575
- ) => Promise<T>,
19638
+ withClient: RunLedgerOutboxWithClient,
19576
19639
  input: RunLedgerOutboxDispatchInput & {
19577
19640
  targetEventId: string;
19578
19641
  maxEvents?: number;
@@ -19606,9 +19669,7 @@ type RunLedgerOutboxAuthorityScope = {
19606
19669
  };
19607
19670
 
19608
19671
  async function dispatchRunLedgerOutboxThroughEventWithScope(
19609
- withClient: <T>(
19610
- operation: (client: PostgresSchedulerQueryClient) => Promise<T>,
19611
- ) => Promise<T>,
19672
+ withClient: RunLedgerOutboxWithClient,
19612
19673
  input: RunLedgerOutboxDispatchInput & {
19613
19674
  targetEventId: string;
19614
19675
  maxEvents?: number;
@@ -19745,9 +19806,7 @@ async function dispatchRunLedgerOutboxThroughEventWithScope(
19745
19806
  * background projector use this exact implementation.
19746
19807
  */
19747
19808
  export async function dispatchRunLedgerOutboxToLedgerBatchOnceWithClientScope(
19748
- withClient: <T>(
19749
- operation: (client: PostgresSchedulerQueryClient) => Promise<T>,
19750
- ) => Promise<T>,
19809
+ withClient: RunLedgerOutboxWithClient,
19751
19810
  input: RunLedgerOutboxDispatchInput & { waitForRunLock?: boolean },
19752
19811
  options?: Pick<PostgresSchedulerOptions, 'schema'>,
19753
19812
  ): Promise<PostgresSchedulerOutboxProjectionResult> {
@@ -19761,9 +19820,7 @@ export async function dispatchRunLedgerOutboxToLedgerBatchOnceWithClientScope(
19761
19820
  }
19762
19821
 
19763
19822
  async function dispatchRunLedgerOutboxBatchWithScope(
19764
- withClient: <T>(
19765
- operation: (client: PostgresSchedulerQueryClient) => Promise<T>,
19766
- ) => Promise<T>,
19823
+ withClient: RunLedgerOutboxWithClient,
19767
19824
  input: RunLedgerOutboxDispatchInput & { waitForRunLock?: boolean },
19768
19825
  options?: Pick<PostgresSchedulerOptions, 'schema'>,
19769
19826
  scope?: RunLedgerOutboxDrainScope,
@@ -19788,14 +19845,31 @@ async function dispatchRunLedgerOutboxBatchWithScope(
19788
19845
  const releasePendingContinuation = async () => {
19789
19846
  const nextClaimed = continuation.current?.nextClaimed ?? [];
19790
19847
  if (nextClaimed.length === 0) return;
19791
- await withClient((client) =>
19792
- releasePostgresSchedulerOutboxLease(
19793
- client,
19794
- nextClaimed.map((event) => event.eventId),
19795
- { ...options, leaseOwner },
19796
- ),
19797
- );
19798
- nextClaimed.length = 0;
19848
+ const eventIds = nextClaimed.map((event) => event.eventId);
19849
+ try {
19850
+ await withClient(
19851
+ (client) =>
19852
+ releasePostgresSchedulerOutboxLease(client, eventIds, {
19853
+ ...options,
19854
+ leaseOwner,
19855
+ }),
19856
+ {
19857
+ runId: continuation.current?.runId ?? nextClaimed[0]!.runId,
19858
+ phase: 'run_ledger_outbox_lease_release',
19859
+ priority: 'critical',
19860
+ },
19861
+ );
19862
+ nextClaimed.length = 0;
19863
+ } catch (settlementError) {
19864
+ // Keep the in-memory claim visible to this drain and let its durable
19865
+ // lease expire if even critical pool admission cannot settle it.
19866
+ logRunLedgerOutboxSettlementFailure({
19867
+ runId: continuation.current?.runId ?? nextClaimed[0]!.runId,
19868
+ eventIds,
19869
+ stage: 'continuation_release',
19870
+ settlementError,
19871
+ });
19872
+ }
19799
19873
  };
19800
19874
  const claimEvents = async (client: PostgresSchedulerQueryClient) => {
19801
19875
  // The checkout is exclusive. Hold the existing scheduler run's row lock
@@ -20497,13 +20571,31 @@ async function dispatchRunLedgerOutboxBatchWithScope(
20497
20571
  // projection attempt or scheduling backoff, and wake the durable
20498
20572
  // projector. If the append already reached the ledger, the projector's
20499
20573
  // replay carries the same idempotency key and is a no-op there.
20500
- const released = await withClient((client) =>
20501
- releasePostgresSchedulerOutboxLease(
20502
- client,
20503
- events.map((event) => event.eventId),
20504
- { ...options, leaseOwner },
20505
- ),
20506
- );
20574
+ const eventIds = events.map((event) => event.eventId);
20575
+ let released: string[];
20576
+ try {
20577
+ released = await withClient(
20578
+ (client) =>
20579
+ releasePostgresSchedulerOutboxLease(client, eventIds, {
20580
+ ...options,
20581
+ leaseOwner,
20582
+ }),
20583
+ {
20584
+ runId: events[0]!.runId,
20585
+ phase: 'run_ledger_outbox_lease_release',
20586
+ priority: 'critical',
20587
+ },
20588
+ );
20589
+ } catch (settlementError) {
20590
+ logRunLedgerOutboxSettlementFailure({
20591
+ runId: events[0]!.runId,
20592
+ eventIds,
20593
+ stage: 'aborted_release',
20594
+ settlementError,
20595
+ deliveryError: error,
20596
+ });
20597
+ released = eventIds;
20598
+ }
20507
20599
  return {
20508
20600
  attempted: events.length,
20509
20601
  projected: 0,
@@ -20515,22 +20607,34 @@ async function dispatchRunLedgerOutboxBatchWithScope(
20515
20607
  };
20516
20608
  }
20517
20609
  if (error instanceof DeferredRuntimeProjectionInputError) {
20518
- const outcome = await withClient((client) =>
20519
- settlePostgresSchedulerOutboxFailure(client, error.eventId, error, {
20520
- ...options,
20521
- leaseOwner,
20522
- }),
20610
+ const outcome = await withClient(
20611
+ (client) =>
20612
+ settlePostgresSchedulerOutboxFailure(client, error.eventId, error, {
20613
+ ...options,
20614
+ leaseOwner,
20615
+ }),
20616
+ {
20617
+ runId: events[0]!.runId,
20618
+ phase: 'run_ledger_outbox_failure_settlement',
20619
+ priority: 'critical',
20620
+ },
20523
20621
  );
20524
20622
  // Earlier facts may already be indexed. Only the invalid immutable row
20525
20623
  // is quarantined; valid predecessors remain deliverable in causal order.
20526
- const released = await withClient((client) =>
20527
- releasePostgresSchedulerOutboxLease(
20528
- client,
20529
- events
20530
- .filter((event) => event.eventId !== error.eventId)
20531
- .map((event) => event.eventId),
20532
- { ...options, leaseOwner },
20533
- ),
20624
+ const released = await withClient(
20625
+ (client) =>
20626
+ releasePostgresSchedulerOutboxLease(
20627
+ client,
20628
+ events
20629
+ .filter((event) => event.eventId !== error.eventId)
20630
+ .map((event) => event.eventId),
20631
+ { ...options, leaseOwner },
20632
+ ),
20633
+ {
20634
+ runId: events[0]!.runId,
20635
+ phase: 'run_ledger_outbox_lease_release',
20636
+ priority: 'critical',
20637
+ },
20534
20638
  );
20535
20639
  const failed = outcome === 'blocked' ? [error.eventId] : [];
20536
20640
  const retrying =
@@ -20550,52 +20654,79 @@ async function dispatchRunLedgerOutboxBatchWithScope(
20550
20654
  retryingEventIds: retrying,
20551
20655
  };
20552
20656
  }
20553
- const settlement = await withClient(async (client) => {
20554
- await client.query('BEGIN');
20555
- try {
20556
- const blocked: string[] = [];
20557
- const retrying: string[] = [];
20558
- const ownedRetrying: string[] = [];
20559
- for (const event of events) {
20560
- const outcome = await settlePostgresSchedulerOutboxFailure(
20561
- client,
20562
- event.eventId,
20563
- error,
20564
- { ...options, leaseOwner },
20565
- );
20566
- if (outcome === 'blocked') blocked.push(event.eventId);
20567
- else retrying.push(event.eventId);
20568
- if (outcome === 'retrying') ownedRetrying.push(event.eventId);
20569
- }
20570
- // All members of this failed append must become due together. Keep
20571
- // the existing per-row retry policy, taking its latest deadline only
20572
- // for rows this owner actually settled, before releasing their locks.
20573
- if (ownedRetrying.length > 1) {
20574
- await client.query(
20575
- `
20576
- WITH retry AS (
20577
- SELECT max(next_attempt_at) AS retry_at
20578
- FROM ${tableName('outbox', options)}
20579
- WHERE event_id = ANY($1::text[])
20580
- AND delivered_at IS NULL AND failed_at IS NULL
20581
- )
20582
- UPDATE ${tableName('outbox', options)} AS outbox
20583
- SET next_attempt_at = retry.retry_at
20584
- FROM retry
20585
- WHERE outbox.event_id = ANY($1::text[])
20586
- AND outbox.delivered_at IS NULL AND outbox.failed_at IS NULL
20587
- AND retry.retry_at IS NOT NULL
20588
- `,
20589
- [ownedRetrying],
20590
- );
20591
- }
20592
- await client.query('COMMIT');
20593
- return { blocked, retrying };
20594
- } catch (settlementError) {
20595
- await client.query('ROLLBACK');
20596
- throw settlementError;
20597
- }
20598
- });
20657
+ let settlement: { blocked: string[]; retrying: string[] };
20658
+ try {
20659
+ settlement = await withClient(
20660
+ async (client) => {
20661
+ await client.query('BEGIN');
20662
+ try {
20663
+ const blocked: string[] = [];
20664
+ const retrying: string[] = [];
20665
+ const ownedRetrying: string[] = [];
20666
+ for (const event of events) {
20667
+ const outcome = await settlePostgresSchedulerOutboxFailure(
20668
+ client,
20669
+ event.eventId,
20670
+ error,
20671
+ { ...options, leaseOwner },
20672
+ );
20673
+ if (outcome === 'blocked') blocked.push(event.eventId);
20674
+ else retrying.push(event.eventId);
20675
+ if (outcome === 'retrying') ownedRetrying.push(event.eventId);
20676
+ }
20677
+ // Keep every member of a failed append on the same retry deadline.
20678
+ if (ownedRetrying.length > 1) {
20679
+ await client.query(
20680
+ `
20681
+ WITH retry AS (
20682
+ SELECT max(next_attempt_at) AS retry_at
20683
+ FROM ${tableName('outbox', options)}
20684
+ WHERE event_id = ANY($1::text[])
20685
+ AND delivered_at IS NULL AND failed_at IS NULL
20686
+ )
20687
+ UPDATE ${tableName('outbox', options)} AS outbox
20688
+ SET next_attempt_at = retry.retry_at
20689
+ FROM retry
20690
+ WHERE outbox.event_id = ANY($1::text[])
20691
+ AND outbox.delivered_at IS NULL AND outbox.failed_at IS NULL
20692
+ AND retry.retry_at IS NOT NULL
20693
+ `,
20694
+ [ownedRetrying],
20695
+ );
20696
+ }
20697
+ await client.query('COMMIT');
20698
+ return { blocked, retrying };
20699
+ } catch (settlementError) {
20700
+ await client.query('ROLLBACK');
20701
+ throw settlementError;
20702
+ }
20703
+ },
20704
+ {
20705
+ runId: events[0]!.runId,
20706
+ phase: 'run_ledger_outbox_failure_settlement',
20707
+ priority: 'critical',
20708
+ },
20709
+ );
20710
+ } catch (settlementError) {
20711
+ // The delivery error is already known. If the critical settlement
20712
+ // retry also fails, durable lease expiry remains the recovery path.
20713
+ logRunLedgerOutboxSettlementFailure({
20714
+ runId: events[0]!.runId,
20715
+ eventIds: events.map((event) => event.eventId),
20716
+ stage: 'failure_settlement',
20717
+ settlementError,
20718
+ deliveryError: error,
20719
+ });
20720
+ return {
20721
+ attempted: events.length,
20722
+ projected: 0,
20723
+ eventIds: [],
20724
+ failed: 0,
20725
+ failedEventIds: [],
20726
+ retrying: events.length,
20727
+ retryingEventIds: events.map((event) => event.eventId),
20728
+ };
20729
+ }
20599
20730
  const failure = runLedgerDeliveryFailure({ error });
20600
20731
  console.warn('[run-ledger-outbox.batch_dispatch_failed]', {
20601
20732
  runId: input.runId ?? null,
@@ -15,10 +15,10 @@ import {
15
15
  readPostgresSchedulerOutboxNextDueAt,
16
16
  type PostgresSchedulerOptions,
17
17
  type PostgresSchedulerOutboxProjectionResult,
18
- type PostgresSchedulerQueryClient,
19
18
  type RunLedgerOutboxDeliveredRow,
20
19
  type RunLedgerOutboxHeadPriority,
21
20
  type RunLedgerOutboxTokenAuthority,
21
+ type RunLedgerOutboxWithClient,
22
22
  } from './postgres';
23
23
  import {
24
24
  acquirePgNotifyHub,
@@ -561,9 +561,7 @@ export type RunCreatedInlineDeliveryOutcome =
561
561
  */
562
562
  export async function deliverRunCreatedOutboxEventInline(input: {
563
563
  runId: string;
564
- withClient: <T>(
565
- operation: (client: PostgresSchedulerQueryClient) => Promise<T>,
566
- ) => Promise<T>;
564
+ withClient: RunLedgerOutboxWithClient;
567
565
  schedulerOptions?: Pick<PostgresSchedulerOptions, 'schema'>;
568
566
  tokenAuthority: RunLedgerOutboxTokenAuthority;
569
567
  deadlineMs?: number;
@@ -9,11 +9,11 @@ import {
9
9
  registerAuthCommands,
10
10
  reportSetupCompleted,
11
11
  resolvePendingAuthClaimForResume
12
- } from "./chunk-GQISQAAZ.mjs";
13
- import "./chunk-6AUI2MS4.mjs";
14
- import "./chunk-BFGSCAZ7.mjs";
12
+ } from "./chunk-V4WVYW3G.mjs";
13
+ import "./chunk-AIIVF62D.mjs";
14
+ import "./chunk-GHYU5YWJ.mjs";
15
15
  import "./chunk-DLIRSHV6.mjs";
16
- import "./chunk-NXOML2N6.mjs";
16
+ import "./chunk-A4UUUINX.mjs";
17
17
  import "./chunk-NXGCO4JB.mjs";
18
18
  import "./chunk-WZYKRD7T.mjs";
19
19
  import "./chunk-KRD6H754.mjs";
@@ -0,0 +1,31 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+ var _chunkOTAGK5MSjs = require('./chunk-OTAGK5MS.js');
13
+ require('./chunk-NRIVXKMQ.js');
14
+ require('./chunk-AAZBNN6N.js');
15
+ require('./chunk-XNYIZMNQ.js');
16
+ require('./chunk-GXYR7DV4.js');
17
+ require('./chunk-7P5AA3SN.js');
18
+ require('./chunk-OG64RBAC.js');
19
+ require('./chunk-COGTRVWW.js');
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+ exports.EXIT_WORKSPACE_MISMATCH = _chunkOTAGK5MSjs.EXIT_WORKSPACE_MISMATCH; exports.clearPendingClaim = _chunkOTAGK5MSjs.clearPendingClaim; exports.clearSatisfiedPendingClaim = _chunkOTAGK5MSjs.clearSatisfiedPendingClaim; exports.handleRegister = _chunkOTAGK5MSjs.handleRegister; exports.handleStatus = _chunkOTAGK5MSjs.handleStatus; exports.handleWait = _chunkOTAGK5MSjs.handleWait; exports.readPendingAuthClaim = _chunkOTAGK5MSjs.readPendingAuthClaim; exports.registerAuthCommands = _chunkOTAGK5MSjs.registerAuthCommands; exports.reportSetupCompleted = _chunkOTAGK5MSjs.reportSetupCompleted; exports.resolvePendingAuthClaimForResume = _chunkOTAGK5MSjs.resolvePendingAuthClaimForResume;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DeeplineClient,
3
3
  iterateCursorPages
4
- } from "./chunk-Z3RMVRCQ.mjs";
4
+ } from "./chunk-S6XS2ABF.mjs";
5
5
  import "./chunk-CBVIJSHF.mjs";
6
6
  import {
7
7
  createTimestampedName,
@@ -9,13 +9,13 @@ import {
9
9
  openInBrowser,
10
10
  printCommandEnvelope,
11
11
  shouldEmitJson
12
- } from "./chunk-6AUI2MS4.mjs";
12
+ } from "./chunk-AIIVF62D.mjs";
13
13
  import {
14
14
  AuthError,
15
15
  ConfigError
16
- } from "./chunk-BFGSCAZ7.mjs";
16
+ } from "./chunk-GHYU5YWJ.mjs";
17
17
  import "./chunk-DLIRSHV6.mjs";
18
- import "./chunk-NXOML2N6.mjs";
18
+ import "./chunk-A4UUUINX.mjs";
19
19
  import "./chunk-GVUJJJ5G.mjs";
20
20
  import {
21
21
  DeeplineError