create-principles-disciple 1.150.4 → 1.151.0

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 (551) hide show
  1. package/README.md +5 -5
  2. package/_release/product-identity.json +1 -1
  3. package/codex-adapter/dist/ingestion/codex-version.d.ts +14 -12
  4. package/codex-adapter/dist/ingestion/codex-version.js +19 -20
  5. package/codex-adapter/dist/ingestion/ingestion.js +25 -4
  6. package/codex-adapter/dist/ingestion/transcript-decoder.d.ts +5 -3
  7. package/codex-adapter/dist/ingestion/transcript-decoder.js +61 -5
  8. package/codex-adapter/package.json +1 -1
  9. package/console/dist/server/bind-guard.d.ts +6 -13
  10. package/console/dist/server/bind-guard.js +8 -17
  11. package/console/dist/server/index.d.ts +9 -3
  12. package/console/dist/server/index.js +69 -55
  13. package/console/dist/server/models/ActivationsConsoleModel.js +5 -3
  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 +61 -22
  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/activations.js +2 -2
  31. package/console/dist/server/routes/diagnostician.js +3 -2
  32. package/console/dist/server/routes/evidence-chain.d.ts +4 -0
  33. package/console/dist/server/routes/evidence-chain.js +22 -0
  34. package/console/dist/server/routes/evidence-outcomes.d.ts +3 -2
  35. package/console/dist/server/routes/evidence-outcomes.js +1 -1
  36. package/console/dist/server/routes/failed-tasks.js +79 -3
  37. package/console/dist/server/routes/governance.d.ts +9 -6
  38. package/console/dist/server/routes/governance.js +10 -6
  39. package/console/dist/server/routes/health.d.ts +8 -0
  40. package/console/dist/server/routes/health.js +72 -0
  41. package/console/dist/server/routes/owner-decisions.d.ts +3 -3
  42. package/console/dist/server/routes/owner-decisions.js +1 -1
  43. package/console/dist/server/routes/owner-identity.d.ts +10 -5
  44. package/console/dist/server/routes/owner-identity.js +11 -7
  45. package/console/dist/server/routes/principles.js +3 -3
  46. package/console/dist/server/routes/rule-candidate-bindings.js +1 -1
  47. package/console/dist/server/routes/update.js +24 -6
  48. package/console/dist/server/utils/request-guard.d.ts +35 -0
  49. package/console/dist/server/utils/request-guard.js +81 -0
  50. package/console/dist/server/utils/response.d.ts +0 -1
  51. package/console/dist/server/utils/response.js +0 -3
  52. package/console/dist/web/assets/app.css +98 -167
  53. package/console/dist/web/assets/app.js +34 -37
  54. package/core/dist/runtime/activation/activation-control-types.d.ts +3 -0
  55. package/core/dist/runtime/activation/activation-control-types.d.ts.map +1 -1
  56. package/core/dist/runtime/activation/adaptive-selection-output.d.ts +0 -21
  57. package/core/dist/runtime/activation/adaptive-selection-output.d.ts.map +1 -1
  58. package/core/dist/runtime/activation/adaptive-selection-output.js.map +1 -1
  59. package/core/dist/runtime/activation/index.d.ts +2 -6
  60. package/core/dist/runtime/activation/index.d.ts.map +1 -1
  61. package/core/dist/runtime/activation/index.js.map +1 -1
  62. package/core/dist/runtime/activation/production-gate-deps.d.ts +2 -1
  63. package/core/dist/runtime/activation/production-gate-deps.d.ts.map +1 -1
  64. package/core/dist/runtime/activation/prompt-activation-reader-contract.d.ts +2 -1
  65. package/core/dist/runtime/activation/prompt-activation-reader-contract.d.ts.map +1 -1
  66. package/core/dist/runtime/activation/rulecode-owner-decision-service.d.ts.map +1 -1
  67. package/core/dist/runtime/activation/rulecode-owner-decision-service.js +3 -2
  68. package/core/dist/runtime/activation/rulecode-owner-decision-service.js.map +1 -1
  69. package/core/dist/runtime/activation/sqlite-activation-safety-store.d.ts.map +1 -1
  70. package/core/dist/runtime/activation/sqlite-activation-safety-store.js +26 -13
  71. package/core/dist/runtime/activation/sqlite-activation-safety-store.js.map +1 -1
  72. package/core/dist/runtime/activation/writers/index.d.ts +0 -1
  73. package/core/dist/runtime/activation/writers/index.d.ts.map +1 -1
  74. package/core/dist/runtime/activation/writers/rule-host-writer.d.ts.map +1 -1
  75. package/core/dist/runtime/activation/writers/rule-host-writer.js +15 -6
  76. package/core/dist/runtime/activation/writers/rule-host-writer.js.map +1 -1
  77. package/core/dist/runtime/activation-compatibility-read-model.d.ts +3 -2
  78. package/core/dist/runtime/activation-compatibility-read-model.d.ts.map +1 -1
  79. package/core/dist/runtime/adapter/context-budget.d.ts +3 -14
  80. package/core/dist/runtime/adapter/context-budget.d.ts.map +1 -1
  81. package/core/dist/runtime/adapter/context-budget.js +2 -2
  82. package/core/dist/runtime/adapter/context-budget.js.map +1 -1
  83. package/core/dist/runtime/adapter/index.d.ts +1 -2
  84. package/core/dist/runtime/adapter/index.d.ts.map +1 -1
  85. package/core/dist/runtime/adapter/index.js +1 -1
  86. package/core/dist/runtime/adapter/index.js.map +1 -1
  87. package/core/dist/runtime/adapter/output-repair-contract.d.ts +18 -1
  88. package/core/dist/runtime/adapter/output-repair-contract.d.ts.map +1 -1
  89. package/core/dist/runtime/adapter/output-repair-contract.js +94 -0
  90. package/core/dist/runtime/adapter/output-repair-contract.js.map +1 -1
  91. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts +2 -3
  92. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
  93. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js +27 -10
  94. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js.map +1 -1
  95. package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts +1 -1
  96. package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts.map +1 -1
  97. package/core/dist/runtime/adapter/schema-prompt-adapter.d.ts +0 -1
  98. package/core/dist/runtime/adapter/schema-prompt-adapter.d.ts.map +1 -1
  99. package/core/dist/runtime/adapter/schema-prompt-adapter.js +43 -1
  100. package/core/dist/runtime/adapter/schema-prompt-adapter.js.map +1 -1
  101. package/core/dist/runtime/adapter/structured-output-repair.d.ts +17 -2
  102. package/core/dist/runtime/adapter/structured-output-repair.d.ts.map +1 -1
  103. package/core/dist/runtime/adapter/structured-output-repair.js +26 -5
  104. package/core/dist/runtime/adapter/structured-output-repair.js.map +1 -1
  105. package/core/dist/runtime/bridge-result-shaper.d.ts +1 -1
  106. package/core/dist/runtime/bridge-result-shaper.d.ts.map +1 -1
  107. package/core/dist/runtime/candidate-intake-service.d.ts +2 -1
  108. package/core/dist/runtime/candidate-intake-service.d.ts.map +1 -1
  109. package/core/dist/runtime/cli/diagnose.d.ts +4 -3
  110. package/core/dist/runtime/cli/diagnose.d.ts.map +1 -1
  111. package/core/dist/runtime/config/index.d.ts +2 -2
  112. package/core/dist/runtime/config/index.d.ts.map +1 -1
  113. package/core/dist/runtime/config/index.js +3 -3
  114. package/core/dist/runtime/config/index.js.map +1 -1
  115. package/core/dist/runtime/config/pd-config-defaults.d.ts +0 -2
  116. package/core/dist/runtime/config/pd-config-defaults.d.ts.map +1 -1
  117. package/core/dist/runtime/config/pd-config-defaults.js +2 -2
  118. package/core/dist/runtime/config/pd-config-defaults.js.map +1 -1
  119. package/core/dist/runtime/config/pd-config-types.d.ts +2 -0
  120. package/core/dist/runtime/config/pd-config-types.d.ts.map +1 -1
  121. package/core/dist/runtime/config/pd-config-types.js.map +1 -1
  122. package/core/dist/runtime/config/pd-config-validate.d.ts.map +1 -1
  123. package/core/dist/runtime/config/pd-config-validate.js +10 -1
  124. package/core/dist/runtime/config/pd-config-validate.js.map +1 -1
  125. package/core/dist/runtime/config/pd-profile-constants.d.ts +1 -7
  126. package/core/dist/runtime/config/pd-profile-constants.d.ts.map +1 -1
  127. package/core/dist/runtime/config/pd-profile-constants.js +5 -6
  128. package/core/dist/runtime/config/pd-profile-constants.js.map +1 -1
  129. package/core/dist/runtime/config/pd-validate-profile.d.ts +3 -2
  130. package/core/dist/runtime/config/pd-validate-profile.d.ts.map +1 -1
  131. package/core/dist/runtime/context-payload.d.ts +0 -7
  132. package/core/dist/runtime/context-payload.d.ts.map +1 -1
  133. package/core/dist/runtime/context-payload.js +1 -1
  134. package/core/dist/runtime/context-payload.js.map +1 -1
  135. package/core/dist/runtime/core-principles/index.d.ts +1 -1
  136. package/core/dist/runtime/core-principles/index.d.ts.map +1 -1
  137. package/core/dist/runtime/correction/correction-types.d.ts +0 -10
  138. package/core/dist/runtime/correction/correction-types.d.ts.map +1 -1
  139. package/core/dist/runtime/correction/correction-types.js.map +1 -1
  140. package/core/dist/runtime/diagnostician/diag-distiller-output.d.ts +0 -3
  141. package/core/dist/runtime/diagnostician/diag-distiller-output.d.ts.map +1 -1
  142. package/core/dist/runtime/diagnostician/diag-distiller-output.js +1 -1
  143. package/core/dist/runtime/diagnostician/diag-distiller-output.js.map +1 -1
  144. package/core/dist/runtime/diagnostician/diag-rootcause-output.d.ts +3 -11
  145. package/core/dist/runtime/diagnostician/diag-rootcause-output.d.ts.map +1 -1
  146. package/core/dist/runtime/diagnostician/diag-rootcause-output.js +3 -3
  147. package/core/dist/runtime/diagnostician/diag-rootcause-output.js.map +1 -1
  148. package/core/dist/runtime/diagnostician/distiller-prompt-builder.d.ts +5 -4
  149. package/core/dist/runtime/diagnostician/distiller-prompt-builder.d.ts.map +1 -1
  150. package/core/dist/runtime/diagnostician/evidence-ref-binding.d.ts +2 -1
  151. package/core/dist/runtime/diagnostician/evidence-ref-binding.d.ts.map +1 -1
  152. package/core/dist/runtime/diagnostician/rootcause-prompt-builder.d.ts +2 -1
  153. package/core/dist/runtime/diagnostician/rootcause-prompt-builder.d.ts.map +1 -1
  154. package/core/dist/runtime/diagnostician/router-prompt-builder.d.ts +22 -3
  155. package/core/dist/runtime/diagnostician/router-prompt-builder.d.ts.map +1 -1
  156. package/core/dist/runtime/diagnostician/router-prompt-builder.js +11 -1
  157. package/core/dist/runtime/diagnostician/router-prompt-builder.js.map +1 -1
  158. package/core/dist/runtime/diagnostician-association-shadow.d.ts +2 -2
  159. package/core/dist/runtime/diagnostician-association-shadow.d.ts.map +1 -1
  160. package/core/dist/runtime/diagnostician-association-validation.d.ts +3 -2
  161. package/core/dist/runtime/diagnostician-association-validation.d.ts.map +1 -1
  162. package/core/dist/runtime/diagnostician-output.d.ts +32 -5
  163. package/core/dist/runtime/diagnostician-output.d.ts.map +1 -1
  164. package/core/dist/runtime/diagnostician-output.js +47 -4
  165. package/core/dist/runtime/diagnostician-output.js.map +1 -1
  166. package/core/dist/runtime/diagnostician-prompt-builder.d.ts +2 -1
  167. package/core/dist/runtime/diagnostician-prompt-builder.d.ts.map +1 -1
  168. package/core/dist/runtime/error-categories.d.ts.map +1 -1
  169. package/core/dist/runtime/error-categories.js +10 -1
  170. package/core/dist/runtime/error-categories.js.map +1 -1
  171. package/core/dist/runtime/evidence-sanitizer.d.ts +8 -1
  172. package/core/dist/runtime/evidence-sanitizer.d.ts.map +1 -1
  173. package/core/dist/runtime/evidence-sanitizer.js +10 -3
  174. package/core/dist/runtime/evidence-sanitizer.js.map +1 -1
  175. package/core/dist/runtime/evolution/evolution-types.d.ts +0 -26
  176. package/core/dist/runtime/evolution/evolution-types.d.ts.map +1 -1
  177. package/core/dist/runtime/evolution/evolution-types.js.map +1 -1
  178. package/core/dist/runtime/feature-flags/index.d.ts +0 -1
  179. package/core/dist/runtime/feature-flags/index.d.ts.map +1 -1
  180. package/core/dist/runtime/feature-flags/index.js.map +1 -1
  181. package/core/dist/runtime/golden-trace.d.ts +9 -1
  182. package/core/dist/runtime/golden-trace.d.ts.map +1 -1
  183. package/core/dist/runtime/golden-trace.js +7 -0
  184. package/core/dist/runtime/golden-trace.js.map +1 -1
  185. package/core/dist/runtime/governance-experience-contract.d.ts +12 -12
  186. package/core/dist/runtime/governance-experience-contract.d.ts.map +1 -1
  187. package/core/dist/runtime/governance-experience-contract.js +0 -2
  188. package/core/dist/runtime/governance-experience-contract.js.map +1 -1
  189. package/core/dist/runtime/governance-experience.d.ts.map +1 -1
  190. package/core/dist/runtime/governance-experience.js +8 -16
  191. package/core/dist/runtime/governance-experience.js.map +1 -1
  192. package/core/dist/runtime/governance-projection-contract.d.ts +0 -6
  193. package/core/dist/runtime/governance-projection-contract.d.ts.map +1 -1
  194. package/core/dist/runtime/governance-projection-contract.js +3 -3
  195. package/core/dist/runtime/governance-projection-contract.js.map +1 -1
  196. package/core/dist/runtime/internalization/approved-rule-revision.d.ts.map +1 -1
  197. package/core/dist/runtime/internalization/approved-rule-revision.js +2 -1
  198. package/core/dist/runtime/internalization/approved-rule-revision.js.map +1 -1
  199. package/core/dist/runtime/internalization/artifact-summary.d.ts +5 -4
  200. package/core/dist/runtime/internalization/artifact-summary.d.ts.map +1 -1
  201. package/core/dist/runtime/internalization/artifact-summary.js +1 -1
  202. package/core/dist/runtime/internalization/artifact-summary.js.map +1 -1
  203. package/core/dist/runtime/internalization/artificer-intent-preflight.d.ts +1 -1
  204. package/core/dist/runtime/internalization/artificer-intent-preflight.d.ts.map +1 -1
  205. package/core/dist/runtime/internalization/artificer-output.d.ts +0 -2
  206. package/core/dist/runtime/internalization/artificer-output.d.ts.map +1 -1
  207. package/core/dist/runtime/internalization/artificer-output.js +17 -0
  208. package/core/dist/runtime/internalization/artificer-output.js.map +1 -1
  209. package/core/dist/runtime/internalization/artificer-prompt-builder.d.ts +14 -3
  210. package/core/dist/runtime/internalization/artificer-prompt-builder.d.ts.map +1 -1
  211. package/core/dist/runtime/internalization/artificer-prompt-builder.js +13 -1
  212. package/core/dist/runtime/internalization/artificer-prompt-builder.js.map +1 -1
  213. package/core/dist/runtime/internalization/artificer-run-correlation.d.ts +3 -2
  214. package/core/dist/runtime/internalization/artificer-run-correlation.d.ts.map +1 -1
  215. package/core/dist/runtime/internalization/consumer-evidence-preflight.d.ts +2 -1
  216. package/core/dist/runtime/internalization/consumer-evidence-preflight.d.ts.map +1 -1
  217. package/core/dist/runtime/internalization/diag-distiller-runner.d.ts +1 -1
  218. package/core/dist/runtime/internalization/diag-distiller-runner.d.ts.map +1 -1
  219. package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts +1 -1
  220. package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts.map +1 -1
  221. package/core/dist/runtime/internalization/diag-router-runner.d.ts +11 -1
  222. package/core/dist/runtime/internalization/diag-router-runner.d.ts.map +1 -1
  223. package/core/dist/runtime/internalization/diag-router-runner.js +105 -1
  224. package/core/dist/runtime/internalization/diag-router-runner.js.map +1 -1
  225. package/core/dist/runtime/internalization/dreamer-output.d.ts +0 -9
  226. package/core/dist/runtime/internalization/dreamer-output.d.ts.map +1 -1
  227. package/core/dist/runtime/internalization/dreamer-output.js +1 -1
  228. package/core/dist/runtime/internalization/dreamer-output.js.map +1 -1
  229. package/core/dist/runtime/internalization/dreamer-prompt-builder.d.ts +3 -2
  230. package/core/dist/runtime/internalization/dreamer-prompt-builder.d.ts.map +1 -1
  231. package/core/dist/runtime/internalization/dreamer-runner.d.ts +1 -1
  232. package/core/dist/runtime/internalization/dreamer-runner.d.ts.map +1 -1
  233. package/core/dist/runtime/internalization/evaluator-output.d.ts +7 -17
  234. package/core/dist/runtime/internalization/evaluator-output.d.ts.map +1 -1
  235. package/core/dist/runtime/internalization/evaluator-output.js +2 -2
  236. package/core/dist/runtime/internalization/evaluator-output.js.map +1 -1
  237. package/core/dist/runtime/internalization/evaluator-prompt-builder.d.ts +3 -9
  238. package/core/dist/runtime/internalization/evaluator-prompt-builder.d.ts.map +1 -1
  239. package/core/dist/runtime/internalization/evaluator-prompt-builder.js +1 -1
  240. package/core/dist/runtime/internalization/evaluator-prompt-builder.js.map +1 -1
  241. package/core/dist/runtime/internalization/formation-context.d.ts +4 -6
  242. package/core/dist/runtime/internalization/formation-context.d.ts.map +1 -1
  243. package/core/dist/runtime/internalization/formation-context.js +3 -3
  244. package/core/dist/runtime/internalization/formation-context.js.map +1 -1
  245. package/core/dist/runtime/internalization/index.d.ts +2 -4
  246. package/core/dist/runtime/internalization/index.d.ts.map +1 -1
  247. package/core/dist/runtime/internalization/index.js +8 -1
  248. package/core/dist/runtime/internalization/index.js.map +1 -1
  249. package/core/dist/runtime/internalization/intake-to-internalization-bridge.d.ts +2 -1
  250. package/core/dist/runtime/internalization/intake-to-internalization-bridge.d.ts.map +1 -1
  251. package/core/dist/runtime/internalization/intent-contract.d.ts +2 -1
  252. package/core/dist/runtime/internalization/intent-contract.d.ts.map +1 -1
  253. package/core/dist/runtime/internalization/internalization-job-graph.d.ts +1 -1
  254. package/core/dist/runtime/internalization/internalization-job-graph.d.ts.map +1 -1
  255. package/core/dist/runtime/internalization/internalization-route.d.ts +2 -1
  256. package/core/dist/runtime/internalization/internalization-route.d.ts.map +1 -1
  257. package/core/dist/runtime/internalization/owner-decision-review.d.ts +3 -2
  258. package/core/dist/runtime/internalization/owner-decision-review.d.ts.map +1 -1
  259. package/core/dist/runtime/internalization/owner-resolution-service.d.ts +2 -1
  260. package/core/dist/runtime/internalization/owner-resolution-service.d.ts.map +1 -1
  261. package/core/dist/runtime/internalization/owner-retry.d.ts +2 -1
  262. package/core/dist/runtime/internalization/owner-retry.d.ts.map +1 -1
  263. package/core/dist/runtime/internalization/owner-review.d.ts +2 -21
  264. package/core/dist/runtime/internalization/owner-review.d.ts.map +1 -1
  265. package/core/dist/runtime/internalization/owner-review.js +2 -2
  266. package/core/dist/runtime/internalization/owner-review.js.map +1 -1
  267. package/core/dist/runtime/internalization/peer-runner-contracts.d.ts +2 -5
  268. package/core/dist/runtime/internalization/peer-runner-contracts.d.ts.map +1 -1
  269. package/core/dist/runtime/internalization/peer-runner-contracts.js +1 -1
  270. package/core/dist/runtime/internalization/peer-runner-contracts.js.map +1 -1
  271. package/core/dist/runtime/internalization/philosopher-output.d.ts +0 -8
  272. package/core/dist/runtime/internalization/philosopher-output.d.ts.map +1 -1
  273. package/core/dist/runtime/internalization/philosopher-output.js +1 -1
  274. package/core/dist/runtime/internalization/philosopher-output.js.map +1 -1
  275. package/core/dist/runtime/internalization/philosopher-prompt-builder.d.ts +3 -2
  276. package/core/dist/runtime/internalization/philosopher-prompt-builder.d.ts.map +1 -1
  277. package/core/dist/runtime/internalization/pitask-metadata.d.ts +2 -2
  278. package/core/dist/runtime/internalization/pitask-metadata.d.ts.map +1 -1
  279. package/core/dist/runtime/internalization/repair-replay-resolver.d.ts +4 -3
  280. package/core/dist/runtime/internalization/repair-replay-resolver.d.ts.map +1 -1
  281. package/core/dist/runtime/internalization/rollout-reviewer-output.d.ts +2 -3
  282. package/core/dist/runtime/internalization/rollout-reviewer-output.d.ts.map +1 -1
  283. package/core/dist/runtime/internalization/rollout-reviewer-output.js.map +1 -1
  284. package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.d.ts +0 -1
  285. package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.d.ts.map +1 -1
  286. package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.js +1 -1
  287. package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.js.map +1 -1
  288. package/core/dist/runtime/internalization/router-context-reconstruction.d.ts +3 -3
  289. package/core/dist/runtime/internalization/router-context-reconstruction.d.ts.map +1 -1
  290. package/core/dist/runtime/internalization/rule-activation-contract.d.ts +3 -2
  291. package/core/dist/runtime/internalization/rule-activation-contract.d.ts.map +1 -1
  292. package/core/dist/runtime/internalization/rule-reliability-validation.d.ts +13 -18
  293. package/core/dist/runtime/internalization/rule-reliability-validation.d.ts.map +1 -1
  294. package/core/dist/runtime/internalization/rule-reliability-validation.js +43 -1
  295. package/core/dist/runtime/internalization/rule-reliability-validation.js.map +1 -1
  296. package/core/dist/runtime/internalization/scribe-output.d.ts +2 -15
  297. package/core/dist/runtime/internalization/scribe-output.d.ts.map +1 -1
  298. package/core/dist/runtime/internalization/scribe-output.js +2 -2
  299. package/core/dist/runtime/internalization/scribe-output.js.map +1 -1
  300. package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts +3 -3
  301. package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts.map +1 -1
  302. package/core/dist/runtime/internalization/scribe-prompt-builder.js +0 -1
  303. package/core/dist/runtime/internalization/scribe-prompt-builder.js.map +1 -1
  304. package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts +17 -1
  305. package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts.map +1 -1
  306. package/core/dist/runtime/internalization/split-diagnostician-runner.js +98 -3
  307. package/core/dist/runtime/internalization/split-diagnostician-runner.js.map +1 -1
  308. package/core/dist/runtime/internalization/textual-basis-anchor.d.ts +3 -6
  309. package/core/dist/runtime/internalization/textual-basis-anchor.d.ts.map +1 -1
  310. package/core/dist/runtime/internalization/textual-basis-anchor.js +2 -2
  311. package/core/dist/runtime/internalization/textual-basis-anchor.js.map +1 -1
  312. package/core/dist/runtime/language-directive.d.ts +2 -1
  313. package/core/dist/runtime/language-directive.d.ts.map +1 -1
  314. package/core/dist/runtime/owner-decision/owner-decision-view-contract.d.ts +3 -29
  315. package/core/dist/runtime/owner-decision/owner-decision-view-contract.d.ts.map +1 -1
  316. package/core/dist/runtime/owner-decision/owner-decision-view-contract.js +4 -5
  317. package/core/dist/runtime/owner-decision/owner-decision-view-contract.js.map +1 -1
  318. package/core/dist/runtime/owner-decision/owner-decision-view.d.ts +0 -49
  319. package/core/dist/runtime/owner-decision/owner-decision-view.d.ts.map +1 -1
  320. package/core/dist/runtime/owner-decision/owner-decision-view.js +5 -5
  321. package/core/dist/runtime/owner-decision/owner-decision-view.js.map +1 -1
  322. package/core/dist/runtime/owner-decision/semantic-selector.d.ts +3 -2
  323. package/core/dist/runtime/owner-decision/semantic-selector.d.ts.map +1 -1
  324. package/core/dist/runtime/owner-identity.d.ts +12 -1
  325. package/core/dist/runtime/owner-identity.d.ts.map +1 -1
  326. package/core/dist/runtime/owner-identity.js +19 -1
  327. package/core/dist/runtime/owner-identity.js.map +1 -1
  328. package/core/dist/runtime/pain-ingress-payload.d.ts +0 -39
  329. package/core/dist/runtime/pain-ingress-payload.d.ts.map +1 -1
  330. package/core/dist/runtime/pain-ingress-payload.js +4 -4
  331. package/core/dist/runtime/pain-ingress-payload.js.map +1 -1
  332. package/core/dist/runtime/pain-ingress.d.ts +1 -1
  333. package/core/dist/runtime/pain-ingress.d.ts.map +1 -1
  334. package/core/dist/runtime/pain-ingress.js.map +1 -1
  335. package/core/dist/runtime/pain-signal-bridge.d.ts +0 -2
  336. package/core/dist/runtime/pain-signal-bridge.d.ts.map +1 -1
  337. package/core/dist/runtime/pain-signal-bridge.js +1 -1
  338. package/core/dist/runtime/pain-signal-bridge.js.map +1 -1
  339. package/core/dist/runtime/pain-signal-runtime-factory.d.ts +3 -3
  340. package/core/dist/runtime/pain-signal-runtime-factory.d.ts.map +1 -1
  341. package/core/dist/runtime/pain-signal-runtime-factory.js +1 -1
  342. package/core/dist/runtime/pain-signal-runtime-factory.js.map +1 -1
  343. package/core/dist/runtime/principle-reuse/reuse-proposal.d.ts +3 -2
  344. package/core/dist/runtime/principle-reuse/reuse-proposal.d.ts.map +1 -1
  345. package/core/dist/runtime/principle-reuse/reuse-retrieval.d.ts +0 -10
  346. package/core/dist/runtime/principle-reuse/reuse-retrieval.d.ts.map +1 -1
  347. package/core/dist/runtime/principle-reuse/reuse-retrieval.js +1 -1
  348. package/core/dist/runtime/principle-reuse/reuse-retrieval.js.map +1 -1
  349. package/core/dist/runtime/principle-reuse/reuse-shortlist.d.ts +1 -8
  350. package/core/dist/runtime/principle-reuse/reuse-shortlist.d.ts.map +1 -1
  351. package/core/dist/runtime/principle-reuse/reuse-shortlist.js +1 -1
  352. package/core/dist/runtime/principle-reuse/reuse-shortlist.js.map +1 -1
  353. package/core/dist/runtime/product-telemetry/snapshot-contract.d.ts +3 -2
  354. package/core/dist/runtime/product-telemetry/snapshot-contract.d.ts.map +1 -1
  355. package/core/dist/runtime/recovery-sweep-service.d.ts +7 -0
  356. package/core/dist/runtime/recovery-sweep-service.d.ts.map +1 -1
  357. package/core/dist/runtime/recovery-sweep-service.js +1 -0
  358. package/core/dist/runtime/recovery-sweep-service.js.map +1 -1
  359. package/core/dist/runtime/runner/base-peer-runner.d.ts +32 -0
  360. package/core/dist/runtime/runner/base-peer-runner.d.ts.map +1 -1
  361. package/core/dist/runtime/runner/base-peer-runner.js +168 -16
  362. package/core/dist/runtime/runner/base-peer-runner.js.map +1 -1
  363. package/core/dist/runtime/runner/default-validator.d.ts +0 -1
  364. package/core/dist/runtime/runner/default-validator.d.ts.map +1 -1
  365. package/core/dist/runtime/runner/default-validator.js +11 -3
  366. package/core/dist/runtime/runner/default-validator.js.map +1 -1
  367. package/core/dist/runtime/runner/peer-runner-types.d.ts +11 -0
  368. package/core/dist/runtime/runner/peer-runner-types.d.ts.map +1 -1
  369. package/core/dist/runtime/storage-paths.d.ts +15 -0
  370. package/core/dist/runtime/storage-paths.d.ts.map +1 -0
  371. package/core/dist/runtime/storage-paths.js +15 -0
  372. package/core/dist/runtime/storage-paths.js.map +1 -0
  373. package/core/dist/runtime/store/artifact/index.d.ts +1 -1
  374. package/core/dist/runtime/store/artifact/index.d.ts.map +1 -1
  375. package/core/dist/runtime/store/candidate/admission-document.d.ts +4 -3
  376. package/core/dist/runtime/store/candidate/admission-document.d.ts.map +1 -1
  377. package/core/dist/runtime/store/commit/index.d.ts +0 -1
  378. package/core/dist/runtime/store/commit/index.d.ts.map +1 -1
  379. package/core/dist/runtime/store/commit/index.js.map +1 -1
  380. package/core/dist/runtime/store/context/promoted-evidence-reader.d.ts +59 -0
  381. package/core/dist/runtime/store/context/promoted-evidence-reader.d.ts.map +1 -0
  382. package/core/dist/runtime/store/context/promoted-evidence-reader.js +201 -0
  383. package/core/dist/runtime/store/context/promoted-evidence-reader.js.map +1 -0
  384. package/core/dist/runtime/store/context/sqlite-context-assembler.d.ts.map +1 -1
  385. package/core/dist/runtime/store/context/sqlite-context-assembler.js +43 -2
  386. package/core/dist/runtime/store/context/sqlite-context-assembler.js.map +1 -1
  387. package/core/dist/runtime/store/design-gate/sqlite-design-gate-store.d.ts +4 -3
  388. package/core/dist/runtime/store/design-gate/sqlite-design-gate-store.d.ts.map +1 -1
  389. package/core/dist/runtime/store/lifecycle/lease-manager.d.ts +2 -1
  390. package/core/dist/runtime/store/lifecycle/lease-manager.d.ts.map +1 -1
  391. package/core/dist/runtime/store/runtime-state-manager.d.ts +1 -2
  392. package/core/dist/runtime/store/runtime-state-manager.d.ts.map +1 -1
  393. package/core/dist/runtime/store/runtime-state-manager.js.map +1 -1
  394. package/core/dist/runtime/store/sqlite-connection.d.ts +2 -1
  395. package/core/dist/runtime/store/sqlite-connection.d.ts.map +1 -1
  396. package/core/dist/runtime/store/sqlite-connection.js +96 -37
  397. package/core/dist/runtime/store/sqlite-connection.js.map +1 -1
  398. package/core/dist/runtime/store/task/sqlite-family-reopen.d.ts +2 -1
  399. package/core/dist/runtime/store/task/sqlite-family-reopen.d.ts.map +1 -1
  400. package/core/dist/runtime/store/task/sqlite-task-store.d.ts +2 -1
  401. package/core/dist/runtime/store/task/sqlite-task-store.d.ts.map +1 -1
  402. package/core/dist/runtime/story-a-demo.d.ts.map +1 -1
  403. package/core/dist/runtime/story-a-demo.js +4 -1
  404. package/core/dist/runtime/story-a-demo.js.map +1 -1
  405. package/core/dist/runtime/tools/agent-tool-contract.d.ts +1 -2
  406. package/core/dist/runtime/tools/agent-tool-contract.d.ts.map +1 -1
  407. package/core/dist/runtime/tools/agent-tool-contract.js +0 -2
  408. package/core/dist/runtime/tools/agent-tool-contract.js.map +1 -1
  409. package/core/dist/runtime/tools/artificer-l2-tool-contract.d.ts +0 -2
  410. package/core/dist/runtime/tools/artificer-l2-tool-contract.d.ts.map +1 -1
  411. package/core/dist/runtime/tools/artificer-l2-tool-contract.js +0 -2
  412. package/core/dist/runtime/tools/artificer-l2-tool-contract.js.map +1 -1
  413. package/core/dist/runtime/types/event-payload.d.ts +0 -2
  414. package/core/dist/runtime/types/event-payload.d.ts.map +1 -1
  415. package/core/dist/runtime/types/event-payload.js.map +1 -1
  416. package/core/dist/runtime/types/evidence-chain-contract.d.ts +66 -2
  417. package/core/dist/runtime/types/evidence-chain-contract.d.ts.map +1 -1
  418. package/core/dist/runtime/types/evidence-chain-contract.js +69 -4
  419. package/core/dist/runtime/types/evidence-chain-contract.js.map +1 -1
  420. package/core/dist/runtime/types/hygiene-types.d.ts +0 -6
  421. package/core/dist/runtime/types/hygiene-types.d.ts.map +1 -1
  422. package/core/dist/runtime/types/hygiene-types.js.map +1 -1
  423. package/core/dist/runtime/types/index.d.ts +1 -1
  424. package/core/dist/runtime/types/index.d.ts.map +1 -1
  425. package/core/dist/runtime/types/index.js.map +1 -1
  426. package/core/dist/runtime/types/intervention-evidence-contract.d.ts +5 -5
  427. package/core/dist/runtime/types/intervention-evidence-contract.d.ts.map +1 -1
  428. package/core/dist/runtime/types/intervention-evidence-contract.js +0 -2
  429. package/core/dist/runtime/types/intervention-evidence-contract.js.map +1 -1
  430. package/core/dist/runtime/types/principle-dependency.d.ts +0 -2
  431. package/core/dist/runtime/types/principle-dependency.d.ts.map +1 -1
  432. package/core/dist/runtime/types/principle-dependency.js.map +1 -1
  433. package/core/dist/runtime/types/principle-lifecycle-event.d.ts +0 -2
  434. package/core/dist/runtime/types/principle-lifecycle-event.d.ts.map +1 -1
  435. package/core/dist/runtime/types/principle-lifecycle-event.js.map +1 -1
  436. package/core/dist/runtime/types/principle-schema.d.ts +0 -26
  437. package/core/dist/runtime/types/principle-schema.d.ts.map +1 -1
  438. package/core/dist/runtime/types/principle-schema.js +2 -2
  439. package/core/dist/runtime/types/principle-schema.js.map +1 -1
  440. package/core/dist/runtime/types/principle-tree-store.d.ts +0 -2
  441. package/core/dist/runtime/types/principle-tree-store.d.ts.map +1 -1
  442. package/core/dist/runtime/types/principle-tree-store.js.map +1 -1
  443. package/core/dist/runtime/types/principle-value-metrics.d.ts +0 -2
  444. package/core/dist/runtime/types/principle-value-metrics.d.ts.map +1 -1
  445. package/core/dist/runtime/types/principle-value-metrics.js.map +1 -1
  446. package/core/dist/runtime/types/rule-candidate-binding.d.ts +2 -1
  447. package/core/dist/runtime/types/rule-candidate-binding.d.ts.map +1 -1
  448. package/core/dist/telemetry-event.d.ts +2 -2
  449. package/core/dist/telemetry-event.d.ts.map +1 -1
  450. package/core/dist/telemetry-event.js +11 -0
  451. package/core/dist/telemetry-event.js.map +1 -1
  452. package/core/package.json +5 -1
  453. package/dist/installer.d.ts +14 -0
  454. package/dist/installer.d.ts.map +1 -1
  455. package/dist/installer.js +36 -77
  456. package/dist/installer.js.map +1 -1
  457. package/dist/installers/codex-host-installer.d.ts +9 -0
  458. package/dist/installers/codex-host-installer.d.ts.map +1 -1
  459. package/dist/installers/codex-host-installer.js +35 -1
  460. package/dist/installers/codex-host-installer.js.map +1 -1
  461. package/dist/mvp-config.js +1 -1
  462. package/dist/mvp-config.js.map +1 -1
  463. package/dist/update/data-compatibility.d.ts.map +1 -1
  464. package/dist/update/data-compatibility.js +3 -1
  465. package/dist/update/data-compatibility.js.map +1 -1
  466. package/dist/update/product-identity.d.ts.map +1 -1
  467. package/dist/update/product-identity.js +5 -1
  468. package/dist/update/product-identity.js.map +1 -1
  469. package/dist/update/release-manager.d.ts +5 -0
  470. package/dist/update/release-manager.d.ts.map +1 -1
  471. package/dist/update/release-manager.js +11 -1
  472. package/dist/update/release-manager.js.map +1 -1
  473. package/host-runtime/dist/active-principle-prompt.d.ts +7 -2
  474. package/host-runtime/dist/active-principle-prompt.js +80 -13
  475. package/host-runtime/dist/adaptive-decision-protocol.d.ts +36 -21
  476. package/host-runtime/dist/adaptive-decision-protocol.js +79 -34
  477. package/host-runtime/dist/adaptive-priority-provider.d.ts +2 -1
  478. package/host-runtime/dist/adaptive-priority-provider.js +6 -5
  479. package/host-runtime/dist/adaptive-selection.d.ts +4 -0
  480. package/host-runtime/dist/adaptive-selection.js +12 -4
  481. package/host-runtime/dist/cli-recovery-probe.d.ts +42 -1
  482. package/host-runtime/dist/cli-recovery-probe.js +16 -3
  483. package/host-runtime/dist/codex-disclosure.d.ts +12 -7
  484. package/host-runtime/dist/codex-disclosure.js +12 -7
  485. package/host-runtime/dist/conversation-ingestion/pipeline.d.ts +8 -29
  486. package/host-runtime/dist/conversation-ingestion/pipeline.js +45 -3
  487. package/host-runtime/dist/conversation-ingestion/text-policy.d.ts +3 -4
  488. package/host-runtime/dist/conversation-ingestion/text-policy.js +3 -4
  489. package/host-runtime/dist/governance-observation-store.d.ts +38 -5
  490. package/host-runtime/dist/governance-observation-store.js +63 -5
  491. package/host-runtime/dist/index.js +5 -2
  492. package/host-runtime/dist/production-rulehost-gate.d.ts +36 -1
  493. package/host-runtime/dist/production-rulehost-gate.js +91 -1
  494. package/host-runtime/package.json +1 -1
  495. package/package.json +2 -2
  496. package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
  497. package/pd-cli/dist/commands/candidate.js +117 -3
  498. package/pd-cli/dist/commands/candidate.js.map +1 -1
  499. package/pd-cli/dist/commands/console.d.ts +0 -4
  500. package/pd-cli/dist/commands/console.d.ts.map +1 -1
  501. package/pd-cli/dist/commands/console.js +4 -67
  502. package/pd-cli/dist/commands/console.js.map +1 -1
  503. package/pd-cli/dist/commands/diagnose.js +1 -1
  504. package/pd-cli/dist/commands/diagnose.js.map +1 -1
  505. package/pd-cli/dist/commands/health-ingestion.d.ts +96 -0
  506. package/pd-cli/dist/commands/health-ingestion.d.ts.map +1 -0
  507. package/pd-cli/dist/commands/health-ingestion.js +473 -0
  508. package/pd-cli/dist/commands/health-ingestion.js.map +1 -0
  509. package/pd-cli/dist/commands/health.d.ts.map +1 -1
  510. package/pd-cli/dist/commands/health.js +10 -0
  511. package/pd-cli/dist/commands/health.js.map +1 -1
  512. package/pd-cli/dist/commands/runtime-activation.d.ts.map +1 -1
  513. package/pd-cli/dist/commands/runtime-activation.js +4 -8
  514. package/pd-cli/dist/commands/runtime-activation.js.map +1 -1
  515. package/pd-cli/dist/commands/runtime-recovery-failed-tasks.d.ts.map +1 -1
  516. package/pd-cli/dist/commands/runtime-recovery-failed-tasks.js +114 -63
  517. package/pd-cli/dist/commands/runtime-recovery-failed-tasks.js.map +1 -1
  518. package/pd-cli/dist/program.d.ts.map +1 -1
  519. package/pd-cli/dist/program.js +0 -8
  520. package/pd-cli/dist/program.js.map +1 -1
  521. package/pd-cli/dist/services/console-launcher.d.ts +1 -18
  522. package/pd-cli/dist/services/console-launcher.d.ts.map +1 -1
  523. package/pd-cli/dist/services/console-launcher.js +4 -92
  524. package/pd-cli/dist/services/console-launcher.js.map +1 -1
  525. package/pd-cli/dist/services/demo-story-a-runner.js +1 -1
  526. package/pd-cli/dist/services/demo-story-a-runner.js.map +1 -1
  527. package/pd-cli/dist/services/version-report.d.ts.map +1 -1
  528. package/pd-cli/dist/services/version-report.js +5 -1
  529. package/pd-cli/dist/services/version-report.js.map +1 -1
  530. package/pd-cli/package.json +1 -1
  531. package/plugin/dist/bundle.js +562 -534
  532. package/plugin/dist/core/experiment-workspace-guard.d.ts +25 -0
  533. package/plugin/dist/index.d.ts +1 -1
  534. package/plugin/dist/openclaw.plugin.json +1 -1
  535. package/plugin/openclaw.plugin.json +1 -1
  536. package/plugin/package.json +1 -1
  537. package/release-manager/dist/installer.js +36 -77
  538. package/release-manager/dist/installers/codex-host-installer.js +35 -1
  539. package/release-manager/dist/mvp-config.js +1 -1
  540. package/release-manager/dist/update/product-identity.js +5 -1
  541. package/release-manager/dist/update/release-manager.js +11 -1
  542. package/release-manager/package.json +1 -1
  543. package/workbuddy-adapter/dist/index.d.ts +1 -1
  544. package/workbuddy-adapter/dist/index.js +1 -1
  545. package/workbuddy-adapter/dist/ingestion/catch-up.d.ts +11 -0
  546. package/workbuddy-adapter/dist/ingestion/catch-up.js +7 -2
  547. package/workbuddy-adapter/dist/ingestion/index.d.ts +1 -1
  548. package/workbuddy-adapter/dist/ingestion/index.js +1 -1
  549. package/workbuddy-adapter/package.json +1 -1
  550. package/console/dist/server/config/AuthConfig.d.ts +0 -14
  551. package/console/dist/server/config/AuthConfig.js +0 -42
@@ -5,9 +5,9 @@ import { fileURLToPath, pathToFileURL } from 'url';
5
5
  import { resolveApplyFullTimeoutMs, resolveCheckTimeoutMs } from './update-timeout.js';
6
6
  import { loadPdConfig, computeFlagsFromLoadResult, getFeedbackMaintainerEmail, getFeedbackChannelConfig, } from './config/pd-config-store.js';
7
7
  import { resolveOwnerIdentity, defaultOwnerIdentityHomeDir } from '@principles/core/runtime';
8
- import { createProductTelemetryService, scheduleProductTelemetryExport } from '@principles/host-runtime';
9
- import { AuthConfig } from './config/AuthConfig.js';
10
- import { assertLoopbackBindForUnauthenticatedServer } from './bind-guard.js';
8
+ import { createProductTelemetryService, scheduleProductTelemetryExport, CONSOLE_REQUEST_BUDGET_MS } from '@principles/host-runtime';
9
+ import { assertLoopbackBind } from './bind-guard.js';
10
+ import { guardConsoleApiRequest } from './utils/request-guard.js';
11
11
  import { WorkspaceConfigStore } from './config/WorkspaceConfigStore.js';
12
12
  import { getPdHome, PdHomeConfigurationError } from './utils/pd-home.js';
13
13
  import { EXPERIMENT_CONSOLE_PORT, defaultConsolePort } from './console-ports.js';
@@ -16,7 +16,7 @@ import { handleFeedbackReportsRoute, handleFeedbackChannelsRoute, disposeFeedbac
16
16
  import { handleFailedTasksRoute, disposeFailedTasksModels } from './routes/failed-tasks.js';
17
17
  import { handleDiagnosticianRoute } from './routes/diagnostician.js';
18
18
  import { handleApprovalsRoute, disposeApprovalsModels } from './routes/approvals.js';
19
- import { handleHealthRoute, disposeHealthModels } from './routes/health.js';
19
+ import { handleHealthRoute, handleIngestionHealthRoute, disposeHealthModels } from './routes/health.js';
20
20
  import { handlePrinciplesRoute, handleCorePrinciplesRoute, disposePrinciplesModels } from './routes/principles.js';
21
21
  import { handleLifecycleRoute, disposeLifecycleModels } from './routes/lifecycle.js';
22
22
  import { handleExaminerRoute } from './routes/examiner.js';
@@ -40,7 +40,7 @@ import { handleUpdateRoute } from './routes/update.js';
40
40
  import { handleUpdateHistoryRoute, reconcileUpdateHistoryFromJournals } from './routes/update-history.js';
41
41
  import { handleUpdateTransactionRoute } from './routes/update-transaction.js';
42
42
  import { handleConfigRoute } from './routes/config.js';
43
- import { sendJson, sendNotFound, sendUnauthorized } from './utils/response.js';
43
+ import { sendJson, sendNotFound, sendError } from './utils/response.js';
44
44
  import { migrateLegacyExtensionBackups, resolvePdBackupsRoot } from './utils/pd-backups.js';
45
45
  const __filename = fileURLToPath(import.meta.url);
46
46
  const __dirname = path.dirname(__filename);
@@ -104,8 +104,6 @@ function parseArgs(argv, mode = 'production') {
104
104
  // 13100 so a bare dev start cannot grab the production port. --port wins.
105
105
  let port = defaultConsolePort(mode);
106
106
  let host = '127.0.0.1';
107
- let noAuth = false;
108
- let token = undefined;
109
107
  for (let i = 0; i < args.length; i++) {
110
108
  if (args[i] === '--port' && i + 1 < args.length) {
111
109
  const portStr = args[i + 1];
@@ -126,22 +124,26 @@ function parseArgs(argv, mode = 'production') {
126
124
  i++;
127
125
  }
128
126
  }
129
- else if (args[i] === '--no-auth') {
130
- noAuth = true;
131
- }
132
- else if (args[i] === '--token' && i + 1 < args.length) {
133
- const next = args[i + 1];
134
- if (next !== undefined) {
135
- token = next;
136
- i++;
137
- }
138
- }
139
127
  }
140
- if (noAuth && host !== '127.0.0.1' && host !== 'localhost') {
141
- console.error('[pd-console] --no-auth is only allowed with loopback binding (127.0.0.1 or localhost). Got --host ' + host);
142
- process.exit(1);
128
+ return { workspace, port, host };
129
+ }
130
+ /**
131
+ * The Console has no application-level credential any more. Old launchers,
132
+ * shell profiles and scripts may still pass `--token` / `--no-auth`; they are
133
+ * ignored (unknown args never failed parsing) but the operator gets one line
134
+ * explaining why their secret no longer does anything.
135
+ */
136
+ export function warnAboutLegacyAuthArgs(argv) {
137
+ const args = argv.slice(2);
138
+ if (args.includes('--token')) {
139
+ console.warn('[pd-console] --token is no longer used: the Console has no token authentication. The value is ignored.');
140
+ }
141
+ if (args.includes('--no-auth')) {
142
+ console.warn('[pd-console] --no-auth is no longer needed: the Console never requires authentication. The flag is ignored.');
143
+ }
144
+ if (process.env.PD_CONSOLE_TOKEN && process.env.PD_CONSOLE_TOKEN.length > 0) {
145
+ console.warn('[pd-console] PD_CONSOLE_TOKEN is no longer used: the Console has no token authentication. The value is ignored.');
143
146
  }
144
- return { workspace, port, host, noAuth, token };
145
147
  }
146
148
  // ── MIME type helpers ──────────────────────────────────────────────────────────────────────
147
149
  const MIME_MAP = {
@@ -181,6 +183,10 @@ function serveFile(res, filePath) {
181
183
  res.writeHead(200, {
182
184
  'Content-Type': contentType,
183
185
  'Content-Length': data.length,
186
+ // The Console is fully usable without a login now, so a hostile page
187
+ // must not be able to frame it and harvest clicks.
188
+ 'X-Frame-Options': 'DENY',
189
+ 'X-Content-Type-Options': 'nosniff',
184
190
  });
185
191
  res.end(data);
186
192
  return true;
@@ -190,7 +196,10 @@ function serveFile(res, filePath) {
190
196
  }
191
197
  }
192
198
  // ── Async handler wrapper ──────────────────────────────────────────────────────────────
193
- const REQUEST_TIMEOUT_MS = 10000;
199
+ // PRI-1202: this is the single budget authority. host-runtime derives the CLI
200
+ // recovery probe budget from the same constant (strictly smaller), so a probe
201
+ // can never outlive the request that awaits it.
202
+ export const REQUEST_TIMEOUT_MS = CONSOLE_REQUEST_BUDGET_MS;
194
203
  const UPDATE_APPLY_TIMEOUT_MS = 120000;
195
204
  // Full update downloads a tarball + copies files — allow 3 min for slow networks.
196
205
  // PD_UPDATE_APPLY_FULL_TIMEOUT_MS (ms) overrides it for slow-disk machines:
@@ -239,7 +248,7 @@ function asyncHandler(fn, timeoutMs = REQUEST_TIMEOUT_MS) {
239
248
  });
240
249
  };
241
250
  }
242
- export async function initServices(workspaceDir, authConfig) {
251
+ export async function initServices(workspaceDir) {
243
252
  const configStore = new WorkspaceConfigStore();
244
253
  const workspaceService = new WorkspaceService(configStore);
245
254
  // Load feature flags from canonical .pd/config.yaml — fail-closed: on error, feedback_channel uses defaults
@@ -289,7 +298,6 @@ export async function initServices(workspaceDir, authConfig) {
289
298
  const feedbackChannelConfig = getFeedbackChannelConfig(workspaceDir);
290
299
  return {
291
300
  workspaceDir,
292
- authConfig,
293
301
  configStore,
294
302
  workspaceService,
295
303
  feedbackFlags,
@@ -339,10 +347,13 @@ export function handleRequest(services) {
339
347
  }
340
348
  return;
341
349
  }
342
- // Auth check for all /api/* routes
350
+ // Origin/Host guard for all /api/* routes. The console has no credential;
351
+ // this is what keeps other browser origins (and DNS rebinding) out while
352
+ // letting local non-browser clients through.
343
353
  if (urlPath.startsWith('/api/')) {
344
- if (!services.authConfig.isAuthenticated(req)) {
345
- sendUnauthorized(res);
354
+ const rejection = guardConsoleApiRequest(req);
355
+ if (rejection !== null) {
356
+ sendError(res, rejection.status, rejection.error, rejection.message, { nextAction: rejection.nextAction });
346
357
  return;
347
358
  }
348
359
  // ── API routes ──────────────────────────────────────────────────
@@ -496,8 +507,10 @@ export function handleRequest(services) {
496
507
  const subPath = routePath.slice('/api/activations'.length);
497
508
  // ADR-0022 (PRI-578): single resolver — env > ~/.pd/owner.json > none
498
509
  const identity = resolveOwnerIdentity(process.env, defaultOwnerIdentityHomeDir());
499
- const ownerActor = services.authConfig.isEnabled() && identity.ownerId && identity.credentialId
500
- ? { principal: { kind: 'configured_owner', ownerId: identity.ownerId }, authentication: { method: 'console_token', credentialId: identity.credentialId } }
510
+ // The OS session is the credential now: a registered Owner identity is
511
+ // enough to act as the configured Owner from the local Console.
512
+ const ownerActor = identity.ownerId && identity.credentialId
513
+ ? { principal: { kind: 'configured_owner', ownerId: identity.ownerId }, authentication: { method: 'local_owner_session', credentialId: identity.credentialId } }
501
514
  : null;
502
515
  asyncHandler(() => handleActivationsRoute(req, res, services.workspaceDir, subPath, {
503
516
  ownerActor,
@@ -508,7 +521,7 @@ export function handleRequest(services) {
508
521
  // ADR-0022 (PRI-578): /api/owner-identity — GET status, POST register, DELETE unregister
509
522
  if (routePath === '/api/owner-identity' || routePath.startsWith('/api/owner-identity/')) {
510
523
  const subPath = routePath.slice('/api/owner-identity'.length);
511
- asyncHandler(() => handleOwnerIdentityRoute(req, res, defaultOwnerIdentityHomeDir(), subPath, services.authConfig))(req, res);
524
+ asyncHandler(() => handleOwnerIdentityRoute(req, res, defaultOwnerIdentityHomeDir(), subPath))(req, res);
512
525
  return;
513
526
  }
514
527
  // PRI-585: GET /api/governance/experience (flag-gated read-only snapshot)
@@ -516,7 +529,7 @@ export function handleRequest(services) {
516
529
  asyncHandler(() => handleGovernanceExperienceRoute(req, res, {
517
530
  workspaceDir: services.workspaceDir,
518
531
  featureFlags: services.feedbackFlags,
519
- ownerConfig: resolveOwnerConfigSnapshot(services.authConfig, resolveOwnerIdentity(process.env, defaultOwnerIdentityHomeDir())),
532
+ ownerConfig: resolveOwnerConfigSnapshot(resolveOwnerIdentity(process.env, defaultOwnerIdentityHomeDir())),
520
533
  }))(req, res);
521
534
  return;
522
535
  }
@@ -530,7 +543,7 @@ export function handleRequest(services) {
530
543
  asyncHandler(() => handleRuleCandidateBindingsRoute(req, res, {
531
544
  workspaceDir: services.workspaceDir,
532
545
  subPath: routePath.slice('/api/governance/rule-candidate-bindings'.length),
533
- ownerIdentity: services.authConfig.isEnabled() && ownerId !== null && credentialId !== null
546
+ ownerIdentity: ownerId !== null && credentialId !== null
534
547
  ? { ownerId, credentialId } : null,
535
548
  }))(req, res);
536
549
  return;
@@ -542,8 +555,7 @@ export function handleRequest(services) {
542
555
  const subPath = routePath.slice('/api/governance/owner-decisions'.length);
543
556
  const odIdentity = resolveOwnerIdentity(process.env, defaultOwnerIdentityHomeDir());
544
557
  const { ownerId, credentialId } = odIdentity;
545
- const authEnabledForOwner = services.authConfig.isEnabled()
546
- && ownerId !== null && credentialId !== null;
558
+ const authEnabledForOwner = ownerId !== null && credentialId !== null;
547
559
  asyncHandler(() => handleOwnerDecisionsRoute(req, res, {
548
560
  workspaceDir: services.workspaceDir,
549
561
  subPath,
@@ -559,7 +571,7 @@ export function handleRequest(services) {
559
571
  asyncHandler(() => handleDesignGateRoute(req, res, {
560
572
  workspaceDir: services.workspaceDir,
561
573
  subPath: routePath.slice('/api/governance/design-gate'.length),
562
- ownerIdentity: services.authConfig.isEnabled() && ownerId !== null && credentialId !== null
574
+ ownerIdentity: ownerId !== null && credentialId !== null
563
575
  ? { ownerId, credentialId } : null,
564
576
  }))(req, res);
565
577
  return;
@@ -584,7 +596,8 @@ export function handleRequest(services) {
584
596
  return;
585
597
  }
586
598
  // PRI-331: GET /api/evidence-chain
587
- if (routePath === '/api/evidence-chain') {
599
+ // P1-2: GET /api/evidence-chain/assistant-turn?id=&session= (verbatim turn)
600
+ if (routePath === '/api/evidence-chain' || routePath === '/api/evidence-chain/assistant-turn') {
588
601
  asyncHandler(() => handleEvidenceChainRoute(req, res, services.workspaceDir))(req, res);
589
602
  return;
590
603
  }
@@ -595,8 +608,7 @@ export function handleRequest(services) {
595
608
  if (routePath === '/api/evidence/outcomes') {
596
609
  const eoIdentity = resolveOwnerIdentity(process.env, defaultOwnerIdentityHomeDir());
597
610
  const { ownerId, credentialId } = eoIdentity;
598
- const authEnabledForOwner = services.authConfig.isEnabled()
599
- && ownerId !== null && credentialId !== null;
611
+ const authEnabledForOwner = ownerId !== null && credentialId !== null;
600
612
  asyncHandler(() => handleEvidenceOutcomesRoute(req, res, {
601
613
  workspaceDir: services.workspaceDir,
602
614
  ownerIdentity: authEnabledForOwner
@@ -609,10 +621,21 @@ export function handleRequest(services) {
609
621
  if (routePath === '/api/health') {
610
622
  asyncHandler(() => handleHealthRoute(req, res, {
611
623
  workspaceDir: services.workspaceDir,
612
- authenticationMode: services.authConfig.isEnabled() ? 'authenticated' : 'no_auth',
624
+ authenticationMode: 'no_auth',
613
625
  }))(req, res);
614
626
  return;
615
627
  }
628
+ // GET /api/health/ingestion — PRI-1171 ticket ⑦: unified three-host
629
+ // conversation-ingestion health (verbatim CLI passthrough, read-only
630
+ // status, never trajectory browsing). The route budget must COVER the
631
+ // model's 30s CLI subprocess timeout — a 504 from the default timeout
632
+ // would render "unable to determine" while the CLI is still working.
633
+ if (routePath === '/api/health/ingestion') {
634
+ asyncHandler(() => handleIngestionHealthRoute(req, res, {
635
+ workspaceDir: services.workspaceDir,
636
+ }), 45_000)(req, res);
637
+ return;
638
+ }
616
639
  // 404 fallback for API routes
617
640
  sendNotFound(res, `Route ${routePath} not found`);
618
641
  return;
@@ -643,7 +666,8 @@ export async function main() {
643
666
  }
644
667
  throw error;
645
668
  }
646
- const { workspace, port, host, noAuth, token } = parseArgs(process.argv, pdHome.mode);
669
+ const { workspace, port, host } = parseArgs(process.argv, pdHome.mode);
670
+ warnAboutLegacyAuthArgs(process.argv);
647
671
  if (pdHome.mode === 'experiment') {
648
672
  console.log(`[pd-console] Environment: experiment (PD_EXPERIMENT_ROOT=${pdHome.experimentRoot ?? ''})`);
649
673
  console.log(`[pd-console] PD home: ${pdHome.pdHome}`);
@@ -653,20 +677,10 @@ export async function main() {
653
677
  else {
654
678
  console.log(`[pd-console] Environment: production (PD home: ${pdHome.pdHome})`);
655
679
  }
656
- const authConfig = new AuthConfig({
657
- cliToken: token,
658
- envToken: process.env.PD_CONSOLE_TOKEN,
659
- noAuth,
660
- });
661
- if (!authConfig.isEnabled() && !noAuth) {
662
- console.warn('[pd-console] No auth token configured. Running without authentication. Use --token or PD_CONSOLE_TOKEN to enable.');
663
- }
664
- // Authentication disabled (explicit --no-auth or the token-less default)
665
- // must never bind a non-loopback interface: every /api/* route would be
666
- // reachable by unauthenticated network peers. parseArgs already restricts
667
- // the explicit --no-auth flag; this is the effective-auth-state guard.
668
- assertLoopbackBindForUnauthenticatedServer(authConfig.isEnabled(), host);
669
- const services = await initServices(workspace, authConfig);
680
+ // The OS session is the trust boundary: the Console never has an
681
+ // application-level credential, so it must never be reachable off-machine.
682
+ assertLoopbackBind(host);
683
+ const services = await initServices(workspace);
670
684
  // One-time hygiene: move legacy PD backups out of ~/.openclaw/extensions so
671
685
  // OpenClaw plugin discovery stops reporting a duplicate principles-disciple
672
686
  // plugin on every gateway startup. Best-effort, never blocks startup.
@@ -715,7 +729,7 @@ export async function main() {
715
729
  server.listen(port, host, () => {
716
730
  console.log('[pd-console] Listening on http://' + host + ':' + port);
717
731
  console.log('[pd-console] Workspace: ' + workspace);
718
- console.log('[pd-console] Auth: ' + (authConfig.isEnabled() ? 'enabled' : 'disabled'));
732
+ console.log('[pd-console] Auth: none (local OS session)');
719
733
  });
720
734
  }
721
735
  // cli-7 / PRI-892 precedent: importing this module (a test driving
@@ -1,4 +1,5 @@
1
1
  import { SqliteConnection, SqliteActivationStateStore, SqlitePIArtifactStore, extractPrincipleId, extractEvidenceRefs, PromotionReadinessReader, RuleHostWriter, createProductionGateDeps, SqliteActivationSafetyStore, isFeatureEnabled, RuleCodeOwnerDecisionService, collectOpenClawPromotionChecks, summarizeRuleCodeShadowEvents, buildPromotionEvidenceSnapshot, createRuntimeStateHandle, PrincipleTreeLedgerAdapter, previewApprovedRuleRevision, reviseApprovedRuleOnce, } from '@principles/core/runtime';
2
+ import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
2
3
  import { resolvePromotionHostLiveness, resolveWorkspaceHostToolSemantics, readPromptActivationInjectionStatuses, operatorDeclaredBudgetResolution, runtimeBudgetObservationToResolution, selectConsoleRuntimeBudgetFacts, productionRouteRotationState, RUNTIME_BUDGET_OBSERVATION_STALE_REASON, RUNTIME_EVENT_LOG_CANDIDATE_DIRS, collectRuleCodeEventEntries } from '@principles/host-runtime';
3
4
  import { PROMPT_BUDGET_HOST_KINDS } from '@principles/core/runtime';
4
5
  import { loadPdConfig, computeFlagsFromLoadResult } from '../config/pd-config-store.js';
@@ -155,7 +156,7 @@ export class ActivationsConsoleModel {
155
156
  }
156
157
  }
157
158
  async getActivations(targetHost) {
158
- const stateDbPath = path.join(this.workspaceDir, '.pd', 'state.db');
159
+ const stateDbPath = resolveStateDbPath(this.workspaceDir);
159
160
  if (!fs.existsSync(stateDbPath)) {
160
161
  return { activations: [], status: 'degraded', reason: 'state.db not found — workspace may not be initialized', nextAction: 'Run pd runtime diagnostics to check workspace state' };
161
162
  }
@@ -705,7 +706,8 @@ export class ActivationsConsoleModel {
705
706
  }
706
707
  }
707
708
  async promoteRuleCode(activationId, expected, input) {
708
- const review = await this.getOwnerReview(activationId, input.actor.principal.kind === 'configured_owner' && input.actor.authentication.method === 'console_token', { ownerActor: input.actor, routeContext: input.routeContext });
709
+ const review = await this.getOwnerReview(activationId, input.actor.principal.kind === 'configured_owner'
710
+ && (input.actor.authentication.method === 'console_token' || input.actor.authentication.method === 'local_owner_session'), { ownerActor: input.actor, routeContext: input.routeContext });
709
711
  const flags = computeFlagsFromLoadResult(loadPdConfig(this.workspaceDir));
710
712
  const conn = new SqliteConnection({ workspaceDir: this.workspaceDir, readonly: false });
711
713
  try {
@@ -809,7 +811,7 @@ export class ActivationsConsoleModel {
809
811
  throw new Error('feature_not_enabled: enable rulecode_owner_live_decision only after the rollout gate passes');
810
812
  }
811
813
  async deactivateActivation(activationId) {
812
- const stateDbPath = path.join(this.workspaceDir, '.pd', 'state.db');
814
+ const stateDbPath = resolveStateDbPath(this.workspaceDir);
813
815
  if (!fs.existsSync(stateDbPath)) {
814
816
  return { ok: false, reason: 'state.db not found — workspace may not be initialized', nextAction: 'Ensure the workspace has been initialized with PD before disabling activations.' };
815
817
  }
@@ -3,6 +3,7 @@ import { approvalReviewMaterial } from './approval-review-material.js';
3
3
  import * as fs from 'node:fs';
4
4
  import * as path from 'node:path';
5
5
  import { SqliteConnection, SqliteApprovalQueueStore, SqliteActivationStateStore, SqlitePIArtifactStore, ActivationDispatcher, PromptWriter, DeferArchiveWriter, RuleHostWriter, createProductionGateDeps, ApprovalCompletionService, ApprovalQueue, mapConfidenceToLabel, isArtifactRevisionOf, detectPromptReplacementTarget, detectRuleReplacementTarget, buildOwnerRevisionArtifact, PrincipleTreeLedgerAdapter, MVP_CHANNELS, computeArtifactDigest, } from '@principles/core/runtime';
6
+ import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
6
7
  import { resolveLedgerPrincipleId } from './principle-id-resolution.js';
7
8
  import { createArtifactPrincipleResolutionDeps } from './artifact-principle-resolver.js';
8
9
  import { loadPdConfig, computeFlagsFromLoadResult } from '../config/pd-config-store.js';
@@ -49,7 +50,7 @@ function describeBudgetBasis(hostKind, facts, declared) {
49
50
  return `budget basis=fixed_fallback (no runtime budget observation for ${hostKind})`;
50
51
  }
51
52
  function stateDbExists(workspaceDir) {
52
- return fs.existsSync(path.join(workspaceDir, '.pd', 'state.db'));
53
+ return fs.existsSync(resolveStateDbPath(workspaceDir));
53
54
  }
54
55
  export class ApprovalsConsoleModel {
55
56
  workspaceDir;
@@ -1,4 +1,5 @@
1
1
  import { SqliteConnection, SqliteApprovalQueueStore, SqlitePIArtifactStore, ApprovalQueue, RUNTIME_PRINCIPLE_BUDGET, detectPromptReplacementTarget, computeArtifactDigest, SqliteActivationStateStore, } from '@principles/core/runtime';
2
+ import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
2
3
  import { checkPromptArtifactDeliverability, hostRotationCapability, operatorDeclaredBudgetResolution, resolveLivePromptInjectionProjection, RUNTIME_BUDGET_OBSERVATION_STALE_REASON, runtimeBudgetObservationToResolution, selectConsoleRuntimeBudgetFacts, } from '@principles/host-runtime';
3
4
  import { PROMPT_BUDGET_HOST_KINDS } from '@principles/core/runtime';
4
5
  import { loadLedger } from '@principles/core/principle-tree-ledger';
@@ -167,7 +168,7 @@ export class ApprovalsGroupedConsoleModel {
167
168
  this.workspaceDir = workspaceDir;
168
169
  }
169
170
  async getApprovalsGrouped(targetHost) {
170
- const stateDbPath = path.join(this.workspaceDir, '.pd', 'state.db');
171
+ const stateDbPath = resolveStateDbPath(this.workspaceDir);
171
172
  if (!fs.existsSync(stateDbPath)) {
172
173
  return { groups: [], generatedAt: new Date().toISOString(), note: 'state.db not found — workspace may not be initialized' };
173
174
  }
@@ -15,6 +15,11 @@
15
15
  * - All summaries go through sanitizeString from evidence-sanitizer
16
16
  * - Degraded paths include structured reason + nextAction (ERR-002)
17
17
  *
18
+ * P1-2 exception: `getAssistantTurn()` returns ONE referenced assistant turn
19
+ * verbatim, on purpose — the Owner must be able to compare the recorded
20
+ * correction against exactly what the agent said. It is bounded to the turn id
21
+ * recorded in correction evidence and pinned to that turn's session.
22
+ *
18
23
  * ERR checklist:
19
24
  * - ERR-001/005: All DB rows treated as unknown, runtime validation with typeof guards
20
25
  * - ERR-002: Degraded paths include reason + nextAction, never silent fallback
@@ -24,9 +29,50 @@
24
29
  */
25
30
  import type { EvidenceChainState, EvidenceChainRecord, EvidenceChainResponse } from '@principles/core/runtime';
26
31
  export type { EvidenceChainState, EvidenceChainRecord, EvidenceChainResponse, };
32
+ /**
33
+ * P1-2: verbatim assistant output referenced by a correction record.
34
+ *
35
+ * This is the ONE place raw assistant text is returned to the Owner. It is not
36
+ * sanitized on purpose: the Owner must be able to compare the correction text
37
+ * with exactly what the agent said. Access is by turn id, optionally pinned to
38
+ * the session id recorded in the correction evidence, so a record can never
39
+ * pull an unrelated conversation.
40
+ */
41
+ export interface AssistantTurnLookup {
42
+ ok: true;
43
+ turn: {
44
+ id: number;
45
+ sessionId: string;
46
+ /** Verbatim assistant output (newlines, spaces and markdown preserved). */
47
+ text: string;
48
+ /**
49
+ * `raw` when the original text was persisted inline or in the overflow
50
+ * blob; `sanitized` when only the redacted copy survives (retention or
51
+ * write-path policy). The UI must label which one the Owner is reading.
52
+ */
53
+ textSource: 'raw' | 'sanitized';
54
+ createdAt: string;
55
+ };
56
+ }
57
+ export interface AssistantTurnLookupFailure {
58
+ ok: false;
59
+ reason: string;
60
+ nextAction: string;
61
+ }
27
62
  export declare class EvidenceChainConsoleModel {
28
63
  private readonly workspaceDir;
29
64
  constructor(workspaceDir: string);
30
65
  getEvidenceChain(): Promise<EvidenceChainResponse>;
66
+ /**
67
+ * P1-2: read the raw assistant turn referenced by correction evidence.
68
+ * Verbatim by contract — no sanitization, no markdown rendering.
69
+ *
70
+ * Uses the registered trajectory-store seam (`openTrajectoryDbReadonly`) so
71
+ * the read-only + path-contract rules have a single owner. The overflow blob
72
+ * directory is derived from the trajectory database location, never
73
+ * hardcoded, and a blob reference is confined to that directory before it is
74
+ * read.
75
+ */
76
+ getAssistantTurn(turnId: number, expectedSessionId?: string): Promise<AssistantTurnLookup | AssistantTurnLookupFailure>;
31
77
  dispose(): void;
32
78
  }
@@ -15,6 +15,11 @@
15
15
  * - All summaries go through sanitizeString from evidence-sanitizer
16
16
  * - Degraded paths include structured reason + nextAction (ERR-002)
17
17
  *
18
+ * P1-2 exception: `getAssistantTurn()` returns ONE referenced assistant turn
19
+ * verbatim, on purpose — the Owner must be able to compare the recorded
20
+ * correction against exactly what the agent said. It is bounded to the turn id
21
+ * recorded in correction evidence and pinned to that turn's session.
22
+ *
18
23
  * ERR checklist:
19
24
  * - ERR-001/005: All DB rows treated as unknown, runtime validation with typeof guards
20
25
  * - ERR-002: Degraded paths include reason + nextAction, never silent fallback
@@ -23,10 +28,46 @@
23
28
  * - ERR-013: Use Object.hasOwn() for untrusted object keys
24
29
  */
25
30
  import { SqliteConnection, sanitizeString, assembleEvidenceChain, } from '@principles/core/runtime';
31
+ import { openTrajectoryDbReadonly } from '@principles/core/trajectory-store';
32
+ import { resolveStateDbPath, resolveTrajectoryDbPath } from '@principles/core/runtime/storage-paths';
26
33
  import * as fs from 'node:fs';
27
34
  import * as path from 'node:path';
28
35
  import Database from 'better-sqlite3';
29
36
  import { errorMessage } from '../utils/response.js';
37
+ /**
38
+ * P1-2: restore the assistant turn text for verbatim display.
39
+ *
40
+ * Order of preference: inline `raw_text` → overflow blob (`blob_ref`) →
41
+ * `sanitized_text` (kept for retention cases where raw text was purged). The
42
+ * blob path is treated as untrusted: it must resolve inside `<state>/blobs`,
43
+ * otherwise it is ignored (rc-1 / rc-2).
44
+ */
45
+ function readVerbatimTurnText(row, stateDir) {
46
+ const inlineRaw = typeof row.raw_text === 'string' ? row.raw_text : '';
47
+ if (inlineRaw !== '')
48
+ return { text: inlineRaw, source: 'raw' };
49
+ const blobRef = typeof row.blob_ref === 'string' ? row.blob_ref : '';
50
+ if (blobRef !== '') {
51
+ const blobsDir = path.resolve(stateDir, 'blobs');
52
+ const blobPath = path.resolve(blobsDir, blobRef);
53
+ const relativeToBlobs = path.relative(blobsDir, blobPath);
54
+ const escapes = relativeToBlobs === '' || relativeToBlobs.startsWith('..') || path.isAbsolute(relativeToBlobs);
55
+ if (!escapes && fs.existsSync(blobPath)) {
56
+ try {
57
+ const blobText = fs.readFileSync(blobPath, 'utf8');
58
+ if (blobText !== '')
59
+ return { text: blobText, source: 'raw' };
60
+ }
61
+ catch {
62
+ // Unreadable blob: fall through to the sanitized copy below.
63
+ }
64
+ }
65
+ }
66
+ const sanitized = typeof row.sanitized_text === 'string' ? row.sanitized_text : '';
67
+ if (sanitized !== '')
68
+ return { text: sanitized, source: 'sanitized' };
69
+ return null;
70
+ }
30
71
  // ── Helpers ────────────────────────────────────────────────────────────────────
31
72
  function isRecord(value) {
32
73
  return typeof value === 'object' && value !== null && !Array.isArray(value);
@@ -136,7 +177,7 @@ export class EvidenceChainConsoleModel {
136
177
  const degradedReasons = [];
137
178
  const degradedNextActions = [];
138
179
  // ── 1. Read pain_events from trajectory.db ────────────────────────────
139
- const trajectoryDbPath = path.join(this.workspaceDir, '.state', 'trajectory.db');
180
+ const trajectoryDbPath = resolveTrajectoryDbPath(this.workspaceDir);
140
181
  let painEvents = [];
141
182
  let trajectoryDbAvailable = false;
142
183
  if (fs.existsSync(trajectoryDbPath)) {
@@ -190,7 +231,7 @@ export class EvidenceChainConsoleModel {
190
231
  degradedNextActions.push('PD has not recorded any pain signals in this workspace yet.');
191
232
  }
192
233
  // ── 2. Read tasks & candidates from state.db ──────────────────────
193
- const stateDbPath = path.join(this.workspaceDir, '.pd', 'state.db');
234
+ const stateDbPath = resolveStateDbPath(this.workspaceDir);
194
235
  let tasks = [];
195
236
  let dreamerTasks = [];
196
237
  let candidates = [];
@@ -340,6 +381,84 @@ export class EvidenceChainConsoleModel {
340
381
  }
341
382
  return response;
342
383
  }
384
+ /**
385
+ * P1-2: read the raw assistant turn referenced by correction evidence.
386
+ * Verbatim by contract — no sanitization, no markdown rendering.
387
+ *
388
+ * Uses the registered trajectory-store seam (`openTrajectoryDbReadonly`) so
389
+ * the read-only + path-contract rules have a single owner. The overflow blob
390
+ * directory is derived from the trajectory database location, never
391
+ * hardcoded, and a blob reference is confined to that directory before it is
392
+ * read.
393
+ */
394
+ async getAssistantTurn(turnId, expectedSessionId) {
395
+ if (!Number.isInteger(turnId) || turnId <= 0) {
396
+ return {
397
+ ok: false,
398
+ reason: 'Assistant turn id must be a positive integer',
399
+ nextAction: 'Reload the page and expand the original output again.',
400
+ };
401
+ }
402
+ const trajectoryDbPath = resolveTrajectoryDbPath(this.workspaceDir);
403
+ if (!fs.existsSync(trajectoryDbPath)) {
404
+ return {
405
+ ok: false,
406
+ reason: 'Trajectory database not found for this workspace',
407
+ nextAction: 'PD has not recorded any turns in this workspace yet.',
408
+ };
409
+ }
410
+ let db = null;
411
+ try {
412
+ db = openTrajectoryDbReadonly(this.workspaceDir);
413
+ // Untrusted DB row: narrow with a guard instead of an `as` cast (rc-2).
414
+ const row = db.prepare('SELECT id, session_id, raw_text, sanitized_text, blob_ref, created_at FROM assistant_turns WHERE id = ?').get(turnId);
415
+ if (!isRecord(row)) {
416
+ return {
417
+ ok: false,
418
+ reason: `Assistant turn ${turnId} was not found`,
419
+ nextAction: 'The trajectory database may have been rotated; the correction text is still shown above.',
420
+ };
421
+ }
422
+ const sessionId = typeof row.session_id === 'string' ? row.session_id : '';
423
+ if (expectedSessionId && sessionId !== expectedSessionId) {
424
+ // Safety: never expose a turn from a different session than the one the
425
+ // correction evidence recorded.
426
+ return {
427
+ ok: false,
428
+ reason: 'Assistant turn does not belong to the recorded session',
429
+ nextAction: 'The evidence link is inconsistent; treat the original output as unavailable.',
430
+ };
431
+ }
432
+ const restored = readVerbatimTurnText(row, path.dirname(trajectoryDbPath));
433
+ if (restored === null) {
434
+ return {
435
+ ok: false,
436
+ reason: 'Assistant turn has no recorded output',
437
+ nextAction: 'The turn exists but its text was not persisted.',
438
+ };
439
+ }
440
+ return {
441
+ ok: true,
442
+ turn: {
443
+ id: turnId,
444
+ sessionId,
445
+ text: restored.text,
446
+ textSource: restored.source,
447
+ createdAt: typeof row.created_at === 'string' ? row.created_at : '',
448
+ },
449
+ };
450
+ }
451
+ catch (err) {
452
+ return {
453
+ ok: false,
454
+ reason: `Failed to read assistant turn: ${errorMessage(err)}`,
455
+ nextAction: 'Check trajectory database integrity in the workspace .state directory.',
456
+ };
457
+ }
458
+ finally {
459
+ db?.close();
460
+ }
461
+ }
343
462
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this -- lifecycle interface; connections are request-scoped
344
463
  dispose() {
345
464
  // Connections are opened and closed per-request; no persistent state.
@@ -1,4 +1,5 @@
1
1
  import { SqliteConnection, SqliteApprovalQueueStore, SqlitePIArtifactStore, ApprovalQueue, } from '@principles/core/runtime';
2
+ import { resolveStateDbPath, resolveTrajectoryDbPath } from '@principles/core/runtime/storage-paths';
2
3
  import * as fs from 'node:fs';
3
4
  import * as path from 'node:path';
4
5
  import { errorMessage } from '../utils/response.js';
@@ -51,7 +52,7 @@ export class GovernanceConsoleModel {
51
52
  this.workspaceDir = workspaceDir;
52
53
  }
53
54
  async getGovernanceQueue() {
54
- const stateDbPath = path.join(this.workspaceDir, '.pd', 'state.db');
55
+ const stateDbPath = resolveStateDbPath(this.workspaceDir);
55
56
  if (!fs.existsSync(stateDbPath)) {
56
57
  // Security audit run-1 (gate-failopen-allow-on-state-corruption): the
57
58
  // governed agent can delete state.db, and the gate then fails open —
@@ -293,7 +294,7 @@ export class GovernanceConsoleModel {
293
294
  }
294
295
  // PRI-380: Query trajectory.db for behavior evidence count
295
296
  let evidenceInProgressCount = 0;
296
- const trajectoryDbPath = path.join(this.workspaceDir, '.state', 'trajectory.db');
297
+ const trajectoryDbPath = resolveTrajectoryDbPath(this.workspaceDir);
297
298
  if (fs.existsSync(trajectoryDbPath)) {
298
299
  try {
299
300
  const Database = (await import('better-sqlite3')).default;
@@ -16,6 +16,7 @@ import * as path from 'node:path';
16
16
  import { createHash } from 'node:crypto';
17
17
  import { RUNTIME_CONTRACT_SCHEMA_VERSION } from '@principles/core/runtime';
18
18
  import { deriveGovernanceExperienceSnapshot, deriveOwnerGovernanceView, } from '@principles/core/runtime';
19
+ import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
19
20
  import { GovernanceProjectionCollector, isRecord, readOwnString, } from './GovernanceProjectionCollector.js';
20
21
  import { loadPdConfig } from '../config/pd-config-store.js';
21
22
  const EMPTY_TABLES = { artifactRows: [], taskRows: [], approvalRows: [], activationRows: [] };
@@ -59,7 +60,7 @@ export class GovernanceExperienceCollector {
59
60
  });
60
61
  }
61
62
  // ── state.db: existence check + one batched table read ───────────────────
62
- const dbPath = path.join(this.workspaceDir, '.pd', 'state.db');
63
+ const dbPath = resolveStateDbPath(this.workspaceDir);
63
64
  let tables = EMPTY_TABLES;
64
65
  let stateDbAvailable = true;
65
66
  let stateDbReasonCode;
@@ -3,6 +3,7 @@ import * as path from 'node:path';
3
3
  import { RUNTIME_CONTRACT_SCHEMA_VERSION } from '@principles/core/runtime';
4
4
  import { Value } from '@sinclair/typebox/value';
5
5
  import { GovernanceFactsSchema, SqliteConnection, isPDErrorCategory, parsePITaskMetadata, PD_TASK_STATUSES, PRINCIPLE_STATUSES, isPDTaskStatus, } from '@principles/core/runtime';
6
+ import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
6
7
  export const GOVERNANCE_TASK_KINDS = new Set([
7
8
  'dreamer', 'philosopher', 'scribe', 'artificer', 'evaluator', 'rollout_reviewer',
8
9
  ]);
@@ -55,7 +56,7 @@ export class GovernanceProjectionCollector {
55
56
  }
56
57
  const collectionIssues = [];
57
58
  const principle = this.readPrinciple(principleId, collectionIssues);
58
- const dbPath = path.join(this.workspaceDir, '.pd', 'state.db');
59
+ const dbPath = resolveStateDbPath(this.workspaceDir);
59
60
  if (!fs.existsSync(dbPath)) {
60
61
  return GovernanceProjectionCollector.factsForUnavailableSource({ principleId, asOf, principle, collectionIssues });
61
62
  }