@caelo-cms/provisioning 0.11.9 → 0.11.11

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 (352) hide show
  1. package/dist/adapter.d.ts +6 -0
  2. package/dist/adapter.d.ts.map +1 -1
  3. package/dist/admin-domain.d.ts +10 -1
  4. package/dist/admin-domain.d.ts.map +1 -1
  5. package/dist/admin-domain.js +13 -3
  6. package/dist/admin-domain.js.map +1 -1
  7. package/dist/adopt-existing.d.ts +12 -3
  8. package/dist/adopt-existing.d.ts.map +1 -1
  9. package/dist/adopt-existing.js +143 -0
  10. package/dist/adopt-existing.js.map +1 -1
  11. package/dist/agent/command.d.ts +23 -0
  12. package/dist/agent/command.d.ts.map +1 -1
  13. package/dist/agent/command.js +32 -9
  14. package/dist/agent/command.js.map +1 -1
  15. package/dist/agent/run.d.ts +2 -0
  16. package/dist/agent/run.d.ts.map +1 -1
  17. package/dist/agent/run.js +5 -1
  18. package/dist/agent/run.js.map +1 -1
  19. package/dist/agent-db.js +69 -10
  20. package/dist/aws-task-roles.d.ts +4 -2
  21. package/dist/aws-task-roles.d.ts.map +1 -1
  22. package/dist/aws-task-roles.js +4 -1
  23. package/dist/aws-task-roles.js.map +1 -1
  24. package/dist/caddy.d.ts +21 -4
  25. package/dist/caddy.d.ts.map +1 -1
  26. package/dist/caddy.js +27 -3
  27. package/dist/caddy.js.map +1 -1
  28. package/dist/cli-routing.js +1 -1
  29. package/dist/cli-routing.js.map +1 -1
  30. package/dist/cli.js +68 -7
  31. package/dist/cli.js.map +1 -1
  32. package/dist/cloudsql-tls.d.ts +93 -0
  33. package/dist/cloudsql-tls.d.ts.map +1 -0
  34. package/dist/cloudsql-tls.js +295 -0
  35. package/dist/cloudsql-tls.js.map +1 -0
  36. package/dist/compose.d.ts +43 -6
  37. package/dist/compose.d.ts.map +1 -1
  38. package/dist/compose.js +148 -23
  39. package/dist/compose.js.map +1 -1
  40. package/dist/converge-checkpoint.d.ts +1 -0
  41. package/dist/converge-checkpoint.d.ts.map +1 -1
  42. package/dist/converge-checkpoint.js +8 -1
  43. package/dist/converge-checkpoint.js.map +1 -1
  44. package/dist/converge-db-trust.d.ts +44 -0
  45. package/dist/converge-db-trust.d.ts.map +1 -0
  46. package/dist/converge-db-trust.js +158 -0
  47. package/dist/converge-db-trust.js.map +1 -0
  48. package/dist/converge-job-gcp.d.ts +5 -2
  49. package/dist/converge-job-gcp.d.ts.map +1 -1
  50. package/dist/converge-job-gcp.js +11 -13
  51. package/dist/converge-job-gcp.js.map +1 -1
  52. package/dist/converge-job-preflight.d.ts.map +1 -1
  53. package/dist/converge-job-preflight.js +8 -0
  54. package/dist/converge-job-preflight.js.map +1 -1
  55. package/dist/converge-job.d.ts +17 -0
  56. package/dist/converge-job.d.ts.map +1 -1
  57. package/dist/converge-job.js +12 -0
  58. package/dist/converge-job.js.map +1 -1
  59. package/dist/deployed-release.d.ts +4 -1
  60. package/dist/deployed-release.d.ts.map +1 -1
  61. package/dist/deployed-release.js +18 -8
  62. package/dist/deployed-release.js.map +1 -1
  63. package/dist/gcp-names.d.ts +34 -0
  64. package/dist/gcp-names.d.ts.map +1 -1
  65. package/dist/gcp-names.js +45 -0
  66. package/dist/gcp-names.js.map +1 -1
  67. package/dist/gcp-url-map.d.ts.map +1 -1
  68. package/dist/gcp-url-map.js +6 -2
  69. package/dist/gcp-url-map.js.map +1 -1
  70. package/dist/index.d.ts +3 -2
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +2 -1
  73. package/dist/index.js.map +1 -1
  74. package/dist/infra-contract.d.ts +1 -1
  75. package/dist/infra-contract.d.ts.map +1 -1
  76. package/dist/infra-contract.js +45 -1
  77. package/dist/infra-contract.js.map +1 -1
  78. package/dist/install-job.d.ts +4 -2
  79. package/dist/install-job.d.ts.map +1 -1
  80. package/dist/install-job.js +4 -1
  81. package/dist/install-job.js.map +1 -1
  82. package/dist/install-state.d.ts +13 -0
  83. package/dist/install-state.d.ts.map +1 -1
  84. package/dist/install-state.js +17 -4
  85. package/dist/install-state.js.map +1 -1
  86. package/dist/lifecycle.d.ts.map +1 -1
  87. package/dist/lifecycle.js +20 -8
  88. package/dist/lifecycle.js.map +1 -1
  89. package/dist/mcp-auth-proxy-setup.d.ts +48 -0
  90. package/dist/mcp-auth-proxy-setup.d.ts.map +1 -0
  91. package/dist/mcp-auth-proxy-setup.js +280 -0
  92. package/dist/mcp-auth-proxy-setup.js.map +1 -0
  93. package/dist/migration-runner.d.ts.map +1 -1
  94. package/dist/migration-runner.js +8 -3
  95. package/dist/migration-runner.js.map +1 -1
  96. package/dist/migration-targets.d.ts +11 -0
  97. package/dist/migration-targets.d.ts.map +1 -0
  98. package/dist/migration-targets.js +12 -0
  99. package/dist/migration-targets.js.map +1 -0
  100. package/dist/operator-access.d.ts +10 -0
  101. package/dist/operator-access.d.ts.map +1 -1
  102. package/dist/operator-access.js +5 -0
  103. package/dist/operator-access.js.map +1 -1
  104. package/dist/pool-budget-stack.d.ts +13 -1
  105. package/dist/pool-budget-stack.d.ts.map +1 -1
  106. package/dist/pool-budget-stack.js +11 -1
  107. package/dist/pool-budget-stack.js.map +1 -1
  108. package/dist/public-role-isolation.d.ts +7 -3
  109. package/dist/public-role-isolation.d.ts.map +1 -1
  110. package/dist/public-role-isolation.js +25 -13
  111. package/dist/public-role-isolation.js.map +1 -1
  112. package/dist/release-contract.d.ts.map +1 -1
  113. package/dist/release-contract.js +3 -0
  114. package/dist/release-contract.js.map +1 -1
  115. package/dist/release-manifest.d.ts +25 -1
  116. package/dist/release-manifest.d.ts.map +1 -1
  117. package/dist/release-manifest.js +36 -3
  118. package/dist/release-manifest.js.map +1 -1
  119. package/dist/remote-mcp.d.ts +55 -18
  120. package/dist/remote-mcp.d.ts.map +1 -1
  121. package/dist/remote-mcp.js +307 -77
  122. package/dist/remote-mcp.js.map +1 -1
  123. package/dist/runtime-secrets.d.ts +11 -0
  124. package/dist/runtime-secrets.d.ts.map +1 -1
  125. package/dist/runtime-secrets.js +40 -25
  126. package/dist/runtime-secrets.js.map +1 -1
  127. package/dist/scheduler-setup.d.ts +75 -0
  128. package/dist/scheduler-setup.d.ts.map +1 -0
  129. package/dist/scheduler-setup.js +331 -0
  130. package/dist/scheduler-setup.js.map +1 -0
  131. package/dist/seal-key-rotation.d.ts +7 -7
  132. package/dist/seal-key-rotation.d.ts.map +1 -1
  133. package/dist/seal-key-rotation.js +22 -22
  134. package/dist/seal-key-rotation.js.map +1 -1
  135. package/dist/self-hosted-db-tls.d.ts +37 -0
  136. package/dist/self-hosted-db-tls.d.ts.map +1 -0
  137. package/dist/self-hosted-db-tls.js +220 -0
  138. package/dist/self-hosted-db-tls.js.map +1 -0
  139. package/dist/self-hosted-release.d.ts +3 -1
  140. package/dist/self-hosted-release.d.ts.map +1 -1
  141. package/dist/self-hosted-release.js +33 -9
  142. package/dist/self-hosted-release.js.map +1 -1
  143. package/dist/self-hosted-roles.d.ts +43 -2
  144. package/dist/self-hosted-roles.d.ts.map +1 -1
  145. package/dist/self-hosted-roles.js +87 -1
  146. package/dist/self-hosted-roles.js.map +1 -1
  147. package/dist/self-hosted-scheduler-interval.d.ts +21 -0
  148. package/dist/self-hosted-scheduler-interval.d.ts.map +1 -0
  149. package/dist/self-hosted-scheduler-interval.js +68 -0
  150. package/dist/self-hosted-scheduler-interval.js.map +1 -0
  151. package/dist/self-hosted-start.d.ts +0 -21
  152. package/dist/self-hosted-start.d.ts.map +1 -1
  153. package/dist/self-hosted-start.js +39 -1
  154. package/dist/self-hosted-start.js.map +1 -1
  155. package/dist/self-hosted-upgrade.d.ts +19 -7
  156. package/dist/self-hosted-upgrade.d.ts.map +1 -1
  157. package/dist/self-hosted-upgrade.js +78 -25
  158. package/dist/self-hosted-upgrade.js.map +1 -1
  159. package/dist/stack-contract.d.ts +234 -28
  160. package/dist/stack-contract.d.ts.map +1 -1
  161. package/dist/stack-contract.js +397 -39
  162. package/dist/stack-contract.js.map +1 -1
  163. package/dist/stack-converge.d.ts +31 -0
  164. package/dist/stack-converge.d.ts.map +1 -1
  165. package/dist/stack-converge.js +71 -30
  166. package/dist/stack-converge.js.map +1 -1
  167. package/dist/staging-database.d.ts +22 -0
  168. package/dist/staging-database.d.ts.map +1 -0
  169. package/dist/staging-database.js +117 -0
  170. package/dist/staging-database.js.map +1 -0
  171. package/dist/upgrade/app-roll.d.ts +25 -4
  172. package/dist/upgrade/app-roll.d.ts.map +1 -1
  173. package/dist/upgrade/app-roll.js +63 -17
  174. package/dist/upgrade/app-roll.js.map +1 -1
  175. package/dist/upgrade/converge.d.ts +5 -0
  176. package/dist/upgrade/converge.d.ts.map +1 -1
  177. package/dist/upgrade/converge.js +207 -20
  178. package/dist/upgrade/converge.js.map +1 -1
  179. package/dist/upgrade/health.d.ts +31 -7
  180. package/dist/upgrade/health.d.ts.map +1 -1
  181. package/dist/upgrade/health.js +41 -17
  182. package/dist/upgrade/health.js.map +1 -1
  183. package/dist/upgrade/image-forms.d.ts +1 -1
  184. package/dist/upgrade/image-forms.d.ts.map +1 -1
  185. package/dist/upgrade/image-forms.js +24 -7
  186. package/dist/upgrade/image-forms.js.map +1 -1
  187. package/dist/upgrade/release-images.d.ts +12 -3
  188. package/dist/upgrade/release-images.d.ts.map +1 -1
  189. package/dist/upgrade/release-images.js +13 -4
  190. package/dist/upgrade/release-images.js.map +1 -1
  191. package/dist/upgrade/upgrade.d.ts +19 -3
  192. package/dist/upgrade/upgrade.d.ts.map +1 -1
  193. package/dist/upgrade/upgrade.js +37 -2
  194. package/dist/upgrade/upgrade.js.map +1 -1
  195. package/dist/upgrader-gcp.d.ts +13 -0
  196. package/dist/upgrader-gcp.d.ts.map +1 -1
  197. package/dist/upgrader-gcp.js +50 -1
  198. package/dist/upgrader-gcp.js.map +1 -1
  199. package/dist/upgrader-iam-preflight.d.ts.map +1 -1
  200. package/dist/upgrader-iam-preflight.js +6 -1
  201. package/dist/upgrader-iam-preflight.js.map +1 -1
  202. package/dist/upgrader-job.d.ts +1 -1
  203. package/dist/upgrader-job.d.ts.map +1 -1
  204. package/dist/upgrader-job.js +20 -14
  205. package/dist/upgrader-job.js.map +1 -1
  206. package/dist/upgrader-records.d.ts +1 -1
  207. package/dist/upgrader-records.d.ts.map +1 -1
  208. package/dist/upgrader-records.js +26 -7
  209. package/dist/upgrader-records.js.map +1 -1
  210. package/dist/upgrader-setup.d.ts.map +1 -1
  211. package/dist/upgrader-setup.js +10 -5
  212. package/dist/upgrader-setup.js.map +1 -1
  213. package/dist/wizard.d.ts +7 -0
  214. package/dist/wizard.d.ts.map +1 -1
  215. package/dist/wizard.js +11 -0
  216. package/dist/wizard.js.map +1 -1
  217. package/dist/wizards/gcp-cost.d.ts +31 -0
  218. package/dist/wizards/gcp-cost.d.ts.map +1 -1
  219. package/dist/wizards/gcp-cost.js +103 -18
  220. package/dist/wizards/gcp-cost.js.map +1 -1
  221. package/dist/wizards/gcp.d.ts.map +1 -1
  222. package/dist/wizards/gcp.js +129 -27
  223. package/dist/wizards/gcp.js.map +1 -1
  224. package/package.json +2 -2
  225. package/src/adapter.ts +6 -0
  226. package/src/admin-domain.test.ts +9 -8
  227. package/src/admin-domain.ts +13 -3
  228. package/src/admin-memory.test.ts +2 -1
  229. package/src/adopt-existing.test.ts +85 -0
  230. package/src/adopt-existing.ts +141 -3
  231. package/src/agent/command.test.ts +49 -1
  232. package/src/agent/command.ts +39 -9
  233. package/src/agent/run.test.ts +19 -0
  234. package/src/agent/run.ts +11 -2
  235. package/src/aws-task-roles.ts +5 -2
  236. package/src/caddy-redirects.docker.test.ts +2 -0
  237. package/src/caddy-redirects.test.ts +4 -1
  238. package/src/caddy-validate.test.ts +7 -1
  239. package/src/caddy.test.ts +39 -1
  240. package/src/caddy.ts +36 -4
  241. package/src/checkpoint-secrets.test.ts +14 -6
  242. package/src/cli-routing.test.ts +1 -1
  243. package/src/cli-routing.ts +1 -1
  244. package/src/cli.ts +71 -5
  245. package/src/cloudsql-tls.test.ts +255 -0
  246. package/src/cloudsql-tls.ts +359 -0
  247. package/src/compose.ts +193 -24
  248. package/src/converge-checkpoint.ts +8 -1
  249. package/src/converge-db-trust.test.ts +237 -0
  250. package/src/converge-db-trust.ts +212 -0
  251. package/src/converge-job-gcp.ts +11 -12
  252. package/src/converge-job-preflight.test.ts +5 -0
  253. package/src/converge-job-preflight.ts +8 -0
  254. package/src/converge-job.test.ts +70 -0
  255. package/src/converge-job.ts +32 -0
  256. package/src/database-tls-builders.test.ts +56 -0
  257. package/src/deployed-release.test.ts +107 -40
  258. package/src/deployed-release.ts +30 -9
  259. package/src/gateway-env-isolation.test.ts +50 -12
  260. package/src/gcp-names.ts +56 -0
  261. package/src/gcp-url-map.test.ts +6 -8
  262. package/src/gcp-url-map.ts +6 -2
  263. package/src/index.test.ts +10 -4
  264. package/src/index.ts +7 -0
  265. package/src/infra-contract.test.ts +7 -3
  266. package/src/infra-contract.ts +45 -1
  267. package/src/install-job.ts +4 -1
  268. package/src/install-state.ts +33 -4
  269. package/src/lifecycle.ts +23 -11
  270. package/src/mcp-auth-proxy-setup.test.ts +305 -0
  271. package/src/mcp-auth-proxy-setup.ts +374 -0
  272. package/src/mcp-iap-stacks.test.ts +1 -1
  273. package/src/media-volume.test.ts +1 -1
  274. package/src/migration-runner.ts +14 -9
  275. package/src/migration-targets.ts +12 -0
  276. package/src/operator-access-stacks.test.ts +1 -1
  277. package/src/operator-access.test.ts +20 -4
  278. package/src/operator-access.ts +14 -0
  279. package/src/pool-budget-stack.ts +15 -0
  280. package/src/pool-budget-stacks.test.ts +39 -14
  281. package/src/public-role-isolation.test.ts +18 -8
  282. package/src/public-role-isolation.ts +31 -17
  283. package/src/release-contract.ts +3 -0
  284. package/src/release-manifest.test.ts +25 -0
  285. package/src/release-manifest.ts +59 -4
  286. package/src/remote-mcp-stack-config.test.ts +19 -9
  287. package/src/remote-mcp.test.ts +252 -57
  288. package/src/remote-mcp.ts +336 -77
  289. package/src/runtime-secrets.test.ts +37 -14
  290. package/src/runtime-secrets.ts +87 -27
  291. package/src/scheduler-setup.test.ts +201 -0
  292. package/src/scheduler-setup.ts +375 -0
  293. package/src/seal-key-rotation.test.ts +2 -2
  294. package/src/seal-key-rotation.ts +25 -25
  295. package/src/self-hosted-backup.test.ts +1 -0
  296. package/src/self-hosted-compose.test.ts +180 -6
  297. package/src/self-hosted-db-tls.test.ts +111 -0
  298. package/src/self-hosted-db-tls.ts +287 -0
  299. package/src/self-hosted-release-resolve.test.ts +71 -0
  300. package/src/self-hosted-release.ts +41 -11
  301. package/src/self-hosted-roles.integration.test.ts +2 -0
  302. package/src/self-hosted-roles.test.ts +87 -3
  303. package/src/self-hosted-roles.ts +101 -3
  304. package/src/self-hosted-scheduler-interval.test.ts +66 -0
  305. package/src/self-hosted-scheduler-interval.ts +79 -0
  306. package/src/self-hosted-start.test.ts +35 -2
  307. package/src/self-hosted-start.ts +20 -2
  308. package/src/self-hosted-upgrade.test.ts +104 -14
  309. package/src/self-hosted-upgrade.ts +123 -31
  310. package/src/stack-contract-parity.test.ts +79 -12
  311. package/src/stack-contract.test.ts +199 -31
  312. package/src/stack-contract.ts +472 -45
  313. package/src/stack-converge-secrets.test.ts +28 -13
  314. package/src/stack-converge.test.ts +203 -28
  315. package/src/stack-converge.ts +92 -30
  316. package/src/staging-database.test.ts +114 -0
  317. package/src/staging-database.ts +148 -0
  318. package/src/state-store.test.ts +2 -1
  319. package/src/upgrade/app-roll.ts +97 -19
  320. package/src/upgrade/converge.ts +249 -19
  321. package/src/upgrade/health.test.ts +63 -25
  322. package/src/upgrade/health.ts +54 -22
  323. package/src/upgrade/image-forms.test.ts +34 -0
  324. package/src/upgrade/image-forms.ts +23 -8
  325. package/src/upgrade/release-images.test.ts +5 -1
  326. package/src/upgrade/release-images.ts +22 -6
  327. package/src/upgrade/upgrade.test.ts +438 -46
  328. package/src/upgrade/upgrade.ts +64 -6
  329. package/src/upgrader-gcp.ts +66 -3
  330. package/src/upgrader-iam-preflight.test.ts +19 -0
  331. package/src/upgrader-iam-preflight.ts +6 -0
  332. package/src/upgrader-job.test.ts +101 -27
  333. package/src/upgrader-job.ts +27 -14
  334. package/src/upgrader-records.test.ts +97 -12
  335. package/src/upgrader-records.ts +28 -11
  336. package/src/upgrader-setup.test.ts +2 -0
  337. package/src/upgrader-setup.ts +10 -4
  338. package/src/wizard.ts +19 -0
  339. package/src/wizards/gcp-cost.test.ts +103 -0
  340. package/src/wizards/gcp-cost.ts +125 -18
  341. package/src/wizards/gcp.ts +164 -22
  342. package/stacks/aws/Pulumi.yaml +1 -1
  343. package/stacks/aws/index.ts +72 -14
  344. package/stacks/azure/index.ts +108 -21
  345. package/stacks/gcp/Pulumi.yaml +1 -1
  346. package/stacks/gcp/README.md +1 -0
  347. package/stacks/gcp/index.ts +133 -24
  348. package/stacks/gcp-firebase/Pulumi.yaml +1 -1
  349. package/stacks/gcp-firebase/index.ts +212 -34
  350. package/stacks/self-hosted/Pulumi.yaml +3 -0
  351. package/stacks/self-hosted/README.md +6 -1
  352. package/stacks/self-hosted/index.ts +40 -5
@@ -0,0 +1,375 @@
1
+ // SPDX-License-Identifier: MPL-2.0
2
+
3
+ /**
4
+ * #1140 — set up (and converge) the scheduler tick on a Google Cloud install
5
+ * (`gcp`, `gcp-firebase`): the ONE Cloud Scheduler job that calls the
6
+ * admin's `/api/internal/scheduler/tick` every `schedulerIntervalMinutes`
7
+ * (1–15, default 5). Each task's own cadence lives in the admin's
8
+ * due-table; the tick only says "run what is due now". Run by the wizard
9
+ * after migrations and by `cms-provision upgrade`'s converge (and the
10
+ * converge job), as the operator's or the provisioner's identity.
11
+ *
12
+ * Why not Cloud Scheduler → admin directly. The admin sits behind IAP, and
13
+ * IAP accepts a service account's OIDC ID token only when its `aud` is an
14
+ * OAuth client allowlisted for programmatic access; an install on the
15
+ * Google-managed IAP client has none (cloud.google.com/iap/docs/
16
+ * authentication-howto). Cloud Scheduler's other credential, an OAuth
17
+ * access token, it sends only to `*.googleapis.com` (cloud.google.com/
18
+ * scheduler/docs/http-target-auth). What passes IAP for a service account
19
+ * on every install is a self-signed service-account JWT with `aud` =
20
+ * `<admin origin>/*` — the path caelo-mcp and admin-internal-google.ts
21
+ * take. Cloud Scheduler cannot sign one, so the job starts a Cloud
22
+ * Workflows execution (a googleapis.com target, OAuth), and the workflow
23
+ * signs the JWT as the scheduler account through the IAM Credentials API
24
+ * and POSTs the tick. No container per tick and no image to keep in step
25
+ * with the app-roll; cents a month (wizards/gcp-cost.ts).
26
+ *
27
+ * Why the CLI owns it and not the stacks: the same as audit-job-setup.ts —
28
+ * `upgrade` never runs Pulumi, and existing installs get the tick from here.
29
+ *
30
+ * Trust boundary. The scheduler's identity, `caelo-<env>-scheduler`, holds:
31
+ *
32
+ * - `roles/iam.serviceAccountTokenCreator` on ITSELF only (signJwt);
33
+ * - `roles/iap.httpsResourceAccessor` on the admin's IAP resource (the
34
+ * operator-access sync job keeps it there, operator-access.ts);
35
+ * - `roles/workflows.invoker` on the project (Cloud Scheduler starts the
36
+ * workflow as it; Workflows has no per-workflow IAM policy to bind to);
37
+ * - `roles/logging.logWriter` (the workflow's error call logs).
38
+ *
39
+ * Nothing else: no Secret Manager, no Cloud SQL, no Cloud Run rights. What
40
+ * it can do with the admin is the admin's to decide: the tick endpoint
41
+ * accepts exactly this account's IAP identity (`CAELO_SCHEDULER_SERVICE_
42
+ * ACCOUNT` on the admin) and only ever runs the due-table, never a build
43
+ * or a publish (scripts/no-automatic-production-deploy.test.ts).
44
+ * {@link SCHEDULER_FORBIDDEN_ROLES} names that line; the tests assert no
45
+ * grant crosses it.
46
+ */
47
+
48
+ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
49
+ import { tmpdir } from "node:os";
50
+ import { join } from "node:path";
51
+ import { gcloud as defaultGcloud, type GcloudResult } from "./gcloud.js";
52
+ import { type GcloudRunner, realSleep, runWithRetry, type Sleep } from "./gcloud-retry.js";
53
+ import {
54
+ schedulerJobName,
55
+ schedulerServiceAccountEmail,
56
+ schedulerServiceAccountId,
57
+ schedulerWorkflowName,
58
+ } from "./gcp-names.js";
59
+ import { type IapResource, iapResourceArgs } from "./mcp-iap.js";
60
+ import { schedulerCron } from "./stack-contract.js";
61
+
62
+ /** The admin path the workflow calls (apps/admin `api/internal/scheduler/tick`). */
63
+ export const SCHEDULER_TICK_PATH = "/api/internal/scheduler/tick";
64
+
65
+ /**
66
+ * How long the workflow waits for the admin's answer, in seconds: Workflows'
67
+ * maximum (cloud.google.com/workflows/docs/reference/stdlib/http/post). The
68
+ * admin holds the request until the tick's work is done: it claims tasks for
69
+ * at most its budget (4 minutes, admin-core scheduler/tick.ts) and then waits
70
+ * at most one task's lease (10 minutes) for the last one, so 14 minutes in
71
+ * the worst case, inside the admin's own 3600 s request timeout.
72
+ */
73
+ export const SCHEDULER_TICK_TIMEOUT_SECONDS = 1800;
74
+
75
+ /** Lifetime of the IAP credential the workflow signs per tick. */
76
+ const JWT_LIFETIME_SECONDS = 600;
77
+
78
+ /** APIs the tick needs on the project. */
79
+ export const SCHEDULER_APIS = [
80
+ "cloudscheduler.googleapis.com",
81
+ "workflows.googleapis.com",
82
+ "iamcredentials.googleapis.com",
83
+ ] as const;
84
+
85
+ /**
86
+ * Roles the scheduler's identity must never hold anywhere. Prefix matches
87
+ * (`roles/secretmanager.` = every Secret Manager role).
88
+ */
89
+ export const SCHEDULER_FORBIDDEN_ROLES = [
90
+ "roles/owner",
91
+ "roles/editor",
92
+ "roles/viewer",
93
+ "roles/run.",
94
+ "roles/iam.serviceAccountUser",
95
+ "roles/iam.serviceAccountAdmin",
96
+ "roles/iam.securityAdmin",
97
+ "roles/iap.admin",
98
+ "roles/iap.settingsAdmin",
99
+ "roles/secretmanager.",
100
+ "roles/cloudsql.",
101
+ "roles/compute.",
102
+ "roles/storage.",
103
+ "roles/resourcemanager.",
104
+ "roles/workflows.admin",
105
+ "roles/workflows.editor",
106
+ "roles/cloudscheduler.",
107
+ ] as const;
108
+
109
+ export interface SchedulerTickTarget {
110
+ readonly projectId: string;
111
+ readonly region: string;
112
+ /** Pulumi stack name (`production`). */
113
+ readonly env: string;
114
+ /**
115
+ * Where the admin answers behind IAP, an origin: `https://admin.<domain>`
116
+ * on gcp, the admin service's URL on gcp-firebase (remote-mcp.ts
117
+ * RemoteMcpIdentity.adminUrl, the same value as the admin's
118
+ * CAELO_ADMIN_URL).
119
+ */
120
+ readonly adminUrl: string;
121
+ /** The admin's IAP resource (the service on gcp-firebase, the LB backend on gcp). */
122
+ readonly resource: IapResource;
123
+ /** The `schedulerIntervalMinutes` knob (1–15). */
124
+ readonly intervalMinutes: number;
125
+ }
126
+
127
+ export type SchedulerTickResult =
128
+ | { readonly ok: true; readonly done: string[]; readonly serviceAccount: string }
129
+ | { readonly ok: false; readonly done: string[]; readonly error: string };
130
+
131
+ /**
132
+ * The tick's admin origin, or an error naming why it is not one: an https
133
+ * origin without path, query or credentials (it is written into the
134
+ * workflow's source, so nothing but an origin may get there).
135
+ */
136
+ export function tickOrigin(
137
+ adminUrl: string,
138
+ ): { ok: true; origin: string } | { ok: false; error: string } {
139
+ let u: URL;
140
+ try {
141
+ u = new URL(adminUrl);
142
+ } catch {
143
+ return { ok: false, error: `the admin URL ${JSON.stringify(adminUrl)} is not a URL` };
144
+ }
145
+ if (
146
+ u.protocol !== "https:" ||
147
+ u.username ||
148
+ u.password ||
149
+ (u.pathname !== "/" && u.pathname !== "") ||
150
+ u.search ||
151
+ u.hash ||
152
+ !/^[a-z0-9.-]+$/.test(u.hostname)
153
+ ) {
154
+ return {
155
+ ok: false,
156
+ error: `the admin URL ${JSON.stringify(adminUrl)} is not a plain https origin`,
157
+ };
158
+ }
159
+ return { ok: true, origin: u.origin };
160
+ }
161
+
162
+ /**
163
+ * The workflow one tick runs (Cloud Workflows YAML): sign a service-account
164
+ * JWT for the admin's IAP as the scheduler account itself (the IAM
165
+ * Credentials API, authenticated with the workflow's own OAuth token), then
166
+ * POST the tick with it. A refused or failed tick (HTTP ≥ 400) fails the
167
+ * execution, so it shows in the workflow's execution history and logs.
168
+ */
169
+ export function schedulerWorkflowSource(opts: {
170
+ readonly serviceAccount: string;
171
+ readonly origin: string;
172
+ }): string {
173
+ const { serviceAccount: sa, origin } = opts;
174
+ return `# Caelo scheduler tick (#1140) — generated by cms-provision, do not edit.
175
+ main:
176
+ steps:
177
+ - claims:
178
+ assign:
179
+ - now: \${int(sys.now())}
180
+ - jwtClaims:
181
+ iss: "${sa}"
182
+ sub: "${sa}"
183
+ aud: "${origin}/*"
184
+ iat: \${now}
185
+ exp: \${now + ${JWT_LIFETIME_SECONDS}}
186
+ - sign:
187
+ call: http.post
188
+ args:
189
+ url: "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/${sa}:signJwt"
190
+ auth:
191
+ type: OAuth2
192
+ body:
193
+ payload: \${json.encode_to_string(jwtClaims)}
194
+ result: signed
195
+ - tick:
196
+ call: http.post
197
+ args:
198
+ url: "${origin}${SCHEDULER_TICK_PATH}"
199
+ headers:
200
+ Authorization: \${"Bearer " + signed.body.signedJwt}
201
+ timeout: ${SCHEDULER_TICK_TIMEOUT_SECONDS}
202
+ result: answer
203
+ - done:
204
+ return: \${answer.code}
205
+ `;
206
+ }
207
+
208
+ /** Ensure the scheduler tick and everything it needs. Never throws for a gcloud failure. */
209
+ export async function ensureSchedulerTick(
210
+ target: SchedulerTickTarget,
211
+ deps: { run?: GcloudRunner; sleep?: Sleep } = {},
212
+ ): Promise<SchedulerTickResult> {
213
+ const run = deps.run ?? defaultGcloud;
214
+ const sleep = deps.sleep ?? realSleep;
215
+ const retry = (args: string[]) => runWithRetry(run, sleep, args);
216
+ const { projectId, region, env } = target;
217
+ const project = `--project=${projectId}`;
218
+ const sa = schedulerServiceAccountEmail(projectId, env);
219
+ const member = `serviceAccount:${sa}`;
220
+ const workflow = schedulerWorkflowName(env);
221
+ const job = schedulerJobName(env);
222
+ const done: string[] = [];
223
+ const fail = (step: string, r: GcloudResult): SchedulerTickResult => ({
224
+ ok: false,
225
+ done,
226
+ error: `${step}: ${r.stderr.trim()}`,
227
+ });
228
+
229
+ const origin = tickOrigin(target.adminUrl);
230
+ if (!origin.ok) return { ok: false, done, error: origin.error };
231
+ let cron: string;
232
+ try {
233
+ cron = schedulerCron(target.intervalMinutes);
234
+ } catch (e) {
235
+ return { ok: false, done, error: (e as Error).message };
236
+ }
237
+
238
+ // 1. APIs.
239
+ const api = await run(["services", "enable", ...SCHEDULER_APIS, project, "--quiet"]);
240
+ if (!api.ok) return fail(`enable ${SCHEDULER_APIS.join(", ")}`, api);
241
+ done.push(`APIs enabled (${SCHEDULER_APIS.join(", ")})`);
242
+
243
+ // 2. The scheduler's own service account.
244
+ const describe = await run([
245
+ "iam",
246
+ "service-accounts",
247
+ "describe",
248
+ sa,
249
+ project,
250
+ "--format=value(email)",
251
+ ]);
252
+ if (!describe.ok) {
253
+ const create = await run([
254
+ "iam",
255
+ "service-accounts",
256
+ "create",
257
+ schedulerServiceAccountId(env),
258
+ "--display-name=Caelo scheduler tick",
259
+ "--description=Calls the admin's scheduler tick through IAP every few minutes; signs its own IAP credential, nothing else.",
260
+ project,
261
+ ]);
262
+ if (!create.ok && !/already exists/i.test(create.stderr)) return fail(`create ${sa}`, create);
263
+ }
264
+ done.push(`service account ${sa}`);
265
+
266
+ // 3. Its grants (see the file comment).
267
+ const self = await retry([
268
+ "iam",
269
+ "service-accounts",
270
+ "add-iam-policy-binding",
271
+ sa,
272
+ `--member=${member}`,
273
+ "--role=roles/iam.serviceAccountTokenCreator",
274
+ "--condition=None",
275
+ project,
276
+ "--quiet",
277
+ "--format=none",
278
+ ]);
279
+ if (!self.ok) return fail("let the scheduler sign its IAP credential as itself", self);
280
+ done.push(`scheduler: roles/iam.serviceAccountTokenCreator on ${sa} (itself, signJwt)`);
281
+
282
+ for (const g of [
283
+ { role: "roles/workflows.invoker", why: "Cloud Scheduler starts the tick workflow as it" },
284
+ { role: "roles/logging.logWriter", why: "the workflow logs failed calls" },
285
+ ]) {
286
+ const r = await retry([
287
+ "projects",
288
+ "add-iam-policy-binding",
289
+ projectId,
290
+ `--member=${member}`,
291
+ `--role=${g.role}`,
292
+ "--condition=None",
293
+ "--quiet",
294
+ "--format=none",
295
+ ]);
296
+ if (!r.ok) return fail(`grant the scheduler ${g.role} (${g.why})`, r);
297
+ done.push(`scheduler: ${g.role} on the project`);
298
+ }
299
+
300
+ const iap = await retry([
301
+ "iap",
302
+ "web",
303
+ "add-iam-policy-binding",
304
+ ...iapResourceArgs(target.resource),
305
+ `--member=${member}`,
306
+ "--role=roles/iap.httpsResourceAccessor",
307
+ "--condition=None",
308
+ project,
309
+ "--quiet",
310
+ ]);
311
+ if (!iap.ok) return fail("let the scheduler pass the admin's IAP", iap);
312
+ done.push(`scheduler: roles/iap.httpsResourceAccessor on the admin (${target.resource.service})`);
313
+
314
+ // 4. The workflow. A private directory (mkdtemp, mode 700): no other local
315
+ // user can swap the file between write and read.
316
+ const dir = mkdtempSync(join(tmpdir(), "caelo-scheduler-"));
317
+ try {
318
+ const file = join(dir, "tick.yaml");
319
+ writeFileSync(file, schedulerWorkflowSource({ serviceAccount: sa, origin: origin.origin }), {
320
+ mode: 0o600,
321
+ });
322
+ const deploy = await retry([
323
+ "workflows",
324
+ "deploy",
325
+ workflow,
326
+ `--source=${file}`,
327
+ `--location=${region}`,
328
+ `--service-account=${sa}`,
329
+ "--call-log-level=log-errors-only",
330
+ `--description=Caelo scheduler tick (#1140): calls ${origin.origin}${SCHEDULER_TICK_PATH}`,
331
+ project,
332
+ "--quiet",
333
+ ]);
334
+ if (!deploy.ok) return fail(`deploy workflow ${workflow}`, deploy);
335
+ } finally {
336
+ rmSync(dir, { recursive: true, force: true });
337
+ }
338
+ done.push(`workflow ${workflow} (calls ${origin.origin}${SCHEDULER_TICK_PATH})`);
339
+
340
+ // 5. The one Cloud Scheduler job.
341
+ const scheduleArgs = [
342
+ job,
343
+ `--location=${region}`,
344
+ project,
345
+ `--schedule=${cron}`,
346
+ "--time-zone=Etc/UTC",
347
+ `--uri=https://workflowexecutions.googleapis.com/v1/projects/${projectId}/locations/${region}/workflows/${workflow}/executions`,
348
+ "--http-method=POST",
349
+ `--oauth-service-account-email=${sa}`,
350
+ // A tick that has not answered when the next one is due is the admin's
351
+ // lease to sort out (its due-table), not a reason to retry this one.
352
+ "--max-retry-attempts=0",
353
+ "--quiet",
354
+ ];
355
+ const existing = await run([
356
+ "scheduler",
357
+ "jobs",
358
+ "describe",
359
+ job,
360
+ `--location=${region}`,
361
+ project,
362
+ "--format=value(name)",
363
+ ]);
364
+ const sched = await retry([
365
+ "scheduler",
366
+ "jobs",
367
+ existing.ok ? "update" : "create",
368
+ "http",
369
+ ...scheduleArgs,
370
+ ]);
371
+ if (!sched.ok) return fail(`schedule ${job}`, sched);
372
+ done.push(`Cloud Scheduler job ${job} (${cron}, UTC)`);
373
+
374
+ return { ok: true, done, serviceAccount: sa };
375
+ }
@@ -15,7 +15,7 @@ const T = {
15
15
  projectId: "acme",
16
16
  region: "europe-west1",
17
17
  env: "production",
18
- gatewayService: "caelo-production-gateway-abc",
18
+ proxyService: "caelo-production-gateway-abc",
19
19
  };
20
20
  const DAY = 24 * 60 * 60 * 1000;
21
21
  const NOW = Date.UTC(2026, 9, 20);
@@ -122,7 +122,7 @@ describe("seal-key rotation (#806)", () => {
122
122
 
123
123
  it("keeps the window equal to the broker's refresh-token lifetime", async () => {
124
124
  const src = await Bun.file(
125
- new URL("../../../apps/api-gateway/src/mcp/token.ts", import.meta.url),
125
+ new URL("../../../apps/mcp-auth-proxy/src/token.ts", import.meta.url),
126
126
  ).text();
127
127
  expect(src).toContain(
128
128
  `REFRESH_MAX_LIFETIME_SECONDS = ${SEAL_KEY_ROTATION_WINDOW_DAYS} * 24 * 60 * 60`,
@@ -5,7 +5,7 @@
5
5
  * every connected MCP client out.
6
6
  *
7
7
  * The broker seals its OAuth state, codes and refresh tokens under
8
- * `CAELO_MCP_OAUTH_SEAL_KEY` (api-gateway mcp/seal.ts, envelope v2 with a
8
+ * `CAELO_MCP_OAUTH_SEAL_KEY` (apps/mcp-auth-proxy seal.ts, envelope v2 with a
9
9
  * key id). While `CAELO_MCP_OAUTH_SEAL_KEY_PREVIOUS` is set it also opens
10
10
  * values sealed under that key, and seals everything new under the current
11
11
  * one. Refresh tokens live at most {@link SEAL_KEY_ROTATION_WINDOW_DAYS}
@@ -14,7 +14,7 @@
14
14
  *
15
15
  * Two steps, both `cms-provision rotate-secret mcp-oauth-seal-key`:
16
16
  *
17
- * start — add a new version to the secret, then roll the gateway with
17
+ * start — add a new version to the secret, then roll the MCP-Auth-Proxy with
18
18
  * the current key at `latest` and the previous key PINNED to
19
19
  * the version that was latest before (a pinned version never
20
20
  * follows the new one), labelled with the start time.
@@ -27,7 +27,7 @@
27
27
  * progress (a second start would pin the CURRENT key as "previous" and drop
28
28
  * the real previous one early), and finishing before the window ends.
29
29
  *
30
- * A `cms-provision upgrade` whose `pulumi up` rewrites the gateway template
30
+ * A `cms-provision upgrade` whose `pulumi up` rewrites the MCP-Auth-Proxy template
31
31
  * during the window drops the previous key (the stack does not declare it):
32
32
  * clients sealed under it sign in again. That fails safe — no token lives
33
33
  * longer than intended — and is documented in the rotate output.
@@ -39,27 +39,27 @@ import { gcpSecretId } from "./gcp-names.js";
39
39
  import { initialSecretValue } from "./runtime-secrets.js";
40
40
  import { liveContainerEnv } from "./stack-converge.js";
41
41
 
42
- /** The gateway env var holding the previous key during a rotation. */
42
+ /** The MCP-Auth-Proxy env var holding the previous key during a rotation. */
43
43
  export const SEAL_KEY_PREVIOUS_ENV = "CAELO_MCP_OAUTH_SEAL_KEY_PREVIOUS";
44
- /** The gateway env var holding the current key (stack-contract SERVICE_SECRET_ENV). */
44
+ /** The MCP-Auth-Proxy env var holding the current key (stack-contract SERVICE_SECRET_ENV). */
45
45
  export const SEAL_KEY_ENV = "CAELO_MCP_OAUTH_SEAL_KEY";
46
- /** Label on the gateway service: when the rotation started (epoch ms). */
46
+ /** Label on the MCP-Auth-Proxy service: when the rotation started (epoch ms). */
47
47
  export const SEAL_ROTATION_LABEL = "caelo-seal-rotation-started";
48
48
  /**
49
49
  * Days the previous key must stay: the broker's refresh-token lifetime
50
- * (api-gateway mcp/token.ts REFRESH_MAX_LIFETIME_SECONDS, 30 days).
50
+ * (apps/mcp-auth-proxy token.ts REFRESH_MAX_LIFETIME_SECONDS, 30 days).
51
51
  */
52
52
  export const SEAL_KEY_ROTATION_WINDOW_DAYS = 30;
53
53
 
54
54
  const DAY_MS = 24 * 60 * 60 * 1000;
55
55
 
56
- /** The deployed gateway a rotation works on. */
56
+ /** The deployed MCP-Auth-Proxy a rotation works on. */
57
57
  export interface SealRotationTarget {
58
58
  readonly projectId: string;
59
59
  readonly region: string;
60
60
  readonly env: string;
61
- /** Deployed (Pulumi-suffixed) gateway Cloud Run service name. */
62
- readonly gatewayService: string;
61
+ /** Deployed (Pulumi-suffixed or fixed) MCP-Auth-Proxy Cloud Run service name. */
62
+ readonly proxyService: string;
63
63
  }
64
64
 
65
65
  export interface SealRotationReport {
@@ -80,7 +80,7 @@ interface GatewayState {
80
80
  readonly startedAtMs: number | null;
81
81
  }
82
82
 
83
- async function gatewayState(
83
+ async function proxyState(
84
84
  run: GcloudRunner,
85
85
  t: SealRotationTarget,
86
86
  ): Promise<{ ok: true; state: GatewayState } | { ok: false; error: string }> {
@@ -88,13 +88,13 @@ async function gatewayState(
88
88
  "run",
89
89
  "services",
90
90
  "describe",
91
- t.gatewayService,
91
+ t.proxyService,
92
92
  "--region",
93
93
  t.region,
94
94
  `--project=${t.projectId}`,
95
95
  "--format=json",
96
96
  ]);
97
- if (!r.ok) return { ok: false, error: `read the gateway service: ${r.stderr.trim()}` };
97
+ if (!r.ok) return { ok: false, error: `read the MCP-Auth-Proxy service: ${r.stderr.trim()}` };
98
98
  const env = liveContainerEnv(r.stdout);
99
99
  const labels =
100
100
  (JSON.parse(r.stdout) as { metadata?: { labels?: Record<string, string> } }).metadata?.labels ??
@@ -105,7 +105,7 @@ async function gatewayState(
105
105
  if (current?.kind !== "secret") {
106
106
  return {
107
107
  ok: false,
108
- error: `${SEAL_KEY_ENV} on ${t.gatewayService} is not a Secret Manager reference — run \`cms-provision upgrade\` first (it installs remote MCP's secrets).`,
108
+ error: `${SEAL_KEY_ENV} on ${t.proxyService} is not a Secret Manager reference — run \`cms-provision upgrade\` first (it installs remote MCP's secrets).`,
109
109
  };
110
110
  }
111
111
  return {
@@ -119,7 +119,7 @@ function rollFlip(t: SealRotationTarget): string[] {
119
119
  "run",
120
120
  "services",
121
121
  "update-traffic",
122
- t.gatewayService,
122
+ t.proxyService,
123
123
  "--region",
124
124
  t.region,
125
125
  `--project=${t.projectId}`,
@@ -140,7 +140,7 @@ export async function startSealKeyRotation(
140
140
  const project = `--project=${t.projectId}`;
141
141
  const steps: string[] = [];
142
142
 
143
- const live = await gatewayState(run, t);
143
+ const live = await proxyState(run, t);
144
144
  if (!live.ok) return { ok: false, steps, error: live.error };
145
145
  if (live.state.previousPinned) {
146
146
  const since = live.state.startedAtMs;
@@ -181,7 +181,7 @@ export async function startSealKeyRotation(
181
181
  "run",
182
182
  "services",
183
183
  "update",
184
- t.gatewayService,
184
+ t.proxyService,
185
185
  "--region",
186
186
  t.region,
187
187
  project,
@@ -195,11 +195,11 @@ export async function startSealKeyRotation(
195
195
  return {
196
196
  ok: false,
197
197
  steps,
198
- error: `The new key is stored but the gateway does not use it yet. Do not rotate again — roll the gateway:\n gcloud ${update.join(" ")}\n gcloud ${rollFlip(t).join(" ")}\n(${flipped.stderr.trim()})`,
198
+ error: `The new key is stored but the MCP-Auth-Proxy does not use it yet. Do not rotate again — roll the MCP-Auth-Proxy:\n gcloud ${update.join(" ")}\n gcloud ${rollFlip(t).join(" ")}\n(${flipped.stderr.trim()})`,
199
199
  };
200
200
  }
201
201
  steps.push(
202
- `rolled the gateway onto the new key; tokens sealed under version ${version} keep working`,
202
+ `rolled the MCP-Auth-Proxy onto the new key; tokens sealed under version ${version} keep working`,
203
203
  `finish after ${new Date(now + SEAL_KEY_ROTATION_WINDOW_DAYS * DAY_MS).toISOString()} with: cms-provision rotate-secret mcp-oauth-seal-key --finish`,
204
204
  "a `cms-provision upgrade` before then drops the previous key early: clients sealed under it sign in again",
205
205
  );
@@ -215,13 +215,13 @@ export async function finishSealKeyRotation(
215
215
  const run = deps.run ?? defaultGcloud;
216
216
  const now = (deps.nowMs ?? Date.now)();
217
217
  const steps: string[] = [];
218
- const live = await gatewayState(run, t);
218
+ const live = await proxyState(run, t);
219
219
  if (!live.ok) return { ok: false, steps, error: live.error };
220
220
  if (!live.state.previousPinned) {
221
221
  return {
222
222
  ok: false,
223
223
  steps,
224
- error: `No seal-key rotation is in progress on ${t.gatewayService} (${SEAL_KEY_PREVIOUS_ENV} is not set). Start one with \`cms-provision rotate-secret mcp-oauth-seal-key\`.`,
224
+ error: `No seal-key rotation is in progress on ${t.proxyService} (${SEAL_KEY_PREVIOUS_ENV} is not set). Start one with \`cms-provision rotate-secret mcp-oauth-seal-key\`.`,
225
225
  };
226
226
  }
227
227
  const started = live.state.startedAtMs;
@@ -232,7 +232,7 @@ export async function finishSealKeyRotation(
232
232
  steps,
233
233
  error:
234
234
  due === null
235
- ? `The gateway has ${SEAL_KEY_PREVIOUS_ENV} but no ${SEAL_ROTATION_LABEL} label, so the rotation's start is unknown. Wait ${SEAL_KEY_ROTATION_WINDOW_DAYS} days from when it started, then run --finish --now.`
235
+ ? `The MCP-Auth-Proxy has ${SEAL_KEY_PREVIOUS_ENV} but no ${SEAL_ROTATION_LABEL} label, so the rotation's start is unknown. Wait ${SEAL_KEY_ROTATION_WINDOW_DAYS} days from when it started, then run --finish --now.`
236
236
  : `The previous key still opens refresh tokens until ${new Date(due).toISOString()} (${SEAL_KEY_ROTATION_WINDOW_DAYS}-day lifetime). Finishing now would sign those clients out; run --finish after that time, or --finish --now if the old key leaked.`,
237
237
  };
238
238
  }
@@ -240,7 +240,7 @@ export async function finishSealKeyRotation(
240
240
  "run",
241
241
  "services",
242
242
  "update",
243
- t.gatewayService,
243
+ t.proxyService,
244
244
  "--region",
245
245
  t.region,
246
246
  `--project=${t.projectId}`,
@@ -251,8 +251,8 @@ export async function finishSealKeyRotation(
251
251
  const rolled = await run(update);
252
252
  const flipped = rolled.ok ? await run(rollFlip(t)) : rolled;
253
253
  if (!flipped.ok) {
254
- return { ok: false, steps, error: `roll the gateway: ${flipped.stderr.trim()}` };
254
+ return { ok: false, steps, error: `roll the MCP-Auth-Proxy: ${flipped.stderr.trim()}` };
255
255
  }
256
- steps.push("removed the previous seal key from the gateway; the rotation is complete");
256
+ steps.push("removed the previous seal key from the MCP-Auth-Proxy; the rotation is complete");
257
257
  return { ok: true, steps };
258
258
  }
@@ -203,6 +203,7 @@ describe("restoreSelfHosted", () => {
203
203
  "<converge roles>",
204
204
  `${MIGRATE} admin`,
205
205
  `${MIGRATE} public`,
206
+ `${MIGRATE} public-staging`,
206
207
  "run --rm --no-deps -T --entrypoint sh caelo-admin -c set -e; find /srv/caelo /data/media -mindepth 1 -delete; tar -C / -xf -",
207
208
  "up -d --remove-orphans",
208
209
  "exec -T caelo-admin bun -e <probe>",