deepline 0.3.88 → 0.3.90

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 (280) hide show
  1. package/contracts/install-commands.json +29 -0
  2. package/dist/bundling-sources/sdk/src/client.ts +652 -39
  3. package/dist/bundling-sources/sdk/src/config.ts +77 -0
  4. package/dist/bundling-sources/sdk/src/http.ts +76 -30
  5. package/dist/bundling-sources/sdk/src/index.ts +10 -0
  6. package/dist/bundling-sources/sdk/src/monitor-fleet-contract.ts +1 -1
  7. package/dist/bundling-sources/sdk/src/pagination.ts +25 -0
  8. package/dist/bundling-sources/sdk/src/play.ts +15 -1
  9. package/dist/bundling-sources/sdk/src/plays/bundle-play-file.ts +3 -3
  10. package/dist/bundling-sources/sdk/src/release.ts +16 -9
  11. package/dist/bundling-sources/sdk/src/types.ts +106 -4
  12. package/dist/bundling-sources/shared_libs/integration-contracts/AGENTS.md +9 -0
  13. package/dist/bundling-sources/shared_libs/integration-contracts/README.md +3 -0
  14. package/dist/bundling-sources/shared_libs/integration-contracts/index.ts +2 -0
  15. package/dist/bundling-sources/shared_libs/monitors/analytics-install-guides.ts +77 -0
  16. package/dist/bundling-sources/shared_libs/monitors/analytics-public.ts +10 -0
  17. package/dist/bundling-sources/shared_libs/monitors/billing/charges.ts +125 -0
  18. package/dist/bundling-sources/shared_libs/monitors/billing/policy-builders.ts +686 -0
  19. package/dist/bundling-sources/shared_libs/monitors/billing/pricing.ts +54 -0
  20. package/dist/bundling-sources/shared_libs/monitors/billing/public-pricing.ts +72 -0
  21. package/dist/bundling-sources/shared_libs/monitors/billing/session.ts +45 -0
  22. package/dist/bundling-sources/shared_libs/monitors/billing/state.ts +454 -0
  23. package/dist/bundling-sources/shared_libs/monitors/billing/tamradar.ts +260 -0
  24. package/dist/bundling-sources/shared_libs/monitors/billing/types.ts +215 -0
  25. package/dist/bundling-sources/shared_libs/monitors/callback-security.ts +333 -0
  26. package/dist/bundling-sources/shared_libs/monitors/cursor-page.ts +42 -0
  27. package/dist/bundling-sources/shared_libs/monitors/deactivation-reasons.ts +16 -0
  28. package/dist/bundling-sources/shared_libs/monitors/framework-managed-payload-fields.ts +71 -0
  29. package/dist/bundling-sources/shared_libs/monitors/generated/provider-monitor-callback-admission-targets.ts +16 -0
  30. package/dist/bundling-sources/shared_libs/monitors/http-error-response.ts +270 -0
  31. package/dist/bundling-sources/shared_libs/monitors/inbound-publish-key.ts +39 -0
  32. package/dist/bundling-sources/shared_libs/monitors/inbound-queue.ts +82 -0
  33. package/dist/bundling-sources/shared_libs/monitors/inventory-reconciliation.ts +59 -0
  34. package/dist/bundling-sources/shared_libs/monitors/lifecycle-notifications.ts +471 -0
  35. package/dist/bundling-sources/shared_libs/monitors/org-monitor-limits.ts +1 -1
  36. package/dist/bundling-sources/shared_libs/monitors/package.json +36 -0
  37. package/dist/bundling-sources/shared_libs/monitors/provider-callback-verification.ts +1125 -0
  38. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +305 -0
  39. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-capability.ts +964 -0
  40. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-consumer-health.ts +56 -0
  41. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-errors.ts +131 -0
  42. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-identity-claims.ts +535 -0
  43. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-legacy-aliases.ts +16 -0
  44. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-priority-execution.ts +56 -0
  45. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-public-aliases.ts +28 -0
  46. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-runtime-read-eligibility.ts +38 -0
  47. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-state.ts +122 -0
  48. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-status.ts +10 -0
  49. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-upstream-identity.ts +112 -0
  50. package/dist/bundling-sources/shared_libs/monitors/provider-webhook-monitor-runtime.ts +300 -0
  51. package/dist/bundling-sources/shared_libs/monitors/quickstart-prompts.ts +22 -0
  52. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-dead-letter.ts +245 -0
  53. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-message.ts +38 -0
  54. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-queue-ack-probe.ts +94 -0
  55. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-queue-delivery.ts +60 -0
  56. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-queue.ts +60 -0
  57. package/dist/bundling-sources/shared_libs/monitors/snitcher-install-validation.ts +93 -0
  58. package/dist/bundling-sources/shared_libs/monitors/snitcher-ip2company.ts +332 -0
  59. package/dist/bundling-sources/shared_libs/monitors/snitcher-radar.ts +221 -0
  60. package/dist/bundling-sources/shared_libs/monitors/starter-templates.ts +105 -0
  61. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +73 -0
  62. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-integrations.ts +81 -0
  63. package/dist/bundling-sources/shared_libs/monitors/tsconfig.json +10 -0
  64. package/dist/bundling-sources/shared_libs/observability/build-context.ts +13 -0
  65. package/dist/bundling-sources/shared_libs/observability/log-metadata.ts +160 -0
  66. package/dist/bundling-sources/shared_libs/observability/request-context.ts +68 -0
  67. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +654 -0
  68. package/dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts +35 -0
  69. package/dist/bundling-sources/shared_libs/observability/scheduled-work.ts +5 -0
  70. package/dist/bundling-sources/shared_libs/play-data-plane/neon-constants.ts +9 -0
  71. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +272 -0
  72. package/dist/bundling-sources/shared_libs/play-runtime/activity-observation.ts +6 -11
  73. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +135 -12
  74. package/dist/bundling-sources/shared_libs/play-runtime/async-operation.ts +66 -1
  75. package/dist/bundling-sources/shared_libs/play-runtime/async-play-invocation.ts +77 -0
  76. package/dist/bundling-sources/shared_libs/play-runtime/bounceban-batching.ts +137 -0
  77. package/dist/bundling-sources/shared_libs/play-runtime/checkpoint-boundaries.ts +70 -0
  78. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +1159 -166
  79. package/dist/bundling-sources/shared_libs/play-runtime/coordinator-headers.ts +1 -32
  80. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +103 -0
  81. package/dist/bundling-sources/shared_libs/play-runtime/daytona-payload-contract.ts +68 -0
  82. package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-janitor.ts +103 -0
  83. package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-reaper.ts +725 -0
  84. package/dist/bundling-sources/shared_libs/play-runtime/default-batch-strategies.ts +20 -1
  85. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +29 -0
  86. package/dist/bundling-sources/shared_libs/play-runtime/execution-capabilities.ts +29 -0
  87. package/dist/bundling-sources/shared_libs/play-runtime/execution-gateway-invocation-fence.ts +442 -0
  88. package/dist/bundling-sources/shared_libs/play-runtime/execution-protocol.ts +7 -1
  89. package/dist/bundling-sources/shared_libs/play-runtime/fixture-behavior.ts +18 -0
  90. package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +9 -0
  91. package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +1 -1
  92. package/dist/bundling-sources/shared_libs/play-runtime/governor/rate-state-backend.ts +1 -1
  93. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/contracts.ts +66 -0
  94. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/job.ts +145 -0
  95. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/ports.ts +21 -0
  96. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/postgres-store.ts +170 -0
  97. package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +1322 -0
  98. package/dist/bundling-sources/shared_libs/play-runtime/internal-step-ids.ts +2 -2
  99. package/dist/bundling-sources/shared_libs/play-runtime/lane-retirement-gate.ts +189 -0
  100. package/dist/bundling-sources/shared_libs/play-runtime/launch-source-policy.ts +112 -0
  101. package/dist/bundling-sources/shared_libs/play-runtime/map-execution-frame.ts +8 -0
  102. package/dist/bundling-sources/shared_libs/play-runtime/perf-trace.ts +127 -0
  103. package/dist/bundling-sources/shared_libs/play-runtime/play-artifact-runtime-contract.ts +5 -0
  104. package/dist/bundling-sources/shared_libs/play-runtime/play-run-recovery-policy.ts +24 -1
  105. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/contracts.ts +56 -0
  106. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/index.ts +13 -0
  107. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/job.ts +41 -0
  108. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/ports.ts +17 -0
  109. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/postgres-adapter.ts +54 -0
  110. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/contracts.ts +114 -0
  111. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/engine-suspension.ts +108 -0
  112. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/index.ts +36 -0
  113. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/job.ts +97 -0
  114. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/ports.ts +104 -0
  115. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/postgres-fence-adapter.ts +263 -0
  116. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/worker-terminal-projection.ts +64 -0
  117. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/contracts.ts +29 -0
  118. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/gateway-adapter.ts +56 -0
  119. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/index.ts +15 -0
  120. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/job.ts +65 -0
  121. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/ports.ts +17 -0
  122. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/contracts.ts +42 -0
  123. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/index.ts +17 -0
  124. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/job.ts +142 -0
  125. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/ports.ts +42 -0
  126. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/postgres-adapter.ts +102 -0
  127. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/contracts.ts +60 -0
  128. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/index.ts +16 -0
  129. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/job.ts +78 -0
  130. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/ports.ts +54 -0
  131. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/postgres-adapter.ts +71 -0
  132. package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-batching-registry.ts +4 -0
  133. package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-semantics.ts +28 -0
  134. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +4 -0
  135. package/dist/bundling-sources/shared_libs/play-runtime/receipt-status.ts +5 -8
  136. package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +23 -2
  137. package/dist/bundling-sources/shared_libs/play-runtime/run-identity.ts +168 -0
  138. package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +1 -1
  139. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +90 -13
  140. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +6 -12
  141. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-start-admission.ts +68 -0
  142. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +21 -0
  143. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/bundle.ts +0 -1
  144. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/runtime-sandbox-reconciliation.ts +14 -43
  145. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +67 -213
  146. package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +201 -0
  147. package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +20 -0
  148. package/dist/bundling-sources/shared_libs/play-runtime/runtime-contract.ts +6 -0
  149. package/dist/bundling-sources/shared_libs/play-runtime/runtime-env.ts +12 -0
  150. package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +67 -0
  151. package/dist/bundling-sources/shared_libs/play-runtime/runtime-release-environment.ts +2 -0
  152. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sandbox-contract.ts +68 -0
  153. package/dist/bundling-sources/shared_libs/play-runtime/runtime-scheduler-topology.ts +38 -2
  154. package/dist/bundling-sources/shared_libs/play-runtime/runtime-telemetry.ts +108 -0
  155. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/contract.ts +4 -0
  156. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +3 -0
  157. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +37 -1
  158. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-deadline-reconciliation.ts +88 -0
  159. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-deploy-task.ts +124 -0
  160. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-run-task.ts +68 -0
  161. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +193 -0
  162. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-queue-lifecycle.ts +269 -0
  163. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-queue-suffix.ts +73 -0
  164. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +6642 -0
  165. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +897 -0
  166. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-metrics.ts +120 -0
  167. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-required-env.ts +76 -0
  168. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd.ts +476 -0
  169. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-heavy-request-admission.ts +47 -0
  170. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-progress-registry.ts +147 -0
  171. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/index.ts +27 -0
  172. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/lazy.ts +50 -0
  173. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/play-run-recovery.ts +98 -0
  174. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-budget-state.ts +260 -0
  175. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-pool.ts +1416 -0
  176. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +1255 -0
  177. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +942 -0
  178. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +14636 -0
  179. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-gateway.ts +888 -0
  180. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +355 -0
  181. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-terminal-transition.ts +46 -0
  182. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runner-push.ts +60 -0
  183. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-api-origin.ts +33 -0
  184. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-receipt-gateway-health.ts +64 -0
  185. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +835 -0
  186. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-ledger-reconciliation.ts +1218 -0
  187. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-operation.ts +207 -0
  188. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-scheduler-schema.ts +10 -0
  189. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/scheduler-capacity.ts +123 -0
  190. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/scheduler-launch-read-observability.ts +78 -0
  191. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/submit-admission.ts +169 -0
  192. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/terminal-contract.ts +20 -0
  193. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/worker-queue-metrics.ts +34 -0
  194. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/worker-resource-metrics.ts +249 -0
  195. package/dist/bundling-sources/shared_libs/play-runtime/sheet-attempt-sql.ts +7 -0
  196. package/dist/bundling-sources/shared_libs/play-runtime/step-progress.ts +296 -0
  197. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/native-batch.ts +3 -3
  198. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/runtime-step-receipts-adapter.ts +20 -1
  199. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +60 -15
  200. package/dist/bundling-sources/shared_libs/play-runtime/tool-execution-outcome.ts +20 -0
  201. package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +1 -1
  202. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +1 -1
  203. package/dist/bundling-sources/shared_libs/play-runtime/transient-service-error.ts +12 -0
  204. package/dist/bundling-sources/shared_libs/play-runtime/vercel-protection.ts +14 -1
  205. package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-storage-contract.ts +165 -0
  206. package/dist/bundling-sources/shared_libs/play-runtime/work-receipts.ts +15 -23
  207. package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +169 -0
  208. package/dist/bundling-sources/shared_libs/play-runtime/zerobounce-batching.ts +122 -0
  209. package/dist/bundling-sources/shared_libs/plays/artifact-types.ts +8 -3
  210. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +454 -17
  211. package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +19 -4
  212. package/dist/bundling-sources/shared_libs/plays/contracts.ts +8 -14
  213. package/dist/bundling-sources/shared_libs/plays/core.ts +11 -6
  214. package/dist/bundling-sources/shared_libs/plays/deployment-status.ts +1 -1
  215. package/dist/bundling-sources/shared_libs/plays/docflow-binding-owner.ts +16 -11
  216. package/dist/bundling-sources/shared_libs/plays/docflow.ts +1 -1
  217. package/dist/bundling-sources/shared_libs/plays/email-status.ts +1 -1
  218. package/dist/bundling-sources/shared_libs/plays/play-grep-search.ts +39 -0
  219. package/dist/bundling-sources/shared_libs/plays/resolve-static-pipeline.ts +1 -1
  220. package/dist/bundling-sources/shared_libs/plays/share/copy.ts +271 -0
  221. package/dist/bundling-sources/shared_libs/plays/share/metrics.ts +140 -0
  222. package/dist/bundling-sources/shared_libs/plays/share/public-read-model.ts +86 -0
  223. package/dist/bundling-sources/shared_libs/plays/share/seo-quality.ts +181 -0
  224. package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +658 -0
  225. package/dist/bundling-sources/shared_libs/plays/share/types.ts +197 -0
  226. package/dist/bundling-sources/shared_libs/plays/slack-hitl-timeout-error.ts +37 -0
  227. package/dist/bundling-sources/shared_libs/plays/slug.ts +115 -0
  228. package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +50 -15
  229. package/dist/bundling-sources/shared_libs/plays/tool-category-descriptions.ts +2 -2
  230. package/dist/bundling-sources/shared_libs/plays/tool-result-types.ts +1 -1
  231. package/dist/bundling-sources/shared_libs/product-notifications/catalog.ts +877 -0
  232. package/dist/bundling-sources/shared_libs/product-notifications/configuration-draft.ts +456 -0
  233. package/dist/bundling-sources/shared_libs/product-notifications/configuration.ts +566 -0
  234. package/dist/bundling-sources/shared_libs/product-notifications/content.ts +28 -0
  235. package/dist/bundling-sources/shared_libs/product-notifications/default-policy.ts +60 -0
  236. package/dist/bundling-sources/shared_libs/product-notifications/email.ts +246 -0
  237. package/dist/bundling-sources/shared_libs/product-notifications/evaluation.ts +280 -0
  238. package/dist/bundling-sources/shared_libs/product-notifications/events.ts +433 -0
  239. package/dist/bundling-sources/shared_libs/product-notifications/legacy-slack.ts +80 -0
  240. package/dist/bundling-sources/shared_libs/product-notifications/overflow.ts +18 -0
  241. package/dist/bundling-sources/shared_libs/product-notifications/rolling-limit.ts +24 -0
  242. package/dist/bundling-sources/shared_libs/product-notifications/slack-delivery.ts +624 -0
  243. package/dist/bundling-sources/shared_libs/product-notifications/slack-payload.ts +140 -0
  244. package/dist/bundling-sources/shared_libs/product-notifications/slack-transport.ts +75 -0
  245. package/dist/bundling-sources/shared_libs/product-notifications/workspace.ts +38 -0
  246. package/dist/bundling-sources/shared_libs/runtime-env.ts +12 -0
  247. package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +42 -0
  248. package/dist/bundling-sources/shared_libs/security/header-safe-env.ts +35 -0
  249. package/dist/bundling-sources/shared_libs/security/internal-actor.ts +50 -0
  250. package/dist/bundling-sources/shared_libs/security/secret-redaction.ts +267 -0
  251. package/dist/bundling-sources/shared_libs/security/slack-sanitize.ts +133 -0
  252. package/dist/cli/getting-started.d.mts +52 -0
  253. package/dist/cli/getting-started.d.ts +52 -0
  254. package/dist/cli/getting-started.js +65 -0
  255. package/dist/cli/getting-started.mjs +36 -0
  256. package/dist/cli/index.d.mts +9 -0
  257. package/dist/cli/index.d.ts +9 -0
  258. package/dist/cli/index.js +1611 -453
  259. package/dist/cli/index.mjs +1596 -447
  260. package/dist/{compiler-manifest-Dbov16F7.d.mts → compiler-manifest-BaJfE-5H.d.mts} +136 -10
  261. package/dist/{compiler-manifest-Dbov16F7.d.ts → compiler-manifest-BaJfE-5H.d.ts} +136 -10
  262. package/dist/index.d.mts +910 -155
  263. package/dist/index.d.ts +910 -155
  264. package/dist/index.js +550 -64
  265. package/dist/index.mjs +550 -64
  266. package/dist/install-integrity.json +193 -4
  267. package/dist/monitor-fleet-contract.d.mts +138 -0
  268. package/dist/monitor-fleet-contract.d.ts +138 -0
  269. package/dist/monitor-fleet-contract.js +404 -0
  270. package/dist/monitor-fleet-contract.mjs +367 -0
  271. package/dist/plays/bundle-play-file.d.mts +8 -3
  272. package/dist/plays/bundle-play-file.d.ts +8 -3
  273. package/dist/plays/bundle-play-file.mjs +100 -20
  274. package/dist/release.d.mts +255 -0
  275. package/dist/release.d.ts +255 -0
  276. package/dist/release.js +215 -0
  277. package/dist/release.mjs +188 -0
  278. package/package.json +23 -4
  279. /package/dist/bundling-sources/shared_libs/{integrations/bettercontact-execution-policy.ts → integration-contracts/bettercontact/execution-policy.ts} +0 -0
  280. /package/dist/bundling-sources/shared_libs/{integrations/theirstack-execution-policy.ts → integration-contracts/theirstack/execution-policy.ts} +0 -0
@@ -0,0 +1,88 @@
1
+ import { cancelPostgresSchedulerRun } from './postgres';
2
+ import type {
3
+ PostgresSchedulerOptions,
4
+ PostgresSchedulerQueryClient,
5
+ } from './postgres';
6
+ import { ABSURD_PLAY_RUN_TASK } from './absurd-shared';
7
+ import { resolveRuntimeSchedulerSchemaEnv } from './runtime-scheduler-schema';
8
+
9
+ /** Bound deadline reconciliation just like Absurd's own cancellation sweep. */
10
+ export const ABSURD_CANCELLED_DEADLINE_RECONCILE_LIMIT = 100;
11
+
12
+ function quoteAbsurdTable(table: string): string {
13
+ return `"${table.replaceAll('"', '""')}"`;
14
+ }
15
+
16
+ /**
17
+ * Project a play task cancelled by Absurd's indexed `max_delay` sweep into the
18
+ * scheduler's authoritative run state.
19
+ *
20
+ * The engine can cancel an overdue task before or after a worker claims its
21
+ * handler. A cancelled task has no handler path left to write the normal
22
+ * terminal state. This reconciler
23
+ * closes that gap: `cancelPostgresSchedulerRun` atomically writes the runtime
24
+ * terminal and its run-ledger outbox event, and is idempotent if a user cancel
25
+ * or a racing worker already terminalized the run. The next empty claim invokes
26
+ * it immediately after Absurd performs its bounded cancellation sweep.
27
+ */
28
+ export async function reconcileAbsurdRuntimeMaxDelayCancellations(input: {
29
+ client: PostgresSchedulerQueryClient;
30
+ queue: string;
31
+ schedulerOptions?: Pick<PostgresSchedulerOptions, 'schema'>;
32
+ limit?: number;
33
+ }): Promise<{ reconciled: number; skipped: number }> {
34
+ const requestedLimit = Math.floor(
35
+ input.limit ?? ABSURD_CANCELLED_DEADLINE_RECONCILE_LIMIT,
36
+ );
37
+ const limit = Number.isFinite(requestedLimit)
38
+ ? Math.max(
39
+ 1,
40
+ Math.min(ABSURD_CANCELLED_DEADLINE_RECONCILE_LIMIT, requestedLimit),
41
+ )
42
+ : ABSURD_CANCELLED_DEADLINE_RECONCILE_LIMIT;
43
+ const taskTable = quoteAbsurdTable(`t_${input.queue}`);
44
+ const schedulerSchema = quoteAbsurdTable(
45
+ input.schedulerOptions?.schema?.trim() ||
46
+ resolveRuntimeSchedulerSchemaEnv() ||
47
+ 'runtime_scheduler',
48
+ );
49
+ const cancelled = await input.client.query<{ run_id: string | null }>(
50
+ `
51
+ SELECT task.params ->> 'runId' AS run_id
52
+ FROM absurd.${taskTable} AS task
53
+ JOIN ${schedulerSchema}.runs AS run
54
+ ON run.run_id = task.params ->> 'runId'
55
+ AND run.status IN ('queued', 'running', 'waiting')
56
+ WHERE task.state = 'cancelled'
57
+ AND task.task_name = $1
58
+ AND task.cancellation ? 'max_delay'
59
+ AND task.cancel_at IS NOT NULL
60
+ AND task.cancelled_at >= task.cancel_at
61
+ ORDER BY task.cancelled_at ASC NULLS LAST, task.task_id ASC
62
+ LIMIT $2
63
+ `,
64
+ [ABSURD_PLAY_RUN_TASK, limit],
65
+ );
66
+
67
+ let reconciled = 0;
68
+ let skipped = 0;
69
+ for (const row of cancelled.rows) {
70
+ const runId = row.run_id?.trim();
71
+ if (!runId) {
72
+ skipped += 1;
73
+ continue;
74
+ }
75
+ const didCancel = await cancelPostgresSchedulerRun(
76
+ input.client,
77
+ {
78
+ runId,
79
+ reason:
80
+ 'Run did not start within its configured scheduler queue deadline.',
81
+ },
82
+ input.schedulerOptions,
83
+ );
84
+ if (didCancel) reconciled += 1;
85
+ else skipped += 1;
86
+ }
87
+ return { reconciled, skipped };
88
+ }
@@ -0,0 +1,124 @@
1
+ import type { RetryStrategy } from '@deepline/absurd/sdk';
2
+ import {
3
+ createAbsurdRuntimeClient,
4
+ resolveAbsurdPoolOptions,
5
+ resolveAbsurdQueueSuffix,
6
+ } from './absurd-shared';
7
+ import { ensureAbsurdSchema } from './postgres';
8
+ import { withRuntimeSchedulerClient } from './postgres-pool';
9
+
10
+ /**
11
+ * GitHub deploy-on-push build tasks ride their own fixed Absurd queue,
12
+ * deliberately OUTSIDE the release-lane model: builds are not versioned by
13
+ * play-runtime release, so pinning them to a `runs_<release>` lane would
14
+ * strand queued deploys on lane retirement. A plain rolling deploy of the
15
+ * deploy worker is correct.
16
+ */
17
+ export const PLAY_DEPLOY_QUEUE = 'deploys';
18
+ export const PLAY_DEPLOY_TASK_NAME = 'play-deploy';
19
+
20
+ /**
21
+ * The queue this process submits to / drains. Production and plain local
22
+ * dev use the fixed base name; a worktree/preview with
23
+ * DEEPLINE_ABSURD_QUEUE_SUFFIX gets `deploys_<suffix>` so multiple local
24
+ * stacks sharing one docker Postgres never consume each other's builds
25
+ * (Absurd partitions its engine tables BY QUEUE, same as the runs lanes).
26
+ */
27
+ export function playDeployQueueName(): string {
28
+ const suffix = resolveAbsurdQueueSuffix();
29
+ return suffix ? `${PLAY_DEPLOY_QUEUE}_${suffix}` : PLAY_DEPLOY_QUEUE;
30
+ }
31
+ export const PLAY_DEPLOY_MAX_ATTEMPTS = 5;
32
+ export const PLAY_DEPLOY_RETRY_STRATEGY: RetryStrategy = {
33
+ kind: 'exponential',
34
+ baseSeconds: 5,
35
+ maxSeconds: 60,
36
+ };
37
+ /**
38
+ * Retained deploy rows are bounded like the runs queue: a stuck or finished
39
+ * deploy task must not accumulate forever.
40
+ *
41
+ * NOTE: this queue previously set a per-org claim cap. Upstream Absurd
42
+ * removed account-level caps from queue policy (see the comment on the runs
43
+ * queue in absurd-shared.ts: parked work holds no slot and fair claim
44
+ * ordering picks the next runnable task). Build parallelism is now bounded
45
+ * by worker slots, not per-org policy. If per-org fairness is wanted again
46
+ * it has to be expressed at claim time, not here.
47
+ */
48
+ export const PLAY_DEPLOY_CLEANUP_TTL = '6 hours';
49
+ export const PLAY_DEPLOY_CLEANUP_LIMIT = 1_000;
50
+
51
+ /**
52
+ * Task payload stays tiny (32 KiB control-plane cap): the deploy token plus
53
+ * addressing. The worker fetches everything else — repo, commit, project
54
+ * settings, a GitHub installation token — from the app API with the token,
55
+ * so state is always read fresh (supersession, disabled projects).
56
+ */
57
+ export type PlayDeployTaskParams = {
58
+ deploymentId: string;
59
+ orgId: string;
60
+ playProjectId: string;
61
+ deployToken: string;
62
+ appBaseUrl: string;
63
+ };
64
+
65
+ const deployQueueReadyPromises = new Map<string, Promise<void>>();
66
+
67
+ /**
68
+ * Ensure the deploys queue exists with its policy. Idempotent per process;
69
+ * a failure evicts the memo so the next caller retries loudly. Deliberately
70
+ * NOT ensureAbsurdRuntimeReady — that helper hardcodes the runs-lane
71
+ * derivation and its policies.
72
+ */
73
+ export function ensurePlayDeployQueueReady(input?: {
74
+ url?: string | null;
75
+ schema?: string | null;
76
+ }): Promise<void> {
77
+ const poolOptions = resolveAbsurdPoolOptions(input?.url);
78
+ const schema = input?.schema?.trim() ?? '';
79
+ const queueName = playDeployQueueName();
80
+ const key = `${poolOptions.url}::${schema}::${queueName}`;
81
+ const existing = deployQueueReadyPromises.get(key);
82
+ if (existing) return existing;
83
+ const promise = (async () => {
84
+ await withRuntimeSchedulerClient(poolOptions, (client) =>
85
+ ensureAbsurdSchema(client),
86
+ );
87
+ const absurd = createAbsurdRuntimeClient(poolOptions, queueName);
88
+ const existingQueues = new Set(await absurd.listQueues());
89
+ if (!existingQueues.has(queueName)) {
90
+ await absurd.createQueue(queueName);
91
+ }
92
+ await absurd.setQueuePolicy(queueName, {
93
+ cleanupTtl: PLAY_DEPLOY_CLEANUP_TTL,
94
+ cleanupLimit: PLAY_DEPLOY_CLEANUP_LIMIT,
95
+ });
96
+ })().catch((error) => {
97
+ deployQueueReadyPromises.delete(key);
98
+ throw error;
99
+ });
100
+ deployQueueReadyPromises.set(key, promise);
101
+ return promise;
102
+ }
103
+
104
+ /**
105
+ * Enqueue one deploy build task, idempotent on the deployment id. Called by
106
+ * the webhook receiver AFTER the Convex playDeployments row exists and
107
+ * BEFORE the delivery is marked processed — a crash in between lets
108
+ * GitHub's redelivery re-run both steps safely.
109
+ */
110
+ export async function enqueuePlayDeployTask(
111
+ params: PlayDeployTaskParams,
112
+ ): Promise<void> {
113
+ const poolOptions = resolveAbsurdPoolOptions();
114
+ await ensurePlayDeployQueueReady();
115
+ const queueName = playDeployQueueName();
116
+ const absurd = createAbsurdRuntimeClient(poolOptions, queueName);
117
+ await absurd.spawn(PLAY_DEPLOY_TASK_NAME, params, {
118
+ queue: queueName,
119
+ idempotencyKey: `play-deploy:${params.deploymentId}`,
120
+ orgKey: params.orgId,
121
+ maxAttempts: PLAY_DEPLOY_MAX_ATTEMPTS,
122
+ retryStrategy: PLAY_DEPLOY_RETRY_STRATEGY,
123
+ });
124
+ }
@@ -0,0 +1,68 @@
1
+ import type { RetryStrategy } from '@deepline/absurd/sdk';
2
+ import type { PlaySchedulerSubmitInput } from '../scheduler-backend';
3
+ import { RUNTIME_RELIABILITY_POLICY } from '../runtime-reliability-policy';
4
+
5
+ export const ABSURD_PLAY_RUN_TASK = 'play-run';
6
+
7
+ export const ABSURD_PLAY_RUN_RETRY_STRATEGY: RetryStrategy = {
8
+ kind: 'exponential',
9
+ baseSeconds: RUNTIME_RELIABILITY_POLICY.engine.retryBaseSeconds,
10
+ factor: 2,
11
+ maxSeconds: RUNTIME_RELIABILITY_POLICY.engine.retryMaxSeconds,
12
+ };
13
+
14
+ export const ABSURD_PLAY_RUN_MAX_ATTEMPTS =
15
+ RUNTIME_RELIABILITY_POLICY.engine.maxAttempts;
16
+
17
+ export type AbsurdPlayRunTaskParams = {
18
+ runId: string;
19
+ orgId: string;
20
+ /**
21
+ * Retained release lanes may still validate this field before loading the
22
+ * launch row. Every newly submitted task is a root.
23
+ */
24
+ nestingDepth: number;
25
+ schedulerSchema?: string | null;
26
+ };
27
+
28
+ /**
29
+ * The one task ABI for an ordinary Play Run.
30
+ *
31
+ * Callers choose only the release queue. Task identity, fairness, retries, and
32
+ * queue-delay policy stay inside the scheduler adapter.
33
+ */
34
+ export function buildAbsurdPlayRunTask(input: {
35
+ launch: Pick<
36
+ PlaySchedulerSubmitInput,
37
+ 'runId' | 'orgId' | 'queueMaxDelaySeconds' | 'queuePriority'
38
+ >;
39
+ schedulerSchema?: string | null;
40
+ }) {
41
+ const params: AbsurdPlayRunTaskParams = {
42
+ runId: input.launch.runId,
43
+ orgId: input.launch.orgId,
44
+ nestingDepth: 0,
45
+ schedulerSchema: input.schedulerSchema ?? null,
46
+ };
47
+ const maxDelaySeconds = input.launch.queueMaxDelaySeconds;
48
+ const priority = input.launch.queuePriority;
49
+ return {
50
+ taskName: ABSURD_PLAY_RUN_TASK,
51
+ params,
52
+ options: {
53
+ idempotency_key: input.launch.runId,
54
+ org_key: input.launch.orgId,
55
+ max_attempts: ABSURD_PLAY_RUN_MAX_ATTEMPTS,
56
+ retry_strategy: {
57
+ kind: ABSURD_PLAY_RUN_RETRY_STRATEGY.kind,
58
+ base_seconds: ABSURD_PLAY_RUN_RETRY_STRATEGY.baseSeconds,
59
+ factor: ABSURD_PLAY_RUN_RETRY_STRATEGY.factor,
60
+ max_seconds: ABSURD_PLAY_RUN_RETRY_STRATEGY.maxSeconds,
61
+ },
62
+ ...(typeof priority === 'number' ? { priority } : {}),
63
+ ...(typeof maxDelaySeconds === 'number'
64
+ ? { cancellation: { max_delay: maxDelaySeconds } }
65
+ : {}),
66
+ },
67
+ };
68
+ }
@@ -0,0 +1,193 @@
1
+ /**
2
+ * Src-coupled bridge between the vendored Absurd SDK (`packages/absurd`) and
3
+ * the hardened runtime scheduler Postgres pool (`./postgres-pool.ts`).
4
+ *
5
+ * workspace packages stay free of `src/**` imports, so the Absurd client takes an
6
+ * injected `Queryable`. This module supplies that handle by delegating every
7
+ * query through `withRuntimeSchedulerClient`, which is the process-singleton
8
+ * `pg.Pool` with saturation backpressure, a circuit breaker, and idempotent
9
+ * connection-error retries. Each Absurd SQL call is a self-contained plpgsql
10
+ * transaction, so a per-call client checkout is correct — Absurd never relies on
11
+ * cross-call session state.
12
+ */
13
+ import { createRequire } from 'node:module';
14
+ import { readFileSync } from 'node:fs';
15
+ import path from 'node:path';
16
+ import {
17
+ Absurd,
18
+ type AbsurdOptions,
19
+ type Queryable,
20
+ type QueryResult,
21
+ } from '@deepline/absurd/sdk';
22
+ import {
23
+ ABSURD_SCHEMA_SQL_RELATIVE_PATH,
24
+ ABSURD_SCHEMA_VERSION,
25
+ } from '@deepline/absurd/pool';
26
+ import {
27
+ withRuntimeSchedulerClient,
28
+ type RuntimeSchedulerPoolOptions,
29
+ } from './postgres-pool';
30
+
31
+ export { ABSURD_SCHEMA_VERSION };
32
+
33
+ /**
34
+ * Builds an SDK `Queryable` backed by the hardened runtime scheduler pool.
35
+ * Every query runs on a freshly checked-out pooled client and releases it,
36
+ * inheriting the pool's backpressure/breaker/retry guarantees.
37
+ */
38
+ export function absurdQueryableForRuntimeScheduler(
39
+ poolOptions: RuntimeSchedulerPoolOptions,
40
+ ): Queryable {
41
+ return {
42
+ query: async <Row = Record<string, unknown>>(
43
+ sql: string,
44
+ params?: unknown[],
45
+ ): Promise<QueryResult<Row>> => {
46
+ return withRuntimeSchedulerClient(poolOptions, async (client) => {
47
+ const result = await client.query<Row & Record<string, unknown>>(
48
+ sql,
49
+ params,
50
+ );
51
+ return { rows: result.rows as Row[] };
52
+ });
53
+ },
54
+ };
55
+ }
56
+
57
+ /**
58
+ * Constructs an Absurd client wired to the runtime scheduler pool.
59
+ */
60
+ export function createAbsurdForRuntimeScheduler(
61
+ poolOptions: RuntimeSchedulerPoolOptions,
62
+ options: Omit<AbsurdOptions, 'db'> = {},
63
+ ): Absurd {
64
+ return new Absurd({
65
+ ...options,
66
+ db: absurdQueryableForRuntimeScheduler(poolOptions),
67
+ });
68
+ }
69
+
70
+ let cachedSchemaSql: string | null = null;
71
+ let cachedNoSchedulerOrgCapCompatibilitySql: string | null = null;
72
+
73
+ /**
74
+ * The vendored schema version cannot represent Deepline-owned compatibility
75
+ * patches. Keep an explicit durable marker in the shared `absurd` schema so
76
+ * cold Vercel instances do not execute `CREATE OR REPLACE FUNCTION` on every
77
+ * first submission. Replacing a function while claims are running is DDL
78
+ * contention, not useful admission work.
79
+ */
80
+ export const ABSURD_NO_SCHEDULER_ORG_CAP_COMPATIBILITY_VERSION =
81
+ 'deepline-no-scheduler-org-cap-v1';
82
+
83
+ function schemaSection(sql: string, start: string, end: string): string {
84
+ const startIndex = sql.indexOf(start);
85
+ const endIndex = sql.indexOf(end);
86
+ if (startIndex < 0 || endIndex < 0 || endIndex <= startIndex) {
87
+ throw new Error('Vendored absurd v5 schema upgrade markers are malformed.');
88
+ }
89
+ return sql.slice(startIndex + start.length, endIndex).trim();
90
+ }
91
+
92
+ /**
93
+ * Reads the vendored `absurd.sql` schema text. Cached after first read. Node
94
+ * only — the scheduler control plane and worker run under Node, never workerd.
95
+ */
96
+ export function readAbsurdSchemaSql(): string {
97
+ if (cachedSchemaSql !== null) {
98
+ return cachedSchemaSql;
99
+ }
100
+ const packagePoolPath = createRequire(import.meta.url).resolve(
101
+ '@deepline/absurd/pool',
102
+ );
103
+ const schemaPath = path.resolve(
104
+ path.dirname(packagePoolPath),
105
+ ABSURD_SCHEMA_SQL_RELATIVE_PATH,
106
+ );
107
+ const sql = readFileSync(schemaPath, 'utf8');
108
+ if (!sql.includes('create schema if not exists absurd')) {
109
+ throw new Error(
110
+ `Vendored absurd schema at ${schemaPath} is missing or malformed.`,
111
+ );
112
+ }
113
+ cachedSchemaSql = sql;
114
+ return sql;
115
+ }
116
+
117
+ /**
118
+ * Applies no-cap behavior without changing the v4 schema contract.
119
+ *
120
+ * During a rolling release older workers still cold-start against v4 and may
121
+ * submit `per_org_concurrency`. Keeping the marker, column, function result
122
+ * shape, and accepted input key lets both versions run. The replacement
123
+ * claim function deliberately ignores the retired setting, so it cannot limit
124
+ * scheduler claims even while its compatibility-only column exists.
125
+ */
126
+ export function readAbsurdSchemaNoSchedulerOrgCapCompatibilitySql(): string {
127
+ if (cachedNoSchedulerOrgCapCompatibilitySql !== null) {
128
+ return cachedNoSchedulerOrgCapCompatibilitySql;
129
+ }
130
+ const sql = readAbsurdSchemaSql();
131
+ const claim = schemaSection(
132
+ sql,
133
+ '-- Workers call this to reserve a task from a given queue',
134
+ '-- Markes a run as completed',
135
+ );
136
+ const noCapClaim = claim
137
+ .replace(
138
+ ` -- DEEPLINE PATCH (a): per-org admission cap from queue policy (null=unlimited).\n v_per_org_cap integer;\n`,
139
+ '',
140
+ )
141
+ .replace(
142
+ `\n select per_org_concurrency into v_per_org_cap\n from absurd.queues\n where queue_name = p_queue_name;\n`,
143
+ '',
144
+ )
145
+ .replace(
146
+ ` -- DEEPLINE PATCH (a): fair per-org claiming + priority + admission caps.\n`,
147
+ ` -- DEEPLINE PATCH (a): fair per-org claiming + priority.\n`,
148
+ )
149
+ .replace(
150
+ ` -- * admission — when the queue sets per_org_concurrency, an org may only\n -- admit (cap - inflight) head-of-line tasks; an org already at\n -- the cap is skipped entirely.\n --\n`,
151
+ '',
152
+ )
153
+ .replace(
154
+ ` admissible as (\n select run_id,\n priority,\n available_at,\n created_at,\n (org_rank + inflight_cnt) as fair_rank\n from scored\n where $5::integer is null\n or org_rank <= ($5::integer - inflight_cnt)\n ),\n ranked as (\n select run_id\n from admissible\n`,
155
+ ` ranked as (\n select run_id,\n priority,\n available_at,\n created_at,\n (org_rank + inflight_cnt) as fair_rank\n from scored\n`,
156
+ )
157
+ .replace(
158
+ 'return query execute v_sql using v_now, v_qty, v_worker_id, v_claim_until, v_per_org_cap;',
159
+ 'return query execute v_sql using v_now, v_qty, v_worker_id, v_claim_until;',
160
+ );
161
+
162
+ if (
163
+ noCapClaim.includes('v_per_org_cap') ||
164
+ noCapClaim.includes('$5::integer')
165
+ ) {
166
+ throw new Error(
167
+ 'Absurd no-cap compatibility patch did not remove the retired claim gate.',
168
+ );
169
+ }
170
+ // The installed v4 claim function has the identical signature and result
171
+ // type. Replacing only its body is safe for old and new processes alike.
172
+ cachedNoSchedulerOrgCapCompatibilitySql = noCapClaim.replace(
173
+ 'create function absurd.claim_task',
174
+ 'create or replace function absurd.claim_task',
175
+ );
176
+ return cachedNoSchedulerOrgCapCompatibilitySql;
177
+ }
178
+
179
+ /**
180
+ * Marks the no-cap compatibility patch after its replacement claim function
181
+ * has committed. A function keeps the marker in Absurd's global schema and
182
+ * makes it valid for every runtime scheduler namespace that shares it.
183
+ */
184
+ export function readAbsurdSchemaNoSchedulerOrgCapCompatibilityMarkerSql(): string {
185
+ return `
186
+ CREATE OR REPLACE FUNCTION absurd.deepline_no_scheduler_org_cap_compatibility_version()
187
+ RETURNS text
188
+ LANGUAGE sql
189
+ AS $$
190
+ SELECT '${ABSURD_NO_SCHEDULER_ORG_CAP_COMPATIBILITY_VERSION}'::text
191
+ $$
192
+ `;
193
+ }