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
@@ -0,0 +1,159 @@
1
+ /**
2
+ * `pd trajectory maintain | retention status | vacuum` — SPEC-PD-TR-001.
3
+ *
4
+ * CLI contract:
5
+ * - `--json` writes exactly one JSON document to stdout (cli-1);
6
+ * - refusals carry a structured `reason` + `nextAction` and exit non-zero
7
+ * without mutating anything (cli-5, cli-6);
8
+ * - `vacuum` is dry-run unless `--yes` (cli-4).
9
+ */
10
+ import { readTrajectoryRetentionStatus, runTrajectoryRetention, vacuumTrajectoryDatabase, } from '@principles/host-runtime';
11
+ import { resolveWorkspaceDir } from '../resolve-workspace.js';
12
+ function printMaintain(report) {
13
+ if (report.outcome === 'skipped') {
14
+ console.log(`Retention skipped: ${report.reason ?? 'unknown'}`);
15
+ if (report.nextAction !== undefined)
16
+ console.log(`Next: ${report.nextAction}`);
17
+ return;
18
+ }
19
+ const deleted = Object.entries(report.deletedByTable)
20
+ .filter(([, count]) => count > 0)
21
+ .map(([table, count]) => `${table}=${count}`)
22
+ .join(' ');
23
+ console.log(`Retention ${report.outcome} (cutoff ${report.cutoff ?? 'n/a'}, ${report.batches} batch(es), `
24
+ + `${report.totalDurationMs} ms total, max batch ${report.maxBatchDurationMs} ms)`
25
+ + (deleted === '' ? ', deleted 0 rows' : `: ${deleted}`));
26
+ if (report.partial)
27
+ console.log('Partial: the run budget or batch budget was exhausted; the next run continues.');
28
+ if (report.backoffUntil !== null)
29
+ console.log(`Backoff until ${report.backoffUntil}`);
30
+ if (report.nextAction !== undefined)
31
+ console.log(`Next: ${report.nextAction}`);
32
+ }
33
+ /**
34
+ * Reasons that mean "this run was supposed to delete but could not" and that a
35
+ * human/automation must act on. Deliberately EXCLUDES the designed yields —
36
+ * `deferred:busy`, `deadline`, `run_budget_exhausted`, `no_progress:*`,
37
+ * `batch_over_budget`, `locked`, `not_due:*`, `backoff:*` — because a healthy
38
+ * cron must not page on the budget doing its job.
39
+ *
40
+ * Included:
41
+ * - `failed:` unhandled error, deletion stopped;
42
+ * - `audit_failed:` fail-closed: the batch was NOT deleted because the
43
+ * audit list could not be written;
44
+ * - `config_invalid:` / config refuses to load or degrades: nothing is deleted;
45
+ * `degraded:`
46
+ * - `journal_mode_not_wal` the database can never be swept in this mode;
47
+ * - `clock_*` / `marker_timestamp_invalid` the clock/marker guard skipped the
48
+ * run (forward/invalid self-heals next run, backwards
49
+ * persists while the clock is wrong);
50
+ * - `index_failed:` sweeping works but the plan is degraded; persistent
51
+ * until repaired;
52
+ * - `invariant_violation` row counts did not reconcile.
53
+ */
54
+ const OPERATOR_FAILURE_REASON_PREFIXES = Object.freeze([
55
+ 'failed:',
56
+ 'audit_failed:',
57
+ 'config_invalid:',
58
+ 'degraded:',
59
+ 'journal_mode_not_wal',
60
+ 'clock_',
61
+ 'marker_timestamp_invalid',
62
+ 'index_failed:',
63
+ ]);
64
+ /**
65
+ * Exit code for `pd trajectory maintain`: 1 only when the run needs a human,
66
+ * 0 for success, intentional-off states and designed budget/busy yields.
67
+ */
68
+ export function retentionExitCode(report) {
69
+ if (report.outcome === 'invariant_violation')
70
+ return 1;
71
+ const reason = report.reason ?? '';
72
+ return OPERATOR_FAILURE_REASON_PREFIXES.some((prefix) => reason.startsWith(prefix)) ? 1 : 0;
73
+ }
74
+ export async function handleTrajectoryMaintain(opts) {
75
+ const workspaceDir = resolveWorkspaceDir(opts.workspace);
76
+ // Manual invocations are the fallback for workspaces with no running worker,
77
+ // so they ignore `intervalHours`; lock, clock guards, budgets and the
78
+ // fail-closed config rules all still apply.
79
+ const report = runTrajectoryRetention({ workspaceDir, trigger: 'manual' });
80
+ if (opts.json === true) {
81
+ console.log(JSON.stringify(report, null, 2));
82
+ }
83
+ else {
84
+ printMaintain(report);
85
+ }
86
+ const exitCode = retentionExitCode(report);
87
+ if (exitCode !== 0)
88
+ process.exitCode = exitCode;
89
+ }
90
+ export async function handleTrajectoryRetentionStatus(opts) {
91
+ const workspaceDir = resolveWorkspaceDir(opts.workspace);
92
+ const status = readTrajectoryRetentionStatus(workspaceDir);
93
+ if (opts.json === true) {
94
+ console.log(JSON.stringify(status, null, 2));
95
+ return;
96
+ }
97
+ console.log(`Workspace: ${status.workspaceDir}`);
98
+ console.log(`Database: ${status.dbPath} (${status.dbExists ? 'present' : 'missing'})`);
99
+ console.log(`Policy: enabled=${status.policy.enabled} retentionDays=${status.policy.retentionDays} `
100
+ + `intervalHours=${status.policy.intervalHours} batchSize=${status.policy.batchSize} `
101
+ + `runBudgetMs=${status.policy.runBudgetMs}`
102
+ + (status.policy.degradedReason === undefined ? '' : ` [degraded: ${status.policy.degradedReason}]`));
103
+ console.log(`Last run: ${status.marker.lastRunAt ?? 'never'} (${status.marker.lastOutcome ?? 'n/a'})`);
104
+ console.log(`Cutoff: ${status.marker.lastCutoff ?? 'n/a'}`);
105
+ console.log(`Next run: cutoff ${status.nextCutoff ?? 'n/a (no sweep scheduled)'}`);
106
+ if (status.marker.backoffUntil !== null)
107
+ console.log(`Backoff: ${status.marker.backoffUntil}`);
108
+ if (status.markerError !== null)
109
+ console.log(`Marker: unreadable (${status.markerError})`);
110
+ if (status.dbError !== null)
111
+ console.log(`Database: unreadable (${status.dbError})`);
112
+ if (status.indexesMissing.length > 0) {
113
+ console.log(`Indexes: missing ${status.indexesMissing.join(', ')} — run \`pd trajectory vacuum --yes\``);
114
+ }
115
+ if (status.expiredByTable !== null) {
116
+ const counts = Object.entries(status.expiredByTable)
117
+ .map(([table, count]) => `${table}=${count}`)
118
+ .join(' ');
119
+ // Same cutoff the next run will use, so this is a projection, not a
120
+ // different definition of "expired" (F4).
121
+ console.log(`Next delete: ${counts}`);
122
+ }
123
+ }
124
+ function printVacuum(report) {
125
+ if (report.refusedReason !== null) {
126
+ console.log(`VACUUM refused: ${report.refusedReason}`);
127
+ console.log(`Size ${report.sizeBeforeBytes} bytes, free ${report.freeBytes ?? 'unknown'}, `
128
+ + `required ${report.requiredBytes ?? 'unknown'} (2 x size + 10%)`);
129
+ if (report.nextAction !== undefined)
130
+ console.log(`Next: ${report.nextAction}`);
131
+ return;
132
+ }
133
+ if (!report.applied) {
134
+ console.log(`VACUUM dry run: size ${report.sizeBeforeBytes} bytes, freelist ${report.freelistBefore ?? 'unknown'} pages, `
135
+ + `free ${report.freeBytes ?? 'unknown'}, required ${report.requiredBytes ?? 'unknown'}`);
136
+ if (report.nextAction !== undefined)
137
+ console.log(`Next: ${report.nextAction}`);
138
+ return;
139
+ }
140
+ console.log(`VACUUM done in ${report.durationMs} ms: ${report.sizeBeforeBytes} -> ${report.sizeAfterBytes ?? 'unknown'} bytes, `
141
+ + `freelist ${report.freelistBefore ?? 'unknown'} -> ${report.freelistAfter ?? 'unknown'} pages`);
142
+ if (report.indexes !== null) {
143
+ console.log(`Indexes: ${report.indexes.applied.length} applied, ${report.indexes.skipped.length} skipped`);
144
+ }
145
+ }
146
+ export async function handleTrajectoryVacuum(opts) {
147
+ const workspaceDir = resolveWorkspaceDir(opts.workspace);
148
+ const report = vacuumTrajectoryDatabase({ workspaceDir, apply: opts.yes === true });
149
+ if (opts.json === true) {
150
+ console.log(JSON.stringify(report, null, 2));
151
+ }
152
+ else {
153
+ printVacuum(report);
154
+ }
155
+ if (report.refusedReason !== null) {
156
+ process.exitCode = 1;
157
+ }
158
+ }
159
+ //# sourceMappingURL=trajectory-retention.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trajectory-retention.js","sourceRoot":"","sources":["../../src/commands/trajectory-retention.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,6BAA6B,EAC7B,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAkB9D,SAAS,aAAa,CAAC,MAAiC;IACtD,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,sBAAsB,MAAM,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC,CAAC;QAChE,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS;YAAE,OAAO,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;QAC/E,OAAO;IACT,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC;SAClD,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC;SAChC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,KAAK,EAAE,CAAC;SAC5C,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,OAAO,CAAC,GAAG,CACT,aAAa,MAAM,CAAC,OAAO,YAAY,MAAM,CAAC,MAAM,IAAI,KAAK,KAAK,MAAM,CAAC,OAAO,cAAc;UAC5F,GAAG,MAAM,CAAC,eAAe,wB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,MAAM,CAAC,aAAa,IAAI,SAAS,QAAQ,CACjG,CAAC;IACF,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,CACT,cAAc,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,aAAa,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,UAAU,CAChG,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,IAA6B;IACxE,MAAM,YAAY,GAAG,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,wBAAwB,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,KAAK,IAAI,EAAE,CAAC,CAAC;IAEpF,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;SAAM,CAAC;QACN,WAAW,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;IAED,IAAI,MAAM,CAAC,aAAa,KAAK,IAAI,EAAE,CAAC;QAClC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
@@ -0,0 +1,69 @@
1
+ import { type ConversationIngestionConsentState } from '@principles/host-runtime';
2
+ export declare const WORKBUDDY_INGESTION_DISCLOSURE_VERSION = "wb-2026-11-11";
3
+ export interface WorkbuddySetupOptions {
4
+ workspace?: string;
5
+ json?: boolean;
6
+ accept?: boolean;
7
+ decline?: boolean;
8
+ showDisclosure?: boolean;
9
+ }
10
+ export interface WorkbuddySetupReport {
11
+ generatedAt: string;
12
+ host: 'workbuddy';
13
+ workspace: string;
14
+ status: 'ok' | 'degraded';
15
+ decision?: 'granted' | 'revoked';
16
+ consentStateBefore: ConversationIngestionConsentState;
17
+ consentState: ConversationIngestionConsentState;
18
+ disclosureVersion: string;
19
+ ingestionFlag: {
20
+ name: string;
21
+ enabled: boolean;
22
+ };
23
+ hostWorkbuddyFlagEnabled: boolean;
24
+ warnings: string[];
25
+ reason?: string;
26
+ nextAction?: string;
27
+ }
28
+ export declare function getWorkbuddyIngestionDisclosureText(): string;
29
+ /**
30
+ * `restored` is only meaningful on failure: it says whether the pre-mutation
31
+ * bytes were successfully put back. A rollback whose calibration check fails
32
+ * can still have restored the file, and the operator message must not claim
33
+ * otherwise.
34
+ */
35
+ type FlagWriteResult = {
36
+ ok: true;
37
+ } | {
38
+ ok: false;
39
+ reason: string;
40
+ nextAction: string;
41
+ restored?: boolean;
42
+ };
43
+ /** Options for {@link setWorkbuddyIngestionFlag}. */
44
+ export interface SetWorkbuddyIngestionFlagOptions {
45
+ /**
46
+ * Exact bytes captured BEFORE this command's first mutation. Used when the
47
+ * round-trip verification fails: a restore must return the file to the last
48
+ * state the Owner actually saw, not to whatever the current call just read
49
+ * (a rollback call would otherwise "restore" the intermediate enabled bytes).
50
+ */
51
+ restoreBytes?: string;
52
+ }
53
+ /**
54
+ * Line-targeted, atomic, round-trip-verified edit of
55
+ * `features.workbuddy_conversation_ingestion.enabled`. Same shape as the
56
+ * Codex setup's config edit (kept separate so the frozen Codex consent flow
57
+ * is untouched); comments and every other key are preserved.
58
+ */
59
+ export declare function setWorkbuddyIngestionFlag(workspaceDir: string, enabled: boolean, options?: SetWorkbuddyIngestionFlagOptions): FlagWriteResult;
60
+ /**
61
+ * `pd workbuddy setup` entry point: read the current consent/flag state, then
62
+ * grant or revoke WorkBuddy ingestion and report what changed.
63
+ *
64
+ * Emits exactly one machine-readable JSON object under `--json` (cli-1) and
65
+ * sets exit code 1 only for a degraded outcome.
66
+ */
67
+ export declare function handleWorkbuddySetup(options: WorkbuddySetupOptions): Promise<void>;
68
+ export {};
69
+ //# sourceMappingURL=workbuddy-setup.d.ts.map
@@ -0,0 +1 @@
1
+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M,WAAW,gCAAgC;IAC/C;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,gCAAqC,GAAG,eAAe,CA0HjJ;AAWD;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+JxF"}
@@ -0,0 +1,379 @@
1
+ /**
2
+ * pd workbuddy setup — the SUPPORTED entry point for WorkBuddy conversation
3
+ * ingestion consent (PRI-1171 P2, tickets ⑤/⑥).
4
+ *
5
+ * "Supported" is a convention, not an enforced boundary: the consent ledger
6
+ * (`<workspace>/.state/conversation-ingestion-consent.json`) and the workspace
7
+ * config are ordinary files, and `recordConversationIngestionConsent` is a
8
+ * public export — another tool could write the same durable facts. What this
9
+ * command owns is the intended UX: present the disclosure, record the explicit
10
+ * decision, and flip the flag in the order below.
11
+ *
12
+ * The two writes are ordered so a granted record can never precede a
13
+ * successfully enabled flag, and a failed consent write rolls the flag back to
14
+ * the exact bytes captured before this command's first mutation (atomic
15
+ * tmp+rename, never an in-place truncate).
16
+ *
17
+ * The runtime (workbuddy-adapter/src/ingestion/ingestion.ts) READS this ledger
18
+ * on every Stop hook — unlike the Codex path, which still hard-codes a grant
19
+ * from its setup-flow invariant. Revocation therefore takes effect immediately.
20
+ *
21
+ * CLI gate compliance: cli-1 (--json is one JSON object), cli-2 (explicit
22
+ * exit after refuse), cli-4 (--accept/--decline mutex), cli-5 (refused runs
23
+ * mutate nothing), cli-6 (every refusal carries reason + nextAction).
24
+ */
25
+ import * as fs from 'node:fs';
26
+ import * as os from 'node:os';
27
+ import * as path from 'node:path';
28
+ import { getWorkbuddyWorkspaceDir } from '@principles/install-layout';
29
+ import { resolveWorkspaceDir } from '../resolve-workspace.js';
30
+ import { deriveConversationIngestionConsentState, getPdConfigPath, loadPdConfigForPlugin, readConversationIngestionConsent, recordConversationIngestionConsent, } from '@principles/host-runtime';
31
+ import { computeEffectivePdConfig, computeFeatureFlagsFromConfig, isFeatureEnabled } from '@principles/core/runtime';
32
+ export const WORKBUDDY_INGESTION_DISCLOSURE_VERSION = 'wb-2026-11-11';
33
+ const FLAG_ID = 'workbuddy_conversation_ingestion';
34
+ const SETUP_COMMAND = 'pd workbuddy setup';
35
+ export function getWorkbuddyIngestionDisclosureText() {
36
+ return [
37
+ 'PD · WorkBuddy 会话采集授权(' + WORKBUDDY_INGESTION_DISCLOSURE_VERSION + ')',
38
+ '',
39
+ '开启后,PD 会在每次会话结束时读取 WorkBuddy 在本机写下的会话转录',
40
+ '(~/.workbuddy/projects/<项目>/<会话ID>.jsonl),并把以下内容写入本工作区的',
41
+ 'trajectory.db(governance_observations 表),供 Pain 诊断与原则内化的数据管道使用:',
42
+ ' - 您本人输入的话语(仅 <user_query> 内的文本)',
43
+ ' - 助手的可见回复、推理记录、工具调用名称与结果状态',
44
+ '不会采集:宿主注入的 system-reminder 上下文(系统提示、身份文件、工具声明、',
45
+ '连接器状态等)。解码器只从 <user_query> 结构化边界投影 Owner 原话;',
46
+ '无法确认该边界时,该条记录标记为 partial 且不写入原文(fail-closed,宁缺毋滥)。',
47
+ '',
48
+ '采集受三道门约束:host.workbuddy + workbuddy_conversation_ingestion + 本同意记录',
49
+ '(decision=granted)。默认关闭;任一门关闭时 PD 不会打开任何转录文件(零读取)。',
50
+ '',
51
+ '随时可用 `' + SETUP_COMMAND + ' --decline` 撤销;撤销只影响后续采集,',
52
+ '已入库数据按既有的保留策略处理。',
53
+ ].join('\n');
54
+ }
55
+ const FEATURES_LINE = /^features:\s*(?:#.*)?$/;
56
+ const KEY_LINE = /^ {2}workbuddy_conversation_ingestion:\s*(?:#.*)?$/;
57
+ const ENABLED_LINE = /^ {4}enabled:\s*(?:true|false)\s*(?:#.*)?$/;
58
+ /** Drop an inline `#` comment and surrounding whitespace from one YAML line. */
59
+ function stripComment(line) {
60
+ const hash = line.indexOf('#');
61
+ return (hash === -1 ? line : line.slice(0, hash)).trim();
62
+ }
63
+ /** Runtime-contract guard (rc-1): a non-null, non-array object is the only trusted shape. */
64
+ function isPlainObject(value) {
65
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
66
+ }
67
+ /**
68
+ * Line-targeted, atomic, round-trip-verified edit of
69
+ * `features.workbuddy_conversation_ingestion.enabled`. Same shape as the
70
+ * Codex setup's config edit (kept separate so the frozen Codex consent flow
71
+ * is untouched); comments and every other key are preserved.
72
+ */
73
+ export function setWorkbuddyIngestionFlag(workspaceDir, enabled, options = {}) {
74
+ const configPath = getPdConfigPath(workspaceDir);
75
+ let raw;
76
+ try {
77
+ raw = fs.readFileSync(configPath, 'utf8');
78
+ }
79
+ catch (error) {
80
+ const code = typeof error === 'object' && error !== null && Object.hasOwn(error, 'code')
81
+ ? String(error.code) : String(error);
82
+ return { ok: false, reason: 'config_unreadable:' + code, nextAction: 'Run `pd runtime init --confirm` in this workspace, then re-run `' + SETUP_COMMAND + '`.' };
83
+ }
84
+ const registry = computeFeatureFlagsFromConfig(computeEffectivePdConfig(null)).flags;
85
+ const category = registry[FLAG_ID]?.category ?? 'quiet';
86
+ const restoreBytes = options.restoreBytes ?? raw;
87
+ let tmpSequence = 0;
88
+ /**
89
+ * Every mutation — forward write AND restore — goes through tmp+rename.
90
+ * An in-place `writeFileSync(configPath, ...)` can leave a truncated
91
+ * config.yaml if the process dies mid-write, which is exactly the state the
92
+ * restore path exists to prevent. Returns the failure message, or null.
93
+ */
94
+ const atomicWrite = (content) => {
95
+ tmpSequence += 1;
96
+ const tmpPath = configPath + '.tmp-wbsetup-' + String(process.pid) + '-' + String(Date.now()) + '-' + String(tmpSequence);
97
+ try {
98
+ fs.mkdirSync(path.dirname(configPath), { recursive: true });
99
+ fs.writeFileSync(tmpPath, content, { encoding: 'utf8' });
100
+ fs.renameSync(tmpPath, configPath);
101
+ return null;
102
+ }
103
+ catch (error) {
104
+ try {
105
+ fs.rmSync(tmpPath, { force: true });
106
+ }
107
+ catch { /* best effort */ }
108
+ return error instanceof Error ? error.message : String(error);
109
+ }
110
+ };
111
+ /**
112
+ * Shared commit: atomic write, production-loader round-trip verification and
113
+ * an atomic restore of the pre-mutation bytes on any mismatch, so a failed
114
+ * run leaves the file as the Owner last saw it.
115
+ */
116
+ const commit = (nextContent) => {
117
+ const writeFailure = atomicWrite(nextContent);
118
+ if (writeFailure !== null) {
119
+ return { ok: false, reason: 'config_write_failed:' + writeFailure.slice(0, 160), nextAction: 'Check permissions on ' + path.dirname(configPath) + '; config.yaml was left unchanged.' };
120
+ }
121
+ const verification = loadPdConfigForPlugin(workspaceDir);
122
+ const verified = verification.ok ? isFeatureEnabled(computeFeatureFlagsFromConfig(verification.effective), FLAG_ID) : undefined;
123
+ if (!verification.ok || verified !== enabled) {
124
+ const restoreFailure = atomicWrite(restoreBytes);
125
+ return {
126
+ ok: false,
127
+ reason: verification.ok ? 'config_roundtrip_mismatch' : 'config_roundtrip_invalid:' + (verification.errors[0]?.reason ?? 'unknown'),
128
+ restored: restoreFailure === null,
129
+ nextAction: restoreFailure === null
130
+ ? 'config.yaml was restored to its pre-command bytes. Fix the features block in ' + configPath + ' and re-run `' + SETUP_COMMAND + '`.'
131
+ : 'WARNING: config.yaml could not be restored (' + restoreFailure.slice(0, 120) + '); repair ' + configPath + ' manually before re-running `' + SETUP_COMMAND + '`.',
132
+ };
133
+ }
134
+ return { ok: true };
135
+ };
136
+ // JSON is a valid YAML subset and is what some installers/fixtures write.
137
+ // A line-targeted edit cannot see a `features:` line there, so update the
138
+ // parsed object instead — every other key is preserved verbatim.
139
+ if (raw.trim().startsWith('{')) {
140
+ let parsed;
141
+ try {
142
+ parsed = JSON.parse(raw);
143
+ }
144
+ catch {
145
+ return { ok: false, reason: 'config_json_invalid', nextAction: 'Repair ' + configPath + ' (it is neither valid JSON nor YAML), then re-run `' + SETUP_COMMAND + '`.' };
146
+ }
147
+ if (!isPlainObject(parsed) || !isPlainObject(parsed.features)) {
148
+ return { ok: false, reason: 'config_features_section_missing', nextAction: 'Add a features mapping to ' + configPath + ', then re-run `' + SETUP_COMMAND + '`.' };
149
+ }
150
+ const features = parsed.features;
151
+ const existing = features[FLAG_ID];
152
+ features[FLAG_ID] = { ...(isPlainObject(existing) ? existing : {}), category, enabled };
153
+ return commit(JSON.stringify(parsed));
154
+ }
155
+ const lineEnding = raw.includes('\r\n') ? '\r\n' : '\n';
156
+ const lines = raw.replace(/\r\n/g, '\n').split('\n');
157
+ const block = [' ' + FLAG_ID + ':', ' category: ' + category, ' enabled: ' + String(enabled)];
158
+ const featuresIndex = lines.findIndex((line) => FEATURES_LINE.test(line) || stripComment(line).replace(/\s+/g, '') === 'features:{}');
159
+ if (featuresIndex === -1) {
160
+ return { ok: false, reason: 'config_features_section_missing', nextAction: 'Add a features section to ' + configPath + ', then re-run `' + SETUP_COMMAND + '`.' };
161
+ }
162
+ const featuresLine = lines[featuresIndex];
163
+ if (featuresLine === undefined) {
164
+ return { ok: false, reason: 'config_features_line_undefined', nextAction: 'config.yaml was left unchanged; re-run `' + SETUP_COMMAND + '`.' };
165
+ }
166
+ let mutated = false;
167
+ if (stripComment(featuresLine).replace(/\s+/g, '') === 'features:{}') {
168
+ lines.splice(featuresIndex, 1, 'features:', ...block);
169
+ mutated = true;
170
+ }
171
+ else {
172
+ let keyIndex = -1;
173
+ let blockEnd = lines.length;
174
+ for (let i = featuresIndex + 1; i < lines.length; i += 1) {
175
+ const line = lines[i];
176
+ if (line === undefined || line.trim() === '')
177
+ continue;
178
+ if (KEY_LINE.test(line)) {
179
+ keyIndex = i;
180
+ continue;
181
+ }
182
+ if (keyIndex !== -1 && /^( {0,1}\S| {2}\S)/.test(line)) {
183
+ blockEnd = i;
184
+ break;
185
+ }
186
+ }
187
+ if (keyIndex === -1) {
188
+ lines.splice(featuresIndex + 1, 0, ...block);
189
+ mutated = true;
190
+ }
191
+ else {
192
+ let enabledFound = false;
193
+ for (let i = keyIndex + 1; i < blockEnd; i += 1) {
194
+ const current = lines[i];
195
+ if (current === undefined || !ENABLED_LINE.test(current))
196
+ continue;
197
+ enabledFound = true;
198
+ const comment = current.indexOf(' #');
199
+ const next = ' enabled: ' + String(enabled) + (comment === -1 ? '' : ' ' + current.slice(comment + 1));
200
+ if (current !== next) {
201
+ lines[i] = next;
202
+ mutated = true;
203
+ }
204
+ break;
205
+ }
206
+ if (!enabledFound) {
207
+ lines.splice(keyIndex + 1, 0, ' enabled: ' + String(enabled));
208
+ mutated = true;
209
+ }
210
+ }
211
+ }
212
+ if (!mutated)
213
+ return { ok: true };
214
+ return commit(lines.join(lineEnding));
215
+ }
216
+ function consentInput(decision, evidenceRef) {
217
+ return {
218
+ decision,
219
+ decidedVia: 'owner_directive',
220
+ disclosureVersion: WORKBUDDY_INGESTION_DISCLOSURE_VERSION,
221
+ evidenceRef,
222
+ };
223
+ }
224
+ /**
225
+ * `pd workbuddy setup` entry point: read the current consent/flag state, then
226
+ * grant or revoke WorkBuddy ingestion and report what changed.
227
+ *
228
+ * Emits exactly one machine-readable JSON object under `--json` (cli-1) and
229
+ * sets exit code 1 only for a degraded outcome.
230
+ */
231
+ export async function handleWorkbuddySetup(options) {
232
+ const generatedAt = new Date().toISOString();
233
+ // OD-07 / SPEC §4.1: the WorkBuddy runtime (Stop hook AND worker) reads a
234
+ // single user-level governance workspace. Defaulting to the generic CLI
235
+ // workspace here would write consent somewhere the hook never reads, so the
236
+ // default must use the SAME resolution; an explicit --workspace still wins.
237
+ const workspace = options.workspace !== undefined && options.workspace.trim().length > 0
238
+ ? resolveWorkspaceDir(options.workspace)
239
+ : getWorkbuddyWorkspaceDir(os.homedir());
240
+ /** Print the final report (JSON or human) and set the process exit code. */
241
+ const finish = (report) => {
242
+ if (options.json === true) {
243
+ console.log(JSON.stringify(report));
244
+ }
245
+ else {
246
+ const lines = [
247
+ 'WorkBuddy conversation-ingestion setup (' + report.workspace + ')',
248
+ ' status: ' + report.status,
249
+ ' disclosureVersion: ' + report.disclosureVersion,
250
+ ' consent (before): ' + report.consentStateBefore,
251
+ ' consent (now): ' + report.consentState,
252
+ ' ingestion flag: ' + String(report.ingestionFlag.enabled),
253
+ ' host.workbuddy: ' + String(report.hostWorkbuddyFlagEnabled),
254
+ ];
255
+ for (const warning of report.warnings)
256
+ lines.push(' warning: ' + warning);
257
+ if (report.reason !== undefined)
258
+ lines.push(' reason: ' + report.reason);
259
+ if (report.nextAction !== undefined)
260
+ lines.push(' next action: ' + report.nextAction);
261
+ console.log(lines.join('\n'));
262
+ }
263
+ if (report.status === 'degraded')
264
+ process.exitCode = 1;
265
+ };
266
+ const refuse = (reason, nextAction, detail = {}) => {
267
+ const { consentStateBefore: before, actualFlags } = detail;
268
+ const consentStateBefore = before ?? 'not_present';
269
+ finish({
270
+ generatedAt, host: 'workbuddy', workspace, status: 'degraded',
271
+ consentStateBefore, consentState: consentStateBefore,
272
+ disclosureVersion: WORKBUDDY_INGESTION_DISCLOSURE_VERSION,
273
+ // A rolled-back failure can leave the flag ON (rollback itself failed).
274
+ // Report the state we actually know, never a comforting `false`.
275
+ ingestionFlag: { name: FLAG_ID, enabled: actualFlags?.ingestionFlagEnabled ?? false },
276
+ hostWorkbuddyFlagEnabled: actualFlags?.hostWorkbuddyFlagEnabled ?? false,
277
+ warnings: [], reason, nextAction,
278
+ });
279
+ };
280
+ // cli-1/cli-5 (P2 review): `--show-disclosure` is a read-only early exit and
281
+ // cannot honour a decision or the JSON contract. Silently printing text made
282
+ // `--show-disclosure --accept` exit 0 without recording consent, and made
283
+ // `--show-disclosure --json` emit non-JSON. Reject the combinations instead.
284
+ if (options.showDisclosure === true && (options.accept === true || options.decline === true || options.json === true)) {
285
+ refuse('show_disclosure_conflicts_with_decision', '--show-disclosure only prints the disclosure. Drop --accept/--decline/--json, or run `pd workbuddy setup --accept|--decline [--json]` to record a decision.');
286
+ return;
287
+ }
288
+ if (options.showDisclosure === true) {
289
+ console.log(getWorkbuddyIngestionDisclosureText());
290
+ return;
291
+ }
292
+ if (options.accept === true && options.decline === true) {
293
+ refuse('accept_decline_mutex', 'Pass either --accept or --decline, not both.');
294
+ return;
295
+ }
296
+ if (options.json === true && options.accept !== true && options.decline !== true) {
297
+ refuse('decision_not_explicit', 'With --json a decision must be explicit: pass --accept or --decline.');
298
+ return;
299
+ }
300
+ if (options.accept === true) {
301
+ // Accepting must never skip the disclosure: print it before any mutation.
302
+ // `--json` keeps stdout machine-readable (cli-1), so there it goes to
303
+ // stderr — the same split the Codex setup uses for its human channel.
304
+ const disclosure = getWorkbuddyIngestionDisclosureText();
305
+ if (options.json === true)
306
+ console.error(disclosure);
307
+ else
308
+ console.log(disclosure);
309
+ }
310
+ const configPath = getPdConfigPath(workspace);
311
+ if (!fs.existsSync(configPath)) {
312
+ refuse('workspace_config_not_found', 'No .pd/config.yaml at ' + workspace + '. Run `pd runtime init --confirm` first.');
313
+ return;
314
+ }
315
+ const configLoad = loadPdConfigForPlugin(workspace);
316
+ if (!configLoad.ok) {
317
+ refuse('workspace_config_malformed:' + (configLoad.errors[0]?.reason ?? 'unknown'), 'Fix .pd/config.yaml before granting consent; nothing was mutated.');
318
+ return;
319
+ }
320
+ const flags = computeFeatureFlagsFromConfig(configLoad.effective);
321
+ const flagEnabledBefore = isFeatureEnabled(flags, FLAG_ID);
322
+ const hostEnabled = isFeatureEnabled(flags, 'host.workbuddy');
323
+ const consentRead = readConversationIngestionConsent(workspace, 'workbuddy');
324
+ if (!consentRead.ok) {
325
+ refuse(consentRead.reason, consentRead.nextAction);
326
+ return;
327
+ }
328
+ const stateBefore = deriveConversationIngestionConsentState(consentRead.record, flagEnabledBefore);
329
+ // No explicit decision: report-only, never mutate (cli-5).
330
+ if (options.accept !== true && options.decline !== true) {
331
+ console.log(getWorkbuddyIngestionDisclosureText());
332
+ finish({
333
+ generatedAt, host: 'workbuddy', workspace, status: 'ok',
334
+ consentStateBefore: stateBefore, consentState: stateBefore,
335
+ disclosureVersion: WORKBUDDY_INGESTION_DISCLOSURE_VERSION,
336
+ ingestionFlag: { name: FLAG_ID, enabled: flagEnabledBefore }, hostWorkbuddyFlagEnabled: hostEnabled,
337
+ warnings: hostEnabled ? [] : ['host.workbuddy is off: ingestion stays gated even after consent is granted.'],
338
+ });
339
+ return;
340
+ }
341
+ const decision = options.accept === true ? 'granted' : 'revoked';
342
+ const targetFlag = decision === 'granted';
343
+ // Capture the pre-mutation bytes BEFORE the first write: if the consent
344
+ // write fails, the rollback restores this exact state, not the intermediate
345
+ // flag flip this command just made.
346
+ let originalConfigBytes;
347
+ try {
348
+ originalConfigBytes = fs.readFileSync(configPath, 'utf8');
349
+ }
350
+ catch { /* pre-checked above; leave undefined */ }
351
+ const flagWrite = setWorkbuddyIngestionFlag(workspace, targetFlag);
352
+ if (!flagWrite.ok) {
353
+ refuse(flagWrite.reason, flagWrite.nextAction, { consentStateBefore: stateBefore });
354
+ return;
355
+ }
356
+ const recorded = recordConversationIngestionConsent(workspace, 'workbuddy', consentInput(decision, '`' + SETUP_COMMAND + ' --' + (decision === 'granted' ? 'accept' : 'decline') + '` at ' + generatedAt));
357
+ if (!recorded.ok) {
358
+ // Never leave a flag enabled without its grant (or a revocation without
359
+ // its flag off): roll the config back to the previous value.
360
+ const rollback = setWorkbuddyIngestionFlag(workspace, flagEnabledBefore, originalConfigBytes !== undefined ? { restoreBytes: originalConfigBytes } : {});
361
+ const rollbackOk = rollback.ok || rollback.restored === true;
362
+ refuse('consent_write_failed:' + recorded.reason, recorded.nextAction + (rollbackOk
363
+ ? ' The ingestion flag was rolled back.'
364
+ : ' WARNING: the ingestion flag could NOT be rolled back; disable it manually.'), {
365
+ consentStateBefore: stateBefore,
366
+ actualFlags: { ingestionFlagEnabled: rollbackOk ? flagEnabledBefore : targetFlag, hostWorkbuddyFlagEnabled: hostEnabled },
367
+ });
368
+ return;
369
+ }
370
+ const stateAfter = deriveConversationIngestionConsentState(recorded.record, targetFlag);
371
+ finish({
372
+ generatedAt, host: 'workbuddy', workspace, status: 'ok', decision,
373
+ consentStateBefore: stateBefore, consentState: stateAfter,
374
+ disclosureVersion: WORKBUDDY_INGESTION_DISCLOSURE_VERSION,
375
+ ingestionFlag: { name: FLAG_ID, enabled: targetFlag }, hostWorkbuddyFlagEnabled: hostEnabled,
376
+ warnings: decision === 'granted' && !hostEnabled ? ['host.workbuddy is off: no transcript will be read until the host master switch is enabled.'] : [],
377
+ });
378
+ }
379
+ //# sourceMappingURL=workbuddy-setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbuddy-setup.js","sourceRoot":"","sources":["../../src/commands/workbuddy-setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EACL,uCAAuC,EACvC,eAAe,EACf,qBAAqB,EACrB,gCAAgC,EAChC,kCAAkC,GAEnC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAErH,MAAM,CAAC,MAAM,sCAAsC,GAAG,eAAe,CAAC;AACtE,MAAM,OAAO,GAAG,kCAAkC,CAAC;AACnD,MAAM,aAAa,GAAG,oBAAoB,CAAC;AA0B3C,MAAM,UAAU,mCAAmC;IACjD,OAAO;QACL,wBAAwB,GAAG,sCAAsC,GAAG,GAAG;QACvE,EAAE;QACF,yCAAyC;QACzC,yDAAyD;QACzD,iEAAiE;QACjE,mCAAmC;QACnC,8BAA8B;QAC9B,gDAAgD;QAChD,8CAA8C;QAC9C,oDAAoD;QACpD,EAAE;QACF,oEAAoE;QACpE,oDA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