deepline 0.3.312 → 0.3.314

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 (101) hide show
  1. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  2. package/dist/bundling-sources/shared_libs/play-runtime/play-run-recovery-policy.ts +50 -0
  3. package/dist/bundling-sources/shared_libs/play-runtime/run-event-query.ts +15 -2
  4. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-launch-transport.ts +210 -2
  5. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +226 -14
  6. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +4 -18
  7. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +5 -0
  8. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +126 -51
  9. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +11 -6
  10. package/dist/cli/{auth-ACDTPM3M.mjs → auth-GWF55S3N.mjs} +4 -4
  11. package/dist/cli/auth-QX2L4LPM.js +31 -0
  12. package/dist/cli/{billing-YTJFHEGU.js → billing-2YU6E2IF.js} +70 -70
  13. package/dist/cli/{billing-FVBBJ77L.mjs → billing-WWOJN7GV.mjs} +4 -4
  14. package/dist/cli/{chunk-WPTUKXIF.mjs → chunk-25SPKKF2.mjs} +1 -1
  15. package/dist/cli/{chunk-MK4K5MQU.mjs → chunk-2Q2IKUL5.mjs} +3 -3
  16. package/dist/cli/{chunk-EHVJ7XXD.mjs → chunk-3A4LJUX6.mjs} +2 -2
  17. package/dist/cli/{chunk-ENSDO4SG.mjs → chunk-3CKNUJVZ.mjs} +4 -4
  18. package/dist/cli/{chunk-AA66YTS7.mjs → chunk-3K6QD7Z3.mjs} +1 -1
  19. package/dist/cli/{chunk-TID5XLTZ.js → chunk-B5LUKLKH.js} +4 -4
  20. package/dist/cli/{chunk-I25C4KL7.mjs → chunk-CPN2N6EZ.mjs} +7 -6
  21. package/dist/cli/{chunk-GTEDCRKC.mjs → chunk-DR3S76BG.mjs} +1 -1
  22. package/dist/cli/{chunk-QFSLMI42.js → chunk-ENQZV7NR.js} +221 -220
  23. package/dist/cli/{chunk-BRJOVSTH.js → chunk-GSRDZD7R.js} +2 -2
  24. package/dist/cli/{chunk-6OGNRAS7.mjs → chunk-HTXZLCSP.mjs} +2 -2
  25. package/dist/cli/{chunk-NWFE4PGX.mjs → chunk-IZTIBG7A.mjs} +13 -3
  26. package/dist/cli/{chunk-V7N6BJQD.js → chunk-JNUHGWB2.js} +50 -50
  27. package/dist/cli/{chunk-OV6IFAXH.mjs → chunk-JZZT4GAY.mjs} +5 -5
  28. package/dist/cli/{chunk-ULI6UVV6.js → chunk-MLEJ2FYH.js} +212 -202
  29. package/dist/cli/{chunk-6KKETQSI.js → chunk-NG4WDOGN.js} +6 -6
  30. package/dist/cli/{chunk-6LLJWMYH.js → chunk-ODEWOXWW.js} +6 -6
  31. package/dist/cli/{chunk-NMZPK7LM.mjs → chunk-OUHCJL5B.mjs} +1 -1
  32. package/dist/cli/{chunk-ZH7KTVAB.mjs → chunk-QB5MAFCU.mjs} +1 -1
  33. package/dist/cli/{chunk-VJDKV5RU.js → chunk-UZTTPEG2.js} +6 -6
  34. package/dist/cli/{chunk-FQVTHBEH.js → chunk-VBRO5QCI.js} +15 -15
  35. package/dist/cli/{chunk-ZQJDRSR5.js → chunk-VFRZG4OW.js} +1 -1
  36. package/dist/cli/{chunk-7SW43OAX.js → chunk-VWW6VHQX.js} +60 -60
  37. package/dist/cli/{chunk-YYU3PYVK.js → chunk-WDPRE6DU.js} +48 -48
  38. package/dist/cli/{chunk-NJNYWVEF.mjs → chunk-WTO3ITBC.mjs} +2 -2
  39. package/dist/cli/{chunk-T4IJQKRE.js → chunk-YVMJTXEG.js} +26 -26
  40. package/dist/cli/{client-ENGOMTTU.mjs → client-EYGNDORT.mjs} +3 -3
  41. package/dist/cli/client-Z4VFNTUB.js +20 -0
  42. package/dist/cli/{csv-ENKTPYAJ.mjs → csv-NZCN7SVV.mjs} +3 -3
  43. package/dist/cli/{csv-6WOJC6NZ.js → csv-YOW5JMOH.js} +12 -12
  44. package/dist/cli/{db-BAEVP4QK.js → db-6BIYLZ6F.js} +20 -20
  45. package/dist/cli/{db-DSCJZYJU.mjs → db-HALJV3KY.mjs} +4 -4
  46. package/dist/cli/{describe-PAUHJF7H.mjs → describe-KY2ZYGBR.mjs} +8 -8
  47. package/dist/cli/{describe-X2AFAC4B.js → describe-WA6R2JSH.js} +15 -15
  48. package/dist/cli/{executions-R6JOR67D.mjs → executions-CBOAN6KI.mjs} +4 -4
  49. package/dist/cli/{executions-LXS6NLCV.js → executions-NMCTN7XM.js} +6 -6
  50. package/dist/cli/{feedback-CYRVNCGT.mjs → feedback-FOMPE3DJ.mjs} +3 -3
  51. package/dist/cli/{feedback-HXP2D7K6.js → feedback-ZZFDSCWS.js} +6 -6
  52. package/dist/cli/git-AC2ATBDK.js +23 -0
  53. package/dist/cli/{git-XBYBZB4R.mjs → git-YQR2NBCO.mjs} +4 -4
  54. package/dist/cli/index.js +74 -74
  55. package/dist/cli/index.mjs +31 -31
  56. package/dist/cli/{legacy-noops-OQP6VZKE.mjs → legacy-noops-KMU6P3K4.mjs} +4 -4
  57. package/dist/cli/{legacy-noops-AUNAFEZP.js → legacy-noops-XH2TFFI6.js} +7 -7
  58. package/dist/cli/{monitors-L2HAAPAL.mjs → monitors-2ONK5L3I.mjs} +4 -4
  59. package/dist/cli/{monitors-QSIZG3CJ.js → monitors-5M3BZ5OR.js} +85 -85
  60. package/dist/cli/{org-JUHQGBQE.js → org-6MKULUZI.js} +60 -60
  61. package/dist/cli/{org-UCSN5XRC.mjs → org-LR5BMCGL.mjs} +4 -4
  62. package/dist/cli/{play-5AT2RB3M.mjs → play-4NOSD7DW.mjs} +7 -7
  63. package/dist/cli/play-U3CZ4F2W.js +152 -0
  64. package/dist/cli/{providers-GVPAPZ4L.mjs → providers-UBGIKGCA.mjs} +4 -4
  65. package/dist/cli/{providers-CVG4L3VR.js → providers-UFJD3VKF.js} +7 -7
  66. package/dist/cli/{quickstart-Y6ZU27LE.mjs → quickstart-KDUKQRUH.mjs} +3 -3
  67. package/dist/cli/{quickstart-7OIFIQG3.js → quickstart-KQZHZE6C.js} +5 -5
  68. package/dist/cli/{search-4I2Y2NKK.mjs → search-4BVOOS5Q.mjs} +5 -5
  69. package/dist/cli/search-Y7OTFRCI.js +26 -0
  70. package/dist/cli/{secrets-O2UFLU52.js → secrets-TVXZ3WJ3.js} +13 -13
  71. package/dist/cli/{secrets-3Z4IUEBA.mjs → secrets-YGV23N3N.mjs} +4 -4
  72. package/dist/cli/{sessions-OMAXRY5I.mjs → sessions-G7ROUW35.mjs} +4 -4
  73. package/dist/cli/{sessions-T6MWWQRH.js → sessions-RWIQWDFD.js} +5 -5
  74. package/dist/cli/{settings-C47WXZY5.mjs → settings-QZEVGCXE.mjs} +7 -7
  75. package/dist/cli/{settings-R4LO5NMY.js → settings-TG3E2NR7.js} +74 -74
  76. package/dist/cli/{setup-FIUTV4DD.js → setup-3KDUNEEE.js} +41 -41
  77. package/dist/cli/{setup-JPJVTIQ6.mjs → setup-HUXINKOH.mjs} +6 -6
  78. package/dist/cli/skills-CO5YUWBK.js +28 -0
  79. package/dist/cli/{skills-6WVTMKP5.mjs → skills-LHU3DB7J.mjs} +4 -4
  80. package/dist/cli/{tools-TKS77TNU.mjs → tools-J5WQ33BB.mjs} +6 -6
  81. package/dist/cli/tools-MWPT5X47.js +38 -0
  82. package/dist/cli/{update-GD754XMA.mjs → update-T6744RM7.mjs} +6 -6
  83. package/dist/cli/update-VVIJW7ZJ.js +28 -0
  84. package/dist/cli/{workflow-YKQSPXQZ.mjs → workflow-CG2B65HD.mjs} +5 -5
  85. package/dist/cli/{workflow-OCUQCNXA.js → workflow-YF5SQJLG.js} +15 -15
  86. package/dist/index.js +6 -6
  87. package/dist/index.mjs +3 -3
  88. package/dist/install-integrity.json +74 -74
  89. package/dist/release.d.mts +1 -1
  90. package/dist/release.d.ts +1 -1
  91. package/dist/release.js +2 -2
  92. package/dist/release.mjs +1 -1
  93. package/package.json +1 -1
  94. package/dist/cli/auth-TFDGA24W.js +0 -31
  95. package/dist/cli/client-T6YGH6TT.js +0 -20
  96. package/dist/cli/git-JOE2RM3Q.js +0 -23
  97. package/dist/cli/play-2SNMTZGK.js +0 -152
  98. package/dist/cli/search-DS36UHOX.js +0 -26
  99. package/dist/cli/skills-GLPKPF7R.js +0 -28
  100. package/dist/cli/tools-L3YLQ7BR.js +0 -38
  101. package/dist/cli/update-HXI35NME.js +0 -28
@@ -1,4 +1,7 @@
1
- import { createDaytonaLaunchClient } from './daytona-launch-transport';
1
+ import {
2
+ createDaytonaLaunchClient,
3
+ redactDaytonaErrorDetail,
4
+ } from './daytona-launch-transport';
2
5
  import type { DaytonaClientOptions } from '../../daytona-runtime-config';
3
6
  import {
4
7
  createDaytonaControlClient,
@@ -328,23 +331,6 @@ function numberProperty(value: unknown, key: string): number | null {
328
331
  : null;
329
332
  }
330
333
 
331
- function redactDaytonaErrorDetail(value: string): string {
332
- return value
333
- .replace(
334
- /authorization\s*[=:]\s*bearer\s+[^\s,;]+/gi,
335
- 'Authorization=Bearer [redacted]',
336
- )
337
- .replace(
338
- /(authorization\s*[=:]\s*)(?!bearer\s+\[redacted\])[^\s,;]+/gi,
339
- '$1[redacted]',
340
- )
341
- .replace(/(bearer\s+)[^\s,;]+/gi, '$1[redacted]')
342
- .replace(/((?:api[_-]?key|token)\s*[=:]\s*)[^\s,;]+/gi, '$1[redacted]')
343
- .replace(/\s+/g, ' ')
344
- .trim()
345
- .slice(0, 1_000);
346
- }
347
-
348
334
  /**
349
335
  * Preserve the actionable shape of a Daytona control-plane failure without
350
336
  * copying credentials or an arbitrarily large upstream response into logs.
@@ -48,6 +48,7 @@ import { RUNTIME_RELIABILITY_POLICY } from '../runtime-reliability-policy';
48
48
  import type { RuntimeTrafficPolicy } from '../runtime-traffic-policy';
49
49
  import { runtimeLimitExceededCause } from '../run-failure';
50
50
  import {
51
+ playRunRecoveryLogDetail,
51
52
  recoveryForDaytonaSandboxAcquisitionUnavailable,
52
53
  recoveryForRuntimeInitializationTransportFailure,
53
54
  recoveryForRuntimeSchedulerAdmissionFailure,
@@ -4359,6 +4360,9 @@ async function executeAssignedAbsurdAttempt(input: {
4359
4360
  }),
4360
4361
  );
4361
4362
  if (recovery.kind === 'deferred') {
4363
+ // Log-only. The persisted reason groups several provider conditions
4364
+ // into one decision; the detail names the one that was observed.
4365
+ const detail = playRunRecoveryLogDetail(recoveryError);
4362
4366
  console.warn('[absurd-runtime.worker] pre_code_recovery_deferred', {
4363
4367
  runId,
4364
4368
  generation,
@@ -4367,6 +4371,7 @@ async function executeAssignedAbsurdAttempt(input: {
4367
4371
  deferCount: recovery.deferCount,
4368
4372
  deadlineAtMs: recovery.deadlineAtMs,
4369
4373
  delaySeconds: recovery.delaySeconds,
4374
+ ...(detail ? { detail } : {}),
4370
4375
  });
4371
4376
  throw new DeferTask(
4372
4377
  `Platform recovery deferred for ${recovery.dependency}: ${recovery.reason}`,
@@ -354,8 +354,10 @@ const POSTGRES_SCHEDULER_SCHEMA_INIT_STATEMENT_TIMEOUT_MS = 60_000;
354
354
  // v60 indexes all sandbox leases by Run, including released custody history.
355
355
  // v61 adds an operator-owned new-run projection cutover and admission pin.
356
356
  // Existing namespace mode values and unpinned runs keep their behavior.
357
+ // v62 adds a deploy-owned index for per-run active outbox lease exclusion.
358
+ // Failed facts remain indexed: their live leases still fence the run.
357
359
  // This marker records deployment work, never a runtime schema floor.
358
- export const POSTGRES_SCHEDULER_SCHEMA_VERSION = 61;
360
+ export const POSTGRES_SCHEDULER_SCHEMA_VERSION = 62;
359
361
  const POSTGRES_SCHEDULER_SCHEMA_MIGRATIONS_TABLE =
360
362
  'scheduler_schema_migrations';
361
363
  export const POSTGRES_SCHEDULER_OPEN_RECOVERY_INDEX =
@@ -1986,6 +1988,15 @@ export async function hasCurrentPostgresSchedulerSchemaShape(
1986
1988
  AND index_row.indrelid = to_regclass($3)
1987
1989
  AND index_row.indisready AND index_row.indisvalid
1988
1990
  )
1991
+ AND EXISTS (
1992
+ SELECT 1 FROM pg_index AS index_row
1993
+ JOIN pg_class AS index_class ON index_class.oid = index_row.indexrelid
1994
+ JOIN pg_namespace AS index_namespace ON index_namespace.oid = index_class.relnamespace
1995
+ WHERE index_namespace.nspname = $1
1996
+ AND index_class.relname = 'runtime_scheduler_outbox_run_lease_idx'
1997
+ AND index_row.indrelid = to_regclass($3)
1998
+ AND index_row.indisready AND index_row.indisvalid
1999
+ )
1989
2000
  AND EXISTS (
1990
2001
  SELECT 1 FROM pg_index AS index_row
1991
2002
  JOIN pg_class AS index_class ON index_class.oid = index_row.indexrelid
@@ -4018,6 +4029,11 @@ export async function ensurePostgresSchedulerSchema(
4018
4029
  )
4019
4030
  WHERE delivered_at IS NULL AND ${searchLaneSql('outbox')} = true
4020
4031
  `);
4032
+ await client.query(`
4033
+ CREATE INDEX IF NOT EXISTS runtime_scheduler_outbox_run_lease_idx
4034
+ ON ${tableName('outbox', options)} (run_id, lease_expires_at)
4035
+ WHERE delivered_at IS NULL AND lease_owner IS NOT NULL
4036
+ `);
4021
4037
  await client.query(`
4022
4038
  CREATE INDEX IF NOT EXISTS runtime_scheduler_outbox_lease_health_idx
4023
4039
  ON ${tableName('outbox', options)}
@@ -4194,6 +4210,12 @@ const POSTGRES_SCHEDULER_RUNTIME_ADMIN_INDEXES = [
4194
4210
  created_at, event_id)
4195
4211
  WHERE delivered_at IS NULL AND ${searchLaneSql('outbox')} = true`,
4196
4212
  },
4213
+ {
4214
+ name: 'runtime_scheduler_outbox_run_lease_idx',
4215
+ table: 'outbox',
4216
+ definition: `(run_id, lease_expires_at)
4217
+ WHERE delivered_at IS NULL AND lease_owner IS NOT NULL`,
4218
+ },
4197
4219
  {
4198
4220
  name: 'runtime_scheduler_outbox_lease_health_idx',
4199
4221
  table: 'outbox',
@@ -17982,8 +18004,11 @@ function runLedgerPrecedesSql(
17982
18004
  predecessor: string,
17983
18005
  successor: string,
17984
18006
  inclusive = false,
18007
+ searchOnly?: boolean,
17985
18008
  ): string {
17986
- return `(${searchLaneSql(predecessor)} = ${searchLaneSql(successor)} AND ${runLedgerPositionSql(predecessor)} ${inclusive ? '<=' : '<'} ${runLedgerPositionSql(successor)})`;
18009
+ const lane =
18010
+ searchOnly === undefined ? searchLaneSql(successor) : String(searchOnly);
18011
+ return `(${searchLaneSql(predecessor)} = ${lane} AND ${runLedgerPositionSql(predecessor)} ${inclusive ? '<=' : '<'} ${runLedgerPositionSql(successor)})`;
17987
18012
  }
17988
18013
 
17989
18014
  function searchLaneSql(alias: string): string {
@@ -18014,30 +18039,28 @@ function runLedgerTerminalPendingSql(
18014
18039
  )`;
18015
18040
  }
18016
18041
 
18017
- function runLedgerWaitingRunsSql(
18042
+ function runLedgerWaitingPendingSql(
18043
+ alias: string,
18018
18044
  options?: Pick<PostgresSchedulerOptions, 'schema'>,
18019
- runIdParameter?: string,
18045
+ runIdSql = `${alias}.run_id`,
18020
18046
  ): string {
18021
- return `SELECT DISTINCT waiting_event.run_id
18047
+ return `EXISTS (SELECT 1
18022
18048
  FROM ${tableName('outbox', options)} AS waiting_event
18023
- WHERE waiting_event.event_type = ${RUN_EVENT_KIND_SQL_LITERAL.runWaiting}
18049
+ WHERE waiting_event.run_id = ${runIdSql}
18050
+ AND waiting_event.event_type = ${RUN_EVENT_KIND_SQL_LITERAL.runWaiting}
18024
18051
  -- Detached runner parks are transport-only and project no public wait.
18025
18052
  AND waiting_event.payload_json->>'kind' IS DISTINCT FROM 'detached_runner'
18026
18053
  AND waiting_event.delivered_at IS NULL
18027
18054
  AND waiting_event.failed_at IS NULL
18028
- AND coalesce(waiting_event.next_attempt_at, waiting_event.created_at) <= now()
18029
- ${runIdParameter ? `AND (${runIdParameter}::text IS NULL OR waiting_event.run_id = ${runIdParameter}::text)` : ''}`;
18030
- }
18031
-
18032
- function runLedgerWaitingPendingSql(alias: string): string {
18033
- return `(${alias}.run_id IN (SELECT run_id FROM waiting_runs))`;
18055
+ AND coalesce(waiting_event.next_attempt_at, waiting_event.created_at) <= now())`;
18034
18056
  }
18035
18057
 
18036
18058
  function runLedgerUrgentLifecyclePendingSql(
18037
18059
  alias: string,
18038
18060
  options?: Pick<PostgresSchedulerOptions, 'schema'>,
18061
+ runIdSql?: string,
18039
18062
  ): string {
18040
- return `(${runLedgerTerminalPendingSql(alias, options)} OR ${runLedgerWaitingPendingSql(alias)})`;
18063
+ return `(${runLedgerTerminalPendingSql(alias, options)} OR ${runLedgerWaitingPendingSql(alias, options, runIdSql)})`;
18041
18064
  }
18042
18065
 
18043
18066
  /**
@@ -18111,7 +18134,14 @@ async function claimPostgresSchedulerOutboxPrefix(
18111
18134
  const urgentLifecyclePendingSql = (alias: string) =>
18112
18135
  input.searchOnly === true
18113
18136
  ? runLedgerTerminalPendingSql(alias, options)
18114
- : runLedgerUrgentLifecyclePendingSql(alias, options);
18137
+ : runLedgerUrgentLifecyclePendingSql(
18138
+ alias,
18139
+ options,
18140
+ // Every claimed row belongs to the selected run. An independent
18141
+ // wait probe evaluates once, instead of scanning its backlog for
18142
+ // each row whose delivery batch is being frozen.
18143
+ runId !== null ? '$2::text' : undefined,
18144
+ );
18115
18145
  // Search is locally indexed and acknowledged; it has no remote ingress
18116
18146
  // receipt to freeze. Preserve causal ordering/due/lease checks, but admit
18117
18147
  // its full prefix instead of inheriting lifecycle's singleton transport.
@@ -18121,6 +18151,20 @@ async function claimPostgresSchedulerOutboxPrefix(
18121
18151
  : supportsTerminalBatchMarker && input.allowIngressPrefix === true
18122
18152
  ? `(head.event_type = ${RUN_SCHEDULER_OUTBOX_EVENT_TYPE_SQL_LITERAL.runEvents})`
18123
18153
  : 'false';
18154
+ const findSearchBlockersOnce = seekRunHead && input.searchOnly === true;
18155
+ const blockingPredecessorSql = (alias: string) => `(
18156
+ (${alias}.event_type = ${RUN_SCHEDULER_OUTBOX_EVENT_TYPE_SQL_LITERAL.runEvents}
18157
+ AND NOT (${ingressPrefixSql}))
18158
+ OR (${supportsTerminalBatchMarker && input.allowIngressPrefix === true ? `head.delivery_batch_started_at IS NOT NULL AND ${alias}.delivery_batch_started_at IS NULL` : 'false'})
18159
+ OR ${alias}.failed_at IS NOT NULL
18160
+ OR coalesce(${alias}.next_attempt_at, ${alias}.created_at) > now()
18161
+ OR (
18162
+ $3::text IS NOT NULL
18163
+ AND ${alias}.lease_expires_at IS NOT NULL
18164
+ AND ${alias}.lease_expires_at > now()
18165
+ AND ${alias}.lease_owner IS DISTINCT FROM $3::text
18166
+ )
18167
+ )`;
18124
18168
  return await client.query<{
18125
18169
  row_kind: 'claimed' | 'delivered';
18126
18170
  event_id: string;
@@ -18139,12 +18183,6 @@ async function claimPostgresSchedulerOutboxPrefix(
18139
18183
  ),`
18140
18184
  : ''
18141
18185
  } ${
18142
- input.searchOnly === true
18143
- ? ''
18144
- : `waiting_runs AS MATERIALIZED (
18145
- ${runLedgerWaitingRunsSql(options, '$2')}
18146
- ), `
18147
- }${
18148
18186
  seekRunHead
18149
18187
  ? `pending_head AS MATERIALIZED (
18150
18188
  SELECT pending.event_id
@@ -18169,6 +18207,7 @@ async function claimPostgresSchedulerOutboxPrefix(
18169
18207
  : ''
18170
18208
  } head AS MATERIALIZED (
18171
18209
  SELECT candidate.event_id, candidate.run_id, candidate.event_type,
18210
+ ${findSearchBlockersOnce ? 'candidate.created_at,' : ''}
18172
18211
  ${supportsTerminalBatchMarker ? 'candidate.delivery_batch_started_at' : 'NULL::timestamptz'} AS delivery_batch_started_at
18173
18212
  FROM ${tableName('outbox', options)} AS candidate
18174
18213
  ${seekRunHead ? 'JOIN pending_head ON pending_head.event_id = candidate.event_id' : ''}
@@ -18207,7 +18246,7 @@ async function claimPostgresSchedulerOutboxPrefix(
18207
18246
  SELECT 1 FROM ${tableName('outbox', options)} AS active
18208
18247
  WHERE active.run_id = candidate.run_id
18209
18248
  AND ${pending('active')}
18210
- AND ${searchLaneSql('active')} = ${searchLaneSql('candidate')}
18249
+ AND ${searchLaneSql('active')} = ${input.searchOnly === true ? 'true' : 'false'}
18211
18250
  AND active.lease_owner IS NOT NULL
18212
18251
  AND active.lease_expires_at > now()
18213
18252
  AND active.lease_owner IS DISTINCT FROM $3::text
@@ -18223,7 +18262,7 @@ async function claimPostgresSchedulerOutboxPrefix(
18223
18262
  FROM ${tableName('outbox', options)} AS predecessor
18224
18263
  WHERE predecessor.run_id = candidate.run_id
18225
18264
  AND ${pending('predecessor')}
18226
- AND ${runLedgerPrecedesSql('predecessor', 'candidate')}
18265
+ AND ${runLedgerPrecedesSql('predecessor', 'candidate', false, input.searchOnly === true)}
18227
18266
  )`
18228
18267
  }
18229
18268
  -- A new durable admission has no causal dependency on unrelated
@@ -18234,23 +18273,62 @@ async function claimPostgresSchedulerOutboxPrefix(
18234
18273
  -- predecessors. Giving priority only to a terminal head leaves a
18235
18274
  -- finished run's earlier progress behind unrelated progress. The
18236
18275
  -- predecessor checks still forbid skipping any fact within the run.
18237
- ORDER BY
18276
+ ${
18277
+ runId !== null
18278
+ ? ''
18279
+ : `ORDER BY
18238
18280
  CASE
18239
18281
  WHEN candidate.event_type = ${RUN_EVENT_KIND_SQL_LITERAL.runCreated} THEN 0
18240
18282
  WHEN ${runLedgerTerminalPendingSql('candidate', options)} THEN 1
18241
- ${input.searchOnly === true ? '' : `WHEN ${runLedgerWaitingPendingSql('candidate')} THEN 2`}
18283
+ ${input.searchOnly === true ? '' : `WHEN ${runLedgerWaitingPendingSql('candidate', options)} THEN 2`}
18242
18284
  ELSE 3
18243
18285
  END,
18244
18286
  coalesce(candidate.next_attempt_at, candidate.created_at),
18245
18287
  candidate.created_at,
18246
- candidate.event_id
18288
+ candidate.event_id`
18289
+ }
18247
18290
  FOR UPDATE SKIP LOCKED
18248
18291
  LIMIT 1
18249
- ), candidates AS MATERIALIZED (
18292
+ ), ${
18293
+ findSearchBlockersOnce
18294
+ ? `first_blocker AS MATERIALIZED (
18295
+ SELECT predecessor.event_type, predecessor.created_at, predecessor.event_id
18296
+ FROM ${tableName('outbox', options)} AS predecessor
18297
+ JOIN head ON head.run_id = predecessor.run_id
18298
+ WHERE predecessor.run_id = $2::text
18299
+ AND ${pending('predecessor')}
18300
+ AND ${searchLaneSql('predecessor')} = true
18301
+ -- The oldest pending head passed eligibility above. Only later
18302
+ -- facts can introduce an ordinary blocker for this prefix.
18303
+ AND ${runLedgerPositionSql('predecessor')} > (
18304
+ (SELECT CASE head.event_type WHEN ${RUN_EVENT_KIND_SQL_LITERAL.runCreated} THEN 0 WHEN ${RUN_EVENT_KIND_SQL_LITERAL.runStarted} THEN 1 ELSE 2 END FROM head),
18305
+ (SELECT head.created_at FROM head),
18306
+ (SELECT head.event_id FROM head)
18307
+ )
18308
+ AND ${blockingPredecessorSql('predecessor')}
18309
+ ORDER BY ${runLedgerOrderSql('predecessor')}
18310
+ LIMIT 1
18311
+ ), first_started_terminal AS MATERIALIZED (
18312
+ SELECT terminal_predecessor.event_type, terminal_predecessor.created_at, terminal_predecessor.event_id
18313
+ FROM ${tableName('outbox', options)} AS terminal_predecessor
18314
+ JOIN head ON head.run_id = terminal_predecessor.run_id
18315
+ WHERE terminal_predecessor.run_id = $2::text
18316
+ AND ${pending('terminal_predecessor')}
18317
+ AND ${searchLaneSql('terminal_predecessor')} = true
18318
+ AND ${supportsTerminalBatchMarker ? 'terminal_predecessor.delivery_batch_started_at IS NOT NULL' : 'false'}
18319
+ AND terminal_predecessor.event_type IN (
18320
+ ${RUN_EVENT_KIND_SQL_LITERAL.runCompleted}, ${RUN_EVENT_KIND_SQL_LITERAL.runFailed}, ${RUN_EVENT_KIND_SQL_LITERAL.runCancelled}
18321
+ )
18322
+ ORDER BY ${runLedgerOrderSql('terminal_predecessor')}
18323
+ LIMIT 1
18324
+ ),`
18325
+ : ''
18326
+ }candidates AS MATERIALIZED (
18250
18327
  SELECT outbox.event_id
18251
18328
  FROM ${tableName('outbox', options)} AS outbox
18252
18329
  JOIN head ON head.run_id = outbox.run_id
18253
18330
  WHERE ${pending('outbox')}
18331
+ ${runId !== null ? 'AND outbox.run_id = $2::text' : ''}
18254
18332
  AND ${searchLaneSql('outbox')} = ${input.searchOnly === true ? 'true' : 'false'}
18255
18333
  AND outbox.failed_at IS NULL
18256
18334
  -- Admission is causally first and must be projected alone. A later
@@ -18284,7 +18362,20 @@ async function claimPostgresSchedulerOutboxPrefix(
18284
18362
  -- that the replay included a new event. A terminal which has not
18285
18363
  -- started a batch yet remains an ordinary causal event and can be
18286
18364
  -- claimed with its existing contiguous prefix.
18365
+ ${
18366
+ findSearchBlockersOnce
18367
+ ? `-- Each cutoff reads this run's blockers once, even when stale
18368
+ -- statistics make a broad pending scan look cheaper than a seek.
18369
+ AND NOT EXISTS (
18370
+ SELECT 1 FROM first_started_terminal AS blocker
18371
+ WHERE ${supportsTerminalBatchMarker ? 'outbox.delivery_batch_started_at IS NULL' : 'true'}
18372
+ AND ${runLedgerPositionSql('blocker')} < ${runLedgerPositionSql('outbox')}
18373
+ )
18287
18374
  AND NOT EXISTS (
18375
+ SELECT 1 FROM first_blocker AS blocker
18376
+ WHERE ${runLedgerPositionSql('blocker')} < ${runLedgerPositionSql('outbox')}
18377
+ )`
18378
+ : ` AND NOT EXISTS (
18288
18379
  SELECT 1
18289
18380
  FROM ${tableName('outbox', options)} AS terminal_predecessor
18290
18381
  WHERE terminal_predecessor.run_id = outbox.run_id
@@ -18302,7 +18393,7 @@ async function claimPostgresSchedulerOutboxPrefix(
18302
18393
  AND terminal_predecessor.event_type IN (
18303
18394
  ${RUN_EVENT_KIND_SQL_LITERAL.runCompleted}, ${RUN_EVENT_KIND_SQL_LITERAL.runFailed}, ${RUN_EVENT_KIND_SQL_LITERAL.runCancelled}
18304
18395
  )
18305
- AND ${runLedgerPrecedesSql('terminal_predecessor', 'outbox')}
18396
+ AND ${runLedgerPrecedesSql('terminal_predecessor', 'outbox', false, input.searchOnly === true)}
18306
18397
  )
18307
18398
  -- Claim only the contiguous due prefix. A delayed, leased, or failed
18308
18399
  -- predecessor retains ownership of everything that follows it.
@@ -18311,21 +18402,11 @@ async function claimPostgresSchedulerOutboxPrefix(
18311
18402
  FROM ${tableName('outbox', options)} AS predecessor
18312
18403
  WHERE predecessor.run_id = outbox.run_id
18313
18404
  AND ${pending('predecessor')}
18314
- AND ${runLedgerPrecedesSql('predecessor', 'outbox')}
18315
- AND (
18316
- (predecessor.event_type = ${RUN_SCHEDULER_OUTBOX_EVENT_TYPE_SQL_LITERAL.runEvents}
18317
- AND NOT (${ingressPrefixSql}))
18318
- OR (${supportsTerminalBatchMarker && input.allowIngressPrefix === true ? 'head.delivery_batch_started_at IS NOT NULL AND predecessor.delivery_batch_started_at IS NULL' : 'false'})
18319
- OR predecessor.failed_at IS NOT NULL
18320
- OR coalesce(predecessor.next_attempt_at, predecessor.created_at) > now()
18321
- OR (
18322
- $3::text IS NOT NULL
18323
- AND predecessor.lease_expires_at IS NOT NULL
18324
- AND predecessor.lease_expires_at > now()
18325
- AND predecessor.lease_owner IS DISTINCT FROM $3::text
18326
- )
18327
- )
18405
+ AND ${runLedgerPrecedesSql('predecessor', 'outbox', false, input.searchOnly === true)}
18406
+ AND ${blockingPredecessorSql('predecessor')}
18328
18407
  )
18408
+ `
18409
+ }
18329
18410
  ORDER BY ${runLedgerOrderSql('outbox')}
18330
18411
  FOR UPDATE OF outbox
18331
18412
  LIMIT $1
@@ -20021,7 +20102,7 @@ async function dispatchRunLedgerOutboxBatchWithScope(
20021
20102
  SELECT pending.run_id,
20022
20103
  pending.event_id,
20023
20104
  pending.event_type,
20024
- pending.payload_json,
20105
+ ${needsLaunch ? 'pending.payload_json,' : ''}
20025
20106
  pending.created_at,
20026
20107
  pending.next_attempt_at,
20027
20108
  pending.failed_at
@@ -20055,18 +20136,12 @@ async function dispatchRunLedgerOutboxBatchWithScope(
20055
20136
  run_id: string;
20056
20137
  dispatch_launch_json: unknown;
20057
20138
  }>(`
20058
- WITH ${
20059
- input.searchOnly === true
20060
- ? ''
20061
- : `waiting_runs AS MATERIALIZED (
20062
- ${runLedgerWaitingRunsSql(options)}
20063
- ), `
20064
- }heads AS MATERIALIZED (
20139
+ WITH heads AS MATERIALIZED (
20065
20140
  SELECT DISTINCT ON (pending.run_id)
20066
20141
  pending.run_id,
20067
20142
  pending.event_id,
20068
20143
  pending.event_type,
20069
- pending.payload_json,
20144
+ ${needsLaunch ? 'pending.payload_json,' : ''}
20070
20145
  pending.created_at,
20071
20146
  pending.next_attempt_at,
20072
20147
  pending.failed_at
@@ -20098,7 +20173,7 @@ async function dispatchRunLedgerOutboxBatchWithScope(
20098
20173
  : `CASE
20099
20174
  WHEN head.event_type = ${RUN_EVENT_KIND_SQL_LITERAL.runCreated} THEN 0
20100
20175
  WHEN ${runLedgerTerminalPendingSql('head', options)} THEN 1
20101
- ${input.searchOnly === true ? '' : `WHEN ${runLedgerWaitingPendingSql('head')} THEN 2`}
20176
+ ${input.searchOnly === true ? '' : `WHEN ${runLedgerWaitingPendingSql('head', options)} THEN 2`}
20102
20177
  ELSE 3
20103
20178
  END,`
20104
20179
  }
@@ -345,6 +345,7 @@ export function startRunLedgerOutboxRecovery(
345
345
  const pendingObservability = new Set<symbol>();
346
346
  const deliveries: Delivery[] = [];
347
347
  let refill = false;
348
+ let observabilityRefill = false;
348
349
  let dispatchFailed = false;
349
350
  let completed = 0;
350
351
  let attempted = 0;
@@ -420,11 +421,7 @@ export function startRunLedgerOutboxRecovery(
420
421
  // cannot consume a notification that arrived after its query began.
421
422
  if (canProbeObservability()) {
422
423
  observabilityRequested = false;
423
- while (
424
- pendingObservability.size < observabilityParallelism &&
425
- pending.size < parallelism
426
- )
427
- launch(true);
424
+ launch(true);
428
425
  }
429
426
  if (canProbeLifecycle()) {
430
427
  requested = false;
@@ -432,6 +429,14 @@ export function startRunLedgerOutboxRecovery(
432
429
  }
433
430
  // Productive completion permits immediate use of every free slot.
434
431
  // Empty results grant no refill, so idle work cannot spin on scans.
432
+ if (observabilityRefill) {
433
+ while (
434
+ pendingObservability.size < observabilityParallelism &&
435
+ pending.size < parallelism
436
+ )
437
+ launch(true);
438
+ observabilityRefill = false;
439
+ }
435
440
  if (refill) {
436
441
  while (
437
442
  pending.size < parallelism &&
@@ -477,7 +482,7 @@ export function startRunLedgerOutboxRecovery(
477
482
  // Retryable rows own durable retry clocks. The SQL claim keeps their
478
483
  // run ordered while successful slots keep unrelated runs moving.
479
484
  if (delivery.observability) {
480
- if (result.attempted > 0) observabilityRequested = true;
485
+ observabilityRefill = result.attempted > 0;
481
486
  } else refill = result.attempted > 0;
482
487
  }
483
488
  };
@@ -9,11 +9,11 @@ import {
9
9
  registerAuthCommands,
10
10
  reportSetupCompleted,
11
11
  resolvePendingAuthClaimForResume
12
- } from "./chunk-6OGNRAS7.mjs";
13
- import "./chunk-ZH7KTVAB.mjs";
14
- import "./chunk-WPTUKXIF.mjs";
12
+ } from "./chunk-HTXZLCSP.mjs";
13
+ import "./chunk-QB5MAFCU.mjs";
14
+ import "./chunk-25SPKKF2.mjs";
15
15
  import "./chunk-DLIRSHV6.mjs";
16
- import "./chunk-AA66YTS7.mjs";
16
+ import "./chunk-3K6QD7Z3.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 _chunkWDPRE6DUjs = require('./chunk-WDPRE6DU.js');
13
+ require('./chunk-ODEWOXWW.js');
14
+ require('./chunk-B5LUKLKH.js');
15
+ require('./chunk-XNYIZMNQ.js');
16
+ require('./chunk-VFRZG4OW.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 = _chunkWDPRE6DUjs.EXIT_WORKSPACE_MISMATCH; exports.clearPendingClaim = _chunkWDPRE6DUjs.clearPendingClaim; exports.clearSatisfiedPendingClaim = _chunkWDPRE6DUjs.clearSatisfiedPendingClaim; exports.handleRegister = _chunkWDPRE6DUjs.handleRegister; exports.handleStatus = _chunkWDPRE6DUjs.handleStatus; exports.handleWait = _chunkWDPRE6DUjs.handleWait; exports.readPendingAuthClaim = _chunkWDPRE6DUjs.readPendingAuthClaim; exports.registerAuthCommands = _chunkWDPRE6DUjs.registerAuthCommands; exports.reportSetupCompleted = _chunkWDPRE6DUjs.reportSetupCompleted; exports.resolvePendingAuthClaimForResume = _chunkWDPRE6DUjs.resolvePendingAuthClaimForResume;