@anyswarm/core 0.5.0 → 0.5.2

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 (403) hide show
  1. package/AGENTS.md +1 -1
  2. package/README.md +21 -13
  3. package/deploy/worker/Dockerfile +12 -4
  4. package/dist/deploy/worker/Dockerfile +12 -4
  5. package/dist/examples/README.md +35 -12
  6. package/dist/examples/authoring/README.md +24 -0
  7. package/dist/examples/authoring/business.d.ts +2 -0
  8. package/dist/examples/authoring/business.js +4 -0
  9. package/dist/examples/authoring/config.d.ts +5 -0
  10. package/dist/examples/authoring/config.js +2 -0
  11. package/dist/examples/authoring/eject.json +5 -0
  12. package/dist/examples/authoring/harness.d.ts +4 -0
  13. package/dist/examples/authoring/harness.js +19 -0
  14. package/dist/examples/autoresearch/README.md +40 -0
  15. package/dist/examples/autoresearch/REQUIREMENTS.zh.md +11 -0
  16. package/dist/examples/autoresearch/config.d.ts +51 -0
  17. package/dist/examples/autoresearch/config.js +57 -0
  18. package/dist/examples/autoresearch/demo.d.ts +11 -0
  19. package/dist/examples/autoresearch/demo.js +52 -0
  20. package/dist/examples/autoresearch/eject.json +17 -0
  21. package/dist/examples/autoresearch/frontiercs2-config.d.ts +2 -0
  22. package/dist/examples/autoresearch/frontiercs2-config.js +3 -0
  23. package/dist/examples/autoresearch/frontiercs2.d.ts +87 -0
  24. package/dist/examples/autoresearch/frontiercs2.js +211 -0
  25. package/dist/examples/autoresearch/prepare-demo.d.ts +1 -0
  26. package/dist/examples/autoresearch/prepare-demo.js +15 -0
  27. package/dist/examples/autoresearch/prepare.d.ts +95 -0
  28. package/dist/examples/autoresearch/prepare.js +257 -0
  29. package/dist/examples/autoresearch/process.d.ts +13 -0
  30. package/dist/examples/autoresearch/process.js +48 -0
  31. package/dist/examples/autoresearch/project.d.ts +21 -0
  32. package/dist/examples/autoresearch/project.js +392 -0
  33. package/dist/examples/autoresearch/research-service.d.ts +106 -0
  34. package/dist/examples/autoresearch/research-service.js +255 -0
  35. package/dist/examples/code/README.md +33 -0
  36. package/dist/examples/code/REQUIREMENTS.zh.md +11 -0
  37. package/dist/examples/code/candidate.d.ts +19 -0
  38. package/dist/examples/code/candidate.js +80 -0
  39. package/dist/examples/code/config.d.ts +32 -0
  40. package/dist/examples/code/config.js +18 -0
  41. package/dist/examples/code/eject.json +5 -0
  42. package/dist/examples/code/project.d.ts +3 -0
  43. package/dist/examples/code/project.js +605 -0
  44. package/dist/examples/code/prompts.d.ts +5 -0
  45. package/dist/examples/code/prompts.js +12 -0
  46. package/dist/examples/code/verification.d.ts +19 -0
  47. package/dist/examples/code/verification.js +268 -0
  48. package/dist/examples/code/worktree.d.ts +17 -0
  49. package/dist/examples/code/worktree.js +233 -0
  50. package/dist/examples/harness-session/README.md +3 -6
  51. package/dist/examples/lead-worker/harness/dynamic-scheduler.d.ts +2 -1
  52. package/dist/examples/lead-worker/harness/dynamic-scheduler.js +5 -2
  53. package/dist/examples/lead-worker/harness/index.d.ts +60 -0
  54. package/dist/examples/lead-worker/harness/index.js +77 -6
  55. package/dist/examples/lead-worker/project.js +2 -2
  56. package/dist/examples/lead-worker/services/board.d.ts +5 -0
  57. package/dist/examples/lead-worker/services/board.js +19 -1
  58. package/dist/examples/messages/README.md +5 -5
  59. package/dist/examples/messages/handoff.d.ts +2 -0
  60. package/dist/examples/messages/handoff.js +5 -1
  61. package/dist/examples/messages/project.js +52 -2
  62. package/dist/examples/notes/README.md +13 -18
  63. package/dist/examples/notes/project.js +67 -6
  64. package/dist/examples/peermesh/harness/router.js +3 -1
  65. package/dist/examples/peermesh/harness/team.d.ts +8 -0
  66. package/dist/examples/peermesh/harness/team.js +13 -0
  67. package/dist/examples/peermesh/project.js +22 -4
  68. package/dist/examples/services/agent-control/README.md +3 -3
  69. package/dist/examples/services/mathlib-search/Dockerfile +4 -2
  70. package/dist/examples/services/mathlib-search/README.md +1 -1
  71. package/dist/examples/services/mcp-managed/README.md +2 -2
  72. package/dist/examples/services/persistent-board/README.md +16 -3
  73. package/dist/examples/services/persistent-board/business.d.ts +7 -0
  74. package/dist/examples/services/persistent-board/business.js +7 -0
  75. package/dist/examples/services/persistent-board/index.js +10 -0
  76. package/dist/examples/services/persistent-board/live.d.ts +3 -0
  77. package/dist/examples/services/persistent-board/live.js +58 -0
  78. package/dist/examples/subagents/README.md +5 -5
  79. package/dist/examples/subagents/business.js +3 -1
  80. package/dist/examples/subagents/config.js +3 -3
  81. package/dist/examples/subagents/harness/controller.d.ts +15 -0
  82. package/dist/examples/subagents/harness/controller.js +181 -32
  83. package/dist/examples/subagents/project.d.ts +2 -0
  84. package/dist/examples/subagents/project.js +43 -34
  85. package/dist/examples/subagents/prompts/prompts.d.ts +1 -0
  86. package/dist/examples/subagents/prompts/prompts.js +3 -0
  87. package/dist/examples/subagents/services/collaboration-service.d.ts +3 -2
  88. package/dist/examples/subagents/services/collaboration-service.js +14 -2
  89. package/dist/examples/substrate/README.md +2 -2
  90. package/dist/examples/substrate/harness/index.d.ts +1 -1
  91. package/dist/examples/substrate/harness/index.js +77 -12
  92. package/dist/examples/substrate/project.js +4 -1
  93. package/dist/examples/super/README.md +52 -0
  94. package/dist/examples/super/actions.d.ts +95 -0
  95. package/dist/examples/super/actions.js +230 -0
  96. package/dist/examples/super/artifact.d.ts +4 -0
  97. package/dist/examples/super/artifact.js +51 -0
  98. package/dist/examples/super/config.d.ts +80 -0
  99. package/dist/examples/super/config.js +83 -0
  100. package/dist/examples/super/coordinator.d.ts +33 -0
  101. package/dist/examples/super/coordinator.js +151 -0
  102. package/dist/examples/super/daemon.d.ts +11 -0
  103. package/dist/examples/super/daemon.js +109 -0
  104. package/dist/examples/super/decisions.d.ts +8 -0
  105. package/dist/examples/super/decisions.js +52 -0
  106. package/dist/examples/super/eject.json +5 -0
  107. package/dist/examples/super/execution.d.ts +11 -0
  108. package/dist/examples/super/execution.js +136 -0
  109. package/dist/examples/super/github.d.ts +62 -0
  110. package/dist/examples/super/github.js +269 -0
  111. package/dist/examples/super/inbox.d.ts +162 -0
  112. package/dist/examples/super/inbox.js +284 -0
  113. package/dist/examples/super/location.d.ts +5 -0
  114. package/dist/examples/super/location.js +64 -0
  115. package/dist/examples/super/operator.d.ts +1 -0
  116. package/dist/examples/super/operator.js +31 -0
  117. package/dist/examples/super/outbox.d.ts +5 -0
  118. package/dist/examples/super/outbox.js +103 -0
  119. package/dist/examples/super/project.d.ts +4 -0
  120. package/dist/examples/super/project.js +251 -0
  121. package/dist/examples/super/prompts.d.ts +3 -0
  122. package/dist/examples/super/prompts.js +25 -0
  123. package/dist/examples/taskpool/deploy/service-hosts/Dockerfile +4 -2
  124. package/dist/examples/taskpool/harness/controller.d.ts +35 -6
  125. package/dist/examples/taskpool/harness/controller.js +73 -7
  126. package/dist/examples/taskpool/project.js +18 -2
  127. package/dist/scripts/anyswarm-arguments.d.ts +18 -6
  128. package/dist/scripts/anyswarm-arguments.js +88 -52
  129. package/dist/scripts/anyswarm-author.d.ts +5 -0
  130. package/dist/scripts/anyswarm-author.js +24 -0
  131. package/dist/scripts/anyswarm-eject.d.ts +11 -0
  132. package/dist/scripts/anyswarm-eject.js +164 -0
  133. package/dist/scripts/anyswarm-harnesses.d.ts +1 -0
  134. package/dist/scripts/anyswarm-harnesses.js +10 -0
  135. package/dist/scripts/anyswarm-installation.d.ts +7 -40
  136. package/dist/scripts/anyswarm-installation.js +17 -285
  137. package/dist/scripts/anyswarm-launch.d.ts +7 -0
  138. package/dist/scripts/anyswarm-launch.js +37 -0
  139. package/dist/scripts/anyswarm-progress.d.ts +6 -0
  140. package/dist/scripts/anyswarm-progress.js +102 -0
  141. package/dist/scripts/anyswarm-project.d.ts +3 -1
  142. package/dist/scripts/anyswarm-project.js +49 -35
  143. package/dist/scripts/anyswarm-source-runner.d.ts +1 -0
  144. package/dist/scripts/anyswarm-source-runner.js +200 -0
  145. package/dist/scripts/anyswarm.js +28 -3
  146. package/dist/scripts/build-provenance.json +1 -0
  147. package/dist/scripts/build.js +7 -1
  148. package/dist/scripts/generate-architecture-api.js +2 -0
  149. package/dist/scripts/generate-architecture-prompts.js +24 -2
  150. package/dist/scripts/local-environment.d.ts +13 -2
  151. package/dist/scripts/local-environment.js +111 -28
  152. package/dist/scripts/local-setup-smoke.js +3 -2
  153. package/dist/scripts/local-setup-worker.d.ts +1 -1
  154. package/dist/scripts/local-setup-worker.js +15 -6
  155. package/dist/scripts/local-setup.d.ts +5 -2
  156. package/dist/scripts/local-setup.js +167 -79
  157. package/dist/scripts/opensandbox-agent-worker.js +2 -2
  158. package/dist/scripts/pack-release.d.ts +1 -0
  159. package/dist/scripts/pack-release.js +66 -0
  160. package/dist/scripts/pi-session-bridge.js +11 -3
  161. package/dist/scripts/run-harness.js +3 -1
  162. package/dist/scripts/setup-bootstrap.js +43 -6
  163. package/dist/src/core/allocation-ledger.js +4 -3
  164. package/dist/src/core/host-identity.d.ts +2 -0
  165. package/dist/src/core/host-identity.js +11 -0
  166. package/dist/src/core/index.d.ts +4 -2
  167. package/dist/src/core/index.js +12 -4
  168. package/dist/src/core/mcp-service.js +2 -2
  169. package/dist/src/core/runtime-management.d.ts +6 -0
  170. package/dist/src/core/runtime-management.js +24 -0
  171. package/dist/src/core/sandbox/executor-driver.d.ts +4 -2
  172. package/dist/src/core/sandbox/executor-driver.js +12 -14
  173. package/dist/src/core/sandbox/local-executor.d.ts +13 -1
  174. package/dist/src/core/sandbox/local-executor.js +69 -19
  175. package/dist/src/core/sandbox/local-worker.js +32 -21
  176. package/dist/src/core/sandbox/opensandbox-backend.d.ts +2 -0
  177. package/dist/src/core/sandbox/opensandbox-backend.js +36 -11
  178. package/dist/src/core/sandbox/sandbox-connection.d.ts +2 -0
  179. package/dist/src/core/sandbox/sandbox-connection.js +14 -6
  180. package/dist/src/core/service-live-state.d.ts +14 -0
  181. package/dist/src/core/service-live-state.js +161 -0
  182. package/dist/src/core/service-observation-types.d.ts +21 -1
  183. package/dist/src/core/service-process.d.ts +1 -1
  184. package/dist/src/core/service-process.js +45 -4
  185. package/dist/src/core/service-types.d.ts +5 -1
  186. package/dist/src/core/services.d.ts +1 -1
  187. package/dist/src/core/services.js +8 -3
  188. package/dist/src/core/types.d.ts +3 -0
  189. package/dist/src/core/worker-image.js +3 -3
  190. package/dist/src/harness/harness-session-types.d.ts +10 -0
  191. package/dist/src/harness/harness-session.js +42 -5
  192. package/dist/src/harness/project-harness.d.ts +14 -1
  193. package/dist/src/harness/project-harness.js +38 -12
  194. package/dist/src/harness/project-input.js +81 -15
  195. package/dist/src/harness/project-rpc-client.d.ts +1 -0
  196. package/dist/src/harness/project-rpc-client.js +5 -0
  197. package/dist/src/harness/project-rpc.d.ts +8 -2
  198. package/dist/src/harness/project-rpc.js +31 -7
  199. package/dist/src/harness/project-runtime.js +6 -2
  200. package/dist/src/harness/typescript-loader.d.ts +2 -0
  201. package/dist/src/harness/typescript-loader.js +41 -0
  202. package/dist/src/trace-viewer/public/app.js +6 -5
  203. package/dist/src/trace-viewer/reader.mjs +42 -2
  204. package/docs/INDEX.md +5 -2
  205. package/docs/architecture/00-overview.md +1 -1
  206. package/docs/architecture/01-agent-core.md +1 -1
  207. package/docs/architecture/04-services.md +1 -1
  208. package/docs/architecture/06-observability-experiments.md +1 -1
  209. package/docs/architecture/07-run-configuration.md +38 -18
  210. package/docs/architecture/08-prompts.md +22 -0
  211. package/docs/architecture/10-service-api-reference.md +53 -18
  212. package/docs/architecture/11-storage-reference.md +18 -1
  213. package/docs/architecture/12-code-coverage.md +152 -89
  214. package/docs/architecture/15-core-runtime.md +8 -0
  215. package/docs/architecture/16-pi-opensandbox-backend.md +5 -5
  216. package/docs/architecture/17-harness-reporting.md +1 -1
  217. package/docs/architecture/19-substrate-harness.md +28 -1
  218. package/docs/architecture/20-lead-worker-harness.md +34 -1
  219. package/docs/architecture/22-website.md +5 -6
  220. package/docs/architecture/23-project-harness.md +152 -8
  221. package/docs/architecture/24-runtime-recovery.md +10 -3
  222. package/docs/architecture/26-code.md +54 -0
  223. package/docs/architecture/27-personal.md +58 -0
  224. package/docs/architecture/28-autoresearch.md +43 -0
  225. package/docs/architecture/INDEX.md +3 -0
  226. package/docs/architecture/prompts/08-lead-worker-harness.md +4 -2
  227. package/docs/architecture/prompts/08-subagents-harness.md +21 -0
  228. package/docs/architecture/prompts/21-personal.md +44 -0
  229. package/docs/architecture/prompts/22-autoresearch.md +63 -0
  230. package/docs/architecture/prompts/26-code.md +55 -0
  231. package/docs/architecture/prompts/source-manifest.json +152 -33
  232. package/docs/architecture/source-map.json +473 -25
  233. package/docs/designs/core-harness/01-core.md +2 -2
  234. package/docs/designs/core-harness/06-project-harness.md +13 -2
  235. package/docs/designs/core-harness/README.md +7 -2
  236. package/docs/en/agents.md +1 -1
  237. package/docs/en/build-your-harness.md +3 -5
  238. package/docs/en/changelog.md +20 -4
  239. package/docs/en/first-harness.md +9 -12
  240. package/docs/en/harnesses/lead-worker.md +1 -1
  241. package/docs/en/harnesses/peermesh.md +2 -2
  242. package/docs/en/harnesses/subagents.md +2 -2
  243. package/docs/en/harnesses/substrate.md +4 -4
  244. package/docs/en/harnesses/taskpool.md +2 -2
  245. package/docs/en/latest.md +14 -121
  246. package/docs/en/overview.md +1 -1
  247. package/docs/en/quickstart.md +42 -39
  248. package/docs/en/reference/api.md +14 -4
  249. package/docs/en/reference/cli.md +53 -47
  250. package/docs/en/runtime.md +2 -2
  251. package/docs/en/sandbox.md +3 -3
  252. package/docs/en/services.md +4 -0
  253. package/docs/operations/trace-viewer.md +1 -1
  254. package/docs/workflows/development.md +28 -21
  255. package/docs/workflows/release-and-docs-versioning.md +77 -0
  256. package/docs/workflows/release-cli-acceptance.md +85 -0
  257. package/docs/zh/agents.md +1 -1
  258. package/docs/zh/build-your-harness.md +3 -5
  259. package/docs/zh/changelog.md +20 -4
  260. package/docs/zh/first-harness.md +9 -12
  261. package/docs/zh/harnesses/lead-worker.md +1 -1
  262. package/docs/zh/harnesses/peermesh.md +2 -2
  263. package/docs/zh/harnesses/subagents.md +2 -2
  264. package/docs/zh/harnesses/substrate.md +4 -4
  265. package/docs/zh/harnesses/taskpool.md +2 -2
  266. package/docs/zh/latest.md +15 -122
  267. package/docs/zh/overview.md +1 -1
  268. package/docs/zh/quickstart.md +42 -39
  269. package/docs/zh/reference/api.md +14 -4
  270. package/docs/zh/reference/cli.md +24 -40
  271. package/docs/zh/runtime.md +2 -2
  272. package/docs/zh/sandbox.md +3 -3
  273. package/docs/zh/services.md +4 -0
  274. package/examples/README.md +35 -12
  275. package/examples/authoring/README.md +24 -0
  276. package/examples/authoring/business.ts +4 -0
  277. package/examples/authoring/config.ts +2 -0
  278. package/examples/authoring/eject.json +5 -0
  279. package/examples/authoring/harness.ts +21 -0
  280. package/examples/autoresearch/README.md +40 -0
  281. package/examples/autoresearch/REQUIREMENTS.zh.md +11 -0
  282. package/examples/autoresearch/config.ts +90 -0
  283. package/examples/autoresearch/demo.ts +55 -0
  284. package/examples/autoresearch/eject.json +17 -0
  285. package/examples/autoresearch/frontiercs2-config.ts +4 -0
  286. package/examples/autoresearch/frontiercs2.ts +237 -0
  287. package/examples/autoresearch/prepare-demo.ts +15 -0
  288. package/examples/autoresearch/prepare.ts +267 -0
  289. package/examples/autoresearch/process.ts +50 -0
  290. package/examples/autoresearch/project.ts +380 -0
  291. package/examples/autoresearch/research-service.ts +302 -0
  292. package/examples/code/README.md +33 -0
  293. package/examples/code/REQUIREMENTS.zh.md +11 -0
  294. package/examples/code/candidate.ts +89 -0
  295. package/examples/code/config.ts +19 -0
  296. package/examples/code/eject.json +5 -0
  297. package/examples/code/project.ts +581 -0
  298. package/examples/code/prompts.ts +16 -0
  299. package/examples/code/verification.ts +239 -0
  300. package/examples/code/worktree.ts +188 -0
  301. package/examples/harness-session/README.md +3 -6
  302. package/examples/lead-worker/harness/dynamic-scheduler.ts +6 -3
  303. package/examples/lead-worker/harness/index.ts +61 -6
  304. package/examples/lead-worker/project.ts +2 -2
  305. package/examples/lead-worker/services/board.ts +14 -1
  306. package/examples/messages/README.md +5 -5
  307. package/examples/messages/handoff.ts +6 -2
  308. package/examples/messages/project.ts +47 -2
  309. package/examples/notes/README.md +13 -18
  310. package/examples/notes/project.ts +57 -9
  311. package/examples/peermesh/harness/router.ts +2 -2
  312. package/examples/peermesh/harness/team.ts +11 -0
  313. package/examples/peermesh/project.ts +19 -4
  314. package/examples/services/agent-control/README.md +3 -3
  315. package/examples/services/mathlib-search/Dockerfile +4 -2
  316. package/examples/services/mathlib-search/README.md +1 -1
  317. package/examples/services/mcp-managed/README.md +2 -2
  318. package/examples/services/persistent-board/README.md +16 -3
  319. package/examples/services/persistent-board/business.ts +10 -0
  320. package/examples/services/persistent-board/index.ts +10 -0
  321. package/examples/services/persistent-board/live.ts +54 -0
  322. package/examples/subagents/README.md +5 -5
  323. package/examples/subagents/business.ts +3 -1
  324. package/examples/subagents/config.ts +4 -3
  325. package/examples/subagents/harness/controller.ts +161 -29
  326. package/examples/subagents/project.ts +47 -33
  327. package/examples/subagents/prompts/prompts.ts +4 -0
  328. package/examples/subagents/services/collaboration-service.ts +14 -2
  329. package/examples/substrate/README.md +2 -2
  330. package/examples/substrate/harness/index.ts +67 -11
  331. package/examples/substrate/project.ts +5 -1
  332. package/examples/super/README.md +52 -0
  333. package/examples/super/actions.ts +196 -0
  334. package/examples/super/artifact.ts +56 -0
  335. package/examples/super/config.ts +95 -0
  336. package/examples/super/coordinator.ts +158 -0
  337. package/examples/super/daemon.ts +84 -0
  338. package/examples/super/decisions.ts +46 -0
  339. package/examples/super/eject.json +5 -0
  340. package/examples/super/execution.ts +131 -0
  341. package/examples/super/github.ts +242 -0
  342. package/examples/super/inbox.ts +306 -0
  343. package/examples/super/location.ts +54 -0
  344. package/examples/super/operator.ts +28 -0
  345. package/examples/super/outbox.ts +97 -0
  346. package/examples/super/project.ts +225 -0
  347. package/examples/super/prompts.ts +27 -0
  348. package/examples/taskpool/deploy/service-hosts/Dockerfile +4 -2
  349. package/examples/taskpool/harness/controller.ts +59 -7
  350. package/examples/taskpool/project.ts +18 -2
  351. package/npm-shrinkwrap.development.json +700 -0
  352. package/npm-shrinkwrap.json +95 -1969
  353. package/package.development.json +88 -0
  354. package/package.json +11 -8
  355. package/scripts/anyswarm-arguments.ts +91 -54
  356. package/scripts/anyswarm-author.ts +25 -0
  357. package/scripts/anyswarm-eject.ts +145 -0
  358. package/scripts/anyswarm-harnesses.ts +10 -0
  359. package/scripts/anyswarm-installation.ts +18 -288
  360. package/scripts/anyswarm-launch.ts +36 -0
  361. package/scripts/anyswarm-progress.ts +95 -0
  362. package/scripts/anyswarm-project.ts +35 -34
  363. package/scripts/anyswarm-source-runner.ts +176 -0
  364. package/scripts/anyswarm.ts +24 -3
  365. package/scripts/build.ts +8 -1
  366. package/scripts/generate-architecture-api.ts +2 -0
  367. package/scripts/generate-architecture-prompts.ts +35 -2
  368. package/scripts/local-environment.ts +117 -28
  369. package/scripts/local-setup-smoke.ts +3 -2
  370. package/scripts/local-setup-worker.ts +17 -7
  371. package/scripts/local-setup.ts +166 -73
  372. package/scripts/opensandbox-agent-worker.ts +2 -2
  373. package/scripts/pack-release.ts +70 -0
  374. package/scripts/pi-session-bridge.ts +10 -2
  375. package/scripts/run-harness.ts +3 -1
  376. package/scripts/setup-bootstrap.ts +41 -6
  377. package/src/core/allocation-ledger.ts +5 -3
  378. package/src/core/host-identity.ts +11 -0
  379. package/src/core/index.ts +12 -6
  380. package/src/core/mcp-service.ts +2 -2
  381. package/src/core/runtime-management.ts +22 -0
  382. package/src/core/sandbox/executor-driver.ts +15 -18
  383. package/src/core/sandbox/local-executor.ts +65 -19
  384. package/src/core/sandbox/local-worker.ts +29 -21
  385. package/src/core/sandbox/opensandbox-backend.ts +36 -11
  386. package/src/core/sandbox/sandbox-connection.ts +14 -5
  387. package/src/core/service-live-state.ts +156 -0
  388. package/src/core/service-observation-types.ts +23 -1
  389. package/src/core/service-process.ts +36 -3
  390. package/src/core/service-types.ts +3 -1
  391. package/src/core/services.ts +8 -3
  392. package/src/core/types.ts +3 -0
  393. package/src/core/worker-image.ts +3 -3
  394. package/src/harness/harness-session-types.ts +13 -1
  395. package/src/harness/harness-session.ts +40 -7
  396. package/src/harness/project-harness.ts +38 -12
  397. package/src/harness/project-input.ts +73 -15
  398. package/src/harness/project-rpc-client.ts +5 -0
  399. package/src/harness/project-rpc.ts +29 -8
  400. package/src/harness/project-runtime.ts +4 -2
  401. package/src/harness/typescript-loader.ts +37 -0
  402. package/src/trace-viewer/public/app.js +6 -5
  403. package/src/trace-viewer/reader.mjs +42 -2
@@ -18,6 +18,14 @@ Core delivers detached events in registration order. Nested publication queues e
18
18
 
19
19
  The internal Worker continuity cursor, native/tool and Bridge traces and the ordered evidence ledger remain available to [offline Run inspection](17-harness-reporting.md#native-trace-and-bridge-attempts). Their sequence and gap records belong to persisted diagnostics.
20
20
 
21
+ ### Live Service state
22
+
23
+ The owner of the Runtime can call `runtime.services.listState()` for names and support flags, then `runtime.services.readState(name)` for one current sample from a ready Service. The registry captures the optional `ServiceAdapter.readState({ signal })` hook when it binds the adapter. The in-process helper also accepts the hook in its third argument. Discovery and Agent grants continue to describe the Service operations. Neither the Bridge nor an Agent can invoke the observation hook through those operations.
24
+
25
+ The Service chooses which public fields to return under `state` and supplies its actual capture time and optional business revision. The Runtime validates plain JSON data, the timestamp and the declarative summary/table paths, redacts recognized secrets, normalizes the time to UTC, and returns a detached copy. Each read is limited to 64 KiB of serialized output and 32 levels of JSON nesting. Display metadata permits up to 16 summary fields, four tables and up to 16 columns per table. There are eight concurrent reads per Runtime and one underlying read for each Service instance. Concurrent readers of that instance share the capture. A deadline of one second signals abort and returns `timeout`. A hook that ignores abort retains its slot until it settles, preventing repeated refreshes from launching more work on that instance. Service authors should pass the signal into I/O and keep synchronous work short.
26
+
27
+ A malformed sample or provider exception returns a generic error. Unknown, unready and temporarily capacity-limited Services return `unavailable`; a ready adapter without a hook returns `unsupported`. Failure receipts include the most recent successful capture time for the same Service instance where available. Stop, retirement and Runtime close cancel reads, and a replacement instance starts with no capture history. Late results after a fence are discarded. The reader holds only the capture time between reads and makes no storage writes. The closing and retirement `exportState` path still writes its own snapshot and trace metadata independently.
28
+
21
29
  ## Framework failure facts
22
30
 
23
31
  `ErrorInfo` keeps `code`, `message` and `retryable` and can include an optional `diagnostic` for Host callers. Schema version 1 contains an observing `layer`, `stage`, `category`, `nextStep`, optional scoped identities and a closed set of facts. Runtime, Agent, model request, exclusive input request, input and control operation identities have different fields. Producers supply only identities they actually know. A missing field carries no inferred default. HTTP status, validated upstream request identity, rejection kind and delta-seconds Retry-After are bounded observations. The latter is an upstream hint. The existing retry behavior remains controlled by its original owner.
@@ -25,7 +25,7 @@ Required archive or artifact failure retains the Sandbox and Slot. Its pending r
25
25
 
26
26
  ## Codex App Server
27
27
 
28
- Select the local npm Codex CLI 0.172.0 using `anyswarm setup --backend codex`. The built Worker contains the selected program snapshot and the AnySwarm app-server driver. An explicit compatible image and executor selection are also supported. Configure the model as a streaming OpenAI Responses route.
28
+ Select the installed Codex using `anyswarm setup --backend codex`. The Worker starts the same exact CLI version and checks App Server initialization before accepting input. The built Worker contains the selected program snapshot and the AnySwarm app-server driver. An explicit compatible image and executor selection are also supported. Configure the model as a streaming OpenAI Responses route.
29
29
 
30
30
  The manager first checks the CLI and Node versions inside the guest. It then makes the authenticated `anyswarm-core-v2` start request with the fixed work directory, empty resources, file/permission policy, rendered prompt, model alias selection and gateway address. The Worker verifies the identity, directory and startup contract, installs the same file seed and opens private per-Agent runtime directories. It writes an isolated `CODEX_HOME/config.toml`, bootstraps App Server over stdin/stdout under the non-root Agent UID with no-new-privileges and cleared capabilities, and sends `initialize`, `initialized` and `thread/start`. App Server receives the staged role and Service instructions as `baseInstructions`. The guest uses the existing outer Sandbox controls for filesystem and process isolation. Web search, native subagents and remote plugins are disabled in the shipped configuration. The manager compares the startup receipt's executor, version, auth mode and thread ID before Core's bounded `get_state` check returns an idle Agent. The spawn-ready observation records these guest facts separately from the Runtime configuration.
31
31
 
@@ -128,13 +128,13 @@ The opt-in Worker RPC probe in `test/core-worker-rpc-real.test.ts` uses the Core
128
128
 
129
129
  Host setup and explicit `doctor --smoke` use one temporary Runtime and the requested Pi or Codex executor. Project configuration supplies the actual Bridge, Gateway, resource and isolation settings. A loopback model server implements a fixed three-request sequence and one additional same-Session turn for Chat Completions. For an external executor the probe verifies actual guest startup, streams a fixed initial file and collects its bytes without submitting model work. The Runtime registers a read-only in-process `setup-probe` Service, spawns a writable Agent and subscribes for settlement before submitting its fixed follow-up. It proceeds only after an accepted receipt.
130
130
 
131
- The first response requests the executor's shell tool to invoke `setup-probe verify` through `swarm` and write fixed bytes. The second asks the executor to read the marker. The server checks the exact returned contents before emitting `SETUP_OK`. The host checks the Service caller, request count, read result and settlement. Stop collects the bounded project through the Worker protocol. The host compares the exported bytes and requires confirmed deletion on the original lifecycle API.
131
+ The smoke Profile exposes its fixed Service through the CLI for Codex. The first response requests the executor's shell tool to invoke `setup-probe verify` through `swarm` and write fixed bytes. The second asks the executor to read the marker. The server checks the exact returned contents before emitting `SETUP_OK`. The host checks the Service caller, request count, read result and settlement. Stop collects the bounded project through the Worker protocol. The host compares the exported bytes and requires confirmed deletion on the original lifecycle API.
132
132
 
133
133
  The work deadline is 100 seconds. Stop has a 25-second budget and Runtime close has a separate 30-second budget, including during cancellation. The probe closes its local Responses server and removes its temporary evidence after confirmed cleanup. If close remains pending, it retains Runtime and resource identities and an evidence directory for diagnosis. [Setup and doctor](07-run-configuration.md#local-setup-and-doctor) keep separate receipts for managed provider ownership.
134
134
 
135
135
  ## Image-installed executor adapter
136
136
 
137
- Runtime resolves its single executor before opening listeners, and verifies model protocols and Profile capabilities at that point. A local Worker takes its version from the selected host installation. This SDK validates Pi 1.3.0 and 1.4.0 and Codex 0.172.0. Worker preparation verifies the immutable package snapshot in the Docker build. The manager independently probes the actual executor and version inside each Sandbox during allocation. [Local preparation](07-run-configuration.md#executor-and-file-policy-selection) describes content identity, credentials and caching.
137
+ Runtime resolves its single executor before opening listeners, and verifies model protocols and Profile capabilities at that point. A local Worker takes its version from the selected host installation. An optional exact pin must match that installation. An explicitly provided image outside managed local preparation requires the deployment’s selected version. Existing unpinned image configurations retain their historical Pi 1.3.0 and Codex 0.172.0 expectations; a caller can pin any exact version. Managed local setup pins explicit images to their inspected built-in version for its smoke probe. Worker preparation verifies the immutable package snapshot in the Docker build. The manager independently probes the actual executor and version inside each Sandbox during allocation. [Local preparation](07-run-configuration.md#executor-and-file-policy-selection) describes content identity, credentials and caching.
138
138
 
139
139
  External adapter configurations import a trusted Host module with `createExecutorAdapter`. Its identity, compatible versions, selected version, image, model protocol IDs, and declared capabilities are copied and frozen. The Worker resolves the external identity to `/opt/anyswarm/executors/<kind>.json` in the selected image. The directory must be root-owned, traversal-accessible to the Agent and writable only by root. The descriptor is a root-owned regular JSON file up to 32 KiB. It specifies `kind`, `protocol`, `version`, `capabilities`, `command` (absolute executable), `args` and `versionArgs`. The protocol is `anyswarm-executor-v1`. The worker compares normalized capabilities, protocol and expected version, then requires the executable's probe to print exactly the selected version within five seconds. The probe and persistent process run under the non-root Agent UID with no-new-privileges and cleared capabilities. Correct labels help local setup select the image. The runtime trusts the actual guest probe and startup receipt, including its declared capabilities. Where image digest identity is required, use a digest reference in the Profile.
140
140
 
@@ -156,7 +156,7 @@ A rejected startup confirms stop and deletes its Sandbox without attempting to e
156
156
 
157
157
  After creating the native Session but before publishing readiness or accepting input, the bridge compares an explicit Profile/spawn `thinkingLevel` (or the internal `--thinking` argument) with `session.getAvailableThinkingLevels()` and the actual `session.thinkingLevel`. Unsupported requests dispose the unused Session and retain an actionable `INVALID_CONTRACT` startup failure with the available levels; no model request is made. A native mismatch after a supported selection uses `EXECUTOR_CAPABILITY_MISMATCH`. This failed bridge publishes no readiness event and rejects subsequent commands through the ordinary correlated RPC response until Worker cleanup stops it. Normal stdin EOF exits with status 1; forced Worker cleanup may terminate it by signal. The Host preserves the matching readiness `get_state` failure's code and message. `Runtime.spawn` exposes the code and error details with the existing pending cleanup receipt; owned-resource stop and deletion then complete asynchronously. This diagnostic does not depend on the Worker forwarding private stderr. Omitted thinking configuration retains Pi's default, including its handling of a restored Session. Dynamic configure performs the same capability check before any setters; an unsupported level cannot partially apply other fields in the patch. The existing state query reports actual settings and available levels, and successful native changes keep their existing settings events and operation receipts.
158
158
 
159
- The Pi 1.3.0 and 1.4.0 bridge tracks the exact native object handed to Pi’s steer, follow-up, deferred append or start path. It observes the native SessionManager write before reporting an appended context, and the disposition records the input ID, native entry ID and public message ID. Interrupt clears the native queue and waits for abort before discarding remaining inputs. An append committed at a safe boundary during that wait remains in the archive. Inputs whose generation expired cannot start deferred work, and a discarded append is removed from the native pending list. The identity is stored in bridge-owned maps. The model and archive keep the user’s custom type, content, display and details.
159
+ The Pi bridge checks the installed SDK exports at startup and tracks the exact native object handed to Pi’s steer, follow-up, deferred append or start path. It observes the native SessionManager write before reporting an appended context, and the disposition records the input ID, native entry ID and public message ID. Interrupt clears the native queue and waits for abort before discarding remaining inputs. An append committed at a safe boundary during that wait remains in the archive. Inputs whose generation expired cannot start deferred work, and a discarded append is removed from the native pending list. The identity is stored in bridge-owned maps. The model and archive keep the user’s custom type, content, display and details.
160
160
 
161
161
  The event stream gives each live message a stable ID and binds that ID at native persistence. Assistant start, delta and end share the stream identity even though Pi emits new objects for its partial updates. `getMessages` projects the active native entries and their parts. Each entry or compaction-summary part has a unique ID regardless of content and timestamps. The Host forwards the bridge’s message ID when present and preserves the delta block index.
162
162
 
@@ -166,7 +166,7 @@ Core checks the authenticated Worker contract for `pi_session_protocol: pi-sessi
166
166
 
167
167
  When the Worker advertises the protocol, Pi startup carries `piSession` with the resolved per-Agent configuration and an optional finite before-compact timeout. The Worker selects the installed Guest SDK bridge for this payload. The bridge resolves Pi from the Worker executor installation and creates the same persistent SDK Session used for ordinary prompts, queued input, context, queries, compaction, retry cancellation and archival. Host modules import anyswarm-owned types. The bridge loads explicit resources through the SDK and emits `core_session_ready` with its Pi version, capability flags and loading observations before readiness completes. A configured Session or hook also requires this readiness attestation.
168
168
 
169
- For a Worker that supports cursor reads, the Backend observes startup and Session RPC events through the authenticated cursor route. A durable Run commits those events before returning the correlated reply. A missing event, unavailable transport or unconfirmed cursor leaves the reply unknown. The initial Session version and capabilities are checked before the durable checkpoint is written. Event records bundled with RPC replies supply the observation target.
169
+ For a Worker that supports cursor reads, the Backend observes startup and Session RPC events through the authenticated cursor route. A durable Run commits those events before returning the correlated reply. A missing event, unavailable transport or unconfirmed cursor leaves the reply unknown. The initial Session version and capabilities are checked before the durable checkpoint is written. Event records bundled with RPC replies supply the observation target. Background polling and Session reply confirmation share one serialized event reader per Agent. A queued read checks cancellation and takes its cursor after the preceding page commits. Reply confirmation first waits for an active page and rechecks whether that page has already reached its target sequence. This preserves the Worker single-read guard without treating an applied Session operation as unknown merely because its event arrived during a long poll. Different Agents retain independent readers; transport failures and genuine continuity gaps retain the existing unknown and fencing behavior.
170
170
 
171
171
  The backend verifies the ready version and Session capability object against the selected driver. Codex and external adapters expose these additions only through explicit declarations. The built-in Pi driver declares configure, compact, abortRetry, clearQueue, state, stats, messages, context and beforeCompact. A new Host declaration alone cannot establish actual Guest support.
172
172
 
@@ -302,7 +302,7 @@ The installed-package case uses the same archive installation helper and SHA-256
302
302
 
303
303
  ### Installed native PeerMesh foreground acceptance
304
304
 
305
- The package currently declares the `swarm` tool binary. The installed foreground host is invoked explicitly as `node node_modules/@anyswarm/core/dist/scripts/run-harness.js --config ./host-config.mjs`; there is no `swarm-environment` binary alias. `test/peermesh-installed-native.test.ts` adds an opt-in archive-backed acceptance at that entry. Enable only after independent source/archive/image/fixture reviews with `ANYSWARM_PEERMESH_INSTALLED_REAL_TEST=1 ANYSWARM_CORE_TEST_IMAGE=sha256:<reviewed-image> node --test dist/test/peermesh-installed-native.test.js`. The shared installer accepts `ANYSWARM_TEST_PACKAGE_ARCHIVE` and `ANYSWARM_TEST_PACKAGE_SHA256` together, snapshots and verifies those bytes before offline npm installation, and otherwise requires a clean source checkout and builds that checkout through npm prepack before installation. Ordinary package regressions reuse the build created by npm test. The installer removes inherited Node loader overrides. Deterministic package checks normally install in OS temporary storage and remove their installations. Native gates prefer `/var/tmp`, falling back to the configured temporary root and `/tmp` only when those roots have no real checkout ancestry. The installer resolves symlinks and rejects roots beneath either a `.git` directory or linked-worktree `.git` file; a caller-provided private parent inside a checkout fails with `INSTALL_PARENT_IN_CHECKOUT`. A checkout-owned HOME is rejected with `INSTALL_HOME_IN_CHECKOUT`, rather than enabling Node's home-based module fallback. Explicit parents must be existing non-symlink host-owned directories with mode 0700; consumer directories are also mode 0700. Offline npm uses the existing host cache, while npm and runtime subprocesses execute from the external consumer; no source checkout supplies module resolution.
305
+ The package declares `anyswarm` as its host command. The Worker image provides its internal `swarm` command. The installed native PeerMesh acceptance invokes the foreground host explicitly as `node node_modules/@anyswarm/core/dist/scripts/run-harness.js --config ./host-config.mjs`. `test/peermesh-installed-native.test.ts` adds an opt-in archive-backed acceptance at that entry. Enable only after independent source/archive/image/fixture reviews with `ANYSWARM_PEERMESH_INSTALLED_REAL_TEST=1 ANYSWARM_CORE_TEST_IMAGE=sha256:<reviewed-image> node --test dist/test/peermesh-installed-native.test.js`. The shared installer accepts `ANYSWARM_TEST_PACKAGE_ARCHIVE` and `ANYSWARM_TEST_PACKAGE_SHA256` together, snapshots and verifies those bytes before offline npm installation, and otherwise builds the clean source checkout with the release packer before native acceptance. Ordinary package regressions call the same packer with `--skip-build` and reuse the build created by npm test. The installer removes inherited Node loader overrides. Deterministic package checks normally install in OS temporary storage and remove their installations. Native gates prefer `/var/tmp`, falling back to the configured temporary root and `/tmp` only when those roots have no real checkout ancestry. The installer resolves symlinks and rejects roots beneath either a `.git` directory or linked-worktree `.git` file; a caller-provided private parent inside a checkout fails with `INSTALL_PARENT_IN_CHECKOUT`. A checkout-owned HOME is rejected with `INSTALL_HOME_IN_CHECKOUT`, rather than enabling Node's home-based module fallback. Explicit parents must be existing non-symlink host-owned directories with mode 0700; consumer directories are also mode 0700. Offline npm uses the existing host cache, while npm and runtime subprocesses execute from the external consumer; no source checkout supplies module resolution.
306
306
 
307
307
  The installed Notes and Subagents examples select the Runtime's executor from their trusted `backend.executor` configuration, which defaults to Pi. On Codex, the Notes writer and reader each continue on their own App Server thread. The Subagents assembly disables Context Fork for Codex and the registered collaboration manifest requires `fork_turns: "none"` when spawning a child. Both examples use the same Service manifests, input admission, workDir collection and report reader for either driver. The spawn-ready record identifies each Codex thread and the guest executor version. The [OpenSandbox backend](16-pi-opensandbox-backend.md#codex-app-server) explains startup and evidence scope.
308
308
 
@@ -128,4 +128,31 @@ The ordinary Harness report and Core receipts remain independently addressable.
128
128
 
129
129
  ## Public project Session
130
130
 
131
- The project registers its Runtime and observation before dispatch, then marks the Session running through the mechanism's ready callback. Each round publishes active member and round progress, and the final result carries observed findings and cleanup receipts. The project uses its existing rounds and deadline and has no guided input or per-member mutations. Whole-Run stop invokes normal resource closure.
131
+ The project registers its Runtime and observation before dispatch, then marks the Session running through the mechanism's ready callback. Each round publishes active member and round progress, and the final result carries observed findings and cleanup receipts. The project uses its existing rounds and deadline and has no guided business-input channel. Run-owner member controls are registered separately as described below. Whole-Run stop invokes normal resource closure.
132
+
133
+ ## Run-owner member controls
134
+
135
+ The project Harness registers text steer, interrupt and stop for every peer with
136
+ `observeProjectRuntime`. The executor's advertised steering and cancellation
137
+ capabilities determine availability. Session/RPC retains the original member
138
+ identity and request ID and passes its stable native operation identity to Core.
139
+ Text steer is sent directly through the Runtime; its accepted receipt retains
140
+ native delivery timing. It does not grant the scheduler a new round.
141
+
142
+ Before interrupting a peer, the Harness marks that peer held. Its active
143
+ `runInput` can then settle aborted without failing its siblings. The peer waits
144
+ at a member-specific gate instead of admitting the next scheduled cycle or
145
+ correction. Its Session and published content remain available. Steer can still
146
+ reach that Session, while the original scheduled work stays held until the owner
147
+ stops the member or the Run ends. The work deadline and global stop still bound
148
+ this wait. An interrupted operation is never described as freezing every guest
149
+ process.
150
+
151
+ A member stop sets a permanent scheduler fence, aborts only that peer's trusted
152
+ host-cycle waits, releases its hold gate, retires its publication authorization,
153
+ and calls Core stop. Races after a scheduler readiness check are caught again at
154
+ `runInput.beforeSend`. Other peers finish their own serial rounds. The report
155
+ retains each peer's intervention, turns and stop receipt. A Run changed by owner
156
+ intervention reports `SUBSTRATE_USER_INTERVENTION` rather than claiming that its
157
+ original round plan completed. Cleanup remains a separate result. Project
158
+ observation publishes the affected identity, operation and original Core receipt.
@@ -44,7 +44,7 @@ Role prompts and all fixed continuation instructions are reproduced in [the gene
44
44
 
45
45
  ## Failure, shutdown and evidence
46
46
 
47
- Any failed/aborted settled round, fatal error or unexpected exit aborts the lifetime signal. Input unknown, timeout, handled/queued disposition or send failure also ends this first workflow. The original request ID, input ID/receipt when available and error code remain in the input ledger. A synchronous in-memory Board fence prevents new claims and mutations before SQLite persistence is attempted. Fence-write failures are caught and retained as host-owned pending evidence; they cannot replace the original input failure or prevent the Core close attempt. For an active exclusive input, the controller lets its helper finish terminal-event/late-receipt ordering before cancelling the team; an idle Agent failure cancels immediately. Startup rechecks the lifetime signal after the final spawn before binding the team. Owners and verified partial deliveries persist. No retry receives a fresh ID and no second helper takes over the uncertain task. Concurrent helper waits are aborted and all are awaited through bounded `Promise.allSettled` rather than allowing business work to continue after the first rejection.
47
+ An unrequested failed/aborted settled round, fatal error or unexpected exit aborts the lifetime signal. The targeted Run-owner controls described below retain their member-specific scheduling fence. Input unknown, timeout, handled/queued disposition or send failure also ends this first workflow. The original request ID, input ID/receipt when available and error code remain in the input ledger. A synchronous in-memory Board fence prevents new claims and mutations before SQLite persistence is attempted. Fence-write failures are caught and retained as host-owned pending evidence; they cannot replace the original input failure or prevent the Core close attempt. For an active exclusive input, the controller lets its helper finish terminal-event/late-receipt ordering before cancelling the team; an idle Agent failure cancels immediately. Startup rechecks the lifetime signal after the final spawn before binding the team. Owners and verified partial deliveries persist. No retry receives a fresh ID and no second helper takes over the uncertain task. Concurrent helper waits are aborted and all are awaited through bounded `Promise.allSettled` rather than allowing business work to continue after the first rejection.
48
48
 
49
49
  The fixed Harness indexes up to 256 Runtime events and the dynamic Harness indexes up to 2,048. Core retains native Session telemetry in its evidence without adding those events to the Harness index. The fixed Harness fences at its index limit. Both paths still fence on fatal Runtime errors, unsuccessful settlement or unexpected exit. Shutdown stops controller admission, aborts waits and fences Board writes before public `runtime.close` closes Core admission. Core's close receipt is authoritative for each Agent's execution, export and resource cleanup. An input of unknown delivery and execution still unknown after close have distinct receipts. The Board's failure records are updated from those actual stop receipts. SQLite read/write failure during reconciliation returns the actual Core receipt plus an explicit pending Board-evidence entry and keeps dependencies owned. A later close retries the queued original failure record. A deterministic independent SQLite write lock exercises this path, then unlocks and reconciles through the same public close handle. Unknown execution or required-export-pending retains the Board connection and owned Git credentials for reconciliation. Complete Core cleanup permits closing the Board and revoking or disabling owned account resources. Shared database, commits and PRs are retained.
50
50
 
@@ -131,3 +131,36 @@ The project adapter registers the appropriate Runtime and observes workflow stat
131
131
  The static and dynamic project entry uses `observeProjectRuntime` for public `HarnessSession` state. Agent state transitions are one refresh source; Board commits are another. After Runtime creation, `onRuntime(runtime, snapshot, subscribeBoard)` gives the entry a read-only snapshot function and the existing Board subscription. The entry subscribes before initial dispatch. Each committed Board transaction queues its listener after SQLite commit, which requests a serialized observation refresh even if every Agent remains in the same execution state. The snapshot function reads the current Board from SQLite, rather than a cached business projection, and the resulting Session state event includes the fresh Board alongside the Agent vector. Multiple pending refresh requests may coalesce; this is current-state observation, not one state event per Board transaction.
132
132
 
133
133
  A failed or rolled-back transaction does not notify observers. Session stop cancels pending observation reads through the run signal. The entry releases its Board subscription and closes observation in `finally`; Board close also clears its listeners. No observation timer is installed. The public Session regression holds a Lead execution open, writes through the actual Board CLI/Bridge, and requires a fresh state event with the same complete Agent status vector without calling `getState()`.
134
+
135
+ ## Run-owner member controls
136
+
137
+ The project Harness registers text steer, interrupt and stop for every current
138
+ Runtime member, including dynamically admitted members. Its callbacks run on the
139
+ public Session/RPC owner path. Agent Service grants continue to govern Agent-origin
140
+ calls independently. Native request identities come from Session dispatch, so a
141
+ repeated user request queries its original operation.
142
+
143
+ A targeted interrupt installs a per-member scheduler hold before the native
144
+ call. The active dispatch records the original aborted/unknown input facts and
145
+ waits at that member's gate. It does not trigger the global workflow failure
146
+ fence used for unrequested executor errors. Siblings continue their active work.
147
+ Direct steer remains available to the held member, while automatic original
148
+ work stays held. The owner can stop the member or end the Run; the configured
149
+ work deadline also bounds the hold. A targeted stop installs a permanent dispatch
150
+ fence and releases that member's gate before calling Core stop.
151
+
152
+ The Board stores `userInterventions` and a `user_control` history entry. An
153
+ unfinished claimed subtask retains its owner and revision and gains intervention
154
+ metadata. A stopped member's later write is rejected with `MEMBER_STOPPED` at
155
+ both admission and transaction commit, including a verification that began
156
+ before the stop. Other members can continue Board writes. The Board's global
157
+ `fenced` flag remains reserved for whole-workflow failure and close. If SQLite
158
+ cannot persist the member record, native control still proceeds and the Harness
159
+ retains `pendingMemberControls`; close retries those writes and reports pending
160
+ cleanup while evidence remains unconfirmed.
161
+
162
+ The dynamic scheduler skips held/stopped members and turns a new Board
163
+ `user_control` entry into a `user-intervention` notice for the lead. It retains
164
+ pending notices and claimed tasks without dispatching replacement original work.
165
+ Static workflow result checks still require their original delivery proofs, so
166
+ stopped work cannot silently count as a successful complete team delivery.
@@ -10,7 +10,7 @@ Website CI runs for the site, bilingual guides, documentation images, and change
10
10
 
11
11
  The content loader reads the repository's `docs/en/` (English) and `docs/zh/` (Chinese), validating each page's title, description, section, and order. Astro prerenders the English and Chinese landing pages (`/` and `/zh/`) plus one documentation route per content slug under `/docs/` and `/zh/docs/`. The shared layouts use those fields for page metadata, navigation, the current page marker, a top-right language switcher linking each page to its counterpart locale, and active table-of-contents tracking. Copy page writes the title, description, and rendered article text to the clipboard. It excludes the code-copy controls and displays success or failure on the button. The site uses Astro’s Sätteri Markdown processor with a local link plugin. The Markdown files are the shared source for GitHub readers and the site. Authors write relative file links such as `../runtime.md` or `harnesses/index.md`. `markdown-doc-links.mjs` resolves each link from its source file, checks that the destination exists inside the repository, and converts guide links to the matching locale route with `BASE_PATH`. Links to implementation files or manuals become GitHub source links. The transform preserves query strings and fragments. Absolute external URLs and same-page fragments retain their meaning. A missing file fails the build instead of publishing a broken route. The URL helper adds the configured base to generated navigation, search destinations, and the favicon. Astro bundles local font assets and inline SVG landing schematics. The public directory supplies the favicon and verbatim font license notices. Departure Mono’s notice and font come from the [upstream font assets](https://github.com/rektdeckard/departure-mono/tree/75152a3f1e6dacdd248a6c397c97dbf27e33eea0/public/assets). The other notices come from the locked Fontsource packages. Update the included notices when changing the corresponding fonts.
12
12
 
13
- The website navigation and both landing pages render the same six-bird mark at different sizes with the active site foreground color. The browser icon uses the same geometry and follows the browser’s color scheme. The repository README selects the light or dark SVG through its picture element. The Trace Viewer and static replay use the same six silhouettes in their headers. Astro copies the transparent PNG export to `/anyswarm-logo.png` under the configured base path for direct download.
13
+ The shared top navigation displays the documented release, currently `v0.5.1`, and links to the release page in the active language. The version label is set in `TopNav.astro` when the stable guides advance. The website navigation and both landing pages render the same six-bird mark at different sizes with the active site foreground color. The browser icon uses the same geometry and follows the browser’s color scheme. The repository README selects the light or dark SVG through its picture element. The Trace Viewer and static replay use the same six silhouettes in their headers. Astro copies the transparent PNG export to `/anyswarm-logo.png` under the configured base path for direct download.
14
14
 
15
15
  The browser handles the landing page diagrams, Harness selector, theme, and site navigation. Search indexes documentation titles, descriptions and sections for the current locale at build time and uses sidebar labels and order for pages in the navigation. Other pages use their frontmatter section and order. The Tutorials group contains the first SDK Harness and Swarm Harness guides. Opening search shows up to eight pages. Typing filters the index locally. Search renders results and empty-query feedback as DOM text, uses only built documentation destinations, and sends no queries to a server. Escape or backdrop click closes it and returns focus to the navigation button. The theme preference stays in browser storage. The site writes no server-side session state.
16
16
 
@@ -20,12 +20,11 @@ Regenerate that bundle with `node website/scripts/build-trace-demo.mjs`. `--root
20
20
 
21
21
  ## Publish and recover
22
22
 
23
- During the v0.4.1 scope transition, Pages deployed the updated installer before GitHub Latest advanced. Both releases retain the same GitHub asset naming scheme. The published installer supports one-time migration from the archived v0.4.0 npm scope to the managed CLI. [Release procedure](../workflows/development.md#release-verification)
23
+ Both landing pages display the global npm install command and a copy button with clipboard success or failure feedback. Each locale links to its Quickstart and the project-local SDK installation section of the API reference. [npm installation and update](07-run-configuration.md#npm-cli-installation-and-update) describes prefix selection and failure recovery.
24
24
 
25
- Astro copies [the CLI installer](../../website/public/install.sh) verbatim into the Pages artifact at `/anyswarm/install.sh`. It checks Node.js and npm, chooses a writable prefix, and stages the verified stable archive before activating the two CLI entries. The installer reports the active binary, actual package root, source and SHA-256. Its `--archive` input takes an explicit absolute local tarball for release verification. Host setup and CLI update are separate commands. [Managed installation and update](07-run-configuration.md#managed-cli-installation-and-update) describes the on-disk generations and activation.
26
- The homepage defaults to the CLI tab. Its command and the Quickstart pipe the installer from curl into POSIX sh. curl prints download errors to stderr. A shell with `pipefail` enabled also propagates a curl failure through the pipeline exit status. The CLI tab links to Quickstart for OpenSandbox and local Worker setup. The SDK tab shows `npm install @anyswarm/anyswarm@0.4.1` for the published SDK, describes the `@anyswarm/core` source-build name and links to the first SDK Harness tutorial. The installer looks for the managed activation entry in `@anyswarm/core` first, then in `@anyswarm/anyswarm` for the published release. The activated archive runs its own version and executable ownership checks. The GitHub Release asset name stays stable. Selecting a tab switches the displayed command, the text copied to the clipboard and the corresponding guide link in the current language. The release guide links the v0.3.0 documentation and retains pinned v0.2.0 instructions for existing hosts. Website CI verifies that the built installer matches the source. The focused install-command and installer tests also run when the installer script, the install command component, or either Quickstart changes. The full Core suite includes those tests.
25
+ Website CI verifies that the static build omits the retired installation script. The homepage command and bilingual Quickstart parity test runs on changes to those sources and is included in the full Core suite.
27
26
 
28
- The [Pages workflow](../../.github/workflows/deploy-website.yml) starts after a push to `main` that changes `website/`, `docs/en/`, `docs/zh/` or its workflow, from manual dispatch for a selected ref, or after a successful tag-triggered Release run. The workflow requires `AnySwarm/anyswarm` and the `main` ref. It builds only after GitHub marks a release containing `luna-shi-anyswarm.tgz` as Latest. The installer can serve the historical v0.4.0 archive before a managed-install release is available. GitHub Pages uses the GitHub Actions source. The `github-pages` environment allows deployment from `main`. The workflow reads the site origin and base path from Pages, runs a locked Node 24 build, then uploads `website/dist/` as a Pages artifact. The deploy job runs only after the build succeeds and publishes that artifact using the repository Pages permission and an OIDC token. Each successful deployment replaces the entire published site under the configured base path. The public site is at `https://anyswarm.github.io/anyswarm/`. The organization transfer changed the origin, and GitHub Pages does not redirect requests from the previous origin. A deployed artifact must include both locale trees to serve both locales. Deployments share a concurrency group. No npm package publish or sandbox setup runs in this workflow.
27
+ The [Pages workflow](../../.github/workflows/deploy-website.yml) starts after a push to `main` that changes `website/`, `docs/en/`, `docs/zh/` or its workflow, from manual dispatch for a selected ref, or after a successful tag-triggered Release run. The workflow requires `AnySwarm/anyswarm` and the `main` ref. It builds only after GitHub marks a release containing `luna-shi-anyswarm.tgz` as Latest. GitHub Pages uses the GitHub Actions source. The `github-pages` environment allows deployment from `main`. The workflow reads the site origin and base path from Pages, runs a locked Node 24 build, then uploads `website/dist/` as a Pages artifact. The deploy job runs only after the build succeeds and publishes that artifact using the repository Pages permission and an OIDC token. Each successful deployment replaces the entire published site under the configured base path. The public site is at `https://anyswarm.github.io/anyswarm/`. The organization transfer changed the origin, and GitHub Pages does not redirect requests from the previous origin. A deployed artifact must include both locale trees to serve both locales. Deployments share a concurrency group. No npm package publish or sandbox setup runs in this workflow.
29
28
 
30
29
  Installation, build or environment errors surface in the corresponding Actions job. A successful deploy job records the public URL. A failed build leaves the previously published site available. After fixing a failed deployment, dispatch the workflow on `main` and verify both landing pages, a nested documentation route in each locale, and a static asset under the configured base. The package and local build output are independent of the live deployment history.
31
30
 
@@ -38,4 +37,4 @@ After Astro generates the site, `scripts/check-links.mjs` walks every HTML page,
38
37
  For a repository-prefix build, use `BASE_PATH=/anyswarm SITE_URL=https://anyswarm.github.io npm --prefix website run build`. For a root-path preview, build without a base override. Editing user guide content also participates in `npm run docs:check`, which validates repository-relative file links and anchors before publication.
39
38
 
40
39
 
41
- All five current first Harness sources are served at `downloads/first-harness/v2/`. The parallel Swarm uses the sources under `downloads/parallel-swarm/v1/` and the shared first Harness TypeScript configuration. The Markdown link transformer rewrites both locales to these exact shipped files. Historical single-process examples are linked to fixed release tags.
40
+ All five current first Harness sources are served at `downloads/first-harness/v2/`. The parallel Swarm uses the sources under `downloads/parallel-swarm/v1/` and the shared first Harness TypeScript configuration. The Markdown link transformer rewrites both locales to these exact shipped files. Historical single-process examples are linked to fixed release tags.
@@ -1,6 +1,6 @@
1
1
  # Harness entry and lifecycle
2
2
 
3
- The installed `anyswarm --harness` command runs one project. Its task input is a host directory and one nonblank prompt. Run configuration can choose resources, services, and limits. [Launch and configuration](07-run-configuration.md) covers host preparation and the editable SDK template.
3
+ The installed `anyswarm --harness` command runs one project. Its task input is a host directory and one nonblank prompt. Bare `anyswarm` prints Quickstart and exits 0. Run configuration can choose resources, services, and limits. [Launch and configuration](07-run-configuration.md) covers host preparation and the editable SDK template.
4
4
 
5
5
  ## Authoring an example
6
6
 
@@ -54,14 +54,14 @@ A module default-exports a `Harness` and receives `HarnessContext` when its Run
54
54
 
55
55
  The definition declares `inputDescriptor`, the optional lifetime and question support. `ProjectHarness`, `ProjectHarnessContext` and `ProjectHarnessResult` are deprecated aliases for `Harness`, `HarnessContext` and the author return type. `inputDescription` is a deprecated fallback when an input descriptor is absent. Existing package callers can keep these names while updating their code. Compatibility aliases remain until a future announced major contract revision.
56
56
 
57
- `context.runWithRuntime` runs a Harness-owned factory and work callback, calls its close and includes the original receipt in the Session report. It uses the same close evidence as standalone `runWithReport`. `projectResult` delegates to the same projection for legacy callers. `observeProjectRuntime` is a compatibility convenience for projecting business state and reading original receipts. A minimal Harness registers a Runtime through `context.registerAgentControls({ runtime })` and publishes its own business state via `updateStatus`. [Reporting](17-harness-reporting.md)
57
+ `context.runWithRuntime` runs a Harness-owned factory and work callback, calls its close and includes the original receipt in the Session report. It uses the same close evidence as standalone `runWithReport`. `projectResult` delegates to the same projection for legacy callers. `observeProjectRuntime` is a compatibility convenience for projecting business state and reading original receipts. If the observer is registered without a business callback, it leaves the current Harness business status alone. A minimal Harness registers a Runtime through `context.registerAgentControls({ runtime })` and publishes its own business state via `updateStatus`. [Reporting](17-harness-reporting.md)
58
58
 
59
59
  ## Startup and captured source
60
60
 
61
61
  1. The CLI records the invocation directory. It loads a built-in module, resolves a local `.mjs` or ESM `.js` against the invocation directory, or resolves an installed package at that directory using Node's import conditions. Modules export one default object with a stable `id`, `apiVersion: 1`, `run(context)`, and optional `input: true`. Loading validates this shape before any Run is admitted. Modules manage only their own Runtime and facilities.
62
62
  2. Foreground mode accepts `--cwd` and `--prompt`. The RPC `run` request supplies these fields. Both resolve relative project paths against the invocation directory and default an omitted directory to it. A successful admission allocates a UUID and enters `starting`. Startup resolves the project root, reserves a private output directory and saves the original prompt to `initial-prompt.txt`. It loads the optional default-export config module and captures the project before invoking the Harness. An explicitly configured output location inside the project excludes the current Run directory.
63
- 3. Git selection uses existing stage-zero tracked files and unignored untracked files from the selected subtree. For a non-Git input the host walks ordinary files, including hidden files. Both paths confine lookups to open directory handles and detect changes during inspected reads. Git metadata is excluded. The host fails with an affected path when it detects symlinks, multiply linked files, special files, Git submodules, an unmaterialized LFS pointer, invalid paths or file races. Empty directories have no FileTree entry. Limits are 2 MiB per file, 16 MiB per tree, 10,000 files, 128 path segments and a 30-second capture window. The non-Git walk also bounds enumeration to 50,000 directory entries, including empty directories. Binary bytes use base64 and owner execute maps to mode 0755, with ordinary files mapped to 0644. The complete SHA-256 file digest includes normalized paths, modes and content. The host saves `initial-files.json` under the private Run directory before calling the Harness. It lists each selected path, mode, byte count and SHA-256, and the result records its location. Startup can fail if the tree changes during capture and the directory walk provides no simultaneous snapshot across separate files.
64
- 4. The Harness receives `input.cwd`, `input.prompt`, `initial.files` and its digest and selection summary, the resolved configuration, Run ID, output directory, stop signal, and callbacks. Core installs supplied files before starting each executor in `/workspace/project`. The host never reads the input again for this Run, and project changes stay in Sandbox or collected artifacts. Subsequent member creation uses the captured tree or an explicitly chosen business revision.
63
+ 3. Git selection uses existing stage-zero tracked files and unignored untracked files from the selected subtree. For a non-Git input the host walks ordinary files, including hidden files. On Linux both paths anchor child operations to open directory handles using `/proc/self/fd`. On macOS the host canonicalizes the roots, retains the inspected directory handles and identities, and rechecks the parent before each path operation. A bounded directory reader inherits the inspected descriptor and changes its working directory by descriptor before enumerating byte names, anchoring the stream to the same directory. Each file or directory open uses Darwin's `O_NOFOLLOW_ANY` to refuse symlinks in every component in the kernel. The opened identity must match the pre-open inspection; after reading, the handle and visible entry must still match it. A failed check discards the private staged input, not a partial Run. Git metadata is excluded. The host fails with an affected path when it detects symlinks, multiply linked files, special files, Git submodules, an unmaterialized LFS pointer, invalid paths or file races. Empty directories have no FileTree entry. Limits are 2 MiB per file, 16 MiB per tree, 10,000 files, 128 path segments and a 30-second capture window. The non-Git walk also bounds enumeration to 50,000 directory entries, including empty directories. Binary bytes use base64 and owner execute maps to mode 0755, with ordinary files mapped to 0644. The complete SHA-256 file digest includes normalized paths, modes and content. The host saves `initial-files.json` under the private Run directory before calling the Harness. It lists each selected path, mode, byte count and SHA-256, and the result records its location. Startup can fail if the tree changes during capture and the directory walk provides no simultaneous snapshot across separate files.
64
+ 4. The Harness receives `input.cwd`, `input.prompt`, `initial.files` and its digest and selection summary, the resolved configuration, Run ID, output directory, stop signal, and callbacks. Core installs supplied files before starting each executor in `/workspace/project`. Subsequent member creation uses the captured tree or an explicitly chosen business revision. A Harness can call `captureProject(signal?)` to read a later project revision. Code uses this to reconcile each turn with the live files before authorized writeback. See [Code](26-code.md) for its application policy.
65
65
 
66
66
  ## HarnessSession admission and lifetime
67
67
 
@@ -73,26 +73,83 @@ A mutation carries one `requestId`. The Session stores the operation and normali
73
73
 
74
74
  The Session owns the only input handler and captures operation identities before dispatch. The preparation and storage code owns project capture, the Run directory and the stop deadline. Normal return, exceptions, preflight failure, stop and timeout all use the same terminal path. That path seals new Session mutations and questions before cancelling unresolved questions and capturing the operation dispositions. Callbacks released by cancellation cannot admit new work while the report is being saved. Original mutation receipts can still be reconciled. Late evidence does not change the final record.
75
75
 
76
- The Host writes `project-run.json` atomically with private permissions. The report retains the full JSON result and sanitizes known credentials in business evidence and terminal failure messages before saving. `completion`, the final event, the final RPC record and foreground output share a result of at most 256 KiB. A large result marks `snapshotTruncated` and preserves the outcome, export and cleanup statuses, save status and a report path when saving succeeded. A save failure omits the report path. If its stop deadline expires before the Harness confirms cleanup, it reports pending resources. Required export failure can retain the Sandbox and its Slot. Exit 0 requires completed business and confirmed required export, cleanup and report save. Exit 1 records cancellation, business failure or unresolved results. Launch validation uses exit 2, SIGINT uses 130, and SIGTERM uses 143. EOF and input or output failure enter the same foreground stop path.
76
+ The Host writes `project-run.json` atomically with private permissions. The report retains the full JSON result and sanitizes known credentials in business evidence and terminal failure messages before saving. `completion`, the final event, the final RPC record and piped one-shot output share a result of at most 256 KiB. A large result marks `snapshotTruncated` and preserves the outcome, export and cleanup statuses, save status and a report path when saving succeeded. A save failure omits the report path. If its stop deadline expires before the Harness confirms cleanup, it reports pending resources. Required export failure can retain the Sandbox and its Slot. Exit 0 requires completed business and confirmed required export, cleanup and report save. Exit 1 records cancellation, business failure or unresolved results. Launch validation uses exit 2, SIGINT uses 130, and SIGTERM uses 143. RPC EOF or input failure and an output failure enter the same stop path.
77
+
78
+ ## One-shot terminal output
79
+
80
+ The CLI loads and validates the selected module, then constructs a HarnessSession.
81
+ For a module with a workspace resolver, the CLI resolves any explicit trusted
82
+ configuration early to choose the default workspace and allow time for configured
83
+ cleanup. Explicit `--cwd` wins. The early load uses the same configuration validation and stable error messages as admission. A rejected configuration or resolver exits before the Session starts and before any Run directory is created. Other configuration loads occur during admission.
84
+ RPC takes its workspace from the client's run request.
85
+
86
+ With terminal stdout, the CLI prints the Harness name and a copyable Trace
87
+ command for the selected or default state directory before admission. It
88
+ subscribes before starting the Session and writes compact phase transitions,
89
+ Agent startup, Sandbox readiness when an Agent reaches idle or running, turn
90
+ settlement, Agent closure and Service lifecycle changes. Static Service names
91
+ come from Session observation handles when the Harness reaches running. Progress
92
+ uses only the redacted Session projection and escapes terminal control characters.
93
+ Arbitrary business events, messages, and question contents stay out of progress.
94
+ On completion it prints outcome, separately observed export and cleanup statuses,
95
+ up to five artifact paths, the saved report path when available, and a Trace
96
+ command for the actual Run root. The final path accounts for the Host's fallback
97
+ when the default state directory cannot be used. Trace is started explicitly in
98
+ a separate process and can read records as they are written.
99
+
100
+ Piped stdout keeps the single machine-readable result. Both one-shot modes wait
101
+ for Session completion and final stdout flush before returning the exit status.
102
+ Output failure enters the existing cleanup path. Lifecycle observation has the
103
+ same bounded subscription semantics as other Session observers.
77
104
 
78
105
  ## Agent controls and live state
79
106
 
80
107
  The Session subscribes once per registered Runtime before spawn. Agent, Runtime and management changes trigger a membership refresh. Other Runtime events publish in arrival order and can update the live message view without reading membership. Business state refreshes through domain callbacks, including Board, Task, and batch changes. The Harness can extend the registration with explicit control handlers, field and delivery allowances, and a synchronous dispatch fence. Before each operation, the Session refreshes membership and checks the target, current executor capability and Agent state. Failure to refresh the selected target rejects the dispatch. The default query handlers use the actual Runtime Session. Declared configure and abortRetry can use default dispatch. Scheduler-sensitive operations require the Harness policy handler. Descriptions and dispatch use the attestation held by the backend for that Agent. A running Worker without Session attestation exposes its existing text path where the Harness allows it and reports native Session operations as unsupported. Control is narrowed to the Harness's admitted fields and input semantics. Read-only state, statistics and messages use the live Runtime session query. Closed native state is reported as unavailable while the Run view can keep the last observed Agent and cleanup evidence.
81
108
 
82
- Subagents exposes Root text, structured context, configure, manual compact, retry cancellation, interrupt and clear queue. Root dispatch reserves a window for compact and rejects new work while it is reserved. An interrupt cancels an old Root wait, increments its dispatch boundary and keeps Root paused for automatic result delivery. Native queue dispositions identify the ordinary inputs discarded by interrupt or clear queue. The controller restores the corresponding child results from composite queued inputs and retains prior appended context. A new explicit Root text input or waking context resumes dispatch. Child work already accepted continues. PeerMesh exposes a member stop that fences its router and stops its event source before calling native stop. Whole Run stop invokes the owning Harness's existing close path.
109
+ Subagents exposes owner text steering, interrupt and stop for every member of
110
+ the active tree. Root also supports structured context, configure, manual compact,
111
+ retry cancellation and clear queue. Root dispatch rejects new work while compact
112
+ reserves its dispatch window. An interrupt cancels the target's wait and fences
113
+ old dispatches and automatic mailbox delivery. Native queue dispositions identify
114
+ discarded input hashes. The controller restores their original messages without
115
+ reinstating unrelated deliveries. Explicit accepted input resumes the still-live
116
+ target. A stop keeps that target fenced. Each confirmed intervention, or accepted
117
+ steer, schedules a notice for the direct parent through the collaboration mailbox.
118
+ An active parent can receive it during its turn. An idle parent's next admitted
119
+ input carries pending notices. Accepted work for unrelated members continues.
120
+
121
+ Each built-in applies its own scheduling policy before calling Core. TaskPool
122
+ holds the target Worker's native and scheduled continuations while preserving
123
+ the active Execution lease during interruption. A confirmed stop releases the
124
+ Task and the slot through TaskPool finalization. A failure after the native stop
125
+ leaves Harness effects pending until the Task and slot have closed. PeerMesh
126
+ limits an in-flight router dispatch to conditional steering, cancels the target
127
+ router wait on interruption, and fences its deadline and event source on stop.
128
+ Explicit input can resume an interrupted peer. Notes and Messages fence the
129
+ selected member at handoffs and cancel only its active input, so a late turn
130
+ cannot advance its old stage. [Substrate](19-substrate-harness.md) and
131
+ [Lead–Worker](20-lead-worker-harness.md) handle their own round or stage guards
132
+ and preserve surviving peers, Workers and Board ownership. Whole Run stop invokes
133
+ the owning Harness's cleanup path.
83
134
 
84
135
  The Session projects lifecycle, capabilities, Agent identities, business state, questions and bounded output. Business sources refresh independently of Agent state. Message deltas use message identity, and terminal content replaces that message’s live view. Individual business and Agent previews default to 32 KiB, and the output view retains up to eight messages and 64 KiB in total. The overall snapshot defaults to 256 KiB and includes UTF-8 encoding and JSON structure. It keeps every pending question, then includes terminal evidence and any display fields that fit. The nested result omits the duplicate question list. Get the complete terminal details from the saved report.
85
136
 
86
137
  `onEvent(handler, { initialSnapshot: true, onError })` emits the current snapshot before later events. SDK and RPC subscribers each have one callback in flight and up to 128 queued events totaling at most 1 MiB. Both surfaces allow 64 subscriptions. Overflow detaches the affected subscription and reports `OBSERVATION_OVERFLOW` through `onError` outside the event queue. The caller can subscribe again with a fresh snapshot. Sync throws and rejected callback promises remain isolated. Unsubscribing releases queued events and cancels an outstanding RPC snapshot request. An already running async callback can finish on its own.
87
138
 
139
+ ### Service observation from the host
140
+
141
+ Register an owned Runtime through `context.registerAgentControls({ runtime, ... })` or `observeProjectRuntime` to include its Services in `session.services.list()`. Each descriptor includes the Runtime ID so two Runtimes may register the same Service name. `session.services.read(runtimeId, name)` resolves that exact owned Runtime and delegates to the Runtime's bounded [live Service read](15-core-runtime.md#live-service-state). The Session checks ownership again after the read and withholds samples on unregister, Run stop or finalization. A Client receives the same descriptors and receipts through JSONL `service.list` and `service.read`. These are queries and can run while input, questions and member controls proceed. Service samples do not enter the ordinary status/event snapshot and are never persisted by this read path.
142
+
88
143
  ## Questions
89
144
 
90
145
  Harness authors can call `context.askUser` for text, choice or confirmation. Questions bind a stable question and request ID to a source and cancellation signal. For a Service the source comes from the authenticated caller and Service invocation, and authorization is checked again before accepting an answer and before the Service resumes. Subagents conditionally exposes the `user-interaction ask` Service to its Profiles when the client has enabled questions. The request schema accepts the question text. The service reply contains the answer. A question and its source exist in the projection before any event is emitted. A response specifies `questionId`; competing answers, timeout, loss of authorization and stop resolve to a single terminal state. Question stop and source cancellation prevent old work from consuming a late answer.
91
146
 
92
- Clients enable the answer channel with `clientCapabilities.questions`, or with `--interaction questions` on the CLI. It defaults to false and is independent of lifetime. A Run allows up to 64 question identities by default, with an aggregate budget limited by 256 KiB and one third of the snapshot budget. It reserves space for the question identity, source, timestamps, options, terminal fields and largest legal answer before admission. A confirm reserves a boolean, a choice reserves its longest declared option ID, and a text question exposes `maxAnswerBytes` (16 KiB of JSON-encoded string, including quotes). The Session rechecks the source and authorization after asynchronous target lookup and checks for abort again after installing the listener. The default timeout is 60 seconds and the maximum is one hour. The final report retains the question dispositions. Without an answer channel the SDK reports unsupported before publishing a question.
147
+ Clients enable the answer channel with `clientCapabilities.questions`, or with `--interaction questions` in CLI RPC mode. It defaults to false and is independent of lifetime. A Run allows up to 64 question identities by default, with an aggregate budget limited by 256 KiB and one third of the snapshot budget. It reserves space for the question identity, source, timestamps, options, terminal fields and largest legal answer before admission. A confirm reserves a boolean, a choice reserves its longest declared option ID, and a text question exposes `maxAnswerBytes` (16 KiB of JSON-encoded string, including quotes). The Session rechecks the source and authorization after asynchronous target lookup and checks for abort again after installing the listener. The default timeout is 60 seconds and the maximum is one hour. The final report retains the question dispositions. Without an answer channel the SDK reports unsupported before publishing a question.
93
148
 
94
149
  ## JSONL RPC
95
150
 
151
+ An application can call SDK `runProjectRpc(session, input, write, launchDirectory, initialInput?, options?)` to serve the same wire protocol over a caller-owned stream. The default transport owns its foreground Run and closes it on loss of input. `detachOnDisconnect: true` releases that client subscription on EOF or error and leaves the Session running. Explicit stop remains available, and the client can receive the final result while attached. The host application owns authentication, transport permissions and shutdown. Personal uses an owner-only Unix socket.
152
+
96
153
  The project RPC server consumes the same Session as the process-local SDK. It reads strict UTF-8 lines separated by LF, with a command bound of 64 KiB. The wire record has `id`, `operation`, optional `input` and an optional mutation `requestId`. Existing clients use `id` as the mutation identity. Typed clients can choose a fresh transport ID while reusing the business request ID after an uncertain reply. `run`, `status`, `input` and `stop` retain their operation names. `describe`, `answer` and the fixed `agent.*` operations delegate to the corresponding Session methods. Status queries capture and write the current state synchronously. Other queries share an in-flight reply for matching IDs, reject changed arguments while that ID is pending, and release one of the 128 slots when the reply arrives or after 30 seconds. A reused read ID after release starts a fresh query. Answer, stop and mutation replay use independent admission. Dependencies, queues and mutation reconciliation belong to HarnessSession.
97
154
 
98
155
  The server writes `ready` with v1, Harness identity, descriptor and initial state, then writes separate reply, error, event and result records. A fresh status reply is queued synchronously with its captured state. `HarnessRpcClient` installs its read side before sending requests, correlates replies by ID, and gives a new subscriber that status snapshot before subsequent events. It exposes `ready` and the same methods as a direct Session. Its transport declaration describes the pipe and event methods it uses, so other package-root SDK consumers can still typecheck with a standard-library-only configuration. Transport disconnect rejects any unresolved final result. The caller manages its streams and subprocess. Unsubscribing leaves the Run open.
@@ -119,7 +176,7 @@ For the ordinary TaskPool entry, Workspace reads and publication accept the same
119
176
 
120
177
  ## Compatible launch surfaces
121
178
 
122
- Previously generated Subagents hosts are still directly runnable through their own entry point. The installed CLI exposes setup and doctor and prints help when invoked without arguments. The previous explicit Notes and Messages fixtures exercise the fixed observation and undeclared random string scripts. The explicit PeerMesh JSON fixture and prior Lead–Worker staged or Orders paths retain their benchmark roles. FATE preparation, single run, matrix and rescoring use explicit flags. Each uses its own fixtures rather than the ordinary project command.
179
+ Previously generated Subagents hosts are still directly runnable through their own entry point. The previous explicit Notes and Messages fixtures exercise the fixed observation and undeclared random string scripts. The explicit PeerMesh JSON fixture and prior Lead–Worker staged or Orders paths retain their benchmark roles. FATE preparation, single run, matrix and rescoring use explicit flags. Each uses its own fixtures rather than the ordinary project command.
123
180
 
124
181
  [Prompt composition and exact texts](08-prompts.md) · [Workspace handoff](05-workspace-continuity.md) · [Report semantics](17-harness-reporting.md)
125
182
 
@@ -129,6 +186,8 @@ The project host resolves the user's config module before capture and normalizes
129
186
 
130
187
  A Harness can pass `context.initial.files` directly to `runtime.spawn`. The Runtime keeps the spooled source attached to the public FileTree view and uses its manifest identity for request replay. The Worker transport can read retained disk data without materializing the project's base64 strings on the Controller. Explicit FileTree inspection or cloning by a Harness materializes the requested bytes. Harnesses with a separate Git or Workspace import have their own import and storage constraints. A Harness which exposes file policy forwards the same configuration to `createRuntime` so capture, Worker admission, and file operations agree.
131
188
 
189
+ `context.captureProject(signal?)` uses the resolved project root, file policy and output-directory exclusion of the initial capture. The optional caller signal combines with the Run stop signal. Successful results own a temporary spool with `dispose()`. The caller disposes it after its final read, and the host removes any retained spools after the report is serialized and the Harness settles. Recapture leaves the original manifest and initial revision unchanged.
190
+
132
191
  已派发控制返回 unknown 后,重试先读取原登记操作。Runtime 的内部回执查询只接受已有身份,Session 配置、context 和文本输入沿原生查询路径恢复结果,原生 interrupt 沿同一 interruptId 查询。通用 configure 帮助实现自动接入此查询;自定义处理器通过 registerAgentControls.reconcile 提供可信核对。回调可读取原始 payload,但不得以新身份重新派发工作。Subagents 还核对原控制覆盖的 Root 投递集合,只恢复当次丢弃的协作消息,后续新增输入的账本继续保留。PeerMesh 的 pending 成员停止通过同一成员的幂等停止入口继续收尾,先确认事件源关闭,再重试 Core 清理。
133
192
 
134
193
  registerInput 的第四个可选参数是原操作的核对处理器。共享层保留首次捕获的 input、requestId 和 binding,只有已经派发且回执 unknown 才调用核对。Subagents 使用已登记 Root 输入的 Core 身份读取回执;TaskPool 使用首次反馈的 Agent/execution/fence,更新该原输入的处置并保留后来任务的归属。公共层在首次回执、迟到回执和主动核对之间只发布实际变化,已经确认的回执不被迟到 unknown 覆盖。
@@ -138,3 +197,88 @@ registerInput 的第四个可选参数是原操作的核对处理器。共享层
138
197
  When an owned Runtime reports a framework failure, the exclusive runInput error can retain a recognized diagnostic and its original input receipt. When a wait ends without a recognized executor diagnostic, runInput creates a runtime/input_wait/input_wait_failed diagnostic using only its own Runtime, Agent, input request and known input identities. An accepted receipt remains accepted after a Host timeout or wait cancellation; an unknown admission remains unknown. The original input_timeout, wait_aborted, input_unknown or input_aborted code distinguishes these cases. Empty diagnostic facts make no claim about execution, upstream receipt, interruption confirmation or delivery. Only recognized receipt status, input identity and accepted disposition cross the Host boundary; arbitrary receipt properties are excluded. A direct exception through the Host keeps the framework code, scoped Runtime/Agent/input identities and recognized receipt in failure. The message is a fixed explanation selected from the framework diagnostic. HarnessSession applies its configured redactor before saving project-run.json and publishing completion. The 256 KiB public result retains the bounded failure facts when it truncates large optional business content. The shared runWithRuntime report path also retains recognized facts in businessFailure and keeps its close evidence independently.
139
198
 
140
199
  RPC query or mutation rejection carries the same recognized framework fields beside the existing type, request id, Run id and code. The client decodes only schema-version-1 fields with bounded values. A legacy error frame containing only code produces the existing generic RPC error. Foreground command errors use the same projector, while a completed foreground Run prints the shared public result. Ordinary author exceptions still use the existing generic Host error message and omit stack, arbitrary details and unrecognized diagnostic objects. Registered Runtime observations also forward request-scoped modelDiagnostic events to the existing Harness event stream. These events retain their model request identity without changing the Harness business result.
200
+
201
+ ## TypeScript author entry and source export
202
+
203
+ `anyswarm run ./harness.ts` starts a child Node process
204
+ with source maps enabled and forward the remaining arguments and standard streams.
205
+ The parent forwards SIGINT and SIGTERM and returns the child's exit code. The
206
+ child installs synchronous module hooks before loading the trusted author entry.
207
+ These hooks transform `.ts` and `.mts` to ESM with inline source maps using Node's
208
+ `stripTypeScriptTypes` transform mode, including enum syntax. They override the
209
+ surrounding package's CommonJS interpretation for these source files. A relative
210
+ `.js` or `.mjs` import first resolves normally, then falls back to the corresponding
211
+ `.ts` or `.mts` source when the JavaScript file is missing. Ordinary installed
212
+ package resolution runs first. A missing `@anyswarm/core` dependency falls back to
213
+ the invoking CLI's public SDK entry. No hook is installed merely by importing the
214
+ SDK. The trusted Harness and configuration loading paths enable these same hooks,
215
+ so explicit foreground/RPC and the legacy repository foreground runner can
216
+ load TypeScript configuration modules as well.
217
+
218
+ An entry without a default Harness executes as an ordinary source program with
219
+ its original argv. A default Harness with `apiVersion: 1` and `run` is dispatched
220
+ through the same one-shot or RPC host used by explicit `--harness`. A source
221
+ entry accepts `--cwd`, `--config`, `--prompt` and `--output-dir`. Omitted prompt
222
+ uses `Run this Harness.` in one-shot mode. One-shot execution requests task
223
+ lifetime and provides no question channel. An interactive-only Harness needs an
224
+ explicit RPC or SDK client. RPC admits the first input over stdin.
225
+ The loader inspects the effective source before an implicit import. Modules
226
+ without a default export can stream stdout immediately.
227
+ When a TypeScript entry could export a Harness,
228
+ the first stdout write opens a private temporary file and unlinks its path.
229
+ The loader starts replaying to stdout before input arrives when the module adds
230
+ a stdin `data`, `readable`, or `keypress` listener, resumes the stream, or calls
231
+ `stdin.read()` during import. The stream's internal `read(0)` probes leave
232
+ buffering in place. Replay retains write
233
+ order, waits for output writes, and then restores live stdout. If that interactive
234
+ import produced stdout and exports a task Harness, the implicit foreground command
235
+ exits 1 and requests an explicit `--prompt` before it admits a Run.
236
+ For other imports, replay starts when evaluation returns or fails. The loader uses
237
+ stderr for an implicit foreground Harness or a failed import, and stdout for a
238
+ plain script. It restores the output writer,
239
+ removes its stdin listeners, restores its temporary `stdin.read` override and
240
+ closes the temporary file. A script that exits
241
+ directly during import writes pending output to stdout up to the stream's
242
+ backpressure limit, or leaves an active replay's queued writes in order.
243
+ A piped one-shot Run emits a single JSON result or launch error. RPC preserves
244
+ its JSONL protocol and bounded write queue regardless of terminal detection.
245
+ Source diagnostics and Harness console output go to stderr. Configuration
246
+ loading inside the Host records a stable configuration failure in the Run report.
247
+ In a non-Git author directory, untracked top-level `node_modules`, `.anyswarm-sdk` and Code recovery directories named `.anyswarm-code-recovery-` plus a six-character suffix are excluded from project capture. Explicit Git-tracked files at those paths keep the tracked-file capture behavior.
248
+
249
+ `anyswarm eject <code|autoresearch|super|example> --dir <target>` selects a packaged
250
+ application's `examples/<id>/eject.json`; `example` selects `examples/authoring`.
251
+ The version-1 manifest names its TypeScript entry, an explicit file list and optional additional npm dependencies. The engine
252
+ rejects absolute/traversal paths, private/runtime/build directories, secret-file
253
+ extensions and symlinks. It copies only regular listed files into a temporary
254
+ sibling directory, creates the SDK archive and generated package/provenance
255
+ files, and renames the complete export into place. A nonempty target fails before
256
+ writes. Failures remove the temporary export. Applications without a source
257
+ manifest return a reason identifying the missing application source.
258
+
259
+ The exported package depends on `file:./.anyswarm-sdk/core.tgz`. That archive is
260
+ repacked from the actual invoking SDK with lifecycle scripts disabled. The
261
+ provenance file records the SDK name/version, npm installation source/integrity
262
+ when available, source build commit/dirty status, archive SHA-256, package file
263
+ inventory and content SHA-256. Format version 2 stores the inventory and digest
264
+ under `sdk.content`. The current command also reads version 1 exports from the
265
+ previous candidate. New exports omit the old fields so an older CLI rejects them
266
+ before loading source. Build provenance is generated into the package by
267
+ `scripts/build.ts`; it remains unknown when Git revision information was
268
+ unavailable. Before evaluating the entry, `anyswarm run` hashes the recorded inventory
269
+ of its own executable package. It resolves `@anyswarm/core` from the author entry
270
+ with Node's ESM conditions and the same CLI fallback used for imports. It checks
271
+ that the resolved file belongs to the inventory and that all listed package files
272
+ match the recorded digest. The same resolution guard stays active while the source
273
+ runs, including for nested and dynamic imports. It caches successful content
274
+ checks per package directory for the lifetime of the command. A mismatch before
275
+ entry evaluation exits 1, reports the error on stderr and points to `npm install`
276
+ and `npm run start` from the export directory. The generated start script uses
277
+ the locally bound CLI.
278
+ Source code can be edited independently of this SDK identity. No credentials
279
+ or Run records are selected by the source allowlist.
280
+
281
+ The lightweight exported Harness contains its own lifecycle, configuration and
282
+ business module. Its changed greeting is observable after editing `business.ts`.
283
+ It uses no model or Runtime resources. Application Issues own their complete
284
+ prompts, Services and source manifests for the same engine.
@@ -8,7 +8,7 @@ Supply `persistence: { deploymentId, contract, retainForMs? }` to `createRuntime
8
8
 
9
9
  The original Lifecycle URL, deployment identity and proxy mode form the connection fingerprint. With explicit Profile network policy, the trusted public callback hostname must resolve on the Controller to one non-loopback IPv4. Core pins that address and exact port in policy while the Worker retains the original URL. A separate configuration fingerprint includes callback configuration, operation limits, retention, model definitions, Profiles, Service manifests, file policy and resource requests/limits. Recovery must reconstruct the same contract and configuration. Host secrets are read from trusted configuration again. The private ledger retains resource credentials needed to reconnect. Keep the Run directory private and on durable storage with verified SQLite and file-lock semantics.
10
10
 
11
- `allocations.sqlite` is opened only in an owned, private directory without symbolic-link resolution. The file is mode 0600. SQLite uses DELETE journaling, FULL synchronization and an EXCLUSIVE connection lock retained across commits. A second live Controller cannot acquire this same-host writer lock. Kernel release on process death permits recovery. Linux boot identity is required. Outside Kubernetes the ledger also uses the hostname and the machine ID when available. The Kubernetes template supplies the node name via the downward API so a recreated Pod can recover on the original node during the same boot. A different node or boot is refused. A single replica, PVC attachment or an expired heartbeat supplies no cross-node fencing proof. Worker epochs alone cannot revoke an old Controller's Lifecycle credentials.
11
+ `allocations.sqlite` is opened only in an owned, private directory without symbolic-link resolution. The file is mode 0600. SQLite uses DELETE journaling, FULL synchronization and an EXCLUSIVE connection lock retained across commits. A second live Controller cannot acquire this same-host writer lock. Kernel release on process death permits recovery. A verified kernel boot identity is required. Linux uses the kernel boot ID and on a non-Kubernetes host includes the hostname and available machine ID. macOS uses the hostname and `kern.bootsessionuuid` obtained from the system `sysctl`; a missing, malformed or timed-out UUID read refuses durable access. The same Darwin boot identifier is shared with managed processes and cached within a live Controller. The Kubernetes template supplies the node name via the downward API so a recreated Pod can recover on the original node during the same boot. A different node or boot is refused. A single replica, PVC attachment or an expired heartbeat supplies no cross-node fencing proof. Worker epochs alone cannot revoke an old Controller's Lifecycle credentials.
12
12
 
13
13
  The ledger stores one Run header, allocations and all discovered resource identities, input receipts and Worker events. Private checkpoints also hold management reconstruction state, original callback tokens, Worker transport credentials and proposed takeover identities. Public traces omit these private values. Storage failure closes input and Service authority and leaves owned resources pending. Restoration never substitutes a fresh empty ledger to claim successful cleanup. [Storage reference](11-storage-reference.md)
14
14
 
@@ -24,6 +24,13 @@ Close commits the Run's closing intent before performing cleanup. Reopening a cl
24
24
 
25
25
  Call `recoverRuntime({ ...originalOptions, runDirectory, cleanupOnly?, restoreService? })`. Recovery checks the existing Run header, configuration, exclusive writer and original resource ownership before reopening listeners and reconnecting Workers. Each acquisition durably advances the Controller epoch. Existing trace files remain intact through recovery-specific trace filenames.
26
26
 
27
+ `anyswarm recover --run-dir <directory> --config <module>` resolves the trusted
28
+ configuration file by real path and loads it with the [author source loader](23-project-harness.md#typescript-author-entry-and-source-export).
29
+ Its default export is the original Runtime options or a zero-argument factory
30
+ that supplies them. The command adds the provided Run directory and cleanup-only
31
+ mode, calls `close`, reports the cleanup receipt as JSON, and leaves unresolved
32
+ resources in the durable record for a later attempt.
33
+
27
34
  The Worker contract advertises a unique instance ID, event-stream epoch, current Controller epoch, supported file/event/control protocols and whether executor startup was admitted. Reconnection checks the exact stored Worker and stream identity. Legacy Workers can still support ordinary live operation but provide no durable recovery contract. Unknown or unsupported startup state permits cleanup only.
28
35
 
29
36
  Before takeover the Controller persists its proposed epoch and expected previous epoch. The authenticated Worker drains admitted controls, fences new controls while draining, atomically persists the new epoch and takeover receipt, and then acknowledges. A repeated takeover identity returns its original receipt. This preserves reconciliation when an acknowledgement is lost and the next Controller also crashes. Commands with an old epoch fail. Worker management authentication remains separate from Agent and model credentials and retains any ingress route authorization.
@@ -81,7 +88,7 @@ The management checkpoint records each Service definition, prepared manifest, ow
81
88
 
82
89
  Recovery reconstructs static adapters from the new Runtime's per-Run factories and resolves dynamic registrations through `restoreService(definition)`. It compares implementation identity, explicit storage identity and any statically available manifest before invoking lifecycle `restore(context)`. Providers with discovered directories reconnect first, discover their actual operations, and then compare that manifest before admission. The context contains the original recorded resource and storage, allowing a provider to verify or reopen them. Restore returns `ready`, `stopped` or `blocked`. Runtime never substitutes a new empty store or implicitly invokes prepare to replace an unverified original instance. A confirmed stopped provider remains stopped until an explicit Host start. A missing adapter or incompatible identity is kept in an unresolved management record, blocks business authority, and keeps cleanup pending.
83
90
 
84
- A closing or cleanup-only Run passes its closing state through restoration. It may reconstruct the adapter needed to stop an original resource, while its Bridge directory stays closed. Lifecycle restoration cannot reopen business input through this path. Original resources stay in the checkpoint until cleanup confirms release, including when the resolver is temporarily unavailable. Linux process restoration checks boot ID and process start time together with PID. A mismatched identity is blocked, preventing accidental termination of a reused PID.
91
+ A closing or cleanup-only Run passes its closing state through restoration. It may reconstruct the adapter needed to stop an original resource, while its Bridge directory stays closed. Lifecycle restoration cannot reopen business input through this path. Original resources stay in the checkpoint until cleanup confirms release, including when the resolver is temporarily unavailable. Process restoration checks boot ID and kernel process start time together with PID. Linux reads `/proc/<pid>/stat`. macOS queries `libproc` using the system JavaScript Objective-C bridge, with a two-second deadline, checks the returned PID and reads the epoch start time at microsecond precision. If the query cannot identify a process, only `ESRCH` from the existence check counts as confirmed absence; an inaccessible process blocks recovery. A mismatched identity is blocked, preventing accidental termination of a reused PID.
85
92
 
86
93
  For cleanup-only recovery of the previous Profile spelling, Runtime also calculates the exact fingerprint with `addedSystemPrompt` mapped to `prompt` and `tools` mapped to `session.tools`. The allocation ledger accepts that single equivalent fingerprint while atomically committing closing state. Other configuration differences, host changes and capacity changes still conflict. The original stored fingerprint remains the Run identity. Active business recovery uses the current exact configuration check. Cleanup-only admission still accepts earlier Profiles with omitted local tools and static Service grants on a model that declares `capabilities.tools: false`. Live admission rejects that combination. If an earlier Run has incompatible dynamic grants in its checkpoint, the Bridge exposes an empty Service directory and denies calls for that model. Host access records retain the original authorization version and can still be inspected or revoked.
87
94
 
@@ -96,4 +103,4 @@ Prepared Service definitions also retain an optional configuration fingerprint.
96
103
 
97
104
  The process helper captures executable, argv, working directory, effective environment, storage, resource settings and readiness/health function identities when constructed, then hashes that configuration. Caller mutation after construction cannot alter its spawn configuration. Recovery compares this fingerprint before using the original PID, start time and boot identity. The public implementation ID remains the Service author's format/implementation contract. A matching implementation ID alone cannot authorize a changed process command or environment.
98
105
 
99
- A managed MCP stdio transport records its PID, Linux start time and OS boot ID immediately after spawn. After Controller loss the stdio pipes cannot be reopened. With a matching configuration and a live process of the recorded identity, the lifecycle reports `disconnected`. Runtime retains the original resource and instance IDs, leaves the Service out of the Bridge directory and reports `blocked` with `SERVICE_NOT_READY`. The ownership receipt still permits Host stop, retire and Runtime close, including cleanup-only recovery. The process stop helper rechecks identity, sends SIGTERM, and polls every 25 ms for exit for up to five seconds. A missing or zombie process counts as exited. The helper also recognizes `ESRCH` when Linux removes an opened `/proc/<pid>/stat` before the read. Failure to read the kernel boot ID is an identity error. A changed identity, stop error or unconfirmed exit leaves cleanup pending. An unresolved remote write still goes through the quiescence check before retirement. Recovery does not spawn a second process or replay an MCP tool call. The installed managed MCP example starts the Controller in a separate Node process with fixed callback and HTTP addresses, an owned MCP child and a managed HTTP process that writes its finding to disk. It waits for the preparation evidence, then sends SIGKILL to that Controller and confirms both processes survived. Ordinary recovery checks the original Runtime and instance IDs, the ready HTTP instance, its original storage and finding, and the blocked MCP instance. Closing must stop the original process identities. The example repeats from a fresh Run with cleanup-only recovery, which never opens business admission. It requires the same host boot, executable and arguments, storage location and callback configuration. Each run prints its cleanup receipt and report path.
106
+ A managed MCP stdio transport records its PID, kernel start time and OS boot ID immediately after spawn. After Controller loss the stdio pipes cannot be reopened. With a matching configuration and a live process of the recorded identity, the lifecycle reports `disconnected`. Runtime retains the original resource and instance IDs, leaves the Service out of the Bridge directory and reports `blocked` with `SERVICE_NOT_READY`. The ownership receipt still permits Host stop, retire and Runtime close, including cleanup-only recovery. The process stop helper rechecks identity, sends SIGTERM, and polls every 25 ms for exit for up to five seconds. A missing or zombie process counts as exited. The helper also recognizes `ESRCH` when Linux removes an opened `/proc/<pid>/stat` before the read. Failure to read the kernel boot ID is an identity error. A changed identity, stop error or unconfirmed exit leaves cleanup pending. An unresolved remote write still goes through the quiescence check before retirement. Recovery does not spawn a second process or replay an MCP tool call. The installed managed MCP example starts the Controller in a separate Node process with fixed callback and HTTP addresses, an owned MCP child and a managed HTTP process that writes its finding to disk. It waits for the preparation evidence, then sends SIGKILL to that Controller and confirms both processes survived. Ordinary recovery checks the original Runtime and instance IDs, the ready HTTP instance, its original storage and finding, and the blocked MCP instance. Closing must stop the original process identities. The example repeats from a fresh Run with cleanup-only recovery, which never opens business admission. It requires the same host boot, executable and arguments, storage location and callback configuration. Each run prints its cleanup receipt and report path.