spawnfile 0.1.17 → 0.1.19

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 (490) hide show
  1. package/README.md +1 -1
  2. package/dist/auth/importers.js +21 -5
  3. package/dist/auth/index.d.ts +1 -0
  4. package/dist/auth/index.js +1 -0
  5. package/dist/auth/profileStore.js +4 -1
  6. package/dist/auth/trainingGrokWriteback.d.ts +4 -0
  7. package/dist/auth/trainingGrokWriteback.js +119 -0
  8. package/dist/auth/trainingGrokWritebackLock.d.ts +5 -0
  9. package/dist/auth/trainingGrokWritebackLock.js +56 -0
  10. package/dist/cli/authCommands.js +9 -5
  11. package/dist/cli/compileBuildCommands.js +4 -0
  12. package/dist/cli/devCommands.js +4 -2
  13. package/dist/cli/downCommand.d.ts +2 -0
  14. package/dist/cli/downCommand.js +3 -0
  15. package/dist/cli/envFileOption.d.ts +18 -0
  16. package/dist/cli/envFileOption.js +20 -0
  17. package/dist/cli/lifecycleCommands.d.ts +1 -1
  18. package/dist/cli/lifecycleCommands.js +3 -1
  19. package/dist/cli/lifecyclePlan.d.ts +1 -0
  20. package/dist/cli/lifecyclePlan.js +2 -0
  21. package/dist/cli/paideiaDelegation.d.ts +2 -1
  22. package/dist/cli/paideiaDelegation.js +5 -4
  23. package/dist/cli/recordCommands.d.ts +17 -0
  24. package/dist/cli/recordCommands.js +43 -0
  25. package/dist/cli/releaseCommand.d.ts +6 -0
  26. package/dist/cli/releaseCommand.js +91 -0
  27. package/dist/cli/runCli.d.ts +7 -1
  28. package/dist/cli/runCli.js +11 -6
  29. package/dist/cli/runPublishCommands.js +5 -3
  30. package/dist/cli/trainCommand.js +73 -20
  31. package/dist/cli/upCommand.js +5 -1
  32. package/dist/cli/volumeCommands.d.ts +8 -0
  33. package/dist/cli/volumeCommands.js +53 -0
  34. package/dist/compiler/agentNodeMerge.js +3 -2
  35. package/dist/compiler/buildCompilePlan.js +4 -0
  36. package/dist/compiler/buildCompilePlanAgent.js +3 -1
  37. package/dist/compiler/buildCompilePlanTraversal.js +2 -0
  38. package/dist/compiler/buildCompilePlanTraversalHelpers.d.ts +2 -2
  39. package/dist/compiler/buildCompilePlanTraversalHelpers.js +4 -3
  40. package/dist/compiler/buildProject.d.ts +10 -0
  41. package/dist/compiler/buildProject.js +14 -2
  42. package/dist/compiler/cleanCompileOutput.d.ts +2 -0
  43. package/dist/compiler/cleanCompileOutput.js +14 -0
  44. package/dist/compiler/compilePlanHelpers.js +2 -0
  45. package/dist/compiler/compileProject.d.ts +10 -0
  46. package/dist/compiler/compileProject.js +29 -3
  47. package/dist/compiler/containerArtifactSummaries.js +1 -0
  48. package/dist/compiler/containerArtifacts.d.ts +4 -4
  49. package/dist/compiler/containerArtifacts.js +18 -34
  50. package/dist/compiler/containerArtifactsPlans.js +7 -0
  51. package/dist/compiler/containerArtifactsTypes.d.ts +7 -0
  52. package/dist/compiler/containerDaimonBrokerRender.d.ts +3 -1
  53. package/dist/compiler/containerDaimonBrokerRender.js +6 -3
  54. package/dist/compiler/containerDaimonGrokTaskClock.d.ts +5 -0
  55. package/dist/compiler/containerDaimonGrokTaskClock.js +29 -0
  56. package/dist/compiler/containerDaimonGrokWorkerProvisioning.d.ts +1 -1
  57. package/dist/compiler/containerDaimonGrokWorkerProvisioning.js +38 -16
  58. package/dist/compiler/containerDaimonGrokWorkerRender.d.ts +33 -8
  59. package/dist/compiler/containerDaimonGrokWorkerRender.js +18 -5
  60. package/dist/compiler/containerDaimonOwnershipGuardRender.d.ts +14 -1
  61. package/dist/compiler/containerDaimonOwnershipGuardRender.js +15 -2
  62. package/dist/compiler/containerDaimonUidEntrypointRender.js +6 -12
  63. package/dist/compiler/containerTargetResources.d.ts +10 -0
  64. package/dist/compiler/containerTargetResources.js +21 -13
  65. package/dist/compiler/containerWorkspaceResourceRender.js +4 -1
  66. package/dist/compiler/index.d.ts +2 -0
  67. package/dist/compiler/index.js +2 -0
  68. package/dist/compiler/mcpPlaceholders.d.ts +11 -0
  69. package/dist/compiler/mcpPlaceholders.js +58 -0
  70. package/dist/compiler/mcpServerInheritance.d.ts +18 -0
  71. package/dist/compiler/mcpServerInheritance.js +43 -0
  72. package/dist/compiler/moltnetArtifactTypes.d.ts +1 -0
  73. package/dist/compiler/moltnetArtifacts.js +1 -0
  74. package/dist/compiler/preflightCompilePlan.d.ts +9 -0
  75. package/dist/compiler/preflightCompilePlan.js +38 -0
  76. package/dist/compiler/recordingAgentFacts.d.ts +4 -0
  77. package/dist/compiler/recordingAgentFacts.js +35 -0
  78. package/dist/compiler/recordingCapability.d.ts +4 -0
  79. package/dist/compiler/recordingCapability.js +22 -0
  80. package/dist/compiler/recordingReport.d.ts +4 -0
  81. package/dist/compiler/recordingReport.js +18 -0
  82. package/dist/compiler/runProject.d.ts +2 -1
  83. package/dist/compiler/runProject.js +2 -0
  84. package/dist/compiler/surfaces.d.ts +1 -2
  85. package/dist/compiler/surfaces.js +0 -1
  86. package/dist/compiler/syncProjectAuth.js +2 -1
  87. package/dist/compiler/training/broker/clockProbe.d.ts +6 -0
  88. package/dist/compiler/training/broker/clockProbe.js +27 -0
  89. package/dist/compiler/training/broker/declaration.d.ts +4 -2
  90. package/dist/compiler/training/broker/declaration.js +4 -2
  91. package/dist/compiler/training/broker/entrypoint.js +33 -18
  92. package/dist/compiler/training/broker/evaluatorSecrets.d.ts +2 -0
  93. package/dist/compiler/training/broker/evaluatorSecrets.js +60 -0
  94. package/dist/compiler/training/broker/index.d.ts +3 -2
  95. package/dist/compiler/training/broker/index.js +3 -2
  96. package/dist/compiler/training/broker/main.js +1 -1
  97. package/dist/compiler/training/broker/paths.d.ts +96 -56
  98. package/dist/compiler/training/broker/paths.js +97 -89
  99. package/dist/compiler/training/broker/processes.d.ts +9 -0
  100. package/dist/compiler/training/broker/processes.js +4 -1
  101. package/dist/compiler/training/broker/projection.d.ts +3 -2
  102. package/dist/compiler/training/broker/projection.js +21 -9
  103. package/dist/compiler/training/broker/provisioning.d.ts +6 -15
  104. package/dist/compiler/training/broker/provisioning.js +71 -53
  105. package/dist/compiler/training/broker/registration.d.ts +3 -1
  106. package/dist/compiler/training/broker/registration.js +29 -21
  107. package/dist/compiler/training/broker/reset.d.ts +9 -0
  108. package/dist/compiler/training/broker/reset.js +71 -0
  109. package/dist/compiler/training/broker/runtime.d.ts +10 -13
  110. package/dist/compiler/training/broker/runtime.js +69 -115
  111. package/dist/compiler/training/broker/supervisor.d.ts +10 -11
  112. package/dist/compiler/training/broker/supervisor.js +22 -23
  113. package/dist/compiler/training/broker/taskClock.d.ts +5 -0
  114. package/dist/compiler/training/broker/taskClock.js +41 -0
  115. package/dist/compiler/training/compiledAgent.d.ts +21 -0
  116. package/dist/compiler/training/compiledAgent.js +62 -0
  117. package/dist/compiler/training/container/contract.d.ts +23 -0
  118. package/dist/compiler/training/container/contract.js +23 -5
  119. package/dist/compiler/training/container/evaluators.d.ts +48 -0
  120. package/dist/compiler/training/container/evaluators.js +50 -0
  121. package/dist/compiler/training/container/grokWriteback.d.ts +8 -0
  122. package/dist/compiler/training/container/grokWriteback.js +26 -0
  123. package/dist/compiler/training/container/index.d.ts +2 -1
  124. package/dist/compiler/training/container/index.js +2 -1
  125. package/dist/compiler/training/container/launch.d.ts +3 -0
  126. package/dist/compiler/training/container/launch.js +119 -28
  127. package/dist/compiler/training/container/nativeSlots.d.ts +14 -0
  128. package/dist/compiler/training/container/nativeSlots.js +13 -0
  129. package/dist/compiler/training/container/outputCopy.d.ts +2 -0
  130. package/dist/compiler/training/container/outputCopy.js +72 -0
  131. package/dist/compiler/training/container/outputVolume.d.ts +27 -0
  132. package/dist/compiler/training/container/outputVolume.js +161 -0
  133. package/dist/compiler/training/container/prepare.d.ts +3 -1
  134. package/dist/compiler/training/container/prepare.js +57 -12
  135. package/dist/compiler/training/container/security.d.ts +5 -3
  136. package/dist/compiler/training/container/security.js +15 -5
  137. package/dist/compiler/training/container/subjectIsolation.d.ts +5 -0
  138. package/dist/compiler/training/container/subjectIsolation.js +15 -0
  139. package/dist/compiler/training/context.d.ts +8 -0
  140. package/dist/compiler/training/context.js +12 -12
  141. package/dist/compiler/training/contract.d.ts +2 -0
  142. package/dist/compiler/training/contract.js +2 -0
  143. package/dist/compiler/training/execution.d.ts +417 -0
  144. package/dist/compiler/training/execution.js +160 -0
  145. package/dist/compiler/training/index.d.ts +8 -0
  146. package/dist/compiler/training/index.js +7 -0
  147. package/dist/compiler/training/moments.d.ts +80 -0
  148. package/dist/compiler/training/moments.js +118 -0
  149. package/dist/compiler/training/output.d.ts +2 -0
  150. package/dist/compiler/training/output.js +20 -0
  151. package/dist/compiler/training/plan/contract.d.ts +287 -0
  152. package/dist/compiler/training/plan/contract.js +49 -0
  153. package/dist/compiler/training/plan/index.d.ts +5 -0
  154. package/dist/compiler/training/plan/index.js +4 -0
  155. package/dist/compiler/training/plan/load.d.ts +9 -0
  156. package/dist/compiler/training/plan/load.js +153 -0
  157. package/dist/compiler/training/plan/references.d.ts +19 -0
  158. package/dist/compiler/training/plan/references.js +57 -0
  159. package/dist/compiler/training/plan/resolve.d.ts +4 -0
  160. package/dist/compiler/training/plan/resolve.js +73 -0
  161. package/dist/compiler/training/plan/targets.d.ts +11 -0
  162. package/dist/compiler/training/plan/targets.js +71 -0
  163. package/dist/compiler/training/plan/types.d.ts +36 -0
  164. package/dist/compiler/training/plan/types.js +1 -0
  165. package/dist/compiler/training/preparation/assets/Dockerfile +13 -2
  166. package/dist/compiler/training/preparation/assets/package-lock.json +2 -2
  167. package/dist/compiler/training/preparation/broker.d.ts +3 -3
  168. package/dist/compiler/training/preparation/broker.js +6 -4
  169. package/dist/compiler/training/preparation/contract.d.ts +27 -2
  170. package/dist/compiler/training/preparation/contract.js +23 -4
  171. package/dist/compiler/training/preparation/files.d.ts +5 -1
  172. package/dist/compiler/training/preparation/files.js +76 -15
  173. package/dist/compiler/training/preparation/image.js +9 -4
  174. package/dist/compiler/training/preparation/inputs.d.ts +1 -0
  175. package/dist/compiler/training/preparation/inputs.js +18 -10
  176. package/dist/compiler/training/preparation/prepare.d.ts +5 -0
  177. package/dist/compiler/training/preparation/prepare.js +66 -29
  178. package/dist/compiler/training/preparation/scratch.d.ts +6 -17
  179. package/dist/compiler/training/preparation/scratch.js +89 -23
  180. package/dist/compiler/training/repair/contract.d.ts +338 -4
  181. package/dist/compiler/training/repair/contract.js +2 -0
  182. package/dist/compiler/training/repair/index.d.ts +1 -1
  183. package/dist/compiler/training/repair/index.js +1 -1
  184. package/dist/compiler/training/repair/prepare.d.ts +155 -3
  185. package/dist/compiler/training/repair/prepare.js +6 -2
  186. package/dist/compiler/training/repair/witness.d.ts +152 -3
  187. package/dist/compiler/training/repair/witness.js +8 -2
  188. package/dist/compiler/training/resolution.d.ts +25 -0
  189. package/dist/compiler/training/resolution.js +69 -0
  190. package/dist/compiler/training/rewind/contract.d.ts +321 -0
  191. package/dist/compiler/training/rewind/contract.js +39 -0
  192. package/dist/compiler/training/rewind/deployedResource.d.ts +22 -0
  193. package/dist/compiler/training/rewind/deployedResource.js +19 -0
  194. package/dist/compiler/training/rewind/feed.d.ts +12 -0
  195. package/dist/compiler/training/rewind/feed.js +182 -0
  196. package/dist/compiler/training/rewind/feedContent.d.ts +6 -0
  197. package/dist/compiler/training/rewind/feedContent.js +38 -0
  198. package/dist/compiler/training/rewind/git.d.ts +8 -0
  199. package/dist/compiler/training/rewind/git.js +159 -0
  200. package/dist/compiler/training/rewind/gitArchive.d.ts +2 -0
  201. package/dist/compiler/training/rewind/gitArchive.js +7 -0
  202. package/dist/compiler/training/rewind/gitHistory.d.ts +3 -0
  203. package/dist/compiler/training/rewind/gitHistory.js +55 -0
  204. package/dist/compiler/training/rewind/gitProcess.d.ts +19 -0
  205. package/dist/compiler/training/rewind/gitProcess.js +81 -0
  206. package/dist/compiler/training/rewind/gitTree.d.ts +14 -0
  207. package/dist/compiler/training/rewind/gitTree.js +90 -0
  208. package/dist/compiler/training/rewind/history.d.ts +28 -0
  209. package/dist/compiler/training/rewind/history.js +239 -0
  210. package/dist/compiler/training/rewind/index.d.ts +18 -0
  211. package/dist/compiler/training/rewind/index.js +15 -0
  212. package/dist/compiler/training/rewind/inputs.d.ts +9 -0
  213. package/dist/compiler/training/rewind/inputs.js +67 -0
  214. package/dist/compiler/training/rewind/instant.d.ts +4 -0
  215. package/dist/compiler/training/rewind/instant.js +24 -0
  216. package/dist/compiler/training/rewind/leakCheck.d.ts +10 -0
  217. package/dist/compiler/training/rewind/leakCheck.js +56 -0
  218. package/dist/compiler/training/rewind/leakFeed.d.ts +5 -0
  219. package/dist/compiler/training/rewind/leakFeed.js +25 -0
  220. package/dist/compiler/training/rewind/leakFiles.d.ts +10 -0
  221. package/dist/compiler/training/rewind/leakFiles.js +106 -0
  222. package/dist/compiler/training/rewind/leakGit.d.ts +3 -0
  223. package/dist/compiler/training/rewind/leakGit.js +78 -0
  224. package/dist/compiler/training/rewind/leakGitPayload.d.ts +4 -0
  225. package/dist/compiler/training/rewind/leakGitPayload.js +57 -0
  226. package/dist/compiler/training/rewind/leakInputs.d.ts +7 -0
  227. package/dist/compiler/training/rewind/leakInputs.js +135 -0
  228. package/dist/compiler/training/rewind/leakLayout.d.ts +2 -0
  229. package/dist/compiler/training/rewind/leakLayout.js +17 -0
  230. package/dist/compiler/training/rewind/leakProvenance.d.ts +3 -0
  231. package/dist/compiler/training/rewind/leakProvenance.js +88 -0
  232. package/dist/compiler/training/rewind/materialize.d.ts +136 -0
  233. package/dist/compiler/training/rewind/materialize.js +212 -0
  234. package/dist/compiler/training/rewind/memory.d.ts +10 -0
  235. package/dist/compiler/training/rewind/memory.js +84 -0
  236. package/dist/compiler/training/rewind/memorySchemas.d.ts +87 -0
  237. package/dist/compiler/training/rewind/memorySchemas.js +50 -0
  238. package/dist/compiler/training/rewind/moltnet.d.ts +2 -0
  239. package/dist/compiler/training/rewind/moltnet.js +54 -0
  240. package/dist/compiler/training/rewind/moltnetJson.d.ts +13 -0
  241. package/dist/compiler/training/rewind/moltnetJson.js +180 -0
  242. package/dist/compiler/training/rewind/moltnetSchemas.d.ts +1226 -0
  243. package/dist/compiler/training/rewind/moltnetSchemas.js +75 -0
  244. package/dist/compiler/training/rewind/moltnetSqlite.d.ts +31 -0
  245. package/dist/compiler/training/rewind/moltnetSqlite.js +192 -0
  246. package/dist/compiler/training/rewind/moltnetSqliteData.d.ts +10 -0
  247. package/dist/compiler/training/rewind/moltnetSqliteData.js +113 -0
  248. package/dist/compiler/training/rewind/recordInput.d.ts +40 -0
  249. package/dist/compiler/training/rewind/recordInput.js +49 -0
  250. package/dist/compiler/training/rewind/recordedBundle.d.ts +4 -0
  251. package/dist/compiler/training/rewind/recordedBundle.js +58 -0
  252. package/dist/compiler/training/rewind/recordedCommit.d.ts +2 -0
  253. package/dist/compiler/training/rewind/recordedCommit.js +10 -0
  254. package/dist/compiler/training/rewind/select.d.ts +18 -0
  255. package/dist/compiler/training/rewind/select.js +64 -0
  256. package/dist/compiler/training/rewind/snapshotManifest.d.ts +42 -0
  257. package/dist/compiler/training/rewind/snapshotManifest.js +134 -0
  258. package/dist/compiler/training/rewind/taskClock.d.ts +12 -0
  259. package/dist/compiler/training/rewind/taskClock.js +40 -0
  260. package/dist/compiler/training/rewind/timestamps.d.ts +4 -0
  261. package/dist/compiler/training/rewind/timestamps.js +26 -0
  262. package/dist/compiler/training/rewind/types.d.ts +43 -0
  263. package/dist/compiler/training/rewind/types.js +1 -0
  264. package/dist/compiler/training/rewind/volumes.d.ts +12 -0
  265. package/dist/compiler/training/rewind/volumes.js +58 -0
  266. package/dist/compiler/training/selection.d.ts +7 -0
  267. package/dist/compiler/training/selection.js +15 -0
  268. package/dist/compiler/types.d.ts +6 -3
  269. package/dist/compiler/upProject.d.ts +1 -0
  270. package/dist/compiler/upProject.js +21 -5
  271. package/dist/compiler/workspaceBundleArtifacts.d.ts +16 -1
  272. package/dist/compiler/workspaceBundleArtifacts.js +69 -20
  273. package/dist/compiler/workspaceBundleCache.d.ts +23 -0
  274. package/dist/compiler/workspaceBundleCache.js +79 -0
  275. package/dist/compiler/workspaceBundleDependencies.d.ts +21 -0
  276. package/dist/compiler/workspaceBundleDependencies.js +122 -0
  277. package/dist/compiler/workspaceBundleFiles.d.ts +51 -0
  278. package/dist/compiler/workspaceBundleFiles.js +251 -0
  279. package/dist/compiler/workspaceBundleGenerated.d.ts +25 -0
  280. package/dist/compiler/workspaceBundleGenerated.js +103 -0
  281. package/dist/compiler/workspaceBundleGit.d.ts +64 -0
  282. package/dist/compiler/workspaceBundleGit.js +154 -0
  283. package/dist/compiler/workspaceBundleKey.d.ts +34 -0
  284. package/dist/compiler/workspaceBundleKey.js +17 -0
  285. package/dist/compiler/workspaceBundleResolve.d.ts +56 -0
  286. package/dist/compiler/workspaceBundleResolve.js +144 -0
  287. package/dist/compiler/workspaceBundleRun.d.ts +41 -0
  288. package/dist/compiler/workspaceBundleRun.js +79 -0
  289. package/dist/compiler/workspaceBundleTar.d.ts +47 -0
  290. package/dist/compiler/workspaceBundleTar.js +140 -0
  291. package/dist/compiler/workspaceBundleTree.d.ts +15 -0
  292. package/dist/compiler/workspaceBundleTree.js +58 -0
  293. package/dist/compiler/workspaceGitFetch.d.ts +41 -0
  294. package/dist/compiler/workspaceGitFetch.js +155 -0
  295. package/dist/compiler/workspaceGitPins.d.ts +33 -0
  296. package/dist/compiler/workspaceGitPins.js +127 -0
  297. package/dist/compiler/workspaceResources.d.ts +5 -1
  298. package/dist/compiler/workspaceResources.js +32 -5
  299. package/dist/deployment/activation.d.ts +3 -0
  300. package/dist/deployment/activation.js +12 -0
  301. package/dist/deployment/canaryCutover.d.ts +1 -1
  302. package/dist/deployment/candidateRecording.d.ts +8 -0
  303. package/dist/deployment/candidateRecording.js +22 -0
  304. package/dist/deployment/dockerManager.d.ts +5 -3
  305. package/dist/deployment/dockerManager.js +12 -2
  306. package/dist/deployment/downDeployment.d.ts +2 -0
  307. package/dist/deployment/downDeployment.js +6 -2
  308. package/dist/deployment/homeStore.d.ts +9 -1
  309. package/dist/deployment/homeStore.js +16 -53
  310. package/dist/deployment/index.d.ts +6 -0
  311. package/dist/deployment/index.js +6 -0
  312. package/dist/deployment/pidLock.d.ts +25 -0
  313. package/dist/deployment/pidLock.js +81 -0
  314. package/dist/deployment/record.d.ts +85 -1
  315. package/dist/deployment/record.js +11 -5
  316. package/dist/deployment/recordPublication.d.ts +15 -0
  317. package/dist/deployment/recordPublication.js +76 -0
  318. package/dist/deployment/recordedMemoryRetention.d.ts +18 -0
  319. package/dist/deployment/recordedMemoryRetention.js +27 -0
  320. package/dist/deployment/resourceLog.d.ts +140 -0
  321. package/dist/deployment/resourceLog.js +78 -0
  322. package/dist/distribution/buildDistributionReport.d.ts +3 -0
  323. package/dist/distribution/buildDistributionReport.js +5 -0
  324. package/dist/distribution/consumeImage.d.ts +3 -0
  325. package/dist/distribution/consumeImage.js +23 -31
  326. package/dist/distribution/consumeImageLifecycle.d.ts +4 -1
  327. package/dist/distribution/consumeImageLifecycle.js +14 -3
  328. package/dist/distribution/consumeImageSupport.d.ts +7 -0
  329. package/dist/distribution/consumeImageSupport.js +25 -0
  330. package/dist/distribution/distributionReportSchema.d.ts +47 -0
  331. package/dist/distribution/distributionReportSchema.js +20 -0
  332. package/dist/distribution/renderImageInterface.js +1 -1
  333. package/dist/distribution/types.d.ts +15 -0
  334. package/dist/filesystem/durableWrite.d.ts +10 -0
  335. package/dist/filesystem/durableWrite.js +87 -0
  336. package/dist/filesystem/index.d.ts +2 -0
  337. package/dist/filesystem/index.js +2 -0
  338. package/dist/filesystem/retainedJsonl.d.ts +23 -0
  339. package/dist/filesystem/retainedJsonl.js +123 -0
  340. package/dist/manifest/commandSchemas.d.ts +5 -0
  341. package/dist/manifest/commandSchemas.js +5 -0
  342. package/dist/manifest/executionSchemas.d.ts +20 -0
  343. package/dist/manifest/executionSchemas.js +13 -3
  344. package/dist/manifest/index.d.ts +2 -0
  345. package/dist/manifest/index.js +2 -0
  346. package/dist/manifest/loadManifest.js +3 -26
  347. package/dist/manifest/mcpSchemas.d.ts +61 -0
  348. package/dist/manifest/mcpSchemas.js +57 -11
  349. package/dist/manifest/memorySchemas.d.ts +1 -1
  350. package/dist/manifest/memorySchemas.js +1 -1
  351. package/dist/manifest/parseManifest.d.ts +7 -0
  352. package/dist/manifest/parseManifest.js +65 -0
  353. package/dist/manifest/renderSpawnfile.js +4 -1
  354. package/dist/manifest/renderSpawnfileWorkspace.js +6 -2
  355. package/dist/manifest/schemas.d.ts +1206 -132
  356. package/dist/manifest/schemas.js +14 -4
  357. package/dist/manifest/teamNetworkSchemas.d.ts +1 -1
  358. package/dist/manifest/trainingDataSchemas.d.ts +357 -0
  359. package/dist/manifest/trainingDataSchemas.js +31 -0
  360. package/dist/manifest/trainingSchemas.d.ts +49 -0
  361. package/dist/manifest/trainingSchemas.js +44 -0
  362. package/dist/manifest/volumeFeedSchemas.d.ts +52 -0
  363. package/dist/manifest/volumeFeedSchemas.js +104 -0
  364. package/dist/manifest/workspaceSchemas.d.ts +182 -5
  365. package/dist/manifest/workspaceSchemas.js +111 -7
  366. package/dist/recording/compose.d.ts +3 -0
  367. package/dist/recording/compose.js +93 -0
  368. package/dist/recording/deployment.d.ts +15 -0
  369. package/dist/recording/deployment.js +38 -0
  370. package/dist/recording/history.d.ts +16 -0
  371. package/dist/recording/history.js +47 -0
  372. package/dist/recording/index.d.ts +9 -0
  373. package/dist/recording/index.js +9 -0
  374. package/dist/recording/moment.d.ts +61 -0
  375. package/dist/recording/moment.js +36 -0
  376. package/dist/recording/parse.d.ts +15 -0
  377. package/dist/recording/parse.js +74 -0
  378. package/dist/recording/read.d.ts +8 -0
  379. package/dist/recording/read.js +61 -0
  380. package/dist/recording/store.d.ts +10 -0
  381. package/dist/recording/store.js +94 -0
  382. package/dist/recording/sync.d.ts +24 -0
  383. package/dist/recording/sync.js +126 -0
  384. package/dist/recording/types.d.ts +45 -0
  385. package/dist/recording/types.js +2 -0
  386. package/dist/release/drainControl.d.ts +54 -0
  387. package/dist/release/drainControl.js +137 -0
  388. package/dist/release/drainPhase.d.ts +37 -0
  389. package/dist/release/drainPhase.js +161 -0
  390. package/dist/release/index.d.ts +11 -0
  391. package/dist/release/index.js +11 -0
  392. package/dist/release/ledger.d.ts +75 -0
  393. package/dist/release/ledger.js +111 -0
  394. package/dist/release/notify.d.ts +58 -0
  395. package/dist/release/notify.js +126 -0
  396. package/dist/release/pending.d.ts +35 -0
  397. package/dist/release/pending.js +60 -0
  398. package/dist/release/postDeploy.d.ts +32 -0
  399. package/dist/release/postDeploy.js +62 -0
  400. package/dist/release/releaseDefaults.d.ts +9 -0
  401. package/dist/release/releaseDefaults.js +115 -0
  402. package/dist/release/releaseDocker.d.ts +38 -0
  403. package/dist/release/releaseDocker.js +94 -0
  404. package/dist/release/releaseTypes.d.ts +94 -0
  405. package/dist/release/releaseTypes.js +1 -0
  406. package/dist/release/runRelease.d.ts +9 -0
  407. package/dist/release/runRelease.js +218 -0
  408. package/dist/release/swap.d.ts +23 -0
  409. package/dist/release/swap.js +55 -0
  410. package/dist/release/types.d.ts +50 -0
  411. package/dist/release/types.js +29 -0
  412. package/dist/report/index.d.ts +1 -0
  413. package/dist/report/index.js +1 -0
  414. package/dist/report/recording.d.ts +57 -0
  415. package/dist/report/recording.js +26 -0
  416. package/dist/report/types.d.ts +58 -0
  417. package/dist/runtime/container.js +8 -13
  418. package/dist/runtime/daimon/adapter.js +15 -4
  419. package/dist/runtime/daimon/config.d.ts +4 -0
  420. package/dist/runtime/daimon/config.js +53 -4
  421. package/dist/runtime/daimon/contract-manifest.json +1 -0
  422. package/dist/runtime/daimon/contract-manifest.sha256 +1 -0
  423. package/dist/runtime/daimon/contractManifest.d.ts +59 -8
  424. package/dist/runtime/daimon/contractManifest.js +26 -10
  425. package/dist/runtime/daimon/grokTurnLimits.d.ts +25 -0
  426. package/dist/runtime/daimon/grokTurnLimits.js +51 -0
  427. package/dist/runtime/daimon/grokWorkerConfigBytes.d.ts +17 -0
  428. package/dist/runtime/daimon/grokWorkerConfigBytes.js +17 -0
  429. package/dist/runtime/daimon/grokWorkerContract.d.ts +5 -0
  430. package/dist/runtime/daimon/grokWorkerContract.js +13 -1
  431. package/dist/runtime/daimon/recording.d.ts +19 -0
  432. package/dist/runtime/daimon/recording.js +50 -0
  433. package/dist/runtime/daimon/scheduleAuthority.d.ts +8 -0
  434. package/dist/runtime/daimon/scheduleAuthority.js +19 -5
  435. package/dist/runtime/daimon/wakeMoments.d.ts +15 -0
  436. package/dist/runtime/daimon/wakeMoments.js +17 -0
  437. package/dist/runtime/daimonInstall.d.ts +3 -0
  438. package/dist/runtime/daimonInstall.js +25 -0
  439. package/dist/runtime/index.d.ts +1 -0
  440. package/dist/runtime/index.js +1 -0
  441. package/dist/runtime/install.d.ts +2 -0
  442. package/dist/runtime/install.js +1 -0
  443. package/dist/runtime/openclaw/adapter.js +3 -0
  444. package/dist/runtime/pi/adapter.js +3 -0
  445. package/dist/runtime/pi/containerTargets.js +6 -0
  446. package/dist/runtime/picoclaw/adapter.js +3 -0
  447. package/dist/runtime/registry.d.ts +3 -0
  448. package/dist/runtime/registry.js +13 -1
  449. package/dist/runtime/types.d.ts +15 -0
  450. package/dist/runtime/usageLedgerRead.d.ts +6 -0
  451. package/dist/runtime/usageLedgerRead.js +3 -3
  452. package/dist/shared/index.d.ts +1 -0
  453. package/dist/shared/index.js +1 -0
  454. package/dist/shared/recording.d.ts +8 -0
  455. package/dist/shared/recording.js +25 -0
  456. package/dist/target/dockerCommandExecutorCore.js +1 -1
  457. package/dist/target/dockerTargetBinding.js +2 -1
  458. package/dist/volume/feedLand.d.ts +31 -0
  459. package/dist/volume/feedLand.js +174 -0
  460. package/dist/volume/feedLandings.d.ts +45 -0
  461. package/dist/volume/feedLandings.js +111 -0
  462. package/dist/volume/feedLayout.d.ts +61 -0
  463. package/dist/volume/feedLayout.js +234 -0
  464. package/dist/volume/feedLock.d.ts +7 -0
  465. package/dist/volume/feedLock.js +131 -0
  466. package/dist/volume/feedManifest.d.ts +27 -0
  467. package/dist/volume/feedManifest.js +123 -0
  468. package/dist/volume/feedPrepare.d.ts +16 -0
  469. package/dist/volume/feedPrepare.js +228 -0
  470. package/dist/volume/feedProject.d.ts +39 -0
  471. package/dist/volume/feedProject.js +92 -0
  472. package/dist/volume/feedRecord.d.ts +55 -0
  473. package/dist/volume/feedRecord.js +148 -0
  474. package/dist/volume/feedRef.d.ts +43 -0
  475. package/dist/volume/feedRef.js +117 -0
  476. package/dist/volume/feedRefresh.d.ts +15 -0
  477. package/dist/volume/feedRefresh.js +187 -0
  478. package/dist/volume/feedSource.d.ts +66 -0
  479. package/dist/volume/feedSource.js +104 -0
  480. package/dist/volume/feedTarget.d.ts +70 -0
  481. package/dist/volume/feedTarget.js +9 -0
  482. package/dist/volume/feedTestKit.d.ts +11 -0
  483. package/dist/volume/feedTestKit.js +45 -0
  484. package/dist/volume/feedVerify.d.ts +18 -0
  485. package/dist/volume/feedVerify.js +104 -0
  486. package/dist/volume/index.d.ts +13 -0
  487. package/dist/volume/index.js +13 -0
  488. package/moltnet-releases.json +4 -4
  489. package/package.json +3 -3
  490. package/runtimes.yaml +8 -6
@@ -13,8 +13,10 @@ import { type DaimonGrokRegistration } from "../../containerDaimonGrokWorkerRend
13
13
  * the profile outright, and masks cannot nest, so an entry covered by another
14
14
  * entry is a provisioning bug rather than something to silently drop.
15
15
  */
16
- export declare const resolveTrainingGrokDenyPaths: (added?: readonly string[]) => string[];
16
+ export declare const resolveTrainingGrokDenyPaths: (added?: readonly string[] | undefined, slot?: number, slots?: number) => string[];
17
17
  export interface TrainingGrokSlotInput {
18
+ slot?: number;
19
+ slots?: number;
18
20
  agentId: string;
19
21
  model: DaimonGrokBrokerModel;
20
22
  reasoningEffort: DaimonGrokBrokerReasoningEffort;
@@ -1,9 +1,9 @@
1
1
  import path from "node:path";
2
2
  import { SpawnfileError } from "../../../shared/index.js";
3
3
  import { DAIMON_GROK_BROKER_MODELS, DAIMON_GROK_BROKER_REASONING_EFFORTS, DAIMON_GROK_ENGINE_BROKER } from "../../../runtime/daimon/contractManifest.js";
4
- import { DAIMON_GROK_WORKER_HOME_DIRECTORY, daimonGrokWorkerSandboxProfileSha256, renderDaimonGrokWorkerSandboxProfile, resolveDaimonGrokWorkerConfig } from "../../../runtime/daimon/grokWorkerContract.js";
4
+ import { DAIMON_GROK_WORKER_HOME_DIRECTORY, daimonGrokWorkerSandboxProfileSha256, renderDaimonGrokWorkerSandboxProfile, resolveDaimonGrokClockedWorkerConfig } from "../../../runtime/daimon/grokWorkerContract.js";
5
5
  import { DAIMON_GROK_BASE_PROFILE_GRANTS, assertCanonicalRegisteredPath } from "../../containerDaimonGrokWorkerRender.js";
6
- import { TRAINING_ADDED_DENY_PATHS, TRAINING_BOOTSTRAP_MOUNT, TRAINING_DEFERRED_DENY_PATHS, TRAINING_REALM_MOUNT, TRAINING_SLOT_INDEX, TRAINING_SLOT_RUNTIME_HOME, TRAINING_SLOT_STATE_ROOT, TRAINING_SLOT_USAGE_LEDGER, TRAINING_SLOT_WORKSPACE, TRAINING_WORKER_HOME, TRAINING_WORKER_UID } from "./paths.js";
6
+ import { trainingSlotPaths, trainingEvaluatorPaths, TRAINING_BOOTSTRAP_MOUNT, TRAINING_REALM_MOUNT, TRAINING_DEFERRED_DENY_PATHS } from "./paths.js";
7
7
  const fail = (message) => {
8
8
  throw new SpawnfileError("compile_error", message);
9
9
  };
@@ -21,26 +21,32 @@ const within = (candidate, root) => candidate === root || candidate.startsWith(`
21
21
  * the profile outright, and masks cannot nest, so an entry covered by another
22
22
  * entry is a provisioning bug rather than something to silently drop.
23
23
  */
24
- export const resolveTrainingGrokDenyPaths = (added = TRAINING_ADDED_DENY_PATHS) => {
25
- // The wake-acceptance store is masked through `TRAINING_SLOT_STATE_ROOT`, never directly: Grok 1.0.34
24
+ export const resolveTrainingGrokDenyPaths = (added = undefined, slot = 0, slots = 1) => {
25
+ const p = trainingSlotPaths(slot);
26
+ const required = trainingEvaluatorPaths(slot, slots).map(entry => entry.path);
27
+ // The wake-acceptance store is masked through `p.state`, never directly: Grok 1.0.34
26
28
  // materializes every deny target inside bubblewrap AS THE WORKER UID, and the store's parent is
27
29
  // `2000:2000 0700`, so the store itself is unplaceable and would make Grok refuse the whole profile
28
30
  // (`.runtime/grok-deny-placement/EVIDENCE.md`). The state root covers it and nothing else lives there.
29
- const daimonOwn = [TRAINING_BOOTSTRAP_MOUNT, TRAINING_REALM_MOUNT, TRAINING_SLOT_STATE_ROOT];
30
- const grokHome = path.posix.join(TRAINING_WORKER_HOME, DAIMON_GROK_WORKER_HOME_DIRECTORY);
31
+ const daimonOwn = [TRAINING_BOOTSTRAP_MOUNT, TRAINING_REALM_MOUNT, p.state];
32
+ const grokHome = path.posix.join(p.workerHome, DAIMON_GROK_WORKER_HOME_DIRECTORY);
31
33
  const grants = [
32
- ...DAIMON_GROK_BASE_PROFILE_GRANTS, TRAINING_SLOT_WORKSPACE, grokHome,
33
- path.posix.join(grokHome, "sessions"), path.posix.join(TRAINING_WORKER_HOME, "tmp")
34
+ ...DAIMON_GROK_BASE_PROFILE_GRANTS, p.workspace, grokHome,
35
+ path.posix.join(grokHome, "sessions"), path.posix.join(p.workerHome, "tmp")
34
36
  ];
35
- const candidates = [...new Set([...daimonOwn, ...added])].sort();
37
+ const candidates = [...new Set([...daimonOwn, ...required, ...(added ?? [])])].sort();
36
38
  for (const entry of candidates) {
37
39
  assertCanonicalRegisteredPath("deny path", entry);
38
40
  const grant = grants.find((candidate) => within(candidate, entry));
39
41
  if (grant)
40
42
  fail(`Training Grok deny path ${entry} equals or contains the base profile grant ${grant}; Grok refuses such a profile`);
41
- if (within(TRAINING_SLOT_WORKSPACE, entry) || within(TRAINING_WORKER_HOME, entry) || within(TRAINING_SLOT_RUNTIME_HOME, entry)) {
43
+ if (within(p.workspace, entry) || within(p.workerHome, entry) || within(p.runtimeHome, entry)) {
42
44
  fail(`Training Grok deny path ${entry} would hide the subject's own workspace, home, or runtime home`);
43
45
  }
46
+ if ([p.clockFile, DAIMON_GROK_ENGINE_BROKER.worker.taskClock.preloadPath,
47
+ "/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1", "/usr/lib/aarch64-linux-gnu/faketime/libfaketime.so.1"].some(file => within(file, entry))) {
48
+ fail(`Training Grok deny path ${entry} would hide the subject's task clock`);
49
+ }
44
50
  const ancestor = candidates.find((other) => other !== entry && within(entry, other));
45
51
  if (ancestor)
46
52
  fail(`Training Grok deny path ${ancestor} would cover ${entry}; masks cannot nest`);
@@ -55,26 +61,28 @@ export const resolveTrainingGrokDenyPaths = (added = TRAINING_ADDED_DENY_PATHS)
55
61
  * not exist here.
56
62
  */
57
63
  export const resolveTrainingGrokRegistration = (input) => {
64
+ const p = trainingSlotPaths(input.slot ?? 0);
58
65
  if (!input.agentId.trim())
59
66
  fail("Training Grok slot requires an agent id");
60
67
  if (!DAIMON_GROK_BROKER_MODELS.includes(input.model)
61
68
  || !DAIMON_GROK_BROKER_REASONING_EFFORTS.includes(input.reasoningEffort)) {
62
69
  fail(`Training Grok slot has no declared broker model and reasoning effort: ${input.agentId}`);
63
70
  }
64
- const home = assertCanonicalRegisteredPath("home", TRAINING_WORKER_HOME);
71
+ const home = assertCanonicalRegisteredPath("home", p.workerHome);
65
72
  const grokHome = path.posix.join(home, DAIMON_GROK_WORKER_HOME_DIRECTORY);
66
- const config = resolveDaimonGrokWorkerConfig(input.model, input.reasoningEffort);
67
- const denyPaths = resolveTrainingGrokDenyPaths(input.denyPaths);
73
+ const config = resolveDaimonGrokClockedWorkerConfig(input.model, input.reasoningEffort, p.slot);
74
+ const denyPaths = resolveTrainingGrokDenyPaths(input.denyPaths, p.slot, input.slots ?? 1);
68
75
  const profile = renderDaimonGrokWorkerSandboxProfile(denyPaths);
69
76
  const eventsPath = path.posix.join(grokHome, DAIMON_GROK_ENGINE_BROKER.worker.home.sandboxEvents.relativePath);
70
77
  const profilePath = path.posix.join(grokHome, "sandbox.toml");
71
78
  for (const [label, value] of [["GROK_HOME", grokHome], ["profile", profilePath], ["events", eventsPath],
72
- ["workspace", TRAINING_SLOT_WORKSPACE], ["runtime home", TRAINING_SLOT_RUNTIME_HOME],
73
- ["usage ledger", TRAINING_SLOT_USAGE_LEDGER]])
79
+ ["workspace", p.workspace], ["runtime home", p.runtimeHome],
80
+ ["usage ledger", p.usageLedger]])
74
81
  assertCanonicalRegisteredPath(label, value);
75
82
  return {
76
83
  agentId: input.agentId,
77
84
  config: config.bytes,
85
+ configVariant: "clocked",
78
86
  ...(input.limits === undefined ? {} : { limits: { ...input.limits } }),
79
87
  configSha256: config.sha256,
80
88
  deferredDenyPaths: denyPaths.filter((entry) => TRAINING_DEFERRED_DENY_PATHS.includes(entry)),
@@ -88,15 +96,15 @@ export const resolveTrainingGrokRegistration = (input) => {
88
96
  profileSha256: daimonGrokWorkerSandboxProfileSha256(denyPaths),
89
97
  privateTmp: path.posix.join(home, DAIMON_GROK_ENGINE_BROKER.worker.home.privateTmp.relativeToWorkerHome),
90
98
  reasoningEffort: input.reasoningEffort,
91
- runtimeHome: TRAINING_SLOT_RUNTIME_HOME,
99
+ runtimeHome: p.runtimeHome,
92
100
  // Empty on purpose: training has no persistent mounts at all. Everything a trial writes under the slot
93
101
  // runtime home is per-slot tmpfs the recycle wipes, and the only thing provisioned inside it is the
94
102
  // setgid `tool-output/` spill directory, so the traversable `0710` home exposes nothing else.
95
103
  runtimeHomeMounts: [],
96
- slot: TRAINING_SLOT_INDEX,
97
- spillDirectory: path.posix.join(TRAINING_SLOT_RUNTIME_HOME, DAIMON_GROK_ENGINE_BROKER.worker.home.spillDirectory.relativeToRuntimeHome),
98
- uid: TRAINING_WORKER_UID,
99
- usageLedgerPath: TRAINING_SLOT_USAGE_LEDGER,
100
- workspace: TRAINING_SLOT_WORKSPACE
104
+ slot: p.slot,
105
+ spillDirectory: path.posix.join(p.runtimeHome, DAIMON_GROK_ENGINE_BROKER.worker.home.spillDirectory.relativeToRuntimeHome),
106
+ uid: p.workerUid,
107
+ usageLedgerPath: p.usageLedger,
108
+ workspace: p.workspace
101
109
  };
102
110
  };
@@ -0,0 +1,9 @@
1
+ /** Root uses the broker's slot reset seam; the broker owns active-turn, worker-reap and clock checks. */
2
+ export declare const resetTrainingBrokerSlot: (slot: number, signal: AbortSignal, socketPath?: "/run/daimon-engine-broker/control.sock") => Promise<void>;
3
+ /** The native control relay authenticates SO_PEERCRED uid 2000 and rejects root. */
4
+ export declare const resetTrainingBrokerSlotAsOrganization: (slot: number, signal: AbortSignal, execute?: (file: string, args: string[], options: {
5
+ signal: AbortSignal;
6
+ timeout: number;
7
+ }) => Promise<{
8
+ stdout: string;
9
+ }>) => Promise<void>;
@@ -0,0 +1,71 @@
1
+ import { execFile } from "node:child_process";
2
+ import { promisify } from "node:util";
3
+ import { randomUUID } from "node:crypto";
4
+ import { createConnection } from "node:net";
5
+ import { DAIMON_GROK_ENGINE_BROKER } from "../../../runtime/daimon/contractManifest.js";
6
+ import { trainingSlotPaths } from "./paths.js";
7
+ /** Root uses the broker's slot reset seam; the broker owns active-turn, worker-reap and clock checks. */
8
+ export const resetTrainingBrokerSlot = (slot, signal, socketPath = DAIMON_GROK_ENGINE_BROKER.controlSocketPath) => {
9
+ trainingSlotPaths(slot);
10
+ signal.throwIfAborted();
11
+ const requestId = randomUUID();
12
+ const version = DAIMON_GROK_ENGINE_BROKER.controlProtocolVersion;
13
+ const payload = Buffer.from(JSON.stringify({ version, kind: "reset_slot", requestId, slot }));
14
+ const frame = Buffer.alloc(4 + payload.length);
15
+ frame.writeUInt32BE(payload.length);
16
+ payload.copy(frame, 4);
17
+ return new Promise((resolve, reject) => {
18
+ const socket = createConnection(socketPath);
19
+ let buffer = Buffer.alloc(0), settled = false;
20
+ const finish = (error) => {
21
+ if (settled)
22
+ return;
23
+ settled = true;
24
+ signal.removeEventListener("abort", abort);
25
+ socket.destroy();
26
+ if (error)
27
+ reject(error);
28
+ else
29
+ resolve();
30
+ };
31
+ const abort = () => finish(new Error("Training broker reset aborted; slot must be quarantined"));
32
+ signal.addEventListener("abort", abort, { once: true });
33
+ socket.once("error", error => finish(error));
34
+ socket.once("close", () => finish(new Error("Training broker reset refused: slot active, unavailable, or reset failed")));
35
+ socket.once("connect", () => socket.write(frame));
36
+ socket.on("data", chunk => {
37
+ buffer = Buffer.concat([buffer, chunk]);
38
+ if (buffer.length < 4)
39
+ return;
40
+ const size = buffer.readUInt32BE(0);
41
+ if (size < 2 || size > 4096 || buffer.length > size + 4) {
42
+ finish(new Error("Invalid broker reset response frame"));
43
+ return;
44
+ }
45
+ if (buffer.length < size + 4)
46
+ return;
47
+ try {
48
+ const response = JSON.parse(buffer.subarray(4).toString("utf8"));
49
+ if (!response || response.version !== version || response.kind !== "slot_reset" || response.requestId !== requestId
50
+ || response.slot !== slot || Object.keys(response).length !== 4)
51
+ throw Error("Invalid broker reset acknowledgement");
52
+ finish();
53
+ }
54
+ catch (error) {
55
+ finish(error instanceof Error ? error : new Error("Invalid broker reset response"));
56
+ }
57
+ });
58
+ });
59
+ };
60
+ /** The native control relay authenticates SO_PEERCRED uid 2000 and rejects root. */
61
+ export const resetTrainingBrokerSlotAsOrganization = async (slot, signal, execute = promisify(execFile)) => {
62
+ trainingSlotPaths(slot);
63
+ signal.throwIfAborted();
64
+ const uid = DAIMON_GROK_ENGINE_BROKER.identities.organizationUid;
65
+ const program = `import { resetTrainingBrokerSlot } from ${JSON.stringify(import.meta.url)}; await resetTrainingBrokerSlot(Number(process.argv[1]), AbortSignal.timeout(10000)); process.stdout.write("slot-reset-complete\\n");`;
66
+ const result = await execute("setpriv", ["--clear-groups", `--reuid=${uid}`, `--regid=${uid}`,
67
+ "--inh-caps=-all", "--ambient-caps=-all", "--bounding-set=-all", "--", process.execPath,
68
+ "--input-type=module", "--eval", program, String(slot)], { signal, timeout: 15_000 });
69
+ if (result.stdout !== "slot-reset-complete\n")
70
+ throw Error("Broker reset child returned no verified acknowledgement");
71
+ };
@@ -1,25 +1,22 @@
1
1
  import type { DaimonGrokRegistration } from "../../containerDaimonGrokWorkerRender.js";
2
2
  import type { TrainingBrokerDeclaration } from "./declaration.js";
3
- import { type BrokerChild } from "./processes.js";
4
3
  import type { TrainingSlotRuntime } from "./supervisor.js";
5
4
  export interface TrainingSlotRuntimeOptions {
6
5
  declaration: TrainingBrokerDeclaration;
7
6
  registration: DaimonGrokRegistration;
8
7
  projectionSha256: string;
8
+ reset: (slot: number, signal: AbortSignal) => Promise<void>;
9
9
  /** Test seam: the shell the provisioning script runs in and the `/proc` it reads identities from. */
10
10
  shell?: string;
11
11
  procRoot?: string;
12
12
  logPath?: string;
13
13
  }
14
- /**
15
- * The real slot runtime: what `recycle` actually does to this container.
16
- *
17
- * Every mutation goes through the same rendered provisioning the root
18
- * entrypoint ran at startup, so a recycled slot is byte-identically
19
- * provisioned — including the credential journal recovery, which is how a
20
- * recycle that lands on a `refreshing` or `stale` realm either recovers or
21
- * fails closed with a named error instead of leaving a silently stale realm.
22
- */
23
- export declare const createTrainingSlotRuntime: (options: TrainingSlotRuntimeOptions) => TrainingSlotRuntime & {
24
- children(): readonly BrokerChild[];
25
- };
14
+ export declare const createTrainingSlotRuntime: (options: TrainingSlotRuntimeOptions) => TrainingSlotRuntime;
15
+ /** Never remove or change the ownership/mode of a worker home or tmp: siblings attest those inodes. */
16
+ export declare const renderTrainingSlotWipe: (slot: number) => string[];
17
+ /** A failed privilege drop is not evidence of denial; require a positive worker verdict. */
18
+ export declare const probeTrainingWorker: (uid: number, target: string, depth: "read" | "enter", execute?: (command: string, args: string[], options: {
19
+ timeout: number;
20
+ }) => Promise<{
21
+ stdout: string;
22
+ }>) => Promise<boolean>;
@@ -1,68 +1,23 @@
1
1
  import { execFile } from "node:child_process";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { appendFileSync } from "node:fs";
4
- import { chmod, chown, mkdir, readFile, readdir, rename, writeFile } from "node:fs/promises";
4
+ import { chmod, chown, mkdir, readFile, rename, writeFile } from "node:fs/promises";
5
5
  import path from "node:path";
6
- import { setTimeout as pause } from "node:timers/promises";
7
6
  import { promisify } from "node:util";
8
7
  import { SpawnfileError } from "../../../shared/index.js";
9
- import { DAIMON_GROK_ENGINE_BROKER } from "../../../runtime/daimon/contractManifest.js";
10
8
  import { MOUNT_AWARE_CLEAR_HELPER } from "../../containerDaimonBrokerRender.js";
11
- import { renderTrainingBrokerProvisioning, renderTrainingIdentities } from "./provisioning.js";
12
- import { startBrokerProcesses, stopBrokerProcesses } from "./processes.js";
9
+ import { probeTrainingSiblingClock } from "./clockProbe.js";
10
+ import { renderTrainingTaskClockAssertions } from "./taskClock.js";
11
+ import { renderTrainingSlotProvisioning } from "./provisioning.js";
13
12
  import { buildTrainingSlotReceipt, readGrokExecutableSha256, resolveTrainingCanaries } from "./receipt.js";
14
- import { DAIMON_ORGANIZATION_UID, TRAINING_HOST_BIND_DENY_PATHS, TRAINING_SEALED_DENY_PATHS, TRAINING_WIPE_TARGETS, TRAINING_SLOT_GENERATION_FILE, TRAINING_SLOT_PREFLIGHT_RECEIPT, TRAINING_SLOT_TURN_STORE, TRAINING_SLOT_USAGE_DIRECTORY, TRAINING_SLOT_WORKSPACE, TRAINING_SUPERVISOR_LOG } from "./paths.js";
13
+ import { DAIMON_ORGANIZATION_UID, TRAINING_HOST_BIND_DENY_PATHS, TRAINING_SEALED_DENY_PATHS, trainingSlotPaths, trainingWipeTargets, trainingClearTargets, TRAINING_SUPERVISOR_LOG } from "./paths.js";
15
14
  const run = promisify(execFile);
16
15
  const quote = (value) => `'${value.replace(/'/gu, `'"'"'`)}'`;
17
- const CREDENTIAL_JOURNAL = `${DAIMON_GROK_ENGINE_BROKER.credentialHomePath}/.daimon-broker/credential-journal.json`;
18
- /** State the broker's credential authority may be left in; only `promoted` (or no journal at all) is settled. */
19
- const settledJournal = async () => {
20
- const raw = await readFile(CREDENTIAL_JOURNAL, "utf8").catch((error) => {
21
- if (error.code === "ENOENT")
22
- return undefined;
23
- throw error;
24
- });
25
- if (raw === undefined)
26
- return "settled";
27
- const journal = JSON.parse(raw);
28
- if (journal.version !== "noopolis.daimon.broker-credential-journal.v1")
29
- throw new SpawnfileError("runtime_error", "The broker credential journal is not a recognised version");
30
- return journal.state === "promoted" ? "settled" : journal.state === "refreshing" ? "refreshing" : "stale";
31
- };
32
- /** A turn is active while its registry record says so; a terminal record is finished work and never blocks a recycle. */
33
- const activeTurns = async () => {
34
- const names = await readdir(TRAINING_SLOT_TURN_STORE).catch((error) => {
35
- if (error.code === "ENOENT")
36
- return [];
37
- throw error;
38
- });
39
- let active = 0;
40
- for (const name of names) {
41
- if (!name.endsWith(".json"))
42
- continue;
43
- const raw = await readFile(path.join(TRAINING_SLOT_TURN_STORE, name), "utf8").catch(() => "");
44
- try {
45
- if (JSON.parse(raw).state === "active")
46
- active += 1;
47
- }
48
- catch { /* a half-written record is not an active turn */ }
49
- }
50
- return active;
51
- };
52
- /**
53
- * The real slot runtime: what `recycle` actually does to this container.
54
- *
55
- * Every mutation goes through the same rendered provisioning the root
56
- * entrypoint ran at startup, so a recycled slot is byte-identically
57
- * provisioned — including the credential journal recovery, which is how a
58
- * recycle that lands on a `refreshing` or `stale` realm either recovers or
59
- * fails closed with a named error instead of leaving a silently stale realm.
60
- */
61
16
  export const createTrainingSlotRuntime = (options) => {
62
17
  const shell = options.shell ?? "/bin/bash";
63
18
  const logPath = options.logPath ?? TRAINING_SUPERVISOR_LOG;
64
- const script = [...renderTrainingIdentities(), ...renderTrainingBrokerProvisioning(options.registration)].join("\n");
65
- let children = [];
19
+ const p = trainingSlotPaths(options.registration.slot);
20
+ const script = renderTrainingSlotProvisioning(options.registration).join("\n");
66
21
  const log = (line) => {
67
22
  const entry = `${new Date().toISOString()} ${line}\n`;
68
23
  process.stderr.write(`[slot-supervisor] ${entry}`);
@@ -71,61 +26,18 @@ export const createTrainingSlotRuntime = (options) => {
71
26
  }
72
27
  catch { /* the log is diagnostics, never the gate */ }
73
28
  };
74
- /**
75
- * One worker-uid reachability attempt. The command below *succeeds* when the
76
- * worker can still reach the target, so a non-zero exit is the denial.
77
- *
78
- * `enter` is the stronger question a sealed root needs answered: a directory
79
- * can be unreadable (`test -r` fails) and still searchable, and a subject
80
- * that knows `test.paideia.yaml` by name needs only search permission.
81
- */
82
- const probe = async (target, depth) => {
83
- const quoted = JSON.stringify(target);
84
- const reachable = depth === "enter"
85
- ? `test -r ${quoted} || test -x ${quoted} || ls -1 ${quoted} >/dev/null 2>&1`
86
- : `test -r ${quoted}`;
87
- try {
88
- await run("setpriv", ["--clear-groups", `--reuid=${options.registration.uid}`, `--regid=${options.registration.uid}`,
89
- "--inh-caps=-all", "--ambient-caps=-all", "--bounding-set=-all", "--", "/bin/sh", "-c", reachable], { timeout: 10_000 });
90
- return false;
91
- }
92
- catch {
93
- return true;
94
- }
95
- };
29
+ const siblingClocks = Array.from({ length: options.declaration.slots }, (_, slot) => trainingSlotPaths(slot))
30
+ .filter(peer => peer.slot !== p.slot).map(peer => peer.clockDirectory);
31
+ const probe = (target, depth) => siblingClocks.includes(target)
32
+ ? probeTrainingSiblingClock(p.slot, target)
33
+ : probeTrainingWorker(options.registration.uid, target, depth);
96
34
  return {
97
35
  log,
98
- children: () => children,
99
- drain: async (signal) => {
100
- for (;;) {
101
- signal.throwIfAborted();
102
- const state = await settledJournal();
103
- if (state === "stale") {
104
- // The audited provisioning below owns stale-realm recovery; it promotes the bootstrap or refuses outright.
105
- log("credential journal is stale; the recycle will replay the root credential recovery");
106
- return;
107
- }
108
- if (state === "settled" && await activeTurns() === 0)
109
- return;
110
- await pause(100);
111
- }
112
- },
113
- stop: async () => { await stopBrokerProcesses(children, log); children = []; },
36
+ reset: signal => options.reset(p.slot, signal),
114
37
  wipe: async () => {
115
38
  // Root holds `CAP_CHOWN` and `CAP_DAC_READ_SEARCH` but not `CAP_DAC_OVERRIDE`, so it cannot delete
116
39
  // inside a directory it handed to the worker or the broker. Reclaim each tree first, then remove it.
117
- const targets = TRAINING_WIPE_TARGETS;
118
- const contents = [TRAINING_SLOT_WORKSPACE, TRAINING_SLOT_USAGE_DIRECTORY];
119
- const script = [
120
- ...MOUNT_AWARE_CLEAR_HELPER,
121
- // The parent has to be reclaimed too: unlinking is a write to the *directory*, and the slot hands
122
- // several of these parents to uid 2000 or the broker. Provisioning restores every mode right after.
123
- 'reclaim() { parent=$(dirname "$1"); chown 0:0 "$parent"; chmod u+rwx "$parent"; if [ -e "$1" ]; then chown -R 0:0 "$1"; chmod -R u+rwX "$1"; fi; }',
124
- ...targets.map((target) => `reclaim ${quote(target)}; spawnfile_remove_tree ${quote(target)}`),
125
- // The workspace and the per-slot ledger directory keep their own root: the registered paths must
126
- // stay canonical across a recycle, so only what a trial put inside them goes.
127
- ...contents.map((target) => `reclaim ${quote(target)}; spawnfile_clear_tree ${quote(target)}`)
128
- ].join("\n");
40
+ const script = renderTrainingSlotWipe(p.slot).join("\n");
129
41
  await run(shell, ["--noprofile", "--norc", "-ceu", script], { maxBuffer: 1024 * 1024 }).catch((error) => {
130
42
  const detail = error;
131
43
  throw new SpawnfileError("runtime_error", `Training slot wipe failed: ${(detail.stderr ?? "").slice(-1024).trim() || "no diagnostic"}`);
@@ -139,19 +51,21 @@ export const createTrainingSlotRuntime = (options) => {
139
51
  if (result.stdout.trim())
140
52
  log(`provisioning: ${result.stdout.trim().slice(-2048)}`);
141
53
  },
142
- start: async () => { children = await startBrokerProcesses({ log, procRoot: options.procRoot }); },
143
- canaries: async () => resolveTrainingCanaries({
144
- denyPaths: options.registration.denyPaths, probe, log, hostBindPaths: TRAINING_HOST_BIND_DENY_PATHS,
145
- sealedPaths: TRAINING_SEALED_DENY_PATHS,
146
- mountinfo: await readFile(`${options.procRoot ?? "/proc"}/self/mountinfo`, "utf8"),
147
- unenforcedBindPolicy: options.declaration.unenforcedBindPolicy
148
- }),
54
+ canaries: async () => {
55
+ await run(shell, ["--noprofile", "--norc", "-ceu", renderTrainingTaskClockAssertions(options.registration).join("\n")]);
56
+ return resolveTrainingCanaries({
57
+ denyPaths: options.registration.denyPaths, probe, log, hostBindPaths: TRAINING_HOST_BIND_DENY_PATHS,
58
+ sealedPaths: TRAINING_SEALED_DENY_PATHS,
59
+ mountinfo: await readFile(`${options.procRoot ?? "/proc"}/self/mountinfo`, "utf8"),
60
+ unenforcedBindPolicy: options.declaration.unenforcedBindPolicy
61
+ });
62
+ },
149
63
  nextGeneration: async () => {
150
- const previous = await readFile(TRAINING_SLOT_GENERATION_FILE, "utf8").catch(() => "");
64
+ const previous = await readFile(p.generationFile, "utf8").catch(() => "");
151
65
  const parsed = Number.parseInt(JSON.parse(previous || "{}").generation ?? "0", 10);
152
66
  // Seeded from the wall clock so a container restart cannot hand out a generation an evaluator already accepted.
153
67
  const generation = Math.max(Number.isSafeInteger(parsed) && parsed > 0 ? parsed + 1 : 1, Math.floor(Date.now() / 1000));
154
- await writeFile(TRAINING_SLOT_GENERATION_FILE, `${JSON.stringify({ generation })}\n`, { mode: 0o600 });
68
+ await writeFile(p.generationFile, `${JSON.stringify({ generation })}\n`, { mode: 0o600 });
155
69
  return generation;
156
70
  },
157
71
  publishReceipt: async ({ generation, nonce, canaries }) => {
@@ -161,13 +75,53 @@ export const createTrainingSlotRuntime = (options) => {
161
75
  seccompProfileSha256: options.declaration.seccompProfileSha256,
162
76
  grokExecutableSha256: readGrokExecutableSha256(), canaries, createdAt: new Date()
163
77
  });
164
- const temporary = `${TRAINING_SLOT_PREFLIGHT_RECEIPT}.${randomUUID()}.tmp`;
165
- await mkdir(path.dirname(TRAINING_SLOT_PREFLIGHT_RECEIPT), { recursive: true });
78
+ const temporary = `${p.preflightReceipt}.${randomUUID()}.tmp`;
79
+ await mkdir(path.dirname(p.preflightReceipt), { recursive: true });
166
80
  await writeFile(temporary, `${JSON.stringify(receipt)}\n`, { mode: 0o600, flag: "wx" });
167
81
  await chown(temporary, 0, DAIMON_ORGANIZATION_UID);
168
82
  await chmod(temporary, 0o640);
169
- await rename(temporary, TRAINING_SLOT_PREFLIGHT_RECEIPT);
170
- return TRAINING_SLOT_PREFLIGHT_RECEIPT;
83
+ await rename(temporary, p.preflightReceipt);
84
+ return p.preflightReceipt;
171
85
  }
172
86
  };
173
87
  };
88
+ /** Never remove or change the ownership/mode of a worker home or tmp: siblings attest those inodes. */
89
+ export const renderTrainingSlotWipe = (slot) => {
90
+ const p = trainingSlotPaths(slot);
91
+ const worker = `setpriv --clear-groups --reuid=${p.workerUid} --regid=${p.workerUid} --inh-caps=-all --ambient-caps=-all --bounding-set=-all --`;
92
+ return [
93
+ ...MOUNT_AWARE_CLEAR_HELPER,
94
+ // Attested roots must still be canonical before any recursive mutation.
95
+ ...[p.workerHome, p.privateTmp, ...trainingWipeTargets(slot), ...trainingClearTargets(slot)].map(target => `if [ -e ${quote(target)} ] || [ -L ${quote(target)} ]; then if [ -L ${quote(target)} ] || [ "$(realpath ${quote(target)})" != ${quote(target)} ]; then echo "noncanonical slot wipe target" >&2; exit 1; fi; fi`),
96
+ 'reclaim() { parent=$(dirname "$1"); chown 0:0 "$parent"; chmod u+rwx "$parent"; if [ -e "$1" ]; then chown -R 0:0 "$1"; chmod -R u+rwX "$1"; fi; }',
97
+ ...trainingWipeTargets(slot).map(target => `reclaim ${quote(target)}; spawnfile_remove_tree ${quote(target)}`),
98
+ ...trainingClearTargets(slot).map(target => `reclaim ${quote(target)}; spawnfile_clear_tree ${quote(target)}`),
99
+ // Reclaim descendants only, then unlink as the worker, who owns the stable parent. No sibling inode changes.
100
+ `for worker_entry in ${quote(p.workerHome)}/* ${quote(p.workerHome)}/.[!.]* ${quote(p.workerHome)}/..?*; do`,
101
+ ' if [ ! -e "$worker_entry" ] && [ ! -L "$worker_entry" ]; then continue; fi',
102
+ ` if [ "$worker_entry" = ${quote(p.privateTmp)} ]; then continue; fi`,
103
+ ' if spawnfile_holds_mount "$worker_entry"; then echo "worker home contains a mount" >&2; exit 1; fi',
104
+ ` chown -hR ${p.workerUid}:${p.workerUid} "$worker_entry"`,
105
+ ` ${worker} /bin/sh -ceu 'if [ ! -L "$1" ]; then chmod -R u+rwX "$1"; fi; rm -rf "$1"' sh "$worker_entry"`,
106
+ 'done',
107
+ `for worker_entry in ${quote(p.privateTmp)}/* ${quote(p.privateTmp)}/.[!.]* ${quote(p.privateTmp)}/..?*; do`,
108
+ ' if [ ! -e "$worker_entry" ] && [ ! -L "$worker_entry" ]; then continue; fi',
109
+ ' if spawnfile_holds_mount "$worker_entry"; then echo "worker tmp contains a mount" >&2; exit 1; fi',
110
+ ` chown -hR ${p.workerUid}:${p.workerUid} "$worker_entry"`,
111
+ ` ${worker} /bin/sh -ceu 'if [ ! -L "$1" ]; then chmod -R u+rwX "$1"; fi; rm -rf "$1"' sh "$worker_entry"`,
112
+ 'done'
113
+ ];
114
+ };
115
+ /** A failed privilege drop is not evidence of denial; require a positive worker verdict. */
116
+ export const probeTrainingWorker = async (uid, target, depth, execute = run) => {
117
+ const q = quote(target);
118
+ const reachable = depth === "enter" ? `test -r ${q} || test -x ${q} || ls -1 ${q} >/dev/null 2>&1` : `test -r ${q}`;
119
+ const result = await execute("setpriv", ["--clear-groups", `--reuid=${uid}`, `--regid=${uid}`,
120
+ "--inh-caps=-all", "--ambient-caps=-all", "--bounding-set=-all", "--", "/bin/sh", "-c",
121
+ `if ${reachable}; then echo reachable; else echo denied; fi`], { timeout: 10_000 });
122
+ if (result.stdout.trim() === "denied")
123
+ return true;
124
+ if (result.stdout.trim() === "reachable")
125
+ return false;
126
+ throw new SpawnfileError("runtime_error", "Training worker canary returned no verified verdict");
127
+ };
@@ -1,4 +1,4 @@
1
- export declare const TRAINING_SUPERVISOR_PROTOCOL: "spawnfile.training-slot-supervisor.v1";
1
+ export declare const TRAINING_SUPERVISOR_PROTOCOL: "spawnfile.training-slot-supervisor.v2";
2
2
  export declare const TRAINING_SUPERVISOR_MAX_REQUEST_BYTES = 4096;
3
3
  /**
4
4
  * Everything the recycle verb does to the running slot. It is an interface so
@@ -8,14 +8,12 @@ export declare const TRAINING_SUPERVISOR_MAX_REQUEST_BYTES = 4096;
8
8
  * of bug a live check finds far too late.
9
9
  */
10
10
  export interface TrainingSlotRuntime {
11
- /** Waits for no active turn and a settled credential journal; throws a named error on an unrecoverable realm. */
12
- drain(signal: AbortSignal): Promise<void>;
13
- stop(): Promise<void>;
14
- /** Removes worker home, slot workspace, wake-acceptance, turn store, per-slot ledger and Grok session state. */
11
+ /** Broker refuses active turns and live workers, then resets only this slot clock/turn store. */
12
+ reset(signal: AbortSignal): Promise<void>;
13
+ /** Clears this slot while preserving the worker-home/tmp identities attested by sibling turns. */
15
14
  wipe(): Promise<void>;
16
- /** Replays the audited root provisioning: registrations, service.json, worker home, temp, spill, ledgers. */
15
+ /** Reuses the audited worker provisioning; shared broker files are untouched. */
17
16
  provision(): Promise<void>;
18
- start(): Promise<void>;
19
17
  /** Worker-uid denial canaries over every deny path; throws when one is still reachable. */
20
18
  canaries(): Promise<{
21
19
  path: string;
@@ -57,7 +55,7 @@ export declare const startTrainingSlot: (runtime: TrainingSlotRuntime, nonce: st
57
55
  canaries: number;
58
56
  }>;
59
57
  export interface TrainingSlotSupervisorOptions {
60
- runtime: TrainingSlotRuntime;
58
+ runtimes: readonly TrainingSlotRuntime[];
61
59
  /** Only this uid may recycle. Paideia, DSPy and the judges all run as it; every worker uid is refused. */
62
60
  organizationUid?: number;
63
61
  drainTimeoutMs?: number;
@@ -66,6 +64,7 @@ export interface TrainingSlotSupervisorOptions {
66
64
  export interface TrainingRecycleResult {
67
65
  ok: true;
68
66
  verb: "recycle";
67
+ slot: number;
69
68
  generation: number;
70
69
  nonce: string;
71
70
  receipt: string;
@@ -74,15 +73,15 @@ export interface TrainingRecycleResult {
74
73
  /**
75
74
  * The single-verb root slot supervisor.
76
75
  *
77
- * One verb, one argument, no path or command ever supplied by the caller: the
76
+ * One verb, slot and nonce, no path or command ever supplied by the caller: the
78
77
  * whole point of D4 is that recycling replays the container's own audited
79
78
  * provisioning rather than exposing a root file-system API to the evaluator.
80
- * Recycles are serialized — a second caller waits rather than interleaving a
79
+ * Recycles of the same slot are serialized — a second caller waits rather than interleaving a
81
80
  * wipe with a provision.
82
81
  */
83
82
  export declare const createTrainingSlotSupervisor: (options: TrainingSlotSupervisorOptions) => {
84
83
  /** Serialized: a recycle already in flight completes before the next one starts. */
85
- recycle: (nonce: string, peerUid: number) => Promise<TrainingRecycleResult>;
84
+ recycle: (slot: number, nonce: string, peerUid: number) => Promise<TrainingRecycleResult>;
86
85
  };
87
86
  export type TrainingSlotSupervisor = ReturnType<typeof createTrainingSlotSupervisor>;
88
87
  /**