create-principles-disciple 1.154.5 → 1.155.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 (428) hide show
  1. package/_release/product-identity.json +2 -2
  2. package/codex-adapter/dist/codec/input-decoder.d.ts +17 -0
  3. package/codex-adapter/dist/codec/input-decoder.js +39 -0
  4. package/codex-adapter/dist/ingestion/explicit-owner-statement.js +125 -1
  5. package/codex-adapter/dist/ingestion/pain-receipt-fallback.d.ts +46 -0
  6. package/codex-adapter/dist/ingestion/pain-receipt-fallback.js +193 -0
  7. package/codex-adapter/dist/ingestion/turn-context.d.ts +10 -15
  8. package/codex-adapter/dist/ingestion/turn-context.js +35 -9
  9. package/codex-adapter/dist/pd-hook.js +57 -1
  10. package/codex-adapter/dist/worker/workspace-worker.d.ts +15 -0
  11. package/codex-adapter/dist/worker/workspace-worker.js +91 -12
  12. package/codex-adapter/package.json +1 -1
  13. package/console/dist/server/index.js +11 -0
  14. package/console/dist/server/models/EvidenceChainConsoleModel.js +31 -0
  15. package/console/dist/server/routes/health.d.ts +1 -0
  16. package/console/dist/server/routes/health.js +12 -0
  17. package/console/dist/server/routes/service-host.d.ts +19 -0
  18. package/console/dist/server/routes/service-host.js +129 -0
  19. package/console/dist/web/assets/app.js +39 -39
  20. package/console/package.json +1 -1
  21. package/core/dist/runtime/adapter/pi-ai-http-transport.d.ts.map +1 -1
  22. package/core/dist/runtime/adapter/pi-ai-http-transport.js.map +1 -1
  23. package/core/dist/runtime/context-payload.d.ts +48 -0
  24. package/core/dist/runtime/context-payload.d.ts.map +1 -1
  25. package/core/dist/runtime/context-payload.js +12 -0
  26. package/core/dist/runtime/context-payload.js.map +1 -1
  27. package/core/dist/runtime/diagnostician/rootcause-prompt-builder.d.ts.map +1 -1
  28. package/core/dist/runtime/diagnostician/rootcause-prompt-builder.js +18 -0
  29. package/core/dist/runtime/diagnostician/rootcause-prompt-builder.js.map +1 -1
  30. package/core/dist/runtime/diagnostician-candidate.d.ts.map +1 -1
  31. package/core/dist/runtime/diagnostician-candidate.js +18 -2
  32. package/core/dist/runtime/diagnostician-candidate.js.map +1 -1
  33. package/core/dist/runtime/evidence-guards.d.ts +7 -3
  34. package/core/dist/runtime/evidence-guards.d.ts.map +1 -1
  35. package/core/dist/runtime/evidence-guards.js +9 -7
  36. package/core/dist/runtime/evidence-guards.js.map +1 -1
  37. package/core/dist/runtime/feature-flags/feature-flag-contract.d.ts.map +1 -1
  38. package/core/dist/runtime/feature-flags/feature-flag-contract.js +14 -0
  39. package/core/dist/runtime/feature-flags/feature-flag-contract.js.map +1 -1
  40. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.d.ts.map +1 -1
  41. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js +8 -0
  42. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js.map +1 -1
  43. package/core/dist/runtime/host-submission-context.d.ts +83 -0
  44. package/core/dist/runtime/host-submission-context.d.ts.map +1 -0
  45. package/core/dist/runtime/host-submission-context.js +183 -0
  46. package/core/dist/runtime/host-submission-context.js.map +1 -0
  47. package/core/dist/runtime/index.d.ts +9 -2
  48. package/core/dist/runtime/index.d.ts.map +1 -1
  49. package/core/dist/runtime/index.js +29 -2
  50. package/core/dist/runtime/index.js.map +1 -1
  51. package/core/dist/runtime/intent/intent-doc.d.ts.map +1 -1
  52. package/core/dist/runtime/intent/intent-doc.js +29 -5
  53. package/core/dist/runtime/intent/intent-doc.js.map +1 -1
  54. package/core/dist/runtime/internalization/diag-distiller-runner.d.ts +9 -0
  55. package/core/dist/runtime/internalization/diag-distiller-runner.d.ts.map +1 -1
  56. package/core/dist/runtime/internalization/diag-distiller-runner.js +13 -0
  57. package/core/dist/runtime/internalization/diag-distiller-runner.js.map +1 -1
  58. package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts +11 -0
  59. package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts.map +1 -1
  60. package/core/dist/runtime/internalization/diag-rootcause-runner.js +10 -0
  61. package/core/dist/runtime/internalization/diag-rootcause-runner.js.map +1 -1
  62. package/core/dist/runtime/internalization/diag-router-runner.d.ts +9 -0
  63. package/core/dist/runtime/internalization/diag-router-runner.d.ts.map +1 -1
  64. package/core/dist/runtime/internalization/diag-router-runner.js +13 -0
  65. package/core/dist/runtime/internalization/diag-router-runner.js.map +1 -1
  66. package/core/dist/runtime/internalization/index.d.ts +1 -1
  67. package/core/dist/runtime/internalization/index.d.ts.map +1 -1
  68. package/core/dist/runtime/internalization/index.js +1 -1
  69. package/core/dist/runtime/internalization/index.js.map +1 -1
  70. package/core/dist/runtime/internalization/intake-to-internalization-bridge.d.ts +19 -0
  71. package/core/dist/runtime/internalization/intake-to-internalization-bridge.d.ts.map +1 -1
  72. package/core/dist/runtime/internalization/intake-to-internalization-bridge.js +24 -0
  73. package/core/dist/runtime/internalization/intake-to-internalization-bridge.js.map +1 -1
  74. package/core/dist/runtime/internalization/internalization-orchestrator.d.ts +8 -0
  75. package/core/dist/runtime/internalization/internalization-orchestrator.d.ts.map +1 -1
  76. package/core/dist/runtime/internalization/internalization-orchestrator.js +36 -4
  77. package/core/dist/runtime/internalization/internalization-orchestrator.js.map +1 -1
  78. package/core/dist/runtime/internalization/source-authorization-boundary.d.ts +39 -0
  79. package/core/dist/runtime/internalization/source-authorization-boundary.d.ts.map +1 -0
  80. package/core/dist/runtime/internalization/source-authorization-boundary.js +57 -0
  81. package/core/dist/runtime/internalization/source-authorization-boundary.js.map +1 -0
  82. package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts.map +1 -1
  83. package/core/dist/runtime/internalization/split-diagnostician-runner.js +72 -5
  84. package/core/dist/runtime/internalization/split-diagnostician-runner.js.map +1 -1
  85. package/core/dist/runtime/pain-admission-disposition.d.ts +60 -0
  86. package/core/dist/runtime/pain-admission-disposition.d.ts.map +1 -0
  87. package/core/dist/runtime/pain-admission-disposition.js +37 -0
  88. package/core/dist/runtime/pain-admission-disposition.js.map +1 -0
  89. package/core/dist/runtime/pain-ingress-payload.d.ts +36 -2
  90. package/core/dist/runtime/pain-ingress-payload.d.ts.map +1 -1
  91. package/core/dist/runtime/pain-ingress-payload.js +63 -6
  92. package/core/dist/runtime/pain-ingress-payload.js.map +1 -1
  93. package/core/dist/runtime/pain-ingress.d.ts.map +1 -1
  94. package/core/dist/runtime/pain-ingress.js +28 -0
  95. package/core/dist/runtime/pain-ingress.js.map +1 -1
  96. package/core/dist/runtime/pain-recall-read-model.d.ts +13 -1
  97. package/core/dist/runtime/pain-recall-read-model.d.ts.map +1 -1
  98. package/core/dist/runtime/pain-recall-read-model.js +50 -7
  99. package/core/dist/runtime/pain-recall-read-model.js.map +1 -1
  100. package/core/dist/runtime/pain-receipt-recovery.d.ts +147 -0
  101. package/core/dist/runtime/pain-receipt-recovery.d.ts.map +1 -0
  102. package/core/dist/runtime/pain-receipt-recovery.js +475 -0
  103. package/core/dist/runtime/pain-receipt-recovery.js.map +1 -0
  104. package/core/dist/runtime/pain-signal-bridge.d.ts +13 -1
  105. package/core/dist/runtime/pain-signal-bridge.d.ts.map +1 -1
  106. package/core/dist/runtime/pain-signal-bridge.js +174 -0
  107. package/core/dist/runtime/pain-signal-bridge.js.map +1 -1
  108. package/core/dist/runtime/pain-signal-runtime-factory.d.ts +9 -0
  109. package/core/dist/runtime/pain-signal-runtime-factory.d.ts.map +1 -1
  110. package/core/dist/runtime/pain-signal-runtime-factory.js +8 -3
  111. package/core/dist/runtime/pain-signal-runtime-factory.js.map +1 -1
  112. package/core/dist/runtime/pain-submit-capability.d.ts +11 -0
  113. package/core/dist/runtime/pain-submit-capability.d.ts.map +1 -1
  114. package/core/dist/runtime/pain-submit-capability.js +77 -3
  115. package/core/dist/runtime/pain-submit-capability.js.map +1 -1
  116. package/core/dist/runtime/pain-target-evidence-reconcile.d.ts +55 -0
  117. package/core/dist/runtime/pain-target-evidence-reconcile.d.ts.map +1 -0
  118. package/core/dist/runtime/pain-target-evidence-reconcile.js +164 -0
  119. package/core/dist/runtime/pain-target-evidence-reconcile.js.map +1 -0
  120. package/core/dist/runtime/pain-to-principle-service.d.ts +8 -0
  121. package/core/dist/runtime/pain-to-principle-service.d.ts.map +1 -1
  122. package/core/dist/runtime/pain-to-principle-service.js +1 -0
  123. package/core/dist/runtime/pain-to-principle-service.js.map +1 -1
  124. package/core/dist/runtime/source-material-authorization.d.ts +166 -0
  125. package/core/dist/runtime/source-material-authorization.d.ts.map +1 -0
  126. package/core/dist/runtime/source-material-authorization.js +250 -0
  127. package/core/dist/runtime/source-material-authorization.js.map +1 -0
  128. package/core/dist/runtime/store/context/index.d.ts +1 -0
  129. package/core/dist/runtime/store/context/index.d.ts.map +1 -1
  130. package/core/dist/runtime/store/context/index.js +1 -0
  131. package/core/dist/runtime/store/context/index.js.map +1 -1
  132. package/core/dist/runtime/store/context/promoted-evidence-reader.d.ts +8 -0
  133. package/core/dist/runtime/store/context/promoted-evidence-reader.d.ts.map +1 -1
  134. package/core/dist/runtime/store/context/promoted-evidence-reader.js +15 -1
  135. package/core/dist/runtime/store/context/promoted-evidence-reader.js.map +1 -1
  136. package/core/dist/runtime/store/context/sqlite-context-assembler.d.ts +22 -0
  137. package/core/dist/runtime/store/context/sqlite-context-assembler.d.ts.map +1 -1
  138. package/core/dist/runtime/store/context/sqlite-context-assembler.js +153 -3
  139. package/core/dist/runtime/store/context/sqlite-context-assembler.js.map +1 -1
  140. package/core/dist/runtime/store/context/trajectory-turn-reader.d.ts +13 -0
  141. package/core/dist/runtime/store/context/trajectory-turn-reader.d.ts.map +1 -1
  142. package/core/dist/runtime/store/lifecycle/lease-manager.d.ts +15 -0
  143. package/core/dist/runtime/store/lifecycle/lease-manager.d.ts.map +1 -1
  144. package/core/dist/runtime/store/lifecycle/lease-manager.js +16 -1
  145. package/core/dist/runtime/store/lifecycle/lease-manager.js.map +1 -1
  146. package/core/dist/runtime/store/runtime-state-manager.d.ts +2 -0
  147. package/core/dist/runtime/store/runtime-state-manager.d.ts.map +1 -1
  148. package/core/dist/runtime/store/runtime-state-manager.js.map +1 -1
  149. package/core/dist/runtime/store/task/memory-task-store.d.ts +1 -0
  150. package/core/dist/runtime/store/task/memory-task-store.d.ts.map +1 -1
  151. package/core/dist/runtime/store/task/memory-task-store.js +37 -0
  152. package/core/dist/runtime/store/task/memory-task-store.js.map +1 -1
  153. package/core/dist/runtime/store/task/sqlite-task-store.d.ts +10 -0
  154. package/core/dist/runtime/store/task/sqlite-task-store.d.ts.map +1 -1
  155. package/core/dist/runtime/store/task/sqlite-task-store.js +20 -0
  156. package/core/dist/runtime/store/task/sqlite-task-store.js.map +1 -1
  157. package/core/dist/runtime/store/task/task-store.d.ts +16 -0
  158. package/core/dist/runtime/store/task/task-store.d.ts.map +1 -1
  159. package/core/dist/runtime/task-status.d.ts +13 -0
  160. package/core/dist/runtime/task-status.d.ts.map +1 -1
  161. package/core/dist/runtime/task-status.js +9 -0
  162. package/core/dist/runtime/task-status.js.map +1 -1
  163. package/core/dist/runtime/types/evidence-chain-contract.d.ts +10 -0
  164. package/core/dist/runtime/types/evidence-chain-contract.d.ts.map +1 -1
  165. package/core/dist/runtime/types/evidence-chain-contract.js +7 -0
  166. package/core/dist/runtime/types/evidence-chain-contract.js.map +1 -1
  167. package/core/package.json +2 -2
  168. package/dist/index.d.ts.map +1 -1
  169. package/dist/index.js +11 -0
  170. package/dist/index.js.map +1 -1
  171. package/dist/installer.d.ts.map +1 -1
  172. package/dist/installer.js +77 -30
  173. package/dist/installer.js.map +1 -1
  174. package/dist/installers/mcp-registration-conflict.d.ts +8 -0
  175. package/dist/installers/mcp-registration-conflict.d.ts.map +1 -1
  176. package/dist/installers/mcp-registration-conflict.js +34 -1
  177. package/dist/installers/mcp-registration-conflict.js.map +1 -1
  178. package/dist/installers/workbuddy-host-installer.d.ts +45 -13
  179. package/dist/installers/workbuddy-host-installer.d.ts.map +1 -1
  180. package/dist/installers/workbuddy-host-installer.js +284 -21
  181. package/dist/installers/workbuddy-host-installer.js.map +1 -1
  182. package/dist/prompts.d.ts +11 -0
  183. package/dist/prompts.d.ts.map +1 -1
  184. package/dist/prompts.js +4 -0
  185. package/dist/prompts.js.map +1 -1
  186. package/dist/service-host-bridge.d.ts +67 -0
  187. package/dist/service-host-bridge.d.ts.map +1 -0
  188. package/dist/service-host-bridge.js +292 -0
  189. package/dist/service-host-bridge.js.map +1 -0
  190. package/dist/uninstaller.d.ts.map +1 -1
  191. package/dist/uninstaller.js +26 -0
  192. package/dist/uninstaller.js.map +1 -1
  193. package/dist/update/install-layout.d.ts +0 -12
  194. package/dist/update/install-layout.d.ts.map +1 -1
  195. package/dist/update/install-layout.js +42 -15
  196. package/dist/update/install-layout.js.map +1 -1
  197. package/host-runtime/dist/diagnostician-auto-run.js +4 -1
  198. package/host-runtime/dist/governance-observation-store.d.ts +7 -0
  199. package/host-runtime/dist/governance-observation-store.js +15 -4
  200. package/host-runtime/dist/governance-signal-admission.d.ts +49 -0
  201. package/host-runtime/dist/governance-signal-admission.js +355 -94
  202. package/host-runtime/dist/governance-trajectory-turn-reader.d.ts +20 -4
  203. package/host-runtime/dist/governance-trajectory-turn-reader.js +77 -5
  204. package/host-runtime/dist/index.d.ts +2 -0
  205. package/host-runtime/dist/index.js +5 -0
  206. package/host-runtime/dist/internalization-consumer-cycle.js +4 -1
  207. package/host-runtime/dist/pd-config.d.ts +10 -0
  208. package/host-runtime/dist/pd-config.js +37 -0
  209. package/host-runtime/dist/signal-stage2-cycle.js +28 -1
  210. package/host-runtime/dist/source-material-authorization.d.ts +53 -0
  211. package/host-runtime/dist/source-material-authorization.js +67 -0
  212. package/host-runtime/dist/source-revocation-sweep.d.ts +172 -0
  213. package/host-runtime/dist/source-revocation-sweep.js +928 -0
  214. package/host-runtime/package.json +5 -1
  215. package/install-layout/dist/background-execution-transition.d.ts +258 -0
  216. package/install-layout/dist/background-execution-transition.js +836 -0
  217. package/install-layout/dist/index.d.ts +8 -0
  218. package/install-layout/dist/index.js +8 -0
  219. package/install-layout/package.json +6 -2
  220. package/package.json +7 -6
  221. package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
  222. package/pd-cli/dist/commands/candidate.js +16 -5
  223. package/pd-cli/dist/commands/candidate.js.map +1 -1
  224. package/pd-cli/dist/commands/codex-setup.d.ts.map +1 -1
  225. package/pd-cli/dist/commands/codex-setup.js +17 -1
  226. package/pd-cli/dist/commands/codex-setup.js.map +1 -1
  227. package/pd-cli/dist/commands/codex-worker.d.ts.map +1 -1
  228. package/pd-cli/dist/commands/codex-worker.js +8 -4
  229. package/pd-cli/dist/commands/codex-worker.js.map +1 -1
  230. package/pd-cli/dist/commands/consent-sweep-revoked.d.ts +20 -0
  231. package/pd-cli/dist/commands/consent-sweep-revoked.d.ts.map +1 -0
  232. package/pd-cli/dist/commands/consent-sweep-revoked.js +85 -0
  233. package/pd-cli/dist/commands/consent-sweep-revoked.js.map +1 -0
  234. package/pd-cli/dist/commands/console.d.ts.map +1 -1
  235. package/pd-cli/dist/commands/console.js +9 -0
  236. package/pd-cli/dist/commands/console.js.map +1 -1
  237. package/pd-cli/dist/commands/context.d.ts.map +1 -1
  238. package/pd-cli/dist/commands/context.js +9 -1
  239. package/pd-cli/dist/commands/context.js.map +1 -1
  240. package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
  241. package/pd-cli/dist/commands/diagnose.js +12 -6
  242. package/pd-cli/dist/commands/diagnose.js.map +1 -1
  243. package/pd-cli/dist/commands/health-console.d.ts +1 -1
  244. package/pd-cli/dist/commands/health-console.d.ts.map +1 -1
  245. package/pd-cli/dist/commands/health-console.js +15 -1
  246. package/pd-cli/dist/commands/health-console.js.map +1 -1
  247. package/pd-cli/dist/commands/health.d.ts.map +1 -1
  248. package/pd-cli/dist/commands/health.js +7 -1
  249. package/pd-cli/dist/commands/health.js.map +1 -1
  250. package/pd-cli/dist/commands/openclaw-worker.d.ts +11 -0
  251. package/pd-cli/dist/commands/openclaw-worker.d.ts.map +1 -0
  252. package/pd-cli/dist/commands/openclaw-worker.js +199 -0
  253. package/pd-cli/dist/commands/openclaw-worker.js.map +1 -0
  254. package/pd-cli/dist/commands/pain-explicit.d.ts.map +1 -1
  255. package/pd-cli/dist/commands/pain-explicit.js +1 -0
  256. package/pd-cli/dist/commands/pain-explicit.js.map +1 -1
  257. package/pd-cli/dist/commands/pain-recall.d.ts +2 -2
  258. package/pd-cli/dist/commands/pain-recall.d.ts.map +1 -1
  259. package/pd-cli/dist/commands/pain-recall.js +7 -1
  260. package/pd-cli/dist/commands/pain-recall.js.map +1 -1
  261. package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
  262. package/pd-cli/dist/commands/pain-retry.js +12 -6
  263. package/pd-cli/dist/commands/pain-retry.js.map +1 -1
  264. package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.d.ts.map +1 -1
  265. package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js +2 -1
  266. package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js.map +1 -1
  267. package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts +1 -0
  268. package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
  269. package/pd-cli/dist/commands/runtime-internalization-run-once.js +32 -8
  270. package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
  271. package/pd-cli/dist/commands/runtime-internalization-wake-once.d.ts.map +1 -1
  272. package/pd-cli/dist/commands/runtime-internalization-wake-once.js +2 -1
  273. package/pd-cli/dist/commands/runtime-internalization-wake-once.js.map +1 -1
  274. package/pd-cli/dist/commands/service-handover.d.ts +12 -0
  275. package/pd-cli/dist/commands/service-handover.d.ts.map +1 -0
  276. package/pd-cli/dist/commands/service-handover.js +117 -0
  277. package/pd-cli/dist/commands/service-handover.js.map +1 -0
  278. package/pd-cli/dist/commands/service-lifecycle.d.ts +31 -0
  279. package/pd-cli/dist/commands/service-lifecycle.d.ts.map +1 -0
  280. package/pd-cli/dist/commands/service-lifecycle.js +207 -0
  281. package/pd-cli/dist/commands/service-lifecycle.js.map +1 -0
  282. package/pd-cli/dist/commands/service-run-once.d.ts +96 -0
  283. package/pd-cli/dist/commands/service-run-once.d.ts.map +1 -1
  284. package/pd-cli/dist/commands/service-run-once.js +432 -13
  285. package/pd-cli/dist/commands/service-run-once.js.map +1 -1
  286. package/pd-cli/dist/commands/workbuddy-setup.d.ts.map +1 -1
  287. package/pd-cli/dist/commands/workbuddy-setup.js +22 -2
  288. package/pd-cli/dist/commands/workbuddy-setup.js.map +1 -1
  289. package/pd-cli/dist/program.d.ts.map +1 -1
  290. package/pd-cli/dist/program.js +167 -9
  291. package/pd-cli/dist/program.js.map +1 -1
  292. package/pd-cli/dist/services/admission-write-gate.d.ts +3 -1
  293. package/pd-cli/dist/services/admission-write-gate.d.ts.map +1 -1
  294. package/pd-cli/dist/services/admission-write-gate.js +1 -0
  295. package/pd-cli/dist/services/admission-write-gate.js.map +1 -1
  296. package/pd-cli/dist/services/console-launcher.d.ts +93 -1
  297. package/pd-cli/dist/services/console-launcher.d.ts.map +1 -1
  298. package/pd-cli/dist/services/console-launcher.js +375 -10
  299. package/pd-cli/dist/services/console-launcher.js.map +1 -1
  300. package/pd-cli/dist/services/service-host/coordinator-common.d.ts +49 -0
  301. package/pd-cli/dist/services/service-host/coordinator-common.d.ts.map +1 -0
  302. package/pd-cli/dist/services/service-host/coordinator-common.js +158 -0
  303. package/pd-cli/dist/services/service-host/coordinator-common.js.map +1 -0
  304. package/pd-cli/dist/services/service-host/handover-claims.d.ts +14 -0
  305. package/pd-cli/dist/services/service-host/handover-claims.d.ts.map +1 -0
  306. package/pd-cli/dist/services/service-host/handover-claims.js +50 -0
  307. package/pd-cli/dist/services/service-host/handover-claims.js.map +1 -0
  308. package/pd-cli/dist/services/service-host/index.d.ts +19 -3
  309. package/pd-cli/dist/services/service-host/index.d.ts.map +1 -1
  310. package/pd-cli/dist/services/service-host/index.js +21 -3
  311. package/pd-cli/dist/services/service-host/index.js.map +1 -1
  312. package/pd-cli/dist/services/service-host/install-identity.d.ts +23 -3
  313. package/pd-cli/dist/services/service-host/install-identity.d.ts.map +1 -1
  314. package/pd-cli/dist/services/service-host/install-identity.js +15 -5
  315. package/pd-cli/dist/services/service-host/install-identity.js.map +1 -1
  316. package/pd-cli/dist/services/service-host/locking/service-run-lock.d.ts +130 -9
  317. package/pd-cli/dist/services/service-host/locking/service-run-lock.d.ts.map +1 -1
  318. package/pd-cli/dist/services/service-host/locking/service-run-lock.js +99 -19
  319. package/pd-cli/dist/services/service-host/locking/service-run-lock.js.map +1 -1
  320. package/pd-cli/dist/services/service-host/managed-run.d.ts +75 -0
  321. package/pd-cli/dist/services/service-host/managed-run.d.ts.map +1 -0
  322. package/pd-cli/dist/services/service-host/managed-run.js +550 -0
  323. package/pd-cli/dist/services/service-host/managed-run.js.map +1 -0
  324. package/pd-cli/dist/services/service-host/progress-evidence.d.ts +38 -0
  325. package/pd-cli/dist/services/service-host/progress-evidence.d.ts.map +1 -0
  326. package/pd-cli/dist/services/service-host/progress-evidence.js +155 -0
  327. package/pd-cli/dist/services/service-host/progress-evidence.js.map +1 -0
  328. package/pd-cli/dist/services/service-host/run-once.d.ts.map +1 -1
  329. package/pd-cli/dist/services/service-host/run-once.js +4 -136
  330. package/pd-cli/dist/services/service-host/run-once.js.map +1 -1
  331. package/pd-cli/dist/services/service-host/scheduler/contract.d.ts +184 -0
  332. package/pd-cli/dist/services/service-host/scheduler/contract.d.ts.map +1 -0
  333. package/pd-cli/dist/services/service-host/scheduler/contract.js +86 -0
  334. package/pd-cli/dist/services/service-host/scheduler/contract.js.map +1 -0
  335. package/pd-cli/dist/services/service-host/scheduler/index.d.ts +76 -0
  336. package/pd-cli/dist/services/service-host/scheduler/index.d.ts.map +1 -0
  337. package/pd-cli/dist/services/service-host/scheduler/index.js +128 -0
  338. package/pd-cli/dist/services/service-host/scheduler/index.js.map +1 -0
  339. package/pd-cli/dist/services/service-host/scheduler/linux.d.ts +27 -0
  340. package/pd-cli/dist/services/service-host/scheduler/linux.d.ts.map +1 -0
  341. package/pd-cli/dist/services/service-host/scheduler/linux.js +1010 -0
  342. package/pd-cli/dist/services/service-host/scheduler/linux.js.map +1 -0
  343. package/pd-cli/dist/services/service-host/scheduler/macos.d.ts +13 -0
  344. package/pd-cli/dist/services/service-host/scheduler/macos.d.ts.map +1 -0
  345. package/pd-cli/dist/services/service-host/scheduler/macos.js +819 -0
  346. package/pd-cli/dist/services/service-host/scheduler/macos.js.map +1 -0
  347. package/pd-cli/dist/services/service-host/scheduler/runtime-io.d.ts +13 -0
  348. package/pd-cli/dist/services/service-host/scheduler/runtime-io.d.ts.map +1 -0
  349. package/pd-cli/dist/services/service-host/scheduler/runtime-io.js +141 -0
  350. package/pd-cli/dist/services/service-host/scheduler/runtime-io.js.map +1 -0
  351. package/pd-cli/dist/services/service-host/scheduler/service-status.d.ts +99 -0
  352. package/pd-cli/dist/services/service-host/scheduler/service-status.d.ts.map +1 -0
  353. package/pd-cli/dist/services/service-host/scheduler/service-status.js +202 -0
  354. package/pd-cli/dist/services/service-host/scheduler/service-status.js.map +1 -0
  355. package/pd-cli/dist/services/service-host/scheduler/windows.d.ts +40 -0
  356. package/pd-cli/dist/services/service-host/scheduler/windows.d.ts.map +1 -0
  357. package/pd-cli/dist/services/service-host/scheduler/windows.js +688 -0
  358. package/pd-cli/dist/services/service-host/scheduler/windows.js.map +1 -0
  359. package/pd-cli/dist/services/service-host/shadow-progress-store.d.ts +43 -0
  360. package/pd-cli/dist/services/service-host/shadow-progress-store.d.ts.map +1 -0
  361. package/pd-cli/dist/services/service-host/shadow-progress-store.js +156 -0
  362. package/pd-cli/dist/services/service-host/shadow-progress-store.js.map +1 -0
  363. package/pd-cli/dist/services/service-host/shadow-run.d.ts +87 -0
  364. package/pd-cli/dist/services/service-host/shadow-run.d.ts.map +1 -0
  365. package/pd-cli/dist/services/service-host/shadow-run.js +549 -0
  366. package/pd-cli/dist/services/service-host/shadow-run.js.map +1 -0
  367. package/pd-cli/dist/services/service-host/status/service-run-status.d.ts +114 -4
  368. package/pd-cli/dist/services/service-host/status/service-run-status.d.ts.map +1 -1
  369. package/pd-cli/dist/services/service-host/status/service-run-status.js +37 -0
  370. package/pd-cli/dist/services/service-host/status/service-run-status.js.map +1 -1
  371. package/pd-cli/dist/services/service-host/worker-adapter-codex.d.ts +2 -0
  372. package/pd-cli/dist/services/service-host/worker-adapter-codex.d.ts.map +1 -0
  373. package/pd-cli/dist/services/service-host/worker-adapter-codex.js +76 -0
  374. package/pd-cli/dist/services/service-host/worker-adapter-codex.js.map +1 -0
  375. package/pd-cli/dist/services/service-host/worker-adapter-openclaw.d.ts +2 -0
  376. package/pd-cli/dist/services/service-host/worker-adapter-openclaw.d.ts.map +1 -0
  377. package/pd-cli/dist/services/service-host/worker-adapter-openclaw.js +49 -0
  378. package/pd-cli/dist/services/service-host/worker-adapter-openclaw.js.map +1 -0
  379. package/pd-cli/dist/services/service-host/worker-adapter-workbuddy.d.ts +2 -0
  380. package/pd-cli/dist/services/service-host/worker-adapter-workbuddy.d.ts.map +1 -0
  381. package/pd-cli/dist/services/service-host/worker-adapter-workbuddy.js +36 -0
  382. package/pd-cli/dist/services/service-host/worker-adapter-workbuddy.js.map +1 -0
  383. package/pd-cli/dist/services/service-host/worker-adapter.d.ts +187 -0
  384. package/pd-cli/dist/services/service-host/worker-adapter.d.ts.map +1 -0
  385. package/pd-cli/dist/services/service-host/worker-adapter.js +609 -0
  386. package/pd-cli/dist/services/service-host/worker-adapter.js.map +1 -0
  387. package/pd-cli/dist/services/service-host/worker-env.d.ts +84 -0
  388. package/pd-cli/dist/services/service-host/worker-env.d.ts.map +1 -0
  389. package/pd-cli/dist/services/service-host/worker-env.js +195 -0
  390. package/pd-cli/dist/services/service-host/worker-env.js.map +1 -0
  391. package/pd-cli/dist/services/service-host/worker-process.d.ts +75 -0
  392. package/pd-cli/dist/services/service-host/worker-process.d.ts.map +1 -0
  393. package/pd-cli/dist/services/service-host/worker-process.js +225 -0
  394. package/pd-cli/dist/services/service-host/worker-process.js.map +1 -0
  395. package/pd-cli/dist/services/service-host/workspace-dispatch.d.ts +61 -0
  396. package/pd-cli/dist/services/service-host/workspace-dispatch.d.ts.map +1 -0
  397. package/pd-cli/dist/services/service-host/workspace-dispatch.js +105 -0
  398. package/pd-cli/dist/services/service-host/workspace-dispatch.js.map +1 -0
  399. package/pd-cli/dist/services/service-host/workspace-handover.d.ts +190 -0
  400. package/pd-cli/dist/services/service-host/workspace-handover.d.ts.map +1 -0
  401. package/pd-cli/dist/services/service-host/workspace-handover.js +1393 -0
  402. package/pd-cli/dist/services/service-host/workspace-handover.js.map +1 -0
  403. package/pd-cli/package.json +6 -5
  404. package/pd-mcp-server/dist/submit-assembly.js +159 -42
  405. package/pd-mcp-server/dist/version.d.ts +1 -1
  406. package/pd-mcp-server/dist/version.js +1 -1
  407. package/pd-mcp-server/package.json +1 -1
  408. package/plugin/dist/bundle.js +662 -637
  409. package/plugin/dist/openclaw-worker.d.ts +92 -0
  410. package/plugin/dist/openclaw-worker.js +2446 -0
  411. package/plugin/dist/openclaw.plugin.json +1 -1
  412. package/plugin/dist/service/gateway-consumer-lease.d.ts +142 -0
  413. package/plugin/dist/service/gateway-quiesce-ack.d.ts +40 -0
  414. package/plugin/dist/service/internalization-auto-consumer-service.d.ts +68 -1
  415. package/plugin/openclaw.plugin.json +1 -1
  416. package/plugin/package.json +5 -1
  417. package/release-manager/dist/installer.js +77 -30
  418. package/release-manager/dist/installers/mcp-registration-conflict.js +34 -1
  419. package/release-manager/dist/installers/workbuddy-host-installer.js +284 -21
  420. package/release-manager/dist/service-host-bridge.js +292 -0
  421. package/release-manager/dist/update/install-layout.js +42 -15
  422. package/release-manager/package.json +5 -4
  423. package/workbuddy-adapter/dist/index.d.ts +1 -1
  424. package/workbuddy-adapter/dist/index.js +1 -1
  425. package/workbuddy-adapter/dist/worker/workspace-worker.d.ts +7 -0
  426. package/workbuddy-adapter/dist/worker/workspace-worker.js +179 -10
  427. package/workbuddy-adapter/package.json +1 -1
  428. package/workbuddy-adapter/plugin/.codebuddy-plugin/plugin.json +2 -2
@@ -0,0 +1,550 @@
1
+ /**
2
+ * The Phase 3 managed-run coordinator (SPEC-PD-SERVICE-HOST-001 §11 Phase 3,
3
+ * PRI-1281 task §4) — the OS scheduler's execution entry:
4
+ *
5
+ * pd service run-once --json [--trigger scheduler] [--pd-home <dir>]
6
+ *
7
+ * Runs the SAME trusted prefix as dry-run/shadow (identity → install lock →
8
+ * active release → manifest → validated claims → discovery), then admits
9
+ * workspaces by the §8.4 ownership projection INSTEAD of an explicit
10
+ * selection:
11
+ *
12
+ * - `effectiveOwner=service_host` + `state=service_host_owned` + an
13
+ * `authorized` discovery verdict → ONE bounded real Worker cycle per
14
+ * bound host adapter (shared dispatch core with shadow);
15
+ * - `legacy_owned` → skipped, the legacy owner stays the unique consumer;
16
+ * - `handover_preparing` / `rollback_pending` → NEVER executed (forbidden);
17
+ * - conflicting owner projection / non-authorized verdict → refused-skip,
18
+ * fail-closed per workspace;
19
+ * - manifest or marker unreadable → the whole run refuses (fail-closed —
20
+ * inherited from the trusted prefix, marker validity is manifest-level).
21
+ *
22
+ * Zero service_host_owned workspaces is a LEGAL empty execution
23
+ * (`no_service_host_owned_workspaces`): no Worker starts, nothing fails.
24
+ * Overlapping triggers converge on the Phase 1 install-level single-instance
25
+ * lock; task-level concurrency stays with the existing Durable Lease.
26
+ */
27
+ import * as fs from 'node:fs';
28
+ import * as path from 'node:path';
29
+ import { randomUUID } from 'node:crypto';
30
+ import { collectHostWorkspaceClaims } from '@principles/install-layout';
31
+ import { loadHostToolDeclarations } from '@principles/host-runtime';
32
+ import { resolveCoordinatorInstallIdentity, } from './install-identity.js';
33
+ import { discoverWorkspaces } from './workspace-discovery.js';
34
+ import { projectWorkspaceOwnerAliases } from './owner-projection.js';
35
+ import { buildEmptyDiscovery, claimOptionsFor, defaultListDir, discoveryIncompleteRoots, hostRootReports, manifestSection, readManifest, } from './coordinator-common.js';
36
+ import { mergeShadowProgress, readShadowProgress, } from './shadow-progress-store.js';
37
+ import { acquireServiceRunLock, holdsServiceRunLock, releaseServiceRunLock, serviceRunLockPath, } from './locking/service-run-lock.js';
38
+ import { readActiveReleaseFacts, writeServiceRunStatus, } from './status/service-run-status.js';
39
+ import { MANAGED_WORKER_HOST_KINDS } from './worker-adapter.js';
40
+ import { createCodexWorkerAdapter } from './worker-adapter-codex.js';
41
+ import { createWorkbuddyWorkerAdapter } from './worker-adapter-workbuddy.js';
42
+ import { createOpenClawWorkerAdapter } from './worker-adapter-openclaw.js';
43
+ import { carriedProgress, dispatchWorkspaceAdapters, workspaceStateFor, } from './workspace-dispatch.js';
44
+ export const DEFAULT_MANAGED_WORKSPACE_TIMEOUT_MS = 45 * 60_000;
45
+ const MIN_MANAGED_WORKSPACE_TIMEOUT_MS = 1_000;
46
+ /** Workspace identity key — same rule as shadow (§9.1.6 canonical identity). */
47
+ function workspaceIdentity(dir) {
48
+ const resolved = path.resolve(dir);
49
+ let real;
50
+ try {
51
+ real = fs.realpathSync.native(resolved);
52
+ }
53
+ catch {
54
+ real = undefined;
55
+ }
56
+ const form = real ?? resolved;
57
+ return process.platform === 'win32' ? form.toLowerCase() : form;
58
+ }
59
+ function declaredHostKinds(canonicalDir) {
60
+ const loaded = loadHostToolDeclarations(canonicalDir);
61
+ if (!loaded.ok)
62
+ return [];
63
+ const declared = [];
64
+ for (const declaration of loaded.declarations) {
65
+ if (MANAGED_WORKER_HOST_KINDS.includes(declaration.hostKind)) {
66
+ declared.push(declaration.hostKind);
67
+ }
68
+ }
69
+ return declared;
70
+ }
71
+ function buildDescriptor(entry) {
72
+ return {
73
+ canonicalDir: entry.canonicalDir,
74
+ discoveryVerdict: entry.verdict,
75
+ claimingHosts: entry.hosts,
76
+ declaredHostKinds: declaredHostKinds(entry.canonicalDir),
77
+ };
78
+ }
79
+ function readPreviousProgress(pdHome) {
80
+ const read = readShadowProgress(pdHome);
81
+ if (!read.ok) {
82
+ return { at: new Map(), verdict: read.verdict };
83
+ }
84
+ const at = new Map();
85
+ for (const [key, entry] of read.entries) {
86
+ at.set(key, entry.lastProgressAt);
87
+ }
88
+ return { at, verdict: read.verdict };
89
+ }
90
+ function buildManagedStatus(args) {
91
+ return {
92
+ schemaVersion: 'pd.service-run-status.v1',
93
+ runId: args.runId,
94
+ outcome: args.outcome,
95
+ dryRun: false,
96
+ triggerSource: args.triggerSource,
97
+ startedAt: args.startedAt.toISOString(),
98
+ completedAt: args.completedAt.toISOString(),
99
+ durationMs: Math.max(0, args.completedAt.getTime() - args.startedAt.getTime()),
100
+ installation: {
101
+ pdHome: args.identity.pdHome,
102
+ homeDir: args.identity.homeDir,
103
+ homeSource: args.identity.homeSource,
104
+ mode: args.identity.mode,
105
+ activeRelease: args.activeRelease,
106
+ },
107
+ environmentIsolation: {
108
+ pdExperimentRootStripped: args.identity.environment.experimentRootStripped,
109
+ ignoredIdentityEnvVars: args.identity.environment.ignoredIdentityEnvVars,
110
+ inheritedHostRootEnvVars: args.identity.environment.inheritedHostRootEnvVars,
111
+ ...(args.identity.environment.ignoredHostRootEnvVars.length > 0
112
+ ? { ignoredHostRootEnvVars: args.identity.environment.ignoredHostRootEnvVars }
113
+ : {}),
114
+ },
115
+ manifest: args.manifest,
116
+ discovery: {
117
+ discoveredTotal: args.discovery.discoveredTotal,
118
+ counts: args.discovery.counts,
119
+ hostRoots: args.hostRoots,
120
+ incomplete: discoveryIncompleteRoots(args.hostRoots).length > 0 || args.bindingDiagnostics.length > 0,
121
+ },
122
+ workspaces: args.discovery.workspaces,
123
+ managed: {
124
+ triggerSource: args.triggerSource,
125
+ perWorkspaceTimeoutMs: args.timeoutMs,
126
+ progressCarryVerdict: args.progressCarryVerdict,
127
+ ...(args.emptyReason !== undefined ? { emptyReason: args.emptyReason } : {}),
128
+ executions: args.executions,
129
+ },
130
+ nextAction: args.nextAction,
131
+ };
132
+ }
133
+ function managedNextAction(executions, empty) {
134
+ if (empty) {
135
+ return 'No workspace is currently owned by the Service Host (effectiveOwner=service_host). This is a legal empty managed run — no Worker started and nothing was consumed. Ownership handover happens per-workspace in Phase 4/5 (SPEC §8.4); legacy consumers remain the unique automatic lifecycle owners.';
136
+ }
137
+ const forbidden = executions.filter((e) => e.skipReason === 'handover_preparing_forbidden' || e.skipReason === 'rollback_pending_forbidden');
138
+ const notAuthorized = executions.filter((e) => e.skipReason !== undefined && e.skipReason.startsWith('workspace_not_authorized'));
139
+ const unhealthy = executions.filter((e) => e.admission === 'executed' && (e.workspaceState === 'failed' || e.workspaceState === 'degraded' || e.workspaceState === 'unavailable'));
140
+ if (forbidden.length > 0) {
141
+ return `Managed run skipped ${forbidden.length} workspace(s) in an ownership transition state (handover_preparing / rollback_pending — never consumed by the scheduler). Let the §8.4 transition finish or roll back; the Service Host executes only stable service_host_owned workspaces.`;
142
+ }
143
+ if (notAuthorized.length > 0) {
144
+ return `Managed run refused ${notAuthorized.length} service_host_owned workspace(s) whose discovery verdict is not authorized (${notAuthorized.map((e) => e.skipReason).join('; ')}). Fix the workspace registration/on-disk state before the next cycle; other workspaces were unaffected.`;
145
+ }
146
+ if (unhealthy.length > 0) {
147
+ return `Managed run completed with ${unhealthy.length} unhealthy workspace execution(s); inspect each execution's reason and nextAction. Pending tasks are not lost — the next trigger retries from persisted task/lease state.`;
148
+ }
149
+ return 'Managed run complete. Only service_host_owned workspaces were consumed; legacy workspaces keep their legacy owner.';
150
+ }
151
+ async function completeManagedRun(identity, context) {
152
+ const { options } = context;
153
+ const timeoutMs = Math.max(MIN_MANAGED_WORKSPACE_TIMEOUT_MS, options.timeoutMs ?? DEFAULT_MANAGED_WORKSPACE_TIMEOUT_MS);
154
+ const hostRoots = hostRootReports(identity, context.listDir);
155
+ const lockLost = () => ({
156
+ ok: false,
157
+ outcome: 'refused',
158
+ runId: context.runId,
159
+ reason: 'service_run_lock_lost',
160
+ nextAction: 'The install-level run lock was taken over mid-run, so the run stopped before writing status. ' +
161
+ 'Inspect the current holder and re-run; do not treat this run\'s results as authoritative.',
162
+ });
163
+ const persistRefusal = (args) => {
164
+ if (!context.holdsLock(context.handle))
165
+ return lockLost();
166
+ const status = buildManagedStatus({
167
+ identity,
168
+ runId: context.runId,
169
+ startedAt: context.startedAt,
170
+ completedAt: new Date(),
171
+ outcome: 'refused',
172
+ triggerSource: options.triggerSource,
173
+ activeRelease: args.activeRelease,
174
+ manifest: args.manifest ?? { verdict: 'ok', hosts: [], unknownHosts: [], workspacesCount: 0 },
175
+ discovery: args.discovery ?? buildEmptyDiscovery(),
176
+ hostRoots,
177
+ bindingDiagnostics: [],
178
+ timeoutMs,
179
+ executions: [],
180
+ progressCarryVerdict: 'missing',
181
+ nextAction: args.nextAction,
182
+ });
183
+ return {
184
+ ok: false,
185
+ outcome: 'refused',
186
+ runId: context.runId,
187
+ reason: args.reason,
188
+ nextAction: status.nextAction,
189
+ statusWrite: writeServiceRunStatus(identity.pdHome, status),
190
+ };
191
+ };
192
+ // ── Trusted prefix: active release → manifest → claims → discovery ──
193
+ const activeRelease = readActiveReleaseFacts(identity.activeRecordPath);
194
+ const manifestRead = readManifest(identity);
195
+ if (activeRelease.verdict !== 'ok') {
196
+ return persistRefusal({
197
+ reason: activeRelease.reason ?? 'active_release_invalid',
198
+ activeRelease,
199
+ manifest: manifestSection(manifestRead),
200
+ nextAction: activeRelease.verdict === 'missing'
201
+ ? 'Install or repair PD with npx create-principles-disciple — no active release record exists for this install.'
202
+ : 'Repair the install with the PD installer/updater; the active release record could not be verified against the authoritative schema.',
203
+ });
204
+ }
205
+ // Fail-closed (task §4): a manifest that cannot be read or parsed is NEVER
206
+ // "zero workspaces" — the whole run refuses.
207
+ if (manifestRead.manifest === undefined) {
208
+ return persistRefusal({
209
+ reason: manifestRead.reason ?? 'install_manifest_invalid',
210
+ activeRelease,
211
+ manifest: manifestSection(manifestRead),
212
+ nextAction: manifestRead.verdict === 'missing'
213
+ ? 'Run npx create-principles-disciple to install PD (no manifest exists for this user-level install).'
214
+ : 'Repair the install manifest with the PD installer/updater before the next trigger; the run refused instead of treating the install as empty.',
215
+ });
216
+ }
217
+ const readDiagnostics = [];
218
+ const claimOptions = claimOptionsFor(identity, readDiagnostics, context.claimReaders);
219
+ const claims = collectHostWorkspaceClaims(claimOptions);
220
+ const discovery = discoverWorkspaces({ manifest: manifestRead.manifest, claims, claimOptions });
221
+ // ── Ownership-based admission (task §4 matrix) + shared bounded dispatch ──
222
+ const previousProgress = readPreviousProgress(identity.pdHome);
223
+ const executions = [];
224
+ const isAborted = () => options.signal?.aborted === true;
225
+ let executedAny = false;
226
+ for (const entry of discovery.workspaces) {
227
+ if (isAborted())
228
+ break;
229
+ // The ownership domain is the MANIFEST-registered set (§8.4: a marker
230
+ // exists only for declared workspaces). Default-tree "discovered"
231
+ // entries outside the manifest are not the scheduler's business — they
232
+ // are not recorded as skips (that would be noise), they are simply not
233
+ // candidates.
234
+ if (!entry.sources.some((source) => source.source === 'manifest'))
235
+ continue;
236
+ const key = workspaceIdentity(entry.canonicalDir);
237
+ const previousAt = previousProgress.at.get(key);
238
+ const hadPrevious = previousProgress.at.has(key);
239
+ // Alias-safe owner projection — the same authority shadow uses (§8.4).
240
+ const owner = projectWorkspaceOwnerAliases(manifestRead.manifest, entry.sources.filter((s) => s.source === 'manifest').map((s) => s.path), process.platform);
241
+ const skip = (skipReason, skipNextAction) => {
242
+ executions.push({
243
+ canonicalDir: entry.canonicalDir,
244
+ hostKind: null,
245
+ admission: 'skipped',
246
+ skipReason,
247
+ ...(skipNextAction !== undefined ? { skipNextAction } : {}),
248
+ workspaceState: 'unavailable',
249
+ lastProgressAt: previousAt ?? null,
250
+ lastProgressSource: hadPrevious ? 'previous_run' : null,
251
+ });
252
+ };
253
+ const serviceHostOwned = owner.state === 'service_host_owned' && owner.effectiveOwner === 'service_host';
254
+ if (owner.source === 'conflicting' || owner.effectiveOwner === 'conflict') {
255
+ // Fail-closed per workspace: an ambiguous marker is never "legacy by
256
+ // default" for an automated consumer.
257
+ skip(`owner_projection_conflict:${owner.state}`, 'The backgroundExecutions record for this workspace is ambiguous (alias conflict). Reconcile the install manifest before the next cycle; the scheduler refuses to guess ownership.');
258
+ continue;
259
+ }
260
+ if (serviceHostOwned) {
261
+ if (entry.verdict !== 'authorized') {
262
+ skip(`workspace_not_authorized:${entry.verdict}${entry.reason !== undefined ? `:${entry.reason}` : ''}`, entry.nextAction ?? 'Fix the workspace registration/on-disk state; the scheduler only executes authorized service_host_owned workspaces.');
263
+ continue;
264
+ }
265
+ const dispatch = await dispatchWorkspaceAdapters({
266
+ workspaceDir: entry.canonicalDir,
267
+ descriptor: buildDescriptor(entry),
268
+ hostKinds: [...MANAGED_WORKER_HOST_KINDS],
269
+ timeoutMs,
270
+ adapters: context.adapters,
271
+ activeRelease,
272
+ identity,
273
+ inheritedEnv: context.env,
274
+ ...(options.signal !== undefined ? { signal: options.signal } : {}),
275
+ probes: {
276
+ ...(context.options.probes?.spawnWorkerProcess !== undefined
277
+ ? { spawnWorkerProcess: context.options.probes.spawnWorkerProcess }
278
+ : {}),
279
+ ...(context.options.probes?.resolveCliEntry !== undefined
280
+ ? { resolveCliEntry: context.options.probes.resolveCliEntry }
281
+ : {}),
282
+ ...(context.options.probes?.now !== undefined ? { now: context.options.probes.now } : {}),
283
+ },
284
+ isAborted,
285
+ });
286
+ let supportedAny = false;
287
+ for (const { hostKind, outcome } of dispatch.entries) {
288
+ if (outcome.kind === 'unsupported')
289
+ continue;
290
+ supportedAny = true;
291
+ executedAny = true;
292
+ if (outcome.kind === 'budget_exhausted') {
293
+ executions.push({
294
+ canonicalDir: entry.canonicalDir,
295
+ hostKind,
296
+ admission: 'executed',
297
+ skipReason: 'workspace_timeout_budget_exhausted',
298
+ skipNextAction: 'The per-workspace timeout budget was consumed by an earlier adapter cycle on this workspace; the next trigger retries from persisted task/lease state.',
299
+ workspaceState: 'failed',
300
+ lastProgressAt: previousAt ?? null,
301
+ lastProgressSource: hadPrevious ? 'previous_run' : null,
302
+ });
303
+ continue;
304
+ }
305
+ if (outcome.kind === 'adapter_threw') {
306
+ executions.push({
307
+ canonicalDir: entry.canonicalDir,
308
+ hostKind,
309
+ admission: 'executed',
310
+ skipReason: `adapter_threw:${outcome.sanitizedMessage}`,
311
+ skipNextAction: 'The Worker Adapter threw before returning a structured result; the next trigger retries from persisted task/lease state.',
312
+ workspaceState: 'failed',
313
+ lastProgressAt: previousAt ?? null,
314
+ lastProgressSource: hadPrevious ? 'previous_run' : null,
315
+ });
316
+ continue;
317
+ }
318
+ const carried = carriedProgress(outcome.result, previousAt);
319
+ executions.push({
320
+ canonicalDir: entry.canonicalDir,
321
+ hostKind,
322
+ admission: 'executed',
323
+ workspaceState: workspaceStateFor(outcome.result.cycleOutcome),
324
+ ...carried,
325
+ execution: outcome.result,
326
+ });
327
+ }
328
+ if (!supportedAny) {
329
+ if (isAborted())
330
+ break;
331
+ executedAny = true; // the workspace WAS admitted; the adapter binding is the problem
332
+ executions.push({
333
+ canonicalDir: entry.canonicalDir,
334
+ hostKind: null,
335
+ admission: 'executed',
336
+ skipReason: `no_adapter_supports_workspace:${MANAGED_WORKER_HOST_KINDS.join('|')}`,
337
+ skipNextAction: 'This service_host_owned workspace has no validated host binding (claim or host-tool declaration) for any adapter. Register the host binding; the scheduler cannot execute it.',
338
+ workspaceState: 'unavailable',
339
+ lastProgressAt: previousAt ?? null,
340
+ lastProgressSource: hadPrevious ? 'previous_run' : null,
341
+ });
342
+ }
343
+ continue;
344
+ }
345
+ if (owner.state === 'handover_preparing') {
346
+ skip('handover_preparing_forbidden', 'This workspace is mid-handover (§8.4): the scheduler never consumes a handover_preparing workspace. The transition will complete or roll back; then the next cycle re-evaluates.');
347
+ continue;
348
+ }
349
+ if (owner.state === 'rollback_pending') {
350
+ skip('rollback_pending_forbidden', 'This workspace is pending rollback to the legacy owner (§8.4): the scheduler never consumes a rollback_pending workspace.');
351
+ continue;
352
+ }
353
+ // legacy_owned (record or default): skip, preserve the legacy owner.
354
+ skip('legacy_owned_workspace');
355
+ }
356
+ if (!context.holdsLock(context.handle))
357
+ return lockLost();
358
+ // ── Cross-run progress projection (same store/contract as shadow) ──
359
+ const progressUpdates = new Map();
360
+ const nowIso = new Date().toISOString();
361
+ for (const record of executions) {
362
+ if (record.admission === 'executed'
363
+ && record.lastProgressAt !== null
364
+ && (record.lastProgressSource === 'task_state_change' || record.lastProgressSource === 'cycle_evidence')) {
365
+ progressUpdates.set(workspaceIdentity(record.canonicalDir), {
366
+ lastProgressAt: record.lastProgressAt,
367
+ source: record.lastProgressSource,
368
+ updatedAt: nowIso,
369
+ });
370
+ }
371
+ }
372
+ let progressWriteNote = '';
373
+ if (progressUpdates.size > 0) {
374
+ const merged = mergeShadowProgress(identity.pdHome, progressUpdates);
375
+ if (!merged.ok) {
376
+ progressWriteNote = ` Additionally, the cross-run progress projection could not be updated (${merged.reason}); the status below is still truthful for this run.`;
377
+ }
378
+ }
379
+ const empty = !executedAny;
380
+ const status = buildManagedStatus({
381
+ identity,
382
+ runId: context.runId,
383
+ startedAt: context.startedAt,
384
+ completedAt: new Date(),
385
+ outcome: 'completed',
386
+ triggerSource: options.triggerSource,
387
+ activeRelease,
388
+ manifest: manifestSection(manifestRead),
389
+ discovery,
390
+ hostRoots,
391
+ bindingDiagnostics: readDiagnostics,
392
+ timeoutMs,
393
+ executions,
394
+ progressCarryVerdict: previousProgress.verdict,
395
+ ...(empty ? { emptyReason: 'no_service_host_owned_workspaces' } : {}),
396
+ nextAction: `${managedNextAction(executions, empty)}${progressWriteNote}`,
397
+ });
398
+ const statusWrite = writeServiceRunStatus(identity.pdHome, status);
399
+ return {
400
+ ok: true,
401
+ outcome: 'completed',
402
+ runId: context.runId,
403
+ identity,
404
+ activeRelease,
405
+ manifest: status.manifest,
406
+ discovery,
407
+ executions,
408
+ statusWrite,
409
+ status,
410
+ };
411
+ }
412
+ /**
413
+ * Execute one managed run (the scheduler entry). Never throws for expected
414
+ * refusals — everything expected is a structured result (rc-9).
415
+ */
416
+ export async function runServiceManagedOnce(options) {
417
+ const runId = randomUUID();
418
+ const startedAt = new Date();
419
+ const env = options.env ?? process.env;
420
+ // The managed run is the SCHEDULER entry: host roots resolve from the
421
+ // trusted home only — inherited OPENCLAW_STATE_DIR / CODEX_HOME /
422
+ // WORKBUDDY_CONFIG_DIR / PD_EXPERIMENT_ROOT never steer discovery (F1/TD §5.2).
423
+ const identityResult = resolveCoordinatorInstallIdentity(env, {
424
+ ...(options.trustedHomeDir !== undefined ? { trustedHomeDir: options.trustedHomeDir } : {}),
425
+ canonicalHostRootsOnly: true,
426
+ });
427
+ if (!identityResult.ok) {
428
+ return { ok: false, outcome: 'refused', runId, reason: identityResult.reason, nextAction: identityResult.nextAction };
429
+ }
430
+ const { identity } = identityResult;
431
+ const lock = acquireServiceRunLock(identity.pdHome, {
432
+ probes: {
433
+ ...(options.probes?.processAlive !== undefined ? { processAlive: options.probes.processAlive } : {}),
434
+ },
435
+ });
436
+ if (!lock.ok) {
437
+ if (lock.kind === 'held') {
438
+ return {
439
+ ok: true,
440
+ outcome: 'already_running',
441
+ runId,
442
+ identity,
443
+ holderBodyHash: lock.holderBodyHash,
444
+ reason: 'service_run_lock_held',
445
+ nextAction: 'Another run-once coordinator holds the install-level lock. This is the overlap convergence working as designed; no second coordinator started.',
446
+ };
447
+ }
448
+ const lockPathForMessage = serviceRunLockPath(identity.pdHome);
449
+ return {
450
+ ok: false,
451
+ outcome: 'refused',
452
+ runId,
453
+ reason: lock.kind === 'corrupt'
454
+ ? `service_run_lock_corrupt:${lock.detail}`
455
+ : `service_run_lock_unwritable:${lock.detail}`,
456
+ nextAction: lock.kind === 'corrupt'
457
+ ? ['Inspect the run lock by hand at', lockPathForMessage, '— a lock this old must stay verifiable before any coordinator may run.'].join(' ')
458
+ : 'Check the permissions of the PD service directory and retry.',
459
+ };
460
+ }
461
+ const handle = lock.handle;
462
+ const releaseLock = options.probes?.releaseLock ?? releaseServiceRunLock;
463
+ const adapters = {
464
+ codex: options.probes?.adapters?.codex ?? createCodexWorkerAdapter(),
465
+ workbuddy: options.probes?.adapters?.workbuddy ?? createWorkbuddyWorkerAdapter(),
466
+ openclaw: options.probes?.adapters?.openclaw ?? createOpenClawWorkerAdapter(),
467
+ };
468
+ let result;
469
+ let runError;
470
+ let runThrew = false;
471
+ try {
472
+ result = await completeManagedRun(identity, {
473
+ runId,
474
+ startedAt,
475
+ handle,
476
+ env,
477
+ options,
478
+ holdsLock: options.probes?.holdsLock ?? holdsServiceRunLock,
479
+ listDir: options.probes?.listDir ?? defaultListDir,
480
+ ...(options.probes?.claimReaders !== undefined ? { claimReaders: options.probes.claimReaders } : {}),
481
+ adapters,
482
+ });
483
+ }
484
+ catch (error) {
485
+ runThrew = true;
486
+ runError = error;
487
+ result = { ok: false, outcome: 'refused', runId, reason: 'internal_error', nextAction: '' };
488
+ }
489
+ if (runThrew) {
490
+ // A crashed run persists 'failed' — the status file must not keep the
491
+ // PREVIOUS run's record standing in for a run that never completed
492
+ // (task §10 review). The lock must still be ours at write time, so
493
+ // persist BEFORE release: holdsServiceRunLock after releaseLock is
494
+ // always false and the failure would never reach the status file.
495
+ try {
496
+ const stillHolds = (options.probes?.holdsLock ?? holdsServiceRunLock)(handle);
497
+ if (stillHolds) {
498
+ const activeRelease = readActiveReleaseFacts(identity.activeRecordPath);
499
+ const manifestRead = readManifest(identity);
500
+ writeServiceRunStatus(identity.pdHome, buildManagedStatus({
501
+ identity,
502
+ runId,
503
+ startedAt,
504
+ completedAt: new Date(),
505
+ outcome: 'failed',
506
+ triggerSource: options.triggerSource,
507
+ activeRelease,
508
+ manifest: manifestSection(manifestRead),
509
+ discovery: buildEmptyDiscovery(),
510
+ hostRoots: hostRootReports(identity, options.probes?.listDir ?? defaultListDir),
511
+ bindingDiagnostics: [],
512
+ timeoutMs: Math.max(MIN_MANAGED_WORKSPACE_TIMEOUT_MS, options.timeoutMs ?? DEFAULT_MANAGED_WORKSPACE_TIMEOUT_MS),
513
+ executions: [],
514
+ progressCarryVerdict: 'missing',
515
+ nextAction: 'The managed run terminated with an internal error before completion — the failure itself is recorded as outcome=failed. Inspect the error and the service directory before the next trigger.',
516
+ }));
517
+ }
518
+ }
519
+ catch {
520
+ // Persisting the failure must never mask the original error.
521
+ }
522
+ const crashedRelease = releaseLock(handle);
523
+ if (crashedRelease === 'failed_busy' || crashedRelease === 'failed_unwritable') {
524
+ console.error(`pd service run-once (managed): lock release also failed (${crashedRelease}) after the run error`);
525
+ }
526
+ throw runError;
527
+ }
528
+ const release = releaseLock(handle);
529
+ const releaseFailed = release === 'failed_busy' || release === 'failed_unwritable';
530
+ if (releaseFailed) {
531
+ if (result.outcome === 'completed') {
532
+ return {
533
+ ok: false,
534
+ outcome: 'refused',
535
+ runId,
536
+ reason: `service_run_lock_release_failed:${release === 'failed_busy' ? 'busy' : 'unwritable'}`,
537
+ nextAction: 'The managed run finished but its run lock could not be released through the arbitration gate. ' +
538
+ 'The leftover lock carries a dead-holder PID once this process exits, so the next trigger recovers ' +
539
+ 'on PID evidence — inspect the service directory and the gate database before re-running.',
540
+ statusWrite: result.statusWrite,
541
+ };
542
+ }
543
+ return {
544
+ ...result,
545
+ nextAction: `${result.nextAction} (Additionally, the run lock release failed: ${release}.)`,
546
+ };
547
+ }
548
+ return result;
549
+ }
550
+ //# sourceMappingURL=managed-run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"managed-run.js","sourceRoot":"","sources":["../../../src/services/service-host/managed-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,0BAA0B,EAAqD,MAAM,4BAA4B,CAAC;AAC3H,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EACL,iCAAiC,GAElC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAA+D,MAAM,0BAA0B,CAAC;AAC3H,OAAO,EAAE,4BA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AAC;YACN,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,6DAA6D;QAC/D,CAAC;QACD,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;QAC3C,IAAI,cAAc,KAAK,aAAa,IAAI,cAAc,KAAK,mBAAmB,EAAE,CAAC;YAC/E,OAAO,CAAC,KAAK,CAAC,4DAA4D,cAAc,uBAAuB,CAAC,CAAC;QACnH,CAAC;QACD,MAAM,QAAQ,CAAC;IACjB,CAAC;IACD,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,aAAa,GAAG,OAAO,KAAK,aAAa,IAAI,OAAO,KAAK,mBAAmB,CAAC;IACnF,IAAI,aAAa,EAAE,CAAC;QAClB,IAAI,MAAM,CAAC,OAAO,KAAK,WAAW,EAAE,CAAC;YACnC,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,OAAO,EAAE,SAAS;gBAClB,KAAK;gBACL,MAAM,EAAE,mCAAmC,OAAO,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,EAAE;gBAC9F,UAAU,EACR,gGAAgG;oBAChG,oGAAoG;oBACpG,0FAA0F;gBAC5F,WAAW,EAAE,MAAM,CAAC,WAAW;aAChC,CAAC;QACJ,CAAC;QACD,OAAO;YACL,GAAG,MAAM;YACT,UAAU,EAAE,GAAG,MAAM,CAAC,UAAU,gDAAgD,OAAO,IAAI;SAC5F,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,38 @@
1
+ export interface TaskProgressSnapshot {
2
+ /** taskId → status (the durable state machine position). */
3
+ readonly tasks: ReadonlyMap<string, string>;
4
+ /** taskId → updatedAt at snapshot time (per-task write timestamp). */
5
+ readonly taskUpdatedAt: ReadonlyMap<string, string>;
6
+ readonly maxUpdatedAt: string | null;
7
+ /** False when no state.db exists yet (empty task set, not an error). */
8
+ readonly storePresent: boolean;
9
+ }
10
+ export interface TaskProgressEvidence {
11
+ /** At least one new task or status transition between the two snapshots. */
12
+ readonly taskStateChanged: boolean;
13
+ readonly changedCount: number;
14
+ /** Max updatedAt among changed/new tasks — the progress timestamp, or null. */
15
+ readonly changedAt: string | null;
16
+ }
17
+ export type TaskProgressRead = {
18
+ readonly ok: true;
19
+ readonly snapshot: TaskProgressSnapshot;
20
+ } | {
21
+ readonly ok: false;
22
+ readonly reason: string;
23
+ };
24
+ export declare function readTaskProgressSnapshot(workspaceDir: string, options?: {
25
+ busyTimeoutMs?: number;
26
+ }): TaskProgressRead;
27
+ /**
28
+ * Diff two snapshots into progress evidence. A change is a NEW taskId or a
29
+ * STATUS transition; updatedAt-only movement (lease renewal) does not count.
30
+ *
31
+ * `changedAt` is the max `updatedAt` over the tasks that ACTUALLY changed —
32
+ * never the snapshot's global max: an unchanged task's lease renewal can hold
33
+ * a later updatedAt than the real transition, and the renewal is deliberately
34
+ * not progress (CodeRabbit review fix). When nothing changed it is null (a
35
+ * completed-but-empty cycle keeps the prior value at the status layer, §6).
36
+ */
37
+ export declare function diffTaskProgress(before: TaskProgressSnapshot, after: TaskProgressSnapshot): TaskProgressEvidence;
38
+ //# sourceMappingURL=progress-evidence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress-evidence.d.ts","sourceRoot":"","sources":["../../../src/services/service-host/progress-evidence.ts"],"names":[],"mappings":"AAkCA,MAAM,WAAW,oBAAoB;IACnC,4DAA4D;IAC5D,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,sEAAsE;IACtE,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpD,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,wEAAwE;IACxE,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,oBAAoB;IACnC,4EAA4E;IAC5E,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,+EAA+E;IAC/E,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAA;CAAE,GAC9D;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAyCpD,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,gBAAgB,CAmDrH;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,oBAAoB,EAAE,KAAK,EAAE,oBAAoB,GAAG,oBAAoB,CAmBhH"}