create-principles-disciple 1.150.3 → 1.150.6

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 (646) hide show
  1. package/_release/product-identity.json +1 -1
  2. package/codex-adapter/dist/ingestion/admission.js +2 -0
  3. package/codex-adapter/dist/ingestion/ingestion.js +25 -4
  4. package/codex-adapter/dist/ingestion/transcript-decoder.d.ts +5 -3
  5. package/codex-adapter/dist/ingestion/transcript-decoder.js +61 -5
  6. package/codex-adapter/dist/pd-hook.d.ts +7 -5
  7. package/codex-adapter/dist/pd-hook.js +18 -7
  8. package/codex-adapter/dist/tool-semantics.js +5 -1
  9. package/codex-adapter/dist/worker/workspace-worker.js +4 -2
  10. package/codex-adapter/package.json +1 -1
  11. package/console/dist/lib/utils.js +16 -1
  12. package/console/dist/server/index.js +14 -2
  13. package/console/dist/server/models/ActivationsConsoleModel.js +3 -2
  14. package/console/dist/server/models/ApprovalsConsoleModel.js +2 -1
  15. package/console/dist/server/models/ApprovalsGroupedConsoleModel.js +2 -1
  16. package/console/dist/server/models/EvidenceChainConsoleModel.d.ts +46 -0
  17. package/console/dist/server/models/EvidenceChainConsoleModel.js +121 -2
  18. package/console/dist/server/models/GovernanceConsoleModel.js +3 -2
  19. package/console/dist/server/models/GovernanceExperienceCollector.js +2 -1
  20. package/console/dist/server/models/GovernanceProjectionCollector.js +2 -1
  21. package/console/dist/server/models/IngestionHealthModel.d.ts +34 -0
  22. package/console/dist/server/models/IngestionHealthModel.js +254 -0
  23. package/console/dist/server/models/IntentDecisionModel.js +2 -2
  24. package/console/dist/server/models/IntentPageModel.js +2 -1
  25. package/console/dist/server/models/OwnerDecisionConsoleModel.js +3 -3
  26. package/console/dist/server/models/OwnerDecisionViewModel.js +2 -2
  27. package/console/dist/server/models/PrincipleTrajectoryModel.js +2 -1
  28. package/console/dist/server/models/ReceiptsConsoleModel.js +2 -2
  29. package/console/dist/server/models/RuleCandidateBindingConsoleModel.js +3 -2
  30. package/console/dist/server/routes/diagnostician.js +2 -1
  31. package/console/dist/server/routes/evidence-chain.d.ts +4 -0
  32. package/console/dist/server/routes/evidence-chain.js +22 -0
  33. package/console/dist/server/routes/failed-tasks.js +78 -2
  34. package/console/dist/server/routes/health.d.ts +8 -0
  35. package/console/dist/server/routes/health.js +72 -0
  36. package/console/dist/server/routes/owner-identity.d.ts +6 -0
  37. package/console/dist/server/routes/owner-identity.js +7 -3
  38. package/console/dist/server/routes/principles.js +3 -3
  39. package/console/dist/web/assets/app.css +150 -46
  40. package/console/dist/web/assets/app.js +37 -32
  41. package/console/package.json +2 -0
  42. package/core/dist/runtime/activation/adaptive-selection-output.d.ts +0 -21
  43. package/core/dist/runtime/activation/adaptive-selection-output.d.ts.map +1 -1
  44. package/core/dist/runtime/activation/adaptive-selection-output.js.map +1 -1
  45. package/core/dist/runtime/activation/index.d.ts +2 -6
  46. package/core/dist/runtime/activation/index.d.ts.map +1 -1
  47. package/core/dist/runtime/activation/index.js.map +1 -1
  48. package/core/dist/runtime/activation/production-gate-deps.d.ts +2 -1
  49. package/core/dist/runtime/activation/production-gate-deps.d.ts.map +1 -1
  50. package/core/dist/runtime/activation/prompt-activation-reader-contract.d.ts +2 -1
  51. package/core/dist/runtime/activation/prompt-activation-reader-contract.d.ts.map +1 -1
  52. package/core/dist/runtime/activation/writers/index.d.ts +0 -1
  53. package/core/dist/runtime/activation/writers/index.d.ts.map +1 -1
  54. package/core/dist/runtime/activation/writers/rule-host-writer.d.ts.map +1 -1
  55. package/core/dist/runtime/activation/writers/rule-host-writer.js +15 -6
  56. package/core/dist/runtime/activation/writers/rule-host-writer.js.map +1 -1
  57. package/core/dist/runtime/activation-compatibility-read-model.d.ts +3 -2
  58. package/core/dist/runtime/activation-compatibility-read-model.d.ts.map +1 -1
  59. package/core/dist/runtime/activation-compatibility-read-model.js +2 -1
  60. package/core/dist/runtime/activation-compatibility-read-model.js.map +1 -1
  61. package/core/dist/runtime/adapter/context-budget.d.ts +3 -14
  62. package/core/dist/runtime/adapter/context-budget.d.ts.map +1 -1
  63. package/core/dist/runtime/adapter/context-budget.js +2 -2
  64. package/core/dist/runtime/adapter/context-budget.js.map +1 -1
  65. package/core/dist/runtime/adapter/index.d.ts +1 -2
  66. package/core/dist/runtime/adapter/index.d.ts.map +1 -1
  67. package/core/dist/runtime/adapter/index.js +1 -1
  68. package/core/dist/runtime/adapter/index.js.map +1 -1
  69. package/core/dist/runtime/adapter/output-repair-contract.d.ts +18 -1
  70. package/core/dist/runtime/adapter/output-repair-contract.d.ts.map +1 -1
  71. package/core/dist/runtime/adapter/output-repair-contract.js +94 -0
  72. package/core/dist/runtime/adapter/output-repair-contract.js.map +1 -1
  73. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts +2 -3
  74. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
  75. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js +111 -21
  76. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js.map +1 -1
  77. package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts +1 -1
  78. package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts.map +1 -1
  79. package/core/dist/runtime/adapter/schema-prompt-adapter.d.ts +0 -1
  80. package/core/dist/runtime/adapter/schema-prompt-adapter.d.ts.map +1 -1
  81. package/core/dist/runtime/adapter/schema-prompt-adapter.js +43 -1
  82. package/core/dist/runtime/adapter/schema-prompt-adapter.js.map +1 -1
  83. package/core/dist/runtime/bridge-result-shaper.d.ts +1 -1
  84. package/core/dist/runtime/bridge-result-shaper.d.ts.map +1 -1
  85. package/core/dist/runtime/candidate-audit.d.ts.map +1 -1
  86. package/core/dist/runtime/candidate-audit.js +2 -1
  87. package/core/dist/runtime/candidate-audit.js.map +1 -1
  88. package/core/dist/runtime/candidate-intake-service.d.ts +2 -1
  89. package/core/dist/runtime/candidate-intake-service.d.ts.map +1 -1
  90. package/core/dist/runtime/cli/diagnose.d.ts +4 -3
  91. package/core/dist/runtime/cli/diagnose.d.ts.map +1 -1
  92. package/core/dist/runtime/config/index.d.ts +2 -2
  93. package/core/dist/runtime/config/index.d.ts.map +1 -1
  94. package/core/dist/runtime/config/index.js +3 -3
  95. package/core/dist/runtime/config/index.js.map +1 -1
  96. package/core/dist/runtime/config/pd-config-defaults.d.ts +0 -2
  97. package/core/dist/runtime/config/pd-config-defaults.d.ts.map +1 -1
  98. package/core/dist/runtime/config/pd-config-defaults.js +2 -2
  99. package/core/dist/runtime/config/pd-config-defaults.js.map +1 -1
  100. package/core/dist/runtime/config/pd-config-effective.d.ts.map +1 -1
  101. package/core/dist/runtime/config/pd-config-effective.js +2 -0
  102. package/core/dist/runtime/config/pd-config-effective.js.map +1 -1
  103. package/core/dist/runtime/config/pd-config-types.d.ts +54 -0
  104. package/core/dist/runtime/config/pd-config-types.d.ts.map +1 -1
  105. package/core/dist/runtime/config/pd-config-types.js.map +1 -1
  106. package/core/dist/runtime/config/pd-config-validate.d.ts.map +1 -1
  107. package/core/dist/runtime/config/pd-config-validate.js +143 -0
  108. package/core/dist/runtime/config/pd-config-validate.js.map +1 -1
  109. package/core/dist/runtime/config/pd-profile-constants.d.ts +1 -7
  110. package/core/dist/runtime/config/pd-profile-constants.d.ts.map +1 -1
  111. package/core/dist/runtime/config/pd-profile-constants.js +5 -6
  112. package/core/dist/runtime/config/pd-profile-constants.js.map +1 -1
  113. package/core/dist/runtime/config/pd-validate-profile.d.ts +3 -2
  114. package/core/dist/runtime/config/pd-validate-profile.d.ts.map +1 -1
  115. package/core/dist/runtime/context-payload.d.ts +0 -7
  116. package/core/dist/runtime/context-payload.d.ts.map +1 -1
  117. package/core/dist/runtime/context-payload.js +1 -1
  118. package/core/dist/runtime/context-payload.js.map +1 -1
  119. package/core/dist/runtime/core-principles/index.d.ts +1 -1
  120. package/core/dist/runtime/core-principles/index.d.ts.map +1 -1
  121. package/core/dist/runtime/correction/correction-types.d.ts +0 -10
  122. package/core/dist/runtime/correction/correction-types.d.ts.map +1 -1
  123. package/core/dist/runtime/correction/correction-types.js.map +1 -1
  124. package/core/dist/runtime/diagnostician/diag-distiller-output.d.ts +0 -3
  125. package/core/dist/runtime/diagnostician/diag-distiller-output.d.ts.map +1 -1
  126. package/core/dist/runtime/diagnostician/diag-distiller-output.js +1 -1
  127. package/core/dist/runtime/diagnostician/diag-distiller-output.js.map +1 -1
  128. package/core/dist/runtime/diagnostician/diag-rootcause-output.d.ts +3 -11
  129. package/core/dist/runtime/diagnostician/diag-rootcause-output.d.ts.map +1 -1
  130. package/core/dist/runtime/diagnostician/diag-rootcause-output.js +3 -3
  131. package/core/dist/runtime/diagnostician/diag-rootcause-output.js.map +1 -1
  132. package/core/dist/runtime/diagnostician/distiller-prompt-builder.d.ts +5 -4
  133. package/core/dist/runtime/diagnostician/distiller-prompt-builder.d.ts.map +1 -1
  134. package/core/dist/runtime/diagnostician/evidence-ref-binding.d.ts +2 -1
  135. package/core/dist/runtime/diagnostician/evidence-ref-binding.d.ts.map +1 -1
  136. package/core/dist/runtime/diagnostician/rootcause-prompt-builder.d.ts +2 -1
  137. package/core/dist/runtime/diagnostician/rootcause-prompt-builder.d.ts.map +1 -1
  138. package/core/dist/runtime/diagnostician/router-prompt-builder.d.ts +22 -3
  139. package/core/dist/runtime/diagnostician/router-prompt-builder.d.ts.map +1 -1
  140. package/core/dist/runtime/diagnostician/router-prompt-builder.js +11 -1
  141. package/core/dist/runtime/diagnostician/router-prompt-builder.js.map +1 -1
  142. package/core/dist/runtime/diagnostician-association-shadow.d.ts +2 -2
  143. package/core/dist/runtime/diagnostician-association-shadow.d.ts.map +1 -1
  144. package/core/dist/runtime/diagnostician-association-validation.d.ts +3 -2
  145. package/core/dist/runtime/diagnostician-association-validation.d.ts.map +1 -1
  146. package/core/dist/runtime/diagnostician-output.d.ts +32 -5
  147. package/core/dist/runtime/diagnostician-output.d.ts.map +1 -1
  148. package/core/dist/runtime/diagnostician-output.js +47 -4
  149. package/core/dist/runtime/diagnostician-output.js.map +1 -1
  150. package/core/dist/runtime/diagnostician-prompt-builder.d.ts +2 -1
  151. package/core/dist/runtime/diagnostician-prompt-builder.d.ts.map +1 -1
  152. package/core/dist/runtime/error-categories.d.ts.map +1 -1
  153. package/core/dist/runtime/error-categories.js +10 -1
  154. package/core/dist/runtime/error-categories.js.map +1 -1
  155. package/core/dist/runtime/evidence-sanitizer.d.ts +8 -1
  156. package/core/dist/runtime/evidence-sanitizer.d.ts.map +1 -1
  157. package/core/dist/runtime/evidence-sanitizer.js +10 -3
  158. package/core/dist/runtime/evidence-sanitizer.js.map +1 -1
  159. package/core/dist/runtime/evolution/evolution-types.d.ts +0 -26
  160. package/core/dist/runtime/evolution/evolution-types.d.ts.map +1 -1
  161. package/core/dist/runtime/evolution/evolution-types.js.map +1 -1
  162. package/core/dist/runtime/feature-flags/feature-flag-contract.d.ts.map +1 -1
  163. package/core/dist/runtime/feature-flags/feature-flag-contract.js +8 -0
  164. package/core/dist/runtime/feature-flags/feature-flag-contract.js.map +1 -1
  165. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.d.ts.map +1 -1
  166. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js +24 -0
  167. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js.map +1 -1
  168. package/core/dist/runtime/feature-flags/index.d.ts +0 -1
  169. package/core/dist/runtime/feature-flags/index.d.ts.map +1 -1
  170. package/core/dist/runtime/feature-flags/index.js.map +1 -1
  171. package/core/dist/runtime/golden-trace.d.ts +9 -1
  172. package/core/dist/runtime/golden-trace.d.ts.map +1 -1
  173. package/core/dist/runtime/golden-trace.js +7 -0
  174. package/core/dist/runtime/golden-trace.js.map +1 -1
  175. package/core/dist/runtime/governance-projection-contract.d.ts +0 -6
  176. package/core/dist/runtime/governance-projection-contract.d.ts.map +1 -1
  177. package/core/dist/runtime/governance-projection-contract.js +3 -3
  178. package/core/dist/runtime/governance-projection-contract.js.map +1 -1
  179. package/core/dist/runtime/index.d.ts +2 -0
  180. package/core/dist/runtime/index.d.ts.map +1 -1
  181. package/core/dist/runtime/index.js +2 -0
  182. package/core/dist/runtime/index.js.map +1 -1
  183. package/core/dist/runtime/internalization/artifact-summary.d.ts +5 -4
  184. package/core/dist/runtime/internalization/artifact-summary.d.ts.map +1 -1
  185. package/core/dist/runtime/internalization/artifact-summary.js +1 -1
  186. package/core/dist/runtime/internalization/artifact-summary.js.map +1 -1
  187. package/core/dist/runtime/internalization/artificer-intent-preflight.d.ts +1 -1
  188. package/core/dist/runtime/internalization/artificer-intent-preflight.d.ts.map +1 -1
  189. package/core/dist/runtime/internalization/artificer-output.d.ts +0 -2
  190. package/core/dist/runtime/internalization/artificer-output.d.ts.map +1 -1
  191. package/core/dist/runtime/internalization/artificer-output.js +17 -0
  192. package/core/dist/runtime/internalization/artificer-output.js.map +1 -1
  193. package/core/dist/runtime/internalization/artificer-prompt-builder.d.ts +14 -3
  194. package/core/dist/runtime/internalization/artificer-prompt-builder.d.ts.map +1 -1
  195. package/core/dist/runtime/internalization/artificer-prompt-builder.js +13 -1
  196. package/core/dist/runtime/internalization/artificer-prompt-builder.js.map +1 -1
  197. package/core/dist/runtime/internalization/artificer-run-correlation.d.ts +3 -2
  198. package/core/dist/runtime/internalization/artificer-run-correlation.d.ts.map +1 -1
  199. package/core/dist/runtime/internalization/consumer-evidence-preflight.d.ts +2 -1
  200. package/core/dist/runtime/internalization/consumer-evidence-preflight.d.ts.map +1 -1
  201. package/core/dist/runtime/internalization/diag-distiller-runner.d.ts +1 -1
  202. package/core/dist/runtime/internalization/diag-distiller-runner.d.ts.map +1 -1
  203. package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts +1 -1
  204. package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts.map +1 -1
  205. package/core/dist/runtime/internalization/diag-router-runner.d.ts +11 -1
  206. package/core/dist/runtime/internalization/diag-router-runner.d.ts.map +1 -1
  207. package/core/dist/runtime/internalization/diag-router-runner.js +105 -1
  208. package/core/dist/runtime/internalization/diag-router-runner.js.map +1 -1
  209. package/core/dist/runtime/internalization/dreamer-output.d.ts +0 -9
  210. package/core/dist/runtime/internalization/dreamer-output.d.ts.map +1 -1
  211. package/core/dist/runtime/internalization/dreamer-output.js +1 -1
  212. package/core/dist/runtime/internalization/dreamer-output.js.map +1 -1
  213. package/core/dist/runtime/internalization/dreamer-prompt-builder.d.ts +3 -2
  214. package/core/dist/runtime/internalization/dreamer-prompt-builder.d.ts.map +1 -1
  215. package/core/dist/runtime/internalization/dreamer-runner.d.ts +1 -1
  216. package/core/dist/runtime/internalization/dreamer-runner.d.ts.map +1 -1
  217. package/core/dist/runtime/internalization/evaluator-output.d.ts +7 -17
  218. package/core/dist/runtime/internalization/evaluator-output.d.ts.map +1 -1
  219. package/core/dist/runtime/internalization/evaluator-output.js +2 -2
  220. package/core/dist/runtime/internalization/evaluator-output.js.map +1 -1
  221. package/core/dist/runtime/internalization/evaluator-prompt-builder.d.ts +3 -9
  222. package/core/dist/runtime/internalization/evaluator-prompt-builder.d.ts.map +1 -1
  223. package/core/dist/runtime/internalization/evaluator-prompt-builder.js +1 -1
  224. package/core/dist/runtime/internalization/evaluator-prompt-builder.js.map +1 -1
  225. package/core/dist/runtime/internalization/formation-context.d.ts +4 -6
  226. package/core/dist/runtime/internalization/formation-context.d.ts.map +1 -1
  227. package/core/dist/runtime/internalization/formation-context.js +3 -3
  228. package/core/dist/runtime/internalization/formation-context.js.map +1 -1
  229. package/core/dist/runtime/internalization/index.d.ts +2 -4
  230. package/core/dist/runtime/internalization/index.d.ts.map +1 -1
  231. package/core/dist/runtime/internalization/index.js +8 -1
  232. package/core/dist/runtime/internalization/index.js.map +1 -1
  233. package/core/dist/runtime/internalization/intake-to-internalization-bridge.d.ts +2 -1
  234. package/core/dist/runtime/internalization/intake-to-internalization-bridge.d.ts.map +1 -1
  235. package/core/dist/runtime/internalization/intent-contract.d.ts +2 -1
  236. package/core/dist/runtime/internalization/intent-contract.d.ts.map +1 -1
  237. package/core/dist/runtime/internalization/internalization-job-graph.d.ts +1 -1
  238. package/core/dist/runtime/internalization/internalization-job-graph.d.ts.map +1 -1
  239. package/core/dist/runtime/internalization/internalization-route.d.ts +2 -1
  240. package/core/dist/runtime/internalization/internalization-route.d.ts.map +1 -1
  241. package/core/dist/runtime/internalization/owner-decision-review.d.ts +3 -2
  242. package/core/dist/runtime/internalization/owner-decision-review.d.ts.map +1 -1
  243. package/core/dist/runtime/internalization/owner-resolution-service.d.ts +2 -1
  244. package/core/dist/runtime/internalization/owner-resolution-service.d.ts.map +1 -1
  245. package/core/dist/runtime/internalization/owner-retry.d.ts +2 -1
  246. package/core/dist/runtime/internalization/owner-retry.d.ts.map +1 -1
  247. package/core/dist/runtime/internalization/owner-review.d.ts +2 -21
  248. package/core/dist/runtime/internalization/owner-review.d.ts.map +1 -1
  249. package/core/dist/runtime/internalization/owner-review.js +2 -2
  250. package/core/dist/runtime/internalization/owner-review.js.map +1 -1
  251. package/core/dist/runtime/internalization/peer-runner-contracts.d.ts +2 -5
  252. package/core/dist/runtime/internalization/peer-runner-contracts.d.ts.map +1 -1
  253. package/core/dist/runtime/internalization/peer-runner-contracts.js +1 -1
  254. package/core/dist/runtime/internalization/peer-runner-contracts.js.map +1 -1
  255. package/core/dist/runtime/internalization/philosopher-output.d.ts +0 -8
  256. package/core/dist/runtime/internalization/philosopher-output.d.ts.map +1 -1
  257. package/core/dist/runtime/internalization/philosopher-output.js +1 -1
  258. package/core/dist/runtime/internalization/philosopher-output.js.map +1 -1
  259. package/core/dist/runtime/internalization/philosopher-prompt-builder.d.ts +3 -2
  260. package/core/dist/runtime/internalization/philosopher-prompt-builder.d.ts.map +1 -1
  261. package/core/dist/runtime/internalization/pitask-metadata.d.ts +1 -1
  262. package/core/dist/runtime/internalization/pitask-metadata.d.ts.map +1 -1
  263. package/core/dist/runtime/internalization/repair-replay-resolver.d.ts +4 -3
  264. package/core/dist/runtime/internalization/repair-replay-resolver.d.ts.map +1 -1
  265. package/core/dist/runtime/internalization/rollout-reviewer-output.d.ts +2 -3
  266. package/core/dist/runtime/internalization/rollout-reviewer-output.d.ts.map +1 -1
  267. package/core/dist/runtime/internalization/rollout-reviewer-output.js.map +1 -1
  268. package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.d.ts +0 -1
  269. package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.d.ts.map +1 -1
  270. package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.js +1 -1
  271. package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.js.map +1 -1
  272. package/core/dist/runtime/internalization/router-context-reconstruction.d.ts +3 -3
  273. package/core/dist/runtime/internalization/router-context-reconstruction.d.ts.map +1 -1
  274. package/core/dist/runtime/internalization/rule-activation-contract.d.ts +3 -2
  275. package/core/dist/runtime/internalization/rule-activation-contract.d.ts.map +1 -1
  276. package/core/dist/runtime/internalization/rule-host-input-builder.d.ts +16 -0
  277. package/core/dist/runtime/internalization/rule-host-input-builder.d.ts.map +1 -1
  278. package/core/dist/runtime/internalization/rule-host-input-builder.js +18 -0
  279. package/core/dist/runtime/internalization/rule-host-input-builder.js.map +1 -1
  280. package/core/dist/runtime/internalization/rule-reliability-validation.d.ts +13 -18
  281. package/core/dist/runtime/internalization/rule-reliability-validation.d.ts.map +1 -1
  282. package/core/dist/runtime/internalization/rule-reliability-validation.js +43 -1
  283. package/core/dist/runtime/internalization/rule-reliability-validation.js.map +1 -1
  284. package/core/dist/runtime/internalization/scribe-output.d.ts +2 -15
  285. package/core/dist/runtime/internalization/scribe-output.d.ts.map +1 -1
  286. package/core/dist/runtime/internalization/scribe-output.js +2 -2
  287. package/core/dist/runtime/internalization/scribe-output.js.map +1 -1
  288. package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts +3 -3
  289. package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts.map +1 -1
  290. package/core/dist/runtime/internalization/scribe-prompt-builder.js +0 -1
  291. package/core/dist/runtime/internalization/scribe-prompt-builder.js.map +1 -1
  292. package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts +25 -1
  293. package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts.map +1 -1
  294. package/core/dist/runtime/internalization/split-diagnostician-runner.js +122 -5
  295. package/core/dist/runtime/internalization/split-diagnostician-runner.js.map +1 -1
  296. package/core/dist/runtime/internalization/textual-basis-anchor.d.ts +3 -6
  297. package/core/dist/runtime/internalization/textual-basis-anchor.d.ts.map +1 -1
  298. package/core/dist/runtime/internalization/textual-basis-anchor.js +2 -2
  299. package/core/dist/runtime/internalization/textual-basis-anchor.js.map +1 -1
  300. package/core/dist/runtime/internalization/tool-semantic-registry.d.ts +26 -0
  301. package/core/dist/runtime/internalization/tool-semantic-registry.d.ts.map +1 -1
  302. package/core/dist/runtime/internalization/tool-semantic-registry.js +55 -5
  303. package/core/dist/runtime/internalization/tool-semantic-registry.js.map +1 -1
  304. package/core/dist/runtime/internalization-chain-integrity-read-model.d.ts.map +1 -1
  305. package/core/dist/runtime/internalization-chain-integrity-read-model.js +2 -2
  306. package/core/dist/runtime/internalization-chain-integrity-read-model.js.map +1 -1
  307. package/core/dist/runtime/internalization-integrity-remediation.d.ts.map +1 -1
  308. package/core/dist/runtime/internalization-integrity-remediation.js +2 -2
  309. package/core/dist/runtime/internalization-integrity-remediation.js.map +1 -1
  310. package/core/dist/runtime/language-directive.d.ts +2 -1
  311. package/core/dist/runtime/language-directive.d.ts.map +1 -1
  312. package/core/dist/runtime/operator-health-read-model.d.ts.map +1 -1
  313. package/core/dist/runtime/operator-health-read-model.js +2 -2
  314. package/core/dist/runtime/operator-health-read-model.js.map +1 -1
  315. package/core/dist/runtime/owner-decision/owner-decision-view-contract.d.ts +3 -29
  316. package/core/dist/runtime/owner-decision/owner-decision-view-contract.d.ts.map +1 -1
  317. package/core/dist/runtime/owner-decision/owner-decision-view-contract.js +4 -5
  318. package/core/dist/runtime/owner-decision/owner-decision-view-contract.js.map +1 -1
  319. package/core/dist/runtime/owner-decision/owner-decision-view.d.ts +0 -49
  320. package/core/dist/runtime/owner-decision/owner-decision-view.d.ts.map +1 -1
  321. package/core/dist/runtime/owner-decision/owner-decision-view.js +5 -5
  322. package/core/dist/runtime/owner-decision/owner-decision-view.js.map +1 -1
  323. package/core/dist/runtime/owner-decision/semantic-selector.d.ts +3 -2
  324. package/core/dist/runtime/owner-decision/semantic-selector.d.ts.map +1 -1
  325. package/core/dist/runtime/owner-identity.d.ts +12 -1
  326. package/core/dist/runtime/owner-identity.d.ts.map +1 -1
  327. package/core/dist/runtime/owner-identity.js +19 -1
  328. package/core/dist/runtime/owner-identity.js.map +1 -1
  329. package/core/dist/runtime/pain-ingress-payload.d.ts +0 -39
  330. package/core/dist/runtime/pain-ingress-payload.d.ts.map +1 -1
  331. package/core/dist/runtime/pain-ingress-payload.js +4 -4
  332. package/core/dist/runtime/pain-ingress-payload.js.map +1 -1
  333. package/core/dist/runtime/pain-ingress.d.ts +1 -1
  334. package/core/dist/runtime/pain-ingress.d.ts.map +1 -1
  335. package/core/dist/runtime/pain-ingress.js.map +1 -1
  336. package/core/dist/runtime/pain-recall-read-model.d.ts.map +1 -1
  337. package/core/dist/runtime/pain-recall-read-model.js +4 -3
  338. package/core/dist/runtime/pain-recall-read-model.js.map +1 -1
  339. package/core/dist/runtime/pain-signal-bridge.d.ts +0 -2
  340. package/core/dist/runtime/pain-signal-bridge.d.ts.map +1 -1
  341. package/core/dist/runtime/pain-signal-bridge.js +1 -1
  342. package/core/dist/runtime/pain-signal-bridge.js.map +1 -1
  343. package/core/dist/runtime/pain-signal-runtime-factory.d.ts +3 -3
  344. package/core/dist/runtime/pain-signal-runtime-factory.d.ts.map +1 -1
  345. package/core/dist/runtime/pain-signal-runtime-factory.js +1 -1
  346. package/core/dist/runtime/pain-signal-runtime-factory.js.map +1 -1
  347. package/core/dist/runtime/principle-reuse/reuse-proposal.d.ts +3 -2
  348. package/core/dist/runtime/principle-reuse/reuse-proposal.d.ts.map +1 -1
  349. package/core/dist/runtime/principle-reuse/reuse-retrieval.d.ts +0 -10
  350. package/core/dist/runtime/principle-reuse/reuse-retrieval.d.ts.map +1 -1
  351. package/core/dist/runtime/principle-reuse/reuse-retrieval.js +1 -1
  352. package/core/dist/runtime/principle-reuse/reuse-retrieval.js.map +1 -1
  353. package/core/dist/runtime/principle-reuse/reuse-shortlist.d.ts +1 -8
  354. package/core/dist/runtime/principle-reuse/reuse-shortlist.d.ts.map +1 -1
  355. package/core/dist/runtime/principle-reuse/reuse-shortlist.js +1 -1
  356. package/core/dist/runtime/principle-reuse/reuse-shortlist.js.map +1 -1
  357. package/core/dist/runtime/product-telemetry/snapshot-contract.d.ts +3 -2
  358. package/core/dist/runtime/product-telemetry/snapshot-contract.d.ts.map +1 -1
  359. package/core/dist/runtime/pruning-read-model.d.ts.map +1 -1
  360. package/core/dist/runtime/pruning-read-model.js +3 -2
  361. package/core/dist/runtime/pruning-read-model.js.map +1 -1
  362. package/core/dist/runtime/risk/risk-calculator-policy.d.ts +12 -2
  363. package/core/dist/runtime/risk/risk-calculator-policy.d.ts.map +1 -1
  364. package/core/dist/runtime/risk/risk-calculator-policy.js +33 -22
  365. package/core/dist/runtime/risk/risk-calculator-policy.js.map +1 -1
  366. package/core/dist/runtime/runner/base-peer-runner.d.ts +32 -0
  367. package/core/dist/runtime/runner/base-peer-runner.d.ts.map +1 -1
  368. package/core/dist/runtime/runner/base-peer-runner.js +168 -16
  369. package/core/dist/runtime/runner/base-peer-runner.js.map +1 -1
  370. package/core/dist/runtime/runner/default-validator.d.ts +0 -1
  371. package/core/dist/runtime/runner/default-validator.d.ts.map +1 -1
  372. package/core/dist/runtime/runner/default-validator.js +11 -3
  373. package/core/dist/runtime/runner/default-validator.js.map +1 -1
  374. package/core/dist/runtime/runner/peer-runner-types.d.ts +11 -0
  375. package/core/dist/runtime/runner/peer-runner-types.d.ts.map +1 -1
  376. package/core/dist/runtime/schema-conformance-read-model.js +2 -2
  377. package/core/dist/runtime/schema-conformance-read-model.js.map +1 -1
  378. package/core/dist/runtime/storage-paths.d.ts +15 -0
  379. package/core/dist/runtime/storage-paths.d.ts.map +1 -0
  380. package/core/dist/runtime/storage-paths.js +15 -0
  381. package/core/dist/runtime/storage-paths.js.map +1 -0
  382. package/core/dist/runtime/store/artifact/index.d.ts +1 -1
  383. package/core/dist/runtime/store/artifact/index.d.ts.map +1 -1
  384. package/core/dist/runtime/store/candidate/admission-document.d.ts +4 -3
  385. package/core/dist/runtime/store/candidate/admission-document.d.ts.map +1 -1
  386. package/core/dist/runtime/store/commit/index.d.ts +0 -1
  387. package/core/dist/runtime/store/commit/index.d.ts.map +1 -1
  388. package/core/dist/runtime/store/commit/index.js.map +1 -1
  389. package/core/dist/runtime/store/design-gate/sqlite-design-gate-store.d.ts +4 -3
  390. package/core/dist/runtime/store/design-gate/sqlite-design-gate-store.d.ts.map +1 -1
  391. package/core/dist/runtime/store/lifecycle/lease-manager.d.ts +2 -1
  392. package/core/dist/runtime/store/lifecycle/lease-manager.d.ts.map +1 -1
  393. package/core/dist/runtime/store/runtime-state-manager.d.ts +1 -2
  394. package/core/dist/runtime/store/runtime-state-manager.d.ts.map +1 -1
  395. package/core/dist/runtime/store/runtime-state-manager.js.map +1 -1
  396. package/core/dist/runtime/store/sqlite-connection.d.ts +2 -6
  397. package/core/dist/runtime/store/sqlite-connection.d.ts.map +1 -1
  398. package/core/dist/runtime/store/sqlite-connection.js +4 -12
  399. package/core/dist/runtime/store/sqlite-connection.js.map +1 -1
  400. package/core/dist/runtime/store/storage-paths.d.ts +17 -0
  401. package/core/dist/runtime/store/storage-paths.d.ts.map +1 -0
  402. package/core/dist/runtime/store/storage-paths.js +52 -0
  403. package/core/dist/runtime/store/storage-paths.js.map +1 -0
  404. package/core/dist/runtime/store/task/sqlite-family-reopen.d.ts +2 -1
  405. package/core/dist/runtime/store/task/sqlite-family-reopen.d.ts.map +1 -1
  406. package/core/dist/runtime/store/task/sqlite-task-store.d.ts +2 -1
  407. package/core/dist/runtime/store/task/sqlite-task-store.d.ts.map +1 -1
  408. package/core/dist/runtime/story-a-demo.d.ts.map +1 -1
  409. package/core/dist/runtime/story-a-demo.js +4 -1
  410. package/core/dist/runtime/story-a-demo.js.map +1 -1
  411. package/core/dist/runtime/tools/agent-tool-contract.d.ts +1 -2
  412. package/core/dist/runtime/tools/agent-tool-contract.d.ts.map +1 -1
  413. package/core/dist/runtime/tools/agent-tool-contract.js +0 -2
  414. package/core/dist/runtime/tools/agent-tool-contract.js.map +1 -1
  415. package/core/dist/runtime/tools/artificer-l2-tool-contract.d.ts +0 -2
  416. package/core/dist/runtime/tools/artificer-l2-tool-contract.d.ts.map +1 -1
  417. package/core/dist/runtime/tools/artificer-l2-tool-contract.js +0 -2
  418. package/core/dist/runtime/tools/artificer-l2-tool-contract.js.map +1 -1
  419. package/core/dist/runtime/trajectory-retention.d.ts +257 -0
  420. package/core/dist/runtime/trajectory-retention.d.ts.map +1 -0
  421. package/core/dist/runtime/trajectory-retention.js +598 -0
  422. package/core/dist/runtime/trajectory-retention.js.map +1 -0
  423. package/core/dist/runtime/types/event-payload.d.ts +0 -2
  424. package/core/dist/runtime/types/event-payload.d.ts.map +1 -1
  425. package/core/dist/runtime/types/event-payload.js.map +1 -1
  426. package/core/dist/runtime/types/evidence-chain-contract.d.ts +66 -2
  427. package/core/dist/runtime/types/evidence-chain-contract.d.ts.map +1 -1
  428. package/core/dist/runtime/types/evidence-chain-contract.js +69 -4
  429. package/core/dist/runtime/types/evidence-chain-contract.js.map +1 -1
  430. package/core/dist/runtime/types/hygiene-types.d.ts +0 -6
  431. package/core/dist/runtime/types/hygiene-types.d.ts.map +1 -1
  432. package/core/dist/runtime/types/hygiene-types.js.map +1 -1
  433. package/core/dist/runtime/types/index.d.ts +1 -1
  434. package/core/dist/runtime/types/index.d.ts.map +1 -1
  435. package/core/dist/runtime/types/index.js.map +1 -1
  436. package/core/dist/runtime/types/intervention-evidence-contract.d.ts +5 -5
  437. package/core/dist/runtime/types/intervention-evidence-contract.d.ts.map +1 -1
  438. package/core/dist/runtime/types/intervention-evidence-contract.js +0 -2
  439. package/core/dist/runtime/types/intervention-evidence-contract.js.map +1 -1
  440. package/core/dist/runtime/types/principle-dependency.d.ts +0 -2
  441. package/core/dist/runtime/types/principle-dependency.d.ts.map +1 -1
  442. package/core/dist/runtime/types/principle-dependency.js.map +1 -1
  443. package/core/dist/runtime/types/principle-lifecycle-event.d.ts +0 -2
  444. package/core/dist/runtime/types/principle-lifecycle-event.d.ts.map +1 -1
  445. package/core/dist/runtime/types/principle-lifecycle-event.js.map +1 -1
  446. package/core/dist/runtime/types/principle-schema.d.ts +0 -26
  447. package/core/dist/runtime/types/principle-schema.d.ts.map +1 -1
  448. package/core/dist/runtime/types/principle-schema.js +2 -2
  449. package/core/dist/runtime/types/principle-schema.js.map +1 -1
  450. package/core/dist/runtime/types/principle-tree-store.d.ts +0 -2
  451. package/core/dist/runtime/types/principle-tree-store.d.ts.map +1 -1
  452. package/core/dist/runtime/types/principle-tree-store.js.map +1 -1
  453. package/core/dist/runtime/types/principle-value-metrics.d.ts +0 -2
  454. package/core/dist/runtime/types/principle-value-metrics.d.ts.map +1 -1
  455. package/core/dist/runtime/types/principle-value-metrics.js.map +1 -1
  456. package/core/dist/runtime/types/rule-candidate-binding.d.ts +2 -1
  457. package/core/dist/runtime/types/rule-candidate-binding.d.ts.map +1 -1
  458. package/core/dist/telemetry-event.d.ts +2 -2
  459. package/core/dist/telemetry-event.d.ts.map +1 -1
  460. package/core/dist/telemetry-event.js +11 -0
  461. package/core/dist/telemetry-event.js.map +1 -1
  462. package/core/dist/trajectory-store.d.ts +9 -9
  463. package/core/dist/trajectory-store.d.ts.map +1 -1
  464. package/core/dist/trajectory-store.js +9 -12
  465. package/core/dist/trajectory-store.js.map +1 -1
  466. package/core/package.json +5 -1
  467. package/dist/installers/codex-host-installer.d.ts +9 -0
  468. package/dist/installers/codex-host-installer.d.ts.map +1 -1
  469. package/dist/installers/codex-host-installer.js +127 -6
  470. package/dist/installers/codex-host-installer.js.map +1 -1
  471. package/dist/installers/mcp-binding-shape-mirror.d.ts +27 -0
  472. package/dist/installers/mcp-binding-shape-mirror.d.ts.map +1 -0
  473. package/dist/installers/mcp-binding-shape-mirror.js +105 -0
  474. package/dist/installers/mcp-binding-shape-mirror.js.map +1 -0
  475. package/dist/skill-catalog.d.ts +35 -0
  476. package/dist/skill-catalog.d.ts.map +1 -0
  477. package/dist/skill-catalog.js +85 -0
  478. package/dist/skill-catalog.js.map +1 -0
  479. package/dist/skill-delivery-parity.d.ts +22 -0
  480. package/dist/skill-delivery-parity.d.ts.map +1 -0
  481. package/dist/skill-delivery-parity.js +31 -0
  482. package/dist/skill-delivery-parity.js.map +1 -0
  483. package/dist/update/product-identity.d.ts.map +1 -1
  484. package/dist/update/product-identity.js +5 -1
  485. package/dist/update/product-identity.js.map +1 -1
  486. package/host-runtime/dist/active-principle-prompt.d.ts +13 -0
  487. package/host-runtime/dist/active-principle-prompt.js +87 -10
  488. package/host-runtime/dist/adaptive-decision-protocol.d.ts +129 -0
  489. package/host-runtime/dist/adaptive-decision-protocol.js +176 -0
  490. package/host-runtime/dist/adaptive-priority-provider.d.ts +38 -13
  491. package/host-runtime/dist/adaptive-priority-provider.js +70 -66
  492. package/host-runtime/dist/adaptive-selection.d.ts +71 -64
  493. package/host-runtime/dist/adaptive-selection.js +220 -329
  494. package/host-runtime/dist/adaptive-skip-decision.d.ts +26 -14
  495. package/host-runtime/dist/adaptive-skip-decision.js +33 -29
  496. package/host-runtime/dist/codex-disclosure.d.ts +12 -7
  497. package/host-runtime/dist/codex-disclosure.js +12 -7
  498. package/host-runtime/dist/codex-rule-context-provider.js +4 -1
  499. package/host-runtime/dist/conversation-ingestion/pipeline.d.ts +8 -0
  500. package/host-runtime/dist/conversation-ingestion/pipeline.js +6 -1
  501. package/host-runtime/dist/conversation-ingestion/text-policy.d.ts +3 -4
  502. package/host-runtime/dist/conversation-ingestion/text-policy.js +3 -4
  503. package/host-runtime/dist/governance-observation-store.d.ts +73 -1
  504. package/host-runtime/dist/governance-observation-store.js +251 -14
  505. package/host-runtime/dist/governance-signal-admission.d.ts +19 -3
  506. package/host-runtime/dist/governance-signal-admission.js +12 -4
  507. package/host-runtime/dist/host-tool-declaration.d.ts +18 -2
  508. package/host-runtime/dist/host-tool-declaration.js +67 -11
  509. package/host-runtime/dist/host-tool-semantic-resolver.d.ts +7 -0
  510. package/host-runtime/dist/host-tool-semantic-resolver.js +22 -2
  511. package/host-runtime/dist/index.d.ts +3 -0
  512. package/host-runtime/dist/index.js +17 -0
  513. package/host-runtime/dist/production-rulehost-gate.d.ts +36 -1
  514. package/host-runtime/dist/production-rulehost-gate.js +106 -4
  515. package/host-runtime/dist/trajectory-retention.d.ts +147 -0
  516. package/host-runtime/dist/trajectory-retention.js +907 -0
  517. package/host-runtime/package.json +1 -1
  518. package/install-layout/dist/index.d.ts +9 -2
  519. package/install-layout/dist/index.js +26 -9
  520. package/install-layout/dist/mcp-binding-contract.d.ts +91 -0
  521. package/install-layout/dist/mcp-binding-contract.js +230 -0
  522. package/install-layout/package.json +1 -1
  523. package/package.json +4 -4
  524. package/pd-cli/dist/commands/build-trajectory-evidence.d.ts.map +1 -1
  525. package/pd-cli/dist/commands/build-trajectory-evidence.js +17 -11
  526. package/pd-cli/dist/commands/build-trajectory-evidence.js.map +1 -1
  527. package/pd-cli/dist/commands/codex-reconcile.d.ts +7 -0
  528. package/pd-cli/dist/commands/codex-reconcile.d.ts.map +1 -1
  529. package/pd-cli/dist/commands/codex-reconcile.js +11 -2
  530. package/pd-cli/dist/commands/codex-reconcile.js.map +1 -1
  531. package/pd-cli/dist/commands/codex-worker.d.ts.map +1 -1
  532. package/pd-cli/dist/commands/codex-worker.js +35 -0
  533. package/pd-cli/dist/commands/codex-worker.js.map +1 -1
  534. package/pd-cli/dist/commands/command-helpers.d.ts +1 -1
  535. package/pd-cli/dist/commands/command-helpers.js +1 -1
  536. package/pd-cli/dist/commands/diagnose.js +1 -1
  537. package/pd-cli/dist/commands/diagnose.js.map +1 -1
  538. package/pd-cli/dist/commands/errors-list.d.ts +1 -1
  539. package/pd-cli/dist/commands/errors-list.js +1 -1
  540. package/pd-cli/dist/commands/health-ingestion.d.ts +96 -0
  541. package/pd-cli/dist/commands/health-ingestion.d.ts.map +1 -0
  542. package/pd-cli/dist/commands/health-ingestion.js +473 -0
  543. package/pd-cli/dist/commands/health-ingestion.js.map +1 -0
  544. package/pd-cli/dist/commands/health-mcp.d.ts +23 -1
  545. package/pd-cli/dist/commands/health-mcp.d.ts.map +1 -1
  546. package/pd-cli/dist/commands/health-mcp.js +81 -22
  547. package/pd-cli/dist/commands/health-mcp.js.map +1 -1
  548. package/pd-cli/dist/commands/health.d.ts +1 -1
  549. package/pd-cli/dist/commands/health.d.ts.map +1 -1
  550. package/pd-cli/dist/commands/health.js +22 -5
  551. package/pd-cli/dist/commands/health.js.map +1 -1
  552. package/pd-cli/dist/commands/principles-stats.d.ts +1 -1
  553. package/pd-cli/dist/commands/principles-stats.js +1 -1
  554. package/pd-cli/dist/commands/trajectory-retention.d.ts +23 -0
  555. package/pd-cli/dist/commands/trajectory-retention.d.ts.map +1 -0
  556. package/pd-cli/dist/commands/trajectory-retention.js +159 -0
  557. package/pd-cli/dist/commands/trajectory-retention.js.map +1 -0
  558. package/pd-cli/dist/commands/workbuddy-setup.d.ts +69 -0
  559. package/pd-cli/dist/commands/workbuddy-setup.d.ts.map +1 -0
  560. package/pd-cli/dist/commands/workbuddy-setup.js +379 -0
  561. package/pd-cli/dist/commands/workbuddy-setup.js.map +1 -0
  562. package/pd-cli/dist/commands/workbuddy-worker.d.ts.map +1 -1
  563. package/pd-cli/dist/commands/workbuddy-worker.js +42 -6
  564. package/pd-cli/dist/commands/workbuddy-worker.js.map +1 -1
  565. package/pd-cli/dist/index.d.ts +1 -7
  566. package/pd-cli/dist/index.d.ts.map +1 -1
  567. package/pd-cli/dist/index.js +15 -1201
  568. package/pd-cli/dist/index.js.map +1 -1
  569. package/pd-cli/dist/program.d.ts +17 -0
  570. package/pd-cli/dist/program.d.ts.map +1 -0
  571. package/pd-cli/dist/program.js +1263 -0
  572. package/pd-cli/dist/program.js.map +1 -0
  573. package/pd-cli/dist/services/delivery-surfaces.d.ts.map +1 -1
  574. package/pd-cli/dist/services/delivery-surfaces.js +7 -5
  575. package/pd-cli/dist/services/delivery-surfaces.js.map +1 -1
  576. package/pd-cli/dist/services/demo-story-a-runner.js +1 -1
  577. package/pd-cli/dist/services/demo-story-a-runner.js.map +1 -1
  578. package/pd-cli/dist/services/version-report.d.ts.map +1 -1
  579. package/pd-cli/dist/services/version-report.js +35 -5
  580. package/pd-cli/dist/services/version-report.js.map +1 -1
  581. package/pd-cli/package.json +1 -1
  582. package/pd-mcp-server/dist/version.d.ts +1 -1
  583. package/pd-mcp-server/dist/version.js +1 -1
  584. package/pd-mcp-server/package.json +3 -1
  585. package/plugin/dist/bundle.js +529 -468
  586. package/plugin/dist/constants/tools.d.ts +8 -1
  587. package/plugin/dist/core/experiment-workspace-guard.d.ts +25 -0
  588. package/plugin/dist/core/trajectory-retention-trigger.d.ts +13 -0
  589. package/plugin/dist/core/trajectory.d.ts +14 -0
  590. package/plugin/dist/hooks/gate-block-helper.d.ts +17 -0
  591. package/plugin/dist/hooks/gate.d.ts +6 -1
  592. package/plugin/dist/host-runtime/openclaw-host-runtime.d.ts +1 -0
  593. package/plugin/dist/index.d.ts +5 -0
  594. package/plugin/dist/openclaw.plugin.json +1 -1
  595. package/plugin/dist/rulehost-evidence.js +29 -23
  596. package/plugin/dist/templates/langs/en/skills/pd-cli-operator/SKILL.md +16 -5
  597. package/plugin/dist/templates/langs/en/skills/pd-control/SKILL.md +7 -6
  598. package/plugin/dist/templates/langs/en/skills/pd-pain-signal/SKILL.md +141 -28
  599. package/plugin/dist/templates/langs/en/skills/pd-review/SKILL.md +15 -1
  600. package/plugin/dist/templates/langs/zh/skills/pd-cli-operator/SKILL.md +16 -5
  601. package/plugin/dist/templates/langs/zh/skills/pd-control/SKILL.md +7 -6
  602. package/plugin/dist/templates/langs/zh/skills/pd-pain-signal/SKILL.md +142 -29
  603. package/plugin/dist/templates/langs/zh/skills/pd-review/SKILL.md +15 -1
  604. package/plugin/openclaw.plugin.json +1 -1
  605. package/plugin/package.json +1 -1
  606. package/plugin/templates/langs/en/skills/pd-cli-operator/SKILL.md +16 -5
  607. package/plugin/templates/langs/en/skills/pd-control/SKILL.md +7 -6
  608. package/plugin/templates/langs/en/skills/pd-pain-signal/SKILL.md +141 -28
  609. package/plugin/templates/langs/en/skills/pd-review/SKILL.md +15 -1
  610. package/plugin/templates/langs/zh/skills/pd-cli-operator/SKILL.md +16 -5
  611. package/plugin/templates/langs/zh/skills/pd-control/SKILL.md +7 -6
  612. package/plugin/templates/langs/zh/skills/pd-pain-signal/SKILL.md +142 -29
  613. package/plugin/templates/langs/zh/skills/pd-review/SKILL.md +15 -1
  614. package/release-manager/dist/installers/codex-host-installer.js +127 -6
  615. package/release-manager/dist/installers/mcp-binding-shape-mirror.js +105 -0
  616. package/release-manager/dist/update/product-identity.js +5 -1
  617. package/release-manager/package.json +1 -1
  618. package/workbuddy-adapter/dist/codec/input-decoder.d.ts +10 -0
  619. package/workbuddy-adapter/dist/codec/input-decoder.js +62 -5
  620. package/workbuddy-adapter/dist/host-adapter.js +1 -0
  621. package/workbuddy-adapter/dist/index.d.ts +1 -0
  622. package/workbuddy-adapter/dist/index.js +1 -0
  623. package/workbuddy-adapter/dist/ingestion/catch-up.d.ts +36 -0
  624. package/workbuddy-adapter/dist/ingestion/catch-up.js +166 -0
  625. package/workbuddy-adapter/dist/ingestion/encode-cwd.d.ts +6 -0
  626. package/workbuddy-adapter/dist/ingestion/encode-cwd.js +39 -0
  627. package/workbuddy-adapter/dist/ingestion/index.d.ts +13 -0
  628. package/workbuddy-adapter/dist/ingestion/index.js +13 -0
  629. package/workbuddy-adapter/dist/ingestion/ingestion.d.ts +46 -0
  630. package/workbuddy-adapter/dist/ingestion/ingestion.js +135 -0
  631. package/workbuddy-adapter/dist/ingestion/transcript-decoder.d.ts +70 -0
  632. package/workbuddy-adapter/dist/ingestion/transcript-decoder.js +554 -0
  633. package/workbuddy-adapter/dist/ingestion/transcript-path.d.ts +39 -0
  634. package/workbuddy-adapter/dist/ingestion/transcript-path.js +117 -0
  635. package/workbuddy-adapter/dist/ingestion/transcript-source.d.ts +15 -0
  636. package/workbuddy-adapter/dist/ingestion/transcript-source.js +152 -0
  637. package/workbuddy-adapter/dist/pd-hook.d.ts +8 -0
  638. package/workbuddy-adapter/dist/pd-hook.js +59 -2
  639. package/workbuddy-adapter/dist/worker/workspace-worker.d.ts +9 -0
  640. package/workbuddy-adapter/dist/worker/workspace-worker.js +46 -17
  641. package/workbuddy-adapter/package.json +1 -1
  642. package/workbuddy-adapter/plugin/hooks/hooks.json +11 -0
  643. package/workbuddy-adapter/plugin/skills/pd-cli-operator/SKILL.md +57 -19
  644. package/workbuddy-adapter/plugin/skills/pd-control/SKILL.md +21 -9
  645. package/workbuddy-adapter/plugin/skills/pd-pain-signal/SKILL.md +72 -61
  646. package/workbuddy-adapter/plugin/skills/pd-review/SKILL.md +27 -12
@@ -77,6 +77,38 @@ function safeJson(value) {
77
77
  return null;
78
78
  }
79
79
  }
80
+ /**
81
+ * Merge a LATER window's tool facts onto an already-committed PARTIAL tool_call
82
+ * row. A host may split one execution across windows (WorkBuddy keys call and
83
+ * result by callId, each decode window is byte-bounded), so the result arrives
84
+ * as a second observation with the same logical key. `fill` alone would drop
85
+ * the result preview because the call's facts column is already non-null.
86
+ * Only two well-formed `facts` envelopes are merged; anything else returns
87
+ * null so the caller can keep the existing `fill` behaviour.
88
+ */
89
+ function mergeToolFactsJson(existingJson, incomingJson) {
90
+ if (typeof existingJson !== 'string' || incomingJson === null)
91
+ return null;
92
+ try {
93
+ const existing = JSON.parse(existingJson);
94
+ const incoming = JSON.parse(incomingJson);
95
+ if (!isRecord(existing) || !isRecord(incoming))
96
+ return null;
97
+ const existingFacts = existing.facts;
98
+ const incomingFacts = incoming.facts;
99
+ if (!isRecord(existingFacts) || !isRecord(incomingFacts))
100
+ return null;
101
+ const merged = { ...existingFacts };
102
+ for (const [key, value] of Object.entries(incomingFacts)) {
103
+ if (value !== null && value !== undefined)
104
+ merged[key] = value;
105
+ }
106
+ return safeJson({ facts: merged });
107
+ }
108
+ catch {
109
+ return null;
110
+ }
111
+ }
80
112
  const CREATE_STATEMENTS = [
81
113
  `CREATE TABLE IF NOT EXISTS governance_observation_schema_version (version INTEGER NOT NULL)`,
82
114
  `CREATE TABLE IF NOT EXISTS governance_rollouts (
@@ -201,20 +233,50 @@ function ensureGovernanceObservationSchema(db) {
201
233
  export function ensureGovernanceSchema(db) {
202
234
  ensureGovernanceObservationSchema(db);
203
235
  }
236
+ /**
237
+ * Open the workspace trajectory database for governance observations.
238
+ *
239
+ * Returns a {@link Degradation} when the database file is absent or cannot be
240
+ * opened. Non-fatal degradations (journal_mode switch losing a race) are
241
+ * reported through `warnings` instead of failing the write (rc-9).
242
+ */
204
243
  function openStore(workspaceDir, factory) {
205
244
  const dbPath = path.join(workspaceDir, '.state', 'trajectory.db');
206
245
  if (!fs.existsSync(dbPath)) {
207
246
  return { ok: false, reason: 'trajectory_db_not_found', nextAction: 'initialize the selected PD workspace (pd runtime init) before enabling conversation ingestion' };
208
247
  }
248
+ const warnings = [];
209
249
  try {
210
250
  const db = factory ? factory(dbPath) : new Database(dbPath);
211
251
  db.pragma('busy_timeout = 5000');
212
- db.pragma('journal_mode = WAL');
213
- ensureGovernanceObservationSchema(db);
214
- return { db, close: () => { try {
215
- db.close();
252
+ // Switching journal_mode takes an exclusive lock, and SQLITE_BUSY on this
253
+ // pragma is NOT covered by busy_timeout. Two hooks that start at the same
254
+ // moment can collide here; neither the mode nor the data is corrupted, and
255
+ // whoever wins performs the switch. Read the mode first (lock-free) and
256
+ // never fail ingestion just because this optimization lost the race.
257
+ //
258
+ // Deliberate choice: NO retry. The losing opener keeps the previous
259
+ // rollback-journal mode for THIS connection only. WAL is a concurrency
260
+ // optimization, not a correctness requirement — writes already run under
261
+ // BEGIN IMMEDIATE with busy_timeout, so isolation and durability are
262
+ // unchanged; the winner's switch is persisted for every later open. The
263
+ // fallback is reported (rc-9: never silent) through `warnings`.
264
+ try {
265
+ const journalMode = db.pragma('journal_mode', { simple: true });
266
+ if (typeof journalMode !== 'string' || journalMode.toLowerCase() !== 'wal') {
267
+ db.pragma('journal_mode = WAL');
216
268
  }
217
- catch { /* write result already determined */ } } };
269
+ }
270
+ catch {
271
+ warnings.push('journal_mode_switch_deferred');
272
+ }
273
+ ensureGovernanceObservationSchema(db);
274
+ /** Close the connection; a close failure must not mask the already-determined write result. */
275
+ const close = () => { try {
276
+ db.close();
277
+ }
278
+ catch { /* write result already determined */ } };
279
+ return { db, close, warnings };
218
280
  }
219
281
  catch (error) {
220
282
  const detail = error instanceof Error ? error.message.slice(0, 200) : String(error).slice(0, 200);
@@ -236,8 +298,39 @@ function upsertRollout(db, input, now) {
236
298
  .run(input.hostKind, input.rolloutIdentity, input.rootSessionId, input.parentRolloutIdentity ?? null, boundedString(input.agentIdentity, MAX_TEXT_BOUND), input.agentDepth ?? null, now, now);
237
299
  return Number(result.lastInsertRowid);
238
300
  }
239
- function applyObservation({ db, rolloutRowId, input, workspaceDir }) {
240
- const existing = db.prepare('SELECT * FROM governance_observations WHERE logical_key = ?').get(input.logicalObservationKey);
301
+ /**
302
+ * Apply one observation against its logical key and report what happened.
303
+ *
304
+ * - `inserted`: new key (a duplicate physical record is reported separately);
305
+ * - `enriched`: the existing row gained identity/ordering/completion facts;
306
+ * - `duplicate`: replay produced nothing new;
307
+ * - `conflict`: a user utterance disagrees for the same key — keep the first
308
+ * committed content, mark partial, and report where the checkpoint must stop.
309
+ * Never overwrites committed content silently (source precedence, SPEC §10).
310
+ */
311
+ function applyObservation({ db, rolloutRowId, input, workspaceDir, maxVisibleTextChars }) {
312
+ // One bound for every visible_text use in this function: the insert, the
313
+ // user-turn conflict comparison and the fill path must agree, otherwise a
314
+ // full-tier row would look like a content mismatch on the next replay.
315
+ const boundVisibleText = (value) => sanitizeString(value, workspaceDir, maxVisibleTextChars);
316
+ const byKey = db.prepare('SELECT * FROM governance_observations WHERE logical_key = ?').get(input.logicalObservationKey);
317
+ let existing = byKey;
318
+ // Cross-window tool completion by STABLE identity (P2 review): the call row
319
+ // is keyed by its transcript record, so a later window's result cannot derive
320
+ // the same logical key. Reconnect it to the single still-partial call row
321
+ // that carries the same `tool_use_id`. `LIMIT 2` makes ambiguity explicit:
322
+ // duplicate callIds across windows yield two candidates and are NOT merged.
323
+ if (!isRecord(byKey)
324
+ && input.kind === 'tool_call'
325
+ && input.completeness === 'complete'
326
+ && typeof input.toolUseId === 'string'
327
+ && input.toolUseId.length > 0) {
328
+ const partials = db.prepare(`SELECT * FROM governance_observations
329
+ WHERE rollout_row_id = ? AND kind = 'tool_call' AND completeness = 'partial' AND tool_use_id = ?
330
+ LIMIT 2`).all(rolloutRowId, input.toolUseId);
331
+ if (partials.length === 1)
332
+ [existing] = partials;
333
+ }
241
334
  if (!isRecord(existing)) {
242
335
  // Physical replay guard: the same transcript record decoded twice (crash
243
336
  // before checkpoint, or a re-invoked hook) must not contribute twice.
@@ -246,7 +339,7 @@ function applyObservation({ db, rolloutRowId, input, workspaceDir }) {
246
339
  if (isRecord(physical))
247
340
  return { disposition: 'duplicate' };
248
341
  }
249
- const sanitizedText = input.visibleText !== undefined ? sanitizeString(input.visibleText, workspaceDir) : null;
342
+ const sanitizedText = input.visibleText !== undefined ? boundVisibleText(input.visibleText) : null;
250
343
  const facts = input.toolFacts !== undefined ? safeJson({ facts: sanitizeValue(input.toolFacts, 0, workspaceDir) }) : null;
251
344
  db.prepare(`INSERT INTO governance_observations
252
345
  (rollout_row_id, host_kind, rollout_identity, root_session_id, host_turn_id, kind, logical_key, transcript_record_key, source_order, source_ordinal, assistant_item_id, phase, tool_use_id, transcript_tool_call_id, visible_text, sanitized_tool_facts_json, source, completeness, retention_class, observed_at)
@@ -266,12 +359,29 @@ function applyObservation({ db, rolloutRowId, input, workspaceDir }) {
266
359
  && input.source === 'transcript'
267
360
  && input.visibleText !== undefined
268
361
  && typeof existingText === 'string'
269
- && sanitizeString(input.visibleText, workspaceDir) !== existingText) {
362
+ && boundVisibleText(input.visibleText) !== existingText) {
363
+ db.prepare("UPDATE governance_observations SET completeness = 'partial' WHERE id = ?").run(existingId);
364
+ return { disposition: 'conflict', stopByteStart: input.recordByteStart };
365
+ }
366
+ // Two DISTINCT executions reusing one callId in DIFFERENT decode windows
367
+ // share the `call:<callId>` logical key. Without this guard the second
368
+ // call's partial observation is silently absorbed into the first (fill and
369
+ // fact-merge never overwrite committed fields), so an execution disappears.
370
+ // A different transcript record is a lineage conflict: keep the first, mark
371
+ // it partial, and stop at the offending record (P2 review).
372
+ const existingRecordKey = rowField(existing, 'transcript_record_key');
373
+ if (input.kind === 'tool_call'
374
+ && input.completeness === 'partial'
375
+ && typeof existingRecordKey === 'string'
376
+ && existingRecordKey.length > 0
377
+ && input.transcriptRecordKey !== undefined
378
+ && existingRecordKey !== input.transcriptRecordKey) {
270
379
  db.prepare("UPDATE governance_observations SET completeness = 'partial' WHERE id = ?").run(existingId);
271
380
  return { disposition: 'conflict', stopByteStart: input.recordByteStart };
272
381
  }
273
382
  const updates = [];
274
383
  const values = [];
384
+ /** Queue a column only when the stored value is still absent (never overwrite committed content). */
275
385
  const fill = (column, value) => {
276
386
  const current = rowField(existing, column);
277
387
  if ((current === null || current === undefined) && value !== null && value !== undefined) {
@@ -289,8 +399,34 @@ function applyObservation({ db, rolloutRowId, input, workspaceDir }) {
289
399
  fill('phase', boundedString(input.phase, MAX_TEXT_BOUND));
290
400
  fill('tool_use_id', boundedString(input.toolUseId, MAX_TEXT_BOUND));
291
401
  fill('transcript_tool_call_id', boundedString(input.transcriptToolCallId, MAX_TEXT_BOUND));
292
- fill('visible_text', input.visibleText !== undefined ? sanitizeString(input.visibleText, workspaceDir) : null);
293
- fill('sanitized_tool_facts_json', input.toolFacts !== undefined ? safeJson({ facts: sanitizeValue(input.toolFacts, 0, workspaceDir) }) : null);
402
+ fill('visible_text', input.visibleText !== undefined ? boundVisibleText(input.visibleText) : null);
403
+ const incomingFacts = input.toolFacts !== undefined ? safeJson({ facts: sanitizeValue(input.toolFacts, 0, workspaceDir) }) : null;
404
+ // Cross-window tool completion (P1): the call row is partial and the result
405
+ // arrives under the same logical key from a later decode window. Merge the
406
+ // result facts instead of dropping them through `fill`'s null-only rule.
407
+ const crossWindowToolCompletion = input.kind === 'tool_call'
408
+ && input.completeness === 'complete'
409
+ && rowField(existing, 'completeness') === 'partial';
410
+ if (crossWindowToolCompletion) {
411
+ const existingFactsJson = rowField(existing, 'sanitized_tool_facts_json');
412
+ const mergedFacts = mergeToolFactsJson(existingFactsJson, incomingFacts);
413
+ // Fall back to the incoming facts ONLY when the row has none AND is still
414
+ // active. An existing but unmergeable value is a bounded truncation
415
+ // preview that is still committed evidence; replacing it would destroy
416
+ // what the advanced checkpoint can no longer recover. A terminal retention
417
+ // class (expired / quarantined) must not regain a body either (P2 review).
418
+ const hasExistingFacts = typeof existingFactsJson === 'string' && existingFactsJson.length > 0;
419
+ const retentionClass = rowField(existing, 'retention_class');
420
+ const activeRow = retentionClass === 'operational' || retentionClass === 'promoted';
421
+ const nextFacts = mergedFacts ?? (hasExistingFacts || !activeRow ? null : incomingFacts);
422
+ if (nextFacts !== null && nextFacts !== rowField(existing, 'sanitized_tool_facts_json')) {
423
+ updates.push('sanitized_tool_facts_json = ?');
424
+ values.push(nextFacts);
425
+ }
426
+ }
427
+ else {
428
+ fill('sanitized_tool_facts_json', incomingFacts);
429
+ }
294
430
  const existingCompleteness = rowField(existing, 'completeness');
295
431
  if (existingCompleteness === 'partial' && input.completeness === 'complete') {
296
432
  updates.push('completeness = ?');
@@ -384,19 +520,33 @@ function expireStalePendingTails(db, now) {
384
520
  db.prepare("UPDATE governance_pending_promotion_tails SET state = 'stale', stale_at = ? WHERE state = 'pending' AND created_at < ?")
385
521
  .run(now.toISOString(), new Date(now.getTime() - GOVERNANCE_PENDING_TAIL_STALE_MS).toISOString());
386
522
  }
523
+ /**
524
+ * Persist one decoded delta (observations + rollout lineage + checkpoint) in a
525
+ * single IMMEDIATE transaction.
526
+ *
527
+ * The up-front write lock is required: with a deferred BEGIN two concurrent
528
+ * hooks both read and then race the upgrade, and SQLite fails that upgrade
529
+ * with SQLITE_BUSY. A failure rolls everything back (checkpoint not advanced)
530
+ * and returns a structured reason/nextAction; warnings stay observable.
531
+ */
387
532
  export function ingestGovernanceObservations(input) {
388
533
  const opened = openStore(input.workspaceDir, input.databaseFactory);
389
534
  if (!('db' in opened))
390
535
  return { ok: false, reason: opened.reason, nextAction: opened.nextAction, inserted: 0, enriched: 0, duplicates: 0, checkpointCommitted: false, warnings: [] };
391
536
  const { db, close } = opened;
392
537
  const now = (input.now ?? new Date()).toISOString();
393
- const warnings = [];
538
+ const warnings = [...opened.warnings];
394
539
  try {
395
540
  let inserted = 0;
396
541
  let enriched = 0;
397
542
  let duplicates = 0;
398
543
  let conflictStop;
399
544
  let conflictKey = '';
545
+ // `.immediate()` takes the write lock up front. With the default deferred
546
+ // BEGIN, two concurrent Stop hooks for the same session both read first
547
+ // and then try to upgrade; SQLite fails that upgrade with SQLITE_BUSY
548
+ // immediately (busy_timeout does not cover upgrade deadlocks), which the
549
+ // hook surfaces as `governance_write_failed:database is locked`.
400
550
  const result = db.transaction(() => {
401
551
  let rolloutRowId = null;
402
552
  if (input.rollout !== undefined) {
@@ -404,7 +554,13 @@ export function ingestGovernanceObservations(input) {
404
554
  }
405
555
  for (const observation of input.observations) {
406
556
  rolloutRowId = upsertRollout(db, observation, now);
407
- const outcome = applyObservation({ db, rolloutRowId, input: observation, workspaceDir: input.workspaceDir });
557
+ const outcome = applyObservation({
558
+ db,
559
+ rolloutRowId,
560
+ input: observation,
561
+ workspaceDir: input.workspaceDir,
562
+ ...(input.maxVisibleTextChars !== undefined ? { maxVisibleTextChars: input.maxVisibleTextChars } : {}),
563
+ });
408
564
  if (outcome.disposition === 'inserted')
409
565
  inserted += 1;
410
566
  else if (outcome.disposition === 'enriched')
@@ -482,7 +638,7 @@ export function ingestGovernanceObservations(input) {
482
638
  expireStalePendingTails(db, new Date(now));
483
639
  pruneRetention(db, rolloutRowId, new Date(now));
484
640
  return 'committed';
485
- })();
641
+ }).immediate();
486
642
  if (result === 'conflict') {
487
643
  return {
488
644
  ok: false, reason: 'logical_key_content_conflict', nextAction: 'the first committed content was preserved and the observation is marked partial; run `pd codex ingest quarantine --workspace <path> --rollout <id> --record <id>` (audited, dry-run default) or re-ingest from a fresh rollout',
@@ -526,6 +682,39 @@ export function readGovernanceCheckpoint(args) {
526
682
  close();
527
683
  }
528
684
  }
685
+ /**
686
+ * Move a checkpoint to the BACK of the oldest-first retry queue without
687
+ * touching its water mark (P2 review).
688
+ *
689
+ * `listGovernanceCheckpoints` returns the oldest-updated rows first and the
690
+ * catch-up worker processes a bounded prefix. A rollout whose transcript is
691
+ * missing/unreadable never advances its checkpoint, so it would occupy the
692
+ * prefix forever and starve every rollout behind it. Bumping ONLY
693
+ * `updated_at` + the degradation reason lets the failed session yield its slot
694
+ * on the next cycle while keeping its byte offset, ordinal and retryability
695
+ * exactly as they were.
696
+ */
697
+ export function deferGovernanceCheckpoint(args) {
698
+ const { workspaceDir, hostKind, rolloutIdentity, reason, now, databaseFactory } = args;
699
+ const opened = openStore(workspaceDir, databaseFactory);
700
+ if (!('db' in opened))
701
+ return opened;
702
+ const { db, close } = opened;
703
+ try {
704
+ db.prepare(`UPDATE governance_transcript_checkpoints
705
+ SET updated_at = ?, last_degradation_reason = ?
706
+ WHERE host_kind = ? AND rollout_identity = ?`)
707
+ .run(now, reason.slice(0, 200), hostKind, rolloutIdentity);
708
+ return { ok: true };
709
+ }
710
+ catch (error) {
711
+ const detail = error instanceof Error ? error.message.slice(0, 200) : String(error).slice(0, 200);
712
+ return { ok: false, reason: `governance_write_failed:${detail}`, nextAction: 'inspect the workspace trajectory database and retry; nothing was partially committed' };
713
+ }
714
+ finally {
715
+ close();
716
+ }
717
+ }
529
718
  /**
530
719
  * List every checkpoint for a host kind, oldest-updated first (PRI-624).
531
720
  * The Slice C worker/CLI catch-up uses this to find rollouts with pending
@@ -564,6 +753,54 @@ export function listGovernanceCheckpoints(args) {
564
753
  close();
565
754
  }
566
755
  }
756
+ /**
757
+ * Sessions that have observations but NO checkpoint row for this host kind
758
+ * (PRI-1171 ticket ⑦, TD §9). The live hook path never writes a checkpoint,
759
+ * so "no checkpoint" must never render as a lag anomaly: the health surface
760
+ * reports these as an explicit `live_only` state stamped with
761
+ * MAX(observed_at) instead of inventing a byte offset. Ordered by
762
+ * lastObservedAt descending; result bounded by `limit` with a `truncated`
763
+ * flag so large live-only sets stay visible without unbounded output.
764
+ */
765
+ export function listGovernanceUncheckpointedSessions(args) {
766
+ const { workspaceDir, hostKind, databaseFactory } = args;
767
+ const opened = openStore(workspaceDir, databaseFactory);
768
+ if (!('db' in opened))
769
+ return opened;
770
+ const { db, close } = opened;
771
+ try {
772
+ const limit = Math.min(Math.max(args.limit ?? 50, 1), 200);
773
+ const rows = db.prepare(`SELECT o.rollout_identity AS rollout_identity,
774
+ MAX(o.observed_at) AS last_observed_at,
775
+ COUNT(*) AS observation_count
776
+ FROM governance_observations o
777
+ WHERE o.host_kind = ?
778
+ AND o.rollout_identity NOT IN (
779
+ SELECT c.rollout_identity FROM governance_transcript_checkpoints c WHERE c.host_kind = ?
780
+ )
781
+ GROUP BY o.rollout_identity
782
+ ORDER BY last_observed_at DESC
783
+ LIMIT ?`).all(hostKind, hostKind, limit + 1);
784
+ const sessions = [];
785
+ for (const raw of rows.slice(0, limit)) {
786
+ if (!isRecord(raw))
787
+ continue;
788
+ sessions.push({
789
+ rolloutIdentity: String(rowField(raw, 'rollout_identity')),
790
+ lastObservedAt: String(rowField(raw, 'last_observed_at')),
791
+ observationCount: Number(rowField(raw, 'observation_count')),
792
+ });
793
+ }
794
+ return { ok: true, sessions, truncated: rows.length > limit };
795
+ }
796
+ catch (error) {
797
+ const detail = error instanceof Error ? error.message.slice(0, 160) : String(error);
798
+ return { ok: false, reason: `governance_live_sessions_failed:${detail}`, nextAction: 'Inspect the workspace trajectory.db; the health surface degraded without mutating anything.' };
799
+ }
800
+ finally {
801
+ close();
802
+ }
803
+ }
567
804
  export function listGovernanceObservations(input) {
568
805
  const opened = openStore(input.workspaceDir, input.databaseFactory);
569
806
  if (!('db' in opened))
@@ -340,7 +340,16 @@ export interface EnsureGovernanceContinuationInput {
340
340
  readonly logicalObservationKey: string;
341
341
  readonly canonicalPainId: string;
342
342
  /** Current Owner consent for Codex conversation evidence. Required to prevent reconciliation from promoting old observations after opt-out. */
343
- readonly conversationIngestionEnabled: boolean;
343
+ readonly codexConversationIngestionEnabled: boolean;
344
+ /**
345
+ * Legacy alias from before the host-scoped rename. It means the SAME thing as
346
+ * the field above — Codex conversation-evidence consent only, never consent
347
+ * for WorkBuddy evidence. Kept so an older caller paired with this runtime
348
+ * still promotes, and callers pass both names so an older runtime still sees
349
+ * consent (P2 review). When the new field is present it wins: an explicit
350
+ * `false` must never be overridden by a stale `true` here.
351
+ */
352
+ readonly conversationIngestionEnabled?: boolean;
344
353
  readonly databaseFactory?: ObservationDatabaseFactory;
345
354
  }
346
355
  export type EnsureGovernanceContinuationResult = {
@@ -369,8 +378,15 @@ export type EnsureGovernanceContinuationResult = {
369
378
  export declare function ensureGovernanceContinuation(input: EnsureGovernanceContinuationInput): Promise<EnsureGovernanceContinuationResult>;
370
379
  export interface ReconcileGovernanceContinuationInput {
371
380
  readonly workspaceDir: string;
372
- /** Current Owner consent; false means reconcile may ensure tasks/links but must not read or promote Codex session evidence. */
373
- readonly conversationIngestionEnabled: boolean;
381
+ /** Current Owner consent for CODEX conversation evidence; false means reconcile may ensure tasks/links but must not read or promote Codex session evidence. A WorkBuddy worker must pass false — its own flag is not consent for Codex evidence. */
382
+ readonly codexConversationIngestionEnabled: boolean;
383
+ /**
384
+ * Legacy alias (pre-rename) for the Codex-only consent above; never consent
385
+ * for WorkBuddy evidence. Kept for cross-version compatibility (P2 review);
386
+ * the new field wins when present, so an explicit `false` cannot be
387
+ * overridden by a stale `true`.
388
+ */
389
+ readonly conversationIngestionEnabled?: boolean;
374
390
  /** Bounded work per pass (default 50 admitted pains). */
375
391
  readonly limit?: number;
376
392
  readonly databaseFactory?: ObservationDatabaseFactory;
@@ -1954,7 +1954,10 @@ export async function ensureGovernanceContinuation(input) {
1954
1954
  // continuation cannot begin diagnosis before the eligible evidence window
1955
1955
  // has been promoted. A promotion failure is retained as a degradation,
1956
1956
  // but never prevents the task from being durably ensured.
1957
- const promoted = input.conversationIngestionEnabled
1957
+ const codexConsent = typeof input.codexConversationIngestionEnabled === 'boolean'
1958
+ ? input.codexConversationIngestionEnabled
1959
+ : input.conversationIngestionEnabled === true;
1960
+ const promoted = codexConsent
1958
1961
  ? promoteAdmittedGovernanceEvidence({
1959
1962
  workspaceDir,
1960
1963
  rolloutIdentity,
@@ -1991,6 +1994,11 @@ export async function ensureGovernanceContinuation(input) {
1991
1994
  */
1992
1995
  export async function reconcileGovernanceContinuation(input) {
1993
1996
  const workspaceDir = path.resolve(input.workspaceDir);
1997
+ // Accept the pre-rename field too: an older caller paired with this runtime
1998
+ // must not silently lose Codex evidence promotion (P2 review).
1999
+ const codexConsent = typeof input.codexConversationIngestionEnabled === 'boolean'
2000
+ ? input.codexConversationIngestionEnabled
2001
+ : input.conversationIngestionEnabled === true;
1994
2002
  const opened = openAdmissionStore(input.workspaceDir, input.databaseFactory);
1995
2003
  if (!('db' in opened)) {
1996
2004
  return { ok: false, reason: opened.reason, nextAction: opened.nextAction, tasksEnsured: 0, linksRepaired: 0, pendingTails: 0, completedTails: 0, staleTails: 0, degradations: [opened.reason] };
@@ -2029,7 +2037,7 @@ export async function reconcileGovernanceContinuation(input) {
2029
2037
  // not retry pending tails, so pending-tail markers do not block later
2030
2038
  // markers. Stale tails are NOT auto-recoverable (substrate refuses to
2031
2039
  // re-arm them): they are counted separately below and reported.
2032
- const promotionRecoveryClause = input.conversationIngestionEnabled
2040
+ const promotionRecoveryClause = codexConsent
2033
2041
  ? `OR (a.host_kind = 'codex'
2034
2042
  AND NOT EXISTS (SELECT 1 FROM governance_observations o
2035
2043
  WHERE o.promotion_ref = a.canonical_pain_id))`
@@ -2064,7 +2072,7 @@ export async function reconcileGovernanceContinuation(input) {
2064
2072
  }
2065
2073
  continue;
2066
2074
  }
2067
- const cont = await ensureGovernanceContinuation({ workspaceDir, logicalObservationKey: key, canonicalPainId: painId, conversationIngestionEnabled: input.conversationIngestionEnabled });
2075
+ const cont = await ensureGovernanceContinuation({ workspaceDir, logicalObservationKey: key, canonicalPainId: painId, codexConversationIngestionEnabled: codexConsent });
2068
2076
  if (cont.ok) {
2069
2077
  // Only count REAL actions: a task actually created, a link actually
2070
2078
  // repaired (task existed but the marker link was missing). Healthy
@@ -2088,7 +2096,7 @@ export async function reconcileGovernanceContinuation(input) {
2088
2096
  }
2089
2097
  }
2090
2098
  // Also report stale tails scoped to governance admissions.
2091
- const stale = input.conversationIngestionEnabled
2099
+ const stale = codexConsent
2092
2100
  ? db.prepare(`SELECT COUNT(*) AS n FROM governance_pending_promotion_tails t
2093
2101
  WHERE t.state = 'stale'
2094
2102
  AND EXISTS (SELECT 1 FROM governance_signal_admissions a WHERE a.canonical_pain_id = t.pain_ref)`).get()
@@ -18,9 +18,20 @@
18
18
  */
19
19
  import { type ToolSemanticMappingV1 } from '@principles/core/runtime';
20
20
  export declare const HOST_TOOL_DECLARATION_DIRNAME = "host-tool-semantics";
21
- export declare const HOST_TOOL_DECLARATION_VERSION: 1;
21
+ /**
22
+ * ADR-0030: version 2 adds `writePayloadFormat` to the mapping contract.
23
+ *
24
+ * The read path is deliberately FORWARD-COMPATIBLE with version 1: an older
25
+ * persisted file must never block host loading. A legacy declaration is read
26
+ * with v1 semantics (`writePayloadFormat` treated as unset) and reported as a
27
+ * structured warning, so the degradation is observable (rc-9). Only a
28
+ * genuinely malformed file still fails loud (rc-3).
29
+ */
30
+ export declare const HOST_TOOL_DECLARATION_VERSION: 2;
31
+ export type HostToolDeclarationVersion = 1 | typeof HOST_TOOL_DECLARATION_VERSION;
22
32
  export interface HostToolDeclaration {
23
- readonly version: 1;
33
+ /** The version literally read from/written to the file. */
34
+ readonly version: HostToolDeclarationVersion;
24
35
  /** Host identity label ('openclaw' | 'codex' | …). */
25
36
  readonly hostKind: string;
26
37
  readonly mappings: readonly ToolSemanticMappingV1[];
@@ -33,6 +44,8 @@ export type HostToolDeclarationSaveResult = {
33
44
  export type HostToolDeclarationLoadResult = {
34
45
  readonly ok: true;
35
46
  readonly declarations: readonly HostToolDeclaration[];
47
+ /** Non-blocking diagnostics (legacy version degraded to defaults). */
48
+ readonly warnings: readonly string[];
36
49
  } | {
37
50
  readonly ok: false;
38
51
  readonly reason: string;
@@ -47,6 +60,9 @@ export type HostToolDeclarationLoadResult = {
47
60
  export declare function saveHostToolDeclaration(workspaceDir: string, declaration: HostToolDeclaration): HostToolDeclarationSaveResult;
48
61
  /**
49
62
  * Load ALL host declarations for the workspace. Typed result —
63
+ * ok:true warnings=[...] : an OLDER (legacy) declaration was read with the
64
+ * current semantics minus the fields that version never had
65
+ * (`writePayloadFormat` treated as unset). Loading is not blocked (rc-9).
50
66
  * ok:false reason=host_tool_declaration_missing : no declarations persisted
51
67
  * ok:false reason=host_tool_declaration_invalid : at least one persisted
52
68
  * file is malformed (named by hostKind — a broken host declaration is a
@@ -20,7 +20,16 @@ import { readFileSync, writeFileSync, mkdirSync, mkdtempSync, renameSync, rmSync
20
20
  import path from 'node:path';
21
21
  import { validateToolSemanticMappings, } from '@principles/core/runtime';
22
22
  export const HOST_TOOL_DECLARATION_DIRNAME = 'host-tool-semantics';
23
- export const HOST_TOOL_DECLARATION_VERSION = 1;
23
+ /**
24
+ * ADR-0030: version 2 adds `writePayloadFormat` to the mapping contract.
25
+ *
26
+ * The read path is deliberately FORWARD-COMPATIBLE with version 1: an older
27
+ * persisted file must never block host loading. A legacy declaration is read
28
+ * with v1 semantics (`writePayloadFormat` treated as unset) and reported as a
29
+ * structured warning, so the degradation is observable (rc-9). Only a
30
+ * genuinely malformed file still fails loud (rc-3).
31
+ */
32
+ export const HOST_TOOL_DECLARATION_VERSION = 2;
24
33
  const MAX_DECLARATION_BYTES = 256 * 1024;
25
34
  /** hostKind doubles as a filename — code-controlled but validated anyway. */
26
35
  const HOST_KIND_PATTERN = /^[a-z][a-z0-9_-]*$/;
@@ -33,6 +42,30 @@ function declarationPath(workspaceDir, hostKind) {
33
42
  function isRecord(value) {
34
43
  return typeof value === 'object' && value !== null && !Array.isArray(value);
35
44
  }
45
+ /**
46
+ * v1 never carried `writePayloadFormat`: applying v1 semantics means reading
47
+ * the mapping exactly as v1 did (rawToolName + canonicalKind only). An
48
+ * unexpected field in a legacy file is ignored, never interpreted — the same
49
+ * bytes read by the old loader would have produced this projection.
50
+ */
51
+ function stripWritePayloadFormat(mappings) {
52
+ if (!Array.isArray(mappings))
53
+ return mappings;
54
+ return mappings.map((entry) => {
55
+ if (!isRecord(entry) || !Object.hasOwn(entry, 'writePayloadFormat'))
56
+ return entry;
57
+ const projected = {};
58
+ for (const [key, value] of Object.entries(entry)) {
59
+ if (key === 'writePayloadFormat')
60
+ continue;
61
+ projected[key] = value;
62
+ }
63
+ return projected;
64
+ });
65
+ }
66
+ function legacyVersionWarning(hostKind, declaredVersion) {
67
+ return `host_tool_declaration_version_legacy (${hostKind}: declared version ${declaredVersion}, supported ${HOST_TOOL_DECLARATION_VERSION}) — writePayloadFormat is treated as unset (default) for this legacy declaration; re-run host '${hostKind}' to refresh .pd/${HOST_TOOL_DECLARATION_DIRNAME}/${hostKind}.json`;
68
+ }
36
69
  function parseDeclaration(hostKind, raw) {
37
70
  if (Buffer.byteLength(raw, 'utf8') > MAX_DECLARATION_BYTES) {
38
71
  return { invalidReason: `declaration exceeds ${MAX_DECLARATION_BYTES} bytes` };
@@ -44,25 +77,43 @@ function parseDeclaration(hostKind, raw) {
44
77
  catch {
45
78
  return { invalidReason: 'not valid JSON' };
46
79
  }
47
- if (!isRecord(parsed) || parsed.version !== HOST_TOOL_DECLARATION_VERSION) {
48
- return { invalidReason: `version must be ${HOST_TOOL_DECLARATION_VERSION}` };
80
+ if (!isRecord(parsed)) {
81
+ return { invalidReason: 'declaration must be a JSON object' };
82
+ }
83
+ const declaredVersion = parsed.version;
84
+ if (typeof declaredVersion !== 'number' || !Number.isInteger(declaredVersion) || declaredVersion < 1) {
85
+ return { invalidReason: `version must be a positive integer, got ${String(declaredVersion)}` };
86
+ }
87
+ // A file from a NEWER runtime carries fields this build cannot interpret —
88
+ // refuse rather than guess (the forward direction is not the compatibility
89
+ // promise; ADR-0030 only blesses reading OLDER declarations).
90
+ if (declaredVersion > HOST_TOOL_DECLARATION_VERSION) {
91
+ return {
92
+ invalidReason: `version ${declaredVersion} is newer than supported version ${HOST_TOOL_DECLARATION_VERSION}`,
93
+ };
49
94
  }
95
+ const legacy = declaredVersion < HOST_TOOL_DECLARATION_VERSION;
50
96
  const { mappings, declaredAt } = parsed;
51
97
  if (typeof declaredAt !== 'string' || declaredAt.trim() === '') {
52
98
  return { invalidReason: 'declaredAt must be a non-empty string' };
53
99
  }
54
- const validation = validateToolSemanticMappings(mappings);
100
+ const effectiveMappings = legacy ? stripWritePayloadFormat(mappings) : mappings;
101
+ const validation = validateToolSemanticMappings(effectiveMappings);
55
102
  if (!validation.valid) {
56
103
  return { invalidReason: `mappings invalid: ${validation.errors.slice(0, 3).join('; ')}` };
57
104
  }
58
- if (!Array.isArray(mappings) || mappings.length === 0) {
105
+ if (!Array.isArray(effectiveMappings) || effectiveMappings.length === 0) {
59
106
  return { invalidReason: 'declaration must contain at least one mapping' };
60
107
  }
108
+ const normalizedVersion = declaredVersion === 1 ? 1 : HOST_TOOL_DECLARATION_VERSION;
61
109
  return {
62
- version: HOST_TOOL_DECLARATION_VERSION,
63
- hostKind,
64
- mappings,
65
- declaredAt,
110
+ declaration: {
111
+ version: normalizedVersion,
112
+ hostKind,
113
+ mappings: effectiveMappings,
114
+ declaredAt,
115
+ },
116
+ warnings: legacy ? [legacyVersionWarning(hostKind, declaredVersion)] : [],
66
117
  };
67
118
  }
68
119
  /**
@@ -105,6 +156,9 @@ export function saveHostToolDeclaration(workspaceDir, declaration) {
105
156
  }
106
157
  /**
107
158
  * Load ALL host declarations for the workspace. Typed result —
159
+ * ok:true warnings=[...] : an OLDER (legacy) declaration was read with the
160
+ * current semantics minus the fields that version never had
161
+ * (`writePayloadFormat` treated as unset). Loading is not blocked (rc-9).
108
162
  * ok:false reason=host_tool_declaration_missing : no declarations persisted
109
163
  * ok:false reason=host_tool_declaration_invalid : at least one persisted
110
164
  * file is malformed (named by hostKind — a broken host declaration is a
@@ -125,6 +179,7 @@ export function loadHostToolDeclarations(workspaceDir) {
125
179
  };
126
180
  }
127
181
  const declarations = [];
182
+ const warnings = [];
128
183
  for (const entry of entries.sort()) {
129
184
  if (!entry.endsWith('.json'))
130
185
  continue;
@@ -148,7 +203,8 @@ export function loadHostToolDeclarations(workspaceDir) {
148
203
  nextAction: `re-run host '${hostKind}' to refresh ${declarationsDir(workspaceDir)}/${entry}`,
149
204
  };
150
205
  }
151
- declarations.push(parsed);
206
+ declarations.push(parsed.declaration);
207
+ warnings.push(...parsed.warnings);
152
208
  }
153
209
  if (declarations.length === 0) {
154
210
  return {
@@ -157,5 +213,5 @@ export function loadHostToolDeclarations(workspaceDir) {
157
213
  nextAction: 'start each workspace host once (OpenClaw plugin / Codex worker) so it persists its tool declaration',
158
214
  };
159
215
  }
160
- return { ok: true, declarations };
216
+ return { ok: true, declarations, warnings };
161
217
  }
@@ -34,6 +34,8 @@ export type HostToolSemanticResolution = {
34
34
  readonly ok: true;
35
35
  readonly registry: ToolSemanticRegistry;
36
36
  readonly hostKinds: readonly string[];
37
+ /** Non-blocking load diagnostics (legacy declaration version). */
38
+ readonly warnings: readonly string[];
37
39
  } | {
38
40
  readonly ok: false;
39
41
  readonly reason: string;
@@ -52,6 +54,8 @@ export type HookToolSemanticsResolution = {
52
54
  readonly ok: true;
53
55
  readonly registry: ToolSemanticRegistry;
54
56
  readonly source: HookToolSemanticsSource;
57
+ /** Non-blocking diagnostics the host must surface (legacy version). */
58
+ readonly warnings: readonly string[];
55
59
  } | {
56
60
  readonly ok: false;
57
61
  readonly reason: string;
@@ -82,6 +86,9 @@ export interface HookToolSemanticsOptions {
82
86
  * - malformed / conflicting declaration → typed refusal, never a silent
83
87
  * static fallback and never an empty registry. Consumers must surface the
84
88
  * reason (rc-9) and may fall back to their static registry for availability.
89
+ * - legacy declaration version (v1 read by a v2 build) → NOT a refusal: the
90
+ * file is read with v1 semantics (`writePayloadFormat` unset) and the
91
+ * result carries `warnings`, which consumers must surface (rc-9).
85
92
  */
86
93
  export declare function resolveHostToolSemanticsForHook(options: HookToolSemanticsOptions): HookToolSemanticsResolution;
87
94
  export { saveHostToolDeclaration };