deepline 0.3.492 → 0.3.493

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 (173) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +11 -5
  2. package/dist/bundling-sources/sdk/src/plays/run-request.ts +1 -0
  3. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  4. package/dist/bundling-sources/sdk/src/types.ts +6 -0
  5. package/dist/bundling-sources/shared_libs/monitors/fleets/verdict.ts +25 -9
  6. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +36 -0
  7. package/dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts +5 -4
  8. package/dist/bundling-sources/shared_libs/play-runtime/crustdata-company-identify-batching.ts +162 -0
  9. package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-reaper.ts +19 -3
  10. package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-batching-registry.ts +2 -0
  11. package/dist/bundling-sources/shared_libs/play-runtime/receipt-sql.ts +17 -23
  12. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-modal-fallback.ts +28 -1
  13. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sandbox-placement-policy.ts +75 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +20 -0
  15. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +412 -59
  16. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +38 -10
  17. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-ledger-reconciliation.ts +19 -11
  18. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-operation.ts +165 -12
  19. package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-state-machine.ts +358 -0
  20. package/dist/cli/{auth-4I6QY5WX.mjs → auth-3NAY3AST.mjs} +5 -5
  21. package/dist/cli/auth-KYQLDI6V.js +43 -0
  22. package/dist/cli/{billing-2H4GOJZY.js → billing-FSB4BBBO.js} +80 -80
  23. package/dist/cli/{billing-4F6L4JSI.mjs → billing-SBWQCC7B.mjs} +7 -7
  24. package/dist/cli/{chunk-MQ2LQOAM.mjs → chunk-2BRTYIAH.mjs} +23 -9
  25. package/dist/cli/{chunk-E47VAVAR.js → chunk-2H4OFVR5.js} +5 -5
  26. package/dist/cli/{chunk-ZDTPSVGF.js → chunk-2I7VN65H.js} +10 -10
  27. package/dist/cli/{chunk-LCCFGSV7.mjs → chunk-2IHGVAGT.mjs} +2 -2
  28. package/dist/cli/{chunk-BDUFZSUL.js → chunk-2NGIBJM2.js} +8 -8
  29. package/dist/cli/{chunk-OTUT3XTX.mjs → chunk-3QGUWB6E.mjs} +4 -4
  30. package/dist/cli/{chunk-3BRDP4UP.mjs → chunk-4IJFQV3O.mjs} +1 -1
  31. package/dist/cli/{chunk-PIC6M4X3.mjs → chunk-4NIGNT7X.mjs} +1 -1
  32. package/dist/cli/{chunk-YVOYZPMY.mjs → chunk-5DIZ2G74.mjs} +2 -2
  33. package/dist/cli/{chunk-TKLDKIJU.mjs → chunk-5JPKRDFC.mjs} +7 -5
  34. package/dist/cli/{chunk-FTXIJTV2.mjs → chunk-5WOPBX3H.mjs} +1 -1
  35. package/dist/cli/{chunk-R5MP3CIY.mjs → chunk-67ZG7XZV.mjs} +3 -3
  36. package/dist/cli/{chunk-W4FEX5ZF.js → chunk-7HABWOMB.js} +261 -261
  37. package/dist/cli/{chunk-FPLN7PHP.js → chunk-AGTXL6LZ.js} +5 -5
  38. package/dist/cli/{chunk-SE23YSBK.js → chunk-AWMCZAUR.js} +3 -3
  39. package/dist/cli/{chunk-HHTVRICE.js → chunk-C2MRDPA5.js} +17 -17
  40. package/dist/cli/{chunk-ONONSV2Q.mjs → chunk-DVQHG6AM.mjs} +1 -0
  41. package/dist/cli/{chunk-O3K22ZC7.js → chunk-DWJ4RXSA.js} +34 -11
  42. package/dist/cli/{chunk-6YO4OJPM.mjs → chunk-DYP27IWC.mjs} +99 -24
  43. package/dist/cli/{chunk-EANFUHRM.mjs → chunk-E5ILCMKQ.mjs} +1 -1
  44. package/dist/cli/{chunk-Y7QCMOGZ.mjs → chunk-EBAS3UT2.mjs} +6 -6
  45. package/dist/cli/{chunk-DJOLMS2A.js → chunk-EFO5GVYS.js} +1 -1
  46. package/dist/cli/{chunk-NF7NUKWF.js → chunk-EYG336YV.js} +132 -57
  47. package/dist/cli/{chunk-OKHBAAJG.mjs → chunk-GSC35TPZ.mjs} +2 -2
  48. package/dist/cli/{chunk-MPITIXW4.mjs → chunk-HLM2UFQ5.mjs} +13 -5
  49. package/dist/cli/{chunk-TVUE4CPW.js → chunk-HTUSTPP4.js} +32 -32
  50. package/dist/cli/{chunk-GDSZWTJK.mjs → chunk-IJJ6D5WL.mjs} +12 -12
  51. package/dist/cli/{chunk-3TISK5RQ.js → chunk-IJOHWGPF.js} +6 -6
  52. package/dist/cli/{chunk-NBL6JMIY.js → chunk-IOBPR2VO.js} +17 -17
  53. package/dist/cli/{chunk-EFFHRXKB.js → chunk-IOMEJKGK.js} +2 -2
  54. package/dist/cli/{chunk-A7ZMG2QZ.mjs → chunk-IRDYBMA7.mjs} +34 -11
  55. package/dist/cli/{chunk-B2JE3HD6.js → chunk-JO2JZUBR.js} +3 -3
  56. package/dist/cli/{chunk-4IP5MLWU.js → chunk-JO5FFSR7.js} +6 -1
  57. package/dist/cli/{chunk-O2FB42N2.js → chunk-KCDZWS2B.js} +56 -56
  58. package/dist/cli/{chunk-CGDUFVNE.mjs → chunk-KGDDQMI7.mjs} +2 -2
  59. package/dist/cli/{chunk-UUH4GQRL.mjs → chunk-KKSKYZO4.mjs} +1 -1
  60. package/dist/cli/{chunk-OTDX4A4W.js → chunk-LGTZYI5B.js} +21 -21
  61. package/dist/cli/{chunk-JJAHWKJ2.js → chunk-MLEUOTEQ.js} +73 -59
  62. package/dist/cli/{chunk-YOCEY4EI.mjs → chunk-NALJJTPS.mjs} +5 -5
  63. package/dist/cli/{chunk-HFEJ7JJT.js → chunk-NPNAEPY4.js} +26 -26
  64. package/dist/cli/{chunk-3IBKEOL4.js → chunk-NWIDPT7H.js} +4 -4
  65. package/dist/cli/{chunk-AUQQVDAB.js → chunk-PKV5CD3W.js} +1 -0
  66. package/dist/cli/{chunk-4RB74KJX.js → chunk-QTPS5RLG.js} +15 -15
  67. package/dist/cli/{chunk-4OLXMJ2L.js → chunk-RLX5ZFNX.js} +8 -6
  68. package/dist/cli/{chunk-DEJIN4DF.mjs → chunk-SAW3FBCA.mjs} +5 -0
  69. package/dist/cli/{chunk-RC366IJS.mjs → chunk-SXD2EYAH.mjs} +6 -6
  70. package/dist/cli/{chunk-YNWET57Z.js → chunk-TIFRRLZT.js} +7 -7
  71. package/dist/cli/{chunk-ZCKUNXXR.mjs → chunk-TNQOR6XQ.mjs} +1 -1
  72. package/dist/cli/{chunk-OGNIB64W.js → chunk-UCMY2SO2.js} +23 -15
  73. package/dist/cli/{chunk-O65HDVA7.mjs → chunk-VFHIYWMC.mjs} +5 -5
  74. package/dist/cli/{chunk-JHBRJDUC.js → chunk-WCZFCOMZ.js} +7 -7
  75. package/dist/cli/{chunk-FFOJRD53.mjs → chunk-WTFI7BVH.mjs} +3 -3
  76. package/dist/cli/{chunk-42Z6VC2Q.js → chunk-XLE7KXE7.js} +2 -2
  77. package/dist/cli/{chunk-Q3CCCTRQ.js → chunk-XQX476QK.js} +14 -14
  78. package/dist/cli/{chunk-F6EQWY4E.mjs → chunk-Y3NN2UAF.mjs} +2 -2
  79. package/dist/cli/{chunk-MJFVF5AW.mjs → chunk-ZQH4TXM2.mjs} +2 -2
  80. package/dist/cli/{chunk-DVGCPOEA.mjs → chunk-ZVW7EWTC.mjs} +7 -7
  81. package/dist/cli/{chunk-4GJIJHRQ.mjs → chunk-ZVXB7OU7.mjs} +1 -1
  82. package/dist/cli/command-docs.js +2 -2
  83. package/dist/cli/command-docs.mjs +1 -1
  84. package/dist/cli/{csv-JGJNDRSA.js → csv-DKYZE2KM.js} +13 -13
  85. package/dist/cli/{csv-VGXGV7YM.mjs → csv-XR22YQXT.mjs} +4 -4
  86. package/dist/cli/{db-OYG27ZBM.mjs → db-EOKG36YN.mjs} +7 -7
  87. package/dist/cli/{db-W52WJ6E5.js → db-RNYRTCMV.js} +28 -28
  88. package/dist/cli/describe-ICFXOQBW.mjs +50 -0
  89. package/dist/cli/describe-RS75I33X.js +50 -0
  90. package/dist/cli/describe-core.d.mts +2 -2
  91. package/dist/cli/describe-core.d.ts +2 -2
  92. package/dist/cli/describe-core.js +4 -4
  93. package/dist/cli/describe-core.mjs +3 -3
  94. package/dist/cli/{executions-EVE4KUGL.mjs → executions-3RAOACNS.mjs} +7 -7
  95. package/dist/cli/{executions-LAJHZGPY.js → executions-OBWPSWH7.js} +9 -9
  96. package/dist/cli/{feedback-75QB7KVG.mjs → feedback-6EQRVBKF.mjs} +4 -4
  97. package/dist/cli/{feedback-ZABCN7RT.js → feedback-6GPEUBLF.js} +8 -8
  98. package/dist/cli/getting-started.d.mts +12 -10
  99. package/dist/cli/getting-started.d.ts +12 -10
  100. package/dist/cli/getting-started.js +4 -2
  101. package/dist/cli/getting-started.mjs +3 -1
  102. package/dist/cli/{git-QIFEYQGY.mjs → git-CVQ24DTR.mjs} +5 -5
  103. package/dist/cli/git-DEFE4SSB.js +25 -0
  104. package/dist/cli/index.js +143 -143
  105. package/dist/cli/index.mjs +43 -43
  106. package/dist/cli/{legacy-noops-PNTWBBGY.mjs → legacy-noops-QULJZYNH.mjs} +5 -5
  107. package/dist/cli/{legacy-noops-2TBIAMCM.js → legacy-noops-XPOATG5V.js} +8 -8
  108. package/dist/cli/{monitors-LOHUYJEI.mjs → monitors-AFT5YJPZ.mjs} +49 -9
  109. package/dist/cli/{monitors-UKBOEGBS.js → monitors-OJ4CMREE.js} +169 -129
  110. package/dist/cli/{org-E7A6QLBW.js → org-RKT52CSL.js} +73 -73
  111. package/dist/cli/{org-JRUKUOUF.mjs → org-WHKNXANG.mjs} +7 -7
  112. package/dist/cli/{pages-K76HA473.mjs → pages-EEAQFGVD.mjs} +7 -7
  113. package/dist/cli/{pages-EUDFFLLD.js → pages-SOE3R667.js} +18 -18
  114. package/dist/cli/{play-DG2N66SV.mjs → play-LXFWHUBP.mjs} +147 -52
  115. package/dist/cli/{play-UWHNUJRA.js → play-OTJJ4E4T.js} +661 -566
  116. package/dist/cli/{providers-DZX6TTC6.js → providers-RU4HIAT3.js} +10 -10
  117. package/dist/cli/{providers-RUTTPUZD.mjs → providers-U3CPKTMM.mjs} +7 -7
  118. package/dist/cli/{quickstart-RGZZN2YE.mjs → quickstart-75AO2AJC.mjs} +5 -5
  119. package/dist/cli/{quickstart-U4NMD7KX.js → quickstart-N72IVA2Y.js} +13 -13
  120. package/dist/cli/{run-MOJWQYFQ.mjs → run-IGWFL6WH.mjs} +29 -28
  121. package/dist/cli/{run-5UNF4FHG.js → run-MMYES3IW.js} +44 -43
  122. package/dist/cli/search-EQURI7SZ.js +32 -0
  123. package/dist/cli/{search-5B3ZDU7H.mjs → search-FIYESBLZ.mjs} +8 -8
  124. package/dist/cli/{search-output-VQWJS3FN.js → search-output-2FXN4ZWD.js} +9 -6
  125. package/dist/cli/{search-output-QS4IWWHA.mjs → search-output-3I5KSW36.mjs} +7 -4
  126. package/dist/cli/{secrets-S3PJMEAC.js → secrets-HCZQ6JNP.js} +16 -16
  127. package/dist/cli/{secrets-V5XVDBIS.mjs → secrets-O7IUQ3VT.mjs} +7 -7
  128. package/dist/cli/{sessions-Y5QMEZ3D.js → sessions-5AYTT4IW.js} +6 -6
  129. package/dist/cli/{sessions-5V3X24XI.mjs → sessions-KY7A3EZO.mjs} +5 -5
  130. package/dist/cli/{settings-3U6RRO5F.js → settings-P4VFYWJK.js} +80 -80
  131. package/dist/cli/{settings-LHZYY5PT.mjs → settings-WSMRR2GS.mjs} +13 -13
  132. package/dist/cli/{setup-MLLIGO2S.js → setup-J7CA3EJL.js} +57 -57
  133. package/dist/cli/{setup-AJLWXYAN.mjs → setup-YTVKVQC7.mjs} +13 -13
  134. package/dist/cli/skills-KKPEGLAR.js +36 -0
  135. package/dist/cli/{skills-5O2MUWKK.mjs → skills-W5WY764N.mjs} +10 -10
  136. package/dist/cli/tools-65Y4QTW6.js +57 -0
  137. package/dist/cli/{tools-PWNMI5CD.mjs → tools-YECI6N3N.mjs} +20 -20
  138. package/dist/cli/{update-SXT4QW7S.mjs → update-BIFBIEII.mjs} +10 -10
  139. package/dist/cli/update-WDG7VFOW.js +34 -0
  140. package/dist/cli/{workflow-3WTF5IYT.js → workflow-D2TUFFH6.js} +18 -18
  141. package/dist/cli/{workflow-KPRM6ARO.mjs → workflow-XZVDNARC.mjs} +8 -8
  142. package/dist/{client-Cb1ej1Vr.d.ts → client-BDB_VbE4.d.ts} +1 -1
  143. package/dist/{client-vWpbLNCB.d.mts → client-CNzJ1LTF.d.mts} +1 -1
  144. package/dist/{client-core-CoBTvsXG.d.mts → client-core-CSv3DlPD.d.mts} +10 -3
  145. package/dist/{client-core-BmVs6SP0.d.ts → client-core-xEa9x3pl.d.ts} +10 -3
  146. package/dist/index.d.mts +3 -3
  147. package/dist/index.d.ts +3 -3
  148. package/dist/index.js +10 -10
  149. package/dist/index.mjs +7 -7
  150. package/dist/install-integrity.json +115 -114
  151. package/dist/plays/play-description.d.mts +1 -1
  152. package/dist/plays/play-description.d.ts +1 -1
  153. package/dist/plays/run-request.d.mts +1 -1
  154. package/dist/plays/run-request.d.ts +1 -1
  155. package/dist/plays/run-request.js +2 -2
  156. package/dist/plays/run-request.mjs +1 -1
  157. package/dist/release.d.mts +1 -1
  158. package/dist/release.d.ts +1 -1
  159. package/dist/release.js +2 -2
  160. package/dist/release.mjs +1 -1
  161. package/dist/server.d.mts +2 -2
  162. package/dist/server.d.ts +2 -2
  163. package/dist/server.js +6 -6
  164. package/dist/server.mjs +4 -4
  165. package/package.json +1 -1
  166. package/dist/cli/auth-7BCLZU6K.js +0 -43
  167. package/dist/cli/describe-FIXCRO5N.mjs +0 -50
  168. package/dist/cli/describe-G3O6OUBG.js +0 -50
  169. package/dist/cli/git-QBAR46NW.js +0 -25
  170. package/dist/cli/search-3DAEJL6S.js +0 -32
  171. package/dist/cli/skills-BBLIML5M.js +0 -36
  172. package/dist/cli/tools-X5SQXUMM.js +0 -57
  173. package/dist/cli/update-AEJ2ZSZQ.js +0 -34
@@ -6,6 +6,364 @@ export type WorkReceiptStateStatus =
6
6
  | 'failed'
7
7
  | 'skipped';
8
8
 
9
+ /**
10
+ * The receipt status machine, declared once for both receipt stores.
11
+ *
12
+ * Every SQL write of a receipt's status takes its allowed-from set from the
13
+ * tables below (`status = ANY($from)`), so the legal moves live here and not
14
+ * in each statement. `absent` is the source of an INSERT: no row exists yet.
15
+ *
16
+ * The two stores hold different machines and this module keeps both, side by
17
+ * side, so a change to one is a visible decision about the other:
18
+ *
19
+ * - The Postgres scheduler (`runtime_scheduler.receipts.status`, text) keeps
20
+ * `pending` (released, free to claim) apart from `queued` (marked by its
21
+ * live owner).
22
+ * - The customer-database store (`status smallint`) stores both as code 0,
23
+ * named `queued` here.
24
+ *
25
+ * `SCHEDULER_TENANT_WORK_RECEIPT_DIFFERENCES` lists where they disagree.
26
+ */
27
+ export const WORK_RECEIPT_STATUSES = [
28
+ 'queued',
29
+ 'pending',
30
+ 'running',
31
+ 'completed',
32
+ 'failed',
33
+ 'skipped',
34
+ ] as const satisfies readonly WorkReceiptStateStatus[];
35
+
36
+ /** Statuses the customer-database store can hold; `pending` is stored as `queued`. */
37
+ export const TENANT_WORK_RECEIPT_STATUSES = [
38
+ 'queued',
39
+ 'running',
40
+ 'completed',
41
+ 'failed',
42
+ 'skipped',
43
+ ] as const satisfies readonly WorkReceiptStateStatus[];
44
+
45
+ export const WORK_RECEIPT_TERMINAL_STATUSES = [
46
+ 'completed',
47
+ 'failed',
48
+ 'skipped',
49
+ ] as const satisfies readonly WorkReceiptStateStatus[];
50
+
51
+ /** Terminal receipts whose output later runs reuse instead of executing. */
52
+ export const WORK_RECEIPT_REUSABLE_STATUSES = [
53
+ 'completed',
54
+ 'skipped',
55
+ ] as const satisfies readonly WorkReceiptStateStatus[];
56
+
57
+ /** Live receipts: claimed by an owner run that has not finished the work. */
58
+ export const WORK_RECEIPT_LIVE_STATUSES = [
59
+ 'queued',
60
+ 'running',
61
+ ] as const satisfies readonly WorkReceiptStateStatus[];
62
+
63
+ export const WORK_RECEIPT_ABSENT = 'absent';
64
+ export type WorkReceiptTransitionSource =
65
+ | WorkReceiptStateStatus
66
+ | typeof WORK_RECEIPT_ABSENT;
67
+
68
+ export type WorkReceiptTransitionSpec = {
69
+ /** Statuses (or `absent`, for an INSERT) the write may start from. */
70
+ readonly from: readonly WorkReceiptTransitionSource[];
71
+ /** Statuses the write may produce. */
72
+ readonly to: readonly WorkReceiptStateStatus[];
73
+ };
74
+
75
+ /**
76
+ * `runtime_scheduler.receipts.status`. Each entry is one write in
77
+ * `scheduler-backends/postgres.ts`; the row-level fences (owner run, attempt,
78
+ * lease) stay in that SQL and narrow these sets further.
79
+ */
80
+ export const SCHEDULER_WORK_RECEIPT_TRANSITIONS = {
81
+ /** claimPostgresSchedulerReceipt(s). A live owner is taken over only when its run is terminal. */
82
+ claim: {
83
+ from: [WORK_RECEIPT_ABSENT, 'pending', 'failed', 'queued', 'running'],
84
+ to: ['running'],
85
+ },
86
+ /** Claim with `reclaimRunning`: an expired or unleased running receipt may be taken over. */
87
+ claim_reclaim_running: {
88
+ from: [WORK_RECEIPT_ABSENT, 'pending', 'failed', 'running'],
89
+ to: ['running'],
90
+ },
91
+ /** Claim with `forceRefresh`: a different run may replace reusable output. */
92
+ claim_force_refresh: {
93
+ from: [
94
+ WORK_RECEIPT_ABSENT,
95
+ 'pending',
96
+ 'failed',
97
+ 'running',
98
+ 'completed',
99
+ 'skipped',
100
+ ],
101
+ to: ['running'],
102
+ },
103
+ /** Leased completion by the running owner and attempt. */
104
+ complete: { from: ['running'], to: ['completed'] },
105
+ /**
106
+ * Immutable cache publication (`COMPLETED_RECEIPT_CACHE_INSERT_LEASE_ID`).
107
+ * It ignores leases: a publisher never waits on a peer, and a live owner's
108
+ * later leased completion matches no row and reads the published value.
109
+ */
110
+ publish_completed: {
111
+ from: [WORK_RECEIPT_ABSENT, 'queued', 'pending', 'running', 'failed'],
112
+ to: ['completed'],
113
+ },
114
+ fail: { from: ['running'], to: ['failed'] },
115
+ /** Exact release by the owner; `pending` is claimable by the next run. */
116
+ release: { from: ['running'], to: ['pending'] },
117
+ /** Attempt cleanup returns every receipt the attempt still holds. */
118
+ release_attempt: { from: ['queued', 'running'], to: ['pending'] },
119
+ mark_running: { from: ['queued', 'running'], to: ['running'] },
120
+ mark_queued: { from: ['queued', 'running'], to: ['queued'] },
121
+ skip: {
122
+ from: [WORK_RECEIPT_ABSENT, 'pending', 'failed', 'running'],
123
+ to: ['skipped'],
124
+ },
125
+ } as const satisfies Record<string, WorkReceiptTransitionSpec>;
126
+
127
+ export type SchedulerWorkReceiptTransition =
128
+ keyof typeof SCHEDULER_WORK_RECEIPT_TRANSITIONS;
129
+
130
+ /**
131
+ * Customer-database receipts (`apps/deepline-api` store-impl, SQL from
132
+ * `receipt-sql.ts`). A lease-aware claim produces `queued`, an unleased one
133
+ * `running`.
134
+ */
135
+ export const TENANT_WORK_RECEIPT_TRANSITIONS = {
136
+ claim: {
137
+ from: [WORK_RECEIPT_ABSENT, 'queued', 'failed'],
138
+ to: ['queued', 'running'],
139
+ },
140
+ claim_reclaim_running: {
141
+ from: [WORK_RECEIPT_ABSENT, 'queued', 'running', 'failed'],
142
+ to: ['queued', 'running'],
143
+ },
144
+ claim_force_refresh: {
145
+ from: [WORK_RECEIPT_ABSENT, 'queued', 'failed', 'completed', 'skipped'],
146
+ to: ['queued', 'running'],
147
+ },
148
+ claim_force_refresh_reclaim_running: {
149
+ from: [
150
+ WORK_RECEIPT_ABSENT,
151
+ 'queued',
152
+ 'failed',
153
+ 'running',
154
+ 'completed',
155
+ 'skipped',
156
+ ],
157
+ to: ['queued', 'running'],
158
+ },
159
+ complete: { from: ['queued', 'running'], to: ['completed'] },
160
+ publish_completed: {
161
+ from: [WORK_RECEIPT_ABSENT, 'queued', 'running', 'failed'],
162
+ to: ['completed'],
163
+ },
164
+ fail: { from: ['queued', 'running'], to: ['failed'] },
165
+ release: { from: ['queued', 'running'], to: ['queued'] },
166
+ mark_running: { from: ['queued', 'running'], to: ['running'] },
167
+ mark_queued: { from: ['queued', 'running'], to: ['queued'] },
168
+ skip: { from: ['queued', 'running'], to: ['skipped'] },
169
+ } as const satisfies Record<string, WorkReceiptTransitionSpec>;
170
+
171
+ export type TenantWorkReceiptTransition =
172
+ keyof typeof TENANT_WORK_RECEIPT_TRANSITIONS;
173
+
174
+ /**
175
+ * Every move out of a terminal status, by name. A transition table entry that
176
+ * leaves a terminal status without a row here fails the conformance test, so a
177
+ * new exit is always a named, reviewed decision.
178
+ */
179
+ export const WORK_RECEIPT_TERMINAL_EXITS = [
180
+ {
181
+ store: 'scheduler',
182
+ transition: 'claim',
183
+ from: 'failed',
184
+ why: 'Failed work is not reusable: another run, or the same run with forceFailedRefresh, retries it.',
185
+ },
186
+ {
187
+ store: 'scheduler',
188
+ transition: 'claim_reclaim_running',
189
+ from: 'failed',
190
+ why: 'As claim.',
191
+ },
192
+ {
193
+ store: 'scheduler',
194
+ transition: 'claim_force_refresh',
195
+ from: 'failed',
196
+ why: 'As claim.',
197
+ },
198
+ {
199
+ store: 'scheduler',
200
+ transition: 'claim_force_refresh',
201
+ from: 'completed',
202
+ why: 'Force refresh from a different run replaces reusable output (seedForcedRuntimeStepReceipts).',
203
+ },
204
+ {
205
+ store: 'scheduler',
206
+ transition: 'claim_force_refresh',
207
+ from: 'skipped',
208
+ why: 'As completed.',
209
+ },
210
+ {
211
+ store: 'scheduler',
212
+ transition: 'publish_completed',
213
+ from: 'failed',
214
+ why: 'A successful re-execution publishes over a non-reusable failure.',
215
+ },
216
+ {
217
+ store: 'scheduler',
218
+ transition: 'skip',
219
+ from: 'failed',
220
+ why: 'The same run (or an unowned row) records a skip over its own failure.',
221
+ },
222
+ {
223
+ store: 'tenant',
224
+ transition: 'claim',
225
+ from: 'failed',
226
+ why: 'As the scheduler claim.',
227
+ },
228
+ {
229
+ store: 'tenant',
230
+ transition: 'claim_reclaim_running',
231
+ from: 'failed',
232
+ why: 'As claim.',
233
+ },
234
+ {
235
+ store: 'tenant',
236
+ transition: 'claim_force_refresh',
237
+ from: 'failed',
238
+ why: 'As claim.',
239
+ },
240
+ {
241
+ store: 'tenant',
242
+ transition: 'claim_force_refresh',
243
+ from: 'completed',
244
+ why: 'As the scheduler force refresh.',
245
+ },
246
+ {
247
+ store: 'tenant',
248
+ transition: 'claim_force_refresh',
249
+ from: 'skipped',
250
+ why: 'As the scheduler force refresh.',
251
+ },
252
+ {
253
+ store: 'tenant',
254
+ transition: 'claim_force_refresh_reclaim_running',
255
+ from: 'failed',
256
+ why: 'As claim.',
257
+ },
258
+ {
259
+ store: 'tenant',
260
+ transition: 'claim_force_refresh_reclaim_running',
261
+ from: 'completed',
262
+ why: 'As the scheduler force refresh.',
263
+ },
264
+ {
265
+ store: 'tenant',
266
+ transition: 'claim_force_refresh_reclaim_running',
267
+ from: 'skipped',
268
+ why: 'As the scheduler force refresh.',
269
+ },
270
+ {
271
+ store: 'tenant',
272
+ transition: 'publish_completed',
273
+ from: 'failed',
274
+ why: 'As the scheduler publication.',
275
+ },
276
+ ] as const;
277
+
278
+ /**
279
+ * Where the two stores' tables disagree, by transition name, after reading the
280
+ * scheduler's `pending` as the customer store's `queued` (both mean free to
281
+ * claim). These predate the shared table and are kept as they are. The
282
+ * conformance test compares the tables and fails when this list no longer
283
+ * names exactly the transitions that differ.
284
+ */
285
+ export const SCHEDULER_TENANT_WORK_RECEIPT_DIFFERENCES = {
286
+ claim:
287
+ 'The scheduler always claims to running and may take over a live (queued or running) receipt once its owner run is terminal. A lease-aware customer claim produces queued, and the customer store claims running only with reclaimRunning.',
288
+ claim_reclaim_running:
289
+ 'The target differs, as for claim. The scheduler also refuses an owner-marked queued receipt, which the customer store cannot tell apart from a free one.',
290
+ claim_force_refresh:
291
+ 'The scheduler admits running on every force refresh, and refuses owner-marked queued; the customer store admits running only when reclaimRunning is also set (claim_force_refresh_reclaim_running).',
292
+ claim_force_refresh_reclaim_running:
293
+ 'Customer store only: the scheduler ignores reclaimRunning when forceRefresh is set.',
294
+ complete:
295
+ 'The scheduler requires running. The customer store also accepts queued, because its lease-aware claim produces queued.',
296
+ fail: 'As complete.',
297
+ release:
298
+ 'The scheduler releases running only; the customer store releases queued or running.',
299
+ release_attempt:
300
+ 'Scheduler only: attempt cleanup returns every receipt the attempt holds to pending.',
301
+ skip: 'The scheduler upserts a skip over an absent, pending, failed or running row; the customer store updates only a live owned row.',
302
+ } as const;
303
+
304
+ /** The SQL `status = ANY($from)` set for a scheduler transition (no `absent`). */
305
+ export function schedulerWorkReceiptFromStatuses(
306
+ transition: SchedulerWorkReceiptTransition,
307
+ ): WorkReceiptStateStatus[] {
308
+ return existingFromStatuses(SCHEDULER_WORK_RECEIPT_TRANSITIONS[transition]);
309
+ }
310
+
311
+ /** The status the scheduler transition writes. */
312
+ export function schedulerWorkReceiptTargetStatus(
313
+ transition: SchedulerWorkReceiptTransition,
314
+ ): WorkReceiptStateStatus {
315
+ const [to] = SCHEDULER_WORK_RECEIPT_TRANSITIONS[transition].to;
316
+ return to;
317
+ }
318
+
319
+ /** The scheduler claim transition for a claim's flags. */
320
+ export function schedulerWorkReceiptClaimTransition(input: {
321
+ forceRefresh?: boolean;
322
+ reclaimRunning?: boolean;
323
+ }): Extract<
324
+ SchedulerWorkReceiptTransition,
325
+ 'claim' | 'claim_reclaim_running' | 'claim_force_refresh'
326
+ > {
327
+ if (input.forceRefresh === true) return 'claim_force_refresh';
328
+ if (input.reclaimRunning === true) return 'claim_reclaim_running';
329
+ return 'claim';
330
+ }
331
+
332
+ /** The customer-database `status = ANY($from)` set (no `absent`). */
333
+ export function tenantWorkReceiptFromStatuses(
334
+ transition: TenantWorkReceiptTransition,
335
+ ): WorkReceiptStateStatus[] {
336
+ return existingFromStatuses(TENANT_WORK_RECEIPT_TRANSITIONS[transition]);
337
+ }
338
+
339
+ /** The customer-database claim transition for a claim's flags. */
340
+ export function tenantWorkReceiptClaimTransition(input: {
341
+ forceRefresh?: boolean;
342
+ reclaimRunning?: boolean;
343
+ }): Extract<
344
+ TenantWorkReceiptTransition,
345
+ | 'claim'
346
+ | 'claim_reclaim_running'
347
+ | 'claim_force_refresh'
348
+ | 'claim_force_refresh_reclaim_running'
349
+ > {
350
+ if (input.forceRefresh === true) {
351
+ return input.reclaimRunning === true
352
+ ? 'claim_force_refresh_reclaim_running'
353
+ : 'claim_force_refresh';
354
+ }
355
+ return input.reclaimRunning === true ? 'claim_reclaim_running' : 'claim';
356
+ }
357
+
358
+ function existingFromStatuses(
359
+ spec: WorkReceiptTransitionSpec,
360
+ ): WorkReceiptStateStatus[] {
361
+ return spec.from.filter(
362
+ (status): status is WorkReceiptStateStatus =>
363
+ status !== WORK_RECEIPT_ABSENT,
364
+ );
365
+ }
366
+
9
367
  export type WorkReceiptStateInput = {
10
368
  status: WorkReceiptStateStatus;
11
369
  runId?: string | null;
@@ -14,14 +14,14 @@ import {
14
14
  reportSetupCompleted,
15
15
  resolvePendingAuthClaimForResume,
16
16
  statusBannerLine
17
- } from "./chunk-MQ2LQOAM.mjs";
18
- import "./chunk-O65HDVA7.mjs";
19
- import "./chunk-PIC6M4X3.mjs";
20
- import "./chunk-ZCKUNXXR.mjs";
17
+ } from "./chunk-2BRTYIAH.mjs";
18
+ import "./chunk-VFHIYWMC.mjs";
19
+ import "./chunk-4NIGNT7X.mjs";
20
+ import "./chunk-TNQOR6XQ.mjs";
21
21
  import "./chunk-4QF2K7TM.mjs";
22
22
  import "./chunk-DLIRSHV6.mjs";
23
23
  import "./chunk-HBL4PM5Q.mjs";
24
- import "./chunk-UUH4GQRL.mjs";
24
+ import "./chunk-KKSKYZO4.mjs";
25
25
  import "./chunk-WZYKRD7T.mjs";
26
26
  import "./chunk-KRD6H754.mjs";
27
27
  export {
@@ -0,0 +1,43 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+ var _chunkMLEUOTEQjs = require('./chunk-MLEUOTEQ.js');
18
+ require('./chunk-2I7VN65H.js');
19
+ require('./chunk-JO2JZUBR.js');
20
+ require('./chunk-NWIDPT7H.js');
21
+ require('./chunk-ALJJRZNJ.js');
22
+ require('./chunk-XNYIZMNQ.js');
23
+ require('./chunk-DIAWYWT5.js');
24
+ require('./chunk-EFO5GVYS.js');
25
+ require('./chunk-OG64RBAC.js');
26
+ require('./chunk-COGTRVWW.js');
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+ exports.EXIT_WORKSPACE_MISMATCH = _chunkMLEUOTEQjs.EXIT_WORKSPACE_MISMATCH; exports.authStatusLine = _chunkMLEUOTEQjs.authStatusLine; exports.clearPendingClaim = _chunkMLEUOTEQjs.clearPendingClaim; exports.clearSatisfiedPendingClaim = _chunkMLEUOTEQjs.clearSatisfiedPendingClaim; exports.handleRegister = _chunkMLEUOTEQjs.handleRegister; exports.handleStatus = _chunkMLEUOTEQjs.handleStatus; exports.handleWait = _chunkMLEUOTEQjs.handleWait; exports.httpJson = _chunkMLEUOTEQjs.httpJson; exports.readPendingAuthClaim = _chunkMLEUOTEQjs.readPendingAuthClaim; exports.readStatusBanner = _chunkMLEUOTEQjs.readStatusBanner; exports.registerAuthCommands = _chunkMLEUOTEQjs.registerAuthCommands; exports.reportApprovalLinkShown = _chunkMLEUOTEQjs.reportApprovalLinkShown; exports.reportSetupCompleted = _chunkMLEUOTEQjs.reportSetupCompleted; exports.resolvePendingAuthClaimForResume = _chunkMLEUOTEQjs.resolvePendingAuthClaimForResume; exports.statusBannerLine = _chunkMLEUOTEQjs.statusBannerLine;