create-principles-disciple 1.154.5 → 1.155.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (409) 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 +10 -0
  14. package/console/dist/server/models/EvidenceChainConsoleModel.js +31 -0
  15. package/console/dist/server/routes/service-host.d.ts +19 -0
  16. package/console/dist/server/routes/service-host.js +129 -0
  17. package/console/dist/web/assets/app.js +37 -37
  18. package/core/dist/runtime/context-payload.d.ts +48 -0
  19. package/core/dist/runtime/context-payload.d.ts.map +1 -1
  20. package/core/dist/runtime/context-payload.js +12 -0
  21. package/core/dist/runtime/context-payload.js.map +1 -1
  22. package/core/dist/runtime/diagnostician/rootcause-prompt-builder.d.ts.map +1 -1
  23. package/core/dist/runtime/diagnostician/rootcause-prompt-builder.js +18 -0
  24. package/core/dist/runtime/diagnostician/rootcause-prompt-builder.js.map +1 -1
  25. package/core/dist/runtime/diagnostician-candidate.d.ts.map +1 -1
  26. package/core/dist/runtime/diagnostician-candidate.js +18 -2
  27. package/core/dist/runtime/diagnostician-candidate.js.map +1 -1
  28. package/core/dist/runtime/evidence-guards.d.ts +7 -3
  29. package/core/dist/runtime/evidence-guards.d.ts.map +1 -1
  30. package/core/dist/runtime/evidence-guards.js +9 -7
  31. package/core/dist/runtime/evidence-guards.js.map +1 -1
  32. package/core/dist/runtime/feature-flags/feature-flag-contract.d.ts.map +1 -1
  33. package/core/dist/runtime/feature-flags/feature-flag-contract.js +14 -0
  34. package/core/dist/runtime/feature-flags/feature-flag-contract.js.map +1 -1
  35. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.d.ts.map +1 -1
  36. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js +8 -0
  37. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js.map +1 -1
  38. package/core/dist/runtime/host-submission-context.d.ts +83 -0
  39. package/core/dist/runtime/host-submission-context.d.ts.map +1 -0
  40. package/core/dist/runtime/host-submission-context.js +183 -0
  41. package/core/dist/runtime/host-submission-context.js.map +1 -0
  42. package/core/dist/runtime/index.d.ts +9 -2
  43. package/core/dist/runtime/index.d.ts.map +1 -1
  44. package/core/dist/runtime/index.js +29 -2
  45. package/core/dist/runtime/index.js.map +1 -1
  46. package/core/dist/runtime/intent/intent-doc.d.ts.map +1 -1
  47. package/core/dist/runtime/intent/intent-doc.js +29 -5
  48. package/core/dist/runtime/intent/intent-doc.js.map +1 -1
  49. package/core/dist/runtime/internalization/diag-distiller-runner.d.ts +9 -0
  50. package/core/dist/runtime/internalization/diag-distiller-runner.d.ts.map +1 -1
  51. package/core/dist/runtime/internalization/diag-distiller-runner.js +13 -0
  52. package/core/dist/runtime/internalization/diag-distiller-runner.js.map +1 -1
  53. package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts +11 -0
  54. package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts.map +1 -1
  55. package/core/dist/runtime/internalization/diag-rootcause-runner.js +10 -0
  56. package/core/dist/runtime/internalization/diag-rootcause-runner.js.map +1 -1
  57. package/core/dist/runtime/internalization/diag-router-runner.d.ts +9 -0
  58. package/core/dist/runtime/internalization/diag-router-runner.d.ts.map +1 -1
  59. package/core/dist/runtime/internalization/diag-router-runner.js +13 -0
  60. package/core/dist/runtime/internalization/diag-router-runner.js.map +1 -1
  61. package/core/dist/runtime/internalization/index.d.ts +1 -1
  62. package/core/dist/runtime/internalization/index.d.ts.map +1 -1
  63. package/core/dist/runtime/internalization/index.js +1 -1
  64. package/core/dist/runtime/internalization/index.js.map +1 -1
  65. package/core/dist/runtime/internalization/intake-to-internalization-bridge.d.ts +19 -0
  66. package/core/dist/runtime/internalization/intake-to-internalization-bridge.d.ts.map +1 -1
  67. package/core/dist/runtime/internalization/intake-to-internalization-bridge.js +24 -0
  68. package/core/dist/runtime/internalization/intake-to-internalization-bridge.js.map +1 -1
  69. package/core/dist/runtime/internalization/internalization-orchestrator.d.ts +8 -0
  70. package/core/dist/runtime/internalization/internalization-orchestrator.d.ts.map +1 -1
  71. package/core/dist/runtime/internalization/internalization-orchestrator.js +36 -4
  72. package/core/dist/runtime/internalization/internalization-orchestrator.js.map +1 -1
  73. package/core/dist/runtime/internalization/source-authorization-boundary.d.ts +39 -0
  74. package/core/dist/runtime/internalization/source-authorization-boundary.d.ts.map +1 -0
  75. package/core/dist/runtime/internalization/source-authorization-boundary.js +57 -0
  76. package/core/dist/runtime/internalization/source-authorization-boundary.js.map +1 -0
  77. package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts.map +1 -1
  78. package/core/dist/runtime/internalization/split-diagnostician-runner.js +72 -5
  79. package/core/dist/runtime/internalization/split-diagnostician-runner.js.map +1 -1
  80. package/core/dist/runtime/pain-admission-disposition.d.ts +60 -0
  81. package/core/dist/runtime/pain-admission-disposition.d.ts.map +1 -0
  82. package/core/dist/runtime/pain-admission-disposition.js +37 -0
  83. package/core/dist/runtime/pain-admission-disposition.js.map +1 -0
  84. package/core/dist/runtime/pain-ingress-payload.d.ts +36 -2
  85. package/core/dist/runtime/pain-ingress-payload.d.ts.map +1 -1
  86. package/core/dist/runtime/pain-ingress-payload.js +63 -6
  87. package/core/dist/runtime/pain-ingress-payload.js.map +1 -1
  88. package/core/dist/runtime/pain-ingress.d.ts.map +1 -1
  89. package/core/dist/runtime/pain-ingress.js +28 -0
  90. package/core/dist/runtime/pain-ingress.js.map +1 -1
  91. package/core/dist/runtime/pain-recall-read-model.d.ts +13 -1
  92. package/core/dist/runtime/pain-recall-read-model.d.ts.map +1 -1
  93. package/core/dist/runtime/pain-recall-read-model.js +50 -7
  94. package/core/dist/runtime/pain-recall-read-model.js.map +1 -1
  95. package/core/dist/runtime/pain-receipt-recovery.d.ts +147 -0
  96. package/core/dist/runtime/pain-receipt-recovery.d.ts.map +1 -0
  97. package/core/dist/runtime/pain-receipt-recovery.js +475 -0
  98. package/core/dist/runtime/pain-receipt-recovery.js.map +1 -0
  99. package/core/dist/runtime/pain-signal-bridge.d.ts +13 -1
  100. package/core/dist/runtime/pain-signal-bridge.d.ts.map +1 -1
  101. package/core/dist/runtime/pain-signal-bridge.js +174 -0
  102. package/core/dist/runtime/pain-signal-bridge.js.map +1 -1
  103. package/core/dist/runtime/pain-signal-runtime-factory.d.ts +9 -0
  104. package/core/dist/runtime/pain-signal-runtime-factory.d.ts.map +1 -1
  105. package/core/dist/runtime/pain-signal-runtime-factory.js +8 -3
  106. package/core/dist/runtime/pain-signal-runtime-factory.js.map +1 -1
  107. package/core/dist/runtime/pain-submit-capability.d.ts +11 -0
  108. package/core/dist/runtime/pain-submit-capability.d.ts.map +1 -1
  109. package/core/dist/runtime/pain-submit-capability.js +77 -3
  110. package/core/dist/runtime/pain-submit-capability.js.map +1 -1
  111. package/core/dist/runtime/pain-target-evidence-reconcile.d.ts +55 -0
  112. package/core/dist/runtime/pain-target-evidence-reconcile.d.ts.map +1 -0
  113. package/core/dist/runtime/pain-target-evidence-reconcile.js +164 -0
  114. package/core/dist/runtime/pain-target-evidence-reconcile.js.map +1 -0
  115. package/core/dist/runtime/pain-to-principle-service.d.ts +8 -0
  116. package/core/dist/runtime/pain-to-principle-service.d.ts.map +1 -1
  117. package/core/dist/runtime/pain-to-principle-service.js +1 -0
  118. package/core/dist/runtime/pain-to-principle-service.js.map +1 -1
  119. package/core/dist/runtime/source-material-authorization.d.ts +166 -0
  120. package/core/dist/runtime/source-material-authorization.d.ts.map +1 -0
  121. package/core/dist/runtime/source-material-authorization.js +250 -0
  122. package/core/dist/runtime/source-material-authorization.js.map +1 -0
  123. package/core/dist/runtime/store/context/index.d.ts +1 -0
  124. package/core/dist/runtime/store/context/index.d.ts.map +1 -1
  125. package/core/dist/runtime/store/context/index.js +1 -0
  126. package/core/dist/runtime/store/context/index.js.map +1 -1
  127. package/core/dist/runtime/store/context/promoted-evidence-reader.d.ts +8 -0
  128. package/core/dist/runtime/store/context/promoted-evidence-reader.d.ts.map +1 -1
  129. package/core/dist/runtime/store/context/promoted-evidence-reader.js +15 -1
  130. package/core/dist/runtime/store/context/promoted-evidence-reader.js.map +1 -1
  131. package/core/dist/runtime/store/context/sqlite-context-assembler.d.ts +22 -0
  132. package/core/dist/runtime/store/context/sqlite-context-assembler.d.ts.map +1 -1
  133. package/core/dist/runtime/store/context/sqlite-context-assembler.js +153 -3
  134. package/core/dist/runtime/store/context/sqlite-context-assembler.js.map +1 -1
  135. package/core/dist/runtime/store/context/trajectory-turn-reader.d.ts +13 -0
  136. package/core/dist/runtime/store/context/trajectory-turn-reader.d.ts.map +1 -1
  137. package/core/dist/runtime/store/lifecycle/lease-manager.d.ts +15 -0
  138. package/core/dist/runtime/store/lifecycle/lease-manager.d.ts.map +1 -1
  139. package/core/dist/runtime/store/lifecycle/lease-manager.js +16 -1
  140. package/core/dist/runtime/store/lifecycle/lease-manager.js.map +1 -1
  141. package/core/dist/runtime/store/runtime-state-manager.d.ts +2 -0
  142. package/core/dist/runtime/store/runtime-state-manager.d.ts.map +1 -1
  143. package/core/dist/runtime/store/runtime-state-manager.js.map +1 -1
  144. package/core/dist/runtime/store/task/memory-task-store.d.ts +1 -0
  145. package/core/dist/runtime/store/task/memory-task-store.d.ts.map +1 -1
  146. package/core/dist/runtime/store/task/memory-task-store.js +37 -0
  147. package/core/dist/runtime/store/task/memory-task-store.js.map +1 -1
  148. package/core/dist/runtime/store/task/sqlite-task-store.d.ts +10 -0
  149. package/core/dist/runtime/store/task/sqlite-task-store.d.ts.map +1 -1
  150. package/core/dist/runtime/store/task/sqlite-task-store.js +20 -0
  151. package/core/dist/runtime/store/task/sqlite-task-store.js.map +1 -1
  152. package/core/dist/runtime/store/task/task-store.d.ts +16 -0
  153. package/core/dist/runtime/store/task/task-store.d.ts.map +1 -1
  154. package/core/dist/runtime/task-status.d.ts +13 -0
  155. package/core/dist/runtime/task-status.d.ts.map +1 -1
  156. package/core/dist/runtime/task-status.js +9 -0
  157. package/core/dist/runtime/task-status.js.map +1 -1
  158. package/core/dist/runtime/types/evidence-chain-contract.d.ts +10 -0
  159. package/core/dist/runtime/types/evidence-chain-contract.d.ts.map +1 -1
  160. package/core/dist/runtime/types/evidence-chain-contract.js +7 -0
  161. package/core/dist/runtime/types/evidence-chain-contract.js.map +1 -1
  162. package/core/package.json +1 -1
  163. package/dist/index.d.ts.map +1 -1
  164. package/dist/index.js +11 -0
  165. package/dist/index.js.map +1 -1
  166. package/dist/installer.d.ts.map +1 -1
  167. package/dist/installer.js +77 -30
  168. package/dist/installer.js.map +1 -1
  169. package/dist/installers/mcp-registration-conflict.d.ts +8 -0
  170. package/dist/installers/mcp-registration-conflict.d.ts.map +1 -1
  171. package/dist/installers/mcp-registration-conflict.js +34 -1
  172. package/dist/installers/mcp-registration-conflict.js.map +1 -1
  173. package/dist/installers/workbuddy-host-installer.d.ts +45 -13
  174. package/dist/installers/workbuddy-host-installer.d.ts.map +1 -1
  175. package/dist/installers/workbuddy-host-installer.js +284 -21
  176. package/dist/installers/workbuddy-host-installer.js.map +1 -1
  177. package/dist/prompts.d.ts +11 -0
  178. package/dist/prompts.d.ts.map +1 -1
  179. package/dist/prompts.js +4 -0
  180. package/dist/prompts.js.map +1 -1
  181. package/dist/service-host-bridge.d.ts +67 -0
  182. package/dist/service-host-bridge.d.ts.map +1 -0
  183. package/dist/service-host-bridge.js +292 -0
  184. package/dist/service-host-bridge.js.map +1 -0
  185. package/dist/uninstaller.d.ts.map +1 -1
  186. package/dist/uninstaller.js +26 -0
  187. package/dist/uninstaller.js.map +1 -1
  188. package/dist/update/install-layout.d.ts +0 -12
  189. package/dist/update/install-layout.d.ts.map +1 -1
  190. package/dist/update/install-layout.js +42 -15
  191. package/dist/update/install-layout.js.map +1 -1
  192. package/host-runtime/dist/diagnostician-auto-run.js +4 -1
  193. package/host-runtime/dist/governance-observation-store.d.ts +7 -0
  194. package/host-runtime/dist/governance-observation-store.js +15 -4
  195. package/host-runtime/dist/governance-signal-admission.d.ts +49 -0
  196. package/host-runtime/dist/governance-signal-admission.js +355 -94
  197. package/host-runtime/dist/governance-trajectory-turn-reader.d.ts +20 -4
  198. package/host-runtime/dist/governance-trajectory-turn-reader.js +77 -5
  199. package/host-runtime/dist/index.d.ts +2 -0
  200. package/host-runtime/dist/index.js +5 -0
  201. package/host-runtime/dist/internalization-consumer-cycle.js +4 -1
  202. package/host-runtime/dist/pd-config.d.ts +10 -0
  203. package/host-runtime/dist/pd-config.js +37 -0
  204. package/host-runtime/dist/signal-stage2-cycle.js +28 -1
  205. package/host-runtime/dist/source-material-authorization.d.ts +53 -0
  206. package/host-runtime/dist/source-material-authorization.js +67 -0
  207. package/host-runtime/dist/source-revocation-sweep.d.ts +172 -0
  208. package/host-runtime/dist/source-revocation-sweep.js +928 -0
  209. package/host-runtime/package.json +5 -1
  210. package/install-layout/dist/background-execution-transition.d.ts +258 -0
  211. package/install-layout/dist/background-execution-transition.js +836 -0
  212. package/install-layout/dist/index.d.ts +8 -0
  213. package/install-layout/dist/index.js +8 -0
  214. package/install-layout/package.json +6 -2
  215. package/package.json +4 -4
  216. package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
  217. package/pd-cli/dist/commands/candidate.js +16 -5
  218. package/pd-cli/dist/commands/candidate.js.map +1 -1
  219. package/pd-cli/dist/commands/codex-setup.d.ts.map +1 -1
  220. package/pd-cli/dist/commands/codex-setup.js +17 -1
  221. package/pd-cli/dist/commands/codex-setup.js.map +1 -1
  222. package/pd-cli/dist/commands/codex-worker.d.ts.map +1 -1
  223. package/pd-cli/dist/commands/codex-worker.js +8 -4
  224. package/pd-cli/dist/commands/codex-worker.js.map +1 -1
  225. package/pd-cli/dist/commands/consent-sweep-revoked.d.ts +20 -0
  226. package/pd-cli/dist/commands/consent-sweep-revoked.d.ts.map +1 -0
  227. package/pd-cli/dist/commands/consent-sweep-revoked.js +85 -0
  228. package/pd-cli/dist/commands/consent-sweep-revoked.js.map +1 -0
  229. package/pd-cli/dist/commands/context.d.ts.map +1 -1
  230. package/pd-cli/dist/commands/context.js +9 -1
  231. package/pd-cli/dist/commands/context.js.map +1 -1
  232. package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
  233. package/pd-cli/dist/commands/diagnose.js +12 -6
  234. package/pd-cli/dist/commands/diagnose.js.map +1 -1
  235. package/pd-cli/dist/commands/openclaw-worker.d.ts +11 -0
  236. package/pd-cli/dist/commands/openclaw-worker.d.ts.map +1 -0
  237. package/pd-cli/dist/commands/openclaw-worker.js +199 -0
  238. package/pd-cli/dist/commands/openclaw-worker.js.map +1 -0
  239. package/pd-cli/dist/commands/pain-explicit.d.ts.map +1 -1
  240. package/pd-cli/dist/commands/pain-explicit.js +1 -0
  241. package/pd-cli/dist/commands/pain-explicit.js.map +1 -1
  242. package/pd-cli/dist/commands/pain-recall.d.ts +2 -2
  243. package/pd-cli/dist/commands/pain-recall.d.ts.map +1 -1
  244. package/pd-cli/dist/commands/pain-recall.js +7 -1
  245. package/pd-cli/dist/commands/pain-recall.js.map +1 -1
  246. package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
  247. package/pd-cli/dist/commands/pain-retry.js +12 -6
  248. package/pd-cli/dist/commands/pain-retry.js.map +1 -1
  249. package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.d.ts.map +1 -1
  250. package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js +2 -1
  251. package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js.map +1 -1
  252. package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts +1 -0
  253. package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
  254. package/pd-cli/dist/commands/runtime-internalization-run-once.js +32 -8
  255. package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
  256. package/pd-cli/dist/commands/runtime-internalization-wake-once.d.ts.map +1 -1
  257. package/pd-cli/dist/commands/runtime-internalization-wake-once.js +2 -1
  258. package/pd-cli/dist/commands/runtime-internalization-wake-once.js.map +1 -1
  259. package/pd-cli/dist/commands/service-handover.d.ts +12 -0
  260. package/pd-cli/dist/commands/service-handover.d.ts.map +1 -0
  261. package/pd-cli/dist/commands/service-handover.js +117 -0
  262. package/pd-cli/dist/commands/service-handover.js.map +1 -0
  263. package/pd-cli/dist/commands/service-lifecycle.d.ts +31 -0
  264. package/pd-cli/dist/commands/service-lifecycle.d.ts.map +1 -0
  265. package/pd-cli/dist/commands/service-lifecycle.js +207 -0
  266. package/pd-cli/dist/commands/service-lifecycle.js.map +1 -0
  267. package/pd-cli/dist/commands/service-run-once.d.ts +96 -0
  268. package/pd-cli/dist/commands/service-run-once.d.ts.map +1 -1
  269. package/pd-cli/dist/commands/service-run-once.js +432 -13
  270. package/pd-cli/dist/commands/service-run-once.js.map +1 -1
  271. package/pd-cli/dist/commands/workbuddy-setup.d.ts.map +1 -1
  272. package/pd-cli/dist/commands/workbuddy-setup.js +22 -2
  273. package/pd-cli/dist/commands/workbuddy-setup.js.map +1 -1
  274. package/pd-cli/dist/program.d.ts.map +1 -1
  275. package/pd-cli/dist/program.js +167 -9
  276. package/pd-cli/dist/program.js.map +1 -1
  277. package/pd-cli/dist/services/admission-write-gate.d.ts +3 -1
  278. package/pd-cli/dist/services/admission-write-gate.d.ts.map +1 -1
  279. package/pd-cli/dist/services/admission-write-gate.js +1 -0
  280. package/pd-cli/dist/services/admission-write-gate.js.map +1 -1
  281. package/pd-cli/dist/services/service-host/coordinator-common.d.ts +49 -0
  282. package/pd-cli/dist/services/service-host/coordinator-common.d.ts.map +1 -0
  283. package/pd-cli/dist/services/service-host/coordinator-common.js +158 -0
  284. package/pd-cli/dist/services/service-host/coordinator-common.js.map +1 -0
  285. package/pd-cli/dist/services/service-host/handover-claims.d.ts +14 -0
  286. package/pd-cli/dist/services/service-host/handover-claims.d.ts.map +1 -0
  287. package/pd-cli/dist/services/service-host/handover-claims.js +50 -0
  288. package/pd-cli/dist/services/service-host/handover-claims.js.map +1 -0
  289. package/pd-cli/dist/services/service-host/index.d.ts +19 -3
  290. package/pd-cli/dist/services/service-host/index.d.ts.map +1 -1
  291. package/pd-cli/dist/services/service-host/index.js +21 -3
  292. package/pd-cli/dist/services/service-host/index.js.map +1 -1
  293. package/pd-cli/dist/services/service-host/install-identity.d.ts +23 -3
  294. package/pd-cli/dist/services/service-host/install-identity.d.ts.map +1 -1
  295. package/pd-cli/dist/services/service-host/install-identity.js +15 -5
  296. package/pd-cli/dist/services/service-host/install-identity.js.map +1 -1
  297. package/pd-cli/dist/services/service-host/locking/service-run-lock.d.ts +130 -9
  298. package/pd-cli/dist/services/service-host/locking/service-run-lock.d.ts.map +1 -1
  299. package/pd-cli/dist/services/service-host/locking/service-run-lock.js +99 -19
  300. package/pd-cli/dist/services/service-host/locking/service-run-lock.js.map +1 -1
  301. package/pd-cli/dist/services/service-host/managed-run.d.ts +75 -0
  302. package/pd-cli/dist/services/service-host/managed-run.d.ts.map +1 -0
  303. package/pd-cli/dist/services/service-host/managed-run.js +550 -0
  304. package/pd-cli/dist/services/service-host/managed-run.js.map +1 -0
  305. package/pd-cli/dist/services/service-host/progress-evidence.d.ts +38 -0
  306. package/pd-cli/dist/services/service-host/progress-evidence.d.ts.map +1 -0
  307. package/pd-cli/dist/services/service-host/progress-evidence.js +155 -0
  308. package/pd-cli/dist/services/service-host/progress-evidence.js.map +1 -0
  309. package/pd-cli/dist/services/service-host/run-once.d.ts.map +1 -1
  310. package/pd-cli/dist/services/service-host/run-once.js +4 -136
  311. package/pd-cli/dist/services/service-host/run-once.js.map +1 -1
  312. package/pd-cli/dist/services/service-host/scheduler/contract.d.ts +184 -0
  313. package/pd-cli/dist/services/service-host/scheduler/contract.d.ts.map +1 -0
  314. package/pd-cli/dist/services/service-host/scheduler/contract.js +86 -0
  315. package/pd-cli/dist/services/service-host/scheduler/contract.js.map +1 -0
  316. package/pd-cli/dist/services/service-host/scheduler/index.d.ts +76 -0
  317. package/pd-cli/dist/services/service-host/scheduler/index.d.ts.map +1 -0
  318. package/pd-cli/dist/services/service-host/scheduler/index.js +128 -0
  319. package/pd-cli/dist/services/service-host/scheduler/index.js.map +1 -0
  320. package/pd-cli/dist/services/service-host/scheduler/linux.d.ts +27 -0
  321. package/pd-cli/dist/services/service-host/scheduler/linux.d.ts.map +1 -0
  322. package/pd-cli/dist/services/service-host/scheduler/linux.js +1010 -0
  323. package/pd-cli/dist/services/service-host/scheduler/linux.js.map +1 -0
  324. package/pd-cli/dist/services/service-host/scheduler/macos.d.ts +13 -0
  325. package/pd-cli/dist/services/service-host/scheduler/macos.d.ts.map +1 -0
  326. package/pd-cli/dist/services/service-host/scheduler/macos.js +819 -0
  327. package/pd-cli/dist/services/service-host/scheduler/macos.js.map +1 -0
  328. package/pd-cli/dist/services/service-host/scheduler/runtime-io.d.ts +13 -0
  329. package/pd-cli/dist/services/service-host/scheduler/runtime-io.d.ts.map +1 -0
  330. package/pd-cli/dist/services/service-host/scheduler/runtime-io.js +141 -0
  331. package/pd-cli/dist/services/service-host/scheduler/runtime-io.js.map +1 -0
  332. package/pd-cli/dist/services/service-host/scheduler/service-status.d.ts +99 -0
  333. package/pd-cli/dist/services/service-host/scheduler/service-status.d.ts.map +1 -0
  334. package/pd-cli/dist/services/service-host/scheduler/service-status.js +202 -0
  335. package/pd-cli/dist/services/service-host/scheduler/service-status.js.map +1 -0
  336. package/pd-cli/dist/services/service-host/scheduler/windows.d.ts +40 -0
  337. package/pd-cli/dist/services/service-host/scheduler/windows.d.ts.map +1 -0
  338. package/pd-cli/dist/services/service-host/scheduler/windows.js +688 -0
  339. package/pd-cli/dist/services/service-host/scheduler/windows.js.map +1 -0
  340. package/pd-cli/dist/services/service-host/shadow-progress-store.d.ts +43 -0
  341. package/pd-cli/dist/services/service-host/shadow-progress-store.d.ts.map +1 -0
  342. package/pd-cli/dist/services/service-host/shadow-progress-store.js +156 -0
  343. package/pd-cli/dist/services/service-host/shadow-progress-store.js.map +1 -0
  344. package/pd-cli/dist/services/service-host/shadow-run.d.ts +87 -0
  345. package/pd-cli/dist/services/service-host/shadow-run.d.ts.map +1 -0
  346. package/pd-cli/dist/services/service-host/shadow-run.js +549 -0
  347. package/pd-cli/dist/services/service-host/shadow-run.js.map +1 -0
  348. package/pd-cli/dist/services/service-host/status/service-run-status.d.ts +114 -4
  349. package/pd-cli/dist/services/service-host/status/service-run-status.d.ts.map +1 -1
  350. package/pd-cli/dist/services/service-host/status/service-run-status.js +37 -0
  351. package/pd-cli/dist/services/service-host/status/service-run-status.js.map +1 -1
  352. package/pd-cli/dist/services/service-host/worker-adapter-codex.d.ts +2 -0
  353. package/pd-cli/dist/services/service-host/worker-adapter-codex.d.ts.map +1 -0
  354. package/pd-cli/dist/services/service-host/worker-adapter-codex.js +76 -0
  355. package/pd-cli/dist/services/service-host/worker-adapter-codex.js.map +1 -0
  356. package/pd-cli/dist/services/service-host/worker-adapter-openclaw.d.ts +2 -0
  357. package/pd-cli/dist/services/service-host/worker-adapter-openclaw.d.ts.map +1 -0
  358. package/pd-cli/dist/services/service-host/worker-adapter-openclaw.js +49 -0
  359. package/pd-cli/dist/services/service-host/worker-adapter-openclaw.js.map +1 -0
  360. package/pd-cli/dist/services/service-host/worker-adapter-workbuddy.d.ts +2 -0
  361. package/pd-cli/dist/services/service-host/worker-adapter-workbuddy.d.ts.map +1 -0
  362. package/pd-cli/dist/services/service-host/worker-adapter-workbuddy.js +36 -0
  363. package/pd-cli/dist/services/service-host/worker-adapter-workbuddy.js.map +1 -0
  364. package/pd-cli/dist/services/service-host/worker-adapter.d.ts +187 -0
  365. package/pd-cli/dist/services/service-host/worker-adapter.d.ts.map +1 -0
  366. package/pd-cli/dist/services/service-host/worker-adapter.js +609 -0
  367. package/pd-cli/dist/services/service-host/worker-adapter.js.map +1 -0
  368. package/pd-cli/dist/services/service-host/worker-env.d.ts +84 -0
  369. package/pd-cli/dist/services/service-host/worker-env.d.ts.map +1 -0
  370. package/pd-cli/dist/services/service-host/worker-env.js +195 -0
  371. package/pd-cli/dist/services/service-host/worker-env.js.map +1 -0
  372. package/pd-cli/dist/services/service-host/worker-process.d.ts +75 -0
  373. package/pd-cli/dist/services/service-host/worker-process.d.ts.map +1 -0
  374. package/pd-cli/dist/services/service-host/worker-process.js +225 -0
  375. package/pd-cli/dist/services/service-host/worker-process.js.map +1 -0
  376. package/pd-cli/dist/services/service-host/workspace-dispatch.d.ts +61 -0
  377. package/pd-cli/dist/services/service-host/workspace-dispatch.d.ts.map +1 -0
  378. package/pd-cli/dist/services/service-host/workspace-dispatch.js +105 -0
  379. package/pd-cli/dist/services/service-host/workspace-dispatch.js.map +1 -0
  380. package/pd-cli/dist/services/service-host/workspace-handover.d.ts +190 -0
  381. package/pd-cli/dist/services/service-host/workspace-handover.d.ts.map +1 -0
  382. package/pd-cli/dist/services/service-host/workspace-handover.js +1393 -0
  383. package/pd-cli/dist/services/service-host/workspace-handover.js.map +1 -0
  384. package/pd-cli/package.json +6 -5
  385. package/pd-mcp-server/dist/submit-assembly.js +159 -42
  386. package/pd-mcp-server/dist/version.d.ts +1 -1
  387. package/pd-mcp-server/dist/version.js +1 -1
  388. package/pd-mcp-server/package.json +1 -1
  389. package/plugin/dist/bundle.js +586 -568
  390. package/plugin/dist/openclaw-worker.d.ts +92 -0
  391. package/plugin/dist/openclaw-worker.js +2439 -0
  392. package/plugin/dist/openclaw.plugin.json +1 -1
  393. package/plugin/dist/service/gateway-consumer-lease.d.ts +142 -0
  394. package/plugin/dist/service/gateway-quiesce-ack.d.ts +40 -0
  395. package/plugin/dist/service/internalization-auto-consumer-service.d.ts +68 -1
  396. package/plugin/openclaw.plugin.json +1 -1
  397. package/plugin/package.json +5 -1
  398. package/release-manager/dist/installer.js +77 -30
  399. package/release-manager/dist/installers/mcp-registration-conflict.js +34 -1
  400. package/release-manager/dist/installers/workbuddy-host-installer.js +284 -21
  401. package/release-manager/dist/service-host-bridge.js +292 -0
  402. package/release-manager/dist/update/install-layout.js +42 -15
  403. package/release-manager/package.json +2 -2
  404. package/workbuddy-adapter/dist/index.d.ts +1 -1
  405. package/workbuddy-adapter/dist/index.js +1 -1
  406. package/workbuddy-adapter/dist/worker/workspace-worker.d.ts +7 -0
  407. package/workbuddy-adapter/dist/worker/workspace-worker.js +179 -10
  408. package/workbuddy-adapter/package.json +1 -1
  409. package/workbuddy-adapter/plugin/.codebuddy-plugin/plugin.json +2 -2
@@ -43,11 +43,15 @@
43
43
  */
44
44
  import { spawnSync, execFileSync } from 'node:child_process';
45
45
  import { createHash } from 'node:crypto';
46
- import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, readlinkSync, renameSync, rmSync, cpSync, writeFileSync, openSync, closeSync } from 'node:fs';
46
+ import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, readlinkSync, renameSync, rmSync, cpSync, copyFileSync, writeFileSync, openSync, closeSync } from 'node:fs';
47
47
  import * as path from 'node:path';
48
48
  import * as yaml from 'js-yaml';
49
49
  import semver from 'semver';
50
50
  import { getInstallLayoutPaths, getWorkbuddyWorkspaceDir, installManifestHostsForPersist, mergeInstallManifestWorkspaces, parseInstallManifest, INSTALL_LAYOUT_VERSION, } from '@principles/install-layout';
51
+ // withInstallManifestWriteLock ships with the PRI-1282 install-layout
52
+ // cohort; a registry-resolved older dep lacks it, so the merge below
53
+ // detects the export (same release-window posture as installer.ts).
54
+ import * as installLayoutModule from '@principles/install-layout';
51
55
  // 2026-11-08: the shared state DEFINITIONS for pd-cli health live in
52
56
  // @principles/install-layout (interpretWorkbuddyPluginState /
53
57
  // getWorkbuddyHostConfigPaths). The installer does NOT import them at
@@ -65,7 +69,7 @@ export const WORKBUDDY_MARKETPLACE_NAME = 'principles-disciple-market';
65
69
  export const WORKBUDDY_PLUGIN_KEY = `${WORKBUDDY_PLUGIN_NAME}@${WORKBUDDY_MARKETPLACE_NAME}`;
66
70
  const WORKBUDDY_REQUIRED_SKILLS = ['pd-cli-operator', 'pd-pain-signal', 'pd-review', 'pd-control'];
67
71
  import { atomicReplaceTextFile, AtomicReplaceCleanupError, AtomicReplaceConflictError, errnoCode } from '../utils/config-file-io.js';
68
- import { checkMcpRegistrationConflict } from './mcp-registration-conflict.js';
72
+ import { checkMcpRegistrationConflict, classifyWorkbuddyMcpJsonObject, PD_MCP_SERVER_NAME } from './mcp-registration-conflict.js';
69
73
  import { deprecateAllLegacyWorkbuddySkills } from './legacy-workbuddy-skill.js';
70
74
  import { resolveMcpServerDir, resolveMcpServerEntry } from '../mcp-server-layout-compat.js';
71
75
  import { getHomeDir, generateConfigYamlContent, getConfigYamlPath, resolveDefaultModelForProvider, isValidHttpBaseUrl } from '../mvp-config.js';
@@ -1063,7 +1067,7 @@ function readInstallJsonRecord(manifestPath) {
1063
1067
  * channel/autoCheck/releaseMetadataUrl — PRI-709 P0-1) are carried through.
1064
1068
  * Malformed existing manifest → hard stop, zero modification.
1065
1069
  */
1066
- export function mergeWorkbuddyIntoInstallManifest(manifestPath, governanceDir, atomicReplace = atomicReplaceTextFile) {
1070
+ function mergeWorkbuddyIntoInstallManifestLocked(manifestPath, governanceDir, atomicReplace = atomicReplaceTextFile) {
1067
1071
  let current;
1068
1072
  let existed = false;
1069
1073
  try {
@@ -1130,19 +1134,87 @@ export function mergeWorkbuddyIntoInstallManifest(manifestPath, governanceDir, a
1130
1134
  };
1131
1135
  }
1132
1136
  }
1137
+ function installedOwnershipCapability() {
1138
+ const transitionModule = path.join(getHomeDir(), '.pd', 'runtime', 'install-layout', 'dist', 'background-execution-transition.js');
1139
+ let content;
1140
+ try {
1141
+ content = readFileSync(transitionModule, 'utf-8');
1142
+ }
1143
+ catch (error) {
1144
+ return errnoCode(error) === 'ENOENT' ? 'pre_cohort' : 'unverifiable';
1145
+ }
1146
+ return content.includes('withInstallManifestWriteLock') ? 'cohort' : 'pre_cohort';
1147
+ }
1148
+ function cohortWindowUnlockedWriteUnsafe(operation, capability) {
1149
+ return {
1150
+ ok: false,
1151
+ reason: `install_manifest_lock_unavailable: the bundled @principles/install-layout predates the §8.4 manifest write lock while the installed runtime ${capability === 'cohort' ? 'IS ownership-capable' : 'capability could not be verified'} — an unlocked ${operation} could clobber an in-flight handover/rollback write. No write was performed.`,
1152
+ nextAction: 'Update @principles/install-layout to a release that exports withInstallManifestWriteLock, or re-run the installer once the dependency resolves to that cohort.',
1153
+ };
1154
+ }
1155
+ export function mergeWorkbuddyIntoInstallManifest(manifestPath, governanceDir, atomicReplace = atomicReplaceTextFile) {
1156
+ // The manifest also carries §8.4 ownership records. Every read-modify-write
1157
+ // must join the same physical lock; an older dependency cohort without the
1158
+ // lock export is incompatible and must not write around the ownership CAS.
1159
+ const lock = installLayoutModule.withInstallManifestWriteLock;
1160
+ if (typeof lock !== 'function') {
1161
+ // An old installer dependency can coexist with a newer installed pd
1162
+ // runtime. Unlocked writes are safe only when that runtime is verifiably
1163
+ // pre-§8.4; otherwise it may be writing ownership concurrently.
1164
+ const capability = installedOwnershipCapability();
1165
+ if (capability !== 'pre_cohort') {
1166
+ return cohortWindowUnlockedWriteUnsafe('workbuddy.mergeInstallManifest', capability);
1167
+ }
1168
+ return mergeWorkbuddyIntoInstallManifestLocked(manifestPath, governanceDir, atomicReplace);
1169
+ }
1170
+ const locked = lock({ manifestPath, operation: 'workbuddy.mergeInstallManifest', context: governanceDir }, () => mergeWorkbuddyIntoInstallManifestLocked(manifestPath, governanceDir, atomicReplace));
1171
+ if (!locked.ok) {
1172
+ return {
1173
+ ok: false,
1174
+ reason: `install_manifest_lock_unavailable: ${locked.message}. No write was performed.`,
1175
+ nextAction: 'Wait for the in-flight manifest operation to finish and re-run the installer; the write is never done unlocked.',
1176
+ };
1177
+ }
1178
+ return locked.value;
1179
+ }
1133
1180
  /** Remove 'workbuddy' from manifest hosts (uninstall bookkeeping; workspaces/governance data preserved). */
1134
1181
  function removeWorkbuddyFromInstallManifestHosts(manifestPath) {
1135
- try {
1182
+ if (!existsSync(manifestPath))
1183
+ return { ok: true };
1184
+ const lock = installLayoutModule.withInstallManifestWriteLock;
1185
+ if (typeof lock !== 'function') {
1186
+ return {
1187
+ ok: false,
1188
+ reason: 'install_manifest_lock_unavailable: the installed @principles/install-layout does not expose the shared manifest lock; WorkBuddy was removed but the host registration remains.',
1189
+ nextAction: 'Update the installer/runtime cohort, then retry WorkBuddy uninstall to remove the stale host registration safely.',
1190
+ };
1191
+ }
1192
+ const write = () => {
1193
+ // Re-read inside the lock: bytes observed before the critical section are stale.
1136
1194
  const parsed = JSON.parse(readFileSync(manifestPath, 'utf-8'));
1137
1195
  if (!isRecord(parsed) || !Array.isArray(parsed.hosts))
1138
1196
  return;
1139
1197
  const hosts = parsed.hosts.filter((h) => typeof h === 'string' && h !== 'workbuddy');
1140
1198
  const payload = { ...parsed, hosts };
1141
- writeFileSync(manifestPath, JSON.stringify(payload, null, 2) + '\n', 'utf-8');
1199
+ atomicReplaceTextFile(manifestPath, JSON.stringify(payload, null, 2) + '\n');
1200
+ };
1201
+ try {
1202
+ const locked = lock({ manifestPath, operation: 'workbuddy.removeFromInstallManifest', context: path.dirname(manifestPath) }, write);
1203
+ if (!locked.ok) {
1204
+ return {
1205
+ ok: false,
1206
+ reason: `install_manifest_lock_unavailable: ${locked.message}; WorkBuddy host registration was preserved.`,
1207
+ nextAction: 'Wait for the in-flight manifest operation to finish, then retry WorkBuddy uninstall.',
1208
+ };
1209
+ }
1210
+ return { ok: true };
1142
1211
  }
1143
- catch {
1144
- // Uninstall must not fail on manifest bookkeeping; the preserved-state
1145
- // report below still names the governance dir. rc-9: surfaced via paths.
1212
+ catch (error) {
1213
+ return {
1214
+ ok: false,
1215
+ reason: `workbuddy_manifest_uninstall_write_failed: ${error instanceof Error ? error.message : String(error)}; the host registration was preserved.`,
1216
+ nextAction: 'Inspect ~/.pd/install.json and the manifest lock, then retry WorkBuddy uninstall.',
1217
+ };
1146
1218
  }
1147
1219
  }
1148
1220
  // ─── Feature flag override (config.yaml line-targeted edit) ─────────────────
@@ -2329,11 +2401,11 @@ export class WorkBuddyHostInstaller {
2329
2401
  // re-create the very deadlock this fix removes. The host's own registration
2330
2402
  // record survives that, so either signal counts.
2331
2403
  //
2332
- // Why proceeding is not a user-config write: this installer writes no part
2333
- // of `~/.workbuddy/mcp.json` — no writer for it exists anywhere in this
2334
- // repository, and the classifier beside this code is read-only. The bytes
2335
- // stay identical whether the install proceeds or not (the test asserts the
2336
- // sha256). What PD itself does write is its own payload + binding.
2404
+ // Why proceeding is not a user-config write AT THIS GATE: the conflict
2405
+ // classifier is read-only, so the bytes stay identical whether the install
2406
+ // proceeds or not here (the test asserts the sha256). A separate,
2407
+ // ownership-proven legacy cleanup (step 3c, `removeLegacyPdOwnedUserMcpEntry`)
2408
+ // may later strip a PD-owned `pd-recall` entry — never another server's.
2337
2409
  const pdMcpBindingPresent = existsSync(path.join(p.marketplaceRoot, WORKBUDDY_PLUGIN_NAME, 'mcp-binding.json'));
2338
2410
  const pdAlreadyInstalledForHost = pdMcpBindingPresent || details.registered;
2339
2411
  const mcpRegistration = checkMcpRegistrationConflict('workbuddy', {
@@ -2359,6 +2431,13 @@ export class WorkBuddyHostInstaller {
2359
2431
  const mcpRegistrationWarning = mcpRegistration.ok
2360
2432
  ? undefined
2361
2433
  : `${mcpRegistration.reason} PD left that entry untouched and continued so this host is not left bound to the previous MCP server version. ${mcpRegistration.nextAction}`;
2434
+ // 3c. Legacy USER-level entry migration runs POST-COMMIT (step 9, review
2435
+ // 2026-11-22): deleting the entry here would leave it unrestored when a
2436
+ // later stage fails — the install transaction only snapshots PD-owned
2437
+ // targets — and would strip the only working pd-recall on a host whose
2438
+ // plugin ends up disabled. The read-only ownership gate above stays the
2439
+ // precondition; the deletion itself belongs to the commit-aftermath
2440
+ // stage, next to the legacy skill cleanup.
2362
2441
  // 4. Materialize the PD-owned marketplace (source stays inside its root).
2363
2442
  try {
2364
2443
  materializeMarketplace(p.marketplaceRoot, payload.pluginDir);
@@ -2586,6 +2665,36 @@ export class WorkBuddyHostInstaller {
2586
2665
  const pendingRebindNote = profilePendingAgents.length > 0
2587
2666
  ? ` Pending config: agent(s) ${profilePendingAgents.join(', ')} still bind to their explicit runtime profiles; to rebind them to the install profile, set internalAgents.agents.<name>.runtimeProfile to '${GOVERNANCE_PROFILE_ID}' (or remove the per-agent runtimeProfile row so they inherit internalAgents.defaultRuntime) in ${path.join(p.governanceDir, '.pd', 'config.yaml')}.`
2588
2667
  : '';
2668
+ // 9. Legacy USER-level entry migration — POST-COMMIT (review 2026-11-22
2669
+ // R1/R2). Before the plugin-bundled `.mcp.json` became the only source,
2670
+ // PD also registered a USER-level `<config>/mcp.json` entry. That origin
2671
+ // is a DIFFERENT MCP origin: it requires a manual trust decision and
2672
+ // duplicates the plugin's own server in the MCP list, so an upgraded
2673
+ // machine would still look broken. The removal runs only here — never
2674
+ // inside the transaction — so a rolled-back install keeps the file
2675
+ // byte-identical, and only when the plugin-side replacement is PROVEN
2676
+ // usable; otherwise the old entry stays and the reason is reported (PD
2677
+ // never flips the Owner's enablement behind their back).
2678
+ let legacyUserMcpCleanup;
2679
+ if (mcpRegistration.ok && mcpRegistration.state === 'pd_owned') {
2680
+ const substituteBlocker = this.recallSubstituteBlocker(mcpBinding);
2681
+ if (substituteBlocker === undefined) {
2682
+ const cleanup = this.removeLegacyPdOwnedUserMcpEntry([payload.pluginDir]);
2683
+ if (cleanup.ok) {
2684
+ if (cleanup.removed) {
2685
+ legacyUserMcpCleanup =
2686
+ `Removed the legacy user-level "${PD_MCP_SERVER_NAME}" entry from ${path.join(p.configDir, 'mcp.json')} ` +
2687
+ `(backup: ${cleanup.backupPath}). The plugin's bundled .mcp.json is the single MCP source now.`;
2688
+ }
2689
+ }
2690
+ else {
2691
+ legacyUserMcpCleanup = `${cleanup.reason} ${cleanup.nextAction}`;
2692
+ }
2693
+ }
2694
+ else {
2695
+ legacyUserMcpCleanup = substituteBlocker;
2696
+ }
2697
+ }
2589
2698
  // SPEC-PD-AGENT-PAIN-INGRESS-001 §5.5 / TD §7.4: retire every old
2590
2699
  // user-level PD skill once per install/upgrade (`pd-record-pain` plus the
2591
2700
  // Codex-era pd-status/pd-setup/pd-disable and the pre-unification
@@ -2595,6 +2704,7 @@ export class WorkBuddyHostInstaller {
2595
2704
  const installWarnings = [
2596
2705
  ...legacySkill.warnings,
2597
2706
  ...(mcpRegistrationWarning === undefined ? [] : [mcpRegistrationWarning]),
2707
+ ...(legacyUserMcpCleanup === undefined ? [] : [legacyUserMcpCleanup]),
2598
2708
  ];
2599
2709
  return {
2600
2710
  success: true,
@@ -2809,7 +2919,9 @@ export class WorkBuddyHostInstaller {
2809
2919
  /**
2810
2920
  * The value an install should leave behind: an explicit boolean already in
2811
2921
  * settings.json is the Owner's choice and always wins; otherwise the plugin
2812
- * manifest's `defaultEnabled` applies. Install never enables by itself.
2922
+ * manifest's `defaultEnabled` applies. PD ships `true`, so a fresh WorkBuddy
2923
+ * install is enabled (and its bundled pd-recall MCP server loads) without a
2924
+ * manual plugin-manager step.
2813
2925
  */
2814
2926
  resolveInstalledEnabledValue(declaredDefaultEnabled) {
2815
2927
  const p = this.paths();
@@ -2823,6 +2935,150 @@ export class WorkBuddyHostInstaller {
2823
2935
  return { ok: true, value: current, fromOwnerChoice: true };
2824
2936
  return { ok: true, value: declaredDefaultEnabled, fromOwnerChoice: false };
2825
2937
  }
2938
+ /**
2939
+ * Is the plugin-side replacement for the legacy user-level `pd-recall`
2940
+ * proven usable? Returns a keep-and-report message when it is NOT, else
2941
+ * undefined — the migration may then delete the old entry.
2942
+ *
2943
+ * Three independent proofs, all read from post-install state:
2944
+ * 1. enablement — the host's `enabledPlugins[key]` ended TRUE (an
2945
+ * explicit Owner false survives registration, so a preserved-disable
2946
+ * host must keep its trusted user-level entry or lose pd-recall
2947
+ * entirely — the plugin's bundled .mcp.json never loads while
2948
+ * disabled);
2949
+ * 2. payload — the INSTALLED marketplace payload still declares
2950
+ * `mcpServers["pd-recall"]` in its .mcp.json;
2951
+ * 3. binding — writeWorkbuddyMcpBinding landed (a failed binding leaves
2952
+ * the launcher fail-closed; enablement alone proves nothing).
2953
+ */
2954
+ recallSubstituteBlocker(mcpBinding) {
2955
+ const p = this.paths();
2956
+ const mcpPath = path.join(p.configDir, 'mcp.json');
2957
+ const state = this.readInstalledPluginState();
2958
+ if (state.enabled !== true) {
2959
+ return `Kept the legacy user-level "${PD_MCP_SERVER_NAME}" entry in ${mcpPath}: the plugin is not enabled (an explicit enabledPlugins choice wins over the shipped default), so its bundled pd-recall will not load and removing this entry would leave no usable recall service. Enable the plugin in WorkBuddy's plugin manager, then re-run the installer to finish the migration.`;
2960
+ }
2961
+ let declaresRecall = false;
2962
+ try {
2963
+ const manifest = JSON.parse(readFileSync(path.join(p.marketplaceRoot, WORKBUDDY_PLUGIN_NAME, '.mcp.json'), 'utf-8'));
2964
+ const servers = isRecord(manifest) && isRecord(manifest.mcpServers) ? manifest.mcpServers : undefined;
2965
+ declaresRecall = servers !== undefined && Object.hasOwn(servers, PD_MCP_SERVER_NAME);
2966
+ }
2967
+ catch { /* unreadable/unparsable payload manifest → not proven */ }
2968
+ if (!declaresRecall) {
2969
+ return `Kept the legacy user-level "${PD_MCP_SERVER_NAME}" entry in ${mcpPath}: the installed plugin payload does not declare a "${PD_MCP_SERVER_NAME}" server in its .mcp.json, so removing this entry could leave no usable recall service. Re-run the installer after restoring a complete plugin payload.`;
2970
+ }
2971
+ if (!mcpBinding.ok) {
2972
+ return `Kept the legacy user-level "${PD_MCP_SERVER_NAME}" entry in ${mcpPath}: the pd-recall launcher binding could not be written (${mcpBinding.reason ?? 'unknown'}), so the plugin's bundled server is not proven usable. Resolve the binding problem and re-run the installer to finish the migration.`;
2973
+ }
2974
+ return undefined;
2975
+ }
2976
+ /**
2977
+ * Remove the LEGACY user-level `pd-recall` entry from `<config>/mcp.json`.
2978
+ *
2979
+ * ONE raw-bytes read drives the parse, the ownership verdict
2980
+ * (`classifyWorkbuddyMcpJsonObject` on that same parsed object — never a
2981
+ * second file read) and the backup; the same bytes are then passed to the
2982
+ * atomic replace as `expectedCurrentBytes`, so a host save landing between
2983
+ * the read and the rename is refused instead of silently overwritten
2984
+ * (review 2026-11-22: the stale-snapshot rewrite could drop an MCP server
2985
+ * WorkBuddy saved concurrently). On `AtomicReplaceConflictError` the file
2986
+ * is left exactly as the host wrote it and the backup is kept as evidence.
2987
+ *
2988
+ * Ownership still comes from the launcher bytes, never the key name: only a
2989
+ * `pd_owned` verdict may be deleted. The backup is a `copyFileSync` of the
2990
+ * source, so its permission bits match the original (CWE-732: a fresh 0644
2991
+ * backup of a private mcp.json would expose MCP credentials to other local
2992
+ * users). The caller turns the outcome into a warning, so a cleanup failure
2993
+ * can never fail the install.
2994
+ */
2995
+ removeLegacyPdOwnedUserMcpEntry(pdLauncherRoots) {
2996
+ const mcpPath = path.join(this.paths().configDir, 'mcp.json');
2997
+ let rawBytes;
2998
+ try {
2999
+ rawBytes = readFileSync(mcpPath);
3000
+ }
3001
+ catch (error) {
3002
+ if (errnoCode(error) === 'ENOENT')
3003
+ return { ok: true, removed: false };
3004
+ return {
3005
+ ok: false,
3006
+ reason: `workbuddy_legacy_mcp_unreadable: cannot read ${mcpPath} (${error instanceof Error ? error.message : String(error)}). The legacy entry was left untouched.`,
3007
+ nextAction: 'Restore read access to the file, then re-run the installer.',
3008
+ };
3009
+ }
3010
+ let root;
3011
+ try {
3012
+ root = JSON.parse(rawBytes.toString('utf-8'));
3013
+ }
3014
+ catch (error) {
3015
+ return {
3016
+ ok: false,
3017
+ reason: `workbuddy_legacy_mcp_unparsable: ${mcpPath} is not valid JSON (${error instanceof Error ? error.message : String(error)}). The legacy entry was left untouched.`,
3018
+ nextAction: 'Fix or remove the malformed file manually, then re-run the installer. PD never merges into a config it cannot parse.',
3019
+ };
3020
+ }
3021
+ if (!isRecord(root)) {
3022
+ return {
3023
+ ok: false,
3024
+ reason: `workbuddy_legacy_mcp_unparsable: ${mcpPath} parsed to ${Array.isArray(root) ? 'an array' : typeof root}, expected an object. The legacy entry was left untouched.`,
3025
+ nextAction: 'Fix or remove the malformed file manually, then re-run the installer.',
3026
+ };
3027
+ }
3028
+ const servers = isRecord(root.mcpServers) ? root.mcpServers : undefined;
3029
+ if (servers === undefined || !Object.hasOwn(servers, PD_MCP_SERVER_NAME))
3030
+ return { ok: true, removed: false };
3031
+ const verdict = classifyWorkbuddyMcpJsonObject(root, mcpPath, {
3032
+ homeDir: this.deps.homeDir(),
3033
+ workbuddyConfigDir: this.paths().configDir,
3034
+ pdLauncherRoots,
3035
+ });
3036
+ // Only a PROVEN PD-owned entry may be removed. `conflict`, `unverifiable`
3037
+ // and an unreadable config keep the existing read-only gate semantics.
3038
+ if (!verdict.ok || verdict.state !== 'pd_owned')
3039
+ return { ok: true, removed: false };
3040
+ const nextServers = { ...servers };
3041
+ delete nextServers[PD_MCP_SERVER_NAME];
3042
+ const nextRoot = { ...root };
3043
+ if (Object.keys(nextServers).length === 0)
3044
+ delete nextRoot.mcpServers;
3045
+ else
3046
+ nextRoot.mcpServers = nextServers;
3047
+ const backupPath = `${mcpPath}.pd-legacy-${Date.now()}.bak`;
3048
+ try {
3049
+ // copyFileSync preserves the source mode — mcp.json may carry
3050
+ // credentials behind private permissions the backup must keep.
3051
+ copyFileSync(mcpPath, backupPath);
3052
+ }
3053
+ catch (error) {
3054
+ return {
3055
+ ok: false,
3056
+ reason: `workbuddy_legacy_mcp_backup_failed: ${error instanceof Error ? error.message : String(error)}. The legacy entry was left untouched.`,
3057
+ nextAction: `Check write permissions beside ${mcpPath}, then re-run the installer.`,
3058
+ };
3059
+ }
3060
+ try {
3061
+ this.deps.atomicReplaceConfig(mcpPath, JSON.stringify(nextRoot, null, 2) + '\n', undefined, undefined, rawBytes);
3062
+ }
3063
+ catch (error) {
3064
+ if (error instanceof AtomicReplaceConflictError) {
3065
+ // The host saved this file between our read and the rename: PD's
3066
+ // replacement never committed, the newer content wins, and the
3067
+ // byte-backup stays as recovery evidence.
3068
+ return {
3069
+ ok: false,
3070
+ reason: `workbuddy_legacy_mcp_concurrent_edit: ${mcpPath} changed between inspection and replacement, so the legacy entry was kept rather than overwriting the newer save (byte backup preserved at ${backupPath}).`,
3071
+ nextAction: 'Re-run the installer after WorkBuddy has finished writing, or remove the entry manually.',
3072
+ };
3073
+ }
3074
+ return {
3075
+ ok: false,
3076
+ reason: `workbuddy_legacy_mcp_write_failed: atomic replace of ${mcpPath} failed (${error instanceof Error ? error.message : String(error)}). The previous content is preserved at ${backupPath}.`,
3077
+ nextAction: `Manually restore ${backupPath} to ${mcpPath} if the file was left modified, then re-run the installer.`,
3078
+ };
3079
+ }
3080
+ return { ok: true, removed: true, backupPath };
3081
+ }
2826
3082
  /** Write enabledPlugins[OUR_KEY]=value, preserving every other key. */
2827
3083
  applyInstalledEnabledValue(value) {
2828
3084
  const p = this.paths();
@@ -2856,9 +3112,9 @@ export class WorkBuddyHostInstaller {
2856
3112
  }
2857
3113
  /**
2858
3114
  * Direct-write registration for engine-unreachable machines, aligned with the
2859
- * frozen P01 formats: enabledPlugins[key] carries the manifest default or the
2860
- * Owner's existing choice (install never enables by itself; other keys and
2861
- * other plugins preserved), installed_plugins.json v2 user registration
3115
+ * frozen P01 formats: enabledPlugins[key] carries the manifest default (PD
3116
+ * ships `true`, so a fresh install is enabled out of the box) or the Owner's
3117
+ * existing choice (other keys and other plugins preserved), installed_plugins.json v2 user registration
2862
3118
  * (native scope array or legacy object), and the versioned cache
2863
3119
  * copy under plugins/cache/<marketplace>/<plugin>/<version>/.
2864
3120
  */
@@ -2890,8 +3146,8 @@ export class WorkBuddyHostInstaller {
2890
3146
  }
2891
3147
  // settings.json merge — computed here, WRITTEN after the cache lands (see
2892
3148
  // below): a failed payload must leave no registration state behind.
2893
- // Install ≠ enable (SPEC §6.4): an explicit Owner choice is preserved;
2894
- // otherwise the manifest's defaultEnabled applies.
3149
+ // An explicit Owner choice is preserved; otherwise the manifest's
3150
+ // defaultEnabled applies (PD ships true: enabled out of the box).
2895
3151
  const currentEnabled = isRecord(settings.value?.enabledPlugins)
2896
3152
  ? settings.value.enabledPlugins[WORKBUDDY_PLUGIN_KEY]
2897
3153
  : undefined;
@@ -3223,8 +3479,14 @@ export class WorkBuddyHostInstaller {
3223
3479
  }
3224
3480
  // 6. Manifest bookkeeping: drop 'workbuddy' from hosts. The governance
3225
3481
  // workspace entry and ALL governance data are preserved (§18 default).
3226
- if (!otherScopesPresent)
3227
- removeWorkbuddyFromInstallManifestHosts(p.installManifestPath);
3482
+ const manifestBookkeeping = !otherScopesPresent
3483
+ ? removeWorkbuddyFromInstallManifestHosts(p.installManifestPath)
3484
+ : { ok: true };
3485
+ if (!manifestBookkeeping.ok) {
3486
+ failedPaths.push(p.installManifestPath);
3487
+ preservedPaths.push(p.installManifestPath);
3488
+ notes.push(`${manifestBookkeeping.reason} ${manifestBookkeeping.nextAction}`);
3489
+ }
3228
3490
  const governancePreservedByDesign = existsSync(p.governanceDir);
3229
3491
  if (governancePreservedByDesign) {
3230
3492
  preservedPaths.push(p.governanceDir);
@@ -3240,6 +3502,7 @@ export class WorkBuddyHostInstaller {
3240
3502
  ? `Partially uninstalled: ${failedPaths.join(', ')} could not be removed. ${notes.join(' ')}`
3241
3503
  : `Uninstalled ${WORKBUDDY_PLUGIN_KEY}. ${notes.join(' ')}`.trim(),
3242
3504
  nextAction: [
3505
+ ...(!manifestBookkeeping.ok ? [manifestBookkeeping.nextAction] : []),
3243
3506
  'Registration removal takes effect in NEW WorkBuddy sessions (or /reload-plugins in a running CLI session).',
3244
3507
  governancePreservedByDesign
3245
3508
  ? `The governance database at ${p.governanceDir} is PRESERVED by design — delete it manually only after exporting what you need.`