deepline 0.3.89 → 0.3.91

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 (267) hide show
  1. package/contracts/install-commands.json +29 -0
  2. package/dist/bundling-sources/sdk/src/client.ts +221 -43
  3. package/dist/bundling-sources/sdk/src/index.ts +4 -0
  4. package/dist/bundling-sources/sdk/src/monitor-fleet-contract.ts +2 -556
  5. package/dist/bundling-sources/sdk/src/monitor-fleets.ts +2 -2
  6. package/dist/bundling-sources/sdk/src/pagination.ts +25 -0
  7. package/dist/bundling-sources/sdk/src/plays/bundle-play-file.ts +1 -1
  8. package/dist/bundling-sources/sdk/src/release.ts +11 -9
  9. package/dist/bundling-sources/sdk/src/types.ts +29 -1
  10. package/dist/bundling-sources/shared_libs/integration-contracts/monitor-fleet-contract.ts +549 -0
  11. package/dist/bundling-sources/shared_libs/monitors/analytics-public.ts +10 -0
  12. package/dist/bundling-sources/shared_libs/monitors/fleets/errors.ts +96 -0
  13. package/dist/bundling-sources/shared_libs/monitors/fleets/limits.ts +8 -0
  14. package/dist/bundling-sources/shared_libs/monitors/fleets/plan.ts +320 -0
  15. package/dist/bundling-sources/shared_libs/monitors/fleets/verdict.ts +106 -0
  16. package/dist/bundling-sources/shared_libs/monitors/http-error-response.ts +8 -1
  17. package/dist/bundling-sources/shared_libs/monitors/inbound-queue.ts +4 -4
  18. package/dist/bundling-sources/shared_libs/monitors/inventory-reconciliation.ts +59 -0
  19. package/dist/bundling-sources/shared_libs/monitors/lifecycle-notifications.ts +7 -9
  20. package/dist/bundling-sources/shared_libs/monitors/monitor-fleet-limits.ts +2 -12
  21. package/dist/bundling-sources/shared_libs/monitors/package.json +113 -4
  22. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +56 -9
  23. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-consumer-health.ts +2 -2
  24. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-identity-claims.ts +2 -2
  25. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-public-aliases.ts +1 -1
  26. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-dead-letter.ts +245 -0
  27. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-message.ts +38 -0
  28. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-queue-ack-probe.ts +94 -0
  29. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-queue-delivery.ts +60 -0
  30. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-queue.ts +60 -0
  31. package/dist/bundling-sources/shared_libs/monitors/snitcher-install-validation.ts +1 -1
  32. package/dist/bundling-sources/shared_libs/monitors/snitcher-ip2company.ts +2 -2
  33. package/dist/bundling-sources/shared_libs/monitors/snitcher-radar.ts +1 -1
  34. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-integrations.ts +1 -1
  35. package/dist/bundling-sources/shared_libs/observability/build-context.ts +13 -0
  36. package/dist/bundling-sources/shared_libs/observability/log-metadata.ts +160 -0
  37. package/dist/bundling-sources/shared_libs/observability/request-context.ts +68 -0
  38. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +690 -0
  39. package/dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts +35 -0
  40. package/dist/bundling-sources/shared_libs/observability/scheduled-work.ts +5 -0
  41. package/dist/bundling-sources/shared_libs/play-data-plane/neon-constants.ts +9 -0
  42. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +272 -0
  43. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +46 -1
  44. package/dist/bundling-sources/shared_libs/play-runtime/async-operation.ts +66 -1
  45. package/dist/bundling-sources/shared_libs/play-runtime/async-play-invocation.ts +0 -1
  46. package/dist/bundling-sources/shared_libs/play-runtime/bounceban-batching.ts +137 -0
  47. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +779 -140
  48. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +46 -0
  49. package/dist/bundling-sources/shared_libs/play-runtime/daytona-payload-contract.ts +68 -0
  50. package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-janitor.ts +103 -0
  51. package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-reaper.ts +725 -0
  52. package/dist/bundling-sources/shared_libs/play-runtime/db-session-lease-store.ts +578 -0
  53. package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-execution-relay.ts +521 -0
  54. package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-receipt-gateway.ts +1378 -0
  55. package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/runtime-topology.ts +1024 -0
  56. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-gateway-route-probe.ts +193 -0
  57. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machine-lifecycle.ts +104 -0
  58. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +1844 -0
  59. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-registry.ts +21 -0
  60. package/dist/bundling-sources/shared_libs/play-runtime/deployment/process-tree.ts +40 -0
  61. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-gateway-drain.ts +262 -0
  62. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-surface.ts +98 -0
  63. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-topology.ts +303 -0
  64. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-tuple-publication-guardian.ts +70 -0
  65. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-tuple-recovery.ts +519 -0
  66. package/dist/bundling-sources/shared_libs/play-runtime/deployment/vercel-fly-rollback-alignment.ts +280 -0
  67. package/dist/bundling-sources/shared_libs/play-runtime/deployment/vercel-production-gate.ts +159 -0
  68. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +29 -0
  69. package/dist/bundling-sources/shared_libs/play-runtime/execution-capabilities.ts +23 -0
  70. package/dist/bundling-sources/shared_libs/play-runtime/execution-gateway-invocation-fence.ts +442 -0
  71. package/dist/bundling-sources/shared_libs/play-runtime/execution-protocol.ts +3 -3
  72. package/dist/bundling-sources/shared_libs/play-runtime/fixture-behavior.ts +18 -0
  73. package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +9 -0
  74. package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +1 -1
  75. package/dist/bundling-sources/shared_libs/play-runtime/governor/rate-state-backend.ts +1 -1
  76. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/contracts.ts +66 -0
  77. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/job.ts +145 -0
  78. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/memory-store.ts +114 -0
  79. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/ports.ts +21 -0
  80. package/dist/bundling-sources/shared_libs/play-runtime/integration-operation-reader-fence/postgres-store.ts +170 -0
  81. package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +1322 -0
  82. package/dist/bundling-sources/shared_libs/play-runtime/internal-step-ids.ts +2 -2
  83. package/dist/bundling-sources/shared_libs/play-runtime/lane-retirement-gate.ts +1 -1
  84. package/dist/bundling-sources/shared_libs/play-runtime/launch-source-policy.ts +112 -0
  85. package/dist/bundling-sources/shared_libs/play-runtime/map-execution-frame.ts +8 -0
  86. package/dist/bundling-sources/shared_libs/play-runtime/perf-trace.ts +127 -0
  87. package/dist/bundling-sources/shared_libs/play-runtime/play-artifact-runtime-contract.ts +5 -0
  88. package/dist/bundling-sources/shared_libs/play-runtime/play-run-recovery-policy.ts +24 -1
  89. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/contracts.ts +56 -0
  90. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/index.ts +13 -0
  91. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/job.ts +41 -0
  92. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/ports.ts +17 -0
  93. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/admission/postgres-adapter.ts +54 -0
  94. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/contracts.ts +114 -0
  95. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/engine-suspension.ts +108 -0
  96. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/index.ts +36 -0
  97. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/job.ts +97 -0
  98. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/ports.ts +104 -0
  99. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/postgres-fence-adapter.ts +263 -0
  100. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/worker-terminal-projection.ts +64 -0
  101. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/contracts.ts +29 -0
  102. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/gateway-adapter.ts +56 -0
  103. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/index.ts +15 -0
  104. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/job.ts +65 -0
  105. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/ports.ts +17 -0
  106. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/contracts.ts +42 -0
  107. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/index.ts +17 -0
  108. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/job.ts +142 -0
  109. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/ports.ts +42 -0
  110. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/postgres-adapter.ts +102 -0
  111. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/contracts.ts +60 -0
  112. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/index.ts +16 -0
  113. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/job.ts +78 -0
  114. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/ports.ts +54 -0
  115. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/postgres-adapter.ts +71 -0
  116. package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-batching-registry.ts +4 -0
  117. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +2 -0
  118. package/dist/bundling-sources/shared_libs/play-runtime/receipt-status.ts +5 -8
  119. package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +3 -5
  120. package/dist/bundling-sources/shared_libs/play-runtime/run-identity.ts +168 -0
  121. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +44 -5
  122. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/child-play-resolver.ts +26 -0
  123. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +3662 -0
  124. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/progress-sidecar.ts +47 -0
  125. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-deadline.ts +84 -0
  126. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-gateway-transport.ts +91 -0
  127. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-heartbeat.ts +424 -0
  128. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-progress-push.ts +321 -0
  129. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-sheet-persistence-retry.ts +110 -0
  130. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-terminal-push.ts +625 -0
  131. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +72 -9
  132. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +6 -12
  133. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +19 -0
  134. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/bundle.ts +0 -1
  135. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/runtime-sandbox-reconciliation.ts +14 -44
  136. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +103 -208
  137. package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +201 -0
  138. package/dist/bundling-sources/shared_libs/play-runtime/runtime-env.ts +6 -0
  139. package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +67 -0
  140. package/dist/bundling-sources/shared_libs/play-runtime/runtime-release-environment.ts +2 -0
  141. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sandbox-contract.ts +68 -0
  142. package/dist/bundling-sources/shared_libs/play-runtime/runtime-scheduler-topology.ts +14 -2
  143. package/dist/bundling-sources/shared_libs/play-runtime/runtime-telemetry.ts +108 -0
  144. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/contract.ts +4 -0
  145. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +3 -0
  146. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +7 -0
  147. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-deadline-reconciliation.ts +88 -0
  148. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-deploy-task.ts +124 -0
  149. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-run-task.ts +68 -0
  150. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +193 -0
  151. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-queue-lifecycle.ts +269 -0
  152. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-queue-suffix.ts +73 -0
  153. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +6642 -0
  154. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +897 -0
  155. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-metrics.ts +120 -0
  156. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-required-env.ts +76 -0
  157. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd.ts +476 -0
  158. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-heavy-request-admission.ts +47 -0
  159. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-progress-registry.ts +147 -0
  160. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/index.ts +27 -0
  161. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/lazy.ts +50 -0
  162. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/play-run-recovery.ts +98 -0
  163. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-budget-state.ts +260 -0
  164. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-pool.ts +1416 -0
  165. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +1255 -0
  166. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +942 -0
  167. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +14636 -0
  168. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-gateway.ts +888 -0
  169. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +355 -0
  170. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-terminal-transition.ts +46 -0
  171. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runner-push.ts +60 -0
  172. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-api-origin.ts +33 -0
  173. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-receipt-gateway-health.ts +64 -0
  174. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +835 -0
  175. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-ledger-reconciliation.ts +1218 -0
  176. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-operation.ts +207 -0
  177. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-scheduler-schema.ts +10 -0
  178. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/scheduler-capacity.ts +123 -0
  179. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/scheduler-launch-read-observability.ts +78 -0
  180. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/submit-admission.ts +169 -0
  181. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/terminal-contract.ts +20 -0
  182. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/worker-queue-metrics.ts +34 -0
  183. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/worker-resource-metrics.ts +249 -0
  184. package/dist/bundling-sources/shared_libs/play-runtime/sheet-attempt-sql.ts +7 -0
  185. package/dist/bundling-sources/shared_libs/play-runtime/step-progress.ts +296 -0
  186. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/native-batch.ts +3 -3
  187. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/runtime-step-receipts-adapter.ts +20 -1
  188. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +60 -15
  189. package/dist/bundling-sources/shared_libs/play-runtime/tool-execution-outcome.ts +20 -0
  190. package/dist/bundling-sources/shared_libs/play-runtime/transient-service-error.ts +12 -0
  191. package/dist/bundling-sources/shared_libs/play-runtime/vercel-protection.ts +14 -1
  192. package/dist/bundling-sources/shared_libs/play-runtime/webhook-receipt-retry.ts +50 -0
  193. package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-storage-contract.ts +165 -0
  194. package/dist/bundling-sources/shared_libs/play-runtime/work-receipts.ts +15 -23
  195. package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +169 -0
  196. package/dist/bundling-sources/shared_libs/play-runtime/zerobounce-batching.ts +122 -0
  197. package/dist/bundling-sources/shared_libs/plays/artifact-types.ts +2 -0
  198. package/dist/bundling-sources/shared_libs/plays/bundling/repository-adapter.ts +24 -0
  199. package/dist/bundling-sources/shared_libs/plays/child-run-projection.ts +174 -0
  200. package/dist/bundling-sources/shared_libs/plays/contracts.ts +2 -0
  201. package/dist/bundling-sources/shared_libs/plays/deploy/api-client.ts +267 -0
  202. package/dist/bundling-sources/shared_libs/plays/deploy/control-plane-types.ts +73 -0
  203. package/dist/bundling-sources/shared_libs/plays/deploy/manifest.ts +162 -0
  204. package/dist/bundling-sources/shared_libs/plays/deploy/project-serializer.ts +87 -0
  205. package/dist/bundling-sources/shared_libs/plays/deploy/source-file-path.ts +26 -0
  206. package/dist/bundling-sources/shared_libs/plays/deploy/target-paths.ts +36 -0
  207. package/dist/bundling-sources/shared_libs/plays/deployment-status.ts +1 -1
  208. package/dist/bundling-sources/shared_libs/plays/docflow.ts +1 -1
  209. package/dist/bundling-sources/shared_libs/plays/launch/input-contract.ts +400 -0
  210. package/dist/bundling-sources/shared_libs/plays/launch/prepare.ts +96 -0
  211. package/dist/bundling-sources/shared_libs/plays/local-file-discovery.ts +385 -0
  212. package/dist/bundling-sources/shared_libs/plays/play-grep-search.ts +112 -0
  213. package/dist/bundling-sources/shared_libs/plays/play-reference.ts +117 -0
  214. package/dist/bundling-sources/shared_libs/plays/run-input-summary.ts +260 -0
  215. package/dist/bundling-sources/shared_libs/plays/run-summary-types.ts +49 -0
  216. package/dist/bundling-sources/shared_libs/plays/secrets/errors.ts +19 -0
  217. package/dist/bundling-sources/shared_libs/plays/share/copy.ts +271 -0
  218. package/dist/bundling-sources/shared_libs/plays/share/metrics.ts +140 -0
  219. package/dist/bundling-sources/shared_libs/plays/share/public-read-model.ts +86 -0
  220. package/dist/bundling-sources/shared_libs/plays/share/seo-quality.ts +181 -0
  221. package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +658 -0
  222. package/dist/bundling-sources/shared_libs/plays/share/types.ts +197 -0
  223. package/dist/bundling-sources/shared_libs/plays/sheet-filter.ts +347 -0
  224. package/dist/bundling-sources/shared_libs/plays/slack-hitl-timeout-error.ts +37 -0
  225. package/dist/bundling-sources/shared_libs/plays/standard-webhooks.ts +117 -0
  226. package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +6 -1
  227. package/dist/bundling-sources/shared_libs/plays/status-result.ts +388 -0
  228. package/dist/bundling-sources/shared_libs/plays/tool-result-types.ts +1 -1
  229. package/dist/bundling-sources/shared_libs/plays/transform-factor-structure.ts +377 -0
  230. package/dist/bundling-sources/shared_libs/plays/webhook-payload.ts +113 -0
  231. package/dist/bundling-sources/shared_libs/product-notifications/configuration.ts +7 -1
  232. package/dist/bundling-sources/shared_libs/product-notifications/default-policy.ts +3 -2
  233. package/dist/bundling-sources/shared_libs/product-notifications/overflow.ts +18 -0
  234. package/dist/bundling-sources/shared_libs/product-notifications/rolling-limit.ts +24 -0
  235. package/dist/bundling-sources/shared_libs/product-notifications/slack-delivery.ts +624 -0
  236. package/dist/bundling-sources/shared_libs/product-notifications/slack-payload.ts +140 -0
  237. package/dist/bundling-sources/shared_libs/product-notifications/slack-transport.ts +75 -0
  238. package/dist/bundling-sources/shared_libs/runtime-env.ts +6 -0
  239. package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +42 -0
  240. package/dist/bundling-sources/shared_libs/security/header-safe-env.ts +10 -3
  241. package/dist/bundling-sources/shared_libs/security/slack-sanitize.ts +133 -0
  242. package/dist/cli/getting-started.d.mts +52 -0
  243. package/dist/cli/getting-started.d.ts +52 -0
  244. package/dist/cli/getting-started.js +65 -0
  245. package/dist/cli/getting-started.mjs +36 -0
  246. package/dist/cli/index.d.mts +9 -0
  247. package/dist/cli/index.d.ts +9 -0
  248. package/dist/cli/index.js +895 -407
  249. package/dist/cli/index.mjs +893 -414
  250. package/dist/{compiler-manifest-DsLbQaew.d.mts → compiler-manifest-x14KL83E.d.mts} +4 -2
  251. package/dist/{compiler-manifest-DsLbQaew.d.ts → compiler-manifest-x14KL83E.d.ts} +4 -2
  252. package/dist/index.d.mts +124 -154
  253. package/dist/index.d.ts +124 -154
  254. package/dist/index.js +132 -28
  255. package/dist/index.mjs +132 -28
  256. package/dist/install-integrity.json +182 -2
  257. package/dist/monitor-fleet-contract.d.mts +131 -0
  258. package/dist/monitor-fleet-contract.d.ts +131 -0
  259. package/dist/monitor-fleet-contract.js +406 -0
  260. package/dist/monitor-fleet-contract.mjs +367 -0
  261. package/dist/plays/bundle-play-file.d.mts +2 -2
  262. package/dist/plays/bundle-play-file.d.ts +2 -2
  263. package/dist/release.d.mts +255 -0
  264. package/dist/release.d.ts +255 -0
  265. package/dist/release.js +210 -0
  266. package/dist/release.mjs +183 -0
  267. package/package.json +21 -4
@@ -0,0 +1,78 @@
1
+ import {
2
+ resolvePlayRunTerminalAuthority,
3
+ type PlayRunTerminalInput,
4
+ type PlayRunTerminalJob,
5
+ type PlayRunTerminalOutcome,
6
+ } from '../../play-runs/terminal/contracts';
7
+ import type { PlayRunTerminalPorts } from '../../play-runs/terminal/ports';
8
+
9
+ /**
10
+ * Play Run Terminal Job.
11
+ *
12
+ * The job owns the terminal transition law:
13
+ *
14
+ * atomic direct transition → terminal outcome
15
+ * otherwise durable compatibility receipt → wake
16
+ *
17
+ * Infrastructure only supplies the three capabilities. In particular, no
18
+ * caller can accidentally publish a wake before the compatibility receipt is
19
+ * durable, or publish after a stale fence rejected its write.
20
+ */
21
+ export function createPlayRunTerminalJob(
22
+ ports: PlayRunTerminalPorts,
23
+ ): PlayRunTerminalJob {
24
+ return {
25
+ async accept(input: PlayRunTerminalInput): Promise<PlayRunTerminalOutcome> {
26
+ // The public compatibility facade historically accepted a manually
27
+ // constructed authority as well as the parsed ingress value. Normalize
28
+ // it again here so whitespace cannot turn an invalid lease into a direct
29
+ // terminal write when a caller bypasses the parser.
30
+ const authority = resolvePlayRunTerminalAuthority(input.authority ?? {});
31
+ const direct = authority
32
+ ? await ports.directCommitter.commit({
33
+ runId: input.runId,
34
+ attempt: input.attempt,
35
+ authority,
36
+ result: input.result,
37
+ queueName: input.queueName,
38
+ // An authority exists only for the one terminal contract this
39
+ // build recognizes, and that contract is what proves the durable
40
+ // compute-billing controller. An absent or unrecognized contract
41
+ // never reaches here: it resolves to null above and wakes instead.
42
+ allowCappedCompletion: true,
43
+ })
44
+ : 'wake_required';
45
+
46
+ if (direct === 'not_found') {
47
+ return { kind: 'not_found_or_fence_rejected' };
48
+ }
49
+ if (direct === 'completed') {
50
+ return { kind: 'direct_completed' };
51
+ }
52
+ if (direct === 'stale_cleaned') {
53
+ return { kind: 'stale_attempt_cleaned' };
54
+ }
55
+ if (direct === 'already_terminal') {
56
+ // Mixed-version recovery is first-write-wins. Re-emitting can retire a
57
+ // historical parked invocation whose prior transition predates atomic
58
+ // retirement-event recording.
59
+ await ports.wakePublisher.publish(input);
60
+ return { kind: 'already_terminal' };
61
+ }
62
+
63
+ const recorded = await ports.compatibilityRecorder.record({
64
+ runId: input.runId,
65
+ attempt: input.attempt,
66
+ result: input.result,
67
+ });
68
+ if (!recorded) {
69
+ return { kind: 'not_found_or_fence_rejected' };
70
+ }
71
+
72
+ // The event carries no terminal payload. A resumed attempt reads truth
73
+ // from its durable store rather than trusting a message body.
74
+ await ports.wakePublisher.publish(input);
75
+ return { kind: 'compatibility_wake_queued' };
76
+ },
77
+ };
78
+ }
@@ -0,0 +1,54 @@
1
+ import type {
2
+ PlayRunTerminalAuthority,
3
+ PlayRunTerminalInput,
4
+ } from '../../play-runs/terminal/contracts';
5
+
6
+ /** The result of the atomic terminal-transition capability. */
7
+ export type DirectTerminalCommitOutcome =
8
+ | 'completed'
9
+ | 'stale_cleaned'
10
+ | 'already_terminal'
11
+ | 'not_found'
12
+ | 'wake_required';
13
+
14
+ /**
15
+ * Capability for the modern atomic terminal transition. An implementation
16
+ * commits run truth, cleanup/billing obligations, terminal log outbox, and
17
+ * retirement event as one transaction when it returns `completed`.
18
+ */
19
+ export type DirectTerminalCommitter = {
20
+ commit(input: {
21
+ runId: string;
22
+ attempt: number;
23
+ authority: PlayRunTerminalAuthority;
24
+ result: unknown;
25
+ queueName: string;
26
+ allowCappedCompletion: boolean;
27
+ }): Promise<DirectTerminalCommitOutcome>;
28
+ };
29
+
30
+ /**
31
+ * Compatibility-only durable write. It persists a runner terminal before the
32
+ * wake is published; false means a stale/missing attempt won and no event may
33
+ * be emitted.
34
+ */
35
+ export type CompatibilityTerminalRecorder = {
36
+ record(input: {
37
+ runId: string;
38
+ attempt: number;
39
+ result: unknown;
40
+ }): Promise<boolean>;
41
+ };
42
+
43
+ /** Publishes the wake only after terminal truth has become durable. */
44
+ export type RunnerTerminalWakePublisher = {
45
+ publish(
46
+ input: Pick<PlayRunTerminalInput, 'queueName' | 'runId' | 'attempt'>,
47
+ ): Promise<void>;
48
+ };
49
+
50
+ export type PlayRunTerminalPorts = {
51
+ directCommitter: DirectTerminalCommitter;
52
+ compatibilityRecorder: CompatibilityTerminalRecorder;
53
+ wakePublisher: RunnerTerminalWakePublisher;
54
+ };
@@ -0,0 +1,71 @@
1
+ import { ABSURD_WAKE_CHANNEL } from '@deepline/absurd/sdk';
2
+
3
+ import { absurdRunnerTerminalEventName } from '../../scheduler-backends/absurd-shared';
4
+ import {
5
+ directCompletePostgresSchedulerRunnerTerminal,
6
+ recordPostgresSchedulerRunnerTerminal,
7
+ type PostgresSchedulerQueryClient,
8
+ } from '../../scheduler-backends/postgres';
9
+ import type { PlayRunTerminalPorts } from '../../play-runs/terminal/ports';
10
+
11
+ /**
12
+ * Postgres implementation of the Play Run Terminal capabilities.
13
+ *
14
+ * This adapter is intentionally the only place this module knows scheduler
15
+ * SQL, the Absurd event name, or PostgreSQL notification transport.
16
+ */
17
+ export function createPostgresPlayRunTerminalPorts(input: {
18
+ client: PostgresSchedulerQueryClient;
19
+ schema?: string;
20
+ }): PlayRunTerminalPorts {
21
+ const options = input.schema ? { schema: input.schema } : undefined;
22
+ return {
23
+ directCommitter: {
24
+ async commit(terminal) {
25
+ return await directCompletePostgresSchedulerRunnerTerminal(
26
+ input.client,
27
+ {
28
+ runId: terminal.runId,
29
+ attempt: terminal.attempt,
30
+ leaseToken: terminal.authority.leaseToken,
31
+ result: terminal.result,
32
+ terminalLogOutbox: 'ctx_log_tail',
33
+ allowCappedCompletion: terminal.allowCappedCompletion,
34
+ engineWake: {
35
+ queueName: terminal.queueName,
36
+ eventName: absurdRunnerTerminalEventName(
37
+ terminal.runId,
38
+ terminal.attempt,
39
+ ),
40
+ wakeChannel: ABSURD_WAKE_CHANNEL,
41
+ },
42
+ },
43
+ options,
44
+ );
45
+ },
46
+ },
47
+ compatibilityRecorder: {
48
+ async record(terminal) {
49
+ return await recordPostgresSchedulerRunnerTerminal(
50
+ input.client,
51
+ terminal,
52
+ options,
53
+ );
54
+ },
55
+ },
56
+ wakePublisher: {
57
+ async publish(terminal) {
58
+ await input.client.query(
59
+ `WITH emitted AS (
60
+ SELECT absurd.emit_event($1, $2, 'null'::jsonb)
61
+ )
62
+ SELECT pg_notify('${ABSURD_WAKE_CHANNEL}', $1) FROM emitted`,
63
+ [
64
+ terminal.queueName,
65
+ absurdRunnerTerminalEventName(terminal.runId, terminal.attempt),
66
+ ],
67
+ );
68
+ },
69
+ },
70
+ };
71
+ }
@@ -1,8 +1,10 @@
1
+ import { bouncebanBatchStrategies } from './/bounceban-batching';
1
2
  import type { AnyBatchOperationStrategy } from './batching-types';
2
3
  import { bettercontactBatchStrategies } from './bettercontact-batching';
3
4
  import { DEFAULT_PLAY_RUNTIME_BATCH_STRATEGIES } from './default-batch-strategies';
4
5
  import { fullenrichBatchStrategies } from './fullenrich-batching';
5
6
  import { opensosdataBatchStrategies } from './opensosdata-batching';
7
+ import { zerobounceBatchStrategies } from './zerobounce-batching';
6
8
  import { testAsyncBatchStrategies } from './test-async-batching';
7
9
 
8
10
  export const PLAY_RUNTIME_BATCH_OPERATION_REGISTRY: Record<
@@ -11,9 +13,11 @@ export const PLAY_RUNTIME_BATCH_OPERATION_REGISTRY: Record<
11
13
  > = {
12
14
  ...DEFAULT_PLAY_RUNTIME_BATCH_STRATEGIES,
13
15
  ...bettercontactBatchStrategies,
16
+ ...bouncebanBatchStrategies,
14
17
  ...fullenrichBatchStrategies,
15
18
  ...opensosdataBatchStrategies,
16
19
  ...testAsyncBatchStrategies,
20
+ ...zerobounceBatchStrategies,
17
21
  };
18
22
 
19
23
  export function getPlayRuntimeBatchStrategy(
@@ -152,6 +152,8 @@ export interface PlayRunnerContextConfig {
152
152
  workflowId?: string;
153
153
  playId?: string;
154
154
  runId?: string;
155
+ /** Original run for an explicit user-requested replay. */
156
+ replayedFromRunId?: string | null;
155
157
  /** Shared governance/billing root. Differs from runId for async children. */
156
158
  rootRunId?: string;
157
159
  runAttempt?: number | null;
@@ -1,13 +1,10 @@
1
1
  import type { WorkReceiptStatus } from './work-receipts';
2
+ import { WORK_RECEIPT_STATUS_CODE } from './work-receipt-storage-contract';
2
3
 
3
- export const RECEIPT_STATUS_CODE = {
4
- queued: 0,
5
- pending: 0,
6
- running: 1,
7
- completed: 2,
8
- failed: 3,
9
- skipped: 4,
10
- } as const satisfies Record<WorkReceiptStatus, number>;
4
+ export const RECEIPT_STATUS_CODE = WORK_RECEIPT_STATUS_CODE satisfies Record<
5
+ WorkReceiptStatus,
6
+ number
7
+ >;
11
8
 
12
9
  export type ReceiptStatusCode =
13
10
  (typeof RECEIPT_STATUS_CODE)[keyof typeof RECEIPT_STATUS_CODE];
@@ -63,10 +63,10 @@ export const WORKSPACE_STORAGE_NOT_READY_CODE = 'WORKSPACE_STORAGE_NOT_READY';
63
63
  // postgres-URI passwords). The raw pg error goes in the Error `cause` for server
64
64
  // logs only, never into this message or the normalized public failure.
65
65
  export const WORKSPACE_STORAGE_NOT_READY_MESSAGE =
66
- 'Workspace storage for this organization is unavailable, so this operation could not start. ' +
66
+ 'Deepline could not prepare your workspace storage in time, so this operation did not start. ' +
67
+ 'Try again in a few moments. You do not need to run a database command. ' +
67
68
  'This blocked operation did not use Deepline credits. ' +
68
69
  'Earlier completed operations in the same run may already have used credits. ' +
69
- 'Re-run the command. If it fails again, ask an organization admin to run `deepline db repair` (POST /api/v2/ingestion/repair), then re-run. ' +
70
70
  'If this keeps happening, contact Deepline support with the run ID.';
71
71
 
72
72
  export class WorkspaceStorageNotReadyError extends Error {
@@ -177,9 +177,7 @@ export class ProviderExhaustedError extends Error {
177
177
  * `ToolExecutionError` shape. Treat those two representations as the same
178
178
  * typed exhaustion outcome; do not fall back based on a message substring.
179
179
  */
180
- export function isProviderExhaustedFailure(
181
- error: unknown,
182
- ): error is
180
+ export function isProviderExhaustedFailure(error: unknown): error is
183
181
  | ProviderExhaustedError
184
182
  | (ToolExecutionError & {
185
183
  readonly origin: 'provider';
@@ -0,0 +1,168 @@
1
+ import { sha256Hex, stableStringify } from '../plays/row-identity';
2
+ function sanitizePlayNameForWorkflowSegment(value: string): string {
3
+ return value
4
+ .toLowerCase()
5
+ .replace(/[^a-z0-9-]/g, '-')
6
+ .replace(/-+/g, '-')
7
+ .replace(/^-+|-+$/g, '')
8
+ .slice(0, 64);
9
+ }
10
+
11
+ export function buildPlayWorkflowFamilyKey(playName: string): string {
12
+ const normalized = playName
13
+ .split('/')
14
+ .map(sanitizePlayNameForWorkflowSegment)
15
+ .filter(Boolean)
16
+ .join('/');
17
+ return normalized || 'play';
18
+ }
19
+
20
+ export function buildPlayWorkflowRunSuffix(now: Date): string {
21
+ const pad = (value: number, size = 2) => String(value).padStart(size, '0');
22
+ return [
23
+ now.getUTCFullYear(),
24
+ pad(now.getUTCMonth() + 1),
25
+ pad(now.getUTCDate()),
26
+ 't',
27
+ pad(now.getUTCHours()),
28
+ pad(now.getUTCMinutes()),
29
+ pad(now.getUTCSeconds()),
30
+ '-',
31
+ pad(now.getUTCMilliseconds(), 3),
32
+ ].join('');
33
+ }
34
+
35
+ const CANONICAL_PLAY_RUN_TIMESTAMP_RE =
36
+ /\/run\/(\d{4})(\d{2})(\d{2})t(\d{2})(\d{2})(\d{2})-(\d{3})(?:-|$)/;
37
+
38
+ /** Read the UTC creation time embedded in a canonical root play-run id. */
39
+ export function canonicalPlayRunStartedAtMs(runId: string): number | null {
40
+ const match = CANONICAL_PLAY_RUN_TIMESTAMP_RE.exec(runId);
41
+ if (!match) return null;
42
+ const [, year, month, day, hour, minute, second, millisecond] = match;
43
+ const value = Date.UTC(
44
+ Number(year),
45
+ Number(month) - 1,
46
+ Number(day),
47
+ Number(hour),
48
+ Number(minute),
49
+ Number(second),
50
+ Number(millisecond),
51
+ );
52
+ if (!Number.isFinite(value)) return null;
53
+ const roundTrip = new Date(value);
54
+ return roundTrip.getUTCFullYear() === Number(year) &&
55
+ roundTrip.getUTCMonth() === Number(month) - 1 &&
56
+ roundTrip.getUTCDate() === Number(day) &&
57
+ roundTrip.getUTCHours() === Number(hour) &&
58
+ roundTrip.getUTCMinutes() === Number(minute) &&
59
+ roundTrip.getUTCSeconds() === Number(second) &&
60
+ roundTrip.getUTCMilliseconds() === Number(millisecond)
61
+ ? value
62
+ : null;
63
+ }
64
+
65
+ type BuildPlayWorkflowIdOptions = {
66
+ /**
67
+ * Add entropy for new run creation. Keep false for tests and explicit
68
+ * externally-owned ids that need deterministic reconstruction.
69
+ */
70
+ unique?: boolean;
71
+ };
72
+
73
+ function buildRunEntropySuffix(): string {
74
+ const randomUuid = globalThis.crypto?.randomUUID?.();
75
+ if (randomUuid) {
76
+ return randomUuid.replace(/-/g, '').slice(0, 8);
77
+ }
78
+ return Math.random().toString(36).slice(2, 10).padEnd(8, '0');
79
+ }
80
+
81
+ export function buildPlayWorkflowId(
82
+ playName: string,
83
+ now?: Date,
84
+ options: BuildPlayWorkflowIdOptions = {},
85
+ ): string {
86
+ const familyKey = buildPlayWorkflowFamilyKey(playName);
87
+ const timestamp = now ?? new Date();
88
+ const unique = options.unique ?? now === undefined;
89
+ const entropy = unique ? `-${buildRunEntropySuffix()}` : '';
90
+ return `play/${familyKey}/run/${buildPlayWorkflowRunSuffix(timestamp)}${entropy}`;
91
+ }
92
+
93
+ export type PlayRunIdentity = {
94
+ workflowId: string;
95
+ runId: string;
96
+ workflowFamilyKey: string;
97
+ };
98
+
99
+ /**
100
+ * Convex and runtime schedulers share one run identity contract.
101
+ *
102
+ * - `workflowId` is the unique execution id.
103
+ * - `runId` is the same execution id surfaced in dashboard/API state.
104
+ * - `workflowFamilyKey` is the stable play-name-derived family/group key.
105
+ *
106
+ * Keeping these three values explicit removes the old ambiguity where one field
107
+ * pretended to mean both "this specific run" and "this play family".
108
+ */
109
+ export function buildPlayRunIdentity(
110
+ playName: string,
111
+ now?: Date,
112
+ options: BuildPlayWorkflowIdOptions = {},
113
+ ): PlayRunIdentity {
114
+ const workflowId = buildPlayWorkflowId(playName, now, {
115
+ unique: options.unique ?? now === undefined,
116
+ });
117
+ return {
118
+ workflowId,
119
+ runId: workflowId,
120
+ workflowFamilyKey: buildPlayWorkflowFamilyKey(playName),
121
+ };
122
+ }
123
+
124
+ /**
125
+ * Build the replay-stable identity for one ctx.runPlayAsync invocation.
126
+ *
127
+ * The parent's embedded timestamp keeps ordinary run ordering useful while
128
+ * the digest makes retries converge on exactly one independently scheduled
129
+ * child. Input is deliberately excluded: a changed request must conflict with
130
+ * the first immutable launch rather than silently minting another Run.
131
+ */
132
+ export function buildAsyncPlayRunIdentity(input: {
133
+ playName: string;
134
+ parentRunId: string;
135
+ invocationKey: string;
136
+ }): PlayRunIdentity {
137
+ const digest = sha256Hex(
138
+ `${input.parentRunId}\0${input.invocationKey}`,
139
+ ).slice(0, 20);
140
+ const parentStartedAt = canonicalPlayRunStartedAtMs(input.parentRunId) ?? 0;
141
+ // The run id is the durable identity of the authored invocation, so it must
142
+ // be reconstructible before resolving a mutable live Play reference. The
143
+ // workflow family remains the resolved child Play for grouping and display.
144
+ const base = buildPlayWorkflowId('async-child', new Date(parentStartedAt), {
145
+ unique: false,
146
+ });
147
+ const workflowId = `${base}-async-${digest}`;
148
+ return {
149
+ workflowId,
150
+ runId: workflowId,
151
+ workflowFamilyKey: buildPlayWorkflowFamilyKey(input.playName),
152
+ };
153
+ }
154
+
155
+ /** Immutable authored request identity, separate from the resolved revision. */
156
+ export function buildAsyncPlayRequestFingerprint(input: {
157
+ key: string;
158
+ playRef: string;
159
+ childInput: Record<string, unknown>;
160
+ }): string {
161
+ return sha256Hex(
162
+ stableStringify({
163
+ key: input.key,
164
+ playRef: input.playRef,
165
+ input: input.childInput,
166
+ }),
167
+ );
168
+ }
@@ -20,6 +20,7 @@ import {
20
20
  normalizeDatasetBornFrom,
21
21
  type PlayDatasetBornFrom,
22
22
  } from './cell-provenance';
23
+ import { isLedgerTerminalResultRef } from './output-size-limits';
23
24
 
24
25
  export type PlayRunLedgerStatus =
25
26
  | 'queued'
@@ -1019,6 +1020,32 @@ function conflictingTerminalSnapshot(
1019
1020
  );
1020
1021
  }
1021
1022
 
1023
+ /**
1024
+ * A legacy out-of-line terminal reference did not prove that its Postgres
1025
+ * value was written in full. A later ref bearing that proof is an enrichment
1026
+ * of the same terminal result, not a competing outcome or payload.
1027
+ */
1028
+ function canPromoteTerminalResultReference(
1029
+ current: unknown,
1030
+ next: unknown,
1031
+ ): boolean {
1032
+ return (
1033
+ isLedgerTerminalResultRef(current) &&
1034
+ current.content !== 'full' &&
1035
+ isLedgerTerminalResultRef(next) &&
1036
+ next.content === 'full'
1037
+ );
1038
+ }
1039
+
1040
+ function mergeTerminalResult(input: {
1041
+ current: unknown;
1042
+ next: unknown;
1043
+ }): unknown {
1044
+ return canPromoteTerminalResultReference(input.current, input.next)
1045
+ ? input.next
1046
+ : (input.next ?? input.current);
1047
+ }
1048
+
1022
1049
  function retryablePlatformDeployFailureSnapshot(
1023
1050
  base: PlayRunLedgerSnapshot,
1024
1051
  eventError?: string | null,
@@ -1249,6 +1276,7 @@ export function reducePlayRunLedgerEvent(
1249
1276
  conflictingTerminalSnapshot(base, event.type, occurredAt, null, {
1250
1277
  allowStaleSameStatusPayloadMerge:
1251
1278
  (base.result === undefined && event.result !== undefined) ||
1279
+ canPromoteTerminalResultReference(base.result, event.result) ||
1252
1280
  (base.resultSummary === undefined &&
1253
1281
  event.resultSummary !== undefined),
1254
1282
  }) ??
@@ -1261,7 +1289,10 @@ export function reducePlayRunLedgerEvent(
1261
1289
  activeStepId: null,
1262
1290
  activeActivityId: null,
1263
1291
  activeArtifactTableNamespace: null,
1264
- result: event.result ?? base.result,
1292
+ result: mergeTerminalResult({
1293
+ current: base.result,
1294
+ next: event.result,
1295
+ }),
1265
1296
  resultSummary: event.resultSummary ?? base.resultSummary,
1266
1297
  terminalSource: nextTerminalSource(base, event.source),
1267
1298
  })
@@ -1272,7 +1303,8 @@ export function reducePlayRunLedgerEvent(
1272
1303
  conflictingTerminalSnapshot(base, event.type, occurredAt, event.error, {
1273
1304
  allowStaleSameStatusPayloadMerge:
1274
1305
  (base.error == null && event.error != null) ||
1275
- (base.result === undefined && event.result !== undefined),
1306
+ (base.result === undefined && event.result !== undefined) ||
1307
+ canPromoteTerminalResultReference(base.result, event.result),
1276
1308
  }) ??
1277
1309
  withTiming({
1278
1310
  ...settleRunningStepsOnTerminal(base, 'failed', occurredAt),
@@ -1286,7 +1318,10 @@ export function reducePlayRunLedgerEvent(
1286
1318
  activeStepId: null,
1287
1319
  activeActivityId: null,
1288
1320
  activeArtifactTableNamespace: null,
1289
- result: event.result ?? base.result,
1321
+ result: mergeTerminalResult({
1322
+ current: base.result,
1323
+ next: event.result,
1324
+ }),
1290
1325
  terminalSource: nextTerminalSource(base, event.source),
1291
1326
  })
1292
1327
  );
@@ -1295,7 +1330,8 @@ export function reducePlayRunLedgerEvent(
1295
1330
  conflictingTerminalSnapshot(base, event.type, occurredAt, event.error, {
1296
1331
  allowStaleSameStatusPayloadMerge:
1297
1332
  (base.error == null && event.error != null) ||
1298
- (base.result === undefined && event.result !== undefined),
1333
+ (base.result === undefined && event.result !== undefined) ||
1334
+ canPromoteTerminalResultReference(base.result, event.result),
1299
1335
  }) ??
1300
1336
  withTiming({
1301
1337
  ...settleRunningStepsOnTerminal(base, 'failed', occurredAt),
@@ -1309,7 +1345,10 @@ export function reducePlayRunLedgerEvent(
1309
1345
  activeStepId: null,
1310
1346
  activeActivityId: null,
1311
1347
  activeArtifactTableNamespace: null,
1312
- result: event.result ?? base.result,
1348
+ result: mergeTerminalResult({
1349
+ current: base.result,
1350
+ next: event.result,
1351
+ }),
1313
1352
  terminalSource: nextTerminalSource(base, event.source),
1314
1353
  })
1315
1354
  );
@@ -0,0 +1,26 @@
1
+ import { createSingleFlight } from '../single-flight';
2
+
3
+ /**
4
+ * Cache authorized child metadata for one Node runner execution. The caller
5
+ * owns this resolver beside the root PlayContext, so all map rows share it and
6
+ * the cache becomes unreachable as soon as the run settles.
7
+ */
8
+ export function createRunScopedChildPlayResolver<T>(input: {
9
+ resolvePlay: (playRef: string) => Promise<T | null>;
10
+ }): (playRef: string) => Promise<T | null> {
11
+ const resolved = new Map<string, T>();
12
+ const flights = createSingleFlight<string, T | null>();
13
+
14
+ return async (playRef) => {
15
+ const cached = resolved.get(playRef);
16
+ if (cached) return cached;
17
+
18
+ return flights.run(playRef, async () => {
19
+ const cachedAfterAdmission = resolved.get(playRef);
20
+ if (cachedAfterAdmission) return cachedAfterAdmission;
21
+ const play = await input.resolvePlay(playRef);
22
+ if (play) resolved.set(playRef, play);
23
+ return play;
24
+ });
25
+ };
26
+ }