@leitwerk-dev/server 0.3.1 → 0.4.1

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 (327) hide show
  1. package/dist/{app-BuJCdkvy.d.ts → app-CtlotzYm.d.ts} +312 -121
  2. package/dist/app-KR3N2JAE.js +8 -0
  3. package/dist/app.d.ts +9 -0
  4. package/dist/app.d.ts.map +1 -1
  5. package/dist/auth/fastify-auth.d.ts +9 -0
  6. package/dist/auth/fastify-auth.d.ts.map +1 -1
  7. package/dist/{chunk-QCHS3X33.js → chunk-OUA5EZS2.js} +3127 -689
  8. package/dist/chunk-OUA5EZS2.js.map +1 -0
  9. package/dist/{chunk-HK6BLLHA.js → chunk-YLWY4UTT.js} +2424 -1580
  10. package/dist/chunk-YLWY4UTT.js.map +1 -0
  11. package/dist/config/config-loader.d.ts +1 -1
  12. package/dist/config/config-loader.d.ts.map +1 -1
  13. package/dist/config/config-types.d.ts +16 -1
  14. package/dist/config/config-types.d.ts.map +1 -1
  15. package/dist/config/kubernetes-docker-isolation.d.ts +7 -0
  16. package/dist/config/kubernetes-docker-isolation.d.ts.map +1 -0
  17. package/dist/dashboard-model-issues.d.ts +10 -0
  18. package/dist/dashboard-model-issues.d.ts.map +1 -0
  19. package/dist/db/database.d.ts.map +1 -1
  20. package/dist/db/execution-inspection-repo.d.ts +15 -0
  21. package/dist/db/execution-inspection-repo.d.ts.map +1 -0
  22. package/dist/db/history-window.d.ts +11 -0
  23. package/dist/db/history-window.d.ts.map +1 -0
  24. package/dist/db/process-event-repo.d.ts +2 -0
  25. package/dist/db/process-event-repo.d.ts.map +1 -1
  26. package/dist/db/process-instance-repo.d.ts +21 -1
  27. package/dist/db/process-instance-repo.d.ts.map +1 -1
  28. package/dist/db/process-leaf-outcome-snapshot-repo.d.ts +2 -1
  29. package/dist/db/process-leaf-outcome-snapshot-repo.d.ts.map +1 -1
  30. package/dist/db/process-project-repo.d.ts +2 -0
  31. package/dist/db/process-project-repo.d.ts.map +1 -1
  32. package/dist/db/process-skill-repo.d.ts.map +1 -1
  33. package/dist/db/process-turn-annotation-repo.d.ts +4 -1
  34. package/dist/db/process-turn-annotation-repo.d.ts.map +1 -1
  35. package/dist/db/process-turn-record-repo.d.ts +4 -0
  36. package/dist/db/process-turn-record-repo.d.ts.map +1 -1
  37. package/dist/db/publication-repo.d.ts +5 -0
  38. package/dist/db/publication-repo.d.ts.map +1 -0
  39. package/dist/db/repositories.d.ts +12 -0
  40. package/dist/db/repositories.d.ts.map +1 -1
  41. package/dist/db/schema.d.ts +693 -2
  42. package/dist/db/schema.d.ts.map +1 -1
  43. package/dist/db/scoped-settings-repo.d.ts +37 -0
  44. package/dist/db/scoped-settings-repo.d.ts.map +1 -0
  45. package/dist/db/skill-repo.d.ts +3 -0
  46. package/dist/db/skill-repo.d.ts.map +1 -1
  47. package/dist/db/turn-start-record-repo.d.ts +2 -1
  48. package/dist/db/turn-start-record-repo.d.ts.map +1 -1
  49. package/dist/db/turn-summary-repo.d.ts +10 -1
  50. package/dist/db/turn-summary-repo.d.ts.map +1 -1
  51. package/dist/db/worker-lease-repo.d.ts +2 -1
  52. package/dist/db/worker-lease-repo.d.ts.map +1 -1
  53. package/dist/domain-logic/outcome-tools.d.ts.map +1 -1
  54. package/dist/domain-logic/worker-lease-lifecycle.d.ts.map +1 -1
  55. package/dist/external-source-service.d.ts.map +1 -1
  56. package/dist/future-execution/execution.d.ts +4 -1
  57. package/dist/future-execution/execution.d.ts.map +1 -1
  58. package/dist/future-execution/launch-lifecycle.d.ts +9 -25
  59. package/dist/future-execution/launch-lifecycle.d.ts.map +1 -1
  60. package/dist/future-execution/lifecycle.d.ts +3 -28
  61. package/dist/future-execution/lifecycle.d.ts.map +1 -1
  62. package/dist/future-execution/model-projection.d.ts.map +1 -1
  63. package/dist/future-execution/reconciliation.d.ts +1 -0
  64. package/dist/future-execution/reconciliation.d.ts.map +1 -1
  65. package/dist/future-execution-presenter.d.ts.map +1 -1
  66. package/dist/index.js +2 -2
  67. package/dist/integration-tool-registry.d.ts +11 -2
  68. package/dist/integration-tool-registry.d.ts.map +1 -1
  69. package/dist/launch-coordinator.d.ts.map +1 -1
  70. package/dist/launcher-model-config-service.d.ts +7 -1
  71. package/dist/launcher-model-config-service.d.ts.map +1 -1
  72. package/dist/leaf-outcome-snapshot-capture.d.ts +1 -0
  73. package/dist/leaf-outcome-snapshot-capture.d.ts.map +1 -1
  74. package/dist/main.js +3 -3
  75. package/dist/primary-path-snapshot.d.ts.map +1 -1
  76. package/dist/process-action-presenter.d.ts +1 -6
  77. package/dist/process-action-presenter.d.ts.map +1 -1
  78. package/dist/process-action-registry.d.ts.map +1 -1
  79. package/dist/process-engine/decision.d.ts +2 -0
  80. package/dist/process-engine/decision.d.ts.map +1 -1
  81. package/dist/process-engine/engine.d.ts.map +1 -1
  82. package/dist/process-engine/mapped-turns.d.ts.map +1 -1
  83. package/dist/process-engine/ops/automatic-retry-startup.d.ts +8 -0
  84. package/dist/process-engine/ops/automatic-retry-startup.d.ts.map +1 -0
  85. package/dist/process-engine/ops/continue-failed-turn.d.ts.map +1 -1
  86. package/dist/process-engine/ops/process-observation.d.ts +6 -0
  87. package/dist/process-engine/ops/process-observation.d.ts.map +1 -0
  88. package/dist/process-engine/ops/retry-failed-turn.d.ts.map +1 -1
  89. package/dist/process-engine/ops/retry-startup.d.ts +2 -0
  90. package/dist/process-engine/ops/retry-startup.d.ts.map +1 -1
  91. package/dist/process-engine/ops/start-process.d.ts +2 -0
  92. package/dist/process-engine/ops/start-process.d.ts.map +1 -1
  93. package/dist/process-engine/ops/turn-outcome.d.ts.map +1 -1
  94. package/dist/process-engine/ops/turn-wait.d.ts +30 -0
  95. package/dist/process-engine/ops/turn-wait.d.ts.map +1 -0
  96. package/dist/process-engine/ops/update-model-config.d.ts +9 -0
  97. package/dist/process-engine/ops/update-model-config.d.ts.map +1 -0
  98. package/dist/process-engine/recorder.d.ts.map +1 -1
  99. package/dist/process-engine/turn-start-preflight.d.ts +6 -0
  100. package/dist/process-engine/turn-start-preflight.d.ts.map +1 -1
  101. package/dist/process-engine/turn-wait-state.d.ts +24 -0
  102. package/dist/process-engine/turn-wait-state.d.ts.map +1 -0
  103. package/dist/process-engine/turn-worker-requirement.d.ts +2 -0
  104. package/dist/process-engine/turn-worker-requirement.d.ts.map +1 -1
  105. package/dist/process-engine/types.d.ts +13 -2
  106. package/dist/process-engine/types.d.ts.map +1 -1
  107. package/dist/process-engine/writes/build-process-abort-writes.d.ts +3 -1
  108. package/dist/process-engine/writes/build-process-abort-writes.d.ts.map +1 -1
  109. package/dist/process-engine/writes/build-turn-outcome-writes.d.ts +2 -0
  110. package/dist/process-engine/writes/build-turn-outcome-writes.d.ts.map +1 -1
  111. package/dist/process-engine/writes/commit-writes.d.ts +2 -0
  112. package/dist/process-engine/writes/commit-writes.d.ts.map +1 -1
  113. package/dist/process-engine/writes/writes.d.ts +28 -60
  114. package/dist/process-engine/writes/writes.d.ts.map +1 -1
  115. package/dist/process-graph.d.ts +1 -1
  116. package/dist/process-graph.d.ts.map +1 -1
  117. package/dist/process-inspection-reader.d.ts +21 -0
  118. package/dist/process-inspection-reader.d.ts.map +1 -0
  119. package/dist/process-inspection-trace.d.ts +13 -0
  120. package/dist/process-inspection-trace.d.ts.map +1 -0
  121. package/dist/process-inspection.d.ts +22 -0
  122. package/dist/process-inspection.d.ts.map +1 -0
  123. package/dist/process-instance-tree-presenter.d.ts +4 -3
  124. package/dist/process-instance-tree-presenter.d.ts.map +1 -1
  125. package/dist/process-launch-executor.d.ts +2 -0
  126. package/dist/process-launch-executor.d.ts.map +1 -1
  127. package/dist/process-launch-plan.d.ts +1 -0
  128. package/dist/process-launch-plan.d.ts.map +1 -1
  129. package/dist/process-launcher-registry.d.ts.map +1 -1
  130. package/dist/process-model-availability-recovery.d.ts +1 -1
  131. package/dist/process-model-availability-recovery.d.ts.map +1 -1
  132. package/dist/process-model-config.d.ts +19 -0
  133. package/dist/process-model-config.d.ts.map +1 -0
  134. package/dist/process-model-policy/construct.d.ts.map +1 -1
  135. package/dist/process-model-policy/evaluate.d.ts.map +1 -1
  136. package/dist/process-model-policy/index.d.ts +4 -1
  137. package/dist/process-model-policy/index.d.ts.map +1 -1
  138. package/dist/process-model-policy/project.d.ts.map +1 -1
  139. package/dist/process-model-policy/types.d.ts +18 -0
  140. package/dist/process-model-policy/types.d.ts.map +1 -1
  141. package/dist/process-model-policy-presenter.d.ts.map +1 -1
  142. package/dist/process-runtime-availability.d.ts +2 -1
  143. package/dist/process-runtime-availability.d.ts.map +1 -1
  144. package/dist/process-turn-trace.d.ts.map +1 -1
  145. package/dist/process-ui-snapshot-presenter.d.ts +14 -3
  146. package/dist/process-ui-snapshot-presenter.d.ts.map +1 -1
  147. package/dist/routes/dashboard.d.ts +17 -0
  148. package/dist/routes/dashboard.d.ts.map +1 -0
  149. package/dist/routes/future-executions.d.ts.map +1 -1
  150. package/dist/routes/launchers.d.ts.map +1 -1
  151. package/dist/routes/process-actions.d.ts.map +1 -1
  152. package/dist/routes/process-detail.d.ts.map +1 -1
  153. package/dist/routes/process-model-config.d.ts +4 -0
  154. package/dist/routes/process-model-config.d.ts.map +1 -0
  155. package/dist/routes/process-route-helpers.d.ts +8 -9
  156. package/dist/routes/process-route-helpers.d.ts.map +1 -1
  157. package/dist/routes/processes.d.ts.map +1 -1
  158. package/dist/routes/settings.d.ts +11 -0
  159. package/dist/routes/settings.d.ts.map +1 -0
  160. package/dist/routes/ticket-creation.d.ts.map +1 -1
  161. package/dist/scoped-settings-service.d.ts +98 -0
  162. package/dist/scoped-settings-service.d.ts.map +1 -0
  163. package/dist/server-bootstrap/build-host-capabilities.d.ts +2 -0
  164. package/dist/server-bootstrap/build-host-capabilities.d.ts.map +1 -1
  165. package/dist/server-bootstrap/register-http.d.ts.map +1 -1
  166. package/dist/session-summary-projection.d.ts.map +1 -1
  167. package/dist/skills/bundled-skills.d.ts +5 -0
  168. package/dist/skills/bundled-skills.d.ts.map +1 -0
  169. package/dist/skills/catalog-service.d.ts +1 -0
  170. package/dist/skills/catalog-service.d.ts.map +1 -1
  171. package/dist/skills/extension-importer.d.ts +11 -0
  172. package/dist/skills/extension-importer.d.ts.map +1 -0
  173. package/dist/skills/launch-skills.d.ts +11 -0
  174. package/dist/skills/launch-skills.d.ts.map +1 -0
  175. package/dist/skills/skill-frontmatter.d.ts +7 -0
  176. package/dist/skills/skill-frontmatter.d.ts.map +1 -1
  177. package/dist/skills/source-importer.d.ts +3 -0
  178. package/dist/skills/source-importer.d.ts.map +1 -1
  179. package/dist/startup-evidence.d.ts +4 -3
  180. package/dist/startup-evidence.d.ts.map +1 -1
  181. package/dist/startup-retry-policy.d.ts +8 -0
  182. package/dist/startup-retry-policy.d.ts.map +1 -0
  183. package/dist/supervisor/execution-inspection-ingestor.d.ts +9 -0
  184. package/dist/supervisor/execution-inspection-ingestor.d.ts.map +1 -0
  185. package/dist/supervisor/ipc-handler.d.ts +2 -0
  186. package/dist/supervisor/ipc-handler.d.ts.map +1 -1
  187. package/dist/supervisor/worker-event-ingestor.d.ts +1 -0
  188. package/dist/supervisor/worker-event-ingestor.d.ts.map +1 -1
  189. package/dist/supervisor/worker-start-payload-builder.d.ts.map +1 -1
  190. package/dist/supervisor/worker-supervisor.d.ts +2 -0
  191. package/dist/supervisor/worker-supervisor.d.ts.map +1 -1
  192. package/dist/test-helpers/prepared-fixture-start.d.ts.map +1 -1
  193. package/dist/test-helpers/process-model-fixtures.d.ts +1 -0
  194. package/dist/test-helpers/process-model-fixtures.d.ts.map +1 -1
  195. package/dist/test-helpers/scoped-settings-fixtures.d.ts +16 -0
  196. package/dist/test-helpers/scoped-settings-fixtures.d.ts.map +1 -0
  197. package/dist/test-helpers/skill-fixtures.d.ts +4 -0
  198. package/dist/test-helpers/skill-fixtures.d.ts.map +1 -0
  199. package/dist/testing.js +2 -1
  200. package/dist/testing.js.map +1 -1
  201. package/dist/tool-approval-gate.d.ts +3 -0
  202. package/dist/tool-approval-gate.d.ts.map +1 -1
  203. package/dist/turn-progress.d.ts.map +1 -1
  204. package/dist/turn-wait-service.d.ts +28 -0
  205. package/dist/turn-wait-service.d.ts.map +1 -0
  206. package/dist/worker-runtime-profile-selection.d.ts +2 -0
  207. package/dist/worker-runtime-profile-selection.d.ts.map +1 -1
  208. package/package.json +20 -19
  209. package/src/app.ts +177 -25
  210. package/src/auth/fastify-auth.ts +13 -0
  211. package/src/config/config-loader.ts +42 -2
  212. package/src/config/config-types.ts +16 -1
  213. package/src/config/kubernetes-docker-isolation.ts +21 -0
  214. package/src/dashboard-model-issues.ts +199 -0
  215. package/src/db/database.ts +131 -40
  216. package/src/db/execution-inspection-repo.ts +163 -0
  217. package/src/db/history-window.ts +18 -0
  218. package/src/db/process-event-repo.ts +88 -10
  219. package/src/db/process-instance-repo.ts +33 -2
  220. package/src/db/process-leaf-outcome-snapshot-repo.ts +8 -2
  221. package/src/db/process-project-repo.ts +4 -0
  222. package/src/db/process-skill-repo.ts +9 -2
  223. package/src/db/process-turn-annotation-repo.ts +27 -9
  224. package/src/db/process-turn-record-repo.ts +45 -12
  225. package/src/db/publication-repo.ts +63 -0
  226. package/src/db/repositories.ts +17 -0
  227. package/src/db/schema.ts +103 -1
  228. package/src/db/scoped-settings-repo.ts +234 -0
  229. package/src/db/skill-repo.ts +89 -27
  230. package/src/db/turn-start-record-repo.ts +13 -3
  231. package/src/db/turn-summary-repo.ts +36 -4
  232. package/src/db/worker-lease-repo.ts +8 -2
  233. package/src/domain-logic/outcome-tools.ts +18 -216
  234. package/src/domain-logic/worker-lease-lifecycle.ts +2 -1
  235. package/src/external-source-service.ts +33 -7
  236. package/src/future-execution/execution.ts +9 -2
  237. package/src/future-execution/launch-lifecycle.ts +87 -78
  238. package/src/future-execution/lifecycle.ts +5 -34
  239. package/src/future-execution/model-projection.ts +2 -0
  240. package/src/future-execution/reconciliation.ts +7 -0
  241. package/src/future-execution-presenter.ts +7 -8
  242. package/src/integration-tool-registry.ts +59 -26
  243. package/src/launch-coordinator.ts +10 -1
  244. package/src/launcher-model-config-service.ts +24 -3
  245. package/src/leaf-outcome-snapshot-capture.ts +2 -0
  246. package/src/primary-path-snapshot.ts +3 -4
  247. package/src/process-action-presenter.ts +22 -57
  248. package/src/process-action-registry.ts +31 -39
  249. package/src/process-engine/decision.ts +10 -0
  250. package/src/process-engine/engine.ts +25 -2
  251. package/src/process-engine/mapped-turns.ts +5 -7
  252. package/src/process-engine/ops/automatic-retry-startup.ts +93 -0
  253. package/src/process-engine/ops/continue-failed-turn.ts +2 -13
  254. package/src/process-engine/ops/process-observation.ts +119 -0
  255. package/src/process-engine/ops/retry-failed-turn.ts +2 -12
  256. package/src/process-engine/ops/retry-startup.ts +20 -16
  257. package/src/process-engine/ops/start-process.ts +34 -2
  258. package/src/process-engine/ops/turn-outcome.ts +61 -60
  259. package/src/process-engine/ops/turn-wait.ts +225 -0
  260. package/src/process-engine/ops/update-model-config.ts +66 -0
  261. package/src/process-engine/recorder.ts +34 -5
  262. package/src/process-engine/turn-start-preflight.ts +168 -105
  263. package/src/process-engine/turn-wait-state.ts +126 -0
  264. package/src/process-engine/turn-worker-requirement.ts +4 -0
  265. package/src/process-engine/types.ts +21 -0
  266. package/src/process-engine/writes/build-process-abort-writes.ts +30 -20
  267. package/src/process-engine/writes/build-turn-outcome-writes.ts +39 -2
  268. package/src/process-engine/writes/commit-writes.ts +16 -4
  269. package/src/process-engine/writes/writes.ts +59 -74
  270. package/src/process-graph.ts +0 -1
  271. package/src/process-inspection-reader.ts +305 -0
  272. package/src/process-inspection-trace.ts +176 -0
  273. package/src/process-inspection.ts +169 -0
  274. package/src/process-instance-tree-presenter.ts +56 -216
  275. package/src/process-launch-executor.ts +5 -2
  276. package/src/process-launch-plan.ts +17 -2
  277. package/src/process-launcher-registry.ts +28 -16
  278. package/src/process-model-availability-recovery.ts +6 -4
  279. package/src/process-model-config.ts +100 -0
  280. package/src/process-model-policy/construct.ts +1 -0
  281. package/src/process-model-policy/evaluate.ts +34 -32
  282. package/src/process-model-policy/index.ts +45 -3
  283. package/src/process-model-policy/project.ts +62 -76
  284. package/src/process-model-policy/types.ts +26 -0
  285. package/src/process-model-policy-presenter.ts +7 -3
  286. package/src/process-runtime-availability.ts +9 -4
  287. package/src/process-turn-trace.ts +12 -24
  288. package/src/process-ui-snapshot-presenter.ts +210 -295
  289. package/src/routes/dashboard.ts +106 -0
  290. package/src/routes/future-executions.ts +5 -5
  291. package/src/routes/launchers.ts +51 -1
  292. package/src/routes/process-actions.ts +10 -10
  293. package/src/routes/process-detail.ts +25 -2
  294. package/src/routes/process-model-config.ts +70 -0
  295. package/src/routes/process-route-helpers.ts +153 -162
  296. package/src/routes/processes.ts +2 -0
  297. package/src/routes/settings.ts +173 -0
  298. package/src/routes/ticket-creation.ts +28 -5
  299. package/src/scoped-settings-service.ts +797 -0
  300. package/src/server-bootstrap/build-host-capabilities.ts +42 -0
  301. package/src/server-bootstrap/register-http.ts +12 -1
  302. package/src/session-summary-projection.ts +1 -2
  303. package/src/skills/bundled-skills.ts +64 -0
  304. package/src/skills/catalog-service.ts +35 -6
  305. package/src/skills/extension-importer.ts +94 -0
  306. package/src/skills/launch-skills.ts +19 -0
  307. package/src/skills/skill-frontmatter.ts +19 -6
  308. package/src/skills/source-importer.ts +7 -13
  309. package/src/startup-evidence.ts +29 -8
  310. package/src/startup-retry-policy.ts +106 -0
  311. package/src/supervisor/execution-inspection-ingestor.ts +55 -0
  312. package/src/supervisor/ipc-handler.ts +2 -0
  313. package/src/supervisor/worker-event-ingestor.ts +30 -14
  314. package/src/supervisor/worker-start-payload-builder.ts +17 -0
  315. package/src/supervisor/worker-supervisor.ts +26 -1
  316. package/src/test-helpers/prepared-fixture-start.ts +1 -0
  317. package/src/test-helpers/process-model-fixtures.ts +2 -0
  318. package/src/test-helpers/scoped-settings-fixtures.ts +126 -0
  319. package/src/test-helpers/skill-fixtures.ts +28 -0
  320. package/src/tool-approval-gate.ts +16 -0
  321. package/src/turn-progress.ts +3 -2
  322. package/src/turn-wait-service.ts +228 -0
  323. package/src/worker-runtime-profile-selection.ts +8 -1
  324. package/dist/app-MSJXFK33.js +0 -8
  325. package/dist/chunk-HK6BLLHA.js.map +0 -1
  326. package/dist/chunk-QCHS3X33.js.map +0 -1
  327. /package/dist/{app-MSJXFK33.js.map → app-KR3N2JAE.js.map} +0 -0
package/src/app.ts CHANGED
@@ -14,9 +14,12 @@ import type {
14
14
  ProvidedCapability,
15
15
  ServerExtensionEventMap,
16
16
  } from "@leitwerk-dev/process-sdk";
17
+ import { scopedSettingsCapability } from "@leitwerk-dev/process-sdk";
17
18
  import type { ModelProfileSnapshot } from "@leitwerk-dev/protocol";
18
19
  import { DEFAULT_SESSION_TRANSFER_LIMITS } from "@leitwerk-dev/session-transfer";
19
20
  import { createPollingCoordinator, parseDurationMs } from "@leitwerk-dev/watcher-utils";
21
+ import { topicWikiCapability } from "@leitwerk-dev/wiki/integration";
22
+ import { createTopicWikiRepo, registerWikiTools } from "@leitwerk-dev/wiki/server";
20
23
  import {
21
24
  cleanupRetainedProcessVolumes,
22
25
  type ProcessStateExporter,
@@ -105,6 +108,7 @@ import {
105
108
  import { RepositoryCredentialService } from "./repository-credentials/service.js";
106
109
  import { ResultImageStore } from "./result-image-store.js";
107
110
  import type { RouteDeps } from "./routes/processes.js";
111
+ import { createScopedSettingsService } from "./scoped-settings-service.js";
108
112
  import { collectCleanupErrors, createAppLifecycle } from "./server-bootstrap/app-lifecycle.js";
109
113
  import { buildHostCapabilities } from "./server-bootstrap/build-host-capabilities.js";
110
114
  import { loadServerExtensionCatalog } from "./server-bootstrap/load-extension-catalog.js";
@@ -114,7 +118,9 @@ import { resolveServerTlsOptions } from "./server-topology.js";
114
118
  import { createProjectedSessionSnapshotStore } from "./session-summary-projection.js";
115
119
  import { createSessionTransferHelperRelays } from "./session-transfer-helper-relays.js";
116
120
  import { createSessionTransferService } from "./session-transfer-service.js";
121
+ import { importBundledSkills } from "./skills/bundled-skills.js";
117
122
  import { createSkillCatalogService } from "./skills/catalog-service.js";
123
+ import { importExtensionSkills } from "./skills/extension-importer.js";
118
124
  import { createDiagnosticTraceWriter } from "./supervisor/diagnostic-trace-writer.js";
119
125
  import { createIpcHandler, type IpcHandler } from "./supervisor/ipc-handler.js";
120
126
  import { startStaleHeartbeatWatchdog } from "./supervisor/stale-heartbeat-watchdog.js";
@@ -124,11 +130,22 @@ import {
124
130
  type WorkerWebSocketIpcManager,
125
131
  } from "./supervisor/worker-websocket-ipc.js";
126
132
  import { createToolApprovalGate } from "./tool-approval-gate.js";
133
+ import { recordTurnProgress } from "./turn-progress.js";
134
+ import { createTurnWaitService } from "./turn-wait-service.js";
127
135
  import { defaultWorkerRuntimeProfile } from "./worker-runtime-profile-selection.js";
128
136
  import { type Broadcaster, createBroadcaster } from "./ws/broadcast.js";
129
137
 
130
138
  /** @public */
131
139
  export interface AppOptions {
140
+ /** Clock and cadence seam for readiness integration tests. @internal */
141
+ turnWait?: {
142
+ /** @internal */
143
+ now?: () => number;
144
+ /** @internal */
145
+ pollIntervalMs?: number;
146
+ /** @internal */
147
+ timeoutMs?: number;
148
+ };
132
149
  /** @public */
133
150
  config?: LeitwerkConfig;
134
151
  /** @internal */
@@ -242,7 +259,12 @@ async function createConfiguredWorkerRunnerRuntime(input: {
242
259
  webSocketIpc: WorkerWebSocketIpcManager;
243
260
  provided?: AppOptions["workerRunnerRuntime"];
244
261
  helperRelays: ProcessStateExportHelperRelayProvider;
245
- onVolumePoolError: () => void;
262
+ onVolumePoolError: (error?: unknown) => void;
263
+ onImagePreparationEvent: NonNullable<
264
+ Parameters<
265
+ typeof import("@leitwerk-dev/worker-runners/kubernetes").createKubernetesWorkerRunner
266
+ >[0]["imagePreload"]
267
+ >["onEvent"];
246
268
  localWorkerSpawnImpl?: AppOptions["localWorkerSpawnImpl"];
247
269
  localWorkerDockerPreflightImpl?: AppOptions["localWorkerDockerPreflightImpl"];
248
270
  }): Promise<{
@@ -250,7 +272,7 @@ async function createConfiguredWorkerRunnerRuntime(input: {
250
272
  volume?: ProcessVolume;
251
273
  exporter: ProcessStateExporter;
252
274
  webSocketIpc: WorkerWebSocketIpcManager;
253
- volumePool?: { start(): void; stop(): Promise<void> };
275
+ preparation?: { start(): void; stop(): Promise<void> };
254
276
  }> {
255
277
  if (input.provided) {
256
278
  return {
@@ -286,9 +308,18 @@ async function createConfiguredWorkerRunnerRuntime(input: {
286
308
  });
287
309
  const created = createKubernetesWorkerRunner({
288
310
  client: kubernetesClient,
311
+ reclaimOnClose: processVolume?.reclaim_on_close === true,
289
312
  preProvision: processVolume?.pre_provision
290
313
  ? { ...processVolume.pre_provision, onError: input.onVolumePoolError }
291
314
  : undefined,
315
+ imagePreload: input.config.kubernetes?.image_preload?.enabled
316
+ ? {
317
+ images: Object.values(input.config.worker_runtime_profiles ?? {}).map(
318
+ (profile) => profile.image,
319
+ ),
320
+ onEvent: input.onImagePreparationEvent,
321
+ }
322
+ : undefined,
292
323
  processNamespacePrefix:
293
324
  input.config.kubernetes?.process_namespace_prefix ?? "leitwerk-process-",
294
325
  volume: {
@@ -421,7 +452,9 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
421
452
  const repos = createAllRepos(db, {
422
453
  ...(credentialCipher ? { credentialCipher } : {}),
423
454
  });
455
+ const extensionSkills = await importExtensionSkills(extensionCatalog.modules);
424
456
  repos.transaction((transactionRepos) => {
457
+ transactionRepos.skills.reconcileExtensions(extensionSkills);
425
458
  // Directly configured skills are no longer supported. Deactivate any left by an older release.
426
459
  transactionRepos.skills.reconcile([]);
427
460
  transactionRepos.skills.backfillDependencies();
@@ -429,6 +462,7 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
429
462
  const skillCatalog = createSkillCatalogService({
430
463
  repositories: config.skill_repositories ?? [],
431
464
  repos,
465
+ bundledSkills: await importBundledSkills(extensionCatalog.piContributions),
432
466
  });
433
467
  await skillCatalog.refresh();
434
468
  markStartup("skill_catalog");
@@ -467,12 +501,34 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
467
501
  markStartup("model_providers");
468
502
 
469
503
  const broadcaster = createBroadcaster();
504
+ repos.topicWiki = createTopicWikiRepo(db, (topicId) =>
505
+ broadcaster.sendDurable("wiki.updated", { topicId }),
506
+ );
470
507
  const processOperations = createProcessOperationCoordinator();
471
508
  const processGraphs = extensionCatalog.processes;
472
509
  const processActionRegistry = buildProcessActionRegistry(extensionCatalog);
473
510
  const integrationTools = new IntegrationToolRegistry(repos.externalWrites);
474
511
  const processUiRegistry = buildProcessUiRegistry(extensionCatalog);
512
+ const scopedSettings = createScopedSettingsService({
513
+ repos,
514
+ catalog: extensionCatalog,
515
+ config,
516
+ modelChoices: () =>
517
+ config.pi.model_profiles.map((profile) => {
518
+ const status = modelStatusCache
519
+ .snapshot()
520
+ .profiles.find((entry) => entry.profileId === profile.id);
521
+ return {
522
+ value: profile.id,
523
+ label: `${profile.id} — ${profile.provider}/${profile.model_id}`,
524
+ ...(status?.availability === "available"
525
+ ? {}
526
+ : { disabledReason: status?.safeReason ?? "Model unavailable" }),
527
+ };
528
+ }),
529
+ });
475
530
  const processModelPolicy = createServerProcessModelPolicy({
531
+ scopedSettings,
476
532
  config,
477
533
  processGraphs,
478
534
  processActionRegistry,
@@ -590,6 +646,7 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
590
646
  },
591
647
  };
592
648
  const launcherModelConfigs = createLauncherModelConfigService({
649
+ scopedSettingsService: scopedSettings,
593
650
  launcherService,
594
651
  launchPlans,
595
652
  processModelPolicy,
@@ -737,6 +794,7 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
737
794
  processModelPolicy,
738
795
  getModelAvailabilitySnapshot: () => modelStatusCache.snapshot(),
739
796
  afterRecord(process) {
797
+ invalidateExternalSourceArmings?.(process.id);
740
798
  // The process volume is the durable source for an already-created start.
741
799
  // A missing server-cache entry is valid after restart.
742
800
  piResourceBundlePins.reconcile(process);
@@ -749,11 +807,15 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
749
807
  {
750
808
  config,
751
809
  registry: modelProviderRegistry,
810
+ processActionRegistry,
811
+ mappedRuns: baseDeps.mappedRuns,
752
812
  modelStatusCache,
753
813
  piContributions: extensionCatalog.piContributions,
754
814
  bundleCache: piResourceBundles,
755
815
  projects: baseDeps.projects,
756
816
  processSkills: baseDeps.processSkills,
817
+ scopedSettings,
818
+ processModelPolicy,
757
819
  },
758
820
  process,
759
821
  writes,
@@ -783,18 +845,23 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
783
845
  const toolApprovalGate = createToolApprovalGate({
784
846
  repos: baseDeps,
785
847
  processOperations,
848
+ broadcaster,
786
849
  });
787
850
  const integrationToolRequests = createIntegrationToolRequestService({
788
851
  registry: integrationTools,
789
852
  repos: baseDeps,
790
853
  processActionRegistry,
791
854
  toolApprovalGate,
855
+ reportProgress: (report) => {
856
+ recordTurnProgress(baseDeps, report);
857
+ },
792
858
  });
793
859
  const diagnosticTraceWriter = createDiagnosticTraceWriter(
794
860
  path.join(config.storage.tree_files_dir, "diagnostic-traces"),
795
861
  );
796
862
  const ipcHandler = createIpcHandler(
797
863
  {
864
+ executionInspections: baseDeps.executionInspections,
798
865
  startupObservations: baseDeps.startupObservations,
799
866
  processes: baseDeps.processes,
800
867
  getLaunchCoordinator: () => launchCoordinator,
@@ -899,17 +966,25 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
899
966
  webSocketIpc: workerWebSocketIpc,
900
967
  provided: opts.workerRunnerRuntime,
901
968
  helperRelays: sessionTransferHelperRelays,
902
- onVolumePoolError: () =>
903
- app.log.warn("Volume pre-provisioning failed; retrying in the background"),
969
+ onVolumePoolError: (error) =>
970
+ app.log.warn(
971
+ { err: error },
972
+ "Volume pool degraded; inspect preparation Pods and CSI storage scheduling",
973
+ ),
974
+ onImagePreparationEvent: (event) => {
975
+ if (event.outcome === "succeeded") app.log.info(event, "Worker image prepared");
976
+ else app.log.warn(event, "Worker image preparation failed; retrying in the background");
977
+ },
904
978
  localWorkerSpawnImpl: opts.localWorkerSpawnImpl,
905
979
  localWorkerDockerPreflightImpl: opts.localWorkerDockerPreflightImpl,
906
980
  });
907
- if (runnerRuntime.volumePool) {
908
- startHooks.push(() => runnerRuntime.volumePool?.start());
909
- stopHooks.push(() => runnerRuntime.volumePool?.stop());
981
+ if (runnerRuntime.preparation) {
982
+ startHooks.push(() => runnerRuntime.preparation?.start());
983
+ stopHooks.push(() => runnerRuntime.preparation?.stop());
910
984
  }
911
985
  markStartup("worker_runner");
912
986
  supervisor = createWorkerSupervisor({
987
+ executionInspections: baseDeps.executionInspections,
913
988
  startupObservations: baseDeps.startupObservations,
914
989
  config: supervisorConfig,
915
990
  processGraphs,
@@ -951,30 +1026,67 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
951
1026
  let retentionWork: Promise<void> | undefined;
952
1027
  let retainedVolumeCleanupTimer: NodeJS.Timeout | null = null;
953
1028
  let retainedVolumeCleanupRunning = false;
954
- const releasedRetainedVolumes = new Set<string>();
1029
+ const retentionPolicy = {
1030
+ completedProcessRetention: config.workers.cleanup.completed_process_retention,
1031
+ errorProcessRetention: config.workers.cleanup.error_process_retention,
1032
+ };
1033
+ const reclaimTerminalStorage =
1034
+ config.workers.runner === "kubernetes" &&
1035
+ config.kubernetes?.process_volume.reclaim_on_close === true;
1036
+ const volumeRetentionPolicy = reclaimTerminalStorage
1037
+ ? { ...retentionPolicy, completedProcessRetention: "0s", abortedProcessRetention: "0s" }
1038
+ : retentionPolicy;
1039
+ const pendingVolumeReleases = new Set<Promise<void>>();
1040
+ function releaseRetainedVolume(instanceId: string): Promise<void> {
1041
+ const work = processOperations.runExclusive(instanceId, async () => {
1042
+ // Re-read under the lifecycle lock so a resumed process keeps its workspace.
1043
+ const process = baseDeps.processes.getById(instanceId);
1044
+ const lease = baseDeps.leases.getByInstance(instanceId);
1045
+ if (!process || (lease && !lease.exitedAt)) return;
1046
+ await cleanupRetainedProcessVolumes({
1047
+ volume: runnerRuntime.volume,
1048
+ processes: [process],
1049
+ now: new Date(),
1050
+ policy: volumeRetentionPolicy,
1051
+ reclaimTerminalBackingStorage: reclaimTerminalStorage,
1052
+ });
1053
+ });
1054
+ pendingVolumeReleases.add(work);
1055
+ return work.finally(() => pendingVolumeReleases.delete(work));
1056
+ }
1057
+ afterSuccessHooks.add(async (instanceId) => {
1058
+ const process = baseDeps.processes.getById(instanceId);
1059
+ if (
1060
+ !reclaimTerminalStorage ||
1061
+ !process ||
1062
+ !["completed", "aborted"].includes(process.lifecycleStatus)
1063
+ )
1064
+ return;
1065
+ try {
1066
+ await releaseRetainedVolume(instanceId);
1067
+ } catch (err) {
1068
+ app.log.warn({ err, instanceId }, "process PVC release failed; retention sweep will retry");
1069
+ }
1070
+ });
955
1071
  async function runRetainedVolumeCleanup(): Promise<void> {
956
1072
  if (retainedVolumeCleanupRunning) return;
957
1073
  retainedVolumeCleanupRunning = true;
958
1074
  const processes = baseDeps.processes.listAll();
959
1075
  const now = new Date();
960
- const policy = {
961
- completedProcessRetention: config.workers.cleanup.completed_process_retention,
962
- errorProcessRetention: config.workers.cleanup.error_process_retention,
963
- };
964
1076
  const expiredImageProcesses = new Set(
965
- planProcessVolumeRetentionCleanup({ processes, now, policy }),
1077
+ planProcessVolumeRetentionCleanup({ processes, now, policy: retentionPolicy }),
966
1078
  );
967
- try {
968
- const released = await cleanupRetainedProcessVolumes({
969
- volume: runnerRuntime.volume,
970
- processes,
971
- now,
972
- policy,
973
- alreadyReleased: releasedRetainedVolumes,
974
- });
975
- for (const instanceId of released) releasedRetainedVolumes.add(instanceId);
976
- } catch (error) {
977
- app.log.warn({ error }, "retained process volume cleanup failed");
1079
+ const expiredVolumes = planProcessVolumeRetentionCleanup({
1080
+ processes,
1081
+ now,
1082
+ policy: volumeRetentionPolicy,
1083
+ });
1084
+ for (const instanceId of expiredVolumes) {
1085
+ try {
1086
+ await releaseRetainedVolume(instanceId);
1087
+ } catch (err) {
1088
+ app.log.warn({ err, instanceId }, "retained process volume cleanup failed");
1089
+ }
978
1090
  }
979
1091
  try {
980
1092
  await resultImages.cleanupProcesses({
@@ -1019,6 +1131,7 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
1019
1131
  retainedVolumeCleanupTimer = null;
1020
1132
  }
1021
1133
  await retentionWork;
1134
+ await Promise.allSettled([...pendingVolumeReleases]);
1022
1135
  });
1023
1136
 
1024
1137
  if (processTitles?.start) {
@@ -1045,6 +1158,7 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
1045
1158
  );
1046
1159
  const processLaunchDeps = {
1047
1160
  ...baseDeps,
1161
+ skillDefaults: config,
1048
1162
  broadcaster,
1049
1163
  commands: processEngine,
1050
1164
  processTitles,
@@ -1056,6 +1170,7 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
1056
1170
  };
1057
1171
  const createProcess = createProcessFromLaunchPlan.bind(null, processLaunchDeps);
1058
1172
  futureExecutionLifecycle = createFutureExecutionLifecycle({
1173
+ skillDefaults: config,
1059
1174
  futureExecutions: baseDeps.futureExecutions,
1060
1175
  processes: baseDeps.processes,
1061
1176
  projects: baseDeps.projects,
@@ -1187,6 +1302,7 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
1187
1302
  modelStatusCache,
1188
1303
  });
1189
1304
  const hostCapabilities = buildHostCapabilities({
1305
+ integrationTools,
1190
1306
  config,
1191
1307
  baseDeps,
1192
1308
  projectMutations,
@@ -1211,6 +1327,33 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
1211
1327
  preProvidedCapabilities: opts.preProvidedCapabilities,
1212
1328
  });
1213
1329
 
1330
+ hostCapabilities.provide(scopedSettingsCapability, scopedSettings);
1331
+ const turnWaitService = createTurnWaitService({
1332
+ commitMessages: config.commit_messages,
1333
+ processes: baseDeps.processes,
1334
+ projects: baseDeps.projects,
1335
+ processGraphs,
1336
+ registry: processActionRegistry,
1337
+ commands: processEngine,
1338
+ require: hostCapabilities.require.bind(hostCapabilities),
1339
+ ...opts.turnWait,
1340
+ });
1341
+ polling.create({
1342
+ id: "turn-readiness",
1343
+ pollOnce: turnWaitService.poll,
1344
+ isEnabled: () => true,
1345
+ pollInterval: () => "1s",
1346
+ defaultIntervalMs: 1000,
1347
+ });
1348
+ afterSuccessHooks.add((instanceId) => {
1349
+ // Resolving readiness invokes this hook again; never await our own check.
1350
+ void turnWaitService.check(instanceId).catch((error: unknown) => {
1351
+ app.log.error({ err: error, instanceId }, "Turn readiness check failed");
1352
+ });
1353
+ });
1354
+ const wiki = hostCapabilities.require(topicWikiCapability);
1355
+ if (Array.isArray(wiki)) throw new Error("Wiki integration must be singular");
1356
+ registerWikiTools({ tool: (definition) => integrationTools.register(definition) }, wiki);
1214
1357
  await setupServerExtensions(
1215
1358
  extensionCatalog,
1216
1359
  {
@@ -1231,7 +1374,10 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
1231
1374
  );
1232
1375
  integrationTools.validateTicketProcesses(extensionCatalog.processes);
1233
1376
  startHooks.push(() => polling.start());
1234
- stopHooks.push(() => polling.stop());
1377
+ stopHooks.push(async () => {
1378
+ await turnWaitService.stop();
1379
+ await polling.stop();
1380
+ });
1235
1381
  for (const process of extensionCatalog.processes.values()) {
1236
1382
  for (const [turnId, binding] of process.turns) {
1237
1383
  const definition = binding.definition;
@@ -1248,6 +1394,12 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
1248
1394
  markStartup("server_extensions");
1249
1395
 
1250
1396
  const deps: RouteDeps = {
1397
+ onSettingsChanged: async () => {
1398
+ await futureExecutionLifecycle.reconcileModelAvailability({
1399
+ availability: modelStatusCache.snapshot(),
1400
+ });
1401
+ },
1402
+ scopedSettingsService: scopedSettings,
1251
1403
  externalSourceService,
1252
1404
  ...baseDeps,
1253
1405
  launchCoordinator,
@@ -2,16 +2,25 @@ import { type Actor, ADMIN_ACTOR } from "@leitwerk-dev/domain";
2
2
  import type { FastifyReply, FastifyRequest } from "fastify";
3
3
  import type { AuthService } from "./auth-service.js";
4
4
 
5
+ /** @internal */
5
6
  export interface TokenAuditContext {
7
+ /** @internal */
6
8
  operation: string;
9
+ /** @internal */
7
10
  tokenId?: string;
11
+ /** @internal */
8
12
  actor?: Actor;
13
+ /** @internal */
9
14
  ownerKind?: "user" | "anonymous";
15
+ /** @internal */
10
16
  count?: number;
11
17
  }
12
18
  declare module "fastify" {
19
+ /** @internal */
13
20
  interface FastifyRequest {
21
+ /** @internal */
14
22
  actor?: Actor;
23
+ /** @internal */
15
24
  tokenAudit?: TokenAuditContext;
16
25
  }
17
26
  }
@@ -57,9 +66,13 @@ export function authenticateRequest(auth: AuthService, request: FastifyRequest):
57
66
  const result = auth.apiTokens.resolve(match[1]);
58
67
  if (result.token) {
59
68
  request.tokenAudit = {
69
+ /** @internal */
60
70
  operation: "bearer_request",
71
+ /** @internal */
61
72
  tokenId: result.token.id,
73
+ /** @internal */
62
74
  actor: result.token.owner.actor,
75
+ /** @internal */
63
76
  ownerKind: result.token.owner.kind,
64
77
  };
65
78
  }
@@ -17,6 +17,7 @@ import { resolveDockerRegistryCredentials } from "../docker-registry-credentials
17
17
  import { isValidStorageSize } from "../process-storage-size.js";
18
18
  import { SAFE_SKILL_ID_PATTERN } from "../skills/skill-id.js";
19
19
  import type { LeitwerkConfig } from "./config-types.js";
20
+ import { resolveKubernetesDockerIsolation } from "./kubernetes-docker-isolation.js";
20
21
  import { isHttpsOrLoopbackHttpUrl, isValidHttpUrl, parseHttpUrl } from "./url-policy.js";
21
22
 
22
23
  const DEFAULT_SEARCH_PATHS = ["./leitwerk.yaml", "~/.leitwerk/leitwerk.yaml"];
@@ -135,12 +136,19 @@ export function loadConfigFromFile(filePath: string): ConfigLoadResult | ConfigL
135
136
  export function loadConfig(explicitPath?: string): ConfigLoadResult | ConfigLoadError {
136
137
  const filePath = resolveConfigPath(explicitPath);
137
138
  if (!filePath) {
138
- return { ok: true, config: getDefaultConfig(), filePath: "<defaults>" };
139
+ return {
140
+ ok: false,
141
+ error:
142
+ "Configuration file required: configure pi.default_model_profile and pi.model_profiles",
143
+ };
139
144
  }
140
145
  return loadConfigFromFile(filePath);
141
146
  }
142
147
 
143
148
  const stringArraySchema = v.array(v.string());
149
+ const skillIdsSchema = v.array(
150
+ v.pipe(v.string(), v.regex(SAFE_SKILL_ID_PATTERN, "Invalid skill ID")),
151
+ );
144
152
  const modelTurnConfigSchema = v.looseObject({
145
153
  model_profile: v.optional(v.string()),
146
154
  });
@@ -287,6 +295,10 @@ const configSchema = v.looseObject({
287
295
  ),
288
296
  pi: v.looseObject({
289
297
  agent_dir: v.string(),
298
+ default_model_profile: v.pipe(
299
+ v.string(),
300
+ v.check((value) => value.trim() !== "", "Must be a non-empty model profile ID"),
301
+ ),
290
302
  model_profiles: v.array(
291
303
  v.looseObject({
292
304
  id: v.string(),
@@ -320,6 +332,7 @@ const configSchema = v.looseObject({
320
332
  v.record(
321
333
  v.string(),
322
334
  v.looseObject({
335
+ default_skills: v.optional(skillIdsSchema),
323
336
  default_model_profile: v.optional(v.string()),
324
337
  allowed_model_profiles: v.optional(v.pipe(stringArraySchema, v.nonEmpty())),
325
338
  worker_runtime_profile: v.optional(v.string()),
@@ -350,6 +363,7 @@ const configSchema = v.looseObject({
350
363
  sources: stringArraySchema,
351
364
  }),
352
365
  auth: v.optional(authConfigSchema),
366
+ default_skills: v.optional(skillIdsSchema),
353
367
  docker_registries: v.optional(
354
368
  v.strictObject({
355
369
  profiles: v.record(v.string(), v.strictObject(dockerRegistryCredentialSchema.entries)),
@@ -381,7 +395,9 @@ const configSchema = v.looseObject({
381
395
  api_server_url: v.optional(v.string()),
382
396
  default_worker_runtime_profile: v.optional(v.string()),
383
397
  worker_service_account: v.optional(v.string()),
398
+ image_preload: v.optional(v.strictObject({ enabled: v.boolean() })),
384
399
  process_volume: v.looseObject({
400
+ reclaim_on_close: v.optional(v.boolean()),
385
401
  storage_class_name: v.optional(v.string()),
386
402
  pre_provision: v.optional(
387
403
  v.strictObject({ count: v.pipe(v.number(), v.integer(), v.minValue(0)) }),
@@ -392,8 +408,11 @@ const configSchema = v.looseObject({
392
408
  }),
393
409
  docker: v.optional(
394
410
  v.strictObject({
411
+ worker_runtime_profile: v.optional(v.pipe(v.string(), v.trim(), v.nonEmpty())),
412
+ node_selector: v.optional(v.record(v.string(), v.string())),
395
413
  runtime_class_name: v.optional(v.string()),
396
414
  host_users: v.optional(v.boolean()),
415
+ isolation: v.optional(v.picklist(["gvisor", "virtual-machine"])),
397
416
  gvisor: v.optional(v.boolean()),
398
417
  process_storage_class_name: v.optional(v.string()),
399
418
  network: v.optional(dockerNetworkSchema),
@@ -495,6 +514,11 @@ function collectModelProfileReferenceErrors(config: LeitwerkConfig): string[] {
495
514
  .filter((profileId) => typeof profileId === "string" && profileId.trim() !== ""),
496
515
  );
497
516
  const titleModelProfile = config.pi.process_title_generation.model_profile;
517
+ if (!configuredModelProfileIds.has(config.pi.default_model_profile)) {
518
+ errors.push(
519
+ `Unknown model profile '${config.pi.default_model_profile}' at pi.default_model_profile`,
520
+ );
521
+ }
498
522
  if (typeof titleModelProfile === "string") {
499
523
  if (titleModelProfile.trim() === "") {
500
524
  errors.push(
@@ -560,6 +584,10 @@ function collectWorkerRuntimeProfileErrors(config: LeitwerkConfig): string[] {
560
584
  config.kubernetes?.default_worker_runtime_profile,
561
585
  "kubernetes.default_worker_runtime_profile",
562
586
  );
587
+ checkReference(
588
+ config.kubernetes?.docker?.worker_runtime_profile,
589
+ "kubernetes.docker.worker_runtime_profile",
590
+ );
563
591
  }
564
592
  for (const [key, component] of Object.entries(config.components)) {
565
593
  checkReference(component.worker_runtime_profile, `components.${key}.worker_runtime_profile`);
@@ -737,6 +765,14 @@ function collectKubernetesRunnerConfigErrors(config: LeitwerkConfig): string[] {
737
765
  errors.push(
738
766
  "worker_runtime_profiles must include at least one profile when workers.runner is 'kubernetes'",
739
767
  );
768
+ if (k.image_preload?.enabled) {
769
+ for (const [id, profile] of Object.entries(config.worker_runtime_profiles ?? {})) {
770
+ if (!/^[a-zA-Z0-9][a-zA-Z0-9._:/-]*@sha256:[0-9a-f]{64}$/.test(profile.image))
771
+ errors.push(
772
+ `worker_runtime_profiles.${id}.image must be digest-qualified when kubernetes.image_preload.enabled is true`,
773
+ );
774
+ }
775
+ }
740
776
  const defaultProfile = k.default_worker_runtime_profile ?? config.workers.default_runtime_profile;
741
777
  if (!defaultProfile?.trim())
742
778
  errors.push(
@@ -935,6 +971,7 @@ function validateResolvedConfig(config: Record<string, unknown>): string[] {
935
971
  ...collectLocalRunnerConfigErrors(resolvedConfig),
936
972
  ...collectDockerRunnerConfigErrors(resolvedConfig),
937
973
  ...collectKubernetesRunnerConfigErrors(resolvedConfig),
974
+ ...resolveKubernetesDockerIsolation(resolvedConfig.kubernetes?.docker).errors,
938
975
  ...collectInternalTlsConfigErrors(resolvedConfig),
939
976
  ...collectAuthConfigErrors(resolvedConfig),
940
977
  ];
@@ -974,7 +1011,7 @@ export function sanitizeConfigForLogging(value: unknown, path: readonly string[]
974
1011
  return sanitized;
975
1012
  }
976
1013
 
977
- /** @public */
1014
+ /** Configuration template; set model_profiles and default_model_profile before startup. @public */
978
1015
  export function getDefaultConfig(): LeitwerkConfig {
979
1016
  return {
980
1017
  skill_repositories: [],
@@ -1028,6 +1065,7 @@ export function getDefaultConfig(): LeitwerkConfig {
1028
1065
  pi: {
1029
1066
  agent_dir: "~/.pi/leitwerk",
1030
1067
  model_profiles: [],
1068
+ default_model_profile: "",
1031
1069
  process_title_generation: {
1032
1070
  model_profile: null,
1033
1071
  retry: {
@@ -1048,6 +1086,7 @@ export function getDefaultConfig(): LeitwerkConfig {
1048
1086
  },
1049
1087
  },
1050
1088
  process_configs: {},
1089
+ default_skills: [],
1051
1090
  notifications: {
1052
1091
  all: { enabled: false, type: "teams_webhook", url: "" },
1053
1092
  debug: { enabled: false, type: "teams_webhook", url: "" },
@@ -1078,6 +1117,7 @@ export function getDefaultConfig(): LeitwerkConfig {
1078
1117
  default_worker_runtime_profile: "generic",
1079
1118
  worker_service_account: "leitwerk-worker",
1080
1119
  process_volume: {
1120
+ reclaim_on_close: false,
1081
1121
  size: "20Gi",
1082
1122
  access_modes: ["ReadWriteOnce"],
1083
1123
  mount_path: "/state",
@@ -148,6 +148,8 @@ export interface DockerRunnerConfig {
148
148
 
149
149
  /** @internal */
150
150
  export interface KubernetesProcessVolumeConfig {
151
+ /** Discard terminal workspaces and their backing storage; disabled by default. @internal */
152
+ reclaim_on_close?: boolean;
151
153
  /** Optional ready-volume target; zero stops replenishment. @internal */
152
154
  pre_provision?: {
153
155
  /** @internal */
@@ -165,11 +167,17 @@ export interface KubernetesProcessVolumeConfig {
165
167
 
166
168
  /** @internal */
167
169
  export interface KubernetesDockerConfig {
170
+ /** Default profile for Docker processes without an explicit process/component profile. @internal */
171
+ worker_runtime_profile?: string;
172
+ /** Docker-only selector keys override matching global Pod selector keys. @internal */
173
+ node_selector?: Record<string, string>;
168
174
  /** Pod RuntimeClass selected for every Docker-requiring process. @internal */
169
175
  runtime_class_name?: string;
170
176
  /** Pod user-namespace policy passed directly to spec.hostUsers. @internal */
171
177
  host_users?: boolean;
172
- /** @internal Opt in to the verified gVisor Docker wrapper and guest capabilities. */
178
+ /** Trusted sandbox policy for a separately qualified cluster runtime. @internal */
179
+ isolation?: "gvisor" | "virtual-machine";
180
+ /** Legacy alias for isolation: gvisor when isolation is omitted. @internal */
173
181
  gvisor?: boolean;
174
182
  /** StorageClass selected for the process's single retained PVC. @internal */
175
183
  process_storage_class_name?: string;
@@ -217,6 +225,11 @@ export interface LocalWorkerRunnerConfig {
217
225
 
218
226
  /** @internal */
219
227
  export interface KubernetesRunnerConfig {
228
+ /** Optional worker image preparation on eligible nodes; disabled by default. @internal */
229
+ image_preload?: {
230
+ /** @internal */
231
+ enabled: boolean;
232
+ };
220
233
  /** Dedicated namespace where the singleton server runs. @internal */
221
234
  server_namespace: string;
222
235
  /** Safe DNS prefix used to derive one namespace per process instance. @internal */
@@ -394,6 +407,8 @@ export interface LeitwerkConfig extends ConfigSnapshot {
394
407
  internal_tls?: InternalTlsConfig;
395
408
  /** Git repositories scanned for operator-managed skills. @internal */
396
409
  skill_repositories?: SkillRepositoryConfig[];
410
+ /** Installed skill IDs included in new launches unless replaced by process defaults. @public */
411
+ default_skills?: string[];
397
412
  /** Server-owned repository-aware commit-message generation rules. @internal */
398
413
  commit_messages?: CommitMessageConfig;
399
414
  /** Bounded archive and extraction ceilings for local session transfer. @internal */
@@ -0,0 +1,21 @@
1
+ import type { KubernetesDockerConfig } from "./config-types.js";
2
+
3
+ /** Normalize trusted sandbox selection before passing it to a worker runner. @internal */
4
+ export function resolveKubernetesDockerIsolation(docker: KubernetesDockerConfig | undefined): {
5
+ isolation: KubernetesDockerConfig["isolation"];
6
+ errors: string[];
7
+ } {
8
+ const isolation = docker?.isolation ?? (docker?.gvisor ? "gvisor" : undefined);
9
+ const errors: string[] = [];
10
+ if (
11
+ docker?.isolation !== undefined &&
12
+ docker.gvisor !== undefined &&
13
+ docker.gvisor !== (docker.isolation === "gvisor")
14
+ ) {
15
+ errors.push("kubernetes.docker.gvisor conflicts with kubernetes.docker.isolation");
16
+ }
17
+ if (isolation !== undefined && docker?.host_users !== undefined) {
18
+ errors.push("kubernetes.docker.host_users must be omitted for sandbox isolation");
19
+ }
20
+ return { isolation, errors };
21
+ }