deepline 0.3.552 → 0.3.553

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 (319) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +107 -12
  2. package/dist/bundling-sources/sdk/src/compat.ts +239 -87
  3. package/dist/bundling-sources/sdk/src/config.ts +113 -2
  4. package/dist/bundling-sources/sdk/src/errors.ts +2 -0
  5. package/dist/bundling-sources/sdk/src/http-core.ts +118 -8
  6. package/dist/bundling-sources/sdk/src/index.ts +2 -0
  7. package/dist/bundling-sources/sdk/src/integrations.ts +6 -4
  8. package/dist/bundling-sources/sdk/src/play.ts +3 -0
  9. package/dist/bundling-sources/sdk/src/plays/run-request.ts +1 -1
  10. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  11. package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +8 -1
  12. package/dist/bundling-sources/sdk/src/tool-calls.ts +2 -1
  13. package/dist/bundling-sources/sdk/src/tool-failure-hint.ts +104 -0
  14. package/dist/bundling-sources/sdk/src/types.ts +9 -1
  15. package/dist/bundling-sources/shared_libs/integration-contracts/billing-entitlements.ts +4 -2
  16. package/dist/bundling-sources/shared_libs/integration-contracts/billing-plan-skus.ts +25 -0
  17. package/dist/bundling-sources/shared_libs/monitors/action-actor.ts +2 -0
  18. package/dist/bundling-sources/shared_libs/monitors/billing/credit-recovery.ts +58 -4
  19. package/dist/bundling-sources/shared_libs/monitors/billing/policy-builders.ts +8 -0
  20. package/dist/bundling-sources/shared_libs/monitors/billing/pricing.ts +11 -0
  21. package/dist/bundling-sources/shared_libs/monitors/billing/types.ts +13 -0
  22. package/dist/bundling-sources/shared_libs/monitors/deactivation-reasons.ts +103 -5
  23. package/dist/bundling-sources/shared_libs/monitors/fleets/converge-admission.ts +133 -0
  24. package/dist/bundling-sources/shared_libs/monitors/fleets/fence-attention.ts +165 -0
  25. package/dist/bundling-sources/shared_libs/monitors/fleets/fence-release.ts +726 -0
  26. package/dist/bundling-sources/shared_libs/monitors/fleets/fence-walk.ts +274 -0
  27. package/dist/bundling-sources/shared_libs/monitors/fleets/issues.ts +1 -0
  28. package/dist/bundling-sources/shared_libs/monitors/fleets/limits.ts +28 -0
  29. package/dist/bundling-sources/shared_libs/monitors/fleets/provider-bulk-wait.ts +126 -0
  30. package/dist/bundling-sources/shared_libs/monitors/fleets/shared-payload.ts +189 -0
  31. package/dist/bundling-sources/shared_libs/monitors/http-error-response.ts +28 -0
  32. package/dist/bundling-sources/shared_libs/monitors/inbound-publish-key.ts +4 -0
  33. package/dist/bundling-sources/shared_libs/monitors/inventory-counter-errors.ts +25 -0
  34. package/dist/bundling-sources/shared_libs/monitors/org-monitor-limits.ts +65 -0
  35. package/dist/bundling-sources/shared_libs/monitors/package.json +9 -0
  36. package/dist/bundling-sources/shared_libs/monitors/provider-callback-verification.ts +152 -1
  37. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +6 -0
  38. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-capability.ts +390 -10
  39. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-errors.ts +34 -0
  40. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-identity-claims.ts +66 -30
  41. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-state.ts +30 -0
  42. package/dist/bundling-sources/shared_libs/monitors/provider-resource-failure.ts +26 -3
  43. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-dead-letter.ts +41 -13
  44. package/dist/bundling-sources/shared_libs/monitors/signal-radars/raw-receipt-causes.ts +219 -0
  45. package/dist/bundling-sources/shared_libs/monitors/snitcher-ip2company.ts +21 -10
  46. package/dist/bundling-sources/shared_libs/monitors/starter-templates.ts +13 -0
  47. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +6 -0
  48. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-integrations.ts +13 -0
  49. package/dist/bundling-sources/shared_libs/observability/dlq.ts +1 -1
  50. package/dist/bundling-sources/shared_libs/observability/log-metadata.ts +5 -3
  51. package/dist/bundling-sources/shared_libs/observability/queue-health.ts +10 -1
  52. package/dist/bundling-sources/shared_libs/observability/queue-item-connectors.ts +1 -0
  53. package/dist/bundling-sources/shared_libs/observability/redaction.ts +24 -1
  54. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +168 -41
  55. package/dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts +1 -2
  56. package/dist/bundling-sources/shared_libs/play-data-plane/preview-r2-oidc.ts +188 -0
  57. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +170 -16
  58. package/dist/bundling-sources/shared_libs/play-data-plane/runtime-sheet-storage-contract.ts +5 -0
  59. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +68 -2
  60. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +444 -39
  61. package/dist/bundling-sources/shared_libs/play-runtime/ctx-fetch-caller-deadline.ts +200 -0
  62. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +6 -0
  63. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-topology.ts +21 -1
  64. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +3 -2
  65. package/dist/bundling-sources/shared_libs/play-runtime/durable-summary-events.ts +70 -2
  66. package/dist/bundling-sources/shared_libs/play-runtime/durable-tool-identity.ts +3 -3
  67. package/dist/bundling-sources/shared_libs/play-runtime/execution-capabilities.ts +16 -0
  68. package/dist/bundling-sources/shared_libs/play-runtime/experiment-switches.ts +72 -0
  69. package/dist/bundling-sources/shared_libs/play-runtime/fixture-behavior.ts +1 -0
  70. package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +7 -1
  71. package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +62 -0
  72. package/dist/bundling-sources/shared_libs/play-runtime/map-memory-limits.ts +74 -3
  73. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +31 -3
  74. package/dist/bundling-sources/shared_libs/play-runtime/play-http-request.ts +6 -0
  75. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +8 -0
  76. package/dist/bundling-sources/shared_libs/play-runtime/query-result-dataset.ts +19 -0
  77. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +39 -2
  78. package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +9 -1
  79. package/dist/bundling-sources/shared_libs/play-runtime/run-identity.ts +33 -0
  80. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger-projection-contract.ts +24 -0
  81. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +254 -44
  82. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +87 -6
  83. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +241 -10
  84. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox-egress.ts +161 -14
  85. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +16 -3
  86. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-compression.ts +37 -0
  87. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-paths.ts +9 -0
  88. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +259 -52
  89. package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +13 -0
  90. package/dist/bundling-sources/shared_libs/play-runtime/runtime-constants.ts +30 -0
  91. package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +62 -1
  92. package/dist/bundling-sources/shared_libs/play-runtime/runtime-scheduler-topology.ts +36 -0
  93. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-row-transition.ts +36 -0
  94. package/dist/bundling-sources/shared_libs/play-runtime/runtime-speed-profile.ts +206 -2
  95. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +42 -0
  96. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +185 -64
  97. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-slot-ledger.ts +157 -0
  98. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +110 -2
  99. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-listener-hint.ts +323 -0
  100. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/executor-attempt-standing.ts +72 -0
  101. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-value-storage.ts +23 -4
  102. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-workspace-purge.ts +199 -0
  103. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +632 -66
  104. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +517 -16
  105. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-api-origin.ts +1 -1
  106. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-receipt-value-storage.ts +9 -0
  107. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +599 -2
  108. package/dist/bundling-sources/shared_libs/play-runtime/secret-resolution-retry-policy.ts +26 -1
  109. package/dist/bundling-sources/shared_libs/play-runtime/startup-read-tool-ids.ts +60 -0
  110. package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +51 -0
  111. package/dist/bundling-sources/shared_libs/play-runtime/tool-call-retry-facts.ts +2 -0
  112. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +113 -3
  113. package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +5 -7
  114. package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-storage-contract.ts +2 -0
  115. package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +3 -0
  116. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +40 -5
  117. package/dist/bundling-sources/shared_libs/plays/deploy/api-client.ts +3 -0
  118. package/dist/bundling-sources/shared_libs/plays/deploy/control-plane-types.ts +16 -0
  119. package/dist/bundling-sources/shared_libs/plays/deploy/run-deployment.ts +10 -41
  120. package/dist/bundling-sources/shared_libs/plays/extension-bridge.ts +33 -0
  121. package/dist/bundling-sources/shared_libs/plays/row-identity.ts +18 -1
  122. package/dist/bundling-sources/shared_libs/plays/tool-execution-error.ts +108 -0
  123. package/dist/bundling-sources/shared_libs/plays/trigger-config-contract.ts +14 -0
  124. package/dist/bundling-sources/shared_libs/product-notifications/catalog.ts +171 -0
  125. package/dist/bundling-sources/shared_libs/product-notifications/events.ts +27 -1
  126. package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +9 -24
  127. package/dist/bundling-sources/shared_libs/security/secret-redaction.ts +178 -5
  128. package/dist/bundling-sources/shared_libs/security/signup-email-dns-screen.ts +148 -0
  129. package/dist/bundling-sources/shared_libs/tool-execution-error.ts +108 -0
  130. package/dist/cli/{auth-KVSBJZOX.mjs → auth-I3QAU4RV.mjs} +8 -7
  131. package/dist/cli/auth-MQCN7WGZ.js +44 -0
  132. package/dist/cli/{billing-54RHFEBI.mjs → billing-3IC54OQQ.mjs} +197 -61
  133. package/dist/cli/{billing-FQREA7UA.js → billing-YGFFVAIC.js} +297 -161
  134. package/dist/cli/{chunk-4MK42735.js → chunk-2B5B5KAW.js} +210 -128
  135. package/dist/cli/{chunk-UBKA33KY.mjs → chunk-2MGZAI54.mjs} +17 -0
  136. package/dist/cli/{chunk-4NQF6KJ3.js → chunk-3NTP2OSG.js} +13 -13
  137. package/dist/cli/{chunk-HYC4MKGK.mjs → chunk-45OAVGU6.mjs} +5 -5
  138. package/dist/cli/{chunk-WLN3SUIA.js → chunk-4747TPLV.js} +3 -3
  139. package/dist/cli/{chunk-AZQ264ID.mjs → chunk-4BFTDNHU.mjs} +1 -1
  140. package/dist/cli/{chunk-BGBJV26E.mjs → chunk-4HYNMXXF.mjs} +4 -4
  141. package/dist/cli/{chunk-DJ2JDK4O.mjs → chunk-4SMCFQ23.mjs} +1 -1
  142. package/dist/cli/{chunk-QPKH23EC.mjs → chunk-55F6HNOY.mjs} +5 -5
  143. package/dist/cli/{chunk-LX35AXTN.mjs → chunk-5TYLSS4Q.mjs} +6 -6
  144. package/dist/cli/{chunk-634ZDA3F.js → chunk-6NE3RRRY.js} +1 -1
  145. package/dist/cli/{chunk-EITMD3A5.js → chunk-6VLFQZK6.js} +8 -8
  146. package/dist/cli/{chunk-EOPEYCY7.mjs → chunk-72V4PDH5.mjs} +18 -18
  147. package/dist/cli/{chunk-IHRKLXZN.js → chunk-74RES4DS.js} +5 -5
  148. package/dist/cli/{chunk-45PVGZST.js → chunk-7GEMELKI.js} +366 -320
  149. package/dist/cli/{chunk-4UUR4TCH.js → chunk-7O6J6A7P.js} +1871 -92
  150. package/dist/cli/{chunk-XVB7V4N7.js → chunk-7SERLBNR.js} +161 -53
  151. package/dist/cli/{chunk-F2LH7TGF.js → chunk-7YRJ5UC4.js} +21 -21
  152. package/dist/cli/{chunk-YJHE3O5M.mjs → chunk-A7DLBE5K.mjs} +136 -54
  153. package/dist/cli/{chunk-6PRW5UBA.mjs → chunk-AGICYWGN.mjs} +299 -69
  154. package/dist/cli/{chunk-S5S355UY.mjs → chunk-AGIQDA2T.mjs} +12 -12
  155. package/dist/cli/{chunk-RBEUVDZF.js → chunk-AGLR6QVN.js} +249 -107
  156. package/dist/cli/{chunk-NURW5XH4.mjs → chunk-ASB47RXJ.mjs} +1 -1
  157. package/dist/cli/{chunk-RQZQVFCJ.js → chunk-BVDKFS2T.js} +2 -2
  158. package/dist/cli/{chunk-PFO3ISXA.js → chunk-CACFJODG.js} +174 -129
  159. package/dist/cli/{chunk-6RZOWL2V.mjs → chunk-CAEBJOYU.mjs} +1 -1
  160. package/dist/cli/{chunk-XDVT3GOM.js → chunk-CFJFUVX2.js} +18 -1
  161. package/dist/cli/{chunk-6YCA5NKJ.js → chunk-DP2VH7CO.js} +12 -12
  162. package/dist/cli/{chunk-AWJPDPMA.mjs → chunk-DP64MD6U.mjs} +1 -1
  163. package/dist/cli/{chunk-PTVD2GVQ.mjs → chunk-DZA7RFGL.mjs} +5 -5
  164. package/dist/cli/{chunk-V436Z54K.js → chunk-E2G2DNAB.js} +3 -1
  165. package/dist/cli/{chunk-GGGAEVCX.mjs → chunk-E7WZOX2A.mjs} +22 -18
  166. package/dist/cli/{chunk-IDVVIXPJ.js → chunk-FM7LPUPA.js} +41 -41
  167. package/dist/cli/{chunk-AQWQ2BFX.mjs → chunk-GAVZ4EOD.mjs} +1 -1
  168. package/dist/cli/{chunk-GKYAYLRI.js → chunk-HEBO3XNZ.js} +27 -31
  169. package/dist/cli/{chunk-IYSTRCLX.mjs → chunk-HSJ6X2AQ.mjs} +4 -4
  170. package/dist/cli/{chunk-UPMRIVZB.js → chunk-HVI55MTK.js} +61 -10
  171. package/dist/cli/{chunk-KWSH5T7K.js → chunk-IH6GDNKW.js} +21 -21
  172. package/dist/cli/{chunk-HO3XK3R7.js → chunk-IMX7J4DU.js} +8 -8
  173. package/dist/cli/{chunk-EUPVF4SU.mjs → chunk-INEMTYMT.mjs} +8 -8
  174. package/dist/cli/{chunk-3FD5EQ62.js → chunk-IUOGII7D.js} +6 -7
  175. package/dist/cli/{chunk-U7QRMBIY.mjs → chunk-JJGWHITQ.mjs} +5 -5
  176. package/dist/cli/{chunk-SHLFOPD6.js → chunk-JLGP5XAJ.js} +5 -5
  177. package/dist/cli/{chunk-4TALT2M3.mjs → chunk-LFOERUQY.mjs} +69 -3
  178. package/dist/cli/{chunk-BBTKAASQ.js → chunk-LFQJW4S2.js} +42 -1
  179. package/dist/cli/{chunk-Z5TSLLOW.mjs → chunk-LH5PZKER.mjs} +63 -18
  180. package/dist/cli/{chunk-S46HWQKO.js → chunk-LRDHPOZW.js} +69 -69
  181. package/dist/cli/{chunk-6ZORHRKB.mjs → chunk-LRZGS6RZ.mjs} +2 -0
  182. package/dist/cli/{chunk-SL6MYJYM.js → chunk-MJTVX4QK.js} +35 -35
  183. package/dist/cli/{chunk-7IKQKKNX.js → chunk-MLABYI4M.js} +90 -24
  184. package/dist/cli/{chunk-ZIAXDBXX.mjs → chunk-NDNHYONK.mjs} +17 -21
  185. package/dist/cli/{chunk-YLTMXJFC.mjs → chunk-OTV2UUKW.mjs} +158 -16
  186. package/dist/cli/{chunk-G4O75EXF.js → chunk-Q6Z6N3A7.js} +18 -18
  187. package/dist/cli/{chunk-WE5HES3H.mjs → chunk-QG6JIWUL.mjs} +151 -43
  188. package/dist/cli/{chunk-QY3ZNU6Z.mjs → chunk-QI5S5HWB.mjs} +2 -2
  189. package/dist/cli/{chunk-CBV7AKWM.js → chunk-R6DZ6NQ2.js} +5 -5
  190. package/dist/cli/{chunk-57VZVF5D.mjs → chunk-RMNOZKRI.mjs} +3 -3
  191. package/dist/cli/{chunk-BAIST2BR.js → chunk-RTV4RF7N.js} +36 -36
  192. package/dist/cli/{chunk-JWUAX6OP.js → chunk-SBH4CKPN.js} +11 -11
  193. package/dist/cli/{chunk-FTJLJCE5.mjs → chunk-SG3LUONJ.mjs} +3 -3
  194. package/dist/cli/{chunk-2WFPHBR4.js → chunk-TFEXSHPM.js} +22 -18
  195. package/dist/cli/{chunk-QAORXEY3.mjs → chunk-TN4TY6TT.mjs} +6 -7
  196. package/dist/cli/{chunk-WEHCBH5R.mjs → chunk-UEVKMZLR.mjs} +54 -3
  197. package/dist/cli/{chunk-QILKGXYF.mjs → chunk-UVQJYV76.mjs} +2 -2
  198. package/dist/cli/{chunk-FSIVF2SI.mjs → chunk-VZGLIK5U.mjs} +1 -1
  199. package/dist/cli/{chunk-MF2GHZDO.js → chunk-WOCHZCUJ.js} +2 -2
  200. package/dist/cli/{chunk-VQALXEXO.js → chunk-XLIHTJVM.js} +348 -118
  201. package/dist/cli/{chunk-ADRC5I3R.js → chunk-Y6SP3JMI.js} +22 -22
  202. package/dist/cli/{chunk-77AAAGVB.js → chunk-YUA6HA6D.js} +2 -2
  203. package/dist/cli/{chunk-JL2OTMSG.mjs → chunk-Z3A2S3QM.mjs} +41 -0
  204. package/dist/cli/{chunk-6O5HOODW.mjs → chunk-Z6XPSHKM.mjs} +87 -41
  205. package/dist/cli/{chunk-QX7LFGJR.mjs → chunk-Z7AOIHFE.mjs} +1870 -91
  206. package/dist/cli/command-docs.js +3 -3
  207. package/dist/cli/command-docs.mjs +2 -2
  208. package/dist/cli/concurrent-runs-help-CFJH4KXV.js +22 -0
  209. package/dist/cli/{concurrent-runs-help-Q4KPAUJX.mjs → concurrent-runs-help-DNV2X5AZ.mjs} +9 -8
  210. package/dist/cli/{csv-F5VAGX4K.js → csv-SA6ELJY6.js} +16 -15
  211. package/dist/cli/{csv-2PTVDNO6.mjs → csv-ZXZGHWOM.mjs} +7 -6
  212. package/dist/cli/{db-IEDXAUF7.mjs → db-A54SP6AD.mjs} +16 -16
  213. package/dist/cli/{db-Z3OIUFMM.js → db-JHFEIQBU.js} +43 -43
  214. package/dist/cli/describe-PHQ33AGS.mjs +50 -0
  215. package/dist/cli/describe-RHJ4XRFI.js +50 -0
  216. package/dist/cli/describe-core.d.mts +3 -3
  217. package/dist/cli/describe-core.d.ts +3 -3
  218. package/dist/cli/describe-core.js +6 -6
  219. package/dist/cli/describe-core.mjs +5 -5
  220. package/dist/cli/{executions-R3LP74QN.mjs → executions-HL2M2DFU.mjs} +10 -10
  221. package/dist/cli/{executions-H6H5655J.js → executions-TLFZRHBJ.js} +12 -12
  222. package/dist/cli/{feedback-VFOUR66B.js → feedback-5UEX5UZK.js} +17 -16
  223. package/dist/cli/{feedback-WL3MRVT5.mjs → feedback-QMBTNXVG.mjs} +9 -8
  224. package/dist/cli/git-4JWOOHBG.js +26 -0
  225. package/dist/cli/{git-YX2J4GCI.mjs → git-LKGXVIVC.mjs} +8 -7
  226. package/dist/cli/index.js +170 -158
  227. package/dist/cli/index.mjs +60 -48
  228. package/dist/cli/{integrations-E2JZYKHS.js → integrations-6RUTLMN7.js} +23 -27
  229. package/dist/cli/{integrations-5ZK5KLVP.mjs → integrations-FGGRVUJ7.mjs} +15 -19
  230. package/dist/cli/{legacy-noops-3VW4IJTH.js → legacy-noops-J3Z7QRWZ.js} +12 -11
  231. package/dist/cli/{legacy-noops-SMN3GSXY.mjs → legacy-noops-YIPRMVXZ.mjs} +9 -8
  232. package/dist/cli/{mcp-UQV2K4EW.js → mcp-6LWFP7RW.js} +121 -48
  233. package/dist/cli/{mcp-V6MGCYAG.mjs → mcp-CHDYFO7F.mjs} +100 -27
  234. package/dist/cli/{monitors-R3BBDCRC.js → monitors-STM6A7OU.js} +221 -186
  235. package/dist/cli/{monitors-GGKS5W6M.mjs → monitors-UGRY2BXI.mjs} +58 -23
  236. package/dist/cli/org-3SYOUQCX.mjs +2289 -0
  237. package/dist/cli/org-ZOBSNSIB.js +2289 -0
  238. package/dist/cli/outcomes-H4YYAT5X.js +2865 -0
  239. package/dist/cli/outcomes-Z3P2JE67.mjs +2865 -0
  240. package/dist/cli/{play-2MVO27VO.js → play-SM4CW2GS.js} +1116 -846
  241. package/dist/cli/{play-MDWPR4XG.mjs → play-SN5YWLS7.mjs} +375 -105
  242. package/dist/cli/{providers-AKDYFZJZ.mjs → providers-WZ4YBR5Y.mjs} +10 -10
  243. package/dist/cli/{providers-2AACRUZH.js → providers-WZARYMCF.js} +13 -13
  244. package/dist/cli/{quickstart-QDGRJFZY.mjs → quickstart-2575BNKA.mjs} +7 -6
  245. package/dist/cli/{quickstart-H6IV3PV3.js → quickstart-PS4YHQJ6.js} +9 -8
  246. package/dist/cli/{run-2634REDK.js → run-FLZ6OTM7.js} +51 -51
  247. package/dist/cli/{run-RTSQNGRD.mjs → run-ZUHCZOJS.mjs} +31 -31
  248. package/dist/cli/run-identity-LMLFMACS.js +31 -0
  249. package/dist/cli/{run-identity-MRNCEGV2.mjs → run-identity-MAZ7ANH5.mjs} +9 -3
  250. package/dist/cli/{search-6AOJ4XPP.mjs → search-HLPPKQEO.mjs} +11 -11
  251. package/dist/cli/search-JJWVHR3N.js +32 -0
  252. package/dist/cli/{search-output-6ADMTOU5.mjs → search-output-PDAXNOGP.mjs} +9 -8
  253. package/dist/cli/{search-output-S5ODBL5E.js → search-output-RXJLU36B.js} +12 -11
  254. package/dist/cli/{secrets-TFIFBFB3.mjs → secrets-CGELYQ3H.mjs} +11 -11
  255. package/dist/cli/{secrets-LHCIIHMT.js → secrets-QJNG7G2Y.js} +20 -20
  256. package/dist/cli/sessions-DHTBT2GN.js +23 -0
  257. package/dist/cli/{sessions-WHBVUHVW.mjs → sessions-ELMWVR4M.mjs} +9 -8
  258. package/dist/cli/{settings-CP4FVK2W.js → settings-44I44P5F.js} +89 -89
  259. package/dist/cli/{settings-EBONWL5C.mjs → settings-RR3LZXL7.mjs} +16 -16
  260. package/dist/cli/{setup-I5AZE3IU.mjs → setup-KGWRWH4B.mjs} +20 -19
  261. package/dist/cli/{setup-LFGHTNLQ.js → setup-KTEYOCJO.js} +60 -59
  262. package/dist/cli/skills-EPZPEXI2.js +37 -0
  263. package/dist/cli/{skills-W76AO5XE.mjs → skills-FPRID2I5.mjs} +10 -9
  264. package/dist/cli/tools-IGQQ5TML.js +57 -0
  265. package/dist/cli/{tools-7IJHGF6W.mjs → tools-PI4WMDLY.mjs} +23 -23
  266. package/dist/cli/update-4RNCVYGE.js +37 -0
  267. package/dist/cli/{update-GFOPZTHY.mjs → update-VJOJAZ7B.mjs} +14 -11
  268. package/dist/cli/{views-BPL2TQJ4.js → views-NTUOLNQU.js} +62 -64
  269. package/dist/cli/{views-D4NX4SBG.mjs → views-OVPSINZO.mjs} +47 -49
  270. package/dist/cli/{workflow-ZYNAUCKC.js → workflow-2UDYDM6F.js} +23 -23
  271. package/dist/cli/{workflow-YXP42FUI.mjs → workflow-7OEFNXZC.mjs} +13 -13
  272. package/dist/{client-CyXGrO4D.d.mts → client-B8f7RNF8.d.mts} +1 -1
  273. package/dist/{client-Bf3IpUKN.d.ts → client-C5TgXmJQ.d.ts} +1 -1
  274. package/dist/{client-core-BxsLnXlm.d.mts → client-core-SLLGBTht.d.mts} +268 -23
  275. package/dist/{client-core-BWd0lX0Z.d.ts → client-core-p0sOxnkl.d.ts} +268 -23
  276. package/dist/{compiler-manifest-BqwVrOri.d.ts → compiler-manifest-D_zZEh9Q.d.mts} +70 -5
  277. package/dist/{compiler-manifest-BqwVrOri.d.mts → compiler-manifest-D_zZEh9Q.d.ts} +70 -5
  278. package/dist/{errors-BU8FB99X.d.mts → errors-CZCrBFrQ.d.mts} +1 -1
  279. package/dist/{errors-DfVN_FUG.d.ts → errors-DsUkLrdZ.d.ts} +1 -1
  280. package/dist/{index-BGnvtYGc.d.ts → index-B6RTOZGC.d.ts} +1 -1
  281. package/dist/{index-DjZgwpGw.d.mts → index-DeOVrEmX.d.mts} +1 -1
  282. package/dist/index.d.mts +7 -7
  283. package/dist/index.d.ts +7 -7
  284. package/dist/index.js +66 -55
  285. package/dist/index.mjs +25 -14
  286. package/dist/install-integrity.json +161 -142
  287. package/dist/plays/bundle-play-file.d.mts +3 -3
  288. package/dist/plays/bundle-play-file.d.ts +3 -3
  289. package/dist/plays/bundle-play-file.mjs +23 -4
  290. package/dist/plays/csv-data-input.js +3 -3
  291. package/dist/plays/csv-data-input.mjs +2 -2
  292. package/dist/plays/play-description.d.mts +2 -2
  293. package/dist/plays/play-description.d.ts +2 -2
  294. package/dist/plays/run-request.d.mts +2 -2
  295. package/dist/plays/run-request.d.ts +2 -2
  296. package/dist/plays/run-request.js +4 -4
  297. package/dist/plays/run-request.mjs +3 -3
  298. package/dist/release.d.mts +1 -1
  299. package/dist/release.d.ts +1 -1
  300. package/dist/release.js +2 -2
  301. package/dist/release.mjs +1 -1
  302. package/dist/server.d.mts +4 -4
  303. package/dist/server.d.ts +4 -4
  304. package/dist/server.js +15 -13
  305. package/dist/server.mjs +9 -7
  306. package/package.json +1 -1
  307. package/dist/cli/auth-MMNVWATX.js +0 -43
  308. package/dist/cli/concurrent-runs-help-FQAIHKKC.js +0 -21
  309. package/dist/cli/describe-QDANCTS3.mjs +0 -50
  310. package/dist/cli/describe-VUTT5ZKU.js +0 -50
  311. package/dist/cli/git-ETB3GH3K.js +0 -25
  312. package/dist/cli/org-GRYVMNSW.js +0 -1282
  313. package/dist/cli/org-Z37NGJV4.mjs +0 -1282
  314. package/dist/cli/run-identity-G257GQED.js +0 -25
  315. package/dist/cli/search-VTW2YNBS.js +0 -32
  316. package/dist/cli/sessions-CJ4FJ2WB.js +0 -22
  317. package/dist/cli/skills-R7EBXREW.js +0 -36
  318. package/dist/cli/tools-V7U2BDXM.js +0 -57
  319. package/dist/cli/update-4COPZETK.js +0 -34
@@ -58,6 +58,12 @@ export type ProviderMonitorIdentityReservation =
58
58
  monitorKey: string;
59
59
  state: 'provisioning' | 'active' | 'migration_conflict';
60
60
  conflictingMonitorKeys?: string[];
61
+ /**
62
+ * The holder is a deleted monitor that holds nothing by the lifecycle
63
+ * rules (#10305). The target is still occupied until an operator
64
+ * releases the orphaned claim.
65
+ */
66
+ holderOrphaned?: true;
61
67
  }
62
68
  | {
63
69
  kind: 'in_progress';
@@ -81,6 +87,8 @@ export type ProviderMonitorLifecycleReservation =
81
87
  kind: 'in_progress';
82
88
  state: 'provisioning' | 'deleting';
83
89
  retryAt: number;
90
+ /** A create whose provider answer was lost holds this fence. */
91
+ createOutcomeUnknown?: true;
84
92
  }
85
93
  | {
86
94
  kind: 'deleting';
@@ -142,6 +150,9 @@ export function normalizeProviderMonitorLifecycleReservation(input: {
142
150
  kind: 'in_progress',
143
151
  state: result.state as 'provisioning' | 'deleting',
144
152
  retryAt: result.retryAt as number,
153
+ ...(result.createOutcomeUnknown === true
154
+ ? { createOutcomeUnknown: true as const }
155
+ : {}),
145
156
  };
146
157
  }
147
158
  return {
@@ -297,6 +308,12 @@ export async function beginProviderMonitorLifecycleReservation(input: {
297
308
  priorityExecutionSlots?: number;
298
309
  expectedControlStateRevision?: number;
299
310
  requiredMonitorStatus?: 'active';
311
+ /**
312
+ * A deploy or start's request time. The provisioning fence records it on
313
+ * the monitor, so an older customer stop waiting for the fence leaves the
314
+ * monitor running. Ignored for a deletion.
315
+ */
316
+ requestedAt?: number;
300
317
  }): Promise<ProviderMonitorLifecycleReservation> {
301
318
  const operationId = input.operationId ?? randomUUID();
302
319
  const action =
@@ -318,6 +335,9 @@ export async function beginProviderMonitorLifecycleReservation(input: {
318
335
  ...(input.requiredMonitorStatus
319
336
  ? { requiredMonitorStatus: input.requiredMonitorStatus }
320
337
  : {}),
338
+ ...(input.state === 'provisioning' && input.requestedAt !== undefined
339
+ ? { requestedAt: input.requestedAt }
340
+ : {}),
321
341
  });
322
342
  let result = await retryProviderMonitorLifecycleAdmission(request);
323
343
  if (result.kind === 'backfill_required') {
@@ -383,6 +403,8 @@ export async function beginProviderMonitorProvisioningBatch(input: {
383
403
  operationId: string;
384
404
  entityKey?: string | null;
385
405
  }>;
406
+ /** The deploy or start's request time; see the scalar reservation. */
407
+ requestedAt?: number;
386
408
  }): Promise<Map<string, ProviderMonitorLifecycleAdmission>> {
387
409
  const client = getRequiredInternalConvexClient();
388
410
  const orgId = input.auth.orgId;
@@ -396,6 +418,9 @@ export async function beginProviderMonitorProvisioningBatch(input: {
396
418
  operationId: item.operationId,
397
419
  entityKey: item.entityKey ?? null,
398
420
  state: 'provisioning',
421
+ ...(input.requestedAt === undefined
422
+ ? {}
423
+ : { requestedAt: input.requestedAt }),
399
424
  });
400
425
  for (
401
426
  let offset = 0;
@@ -455,6 +480,9 @@ export async function beginProviderMonitorProvisioningBatch(input: {
455
480
  {
456
481
  orgId,
457
482
  ...(admission ? { reservationId } : {}),
483
+ ...(input.requestedAt === undefined
484
+ ? {}
485
+ : { requestedAt: input.requestedAt }),
458
486
  items: chunk.map((item) => ({
459
487
  monitorKey: item.monitorKey,
460
488
  operationId: item.operationId,
@@ -595,6 +623,29 @@ export function failProviderMonitorLifecycleReservation(input: {
595
623
  );
596
624
  }
597
625
 
626
+ /**
627
+ * Keep a create's lifecycle fence while its provider outcome is unknown (see
628
+ * `holdLifecycleProvisioning`). Returns when the hold ends, or null when this
629
+ * operation no longer holds the fence.
630
+ */
631
+ export async function holdProviderMonitorLifecycleProvisioning(input: {
632
+ auth: OrgAuthContext;
633
+ monitorKey: string;
634
+ operationId: string;
635
+ }): Promise<number | null> {
636
+ const result = (await getRequiredInternalConvexClient().mutation(
637
+ internal.providerMonitorIdentityClaims.holdLifecycleProvisioning,
638
+ {
639
+ orgId: input.auth.orgId,
640
+ monitorKey: input.monitorKey,
641
+ operationId: input.operationId,
642
+ },
643
+ )) as { held: boolean; leaseExpiresAt?: number };
644
+ return result.held && typeof result.leaseExpiresAt === 'number'
645
+ ? result.leaseExpiresAt
646
+ : null;
647
+ }
648
+
598
649
  export async function beginProviderMonitorIdentityReservation(input: {
599
650
  auth: OrgAuthContext;
600
651
  monitorKey: string;
@@ -606,11 +657,17 @@ export async function beginProviderMonitorIdentityReservation(input: {
606
657
  * see `reclaimSelfProvisioning` on the mutation.
607
658
  */
608
659
  reclaimSelfProvisioning?: boolean;
660
+ /**
661
+ * The id to reserve under. A Fleet create passes its fence's op id, so the
662
+ * settle that clears that fence ends exactly the reservations its pass made
663
+ * (`endFenceReservationsInMutation`). Defaults to a new id.
664
+ */
665
+ operationId?: string;
609
666
  }): Promise<ProviderMonitorIdentityReservation | null> {
610
667
  const claim = providerMonitorIdentityClaim(input);
611
668
  if (!claim) return null;
612
669
  await ensureProviderMonitorIdentityBackfill({ auth: input.auth });
613
- const operationId = randomUUID();
670
+ const operationId = input.operationId ?? randomUUID();
614
671
  const result = await getRequiredInternalConvexClient().mutation(
615
672
  internal.providerMonitorIdentityClaims.begin,
616
673
  {
@@ -639,45 +696,24 @@ export async function beginProviderMonitorIdentityReservation(input: {
639
696
  return { ...result, claim };
640
697
  }
641
698
 
642
- async function mutateClaim(
643
- action: 'activate' | 'release',
644
- input: {
645
- auth: OrgAuthContext;
646
- monitorKey: string;
647
- claim: ProviderMonitorIdentityClaim;
648
- operationId?: string;
649
- },
650
- ) {
699
+ export function activateProviderMonitorIdentityReservation(input: {
700
+ auth: OrgAuthContext;
701
+ monitorKey: string;
702
+ claim: ProviderMonitorIdentityClaim;
703
+ operationId: string;
704
+ }) {
651
705
  return getRequiredInternalConvexClient().mutation(
652
- internal.providerMonitorIdentityClaims[action],
706
+ internal.providerMonitorIdentityClaims.activate,
653
707
  {
654
708
  orgId: input.auth.orgId,
655
709
  tool: input.claim.tool,
656
710
  identityKey: input.claim.identityKey,
657
- ...(action === 'release' ? { scopeKey: input.claim.scopeKey } : {}),
658
711
  monitorKey: input.monitorKey,
659
- ...(input.operationId ? { operationId: input.operationId } : {}),
712
+ operationId: input.operationId,
660
713
  },
661
714
  );
662
715
  }
663
716
 
664
- export function activateProviderMonitorIdentityReservation(input: {
665
- auth: OrgAuthContext;
666
- monitorKey: string;
667
- claim: ProviderMonitorIdentityClaim;
668
- operationId: string;
669
- }) {
670
- return mutateClaim('activate', input);
671
- }
672
-
673
- export function releaseProviderMonitorIdentityClaim(input: {
674
- auth: OrgAuthContext;
675
- monitorKey: string;
676
- claim: ProviderMonitorIdentityClaim;
677
- }) {
678
- return mutateClaim('release', input);
679
- }
680
-
681
717
  export function failProviderMonitorIdentityReservation(input: {
682
718
  auth: OrgAuthContext;
683
719
  monitorKey: string;
@@ -81,6 +81,36 @@ export function providerMonitorResourceId(
81
81
  return normalized === '' ? null : (normalized as ProviderMonitorResourceId);
82
82
  }
83
83
 
84
+ /**
85
+ * The binding identity every native monitor row records
86
+ * (`_dl_binding_id`, `_dl_monitor_binding_version`), read from the stored
87
+ * provider binding. Each inbound handler passes it to its row writer, so a
88
+ * row says which binding of the monitor delivered it, including across a
89
+ * replacement.
90
+ */
91
+ export function providerMonitorBindingWriteIdentity(
92
+ binding: Record<string, unknown>,
93
+ ): { bindingId?: string; bindingVersion?: number } {
94
+ const bindingId =
95
+ typeof binding.binding_id === 'string' && binding.binding_id.trim()
96
+ ? binding.binding_id
97
+ : undefined;
98
+ const rawVersion = binding.binding_version;
99
+ const parsedVersion =
100
+ typeof rawVersion === 'number'
101
+ ? rawVersion
102
+ : typeof rawVersion === 'string' && rawVersion.trim()
103
+ ? Number(rawVersion)
104
+ : Number.NaN;
105
+ const bindingVersion = Number.isFinite(parsedVersion)
106
+ ? parsedVersion
107
+ : undefined;
108
+ return {
109
+ ...(bindingId === undefined ? {} : { bindingId }),
110
+ ...(bindingVersion === undefined ? {} : { bindingVersion }),
111
+ };
112
+ }
113
+
84
114
  /**
85
115
  * A provider-neutral proof that this control record has an upstream
86
116
  * counterpart. The identifier might be a radar id today and a different
@@ -49,6 +49,23 @@ export function isKnownTamradarRadarFailureReason(reason: string): boolean {
49
49
  return KNOWN_TAMRADAR_RADAR_FAILURE_REASONS.has(reason);
50
50
  }
51
51
 
52
+ /**
53
+ * The provider stopped running the monitor on its own after repeated failed
54
+ * runs: Exa disables a monitor after 10 consecutive failed runs, and the
55
+ * monitor audit reads that status (`readProviderStatus` on the capability).
56
+ * It errors the monitor at once: a recreate from the same payload would run
57
+ * into the same failures.
58
+ */
59
+ export const PROVIDER_MONITOR_DISABLED_REASON = 'monitor_disabled';
60
+
61
+ /** Every reason the errored rule has been decided for, any provider. */
62
+ function isKnownProviderResourceFailureReason(reason: string): boolean {
63
+ return (
64
+ isKnownTamradarRadarFailureReason(reason) ||
65
+ reason === PROVIDER_MONITOR_DISABLED_REASON
66
+ );
67
+ }
68
+
52
69
  /**
53
70
  * The `provider`-owned deactivation reasons that mean `errored`. Declared in
54
71
  * `deactivation-reasons.ts`; repeated here, import-free, so the customer state
@@ -147,7 +164,10 @@ export function decideProviderResourceFailure(input: {
147
164
  deactivationReason: 'provider_source_inaccessible',
148
165
  };
149
166
  }
150
- if (failureCount >= PROVIDER_RESOURCE_FAILURES_BEFORE_ERRORED) {
167
+ if (
168
+ event.reason === PROVIDER_MONITOR_DISABLED_REASON ||
169
+ failureCount >= PROVIDER_RESOURCE_FAILURES_BEFORE_ERRORED
170
+ ) {
151
171
  return {
152
172
  kind: 'errored',
153
173
  failure,
@@ -220,6 +240,9 @@ export function providerResourceFailureMessage(input: {
220
240
  ? "This LinkedIn URL no longer resolves (the provider could not reach it). Update the monitor with the person's current URL, or remove it."
221
241
  : 'The provider could not reach the source this monitor watches (reason: source_inaccessible). Update the monitor with a source that resolves, or remove it.';
222
242
  }
243
+ if (input.reason === PROVIDER_MONITOR_DISABLED_REASON) {
244
+ return 'The provider stopped running this monitor after repeated failed runs (reason: monitor_disabled). Check the connected key if it uses your own, then update the monitor, or remove it.';
245
+ }
223
246
  return `The provider could not run this monitor (reason: ${input.reason}). Update or remove the monitor.`;
224
247
  }
225
248
 
@@ -309,11 +332,11 @@ export function providerResourceFailureAlert(input: {
309
332
  sourceCapability?: string | null;
310
333
  }): { reason: string; detail: string } | null {
311
334
  if (input.outcome === 'duplicate') return null;
312
- const unknownReason = !isKnownTamradarRadarFailureReason(input.reason);
335
+ const unknownReason = !isKnownProviderResourceFailureReason(input.reason);
313
336
  const errored = input.outcome === 'errored';
314
337
  if (!errored && !unknownReason) return null;
315
338
  const parts = [
316
- `radar_failure reason=${input.reason} on radar ${input.providerResourceId}`,
339
+ `provider resource failure reason=${input.reason} on ${input.providerResourceId}`,
317
340
  `outcome=${input.outcome}`,
318
341
  ...(input.failureCount ? [`failure ${input.failureCount}`] : []),
319
342
  ...(input.errorId ? [`error_id=${input.errorId}`] : []),
@@ -6,6 +6,7 @@ import {
6
6
  PROVIDER_MONITOR_CONTROL_STATE_PENDING_CODE,
7
7
  } from '@deepline/monitors/signal-radars/inbound-failure-codes';
8
8
  import type { SignalRadarInboundMessage } from '@deepline/monitors/signal-radars/inbound-message';
9
+ import { rawReceiptWriteFailedError } from '@deepline/monitors/signal-radars/raw-receipt-causes';
9
10
  import {
10
11
  hasMonitorSdkValidationIssues,
11
12
  MONITOR_SDK_VALIDATION_ERROR_CODE,
@@ -110,6 +111,17 @@ function inboundFailureCode(error: unknown): string {
110
111
  : '';
111
112
  }
112
113
 
114
+ /** The raw receipt a failed delivery left `write_failed`, when it names one. */
115
+ function inboundFailureRawId(error: unknown): string | null {
116
+ const rawId =
117
+ error && typeof error === 'object'
118
+ ? (error as { rawId?: unknown }).rawId
119
+ : undefined;
120
+ return typeof rawId === 'string' && rawId.length > 0 && rawId.length <= 300
121
+ ? rawId
122
+ : null;
123
+ }
124
+
113
125
  export function classifyInboundFailure(error: unknown): InboundFailureClass {
114
126
  if (isRepairableTenantDataPlaneError(error)) return 'transient';
115
127
 
@@ -221,23 +233,40 @@ type DeadLetterMessageInput = Pick<
221
233
 
222
234
  async function markCapturedRawWriteFailed(
223
235
  client: InboundPgClient,
224
- eventIdempotencyKey: string,
236
+ receipt: { eventIdempotencyKey: string | null; rawId: string | null },
225
237
  lastError: string,
226
238
  ) {
227
239
  // The capture-first raw row (dl_meta.monitor_inbound_raw) may already exist for
228
240
  // this event. Flip it to write_failed so on-call sees "captured, dead-lettered,
229
- // replayable" in one place. Best-effort: a missing table/row must not block the
241
+ // replayable" in one place; the `dead_lettered` cause points the raw-receipt
242
+ // reader at the dead letter. Best-effort: a missing table/row must not block the
230
243
  // dead-letter record itself.
244
+ //
245
+ // A receipt keyed by the receiver's key is found by that key. One keyed by a
246
+ // semantic finding identity (every TamRadar finding) has another key, so the
247
+ // worker names it by id. That receipt is marked only while it still holds
248
+ // the failure this dead letter records (`write_failed`, with the writer's
249
+ // own message, which is the failure's message): a redelivery that has since
250
+ // reclaimed it, written it, or failed it another way is left alone.
251
+ if (!receipt.eventIdempotencyKey && !receipt.rawId) return;
231
252
  try {
232
253
  await client.query(
233
254
  `UPDATE dl_meta.monitor_inbound_raw
234
255
  SET status = 'write_failed', error = $2, updated_at = now()
235
- WHERE event_idempotency_key = $1`,
236
- [eventIdempotencyKey, lastError.slice(0, 4000)],
256
+ WHERE ($1::text IS NOT NULL AND event_idempotency_key = $1::text)
257
+ OR ($3::text IS NOT NULL AND raw_id = $3::text
258
+ AND status = 'write_failed' AND error = $4::text)`,
259
+ [
260
+ receipt.eventIdempotencyKey,
261
+ rawReceiptWriteFailedError('dead_lettered', lastError).slice(0, 4000),
262
+ receipt.rawId,
263
+ lastError,
264
+ ],
237
265
  );
238
266
  } catch (error) {
239
267
  console.warn('[signal-radar.dead_letter.raw_mark_failed]', {
240
- event_idempotency_key: eventIdempotencyKey,
268
+ event_idempotency_key: receipt.eventIdempotencyKey,
269
+ raw_id: receipt.rawId,
241
270
  error: error instanceof Error ? error.message : String(error),
242
271
  });
243
272
  }
@@ -264,6 +293,10 @@ export async function recordSignalRadarDeadLetter(input: {
264
293
  const { client, message } = input;
265
294
  const lastError = errorMessage(input.error);
266
295
  const eventIdempotencyKey = message.eventIdempotencyKey ?? null;
296
+ const rawReceipt = {
297
+ eventIdempotencyKey,
298
+ rawId: inboundFailureRawId(input.error),
299
+ };
267
300
  const payload = {
268
301
  provider: message.provider,
269
302
  orgId: message.orgId,
@@ -315,13 +348,7 @@ export async function recordSignalRadarDeadLetter(input: {
315
348
  'Signal radar dead-letter status changed while recording a failure.',
316
349
  );
317
350
  }
318
- if (eventIdempotencyKey) {
319
- await markCapturedRawWriteFailed(
320
- client,
321
- eventIdempotencyKey,
322
- lastError,
323
- );
324
- }
351
+ await markCapturedRawWriteFailed(client, rawReceipt, lastError);
325
352
  return;
326
353
  }
327
354
  }
@@ -360,7 +387,7 @@ export async function recordSignalRadarDeadLetter(input: {
360
387
  lastError.slice(0, 8000),
361
388
  ],
362
389
  );
363
- await markCapturedRawWriteFailed(client, eventIdempotencyKey, lastError);
390
+ await markCapturedRawWriteFailed(client, rawReceipt, lastError);
364
391
  return;
365
392
  }
366
393
 
@@ -382,6 +409,7 @@ export async function recordSignalRadarDeadLetter(input: {
382
409
  lastError.slice(0, 8000),
383
410
  ],
384
411
  );
412
+ await markCapturedRawWriteFailed(client, rawReceipt, lastError);
385
413
  }
386
414
 
387
415
  // The load-bearing retry-callback decision (plan §4a). Runs on every handler
@@ -0,0 +1,219 @@
1
+ // Why a captured raw callback receipt (`dl_meta.monitor_inbound_raw`) ended
2
+ // `write_failed`. The inbound processor and the dead-letter recorder write the
3
+ // `error` text with `rawReceiptWriteFailedError`; the admin queue reader and
4
+ // the daily dead-letter digest read it back with `classifyRawReceiptError`.
5
+ // Both sides use this one table, so a new or reworded cause cannot drift into
6
+ // the generic typed-write failure (every `write_failed` once read as one).
7
+ //
8
+ // Many `write_failed` receipts are deliberate: a billing-suspended, inactive,
9
+ // errored or retired-binding monitor captures raw-only on purpose, and a
10
+ // finding refused for credits is never recovered (KAR-43). `expected` marks
11
+ // those, so the digest can leave them out of its "needs attention" count.
12
+ import { PROVIDER_CALLBACK_TYPED_WRITE_FAILED_CODE } from './inbound-failure-codes';
13
+
14
+ type ExactCause = {
15
+ readonly text: string;
16
+ readonly expected: boolean;
17
+ readonly message: string;
18
+ };
19
+ type PrefixCause = {
20
+ readonly prefix: string;
21
+ readonly expected: boolean;
22
+ readonly message: string;
23
+ /**
24
+ * `reason`: the detail is a short machine reason (for example
25
+ * `insufficient_credits`) and is shown in the operator message. `withheld`:
26
+ * the detail is free text (an exception message) and is never echoed.
27
+ */
28
+ readonly detail: 'reason' | 'withheld';
29
+ };
30
+ /**
31
+ * The real typed-write failure stores the writer's own message, unchanged, as
32
+ * it always has. It is what any text no other cause owns reads as.
33
+ */
34
+ type FallbackCause = {
35
+ readonly fallback: true;
36
+ readonly expected: false;
37
+ readonly message: string;
38
+ };
39
+ type Cause = ExactCause | PrefixCause | FallbackCause;
40
+
41
+ /** The generic code, kept only for a real typed-write failure. */
42
+ export const RAW_RECEIPT_TYPED_WRITE_FAILED_CODE =
43
+ PROVIDER_CALLBACK_TYPED_WRITE_FAILED_CODE;
44
+
45
+ export const RAW_RECEIPT_CAUSES = {
46
+ binding_retired_raw_only: {
47
+ text: 'Callback matched a retired provider binding during cleanup; typed write skipped.',
48
+ expected: true,
49
+ message:
50
+ 'Captured raw-only on purpose: the callback matched a retired provider binding during cleanup, so no row was written.',
51
+ },
52
+ billing_suspended_raw_only: {
53
+ text: 'Monitor billing is suspended; typed write skipped.',
54
+ expected: true,
55
+ message:
56
+ "Captured raw-only on purpose: the monitor's billing is suspended, so no row was written.",
57
+ },
58
+ monitor_inactive_raw_only: {
59
+ text: 'Monitor is inactive; typed write skipped.',
60
+ expected: true,
61
+ message:
62
+ 'Captured raw-only on purpose: the monitor is inactive, so no row was written.',
63
+ },
64
+ monitor_errored_raw_only: {
65
+ text: 'Monitor is errored; typed write skipped.',
66
+ expected: true,
67
+ message:
68
+ 'Captured raw-only on purpose: the monitor is errored, so no row was written, charged or dispatched.',
69
+ },
70
+ post_write_credit_exhausted: {
71
+ text: 'A provider event was already admitted before the credit balance changed; no automatic monitor suspension was started.',
72
+ expected: false,
73
+ message:
74
+ 'The typed row was written, then the credit balance changed before delivery finished; no monitor suspension was started.',
75
+ },
76
+ monitor_billing_denied: {
77
+ prefix: 'Monitor billing admission denied before typed write: ',
78
+ detail: 'reason',
79
+ expected: true,
80
+ message:
81
+ 'Refused before the typed write because billing admission was denied; refused findings are not recovered and cannot be redriven.',
82
+ },
83
+ billing_preflight_failed: {
84
+ prefix: 'Monitor billing preflight failed before typed write: ',
85
+ detail: 'reason',
86
+ expected: false,
87
+ message:
88
+ 'Billing preflight failed before the typed write; no row was written and the monitor was moved to billing suspension.',
89
+ },
90
+ post_write_billing_suspended: {
91
+ prefix: 'Post-write delivery incomplete: ',
92
+ detail: 'reason',
93
+ expected: false,
94
+ message:
95
+ 'The typed row was written, but billing failed before delivery finished; the monitor was moved to billing suspension.',
96
+ },
97
+ billing_settle_unavailable_after_write: {
98
+ prefix: 'Billing settle unavailable after typed write: ',
99
+ detail: 'withheld',
100
+ expected: false,
101
+ message:
102
+ 'The typed row was written, but billing settlement was unavailable; the inbound queue retries the receipt.',
103
+ },
104
+ dispatch_failed_after_write: {
105
+ prefix: 'Inline dispatch failed after typed write: ',
106
+ detail: 'withheld',
107
+ expected: false,
108
+ message:
109
+ 'The typed row was written and billed, but the inline dispatch after it failed.',
110
+ },
111
+ retryable_failure_redelivery_pending: {
112
+ prefix: 'Retryable failure; the inbound queue redelivers this receipt: ',
113
+ detail: 'withheld',
114
+ expected: false,
115
+ message:
116
+ 'A retryable failure after capture; the inbound queue redelivers the receipt, and one that uses up its deliveries becomes a dead letter.',
117
+ },
118
+ dead_lettered: {
119
+ prefix: 'Dead-lettered: ',
120
+ detail: 'withheld',
121
+ expected: false,
122
+ message:
123
+ 'The event used up its deliveries and was dead-lettered; act on its signal-radar-inbound-legacy-dlq item.',
124
+ },
125
+ [RAW_RECEIPT_TYPED_WRITE_FAILED_CODE]: {
126
+ fallback: true,
127
+ expected: false,
128
+ message: 'The provider callback could not be written by its typed owner.',
129
+ },
130
+ } as const satisfies Record<string, Cause>;
131
+
132
+ export type RawReceiptCauseCode = keyof typeof RAW_RECEIPT_CAUSES;
133
+ type ExactCauseCode = {
134
+ [Code in RawReceiptCauseCode]: (typeof RAW_RECEIPT_CAUSES)[Code] extends {
135
+ text: string;
136
+ }
137
+ ? Code
138
+ : never;
139
+ }[RawReceiptCauseCode];
140
+
141
+ const CAUSE_ENTRIES = Object.entries(RAW_RECEIPT_CAUSES) as Array<
142
+ [RawReceiptCauseCode, Cause]
143
+ >;
144
+
145
+ /** The `error` text a `write_failed` mark stores for one cause. */
146
+ export function rawReceiptWriteFailedError<Code extends RawReceiptCauseCode>(
147
+ code: Code,
148
+ ...detail: Code extends ExactCauseCode ? [] : [detail: string]
149
+ ): string {
150
+ const cause: Cause = RAW_RECEIPT_CAUSES[code];
151
+ if ('text' in cause) return cause.text;
152
+ if ('prefix' in cause) return `${cause.prefix}${detail[0] ?? ''}`;
153
+ return detail[0] ?? '';
154
+ }
155
+
156
+ export type RawReceiptCause = {
157
+ code: RawReceiptCauseCode;
158
+ /** Captured raw-only on purpose; nothing to recover. */
159
+ expected: boolean;
160
+ message: string;
161
+ };
162
+
163
+ const REASON = /^[a-z][a-z0-9_]{0,63}$/;
164
+
165
+ /**
166
+ * The cause of a `write_failed` receipt from its stored `error` text. Text no
167
+ * other cause owns - the real typed-write failure, an empty error, or one
168
+ * stored before this table existed - reads as the generic typed-write failure,
169
+ * as every receipt did before.
170
+ */
171
+ export function classifyRawReceiptError(value: unknown): RawReceiptCause {
172
+ const text = typeof value === 'string' ? value : '';
173
+ for (const [code, cause] of CAUSE_ENTRIES) {
174
+ if ('text' in cause) {
175
+ if (text === cause.text) {
176
+ return { code, expected: cause.expected, message: cause.message };
177
+ }
178
+ continue;
179
+ }
180
+ if (!('prefix' in cause) || !text.startsWith(cause.prefix)) continue;
181
+ const detail = text.slice(cause.prefix.length);
182
+ return {
183
+ code,
184
+ expected: cause.expected,
185
+ message:
186
+ cause.detail === 'reason' && REASON.test(detail)
187
+ ? `${cause.message} Reason: ${detail}.`
188
+ : cause.message,
189
+ };
190
+ }
191
+ const fallback = RAW_RECEIPT_CAUSES[RAW_RECEIPT_TYPED_WRITE_FAILED_CODE];
192
+ return {
193
+ code: RAW_RECEIPT_TYPED_WRITE_FAILED_CODE,
194
+ expected: fallback.expected,
195
+ message: fallback.message,
196
+ };
197
+ }
198
+
199
+ /**
200
+ * One SQL `CASE` expression that classifies `column` the way
201
+ * `classifyRawReceiptError` does, for a grouped count that never reads rows
202
+ * out. The texts are bound as parameters through `bind`, which returns the
203
+ * placeholder for each value.
204
+ */
205
+ export function rawReceiptCauseSqlCase(
206
+ column: string,
207
+ bind: (value: string) => string,
208
+ ): string {
209
+ const branches = CAUSE_ENTRIES.flatMap(([code, cause]) =>
210
+ 'text' in cause
211
+ ? [`WHEN ${column} = ${bind(cause.text)}::text THEN ${bind(code)}::text`]
212
+ : 'prefix' in cause
213
+ ? [
214
+ `WHEN starts_with(${column}, ${bind(cause.prefix)}::text) THEN ${bind(code)}::text`,
215
+ ]
216
+ : [],
217
+ );
218
+ return `CASE ${branches.join(' ')} ELSE ${bind(RAW_RECEIPT_TYPED_WRITE_FAILED_CODE)}::text END`;
219
+ }