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
@@ -17,14 +17,30 @@
17
17
  * session resolves;
18
18
  * - expired/quarantined rows are excluded naturally: retention NULLed their
19
19
  * text at write time (PRI-1179), so nothing new is re-derived here.
20
+ *
21
+ * PRI-1283 R2: every list call resolves the LATEST conversation-ingestion
22
+ * consent per governance host and excludes unauthorized hosts AT THE QUERY
23
+ * BOUNDARY — a revoked host's turns are never read into the window. When no
24
+ * port is wired the reader denies all governance hosts (fail-closed): serving
25
+ * consent-gated conversation text without an authorization check is the exact
26
+ * R2 gap. Fail-open-to-[] still applies to STORE failures only.
20
27
  */
21
28
  import type { TrajectoryTurnReader } from '@principles/core/runtime';
29
+ import { type SourceMaterialAuthorizationPort } from '@principles/core/runtime';
30
+ export interface GovernanceTrajectoryTurnReaderArgs {
31
+ readonly workspaceDir: string;
32
+ /**
33
+ * PRI-1283 R2: latest-consent gate, consulted PER list call. Composition
34
+ * roots inject `createConsentLedgerSourceMaterialAuthorization(workspaceDir)`.
35
+ */
36
+ readonly sourceMaterialAuthorization?: SourceMaterialAuthorizationPort;
37
+ }
22
38
  /**
23
39
  * Build the governance-observation-backed turn reader for a workspace. The
24
40
  * returned object is cheap to construct per invocation; each list call opens
25
41
  * the store read (no cached handle across worker cycles, so a replaced
26
- * database mid-run can never serve stale turns).
42
+ * database mid-run can never serve stale turns) and re-resolves the consent
43
+ * state (no cached authorization, so a mid-run revocation takes effect on the
44
+ * next call).
27
45
  */
28
- export declare function createGovernanceTrajectoryTurnReader(args: {
29
- readonly workspaceDir: string;
30
- }): TrajectoryTurnReader;
46
+ export declare function createGovernanceTrajectoryTurnReader(args: GovernanceTrajectoryTurnReaderArgs): TrajectoryTurnReader;
@@ -1,13 +1,19 @@
1
- import { listGovernanceTurnTexts } from './governance-observation-store.js';
1
+ import { denyAllSourceMaterialAuthorization, } from '@principles/core/runtime';
2
+ import { listGovernanceObservations, listGovernanceTurnTexts } from './governance-observation-store.js';
2
3
  /** Bound on turns per list call — the assembler bounds the window again. */
3
4
  const MAX_TURNS_PER_SESSION = 200;
4
- function readTurnRows(workspaceDir, kind, sessionId) {
5
+ /** The governance-observation hosts whose turns this reader can serve. */
6
+ const GOVERNANCE_TURN_HOSTS = ['codex', 'workbuddy'];
7
+ function readTurnRows(workspaceDir, kind, query) {
8
+ const { sessionId, port } = query;
5
9
  if (sessionId.trim().length === 0)
6
10
  return [];
11
+ const authorizedHostKinds = GOVERNANCE_TURN_HOSTS.filter((host) => port.isHostSourceMaterialAuthorized(host).authorized);
7
12
  const result = listGovernanceTurnTexts({
8
13
  workspaceDir,
9
14
  kind,
10
15
  sessionId,
16
+ authorizedHostKinds,
11
17
  limit: MAX_TURNS_PER_SESSION,
12
18
  });
13
19
  // Unreadable store: the empty result surfaces as an assembler ambiguity
@@ -18,12 +24,15 @@ function readTurnRows(workspaceDir, kind, sessionId) {
18
24
  * Build the governance-observation-backed turn reader for a workspace. The
19
25
  * returned object is cheap to construct per invocation; each list call opens
20
26
  * the store read (no cached handle across worker cycles, so a replaced
21
- * database mid-run can never serve stale turns).
27
+ * database mid-run can never serve stale turns) and re-resolves the consent
28
+ * state (no cached authorization, so a mid-run revocation takes effect on the
29
+ * next call).
22
30
  */
23
31
  export function createGovernanceTrajectoryTurnReader(args) {
32
+ const port = args.sourceMaterialAuthorization ?? denyAllSourceMaterialAuthorization;
24
33
  return {
25
34
  listUserTurnsForSession(sessionId) {
26
- return readTurnRows(args.workspaceDir, 'user_turn', sessionId).map((row, index) => ({
35
+ return readTurnRows(args.workspaceDir, 'user_turn', { sessionId, port }).map((row, index) => ({
27
36
  id: row.id,
28
37
  turnIndex: row.sourceOrdinal >= 0 ? row.sourceOrdinal : index,
29
38
  rawExcerpt: row.visibleText,
@@ -33,7 +42,7 @@ export function createGovernanceTrajectoryTurnReader(args) {
33
42
  }));
34
43
  },
35
44
  listAssistantTurns(sessionId) {
36
- return readTurnRows(args.workspaceDir, 'assistant_turn', sessionId).map((row) => ({
45
+ return readTurnRows(args.workspaceDir, 'assistant_turn', { sessionId, port }).map((row) => ({
37
46
  id: row.id,
38
47
  sessionId,
39
48
  runId: '',
@@ -43,5 +52,68 @@ export function createGovernanceTrajectoryTurnReader(args) {
43
52
  createdAt: row.observedAt,
44
53
  }));
45
54
  },
55
+ /**
56
+ * PRI-1274 (B1 / P1-3): exact (host, session, host turn id) read over the
57
+ * same authorized governance store. `hostKind` keeps another host's
58
+ * identically-named session+turn out of the window (the cross-host
59
+ * isolation class PRI-1247 closes); retained-text filtering mirrors the
60
+ * session-level reads (expired/quarantined rows carry NULL text).
61
+ * Unreadable store ⇒ empty result — the assembler turns that into an
62
+ * ambiguity note, never a session-wide substitution.
63
+ */
64
+ listTurnTextsForHostTurnId(sessionId, hostTurnId, hostKind) {
65
+ if (sessionId.trim().length === 0 || hostTurnId.trim().length === 0) {
66
+ return { userTurns: [], assistantTurns: [] };
67
+ }
68
+ // Exact-turn reads are a separate entry point from the session-level
69
+ // list methods above. Require an explicit supported host and consult
70
+ // the latest consent decision on EVERY call before opening the store.
71
+ // An omitted/unsupported host must never become an unscoped read.
72
+ const authorizedHostKind = GOVERNANCE_TURN_HOSTS.find((candidate) => candidate === hostKind);
73
+ if (authorizedHostKind === undefined
74
+ || !port.isHostSourceMaterialAuthorized(authorizedHostKind).authorized) {
75
+ return { userTurns: [], assistantTurns: [] };
76
+ }
77
+ const result = listGovernanceObservations({
78
+ workspaceDir: args.workspaceDir,
79
+ rolloutIdentity: sessionId,
80
+ hostKind: authorizedHostKind,
81
+ hostTurnId,
82
+ limit: 64,
83
+ });
84
+ if (!result.ok)
85
+ return { userTurns: [], assistantTurns: [] };
86
+ const retainedText = (row) => (row.retentionClass === 'operational' || row.retentionClass === 'promoted')
87
+ && typeof row.visibleText === 'string'
88
+ && row.visibleText.trim() !== ''
89
+ ? row.visibleText
90
+ : null;
91
+ const userRows = result.observations.filter((row) => row.kind === 'user_turn');
92
+ return {
93
+ userTurns: userRows.flatMap((row, index) => {
94
+ const text = retainedText(row);
95
+ return text === null ? [] : [{
96
+ id: row.id,
97
+ turnIndex: row.sourceOrdinal !== null && row.sourceOrdinal >= 0 ? row.sourceOrdinal : index,
98
+ rawExcerpt: text,
99
+ correctionDetected: false,
100
+ correctionCue: null,
101
+ createdAt: row.observedAt,
102
+ }];
103
+ }),
104
+ assistantTurns: result.observations.filter((row) => row.kind === 'assistant_turn').flatMap((row) => {
105
+ const text = retainedText(row);
106
+ return text === null ? [] : [{
107
+ id: row.id,
108
+ sessionId,
109
+ runId: '',
110
+ provider: '',
111
+ model: '',
112
+ sanitizedText: text,
113
+ createdAt: row.observedAt,
114
+ }];
115
+ }),
116
+ };
117
+ },
46
118
  };
47
119
  }
@@ -22,6 +22,8 @@ export * from './governance-observation-store.js';
22
22
  export * from './governance-trajectory-turn-reader.js';
23
23
  export * from './trajectory-retention.js';
24
24
  export * from './conversation-ingestion/index.js';
25
+ export * from './source-material-authorization.js';
26
+ export * from './source-revocation-sweep.js';
25
27
  export * from './governance-signal-admission.js';
26
28
  export * from './signal-classifier.js';
27
29
  export * from './adaptive-selection.js';
@@ -45,6 +45,11 @@ export * from './trajectory-retention.js';
45
45
  // packages; a new host implements TranscriptSourceAdapter with zero changes
46
46
  // here.
47
47
  export * from './conversation-ingestion/index.js';
48
+ // PRI-1283 R2: consent-ledger-backed source-material authorization port
49
+ // implementation (the product adapter for the core port).
50
+ export * from './source-material-authorization.js';
51
+ // PRI-1283 R3: consent-revocation sweep over persisted source-material excerpts.
52
+ export * from './source-revocation-sweep.js';
48
53
  export * from './governance-signal-admission.js';
49
54
  export * from './signal-classifier.js';
50
55
  export * from './adaptive-selection.js';
@@ -28,6 +28,7 @@ import { loadLedger } from '@principles/core/principle-tree-ledger';
28
28
  import { loadPdConfigForPlugin, loadFeatureFlagFromConfig } from './pd-config.js';
29
29
  import { createEvaluatorRepairDeps, createRolloutGovernanceDeps } from './internalization-consumer-governance.js';
30
30
  import { WorkspaceTelemetryEmitter } from './workspace-telemetry-emitter.js';
31
+ import { createConsentLedgerSourceMaterialAuthorization } from './source-material-authorization.js';
31
32
  export const INTERNALIZATION_AUTO_CONSUMER_FLAG_ID = 'internalization_auto_consumer';
32
33
  function formatRunOnceCommand(workspaceDir) {
33
34
  return `pd runtime internalization run-once --workspace "${workspaceDir}" --runner dreamer --runtime config --json`;
@@ -277,7 +278,9 @@ async function executeConsumerCycle(workspaceDir, ports, signals) {
277
278
  // 是 reconciliation 存在的理由; 若 orchestrator 为 null, finally 的
278
279
  // bounded budget 不会执行, orphan 永远无法恢复。
279
280
  const { runtimeKind } = runtimeConfigResult;
280
- orchestrator = new InternalizationOrchestrator({ stateManager }, { owner, runtimeKind, dryRun: true });
281
+ orchestrator = new InternalizationOrchestrator(
282
+ // PRI-1283 R2: admission re-verification reads the latest consent.
283
+ { stateManager, sourceMaterialAuthorization: createConsentLedgerSourceMaterialAuthorization(workspaceDir) }, { owner, runtimeKind, dryRun: true });
281
284
  const readModel = new InternalizationQueueReadModel(stateManager);
282
285
  readModel.setPolicy({
283
286
  enabledChannels: new Set(['prompt', 'code_tool_hook', 'defer_archive']),
@@ -34,3 +34,13 @@ export declare function loadFeatureFlagFromConfig(workspaceDir: string, flagId:
34
34
  enabled: boolean;
35
35
  source: string;
36
36
  };
37
+ /**
38
+ * Env-var NAMES the workspace's runtime profiles reference for credentials
39
+ * (`runtimeProfiles.*.apiKeyEnv`). One collector for every consumer that
40
+ * must know which env names are credential-bearing (the Service Host worker
41
+ * environment allowlist, PRI-1280 Phase 2; the OpenClaw worker readiness
42
+ * credential check, PRI-1282 Phase 4). Names only — values never pass
43
+ * through here. Unreadable/malformed config yields [] and the caller's own
44
+ * degraded path reports the config problem (never a guess).
45
+ */
46
+ export declare function collectWorkspaceCredentialEnvNames(effective: unknown): readonly string[];
@@ -96,3 +96,40 @@ export function loadFeatureFlagFromConfig(workspaceDir, flagId, logger) {
96
96
  }
97
97
  return { enabled: flag?.enabled ?? false, source: result.source };
98
98
  }
99
+ /**
100
+ * Env-var NAMES the workspace's runtime profiles reference for credentials
101
+ * (`runtimeProfiles.*.apiKeyEnv`). One collector for every consumer that
102
+ * must know which env names are credential-bearing (the Service Host worker
103
+ * environment allowlist, PRI-1280 Phase 2; the OpenClaw worker readiness
104
+ * credential check, PRI-1282 Phase 4). Names only — values never pass
105
+ * through here. Unreadable/malformed config yields [] and the caller's own
106
+ * degraded path reports the config problem (never a guess).
107
+ */
108
+ export function collectWorkspaceCredentialEnvNames(effective) {
109
+ if (typeof effective !== 'object' || effective === null || Array.isArray(effective))
110
+ return [];
111
+ const record = effective;
112
+ const candidates = [
113
+ record.config,
114
+ record.runtimeProfiles !== undefined ? { runtimeProfiles: record.runtimeProfiles } : undefined,
115
+ ];
116
+ const names = new Set();
117
+ for (const candidate of candidates) {
118
+ if (typeof candidate !== 'object' || candidate === null || Array.isArray(candidate))
119
+ continue;
120
+ const profiles = candidate.runtimeProfiles;
121
+ if (typeof profiles !== 'object' || profiles === null || Array.isArray(profiles))
122
+ continue;
123
+ for (const profile of Object.values(profiles)) {
124
+ if (typeof profile !== 'object' || profile === null || Array.isArray(profile))
125
+ continue;
126
+ const apiKeyEnv = profile.apiKeyEnv;
127
+ if (typeof apiKeyEnv !== 'string' || apiKeyEnv.length === 0 || apiKeyEnv.length > 64)
128
+ continue;
129
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(apiKeyEnv))
130
+ continue;
131
+ names.add(apiKeyEnv);
132
+ }
133
+ }
134
+ return [...names];
135
+ }
@@ -1,4 +1,4 @@
1
- import { claimPendingCorrectionCandidates, recordPendingCorrectionReview, releasePendingCorrectionClaim, settlePendingCorrection, } from './governance-signal-admission.js';
1
+ import { claimPendingCorrectionCandidates, recordPendingCorrectionReview, releasePendingCorrectionClaim, settlePendingCorrection, verifyPendingClaimForClassification, } from './governance-signal-admission.js';
2
2
  const DEFAULT_MAX_CANDIDATES = 2;
3
3
  const DEFAULT_AGGREGATE_BUDGET_MS = 60_000;
4
4
  const DEFAULT_CLASSIFICATION_TIMEOUT_MS = 60_000;
@@ -102,6 +102,33 @@ export async function runStage2CorrectionCycle(input) {
102
102
  skipped += 1;
103
103
  continue;
104
104
  }
105
+ // PRI-1283 review round 2 (directive A5): the LAST authorization gate
106
+ // before the model request starts. Re-verifies claim ownership AND the
107
+ // row's live consent in one fresh read — after a revocation completes,
108
+ // no new classifier request may be started on the revoked source's
109
+ // text. The result of a request already in flight is fenced by
110
+ // recordPendingCorrectionReview (decision + claimToken CAS).
111
+ if (candidate.claimToken !== null) {
112
+ const verified = verifyPendingClaimForClassification({
113
+ workspaceDir: input.workspaceDir,
114
+ logicalObservationKey: candidate.logicalObservationKey,
115
+ claimToken: candidate.claimToken,
116
+ });
117
+ if (!verified.ok) {
118
+ degradations.push(`${candidate.logicalObservationKey}:claim_verify_failed:${verified.reason}`);
119
+ releaseClaim(candidate);
120
+ skipped += 1;
121
+ continue;
122
+ }
123
+ if (!verified.allowed) {
124
+ // Never start the model call; release so the next cycle's claim
125
+ // path terminates the row (A4) instead of re-claiming it.
126
+ releaseClaim(candidate);
127
+ degradations.push(`${candidate.logicalObservationKey}:classification_blocked:${verified.reason}`);
128
+ skipped += 1;
129
+ continue;
130
+ }
131
+ }
105
132
  // AbortSignal.timeout (pi-ai-runtime-adapter startRun) rejects
106
133
  // fractional delays with ERR_OUT_OF_RANGE, and `remaining` is a
107
134
  // performance.now() float — under the default 60s budget it is
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Consent-ledger-backed source-material authorization — PRI-1283 R2.
3
+ *
4
+ * THE implementation of `@principles/core`'s `SourceMaterialAuthorizationPort`
5
+ * for the real product. It answers ONE question, per call, against the
6
+ * conversation-ingestion consent ledger v3 (the single authority,
7
+ * conversation-ingestion/consent.ts):
8
+ *
9
+ * "is host H's conversation material readable RIGHT NOW?"
10
+ *
11
+ * Decision table (uniform, fail-closed):
12
+ *
13
+ * ledger read | decision | authorization
14
+ * ------------------|--------------|------------------------------------
15
+ * granted | — | authorized
16
+ * revoked | — | blocked (consent_revoked)
17
+ * pending / failed | — | blocked (consent_not_granted)
18
+ * no record | — | blocked (consent_missing) — no
19
+ * | | authority says this material may be
20
+ * | | read; legitimate ingestion never ran
21
+ * | | without a granted record (SPEC §8.2)
22
+ * unreadable file | — | blocked (consent_unreadable) — a
23
+ * | | malformed ledger fails loud, never
24
+ * | | "never asked" (consent.ts posture)
25
+ *
26
+ * Every call re-reads the ledger — there is deliberately NO cache: a
27
+ * revocation recorded between two reads must take effect on the next read
28
+ * (R2: "缓存命中时撤回 → 不得返回旧缓存内容"). Reading one small JSON file
29
+ * per check is the price of correctness; consumers gate once per assembly /
30
+ * model call, not per row.
31
+ */
32
+ import type { SourceAuthorizationState, SourceMaterialAuthorizationPort, SourceMaterialHostKind, SourceMaterialDenialReason } from '@principles/core/runtime';
33
+ export type { SourceAuthorizationState, SourceMaterialAuthorizationPort, SourceMaterialHostKind };
34
+ export interface ReadSourceMaterialAuthorizationInput {
35
+ readonly workspaceDir: string;
36
+ readonly hostKind: SourceMaterialHostKind;
37
+ }
38
+ export type SourceMaterialAuthorizationResult = {
39
+ readonly status: 'authorized';
40
+ } | {
41
+ readonly status: 'blocked';
42
+ readonly reason: SourceMaterialDenialReason;
43
+ readonly detail?: string;
44
+ };
45
+ /** Full-result read for health surfaces, tests and the sweep. */
46
+ export declare function readSourceMaterialAuthorization(input: ReadSourceMaterialAuthorizationInput): SourceMaterialAuthorizationResult;
47
+ /**
48
+ * Build the port bound to one workspace. Cheap to construct; every call
49
+ * performs a live ledger read. Inject at composition roots (CLI commands,
50
+ * workers, console models, MCP assembly) wherever governance-sourced material
51
+ * is consumed.
52
+ */
53
+ export declare function createConsentLedgerSourceMaterialAuthorization(workspaceDir: string): SourceMaterialAuthorizationPort;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Consent-ledger-backed source-material authorization — PRI-1283 R2.
3
+ *
4
+ * THE implementation of `@principles/core`'s `SourceMaterialAuthorizationPort`
5
+ * for the real product. It answers ONE question, per call, against the
6
+ * conversation-ingestion consent ledger v3 (the single authority,
7
+ * conversation-ingestion/consent.ts):
8
+ *
9
+ * "is host H's conversation material readable RIGHT NOW?"
10
+ *
11
+ * Decision table (uniform, fail-closed):
12
+ *
13
+ * ledger read | decision | authorization
14
+ * ------------------|--------------|------------------------------------
15
+ * granted | — | authorized
16
+ * revoked | — | blocked (consent_revoked)
17
+ * pending / failed | — | blocked (consent_not_granted)
18
+ * no record | — | blocked (consent_missing) — no
19
+ * | | authority says this material may be
20
+ * | | read; legitimate ingestion never ran
21
+ * | | without a granted record (SPEC §8.2)
22
+ * unreadable file | — | blocked (consent_unreadable) — a
23
+ * | | malformed ledger fails loud, never
24
+ * | | "never asked" (consent.ts posture)
25
+ *
26
+ * Every call re-reads the ledger — there is deliberately NO cache: a
27
+ * revocation recorded between two reads must take effect on the next read
28
+ * (R2: "缓存命中时撤回 → 不得返回旧缓存内容"). Reading one small JSON file
29
+ * per check is the price of correctness; consumers gate once per assembly /
30
+ * model call, not per row.
31
+ */
32
+ import { readConversationIngestionConsent } from './conversation-ingestion/consent.js';
33
+ /** Full-result read for health surfaces, tests and the sweep. */
34
+ export function readSourceMaterialAuthorization(input) {
35
+ const { workspaceDir, hostKind } = input;
36
+ const read = readConversationIngestionConsent(workspaceDir, hostKind);
37
+ if (!read.ok) {
38
+ return { status: 'blocked', reason: 'consent_unreadable', detail: `${read.reason}; ${read.nextAction}` };
39
+ }
40
+ const { record } = read;
41
+ if (record === null) {
42
+ return { status: 'blocked', reason: 'consent_missing', detail: `no conversation-ingestion consent record for host '${hostKind}' in this workspace` };
43
+ }
44
+ if (record.decision === 'granted') {
45
+ return { status: 'authorized' };
46
+ }
47
+ if (record.decision === 'revoked') {
48
+ return { status: 'blocked', reason: 'consent_revoked', detail: `consent revoked at ${record.decidedAt}` };
49
+ }
50
+ return { status: 'blocked', reason: 'consent_not_granted', detail: `consent decision '${record.decision}' (decidedAt ${record.decidedAt})` };
51
+ }
52
+ /**
53
+ * Build the port bound to one workspace. Cheap to construct; every call
54
+ * performs a live ledger read. Inject at composition roots (CLI commands,
55
+ * workers, console models, MCP assembly) wherever governance-sourced material
56
+ * is consumed.
57
+ */
58
+ export function createConsentLedgerSourceMaterialAuthorization(workspaceDir) {
59
+ return {
60
+ isHostSourceMaterialAuthorized(hostKind) {
61
+ const result = readSourceMaterialAuthorization({ workspaceDir, hostKind });
62
+ if (result.status === 'authorized')
63
+ return { authorized: true };
64
+ return { authorized: false, reason: result.reason, ...(result.detail !== undefined ? { detail: result.detail } : {}) };
65
+ },
66
+ };
67
+ }
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Source revocation sweep — PRI-1283 R3 (SPEC-PD-FEEDBACK-RESILIENCE-001
3
+ * TECH §2.2 "数据清退"), review round 2 (directives A2/A3/B/C/E).
4
+ *
5
+ * When a workspace host's conversation-ingestion consent leaves `granted`,
6
+ * the material already persisted FROM that host's conversations must be
7
+ * purged or made unreadable — UI hiding is not cleanup, and stopping new
8
+ * ingestion is not enough (TECH §2.2.1 R3).
9
+ *
10
+ * What this sweep does, per host whose ledger record exists with a
11
+ * non-granted decision (a MISSING or UNREADABLE ledger is not a revocation —
12
+ * nothing is purged, while the R2 read gates keep blocking consumption):
13
+ *
14
+ * trajectory.db (one connection; each step its own small transaction):
15
+ * 1. governance_observations (host rows, operational+promoted):
16
+ * visible_text / sanitized_tool_facts_json → NULL,
17
+ * retention_class → 'expired', expired_at → revocation time.
18
+ * Reuses the store's own expiry shape; the store's no-regain guard
19
+ * then prevents a later replay from re-bodying these rows — this is
20
+ * what makes RE-GRANTING not resurrect old excerpts.
21
+ * 2. governance_signal_admissions (host markers), classified per marker
22
+ * (directive B):
23
+ * - OWNER-EXPLICIT (correctionEvidence.classification
24
+ * 'owner_statement' / explicit channel / explicit reason marker)
25
+ * → PRESERVED (an explicit Owner submission is an Owner act, not
26
+ * conversation ingestion);
27
+ * - pending_llm_review rows → TERMINATED as abandoned
28
+ * ('source_revoked') with the D6 minimal terminal payload — the
29
+ * nested trigger.text / trigger.matchedTerms / hostTurnId /
30
+ * task_payload copies are dropped and the row becomes
31
+ * unclaimable (directive A3; the claim path re-verifies consent
32
+ * too — A4);
33
+ * - other automatic markers → task_payload_json redacted AND the
34
+ * independent `reason` COLUMN redacted (it quotes detected terms;
35
+ * directive C4);
36
+ * - unparseable payloads → redacted wholesale (fail-closed; the
37
+ * count is reported as unattributable).
38
+ * 3. pain_events of the host's AUTOMATIC admitted pains:
39
+ * text / reason → NULL (row, ids, timestamps survive — the Pain's
40
+ * business identity is NOT deleted). Owner-explicit statement pains
41
+ * are excluded from the purge set (their canonical ids come from the
42
+ * preserved markers).
43
+ *
44
+ * state.db (RuntimeStateManager when applying — task rows go through its
45
+ * CAS authority; a plain readonly connection for dry runs):
46
+ * 4. tasks.diagnostic_json: evidence entries of the revoked source are
47
+ * REMOVED; painIngress.evidenceClass is kept truthful
48
+ * (available.entryCount = remaining, or unavailable/source_revoked
49
+ * when empty); governed correctionEvidence is removed — an
50
+ * OWNER-EXPLICIT channel is kept (directive B); a non-sensitive
51
+ * `sourceRevocation` audit block records the verdict metadata only.
52
+ * Written via updateTaskIfDiagnosticJsonUnchanged (bounded CAS retry).
53
+ * 5. pain_diagnoses.evidence_json: revoked entries removed (row CAS).
54
+ * 6. artifacts (diagnostician_output).content_json: revoked evidence
55
+ * entries removed (row CAS). Model-authored root cause text survives.
56
+ * 7. runs.output_payload: the bare DiagnosticianOutputV2 (or the router
57
+ * envelope) embeds the same evidence[] notes — revoked entries are
58
+ * removed (row CAS; directive C2).
59
+ * 8. pi_artifacts.content_json: revoked evidence entries removed from
60
+ * every artifact kind that carries an evidence array (row CAS;
61
+ * directive C3).
62
+ *
63
+ * Checked, no excerpt fields (reported, never rewritten):
64
+ * - principle_candidates (model-generated description/title),
65
+ * - the principle ledger (reuseEvidence/derivedFromPainIds are ID
66
+ * metadata; principle text is model-authored),
67
+ * - governance_pending_promotion_tails / transcript_checkpoints
68
+ * (progress metadata, no text).
69
+ *
70
+ * Guarantees (SPEC §2.2.1 minimum cleanup contract + directive E):
71
+ * - idempotent: every step converges; a rerun reports zeros;
72
+ * - truly read-only dry run (directive E2): readonly connections
73
+ * (`fileMustExist`, `PRAGMA query_only=ON`), NO RuntimeStateManager
74
+ * initialization, no schema/migration/WAL writes, no database creation,
75
+ * no audit line;
76
+ * - per-table independence (directive E4): a missing table records
77
+ * `not_applicable` for that table ONLY; every other table still sweeps;
78
+ * - counted from writes (directive E5): every purged count comes from an
79
+ * actual successful CAS/UPDATE; a CAS race is a reported failure, never
80
+ * a success; an audit write failure is reported, never swallowed;
81
+ * - visible: an append-only `.state/source-revocation-sweep.jsonl` audit
82
+ * line records counts/verdicts/timestamps per host-run — never excerpt
83
+ * text;
84
+ * - retryable: per-item failures are recorded in the report and the run
85
+ * finishes the remaining items (outcome 'partial'); rerunning is safe;
86
+ * - bounded: busy_timeout + small transactions, per the trajectory
87
+ * retention runner's concurrency posture.
88
+ */
89
+ export declare const SOURCE_REVOCATION_SWEEP_AUDIT_FILENAME = "source-revocation-sweep.jsonl";
90
+ export type SweepHostKind = 'codex' | 'workbuddy' | 'openclaw';
91
+ export interface SourceRevocationSweepCounts {
92
+ /** governance_observations rows whose text/tool facts were NULLed. */
93
+ governanceObservations: number;
94
+ /** automatic admitted markers whose task_payload_json was redacted. */
95
+ admissionPayloads: number;
96
+ /** automatic admitted markers whose independent reason COLUMN was redacted. */
97
+ admissionReasons: number;
98
+ /** pending_llm_review rows terminated as abandoned('source_revoked'). */
99
+ pendingReviewsTerminated: number;
100
+ /** owner-explicit markers deliberately PRESERVED (directive B). */
101
+ preservedOwnerStatements: number;
102
+ /** markers whose payload could not be parsed — redacted wholesale. */
103
+ unattributableMarkers: number;
104
+ /** pain_events rows whose text/reason were NULLed. */
105
+ painEventTexts: number;
106
+ /** tasks whose diagnostic_json lost evidence entries. */
107
+ tasks: number;
108
+ /** evidence entries removed from task diagnostic_json. */
109
+ taskEvidenceEntries: number;
110
+ /** governed correctionEvidence blocks removed from tasks. */
111
+ taskCorrectionEvidence: number;
112
+ /** pain_diagnoses rows whose evidence_json was rewritten. */
113
+ painDiagnoses: number;
114
+ /** evidence entries removed from pain_diagnoses rows. */
115
+ painDiagnosesEvidenceEntries: number;
116
+ /** diagnostician_output artifacts whose content_json was rewritten. */
117
+ artifacts: number;
118
+ /** evidence entries removed from artifacts. */
119
+ artifactEvidenceEntries: number;
120
+ /** runs whose output_payload was rewritten (directive C2). */
121
+ runs: number;
122
+ /** evidence entries removed from runs.output_payload. */
123
+ runEvidenceEntries: number;
124
+ /** pi_artifacts rows whose content_json was rewritten (directive C3). */
125
+ piArtifacts: number;
126
+ /** evidence entries removed from pi_artifacts. */
127
+ piArtifactEvidenceEntries: number;
128
+ }
129
+ export interface SourceRevocationSweepHostReport {
130
+ readonly hostKind: SweepHostKind;
131
+ readonly consentDecision: 'revoked' | 'pending' | 'failed';
132
+ readonly decidedAt: string | null;
133
+ readonly swept: boolean;
134
+ readonly purged: SourceRevocationSweepCounts;
135
+ /** Tables absent in this workspace — reported per table (directive E4). */
136
+ readonly notApplicable: readonly string[];
137
+ /** Non-sensitive per-item failure notes (bounded). */
138
+ readonly failures: readonly string[];
139
+ }
140
+ export type SourceRevocationSweepReport = {
141
+ readonly outcome: 'completed' | 'partial';
142
+ readonly workspaceDir: string;
143
+ readonly ranAt: string;
144
+ readonly apply: boolean;
145
+ readonly hosts: readonly SourceRevocationSweepHostReport[];
146
+ /**
147
+ * `null` on completed; a stable reason on partial so an operator (or
148
+ * `--json` consumer) does not have to mine per-host failures for the
149
+ * headline. PRI-1283 review: the report promised a top-level cause and
150
+ * recovery step, matching the failed/skipped variant below.
151
+ */
152
+ readonly reason: string | null;
153
+ readonly nextAction?: string;
154
+ } | {
155
+ readonly outcome: 'skipped' | 'failed';
156
+ readonly workspaceDir: string;
157
+ readonly ranAt: string;
158
+ readonly apply: boolean;
159
+ readonly hosts: readonly SourceRevocationSweepHostReport[];
160
+ readonly reason: string;
161
+ readonly nextAction?: string;
162
+ /** Locations verified to carry NO excerpt fields (reported for the audit). */
163
+ readonly checkedOnly?: readonly string[];
164
+ };
165
+ export interface RunSourceRevocationSweepOptions {
166
+ readonly workspaceDir: string;
167
+ /** Dry run (default): counts what WOULD be purged, writes nothing. */
168
+ readonly apply: boolean;
169
+ /** Injectable clock (tests). */
170
+ readonly now?: () => Date;
171
+ }
172
+ export declare function runSourceRevocationSweep(options: RunSourceRevocationSweepOptions): Promise<SourceRevocationSweepReport>;