@flisk-sh/flisk 0.0.0-stage → 1.3.190

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 (440) hide show
  1. package/CHANGELOG.md +492 -0
  2. package/LICENSE +21 -0
  3. package/README.md +479 -2
  4. package/Tiltfile +151 -0
  5. package/cli/bin/flisk.js +42 -0
  6. package/cli/dist/agent-runtimes/custom.js +335 -0
  7. package/cli/dist/agent-runtimes/registry.js +34 -0
  8. package/cli/dist/backend-frameworks/elysia.js +38 -0
  9. package/cli/dist/backend-frameworks/express.js +49 -0
  10. package/cli/dist/backend-frameworks/fastify.js +43 -0
  11. package/cli/dist/backend-frameworks/h3.js +37 -0
  12. package/cli/dist/backend-frameworks/koa.js +47 -0
  13. package/cli/dist/backend-frameworks/mcp.js +86 -0
  14. package/cli/dist/backend-frameworks/nestjs.js +55 -0
  15. package/cli/dist/backend-frameworks/registry.js +134 -0
  16. package/cli/dist/backend-frameworks/types.js +1 -0
  17. package/cli/dist/backend-languages/bun.js +76 -0
  18. package/cli/dist/backend-languages/go.js +125 -0
  19. package/cli/dist/backend-languages/node.js +122 -0
  20. package/cli/dist/backend-languages/python.js +94 -0
  21. package/cli/dist/backend-languages/registry.js +37 -0
  22. package/cli/dist/backend-languages/rust.js +82 -0
  23. package/cli/dist/backend-languages/types.js +1 -0
  24. package/cli/dist/cli.js +29 -0
  25. package/cli/dist/commands/__tests__/project-e2e-helpers.js +49 -0
  26. package/cli/dist/commands/__tests__/ui-loading-screen.test.js +16 -0
  27. package/cli/dist/commands/agent.js +182 -0
  28. package/cli/dist/commands/completion-candidates.js +116 -0
  29. package/cli/dist/commands/completion.js +843 -0
  30. package/cli/dist/commands/config.js +362 -0
  31. package/cli/dist/commands/doctor.js +1504 -0
  32. package/cli/dist/commands/down.js +114 -0
  33. package/cli/dist/commands/eject.js +108 -0
  34. package/cli/dist/commands/help.js +152 -0
  35. package/cli/dist/commands/import.js +164 -0
  36. package/cli/dist/commands/logs.js +119 -0
  37. package/cli/dist/commands/maintainers.js +102 -0
  38. package/cli/dist/commands/mcp.js +28 -0
  39. package/cli/dist/commands/networks.js +306 -0
  40. package/cli/dist/commands/project.js +447 -0
  41. package/cli/dist/commands/projects.js +103 -0
  42. package/cli/dist/commands/registry.js +53 -0
  43. package/cli/dist/commands/resource.js +992 -0
  44. package/cli/dist/commands/resources.js +127 -0
  45. package/cli/dist/commands/restart.js +89 -0
  46. package/cli/dist/commands/runtime.js +75 -0
  47. package/cli/dist/commands/stack.js +171 -0
  48. package/cli/dist/commands/stacks.js +71 -0
  49. package/cli/dist/commands/status.js +211 -0
  50. package/cli/dist/commands/ui.js +725 -0
  51. package/cli/dist/commands/up.js +609 -0
  52. package/cli/dist/commands/upgrade.js +840 -0
  53. package/cli/dist/commands/version.js +10 -0
  54. package/cli/dist/components/Accessible.js +11 -0
  55. package/cli/dist/components/BaseTooltip.js +30 -0
  56. package/cli/dist/components/DetailPanel.js +33 -0
  57. package/cli/dist/components/FileTree.js +51 -0
  58. package/cli/dist/components/ResourceSelectInput.js +42 -0
  59. package/cli/dist/components/ResourceTable.js +35 -0
  60. package/cli/dist/components/ServiceIssues.js +13 -0
  61. package/cli/dist/components/TUIHeader.js +27 -0
  62. package/cli/dist/components/TabBar.js +27 -0
  63. package/cli/dist/components/Tooltip.js +13 -0
  64. package/cli/dist/components/index.js +11 -0
  65. package/cli/dist/components/ui-theme.js +120 -0
  66. package/cli/dist/config/platform-standards.js +182 -0
  67. package/cli/dist/frontend-frameworks/lit.js +64 -0
  68. package/cli/dist/frontend-frameworks/preact.js +62 -0
  69. package/cli/dist/frontend-frameworks/qwik.js +61 -0
  70. package/cli/dist/frontend-frameworks/react.js +69 -0
  71. package/cli/dist/frontend-frameworks/registry.js +83 -0
  72. package/cli/dist/frontend-frameworks/solid.js +62 -0
  73. package/cli/dist/frontend-frameworks/svelte.js +67 -0
  74. package/cli/dist/frontend-frameworks/tanstack-router.js +101 -0
  75. package/cli/dist/frontend-frameworks/types.js +1 -0
  76. package/cli/dist/frontend-frameworks/vanilla.js +59 -0
  77. package/cli/dist/frontend-frameworks/vue.js +72 -0
  78. package/cli/dist/generator/__tests__/golden-helpers.js +43 -0
  79. package/cli/dist/generator/extension-fetch.js +291 -0
  80. package/cli/dist/generator/resource-templates.js +133 -0
  81. package/cli/dist/generator/template-engine.js +801 -0
  82. package/cli/dist/index.js +10 -0
  83. package/cli/dist/mcp/server.js +101 -0
  84. package/cli/dist/mcp/tools.js +351 -0
  85. package/cli/dist/program.js +37 -0
  86. package/cli/dist/types/index.js +38 -0
  87. package/cli/dist/utils/agent-host.js +36 -0
  88. package/cli/dist/utils/atomic-write.js +36 -0
  89. package/cli/dist/utils/bun-floor.js +9 -0
  90. package/cli/dist/utils/bun-requirement.js +10 -0
  91. package/cli/dist/utils/cache.js +63 -0
  92. package/cli/dist/utils/cold-preflight.js +257 -0
  93. package/cli/dist/utils/command-helpers.js +57 -0
  94. package/cli/dist/utils/constants.js +160 -0
  95. package/cli/dist/utils/discovery-context.js +71 -0
  96. package/cli/dist/utils/discovery-paths.js +93 -0
  97. package/cli/dist/utils/docker.js +34 -0
  98. package/cli/dist/utils/doctor-crashloop.js +161 -0
  99. package/cli/dist/utils/doctor-fix.js +391 -0
  100. package/cli/dist/utils/doctor-host.js +66 -0
  101. package/cli/dist/utils/doctor-report.js +78 -0
  102. package/cli/dist/utils/doctor-runtime.js +880 -0
  103. package/cli/dist/utils/doctor-starlark.js +132 -0
  104. package/cli/dist/utils/doctor-wiring.js +698 -0
  105. package/cli/dist/utils/down-cleanup.js +125 -0
  106. package/cli/dist/utils/env-validator.js +266 -0
  107. package/cli/dist/utils/errors.js +175 -0
  108. package/cli/dist/utils/exec-async.js +31 -0
  109. package/cli/dist/utils/file-helpers.js +104 -0
  110. package/cli/dist/utils/formatting.js +165 -0
  111. package/cli/dist/utils/generated-paths.js +51 -0
  112. package/cli/dist/utils/help-command.js +11 -0
  113. package/cli/dist/utils/host-port-config.js +140 -0
  114. package/cli/dist/utils/host-port-plan.js +100 -0
  115. package/cli/dist/utils/json-output.js +29 -0
  116. package/cli/dist/utils/machine-output.js +33 -0
  117. package/cli/dist/utils/paths.js +43 -0
  118. package/cli/dist/utils/platform.js +58 -0
  119. package/cli/dist/utils/port-assignment.js +75 -0
  120. package/cli/dist/utils/port-conflict-fix.js +25 -0
  121. package/cli/dist/utils/port-fallback-notice.js +17 -0
  122. package/cli/dist/utils/port-listener-probe.js +20 -0
  123. package/cli/dist/utils/project-config-defaults.js +17 -0
  124. package/cli/dist/utils/project-features.js +91 -0
  125. package/cli/dist/utils/project-templates.js +32 -0
  126. package/cli/dist/utils/prompt.js +97 -0
  127. package/cli/dist/utils/resource-features.js +184 -0
  128. package/cli/dist/utils/resource-kind.js +9 -0
  129. package/cli/dist/utils/schema-version-gate.js +45 -0
  130. package/cli/dist/utils/search-status.js +12 -0
  131. package/cli/dist/utils/secret-redaction.js +73 -0
  132. package/cli/dist/utils/service-config-checks.js +189 -0
  133. package/cli/dist/utils/service-manifest.js +254 -0
  134. package/cli/dist/utils/service-runtime-state.js +66 -0
  135. package/cli/dist/utils/service-urls.js +112 -0
  136. package/cli/dist/utils/services.js +360 -0
  137. package/cli/dist/utils/shared-infra.js +45 -0
  138. package/cli/dist/utils/shared-platform-postgres.js +232 -0
  139. package/cli/dist/utils/single-flight.js +21 -0
  140. package/cli/dist/utils/smoke.js +401 -0
  141. package/cli/dist/utils/spinner.js +40 -0
  142. package/cli/dist/utils/stack-features.js +15 -0
  143. package/cli/dist/utils/stack-status.js +14 -0
  144. package/cli/dist/utils/startup-report.js +78 -0
  145. package/cli/dist/utils/status-message.js +21 -0
  146. package/cli/dist/utils/status-ports.js +33 -0
  147. package/cli/dist/utils/suggestions.js +63 -0
  148. package/cli/dist/utils/tar.js +46 -0
  149. package/cli/dist/utils/tdk-version.js +51 -0
  150. package/cli/dist/utils/terminal-layout.js +19 -0
  151. package/cli/dist/utils/tilt-events.js +194 -0
  152. package/cli/dist/utils/tilt-logs.js +61 -0
  153. package/cli/dist/utils/tilt-port-owner.js +63 -0
  154. package/cli/dist/utils/tilt-process.js +54 -0
  155. package/cli/dist/utils/tilt-resource-state.js +32 -0
  156. package/cli/dist/utils/tilt-startup.js +49 -0
  157. package/cli/dist/utils/tilt-unreachable-message.js +9 -0
  158. package/cli/dist/utils/tilt.js +104 -0
  159. package/cli/dist/utils/ui-keymap.js +129 -0
  160. package/cli/dist/utils/ui-service-state.js +34 -0
  161. package/cli/dist/utils/up-only.js +28 -0
  162. package/cli/dist/utils/up-readiness.js +118 -0
  163. package/cli/dist/utils/url-actions.js +103 -0
  164. package/cli/dist/utils/validation.js +62 -0
  165. package/cli/dist/utils/which.js +56 -0
  166. package/cli/dist/utils/windows-doctor.js +176 -0
  167. package/cli/dist-bundle/chunk-6EA4DGCY.js +2 -0
  168. package/cli/dist-bundle/chunk-BZ4H7MM4.js +3 -0
  169. package/cli/dist-bundle/chunk-CLCUIDBH.js +510 -0
  170. package/cli/dist-bundle/cli.js +2017 -0
  171. package/cli/dist-bundle/cold-preflight-SY26O2IG.js +2 -0
  172. package/cli/dist-bundle/devtools-ZUHXW33W.js +5 -0
  173. package/cli/dist-bundle/extension-fetch-J4FFH7TJ.js +2 -0
  174. package/cli/package.json +83 -0
  175. package/cli/shared-platform-engineering/docker-templates/bun-hoisted-symlink-fix.sh +25 -0
  176. package/cli/shared-platform-engineering/docker-templates/infisical-entrypoint.sh +466 -0
  177. package/cli/shared-platform-engineering/docker-templates/install-deps.sh +154 -0
  178. package/cli/shared-platform-engineering/docker-templates/prisma-bun-client-link-fix.sh +14 -0
  179. package/cli/shared-platform-engineering/docker-templates/prisma-normalize-client.sh +58 -0
  180. package/cli/templates/.tiltignore.hbs +72 -0
  181. package/cli/templates/TILT_RESOURCE_DEFAULTS.star.hbs +220 -0
  182. package/cli/templates/TILT_TECH_STACK.star.hbs +149 -0
  183. package/cli/templates/Tiltfile.hbs +381 -0
  184. package/cli/templates/spec.master.hbs +192 -0
  185. package/discovery/AGENTS.md +362 -0
  186. package/discovery/TILT_DISCOVERY.star +429 -0
  187. package/discovery/Tiltfile +58 -0
  188. package/discovery/config.star +265 -0
  189. package/discovery/constants.star +167 -0
  190. package/discovery/deterministic.star +213 -0
  191. package/discovery/discovery_daemon.star +193 -0
  192. package/discovery/discovery_orchestrator.star +492 -0
  193. package/discovery/filtering.star +7 -0
  194. package/discovery/identity-management-backend/service.yaml +26 -0
  195. package/discovery/identity-management-frontend/service.yaml +29 -0
  196. package/discovery/identity-sdk/service.yaml +9 -0
  197. package/discovery/incremental_discovery.star +215 -0
  198. package/discovery/indexing.star +9 -0
  199. package/discovery/json_manifest_scanner.star +57 -0
  200. package/discovery/libraries.star +48 -0
  201. package/discovery/loading.star +25 -0
  202. package/discovery/manifest/constants.star +106 -0
  203. package/discovery/manifest/loading.star +418 -0
  204. package/discovery/manifest/normalize.star +289 -0
  205. package/discovery/manifest/validation.star +110 -0
  206. package/discovery/normalization.star +13 -0
  207. package/discovery/registry.star +562 -0
  208. package/discovery/resource_snapshot.py +384 -0
  209. package/discovery/resource_snapshot.star +145 -0
  210. package/discovery/schemas.star +3 -0
  211. package/discovery/services/platform/cdc/debezium/nats-connector/service.yaml +9 -0
  212. package/discovery/services/platform/cdc/nats-http-bridge/service.yaml +9 -0
  213. package/discovery/services/platform/orchestrator/orchestrator-glue-backend/service.yaml +26 -0
  214. package/discovery/services/platform/synthetic-monitor/service.yaml +9 -0
  215. package/discovery/test_resource_snapshot.py +253 -0
  216. package/discovery/validation.star +80 -0
  217. package/discovery/versioning.star +3 -0
  218. package/engine/AGENTS.md +706 -0
  219. package/engine/README.md +31 -0
  220. package/engine/REFACTORING_MANIFEST_SYSTEM.md +974 -0
  221. package/engine/Tiltfile +86 -0
  222. package/engine/assets/docker/golden-layers.Dockerfile +204 -0
  223. package/engine/assets/docker/wake-gateway/Dockerfile +28 -0
  224. package/engine/assets/docker/wake-gateway/decide.test.ts +177 -0
  225. package/engine/assets/docker/wake-gateway/decide.ts +135 -0
  226. package/engine/assets/docker/wake-gateway/server.ts +363 -0
  227. package/engine/assets/scripts/cleanup-completed-migrator-images.sh +39 -0
  228. package/engine/assets/scripts/cleanup-tilt-images.sh +122 -0
  229. package/engine/assets/scripts/mac-m1-resource-monitor.sh +123 -0
  230. package/engine/config.star +5 -0
  231. package/engine/entrypoint.star +101 -0
  232. package/engine/lifecycle/orchestrator.star +263 -0
  233. package/engine/paths.star +719 -0
  234. package/engine/schemas/project-schema.json +147 -0
  235. package/engine/schemas/service-schema.json +537 -0
  236. package/engine/scripts/README.md +89 -0
  237. package/engine/scripts/build-and-publish-lib.sh +207 -0
  238. package/engine/scripts/check-lib-publish.sh +87 -0
  239. package/engine/scripts/debug-container.sh +265 -0
  240. package/engine/scripts/generate-manifest.sh +200 -0
  241. package/engine/spec.master +702 -0
  242. package/engine/spec.master.example +341 -0
  243. package/engine/topologies/README.md +33 -0
  244. package/engine/topologies/platform/docker/AGENTS.md +59 -0
  245. package/engine/topologies/platform/docker/auth/auth.star +207 -0
  246. package/engine/topologies/platform/docker/build/frontend_build_plan.star +65 -0
  247. package/engine/topologies/platform/docker/build/golden_image.star +37 -0
  248. package/engine/topologies/platform/docker/build/golden_image_build.star +144 -0
  249. package/engine/topologies/platform/docker/build/golden_image_constants.star +100 -0
  250. package/engine/topologies/platform/docker/build/golden_image_dockerfile.star +263 -0
  251. package/engine/topologies/platform/docker/compose/compose.star +637 -0
  252. package/engine/topologies/platform/docker/compose/compose_helpers.star +54 -0
  253. package/engine/topologies/platform/docker/compose/traefik_standalone.star +171 -0
  254. package/engine/topologies/platform/docker/config/bunignore.star +144 -0
  255. package/engine/topologies/platform/docker/config/dockerignore.star +152 -0
  256. package/engine/topologies/platform/docker/config/healthcheck.star +58 -0
  257. package/engine/topologies/platform/docker/constants.star +211 -0
  258. package/engine/topologies/platform/docker/dockerfile/dockerfile.star +56 -0
  259. package/engine/topologies/platform/docker/dockerfile/language_dockerfile.star +264 -0
  260. package/engine/topologies/platform/docker/generators/golden_docker_generator_v2.star +76 -0
  261. package/engine/topologies/platform/docker/index.star +40 -0
  262. package/engine/topologies/platform/docker/layers/bun_helpers.star +25 -0
  263. package/engine/topologies/platform/docker/layers/infisical/index.star +42 -0
  264. package/engine/topologies/platform/docker/layers/infisical/infisical_docker.star +264 -0
  265. package/engine/topologies/platform/docker/layers/l1_base_layers.star +89 -0
  266. package/engine/topologies/platform/docker/layers/l2_dependency_layers.star +147 -0
  267. package/engine/topologies/platform/docker/layers/l3_builder_layers.star +229 -0
  268. package/engine/topologies/platform/docker/layers/l4_runtime_layers.star +282 -0
  269. package/engine/topologies/platform/docker/layers/prisma/constants.star +138 -0
  270. package/engine/topologies/platform/docker/layers/prisma/db_readiness.star +98 -0
  271. package/engine/topologies/platform/docker/layers/prisma/filesystem_setup.star +131 -0
  272. package/engine/topologies/platform/docker/layers/prisma/migrate_script.star +100 -0
  273. package/engine/topologies/platform/docker/layers/prisma/prisma_build.star +128 -0
  274. package/engine/topologies/platform/docker/layers/prisma/prisma_runtime.star +205 -0
  275. package/engine/topologies/platform/docker/layers/prisma/secret_resolution.star +121 -0
  276. package/engine/topologies/platform/docker/networking/api_path_constants.star +206 -0
  277. package/engine/topologies/platform/docker/networking/sablier_container_cycle.star +31 -0
  278. package/engine/topologies/platform/docker/networking/traefik.star +266 -0
  279. package/engine/topologies/platform/docker/networking/traefik_constants.star +148 -0
  280. package/engine/topologies/platform/docker/networking/traefik_helpers.star +162 -0
  281. package/engine/topologies/platform/docker/networking/traefik_static_routes.star +165 -0
  282. package/engine/topologies/platform/docker/secrets/env_secrets.star +74 -0
  283. package/engine/topologies/platform/docker/secrets/infisical.star +109 -0
  284. package/engine/topologies/platform/net/AGENTS.md +64 -0
  285. package/engine/topologies/platform/net/proxy.star +6 -0
  286. package/engine/topologies/platform/registries/local.star +6 -0
  287. package/engine/topologies/platform/registries/verdaccio_loader.star +20 -0
  288. package/engine/topologies/platform/security/AGENTS.md +49 -0
  289. package/engine/topologies/platform/security/secrets.star +241 -0
  290. package/engine/topologies/platform/state/AGENTS.md +64 -0
  291. package/engine/topologies/platform/state/relational.star +6 -0
  292. package/engine/topologies/tilt/common/AGENTS.md +59 -0
  293. package/engine/topologies/tilt/common/utils.star +409 -0
  294. package/engine/topologies/tilt/common/utils_debug.star +71 -0
  295. package/engine/topologies/tilt/common/utils_deterministic.star +170 -0
  296. package/engine/topologies/tilt/common/utils_docker_networks.star +54 -0
  297. package/engine/topologies/tilt/common/utils_env.star +92 -0
  298. package/engine/topologies/tilt/common/utils_output.star +99 -0
  299. package/engine/topologies/tilt/config/AGENTS.md +68 -0
  300. package/engine/topologies/tilt/config/defaults.star +5 -0
  301. package/engine/topologies/tilt/config/feature_flags.star +12 -0
  302. package/engine/topologies/tilt/config/global.star +57 -0
  303. package/engine/topologies/tilt/config/profiles.star +398 -0
  304. package/engine/topologies/tilt/generators/agents_md.star +64 -0
  305. package/engine/topologies/tilt/generators/api_gateway.star +147 -0
  306. package/engine/topologies/tilt/generators/index.star +126 -0
  307. package/engine/topologies/tilt/generators/infisical/README.md +424 -0
  308. package/engine/topologies/tilt/generators/infisical/examples.star +314 -0
  309. package/engine/topologies/tilt/generators/infisical/index.star +59 -0
  310. package/engine/topologies/tilt/generators/infisical/machine_identity.star +422 -0
  311. package/engine/topologies/tilt/generators/infisical/organization.star +536 -0
  312. package/engine/topologies/tilt/generators/infisical/path_manager.star +478 -0
  313. package/engine/topologies/tilt/generators/infisical/secrets_generator.star +422 -0
  314. package/engine/topologies/tilt/generators/nginx_conf.star +145 -0
  315. package/engine/topologies/tilt/generators/npmrc.star +132 -0
  316. package/engine/topologies/tilt/generators/tsconfig.star +25 -0
  317. package/engine/topologies/tilt/generators/typescript/backend_library_tsconfig.star +73 -0
  318. package/engine/topologies/tilt/generators/typescript/backend_tsconfig.star +137 -0
  319. package/engine/topologies/tilt/generators/typescript/common.star +9 -0
  320. package/engine/topologies/tilt/generators/typescript/frontend_library_tsconfig.star +78 -0
  321. package/engine/topologies/tilt/generators/typescript/frontend_tsconfig.star +140 -0
  322. package/engine/topologies/tilt/generators/typescript/include.star +25 -0
  323. package/engine/topologies/tilt/generators/typescript/playwright_config.star +42 -0
  324. package/engine/topologies/tilt/generators/typescript/prisma_config.star +51 -0
  325. package/engine/topologies/tilt/generators/validators.star +868 -0
  326. package/engine/topologies/tilt/generators/vite/backend.star +80 -0
  327. package/engine/topologies/tilt/generators/vite/frameworks/lit.star +92 -0
  328. package/engine/topologies/tilt/generators/vite/frameworks/preact.star +94 -0
  329. package/engine/topologies/tilt/generators/vite/frameworks/qwik.star +94 -0
  330. package/engine/topologies/tilt/generators/vite/frameworks/react.star +128 -0
  331. package/engine/topologies/tilt/generators/vite/frameworks/solid.star +94 -0
  332. package/engine/topologies/tilt/generators/vite/frameworks/svelte.star +94 -0
  333. package/engine/topologies/tilt/generators/vite/frameworks/vanilla.star +92 -0
  334. package/engine/topologies/tilt/generators/vite/frameworks/vue.star +94 -0
  335. package/engine/topologies/tilt/generators/vite/frontend.star +153 -0
  336. package/engine/topologies/tilt/generators/vite/generators.star +45 -0
  337. package/engine/topologies/tilt/generators/vite/helpers.star +256 -0
  338. package/engine/topologies/tilt/generators/vite/library.star +67 -0
  339. package/engine/topologies/tilt/generators/vite/sdk.star +75 -0
  340. package/engine/topologies/tilt/generators/vite/templates.star +460 -0
  341. package/engine/topologies/tilt/generators/vite_config.star +24 -0
  342. package/engine/topologies/tilt/manifest/AGENTS.md +61 -0
  343. package/engine/topologies/tilt/manifest/README.md +679 -0
  344. package/engine/topologies/tilt/manifest/__init__.star +220 -0
  345. package/engine/topologies/tilt/manifest/constants.star +262 -0
  346. package/engine/topologies/tilt/manifest/errors.star +268 -0
  347. package/engine/topologies/tilt/manifest/integration.star +348 -0
  348. package/engine/topologies/tilt/manifest/json_to_yaml.py +61 -0
  349. package/engine/topologies/tilt/manifest/loader.star +239 -0
  350. package/engine/topologies/tilt/manifest/mapper.star +229 -0
  351. package/engine/topologies/tilt/manifest/parser.star +490 -0
  352. package/engine/topologies/tilt/manifest/schema.star +502 -0
  353. package/engine/topologies/tilt/manifest/tests/test_integration.star +278 -0
  354. package/engine/topologies/tilt/manifest/tests/test_loader_parser.star +475 -0
  355. package/engine/topologies/tilt/manifest/tests/test_manifest.star +319 -0
  356. package/engine/topologies/tilt/manifest/tests/test_validator.star +472 -0
  357. package/engine/topologies/tilt/manifest/validator.star +744 -0
  358. package/engine/topologies/tilt/manifest/yaml_to_json.py +20 -0
  359. package/engine/topologies/tilt/resources/AGENTS.md +71 -0
  360. package/engine/topologies/tilt/resources/build_concurrency.star +56 -0
  361. package/engine/topologies/tilt/resources/conditions.star +5 -0
  362. package/engine/topologies/tilt/resources/databases.star +246 -0
  363. package/engine/topologies/tilt/resources/declaration.star +5 -0
  364. package/engine/topologies/tilt/resources/deps.star +5 -0
  365. package/engine/topologies/tilt/resources/infra-loader.star +504 -0
  366. package/engine/topologies/tilt/resources/libs.star +32 -0
  367. package/engine/topologies/tilt/resources/libs_discovery.star +104 -0
  368. package/engine/topologies/tilt/resources/libs_paths.star +81 -0
  369. package/engine/topologies/tilt/resources/libs_resource_definition.star +153 -0
  370. package/engine/topologies/tilt/resources/libs_setup.star +166 -0
  371. package/engine/topologies/tilt/resources/libs_tsconfig.star +39 -0
  372. package/engine/topologies/tilt/resources/orchestrator/apply.star +79 -0
  373. package/engine/topologies/tilt/resources/orchestrator/apply_compose_resource_registration.star +864 -0
  374. package/engine/topologies/tilt/resources/orchestrator/apply_manifest_orchestration.star +90 -0
  375. package/engine/topologies/tilt/resources/orchestrator/apply_migrator_orchestration.star +150 -0
  376. package/engine/topologies/tilt/resources/orchestrator/apply_resource_validation.star +38 -0
  377. package/engine/topologies/tilt/resources/orchestrator/apply_runtime_flags.star +46 -0
  378. package/engine/topologies/tilt/resources/orchestrator/builders/typescript.star +193 -0
  379. package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/AGENTS.md +75 -0
  380. package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/index.star +23 -0
  381. package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/resolver.star +136 -0
  382. package/engine/topologies/tilt/resources/orchestrator/generators/env.star +219 -0
  383. package/engine/topologies/tilt/resources/orchestrator/generators/frontend.star +172 -0
  384. package/engine/topologies/tilt/resources/orchestrator/generators/manifest_resource.star +577 -0
  385. package/engine/topologies/tilt/resources/orchestrator/helpers.star +35 -0
  386. package/engine/topologies/tilt/resources/orchestrator.star +56 -0
  387. package/engine/topologies/tilt/resources/ordering.star +5 -0
  388. package/engine/topologies/tilt/resources/shared-platform-postgres.star +30 -0
  389. package/engine/topologies/tilt/resources/triggers.star +5 -0
  390. package/engine/topologies/tilt/resources/watchers.star +304 -0
  391. package/engine/where-things-live.star +719 -0
  392. package/examples/tdk-example/LICENSE +21 -0
  393. package/examples/tdk-example/README.md +23 -0
  394. package/examples/tdk-example/TILT_SERVICE_DEFAULTS.star +42 -0
  395. package/examples/tdk-example/TILT_TECH_STACK.star +67 -0
  396. package/examples/tdk-example/Tiltfile +25 -0
  397. package/examples/tdk-example/services/platform/messaging/docker-compose.yml +26 -0
  398. package/examples/tdk-example/services/shop/orders-api/package.json +20 -0
  399. package/examples/tdk-example/services/shop/orders-api/service.json +14 -0
  400. package/examples/tdk-example/services/shop/orders-api/src/index.ts +81 -0
  401. package/examples/tdk-example/services/shop/orders-app/index.html +12 -0
  402. package/examples/tdk-example/services/shop/orders-app/package.json +23 -0
  403. package/examples/tdk-example/services/shop/orders-app/public/.gitkeep +0 -0
  404. package/examples/tdk-example/services/shop/orders-app/service.json +9 -0
  405. package/examples/tdk-example/services/shop/orders-app/src/main.tsx +9 -0
  406. package/examples/tdk-example/services/shop/orders-app/src/orders.tsx +67 -0
  407. package/examples/tdk-example/services/shop/orders-app/src/style.css +15 -0
  408. package/examples/tdk-example/services/shop/orders-worker/package.json +18 -0
  409. package/examples/tdk-example/services/shop/orders-worker/service.json +13 -0
  410. package/examples/tdk-example/services/shop/orders-worker/src/index.ts +33 -0
  411. package/ext/Tiltfile +66 -0
  412. package/ext/ide-components/README.md +221 -0
  413. package/ext/ide-components/code_viewer/server.py +208 -0
  414. package/ext/ide-components/config_inspector/server.py +1052 -0
  415. package/ext/ide-components/file_browser/server.py +287 -0
  416. package/ext/ide-components/shared/config_service.py +471 -0
  417. package/ext/ide-components/shared/file_utils.py +300 -0
  418. package/ext/ide-components/shared/http_utils.py +234 -0
  419. package/ext/ide-components/shared/static/styles.css +1334 -0
  420. package/ext/ide-components/shared/syntax_highlighter.py +142 -0
  421. package/ext/ide-components/shared/template_engine.py +125 -0
  422. package/ext/ide-components/shared/templates/base.html +121 -0
  423. package/ext/ide-components/shared/test_config_service.py +328 -0
  424. package/ext/ide-components/shared/tilt_integration.py +160 -0
  425. package/ext/ui-enhancements/cron-status-server.sh +51 -0
  426. package/ext/ui-enhancements/cron-status-tracker.sh +148 -0
  427. package/ext/ui-enhancements/extension.yaml +36 -0
  428. package/ext/ui-enhancements/tiltfile.py +101 -0
  429. package/ext/ui-enhancements/ui/cron-jobs-tab.css +396 -0
  430. package/ext/ui-enhancements/ui/help-panel.css +279 -0
  431. package/ext/ui-enhancements/ui/icons.css +125 -0
  432. package/ext/ui-enhancements/ui/tooltips.css +114 -0
  433. package/package.json +94 -4
  434. package/shared-platform-engineering/docker-templates/bun-hoisted-symlink-fix.sh +25 -0
  435. package/shared-platform-engineering/docker-templates/infisical-entrypoint.sh +466 -0
  436. package/shared-platform-engineering/docker-templates/install-deps.sh +154 -0
  437. package/shared-platform-engineering/docker-templates/prisma-bun-client-link-fix.sh +14 -0
  438. package/shared-platform-engineering/docker-templates/prisma-normalize-client.sh +58 -0
  439. package/specs/specs/TILT_SERVICE_DEFAULTS.star +207 -0
  440. package/specs/specs/TILT_TECH_STACK.star +161 -0
@@ -0,0 +1,86 @@
1
+ # =============================================================================
2
+ # 🎯 FLISK-ENGINE - Core Execution Engine
3
+ # =============================================================================
4
+ # This is the Tiltfile entry point for the tdk-engine repo.
5
+ # It exports core orchestration, resource builders, and topology management.
6
+ #
7
+ # Usage:
8
+ # v1alpha1.extension_repo(name='tdk-engine', url='https://github.com/tdk-landscape/tdk-engine')
9
+ # load('ext://tdk-engine', 'Utils', 'Manifest', 'Config', ...)
10
+ # =============================================================================
11
+
12
+ # Core
13
+ load('./topologies/tilt/common/utils.star', _Utils='Utils')
14
+ load('./topologies/tilt/discovery/loading.star', _Manifest='Manifest')
15
+ load('./topologies/tilt/config/global.star', _Config='Config')
16
+ load('./topologies/platform/docker/build/frontend_build_plan.star', _frontend_build_plan='frontend_build_plan')
17
+
18
+ # Registry
19
+ load('./topologies/tilt/discovery/registry.star',
20
+ _GLOBAL_CONFIG_EXPORT='GLOBAL_CONFIG_EXPORT',
21
+ _APP_RESOURCES='APP_RESOURCES',
22
+ _INFRA_RESOURCES_EXPORT='INFRA_RESOURCES_EXPORT',
23
+ _DDD_LIBS_EXPORT='DDD_LIBS_EXPORT',
24
+ _DEFAULTS_EXPORT='DEFAULTS_EXPORT',
25
+ _RESOURCE_ALIASES='RESOURCE_ALIASES',
26
+ _RESOURCE_PATH_MAP='RESOURCE_PATH_MAP',
27
+ _get_platform_libs_export='get_platform_libs_export',
28
+ _get_product_libs_export='get_product_libs_export',
29
+ )
30
+
31
+ # Providers
32
+ load('./topologies/tilt/generators/vite_config.star', _Vite='Vite')
33
+ load('./topologies/tilt/generators/tsconfig.star', _TSConfig='TSConfig')
34
+ load('./topologies/platform/docker/index.star', _Docker='Docker')
35
+ load('./topologies/tilt/generators/npmrc.star', _PackageConfig='PackageConfig')
36
+
37
+ # Lifecycle
38
+ load('./topologies/tilt/resources/deps.star', _Libs='Libs')
39
+ load('./topologies/tilt/resources/conditions.star', _Database='Database')
40
+ load('./topologies/tilt/resources/declaration.star', _Orchestrator='Orchestrator')
41
+ load('./topologies/tilt/resources/ordering.star', _Infra='Infra')
42
+ load('./topologies/tilt/resources/triggers.star', _Watchers='Watchers')
43
+ load('./topologies/tilt/resources/orchestrator/apply_compose_resource_registration.star', _resource_defers_start='resource_defers_start')
44
+
45
+ # =============================================================================
46
+ # RE-EXPORTS
47
+ # =============================================================================
48
+
49
+ # Core
50
+ Utils = _Utils
51
+ Manifest = _Manifest
52
+ Config = _Config
53
+ FrontendBuildPlan = _frontend_build_plan
54
+
55
+ # Registry Data
56
+ GLOBAL_CONFIG_EXPORT = _GLOBAL_CONFIG_EXPORT
57
+ APP_RESOURCES = _APP_RESOURCES
58
+ INFRA_RESOURCES_EXPORT = _INFRA_RESOURCES_EXPORT
59
+ DDD_LIBS_EXPORT = _DDD_LIBS_EXPORT
60
+ DEFAULTS_EXPORT = _DEFAULTS_EXPORT
61
+ RESOURCE_ALIASES = _RESOURCE_ALIASES
62
+ RESOURCE_PATH_MAP = _RESOURCE_PATH_MAP
63
+
64
+ def get_platform_libs_export():
65
+ return _get_platform_libs_export()
66
+
67
+ def get_product_libs_export():
68
+ return _get_product_libs_export()
69
+
70
+ # Providers
71
+ Vite = _Vite
72
+ TSConfig = _TSConfig
73
+ Docker = _Docker
74
+ PackageConfig = _PackageConfig
75
+
76
+ # Lifecycle
77
+ Libs = _Libs
78
+ Database = _Database
79
+ Orchestrator = _Orchestrator
80
+ Infra = _Infra
81
+ Watchers = _Watchers
82
+
83
+ # True when a manifest's deferStart is actually active (licensed); decides whether a `<name>-image` prebuild resource exists.
84
+ resource_defers_start = _resource_defers_start
85
+
86
+ print("✅ Flisk Engine loaded: orchestration, resources, and lifecycle")
@@ -0,0 +1,204 @@
1
+ ###############################################################################
2
+ # 🛑 CRITICAL: SYSTEM-GENERATED FILE - DO NOT MODIFY DIRECTLY
3
+ #
4
+ # ANY MANUAL CHANGES MADE TO THIS FILE WILL BE WIPED ON THE NEXT 'tilt up'.
5
+ # TO MODIFY THIS CONFIGURATION:
6
+ # 1. Edit the source generator in: .tilt/topologies/
7
+ # 2. Or update service.json
8
+ #
9
+ # Generation Source: GoldenImage.generate_layered_dockerfile()
10
+ # Service: tdk-project-l1-l4
11
+ # Type: GOLDEN LAYERED IMAGES | L1-L4 Pre-built Layers
12
+ ###############################################################################
13
+
14
+ # =============================================================================
15
+ # 🏗️ GOLDEN LAYERED IMAGES - Multi-Stage Base Images
16
+ # =============================================================================
17
+ # This Dockerfile builds 8 golden images:
18
+ # - tdk-project-l1:latest - OS base + Bun runtime
19
+ # - tdk-project-l2:latest - Dependencies installed
20
+ # - tdk-project-l3-backend:latest - Backend and migrator build tools (Prisma, no Infisical CLI)
21
+ # - tdk-project-l3-frontend:latest - Frontend build tools (no Prisma)
22
+ # - tdk-project-l4-backend:latest - Backend production runtime (Bun)
23
+ # - tdk-project-l4-backend-node:latest - Backend production runtime (Node.js)
24
+ # - tdk-project-l4-frontend:latest - Frontend production runtime (Nginx)
25
+ # - tdk-project-l4-migrator:latest - Migrator production runtime
26
+ #
27
+ # Migrators build on l3-backend: a separate l3-migrator stage installed the same Prisma
28
+ # and produced identical layers under a second image name.
29
+ #
30
+ # Services use these as base images to skip heavy dependency installation.
31
+ #
32
+ # ⚠️ SKIP_INFISICAL_SETUP Support:
33
+ # All generated Dockerfiles support --build-arg SKIP_INFISICAL_SETUP=1
34
+ # to bypass Infisical CLI installation (avoids Cloudsmith CDN hangs).
35
+ # When SKIP_INFISICAL_SETUP=1, secrets are read from env vars only.
36
+ # See: .tilt/topologies/platform/docker/layers/l3_builder_layers.star
37
+ # =============================================================================
38
+
39
+ # =============================================================================
40
+ # L1: OS BASE + RUNTIME ENVIRONMENT
41
+ # =============================================================================
42
+ FROM oven/bun:1.3.11-alpine@sha256:7ed9f74c326d1c260abe247ac423ccbf5ac92af62bb442d515d1f92f21e8ea9b AS l1_golden
43
+
44
+ LABEL layer="l1" description="OS base with runtime environment" maintainer="tdk-project"
45
+
46
+ # System dependencies for all services
47
+ RUN apk add --no-cache ca-certificates tzdata curl file bash openssl
48
+
49
+ # Create app user/group for security
50
+ RUN addgroup -S app && adduser -S app -G app
51
+
52
+ # Runtime environment
53
+ ENV NODE_ENV=development BUN_INSTALL_CACHE_DIR=/cache/bun
54
+
55
+ WORKDIR /app
56
+
57
+
58
+ # =============================================================================
59
+ # L2: DEPENDENCY RESOLVER
60
+ # =============================================================================
61
+ FROM l1_golden AS l2_golden
62
+
63
+ LABEL layer="l2" description="Base with common dependencies installed" maintainer="tdk-project"
64
+
65
+ # Install minimal debugging tools (removed: vim, python3, make, g++ = -67MB)
66
+ RUN apk add --no-cache curl netcat-openbsd jq bind-tools
67
+
68
+ # Pre-create cache directories
69
+ RUN mkdir -p /cache/bun /cache/prisma
70
+
71
+ # Bun is already installed in base image
72
+ RUN echo "Bun version: $(bun --version)"
73
+
74
+
75
+ # =============================================================================
76
+ # L3-BACKEND: BACKEND BUILD TOOLS (PRISMA)
77
+ # =============================================================================
78
+ FROM l2_golden AS l3_backend_golden
79
+
80
+ LABEL layer="l3-backend" description="Backend build tools with Prisma" maintainer="tdk-project"
81
+
82
+ # Install Prisma CLI globally (pinned for deterministic builds)
83
+ RUN bun add -g prisma@7.5.0 @prisma/client@7.5.0
84
+
85
+ # Verify Prisma installation
86
+ RUN echo "Prisma version: $(bunx prisma --version | head -1)"
87
+
88
+ # ⚠️ CRITICAL: Infisical CLI is NOT installed in golden L3 images
89
+ # Reason: curl to dl.cloudsmith.io hangs during Docker builds when CDN is slow
90
+ # Solution: Use SKIP_INFISICAL_SETUP=1 build arg or runtime env var injection
91
+ # Services read secrets from environment variables at runtime (no CLI needed)
92
+ # See: .tilt/topologies/platform/docker/layers/l3_builder_layers.star
93
+
94
+
95
+ # =============================================================================
96
+ # L3-FRONTEND: FRONTEND BUILD TOOLS (NO PRISMA)
97
+ # =============================================================================
98
+ FROM l2_golden AS l3_frontend_golden
99
+
100
+ LABEL layer="l3-frontend" description="Frontend build tools without Prisma" maintainer="tdk-project"
101
+
102
+ # Frontend doesn't need Prisma, just verify Bun
103
+ RUN echo "Bun version: $(bun --version)"
104
+
105
+
106
+ # =============================================================================
107
+ # L4-BACKEND-BUN: BACKEND PRODUCTION RUNTIME (BUN)
108
+ # =============================================================================
109
+ FROM l1_golden AS l4_backend_bun
110
+
111
+ LABEL layer="l4-backend-bun" description="Backend production runtime (Bun)" maintainer="tdk-project"
112
+
113
+ ENV NODE_ENV=production
114
+
115
+ # Install hugo for services that require static site generation (specified via manifest features)
116
+ RUN apk add --no-cache hugo
117
+
118
+ # ⚠️ Infisical CLI is NOT installed in golden L4 images
119
+ # Services use TypeScript SDK (fetch API) or read from env vars - no CLI needed
120
+ # The entrypoint.sh gracefully handles missing CLI (falls back to env vars)
121
+ # Build with --build-arg SKIP_INFISICAL_SETUP=1 to skip CLI installation
122
+
123
+ USER bun
124
+
125
+ # Backend-specific healthcheck (checks Bun runtime)
126
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD bun --version || exit 1
127
+
128
+ WORKDIR /app
129
+
130
+
131
+ # =============================================================================
132
+ # L4-BACKEND-NODE: BACKEND PRODUCTION RUNTIME (NODE.JS - LIGHTWEIGHT!)
133
+ # =============================================================================
134
+ FROM node:22-alpine@sha256:0a7108bf6c7bf5de370ffb1a3ed6be93d405b43ff159f681a8d18c0e2bc2e402 AS l4_backend_node
135
+
136
+ LABEL layer="l4-backend-node" description="Backend production runtime (Node.js - lightweight)" maintainer="tdk-project"
137
+
138
+ ENV NODE_ENV=production
139
+
140
+ # Minimal runtime dependencies
141
+ RUN apk add --no-cache ca-certificates tzdata curl
142
+
143
+ # Create app user for security
144
+ RUN addgroup -S app && adduser -S app -G app
145
+
146
+ # ⚠️ Infisical CLI is NOT installed in golden L4 images
147
+ # Services read secrets from environment variables at runtime
148
+
149
+ USER app
150
+
151
+ # Backend-specific healthcheck (checks Node.js runtime)
152
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD node --version || exit 1
153
+
154
+ WORKDIR /app
155
+
156
+
157
+ # Alias for backwards compatibility - defaults to Bun (most efficient)
158
+ FROM l4_backend_bun AS l4_backend_golden
159
+
160
+
161
+ # =============================================================================
162
+ # L4-FRONTEND: FRONTEND PRODUCTION RUNTIME
163
+ # =============================================================================
164
+ FROM nginx:1.27-alpine@sha256:65645c7bb6a0661892a8b03b89d0743208a18dd2f3f17a54ef4b76fb8e2f2a10 AS l4_frontend_golden
165
+
166
+ LABEL layer="l4-frontend" description="Frontend production runtime with Nginx" maintainer="tdk-project"
167
+
168
+ ENV NODE_ENV=production
169
+
170
+ # Install curl for healthchecks
171
+ RUN apk add --no-cache curl
172
+
173
+ # Frontend-specific healthcheck (checks Nginx)
174
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 CMD curl -f http://localhost/ || exit 1
175
+
176
+ WORKDIR /usr/share/nginx/html
177
+
178
+
179
+ # =============================================================================
180
+ # L4-MIGRATOR: MIGRATOR PRODUCTION RUNTIME
181
+ # =============================================================================
182
+ FROM l1_golden AS l4_migrator_golden
183
+
184
+ LABEL layer="l4-migrator" description="Migrator runtime with Prisma" maintainer="tdk-project"
185
+
186
+ ENV NODE_ENV=production
187
+
188
+ # Copy global Prisma installation from L3 (l3-backend carries the same pinned Prisma)
189
+ COPY --from=l3_backend_golden /root/.bun/install/global /root/.bun/install/global
190
+
191
+ # ⚠️ Infisical CLI is NOT included in golden L4 images
192
+ # The migrator reads secrets directly from environment variables at runtime
193
+ # (no entrypoint wrapper needed for database migrations)
194
+ # Use --build-arg SKIP_INFISICAL_SETUP=1 to skip CLI installation in derived images
195
+
196
+ # Ensure Bun cache path is writable for non-root runtime healthcheck commands.
197
+ RUN mkdir -p /cache/bun && chown -R bun:bun /cache/bun
198
+
199
+ USER bun
200
+
201
+ # Migrator-specific healthcheck (checks Prisma CLI)
202
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD bunx prisma --version || exit 1
203
+
204
+ WORKDIR /app
@@ -0,0 +1,28 @@
1
+ # Wake gateway (see openspec/changes/prioritized-cold-start): fronts every
2
+ # `sablier.deferStart` resource's Traefik static route, triggers cold
3
+ # containers via `tilt trigger` and/or Sablier, then holds the request until
4
+ # healthy. Needs the Docker CLI plus its Compose plugin (client only, talks
5
+ # to the mounted /var/run/docker.sock; compose starts an already-built image
6
+ # directly, ahead of Tilt's build queue) and the real `tilt` CLI (D3: shells out to the
7
+ # documented `tilt trigger` command rather than depending on Tilt's
8
+ # undocumented internal HTTP API).
9
+
10
+ FROM oven/bun:1.3.11-alpine@sha256:7ed9f74c326d1c260abe247ac423ccbf5ac92af62bb442d515d1f92f21e8ea9b AS base
11
+
12
+ # Pin to the same Tilt version this workspace runs (v0.37.7) so `tilt trigger`
13
+ # talks the same protocol as the real daemon it's connecting to. Installed
14
+ # directly (not via tilt-dev's install.sh, which shells out to `sudo` -- not
15
+ # present in this minimal image, and unnecessary since we're already root).
16
+ ARG TILT_VERSION=0.37.7
17
+ RUN apk add --no-cache docker-cli docker-cli-compose curl gcompat \
18
+ && arch="$(uname -m)" \
19
+ && case "$arch" in aarch64) tilt_arch=arm64 ;; x86_64) tilt_arch=x86_64 ;; *) echo "unsupported arch: $arch" >&2; exit 1 ;; esac \
20
+ && curl -fsSL "https://github.com/tilt-dev/tilt/releases/download/v${TILT_VERSION}/tilt.${TILT_VERSION}.linux.${tilt_arch}.tar.gz" \
21
+ | tar -xz -C /usr/local/bin tilt
22
+
23
+ WORKDIR /app
24
+ COPY decide.ts server.ts ./
25
+
26
+ EXPOSE 9999
27
+ HEALTHCHECK --interval=10s --timeout=3s --start-period=10s --retries=3 CMD curl --fail --silent http://127.0.0.1:${PORT:-9999}/health || exit 1
28
+ CMD ["bun", "run", "server.ts"]
@@ -0,0 +1,177 @@
1
+ // Copyright (c) 2026 Flisk Landscape contributors
2
+ // SPDX-License-Identifier: MIT
3
+ import { describe, expect, test } from "bun:test";
4
+ import {
5
+ COMPOSE_START_TIMEOUT_MS,
6
+ EARLY_RESPONSE_MS,
7
+ MAX_EARLY_RESPONSE_MS,
8
+ RETRY_AFTER_SECONDS,
9
+ TILT_TRIGGER_TIMEOUT_MS,
10
+ decideWakeAction,
11
+ earlyResponseMs,
12
+ evaluateReadiness,
13
+ isGatewayLivenessProbe,
14
+ wakeTimeoutMs,
15
+ } from "./decide";
16
+
17
+ describe("decideWakeAction", () => {
18
+ test("never-created resource: tilt trigger only, no Sablier start", () => {
19
+ const action = decideWakeAction({
20
+ resourceContainerName: "data-governance-api",
21
+ resourceState: "absent",
22
+ dependencies: [],
23
+ });
24
+ expect(action.tiltTriggerNames).toEqual(["data-governance-api"]);
25
+ expect(action.useSablierStart).toBe(false);
26
+ });
27
+
28
+ test("previously-run, now-exited resource: both tilt trigger and Sablier start", () => {
29
+ const action = decideWakeAction({
30
+ resourceContainerName: "data-governance-api",
31
+ resourceState: "exited",
32
+ dependencies: [],
33
+ });
34
+ expect(action.tiltTriggerNames).toEqual(["data-governance-api"]);
35
+ expect(action.useSablierStart).toBe(true);
36
+ });
37
+
38
+ test("created-but-not-started resource: both paths apply", () => {
39
+ const action = decideWakeAction({
40
+ resourceContainerName: "data-governance-api",
41
+ resourceState: "created",
42
+ dependencies: [],
43
+ });
44
+ expect(action.useSablierStart).toBe(true);
45
+ });
46
+
47
+ test("already running: no trigger needed", () => {
48
+ const action = decideWakeAction({
49
+ resourceContainerName: "data-governance-api",
50
+ resourceState: "running",
51
+ dependencies: [],
52
+ });
53
+ expect(action.tiltTriggerNames).toEqual([]);
54
+ expect(action.useSablierStart).toBe(false);
55
+ });
56
+
57
+ test("cold dependency is triggered alongside the resource (task 1.5 finding)", () => {
58
+ const action = decideWakeAction({
59
+ resourceContainerName: "data-governance-api",
60
+ resourceState: "absent",
61
+ dependencies: [
62
+ { name: "postgres", state: "running" },
63
+ { name: "data-governance-api-db-migrator", state: "absent" },
64
+ ],
65
+ });
66
+ expect(action.tiltTriggerNames).toEqual([
67
+ "data-governance-api",
68
+ "data-governance-api-db-migrator",
69
+ ]);
70
+ });
71
+
72
+ test("never-created resource with compose details: started directly, not queued in Tilt", () => {
73
+ const action = decideWakeAction({
74
+ resourceContainerName: "data-governance-api",
75
+ resourceState: "absent",
76
+ dependencies: [{ name: "peer-api", state: "absent" }],
77
+ hasComposeInvocation: true,
78
+ });
79
+ expect(action.useComposeStart).toBe(true);
80
+ // Dependencies carry no compose details, so they still go through Tilt.
81
+ expect(action.tiltTriggerNames).toEqual(["peer-api"]);
82
+ expect(action.useSablierStart).toBe(false);
83
+ });
84
+
85
+ test("existing (exited) container keeps the Sablier path even with compose details", () => {
86
+ const action = decideWakeAction({
87
+ resourceContainerName: "data-governance-api",
88
+ resourceState: "exited",
89
+ dependencies: [],
90
+ hasComposeInvocation: true,
91
+ });
92
+ expect(action.useComposeStart).toBe(false);
93
+ expect(action.tiltTriggerNames).toEqual(["data-governance-api"]);
94
+ expect(action.useSablierStart).toBe(true);
95
+ });
96
+
97
+ test("running dependency is not re-triggered", () => {
98
+ const action = decideWakeAction({
99
+ resourceContainerName: "data-governance-api",
100
+ resourceState: "running",
101
+ dependencies: [{ name: "postgres", state: "running" }],
102
+ });
103
+ expect(action.tiltTriggerNames).toEqual([]);
104
+ });
105
+ });
106
+
107
+ describe("wakeTimeoutMs", () => {
108
+ test("a direct compose start only waits for boot + healthcheck", () => {
109
+ expect(wakeTimeoutMs(true)).toBe(COMPOSE_START_TIMEOUT_MS);
110
+ });
111
+
112
+ test("the tilt trigger path allows for an image build, under Bun's 255s idle cap", () => {
113
+ expect(wakeTimeoutMs(false)).toBe(TILT_TRIGGER_TIMEOUT_MS);
114
+ expect(TILT_TRIGGER_TIMEOUT_MS).toBeLessThan(255_000);
115
+ });
116
+
117
+ test("an explicit X-Wake-Timeout-Ms wins", () => {
118
+ expect(wakeTimeoutMs(false, 5_000)).toBe(5_000);
119
+ });
120
+ });
121
+
122
+ describe("earlyResponseMs", () => {
123
+ test("holds a waking request for EARLY_RESPONSE_MS by default", () => {
124
+ expect(earlyResponseMs()).toBe(EARLY_RESPONSE_MS);
125
+ });
126
+
127
+ test("the default answers well before Bun's 255s idle cap drops the connection", () => {
128
+ expect(EARLY_RESPONSE_MS).toBeLessThan(255_000);
129
+ });
130
+
131
+ test("an explicit X-Wake-Respond-Within-Ms wins, but is capped under Bun's idle limit", () => {
132
+ expect(earlyResponseMs(5_000)).toBe(5_000);
133
+ expect(earlyResponseMs(600_000)).toBe(MAX_EARLY_RESPONSE_MS);
134
+ expect(MAX_EARLY_RESPONSE_MS).toBeLessThan(255_000);
135
+ });
136
+
137
+ test("tells the caller to retry soon", () => {
138
+ expect(RETRY_AFTER_SECONDS).toBeGreaterThan(0);
139
+ expect(RETRY_AFTER_SECONDS * 1000).toBeLessThan(EARLY_RESPONSE_MS);
140
+ });
141
+ });
142
+
143
+ describe("evaluateReadiness", () => {
144
+ test("ready once every required name reports healthy", () => {
145
+ const outcome = evaluateReadiness(["a", "b"], { a: true, b: true });
146
+ expect(outcome.ready).toBe(true);
147
+ expect(outcome.pending).toEqual([]);
148
+ });
149
+
150
+ test("not ready while some names are still unhealthy", () => {
151
+ const outcome = evaluateReadiness(["a", "b"], { a: true, b: false });
152
+ expect(outcome.ready).toBe(false);
153
+ expect(outcome.pending).toEqual(["b"]);
154
+ });
155
+
156
+ test("missing entries count as not healthy", () => {
157
+ const outcome = evaluateReadiness(["a", "b"], { a: true });
158
+ expect(outcome.ready).toBe(false);
159
+ expect(outcome.pending).toEqual(["b"]);
160
+ });
161
+ });
162
+
163
+ describe("isGatewayLivenessProbe", () => {
164
+ test("a bare GET /health from the image HEALTHCHECK is answered by the gateway", () => {
165
+ expect(isGatewayLivenessProbe("GET", "/health", new Headers())).toBe(true);
166
+ });
167
+
168
+ test("a backend /health routed through the wake gateway is proxied, not answered", () => {
169
+ const routed = new Headers({ "X-Wake-Resource": "cold-api", "X-Wake-Container": "cold-api-1" });
170
+ expect(isGatewayLivenessProbe("GET", "/health", routed)).toBe(false);
171
+ });
172
+
173
+ test("other methods and paths are not liveness probes", () => {
174
+ expect(isGatewayLivenessProbe("POST", "/health", new Headers())).toBe(false);
175
+ expect(isGatewayLivenessProbe("GET", "/health/ready", new Headers())).toBe(false);
176
+ });
177
+ });
@@ -0,0 +1,135 @@
1
+ // Copyright (c) 2026 Flisk contributors
2
+ // SPDX-License-Identifier: MIT
3
+ /**
4
+ * Pure decision logic for the wake gateway (see openspec/changes/prioritized-cold-start).
5
+ *
6
+ * The gateway sits behind a Traefik static (file-provider) route for every
7
+ * `sablier: {enable: true, deferStart: true}` resource. This module decides
8
+ * what to *do* given a snapshot of container state; the actual Docker/Tilt
9
+ * I/O and the healthcheck-polling loop live in server.ts, which is a thin
10
+ * wrapper around this so the decision itself stays testable without a live
11
+ * Docker daemon or Tilt instance.
12
+ */
13
+
14
+ export type ContainerState = "absent" | "created" | "running" | "exited";
15
+
16
+ export interface DependencySnapshot {
17
+ name: string;
18
+ state: ContainerState;
19
+ }
20
+
21
+ export interface WakeRequestSnapshot {
22
+ resourceContainerName: string;
23
+ resourceState: ContainerState;
24
+ dependencies: DependencySnapshot[];
25
+ /**
26
+ * Whether the route carried enough compose detail (project, files, image)
27
+ * for the gateway to create the resource's container itself.
28
+ */
29
+ hasComposeInvocation?: boolean;
30
+ }
31
+
32
+ export interface WakeAction {
33
+ /** Resources to `tilt trigger` (task 1.5: Tilt never cascades this on its own). */
34
+ tiltTriggerNames: string[];
35
+ /**
36
+ * Whether to create/start the resource's container directly with
37
+ * `docker compose up --no-build` instead of `tilt trigger`. `tilt trigger`
38
+ * only queues the resource: with Tilt's build slots busy (e.g. 100+
39
+ * resources rebuilding after a re-vendor), a triggered resource waited
40
+ * behind them and the request timed out (observed live against
41
+ * tdk-erp-system, see tasks.md 7.2). server.ts falls back to `tilt trigger`
42
+ * when no image exists yet to start from.
43
+ */
44
+ useComposeStart: boolean;
45
+ /**
46
+ * Whether to also try Sablier's own Docker-level start for the resource.
47
+ * Only meaningful when the resource's container already exists (D2/D3):
48
+ * Sablier has nothing to manage for a container that was never created.
49
+ */
50
+ useSablierStart: boolean;
51
+ }
52
+
53
+ /**
54
+ * Decide which resources need `tilt trigger` and whether Sablier's Docker-level
55
+ * start also applies, given one point-in-time snapshot (D2/D3/D5).
56
+ */
57
+ export function decideWakeAction(snapshot: WakeRequestSnapshot): WakeAction {
58
+ const tiltTriggerNames: string[] = [];
59
+ const useComposeStart = snapshot.resourceState === "absent" && snapshot.hasComposeInvocation === true;
60
+
61
+ if (snapshot.resourceState !== "running" && !useComposeStart) {
62
+ tiltTriggerNames.push(snapshot.resourceContainerName);
63
+ }
64
+ for (const dep of snapshot.dependencies) {
65
+ if (dep.state !== "running") {
66
+ tiltTriggerNames.push(dep.name);
67
+ }
68
+ }
69
+
70
+ const useSablierStart = snapshot.resourceState === "exited" || snapshot.resourceState === "created";
71
+
72
+ return { tiltTriggerNames, useComposeStart, useSablierStart };
73
+ }
74
+
75
+ /** Wait budget when the gateway starts an existing image itself (boot + healthcheck only). */
76
+ export const COMPOSE_START_TIMEOUT_MS = 180_000;
77
+ /**
78
+ * Wait budget when the resource has to go through `tilt trigger` (image build
79
+ * included). Kept under Bun.serve's 255s idleTimeout cap in server.ts.
80
+ */
81
+ export const TILT_TRIGGER_TIMEOUT_MS = 240_000;
82
+
83
+ /** The wait budget for a wake: an explicit X-Wake-Timeout-Ms wins, else by start path. */
84
+ export function wakeTimeoutMs(startedViaCompose: boolean, overrideMs?: number): number {
85
+ if (overrideMs && overrideMs > 0) return overrideMs;
86
+ return startedViaCompose ? COMPOSE_START_TIMEOUT_MS : TILT_TRIGGER_TIMEOUT_MS;
87
+ }
88
+
89
+ /**
90
+ * How long a waking request is held before the gateway answers
91
+ * `503` + `Retry-After` while the start keeps going in the background.
92
+ * Found live (task 7.2): during a full `flisk up` bring-up the Docker daemon
93
+ * took ~5 min to start one container, and Bun.serve's 255s idle cap dropped
94
+ * the held connection with no response at all.
95
+ */
96
+ export const EARLY_RESPONSE_MS = 60_000;
97
+ /** Largest hold allowed: stays under Bun.serve's 255s idle cap. */
98
+ export const MAX_EARLY_RESPONSE_MS = 240_000;
99
+ /** The `Retry-After` value sent with the early 503. */
100
+ export const RETRY_AFTER_SECONDS = 10;
101
+
102
+ /** How long to hold a request: an explicit X-Wake-Respond-Within-Ms wins, capped under Bun's idle limit. */
103
+ export function earlyResponseMs(overrideMs?: number): number {
104
+ if (overrideMs && overrideMs > 0) return Math.min(overrideMs, MAX_EARLY_RESPONSE_MS);
105
+ return EARLY_RESPONSE_MS;
106
+ }
107
+
108
+ export interface WaitOutcome {
109
+ ready: boolean;
110
+ /** Names still not running/healthy when the wait ended (empty when ready). */
111
+ pending: string[];
112
+ }
113
+
114
+ /**
115
+ * Decide whether a set of health polls (resource + dependencies) means the
116
+ * request can be let through yet, or should keep waiting / time out.
117
+ * `healthy` maps each name from a WakeAction's tiltTriggerNames (plus the
118
+ * resource itself) to its latest observed health state.
119
+ */
120
+ export function evaluateReadiness(
121
+ requiredNames: string[],
122
+ healthy: Record<string, boolean>,
123
+ ): WaitOutcome {
124
+ const pending = requiredNames.filter((name) => !healthy[name]);
125
+ return { ready: pending.length === 0, pending };
126
+ }
127
+
128
+ /**
129
+ * True for the gateway's own liveness probe (the image HEALTHCHECK's `GET /health`). Traefik's static route
130
+ * forwards every backend request here with its X-Wake-* headers and the backend's prefix stripped, so a
131
+ * backend's `/health` arrives as `/health` too; those must be proxied, not answered by the gateway.
132
+ */
133
+ export function isGatewayLivenessProbe(method: string, pathname: string, headers: Headers): boolean {
134
+ return method === "GET" && pathname === "/health" && !headers.has("X-Wake-Resource");
135
+ }