deepline 0.3.484 → 0.3.485

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 (209) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +91 -30
  2. package/dist/bundling-sources/sdk/src/compat.ts +13 -0
  3. package/dist/bundling-sources/sdk/src/plays/client-core.ts +4 -1
  4. package/dist/bundling-sources/sdk/src/plays/run-request.ts +143 -9
  5. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  6. package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +31 -4
  7. package/dist/bundling-sources/sdk/src/tool-calls.ts +1 -1
  8. package/dist/bundling-sources/sdk/src/types.ts +7 -1
  9. package/dist/bundling-sources/shared_libs/play-data-plane/sheet-column-storage.ts +32 -3
  10. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +126 -41
  11. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +231 -25
  12. package/dist/bundling-sources/shared_libs/play-runtime/daytona-runtime-config.ts +9 -0
  13. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +130 -19
  14. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-registry.ts +105 -0
  15. package/dist/bundling-sources/shared_libs/play-runtime/execute-server-timing.ts +4 -2
  16. package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +194 -56
  17. package/dist/bundling-sources/shared_libs/play-runtime/log-provenance.ts +11 -6
  18. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/job.ts +3 -0
  19. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/ports.ts +2 -0
  20. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/postgres-adapter.ts +2 -1
  21. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +30 -0
  22. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +195 -2
  23. package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +20 -1
  24. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger-projection-contract.ts +15 -0
  25. package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +2 -2
  26. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +102 -23
  27. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/progress-sidecar.ts +9 -1
  28. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-control-transport.ts +25 -5
  29. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-launch-transport.ts +133 -82
  30. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +58 -16
  31. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-sandbox-absence.ts +171 -0
  32. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-session-execution.ts +69 -0
  33. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +100 -40
  34. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +8 -0
  35. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +67 -9
  36. package/dist/bundling-sources/shared_libs/play-runtime/runtime-incident-drills.ts +5 -5
  37. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-store-adapter.ts +6 -3
  38. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-errors.ts +14 -0
  39. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-row-writer.ts +87 -31
  40. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/contract.ts +18 -0
  41. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/index.ts +19 -0
  42. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +14 -0
  43. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +204 -6
  44. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd.ts +39 -0
  45. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/play-run-recovery.ts +12 -1
  46. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +26 -0
  47. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-scope.ts +44 -15
  48. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +60 -11
  49. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +649 -38
  50. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +6 -1
  51. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +17 -0
  52. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +25 -33
  53. package/dist/bundling-sources/shared_libs/play-runtime/suspension.ts +12 -0
  54. package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +21 -0
  55. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +1 -1
  56. package/dist/bundling-sources/shared_libs/plays/source-authoring-edition.ts +1 -1
  57. package/dist/cli/auth-ABZBH55L.js +43 -0
  58. package/dist/cli/{auth-EBFOTF7X.mjs → auth-OWMUENCU.mjs} +5 -5
  59. package/dist/cli/{billing-G2G3EF3I.js → billing-2FMNQGOX.js} +80 -80
  60. package/dist/cli/{billing-2ZOIMW5V.mjs → billing-JX4H3VFF.mjs} +7 -7
  61. package/dist/cli/{chunk-M4PG7FGC.js → chunk-2ILND7XX.js} +2 -2
  62. package/dist/cli/{chunk-WXRM3UC6.mjs → chunk-2ZEQ43B7.mjs} +3 -3
  63. package/dist/cli/{chunk-PU52JXKA.mjs → chunk-3DBW6C7M.mjs} +13 -4
  64. package/dist/cli/{chunk-4OVHIWE7.mjs → chunk-3DYU3JQN.mjs} +2 -2
  65. package/dist/cli/{chunk-QIDDTIVZ.js → chunk-3OF7NSGR.js} +322 -294
  66. package/dist/cli/{chunk-YWC5AN26.mjs → chunk-3Z24NKW7.mjs} +62 -34
  67. package/dist/cli/{chunk-RLLEH2SP.js → chunk-5DCQWQCP.js} +26 -26
  68. package/dist/cli/{chunk-DEXSQGXB.mjs → chunk-62PJ6PK7.mjs} +5 -5
  69. package/dist/cli/{chunk-6NPWXE32.mjs → chunk-676NZ7K4.mjs} +1 -1
  70. package/dist/cli/{chunk-FRD5WFT4.js → chunk-775AZTO7.js} +323 -247
  71. package/dist/cli/{chunk-4OEOM6GP.mjs → chunk-ACTUAZYP.mjs} +5 -5
  72. package/dist/cli/{chunk-ZOKM7DVA.js → chunk-AFADYKFE.js} +8 -8
  73. package/dist/cli/{chunk-GVAENVIG.js → chunk-AUQQVDAB.js} +110 -21
  74. package/dist/cli/{chunk-U7IJAGWB.js → chunk-BSKPQB2P.js} +7 -7
  75. package/dist/cli/chunk-C6QWRSMQ.js +42 -0
  76. package/dist/cli/{chunk-AK7UKQ5R.js → chunk-CSBMKHTV.js} +5 -5
  77. package/dist/cli/{chunk-YHA3EV3I.mjs → chunk-CW6TAQBF.mjs} +15 -4
  78. package/dist/cli/{chunk-UT4YMA2N.js → chunk-DMNVM34J.js} +5 -4
  79. package/dist/cli/{chunk-XZXIWPT3.mjs → chunk-E73JXJA3.mjs} +1 -1
  80. package/dist/cli/{chunk-5KNRQWHE.js → chunk-EC2CVPN5.js} +3 -3
  81. package/dist/cli/{chunk-IXWQOVNW.js → chunk-ECIXZNSW.js} +87 -76
  82. package/dist/cli/{chunk-LTZXLYKE.mjs → chunk-FJY6K3BG.mjs} +93 -17
  83. package/dist/cli/{chunk-TRLDJNVE.mjs → chunk-G5PI3RNT.mjs} +1 -1
  84. package/dist/cli/{chunk-WYUCDLVR.mjs → chunk-GHHJWCMD.mjs} +2 -1
  85. package/dist/cli/{chunk-FQK7BULS.js → chunk-HKGXGGIV.js} +1 -1
  86. package/dist/cli/{chunk-2AWYJXBX.js → chunk-IHMYIHF4.js} +5 -5
  87. package/dist/cli/{chunk-SD7QWZTV.mjs → chunk-INW22YP7.mjs} +1 -1
  88. package/dist/cli/{chunk-OWUZKXE7.mjs → chunk-J7EENGKJ.mjs} +1 -1
  89. package/dist/cli/{chunk-TIRSKEZH.mjs → chunk-JD6HKNKD.mjs} +1 -1
  90. package/dist/cli/{chunk-OHKKDPA5.js → chunk-JQXUWYWX.js} +13 -13
  91. package/dist/cli/{chunk-EACX7QXO.mjs → chunk-KZTNNLIL.mjs} +2 -2
  92. package/dist/cli/{chunk-7K5CWKKZ.mjs → chunk-L352NOE3.mjs} +2 -2
  93. package/dist/cli/{chunk-KGOC6HGI.js → chunk-L7IQ3DFH.js} +53 -53
  94. package/dist/cli/{chunk-4IOY2SCQ.js → chunk-LOX3BISD.js} +4 -4
  95. package/dist/cli/{chunk-6GRZEYSG.js → chunk-NKPTM7SK.js} +7 -7
  96. package/dist/cli/{chunk-VEVGM6B5.js → chunk-NLRTFJGH.js} +14 -14
  97. package/dist/cli/{chunk-UKM74PAA.js → chunk-NRNWPWBW.js} +37 -37
  98. package/dist/cli/{chunk-HNRELVCS.mjs → chunk-ONONSV2Q.mjs} +96 -7
  99. package/dist/cli/{chunk-CYWBAV5H.js → chunk-OW4OTEFF.js} +16 -16
  100. package/dist/cli/{chunk-5K5CAND4.mjs → chunk-RZE5I2XJ.mjs} +4 -4
  101. package/dist/cli/{chunk-3XQIVEAT.js → chunk-S3WQJ5VG.js} +3 -3
  102. package/dist/cli/{chunk-4SFC2XUF.mjs → chunk-SR6S4EYG.mjs} +5 -5
  103. package/dist/cli/{chunk-UWOY74RU.js → chunk-T4G2T5DS.js} +21 -21
  104. package/dist/cli/{chunk-TN2GW57M.mjs → chunk-TMCC7ORQ.mjs} +1 -1
  105. package/dist/cli/{chunk-HEI3BWIV.mjs → chunk-TSCUWWTM.mjs} +1 -1
  106. package/dist/cli/{chunk-DBJ62RAO.js → chunk-TVW6USSG.js} +3 -3
  107. package/dist/cli/{chunk-NW4QJE54.js → chunk-U6WEGDD3.js} +2 -2
  108. package/dist/cli/{chunk-V7JCMBLU.mjs → chunk-UPHXGZCE.mjs} +4 -4
  109. package/dist/cli/{chunk-C62NI2X6.js → chunk-UQ3LQ6IF.js} +5 -5
  110. package/dist/cli/{chunk-5GOG5ZGC.mjs → chunk-VZYTLWOM.mjs} +2 -2
  111. package/dist/cli/{chunk-AF7MOUZP.mjs → chunk-W33OL4F2.mjs} +2 -2
  112. package/dist/cli/{chunk-ZM2YPJQJ.js → chunk-XK5DMLZE.js} +5 -1
  113. package/dist/cli/{chunk-LJ5747UC.mjs → chunk-XRDXNAAY.mjs} +5 -1
  114. package/dist/cli/{chunk-YGN77QA5.mjs → chunk-YDA3PMKK.mjs} +3 -3
  115. package/dist/cli/{csv-S3CHUKI6.js → csv-HFEQPGNY.js} +13 -13
  116. package/dist/cli/{csv-NLWVWD3H.mjs → csv-OHF3Y5KB.mjs} +4 -4
  117. package/dist/cli/{db-OGRPAEEM.mjs → db-M456OUXD.mjs} +7 -7
  118. package/dist/cli/{db-WBSKMMOH.js → db-VLQKCYQS.js} +28 -28
  119. package/dist/cli/describe-CP35DZ5Z.js +49 -0
  120. package/dist/cli/{describe-FAD3Z7LN.mjs → describe-M6VXFYVL.mjs} +21 -21
  121. package/dist/cli/describe-core.d.mts +3 -3
  122. package/dist/cli/describe-core.d.ts +3 -3
  123. package/dist/cli/describe-core.js +4 -4
  124. package/dist/cli/describe-core.mjs +3 -3
  125. package/dist/cli/{executions-LYCL344R.mjs → executions-4FGRBPJF.mjs} +7 -7
  126. package/dist/cli/{executions-SOAZHCY4.js → executions-GKINJZI6.js} +9 -9
  127. package/dist/cli/{feedback-AVF6V7SV.mjs → feedback-D2WMGK3V.mjs} +4 -4
  128. package/dist/cli/{feedback-OROUPUNJ.js → feedback-ZH5K7WV7.js} +8 -8
  129. package/dist/cli/git-IDALMZDN.js +25 -0
  130. package/dist/cli/{git-J5N5M57H.mjs → git-OCIJ5ME4.mjs} +5 -5
  131. package/dist/cli/index.js +142 -139
  132. package/dist/cli/index.mjs +45 -42
  133. package/dist/cli/{legacy-noops-QAQMZMEG.js → legacy-noops-QNIVP7LO.js} +8 -8
  134. package/dist/cli/{legacy-noops-ENRRM7BL.mjs → legacy-noops-V6Q2X34P.mjs} +5 -5
  135. package/dist/cli/{monitors-CKQ65WRL.mjs → monitors-2USHTG5G.mjs} +8 -8
  136. package/dist/cli/{monitors-SFMQ5LFR.js → monitors-5DNK7W2K.js} +92 -92
  137. package/dist/cli/{org-3UNTDLT2.js → org-RPGM5AN4.js} +73 -73
  138. package/dist/cli/{org-K4UIEU5P.mjs → org-TL2YPYSE.mjs} +7 -7
  139. package/dist/cli/{pages-NKZTGB4C.js → pages-PNUKPFWV.js} +18 -18
  140. package/dist/cli/{pages-6GPGBIAH.mjs → pages-XDEW6EE3.mjs} +7 -7
  141. package/dist/cli/{play-BDEADESI.js → play-F5LHRKV5.js} +858 -632
  142. package/dist/cli/{play-62BEE7IX.mjs → play-WINNQ4HZ.mjs} +372 -146
  143. package/dist/cli/{providers-SXGP44GH.js → providers-BD4IS5U5.js} +10 -10
  144. package/dist/cli/{providers-X3CUWMFP.mjs → providers-PXGL3FRE.mjs} +7 -7
  145. package/dist/cli/{quickstart-XQ4426M4.js → quickstart-7LVF6HZF.js} +6 -6
  146. package/dist/cli/{quickstart-7LN22BKX.mjs → quickstart-XTH3UQWZ.mjs} +4 -4
  147. package/dist/cli/{run-XXSN3B5A.mjs → run-MBMUENR7.mjs} +26 -26
  148. package/dist/cli/{run-PBJ4ZJ4W.js → run-NH2BAWPA.js} +41 -41
  149. package/dist/cli/{search-M75VMADD.mjs → search-BMRWBV66.mjs} +8 -8
  150. package/dist/cli/search-R3MQJQMT.js +32 -0
  151. package/dist/cli/{search-output-F6HCFYEI.js → search-output-5NNT337U.js} +22 -16
  152. package/dist/cli/{search-output-NUQAKWDM.mjs → search-output-QKKRD4MF.mjs} +14 -8
  153. package/dist/cli/{secrets-J2H6V33R.mjs → secrets-AWEXBTJV.mjs} +7 -7
  154. package/dist/cli/{secrets-LRYY4QPE.js → secrets-KQSTOREN.js} +16 -16
  155. package/dist/cli/{sessions-YPF62CZE.js → sessions-DSPLZYCJ.js} +6 -6
  156. package/dist/cli/{sessions-IMT336UV.mjs → sessions-RO25Q67X.mjs} +5 -5
  157. package/dist/cli/{settings-35YYC5WA.js → settings-7JXIKNKI.js} +79 -79
  158. package/dist/cli/{settings-PDWVQIGH.mjs → settings-JMGXGK4Z.mjs} +12 -12
  159. package/dist/cli/{setup-UR7GOR7H.js → setup-5QFAQQRW.js} +47 -47
  160. package/dist/cli/{setup-DG5DISSE.mjs → setup-ZQZ47FHB.mjs} +9 -9
  161. package/dist/cli/skills-EDZXY7DV.js +33 -0
  162. package/dist/cli/{skills-U6NJD5J7.mjs → skills-W3H2DL56.mjs} +7 -7
  163. package/dist/cli/{tools-2HGEOELR.mjs → tools-2BZCVNBS.mjs} +19 -19
  164. package/dist/cli/tools-2EY2ETCZ.js +56 -0
  165. package/dist/cli/{update-FRAYBAHK.mjs → update-GAWYMGAW.mjs} +9 -9
  166. package/dist/cli/update-UKDQKNBY.js +33 -0
  167. package/dist/cli/{workflow-DDKVTF36.mjs → workflow-M6LLHQ2I.mjs} +8 -8
  168. package/dist/cli/{workflow-JKKLOMBX.js → workflow-ZPTDFPKW.js} +18 -18
  169. package/dist/{client-DJ3r8VQJ.d.mts → client-BkbDHRIg.d.mts} +1 -1
  170. package/dist/{client-JPSNljtj.d.ts → client-D3hVHXjK.d.ts} +1 -1
  171. package/dist/{client-core-3SJlNsKU.d.mts → client-core-BZoSMKcY.d.mts} +30 -15
  172. package/dist/{client-core-rCoQ5Xz3.d.ts → client-core-DUdVqO_m.d.ts} +30 -15
  173. package/dist/{compiler-manifest-gkO9ZkVg.d.mts → compiler-manifest-BFTwq1HI.d.mts} +1 -1
  174. package/dist/{compiler-manifest-gkO9ZkVg.d.ts → compiler-manifest-BFTwq1HI.d.ts} +1 -1
  175. package/dist/{errors-Cc92LKH-.d.ts → errors-c3pMsylw.d.ts} +1 -1
  176. package/dist/{errors-CeCCOKSA.d.mts → errors-w31ybrQM.d.mts} +1 -1
  177. package/dist/{index-DJQKdV76.d.ts → index-CQ-15-QL.d.ts} +1 -1
  178. package/dist/{index-DsqWJL3Q.d.mts → index-DvNtxucX.d.mts} +1 -1
  179. package/dist/index.d.mts +7 -7
  180. package/dist/index.d.ts +7 -7
  181. package/dist/index.js +10 -10
  182. package/dist/index.mjs +7 -7
  183. package/dist/install-integrity.json +117 -116
  184. package/dist/plays/bundle-play-file.d.mts +3 -3
  185. package/dist/plays/bundle-play-file.d.ts +3 -3
  186. package/dist/plays/bundle-play-file.mjs +2 -2
  187. package/dist/plays/play-description.d.mts +2 -2
  188. package/dist/plays/play-description.d.ts +2 -2
  189. package/dist/plays/run-request.d.mts +2 -2
  190. package/dist/plays/run-request.d.ts +2 -2
  191. package/dist/plays/run-request.js +12 -2
  192. package/dist/plays/run-request.mjs +11 -1
  193. package/dist/release.d.mts +1 -1
  194. package/dist/release.d.ts +1 -1
  195. package/dist/release.js +2 -2
  196. package/dist/release.mjs +1 -1
  197. package/dist/server.d.mts +4 -4
  198. package/dist/server.d.ts +4 -4
  199. package/dist/server.js +6 -6
  200. package/dist/server.mjs +4 -4
  201. package/package.json +1 -1
  202. package/dist/cli/auth-L5CSV3UO.js +0 -43
  203. package/dist/cli/chunk-KA2LNIUP.js +0 -33
  204. package/dist/cli/describe-UIAYCHWW.js +0 -49
  205. package/dist/cli/git-ATMWC27D.js +0 -25
  206. package/dist/cli/search-IGHLRLBD.js +0 -32
  207. package/dist/cli/skills-4U5WC4MJ.js +0 -33
  208. package/dist/cli/tools-PYJTQVVS.js +0 -56
  209. package/dist/cli/update-344OTRFM.js +0 -33
@@ -33,7 +33,10 @@ import { RUNTIME_CAPACITY_POLICY } from '../runtime-capacity-policy';
33
33
  import { ABSURD_RELEASE_ID_RE } from '../runtime-scheduler-topology';
34
34
  import {
35
35
  authenticateFlyRegistry,
36
+ parseSharedRuntimeImageRef,
36
37
  runtimeImageManifestExists,
38
+ runtimeMachineImageMatches,
39
+ type FlyMachineImageRef,
37
40
  } from './fly-registry';
38
41
 
39
42
  export const FLY_MACHINES_API_BASE = 'https://api.machines.dev/v1';
@@ -59,6 +62,7 @@ export const RUNTIME_SURFACE_METADATA_KEY = 'runtime_surface_sha256';
59
62
  * deployment instead of replacing it blindly.
60
63
  */
61
64
  export const COMPONENT_INPUT_METADATA_KEY = 'deepline_component_input';
65
+ export const SOURCE_IMAGE_METADATA_KEY = 'deepline_source_image';
62
66
  export const ROLLBACK_HOLD_UNTIL_METADATA_KEY = 'rollback_hold_until_ms';
63
67
  export const RUNTIME_DEPLOY_VERSION_ENV = 'DEEPLINE_RUNTIME_DEPLOY_VERSION';
64
68
  export const DRAIN_EXIT_ENV = 'DEEPLINE_ABSURD_DRAIN_EXIT';
@@ -214,7 +218,9 @@ export type FlyMachineCheck = {
214
218
  };
215
219
 
216
220
  export type FlyMachine = {
221
+ /** Native resolved identity; config.image can omit its immutable digest. */
217
222
  id: string;
223
+ image_ref?: FlyMachineImageRef | null;
218
224
  name?: string;
219
225
  state?: string; // 'started' | 'stopped' | 'created' | ...
220
226
  /** Fly's machine cordon flag: a cordoned machine is excluded from request
@@ -229,13 +235,6 @@ export type FlyMachine = {
229
235
  * routing event as an explicit legacy-drain fence. */
230
236
  events?: Array<{ type?: string; timestamp?: number }>;
231
237
  region?: string;
232
- /** Native resolved identity; config.image can omit its immutable digest. */
233
- image_ref?: {
234
- registry?: string;
235
- repository?: string;
236
- tag?: string;
237
- digest?: string;
238
- } | null;
239
238
  config?: {
240
239
  image?: string;
241
240
  metadata?: Record<string, string>;
@@ -382,14 +381,26 @@ export function resolveWorkerLaneImage(input: {
382
381
  throw new Error(`Invalid worker image reference: ${input.imageRef}`);
383
382
  if (input.sha !== undefined && sha !== input.sha) {
384
383
  throw new Error(
385
- `Worker image source ${sha} disagrees with requested source ${input.sha}.`,
384
+ `Worker image source ${sha} does not match the requested exact source SHA ${input.sha}.`,
386
385
  );
387
386
  }
388
387
  return { sha, imageRef: input.imageRef };
389
388
  }
390
389
 
391
- /** Exact native immutable identity, shared semantically with the release gate's
392
- * jq predicates. Config equality alone proves a requested tag, not its digest. */
390
+ /** Backwards-compatible resolver retained for existing SDK callers. */
391
+ export function resolveLaneImageRef(
392
+ app: string,
393
+ sha: string,
394
+ imageRef?: string,
395
+ ): string {
396
+ return imageRef === undefined
397
+ ? laneImageRef(app, sha)
398
+ : resolveWorkerLaneImage({ app, sha, imageRef }).imageRef;
399
+ }
400
+
401
+ /** Runtime reuse accepts a digest-only config as immutable image identity.
402
+ * Release-gate verification uses flyMachineMatchesPinnedImageIdentity, which
403
+ * also proves the requested publication tag and native digest. */
393
404
  export function flyMachineMatchesImage(
394
405
  machine: FlyMachine,
395
406
  image: string,
@@ -399,16 +410,86 @@ export function flyMachineMatchesImage(
399
410
  /^([A-Za-z0-9.-]+(?::[0-9]+)?)\/([A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*):([A-Za-z0-9_][A-Za-z0-9_.-]*)@(sha256:[a-f0-9]{64})$/.exec(
400
411
  image,
401
412
  );
402
- const resolved = machine.image_ref;
403
- if (!requested || !resolved || typeof resolved !== 'object') return false;
404
- const [, registry, repository, imageTag, digest] = requested;
405
- const tag = `${registry}/${repository}:${imageTag}`;
413
+ const registry = requested?.[1];
414
+ const repository = requested?.[2];
415
+ const tag = requested?.[3];
416
+ const digest = requested?.[4];
417
+ const actual = machine.config?.image;
418
+ const native = machine.image_ref;
419
+ if (!registry || !repository || !tag || !digest || typeof actual !== 'string')
420
+ return false;
421
+ const configuredPin =
422
+ /^([A-Za-z0-9.-]+(?::[0-9]+)?)\/([A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*)(?::([A-Za-z0-9_][A-Za-z0-9_.-]*))?@(sha256:[a-f0-9]{64})$/.exec(
423
+ actual,
424
+ );
425
+ // A digest-qualified config value is immutable by itself when its
426
+ // registry/repository/digest match. If it also carries a tag, keep that tag
427
+ // exact. Fly's normalized tag-only config needs the separate native witness.
428
+ if (configuredPin) {
429
+ if (
430
+ configuredPin[1] !== registry ||
431
+ configuredPin[2] !== repository ||
432
+ (configuredPin[3] !== undefined && configuredPin[3] !== tag) ||
433
+ configuredPin[4] !== digest
434
+ )
435
+ return false;
436
+ if (!native) return true;
437
+ return (
438
+ native.registry === registry &&
439
+ native.repository === repository &&
440
+ native.digest === digest &&
441
+ (configuredPin[3] === undefined ||
442
+ native.tag === undefined ||
443
+ native.tag === configuredPin[3])
444
+ );
445
+ }
446
+ if (!native) return false;
447
+ if (
448
+ native.registry !== registry ||
449
+ native.repository !== repository ||
450
+ native.tag !== tag ||
451
+ native.digest !== digest
452
+ )
453
+ return false;
454
+ const expectedTag = `${registry}/${repository}:${tag}`;
455
+ return actual === expectedTag;
456
+ }
457
+
458
+ /**
459
+ * The release gate must prove both the published tag and its native immutable
460
+ * digest. Runtime reuse can accept a digest-only config image, but the gate
461
+ * also checks the tag that ties that digest to the requested publication.
462
+ */
463
+ export function flyMachineMatchesPinnedImageIdentity(
464
+ machine: FlyMachine,
465
+ image: string,
466
+ ): boolean {
467
+ if (!image.includes('@')) return machine.config?.image === image;
468
+ const requested =
469
+ /^([A-Za-z0-9.-]+(?::[0-9]+)?)\/([A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*):([A-Za-z0-9_][A-Za-z0-9_.-]*)@(sha256:[a-f0-9]{64})$/.exec(
470
+ image,
471
+ );
472
+ const registry = requested?.[1];
473
+ const repository = requested?.[2];
474
+ const tag = requested?.[3];
475
+ const digest = requested?.[4];
476
+ const actual = machine.config?.image;
477
+ const native = machine.image_ref;
478
+ if (
479
+ !registry ||
480
+ !repository ||
481
+ !tag ||
482
+ !digest ||
483
+ typeof actual !== 'string' ||
484
+ (actual !== image && actual !== `${registry}/${repository}:${tag}`) ||
485
+ !native
486
+ )
487
+ return false;
406
488
  return (
407
- (machine.config?.image === image || machine.config?.image === tag) &&
408
- resolved.registry === registry &&
409
- resolved.repository === repository &&
410
- resolved.tag === imageTag &&
411
- resolved.digest === digest
489
+ native.registry === registry &&
490
+ native.repository === repository &&
491
+ native.tag === tag &&
492
+ native.digest === digest
412
493
  );
413
494
  }
414
495
 
@@ -460,6 +541,9 @@ export function buildBootMachineConfig(input: {
460
541
  }).imageRef,
461
542
  metadata: {
462
543
  [RELEASE_METADATA_KEY]: input.releaseId,
544
+ ...(input.imageRef && parseSharedRuntimeImageRef(input.imageRef)
545
+ ? { [SOURCE_IMAGE_METADATA_KEY]: input.imageRef }
546
+ : {}),
463
547
  ...(input.runtimeSurfaceHash
464
548
  ? { [RUNTIME_SURFACE_METADATA_KEY]: input.runtimeSurfaceHash }
465
549
  : {}),
@@ -1030,9 +1114,25 @@ export function resolveRollbackLaneImage(input: {
1030
1114
  app: string;
1031
1115
  releaseId: string;
1032
1116
  registeredImageRef?: string | null;
1117
+ environment?: 'preview' | 'production';
1033
1118
  }): RollbackLaneImageResolution {
1034
1119
  const prefix = `${FLY_REGISTRY_HOST}/${input.app}:git-`;
1035
1120
  const registeredImageRef = input.registeredImageRef?.trim() || null;
1121
+ const shared = registeredImageRef
1122
+ ? parseSharedRuntimeImageRef(registeredImageRef)
1123
+ : null;
1124
+ if (
1125
+ shared &&
1126
+ input.environment === 'preview' &&
1127
+ shared.kind === 'worker' &&
1128
+ input.releaseId.startsWith('dev-')
1129
+ ) {
1130
+ return {
1131
+ sha: shared.sha,
1132
+ imageRef: registeredImageRef!,
1133
+ registeredImageRef,
1134
+ };
1135
+ }
1036
1136
  let imageSha: string | null = null;
1037
1137
  if (registeredImageRef) {
1038
1138
  if (!registeredImageRef.startsWith(prefix)) {
@@ -1089,8 +1189,17 @@ export function planRollbackLaneImage(input: {
1089
1189
  releaseId: string;
1090
1190
  registeredImageRef?: string | null;
1091
1191
  manifestPresent: boolean;
1192
+ environment?: 'preview' | 'production';
1092
1193
  }): RollbackLaneImagePlan {
1093
1194
  const resolution = resolveRollbackLaneImage(input);
1195
+ if (
1196
+ !input.manifestPresent &&
1197
+ parseSharedRuntimeImageRef(resolution.imageRef)
1198
+ ) {
1199
+ throw new Error(
1200
+ 'Pinned Preview image is unavailable. Recover through normal target preparation; do not replace its recorded digest with a rebuild.',
1201
+ );
1202
+ }
1094
1203
  return {
1095
1204
  ...resolution,
1096
1205
  action: input.manifestPresent ? 'reuse' : 'rebuild',
@@ -1171,12 +1280,14 @@ async function cmdPlanImage(
1171
1280
  app,
1172
1281
  releaseId,
1173
1282
  registeredImageRef,
1283
+ environment: flags.environment === 'preview' ? 'preview' : 'production',
1174
1284
  });
1175
1285
  authenticateFlyRegistry();
1176
1286
  const plan = planRollbackLaneImage({
1177
1287
  app,
1178
1288
  releaseId,
1179
1289
  registeredImageRef,
1290
+ environment: flags.environment === 'preview' ? 'preview' : 'production',
1180
1291
  manifestPresent: runtimeImageManifestExists(resolution.imageRef),
1181
1292
  });
1182
1293
  console.info(
@@ -9,6 +9,111 @@ import {
9
9
  import { homedir } from 'node:os';
10
10
  import { isAbsolute, join } from 'node:path';
11
11
 
12
+ export type SharedRuntimeImage = {
13
+ repository: string;
14
+ sha: string;
15
+ kind: 'gateway' | 'worker' | 'scaler';
16
+ digest: string;
17
+ cacheKey: string;
18
+ coverage: boolean;
19
+ };
20
+
21
+ /** Shared Preview publications carry both source identity and an immutable pin. */
22
+ export function parseSharedRuntimeImageRef(
23
+ image: string,
24
+ ): SharedRuntimeImage | null {
25
+ const match =
26
+ /^registry\.fly\.io\/([a-z0-9-]+):git-([0-9a-f]{40})-(gateway|worker|scaler)-([0-9a-f]{64})(-coverage)?@(sha256:[0-9a-f]{64})$/.exec(
27
+ image,
28
+ );
29
+ if (!match) return null;
30
+ const [, repository, sha, kind, cacheKey, coverage, digest] = match;
31
+ if (
32
+ (kind === 'gateway' &&
33
+ repository !== 'deepline-runtime-receipt-gateway-preview-cache') ||
34
+ (kind !== 'gateway' &&
35
+ repository !== 'deepline-absurd-worker-preview-cache') ||
36
+ (coverage && kind !== 'worker')
37
+ )
38
+ return null;
39
+ return {
40
+ repository,
41
+ sha,
42
+ kind: kind as SharedRuntimeImage['kind'],
43
+ digest,
44
+ cacheKey,
45
+ coverage: Boolean(coverage),
46
+ };
47
+ }
48
+
49
+ /** Fly may normalize away a tag; a verified repository and digest still agree. */
50
+ export function runtimeImagesMatch(expected: string, actual: string): boolean {
51
+ if (expected === actual) return true;
52
+ const publication = parseSharedRuntimeImageRef(expected);
53
+ const normalized =
54
+ /^registry\.fly\.io\/([a-z0-9-]+)(?::[^@\s]+)?@(sha256:[0-9a-f]{64})$/.exec(
55
+ actual,
56
+ );
57
+ return Boolean(
58
+ publication &&
59
+ normalized &&
60
+ publication.repository === normalized[1] &&
61
+ publication.digest === normalized[2],
62
+ );
63
+ }
64
+
65
+ /** Provider-resolved image identity returned alongside a Machine's config. */
66
+ export type FlyMachineImageRef = {
67
+ registry?: string;
68
+ repository?: string;
69
+ tag?: string;
70
+ digest?: string;
71
+ };
72
+
73
+ /**
74
+ * Fly can strip the digest from config.image and report it in image_ref.
75
+ * A tag-only config is proof only with an agreeing provider-resolved digest;
76
+ * never infer an immutable identity from the tag itself.
77
+ */
78
+ export function runtimeMachineImageMatches(
79
+ expected: string,
80
+ machine: {
81
+ config?: { image?: string } | null;
82
+ image_ref?: FlyMachineImageRef | null;
83
+ },
84
+ ): boolean {
85
+ const actual = machine.config?.image;
86
+ if (typeof actual !== 'string') return false;
87
+ const publication = parseSharedRuntimeImageRef(expected);
88
+ const provider = machine.image_ref;
89
+ // Old responses with an explicit pin, and legacy per-app image identities,
90
+ // retain their existing matching rules.
91
+ if (!publication || provider == null)
92
+ return runtimeImagesMatch(expected, actual);
93
+ if (
94
+ provider.registry !== 'registry.fly.io' ||
95
+ provider.repository !== publication.repository ||
96
+ provider.digest !== publication.digest
97
+ )
98
+ return false;
99
+ const configured =
100
+ /^registry\.fly\.io\/([a-z0-9-]+)(?::([^@\s]+))?(?:@(sha256:[0-9a-f]{64}))?$/.exec(
101
+ actual,
102
+ );
103
+ if (!configured || configured[1] !== publication.repository) return false;
104
+ const [, , tag, digest] = configured;
105
+ if (digest && digest !== publication.digest) return false;
106
+ if (tag && provider.tag != null && provider.tag !== tag) return false;
107
+ if (digest) return true;
108
+ return actual === expected.split('@')[0] && provider.tag === tag;
109
+ }
110
+
111
+ export function runtimeImageSourceSha(image: string): string | null {
112
+ const shared = parseSharedRuntimeImageRef(image);
113
+ if (shared) return shared.sha;
114
+ return /:git-([0-9a-f]{7,40})$/.exec(image)?.[1] ?? null;
115
+ }
116
+
12
117
  const FLY_REGISTRY_COMMAND_TIMEOUT_MS = 30_000;
13
118
  const RUNTIME_IMAGE_MANIFEST_TIMEOUT_MS = 10_000;
14
119
  export const FLY_REGISTRY_MANIFEST_ATTEMPTS = 3;
@@ -101,8 +101,10 @@ export const EXECUTE_SERVER_TIMING_STAGES = [
101
101
  'upstream_body',
102
102
  ] as const;
103
103
 
104
- // The public recovery handler surrounds the core: its total includes durable
105
- // response storage and receipt acknowledgement. Keep the core's total intact.
104
+ // The public recovery handler surrounds the core: its response total includes
105
+ // durable response storage. Keyed terminal receipt acknowledgement runs after
106
+ // the response and reports through a separate telemetry event. Keep the core's
107
+ // total intact.
106
108
  export const PUBLIC_EXECUTE_SERVER_TIMING_STAGES = [
107
109
  // Route total includes lazy execution-module loading. The handler's
108
110
  // public_total keeps its existing meaning so older readers remain valid.