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
@@ -0,0 +1,34 @@
1
+ /** The per-host row shape mirrors health-ingestion.ts structurally (review surface, not a projection). */
2
+ export interface IngestionHostRow {
3
+ status: 'monitored' | 'not_wired';
4
+ [field: string]: unknown;
5
+ }
6
+ export interface IngestionHealthSnapshot {
7
+ /** 'ok' = the CLI authority produced a real report (verbatim section passthrough). */
8
+ status: 'ok';
9
+ generatedAt: string;
10
+ workspace: string;
11
+ ingestion: {
12
+ codex: IngestionHostRow;
13
+ workbuddy: IngestionHostRow;
14
+ openclaw: IngestionHostRow;
15
+ };
16
+ }
17
+ export type IngestionHealthResult = {
18
+ status: 'ok';
19
+ snapshot: IngestionHealthSnapshot;
20
+ } | {
21
+ status: 'unknown';
22
+ reason: string;
23
+ nextAction: string;
24
+ productClaim: 'degraded';
25
+ };
26
+ export declare class IngestionHealthModel {
27
+ private readonly workspaceDir;
28
+ private readonly cliEntryOverride;
29
+ private readonly execTimeoutMs;
30
+ constructor(workspaceDir: string, cliEntryOverride?: string, options?: {
31
+ execTimeoutMs?: number;
32
+ });
33
+ collect(): Promise<IngestionHealthResult>;
34
+ }
@@ -0,0 +1,254 @@
1
+ /**
2
+ * IngestionHealthModel — Console adapter for the unified three-host
3
+ * conversation-ingestion health section (PRI-1171 ticket ⑦; SPEC v0.2 §6,
4
+ * tech design §9).
5
+ *
6
+ * The readiness/state computation has ONE authority: the production CLI
7
+ * `pd health --json` (packages/pd-cli/src/commands/health-ingestion.ts).
8
+ * This model executes that command in a fresh subprocess against the
9
+ * workspace and returns its `.ingestion` section VERBATIM — the Console
10
+ * MUST NOT copy the per-host judgment, or CLI and Console could disagree
11
+ * about the same facts (P4: one source of truth). Same discipline as the
12
+ * CodexGovernanceHealthModel (PRI-625 Slice D / PRI-1013).
13
+ *
14
+ * Failure is explicit (rc-9): when the CLI cannot run or its output is not a
15
+ * report, the model returns `status: 'unknown'` with a structured reason and
16
+ * the manual-run nextAction — "unable to determine" is never rendered as
17
+ * healthy. A non-zero exit is NOT by itself a collection failure: the main
18
+ * `pd health` report can exit 1 for OTHER degraded sections (ledger
19
+ * consistency, MCP) while still printing the full JSON report first, so a
20
+ * parseable report on any non-killed exit is accepted (killed/signal/spawn
21
+ * errors are failures — their stdout is partial or stale, never a report).
22
+ *
23
+ * Read-only status, NOT trajectory browsing (SPEC G6 red line): this surface
24
+ * carries flags/consent metadata/water marks/lag counters and bounded
25
+ * session identities — never observation bodies or transcript content.
26
+ */
27
+ import { execFile } from 'node:child_process';
28
+ import { promisify } from 'node:util';
29
+ import { resolvePdCliEntry } from './CodexGovernanceHealthModel.js';
30
+ import { errorMessage } from '../utils/response.js';
31
+ const execFileAsync = promisify(execFile);
32
+ const MANUAL_RUN_ACTION = 'Run `pd health --workspace <dir> --json` manually to see the structured ingestion section.';
33
+ function degradedCollection(reason, detail) {
34
+ return {
35
+ status: 'unknown',
36
+ reason,
37
+ nextAction: detail.length > 0 ? `${MANUAL_RUN_ACTION} (${detail})` : MANUAL_RUN_ACTION,
38
+ productClaim: 'degraded',
39
+ };
40
+ }
41
+ function isDegradedBlock(value) {
42
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
43
+ return false;
44
+ return typeof Reflect.get(value, 'reason') === 'string'
45
+ && typeof Reflect.get(value, 'nextAction') === 'string';
46
+ }
47
+ /** Minimal shapes the CLIENT validator requires — reject here so a malformed
48
+ * row degrades to the explicit unknown block, not a client-side "unable to
49
+ * connect" (the client validator rejects the whole response on one bad row).
50
+ * This is a guard, NOT a second copy of the full client validation. */
51
+ function isCheckpointSessionPart(value) {
52
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
53
+ return false;
54
+ if (!Object.hasOwn(value, 'lagBytes') || !Object.hasOwn(value, 'lastDegradationReason'))
55
+ return false;
56
+ const lag = Reflect.get(value, 'lagBytes');
57
+ const degradation = Reflect.get(value, 'lastDegradationReason');
58
+ return typeof Reflect.get(value, 'rolloutIdentity') === 'string'
59
+ && typeof Reflect.get(value, 'byteOffset') === 'number'
60
+ && typeof Reflect.get(value, 'incompleteTail') === 'boolean'
61
+ && typeof Reflect.get(value, 'updatedAt') === 'string'
62
+ && (lag === null || typeof lag === 'number')
63
+ && (degradation === null || typeof degradation === 'string');
64
+ }
65
+ function isCheckpointsPart(value) {
66
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
67
+ return false;
68
+ if (!Object.hasOwn(value, 'total'))
69
+ return isDegradedBlock(value);
70
+ // The client validator requires these fields and rejects the WHOLE response
71
+ // when one is missing. Guard them here too: a `checkpoints` block lacking
72
+ // lastSuccessAt (or with a malformed session element) must degrade to the
73
+ // structured unknown block, not reach the page as "unable to connect"
74
+ // (PR #2563 re-review 4546270187).
75
+ for (const key of ['lastSuccessAt', 'checkpointOffset', 'lagBytes', 'lastDegradation', 'sessions']) {
76
+ if (!Object.hasOwn(value, key))
77
+ return false;
78
+ }
79
+ const nullableString = (v) => v === null || typeof v === 'string';
80
+ const nullableNumber = (v) => v === null || typeof v === 'number';
81
+ if (!nullableString(Reflect.get(value, 'lastSuccessAt'))
82
+ || !nullableNumber(Reflect.get(value, 'checkpointOffset'))
83
+ || !nullableNumber(Reflect.get(value, 'lagBytes')))
84
+ return false;
85
+ const lastDegradation = Reflect.get(value, 'lastDegradation');
86
+ if (lastDegradation !== null) {
87
+ if (typeof lastDegradation !== 'object' || Array.isArray(lastDegradation))
88
+ return false;
89
+ if (typeof Reflect.get(lastDegradation, 'reason') !== 'string'
90
+ || typeof Reflect.get(lastDegradation, 'updatedAt') !== 'string'
91
+ || !Object.hasOwn(lastDegradation, 'ordinal'))
92
+ return false;
93
+ }
94
+ const sessions = Reflect.get(value, 'sessions');
95
+ if (!Array.isArray(sessions))
96
+ return false;
97
+ return typeof Reflect.get(value, 'total') === 'number'
98
+ && typeof Reflect.get(value, 'incompleteTailCount') === 'number'
99
+ && typeof Reflect.get(value, 'lagUndetectable') === 'boolean'
100
+ && typeof Reflect.get(value, 'truncated') === 'boolean'
101
+ && sessions.every(isCheckpointSessionPart);
102
+ }
103
+ function isLiveOnlyPart(value) {
104
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
105
+ return false;
106
+ if (!Object.hasOwn(value, 'sessions'))
107
+ return isDegradedBlock(value);
108
+ const sessions = Reflect.get(value, 'sessions');
109
+ if (!Array.isArray(sessions))
110
+ return false;
111
+ if (typeof Reflect.get(value, 'truncated') !== 'boolean')
112
+ return false;
113
+ return sessions.every((session) => {
114
+ if (typeof session !== 'object' || session === null || Array.isArray(session))
115
+ return false;
116
+ return typeof Reflect.get(session, 'rolloutIdentity') === 'string'
117
+ && typeof Reflect.get(session, 'lastObservedAt') === 'string'
118
+ && typeof Reflect.get(session, 'observationCount') === 'number';
119
+ });
120
+ }
121
+ function isHostRow(value) {
122
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
123
+ return false;
124
+ const status = Reflect.get(value, 'status');
125
+ if (status === 'not_wired')
126
+ return isDegradedBlock(value);
127
+ if (status !== 'monitored')
128
+ return false;
129
+ // Field presence alone is not enough: `{ status:'monitored', hostFlag:{} }`
130
+ // used to pass here and then fail the client validator, rendering the page
131
+ // as "unreachable" instead of a structured collection failure (PR #2563
132
+ // review, CodeRabbit finding 4545201393).
133
+ for (const field of ['hostFlag', 'ingestionFlag']) {
134
+ const flag = Reflect.get(value, field);
135
+ if (typeof flag !== 'object' || flag === null || Array.isArray(flag))
136
+ return false;
137
+ const state = Reflect.get(flag, 'state');
138
+ if (state !== 'ENABLED' && state !== 'DISABLED' && state !== 'UNKNOWN')
139
+ return false;
140
+ if (typeof Reflect.get(flag, 'source') !== 'string')
141
+ return false;
142
+ }
143
+ const consent = Reflect.get(value, 'consent');
144
+ if (typeof consent !== 'object' || consent === null || Array.isArray(consent)
145
+ || typeof Reflect.get(consent, 'state') !== 'string')
146
+ return false;
147
+ return isCheckpointsPart(Reflect.get(value, 'checkpoints'))
148
+ && isLiveOnlyPart(Reflect.get(value, 'liveOnly'));
149
+ }
150
+ /**
151
+ * rc-1..rc-4: stdout from a subprocess is untrusted runtime data even when
152
+ * the subprocess is our own CLI, so the section-bearing fields are checked
153
+ * before the passthrough cast. This distinguishes a real report from a
154
+ * usage/rejection JSON or truncated output; the cast stays a verbatim
155
+ * passthrough of the CLI's documented contract (runtime-contract-exempt per
156
+ * the CodexGovernanceHealthModel precedent) because it sits behind the guards.
157
+ */
158
+ function parseIngestionReport(text) {
159
+ if (text.trim().length === 0)
160
+ return undefined;
161
+ let parsed;
162
+ try {
163
+ parsed = JSON.parse(text);
164
+ }
165
+ catch {
166
+ return undefined;
167
+ }
168
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed))
169
+ return undefined;
170
+ const generatedAt = Reflect.get(parsed, 'generatedAt');
171
+ const workspace = Reflect.get(parsed, 'workspace');
172
+ if (typeof generatedAt !== 'string' || typeof workspace !== 'string')
173
+ return undefined;
174
+ const ingestion = Reflect.get(parsed, 'ingestion');
175
+ if (typeof ingestion !== 'object' || ingestion === null || Array.isArray(ingestion))
176
+ return undefined;
177
+ const section = ingestion;
178
+ const codex = Reflect.get(section, 'codex');
179
+ const workbuddy = Reflect.get(section, 'workbuddy');
180
+ const openclaw = Reflect.get(section, 'openclaw');
181
+ // isHostRow is a type predicate — the validated values flow through with no cast.
182
+ if (!isHostRow(codex) || !isHostRow(workbuddy) || !isHostRow(openclaw))
183
+ return undefined;
184
+ return {
185
+ status: 'ok',
186
+ generatedAt,
187
+ workspace,
188
+ ingestion: { codex, workbuddy, openclaw },
189
+ };
190
+ }
191
+ /** rc-1/rc-2: the failure shape from fs/exec is unknown — read fields only if present. */
192
+ function stdoutFromExecError(error) {
193
+ if (typeof error !== 'object' || error === null || !Object.hasOwn(error, 'stdout'))
194
+ return '';
195
+ const { stdout } = error;
196
+ return typeof stdout === 'string' ? stdout : '';
197
+ }
198
+ function execFailureKind(error) {
199
+ if (typeof error !== 'object' || error === null)
200
+ return undefined;
201
+ const rec = error;
202
+ if (rec.killed === true)
203
+ return 'killed';
204
+ if (typeof rec.signal === 'string' && rec.signal.length > 0)
205
+ return `signal ${rec.signal}`;
206
+ if (typeof rec.code === 'string')
207
+ return rec.code;
208
+ return undefined;
209
+ }
210
+ export class IngestionHealthModel {
211
+ workspaceDir;
212
+ cliEntryOverride;
213
+ execTimeoutMs;
214
+ constructor(workspaceDir, cliEntryOverride, options) {
215
+ this.workspaceDir = workspaceDir;
216
+ this.cliEntryOverride = cliEntryOverride ?? null;
217
+ // Production default; the option exists only so a regression test can
218
+ // trigger a REAL timeout kill without waiting 30s (PRI-1013 discipline).
219
+ this.execTimeoutMs = options?.execTimeoutMs ?? 30_000;
220
+ }
221
+ async collect() {
222
+ const resolution = this.cliEntryOverride !== null
223
+ ? { ok: true, entry: this.cliEntryOverride }
224
+ : resolvePdCliEntry();
225
+ if (!resolution.ok) {
226
+ return degradedCollection(resolution.reason, resolution.nextAction);
227
+ }
228
+ let stdout;
229
+ try {
230
+ const result = await execFileAsync(process.execPath, [resolution.entry, 'health', '--workspace', this.workspaceDir, '--json'], { encoding: 'utf8', timeout: this.execTimeoutMs, windowsHide: true });
231
+ ({ stdout } = result);
232
+ }
233
+ catch (error) {
234
+ // A parseable report on ANY non-killed exit is accepted: the main health
235
+ // report may exit 1 for OTHER degraded sections (ledger/MCP) after
236
+ // printing the full JSON. killed/signal/spawn failures never render.
237
+ const failureKind = execFailureKind(error);
238
+ if (failureKind !== undefined) {
239
+ return degradedCollection('health_collection_failed', `${errorMessage(error).slice(0, 160)} [${failureKind}]`);
240
+ }
241
+ const report = parseIngestionReport(stdoutFromExecError(error));
242
+ if (report !== undefined)
243
+ return { status: 'ok', snapshot: report };
244
+ return degradedCollection('health_collection_failed', errorMessage(error).slice(0, 160));
245
+ }
246
+ const snapshot = parseIngestionReport(stdout);
247
+ if (snapshot === undefined) {
248
+ // degradedCollection already prefixes MANUAL_RUN_ACTION — pass an empty
249
+ // detail, otherwise the same sentence is emitted twice (PR #2563 review).
250
+ return degradedCollection('health_report_unparseable', '');
251
+ }
252
+ return { status: 'ok', snapshot };
253
+ }
254
+ }
@@ -19,10 +19,10 @@
19
19
  * - EP-09: model is a thin I/O adapter over the pure store contract
20
20
  */
21
21
  import * as fs from 'node:fs';
22
- import * as path from 'node:path';
23
22
  import { SqliteConnection, SqliteIntentDecisionStore, } from '@principles/core/runtime';
23
+ import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
24
24
  function stateDbExists(workspaceDir) {
25
- return fs.existsSync(path.join(workspaceDir, '.pd', 'state.db'));
25
+ return fs.existsSync(resolveStateDbPath(workspaceDir));
26
26
  }
27
27
  function isMissingTableError(err) {
28
28
  if (!(err instanceof Error))
@@ -1,10 +1,11 @@
1
1
  import * as fs from 'node:fs';
2
2
  import * as path from 'node:path';
3
3
  import { INTENT_MAX_BYTES, getIntentFilename, createIntentTemplate, parseIntentDocSections, computeIntentContentHash, validateIntentDocSections, SqliteConnection, SqliteIntentDocVersionStore, } from '@principles/core/runtime';
4
+ import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
4
5
  import { errorMessage } from '../utils/response.js';
5
6
  const INTENT_DIR = '.principles';
6
7
  function stateDbExists(workspaceDir) {
7
- return fs.existsSync(path.join(workspaceDir, '.pd', 'state.db'));
8
+ return fs.existsSync(resolveStateDbPath(workspaceDir));
8
9
  }
9
10
  /**
10
11
  * Size-check and read an intent document through ONE open handle.
@@ -10,8 +10,8 @@
10
10
  * 本模型只负责 workspace I/O 与条目包装(标题/摘要等展示字段)。
11
11
  */
12
12
  import * as fs from 'node:fs';
13
- import * as path from 'node:path';
14
13
  import { SqliteConnection, SqlitePIArtifactStore, SqliteApprovalQueueStore, collectOwnerDecisionFacts, deriveOwnerDecisionCapability, buildOwnerDecisionReview, } from '@principles/core/runtime';
14
+ import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
15
15
  import { ActivationsConsoleModel } from './ActivationsConsoleModel.js';
16
16
  import { createArtifactPrincipleResolutionDeps, resolveArtifactPrincipleId, } from './artifact-principle-resolver.js';
17
17
  /** 每条 issue 保留的样本上限,防止异常放大响应体。 */
@@ -20,6 +20,32 @@ const MAX_READ_ISSUE_DETAIL_CHARS = 200;
20
20
  function describeError(error) {
21
21
  return error instanceof Error ? error.message : String(error);
22
22
  }
23
+ /**
24
+ * PRI-1058: per-activation owner-review reads are independent (each opens its
25
+ * own read-only connection and runs its own CLI probes), but the inbox listed
26
+ * them one at a time. Wall time therefore grew as `N × probes` against the
27
+ * console's fixed request budget, so a loaded machine answered the list with a
28
+ * 504. This bound only changes WHEN the reads happen — `worker` results are
29
+ * consumed in the original row order, so every projection fact (item order,
30
+ * read-issue counts/samples/first detail) stays identical to the serial walk.
31
+ * The bound is finite because each review spawns two real pd CLI subprocesses.
32
+ */
33
+ const OWNER_REVIEW_CONCURRENCY = 4;
34
+ async function mapWithConcurrency(values, limit, worker) {
35
+ const results = new Array(values.length);
36
+ let nextIndex = 0;
37
+ const runnerCount = Math.max(1, Math.min(limit, values.length));
38
+ await Promise.all(Array.from({ length: runnerCount }, async () => {
39
+ for (;;) {
40
+ const index = nextIndex;
41
+ nextIndex += 1;
42
+ if (index >= values.length)
43
+ return;
44
+ results[index] = await worker(values[index]);
45
+ }
46
+ }));
47
+ return results;
48
+ }
23
49
  const GOVERNANCE_TASK_KINDS = new Set(['evaluator', 'rollout_reviewer']);
24
50
  /** tasks.status 合法值(PDTaskStatus)运行时守卫。 */
25
51
  const TASK_STATUSES = new Set(['pending', 'leased', 'succeeded', 'retry_wait', 'failed', 'needs_human_review']);
@@ -195,7 +221,7 @@ export class OwnerDecisionConsoleModel {
195
221
  * N = items.length — 不是 candidate 数、不是 NHR 总数、不是 failed 数。
196
222
  */
197
223
  async listOwnerDecisionItems(routeContext) {
198
- const stateDbPath = path.join(this.workspaceDir, '.pd', 'state.db');
224
+ const stateDbPath = resolveStateDbPath(this.workspaceDir);
199
225
  if (!fs.existsSync(stateDbPath)) {
200
226
  return { items: [], total: 0, generatedAt: new Date().toISOString(), readIssues: [] };
201
227
  }
@@ -289,7 +315,12 @@ export class OwnerDecisionConsoleModel {
289
315
  WHERE action = 'code_tool_hook_shadow_activate'
290
316
  AND promoted_at IS NULL AND deactivated_at IS NULL`).all().filter(isRecordRow);
291
317
  const activationModel = new ActivationsConsoleModel(this.workspaceDir);
292
- for (const row of shadowRows) {
318
+ // PRI-1058: read every shadow activation with bounded concurrency, then
319
+ // fold the outcomes in the original row order. The read is unchanged
320
+ // (same connection scope, same probes, same readiness predicate); only
321
+ // the interleaving changes, so items / readIssues stay identical to the
322
+ // previous serial walk.
323
+ const outcomes = await mapWithConcurrency(shadowRows, OWNER_REVIEW_CONCURRENCY, async (row) => {
293
324
  const artifactId = typeof row.artifact_id === 'string' ? row.artifact_id : '';
294
325
  const activationId = typeof row.activation_id === 'string' ? row.activation_id : '';
295
326
  try {
@@ -300,29 +331,37 @@ export class OwnerDecisionConsoleModel {
300
331
  const review = await activationModel.getOwnerReview(activationId, true, { routeContext });
301
332
  if (review.readiness.status !== 'ready' && review.readiness.status !== 'evidence_insufficient') {
302
333
  // 非待决:不进收件箱,但必须留下计数与原因(否则该 activation 永久不可见)。
303
- recordReadIssue('readiness_not_actionable', activationId, `readiness=${review.readiness.status}`);
304
- continue;
334
+ return { kind: 'skip', reason: 'readiness_not_actionable', activationId, detail: `readiness=${review.readiness.status}` };
305
335
  }
306
336
  }
307
337
  catch (error) {
308
- recordReadIssue('owner_review_read_failed', activationId, describeError(error));
338
+ return { kind: 'skip', reason: 'owner_review_read_failed', activationId, detail: describeError(error) };
339
+ }
340
+ return {
341
+ kind: 'item',
342
+ item: {
343
+ reviewKey: `rulecode:${activationId}`,
344
+ kind: 'rulecode_decision',
345
+ taskId: activationId,
346
+ title: 'RuleCode 影子规则待决',
347
+ summary: '一条 code_tool_hook 规则处于影子激活期,等待拥有者裁决(提升 / 拒绝)。',
348
+ reasonCode: 'rulecode_shadow_pending_promotion',
349
+ legacy: false,
350
+ allowedActions: ['promote', 'reject_after_shadow'],
351
+ expectedRevisionEpoch: 0,
352
+ expectedSourceRunId: '',
353
+ expectedSourceArtifactId: artifactId,
354
+ expectedSourceArtifactHash: '',
355
+ createdAt: typeof row.activated_at === 'string' ? row.activated_at : '',
356
+ },
357
+ };
358
+ });
359
+ for (const outcome of outcomes) {
360
+ if (outcome.kind === 'item') {
361
+ items.push(outcome.item);
309
362
  continue;
310
363
  }
311
- items.push({
312
- reviewKey: `rulecode:${activationId}`,
313
- kind: 'rulecode_decision',
314
- taskId: activationId,
315
- title: 'RuleCode 影子规则待决',
316
- summary: '一条 code_tool_hook 规则处于影子激活期,等待拥有者裁决(提升 / 拒绝)。',
317
- reasonCode: 'rulecode_shadow_pending_promotion',
318
- legacy: false,
319
- allowedActions: ['promote', 'reject_after_shadow'],
320
- expectedRevisionEpoch: 0,
321
- expectedSourceRunId: '',
322
- expectedSourceArtifactId: artifactId,
323
- expectedSourceArtifactHash: '',
324
- createdAt: typeof row.activated_at === 'string' ? row.activated_at : '',
325
- });
364
+ recordReadIssue(outcome.reason, outcome.activationId, outcome.detail);
326
365
  }
327
366
  }
328
367
  catch (error) {
@@ -345,7 +384,7 @@ export class OwnerDecisionConsoleModel {
345
384
  * (decision-capable → 前往治理焦点;technical → Recover)。
346
385
  */
347
386
  async ownerDecisionRequiredTaskIds() {
348
- const stateDbPath = path.join(this.workspaceDir, '.pd', 'state.db');
387
+ const stateDbPath = resolveStateDbPath(this.workspaceDir);
349
388
  if (!fs.existsSync(stateDbPath))
350
389
  return new Set();
351
390
  const conn = new SqliteConnection({ workspaceDir: this.workspaceDir, readonly: true });
@@ -18,11 +18,11 @@
18
18
  /* eslint-disable @typescript-eslint/no-use-before-define -- helpers declared after the class, matching codebase convention */
19
19
  /* eslint-disable @typescript-eslint/class-methods-use-this -- lifecycle-style methods; kept on the model for cohesion */
20
20
  import * as fs from 'node:fs';
21
- import * as path from 'node:path';
22
21
  import { RUNTIME_CONTRACT_SCHEMA_VERSION } from '@principles/core/runtime';
23
22
  import { GovernanceProjectionCollector, isRecord, readOwnString, } from './GovernanceProjectionCollector.js';
24
23
  import { deriveOwnerDecisionView, } from '@principles/core/runtime';
25
24
  import { SqliteConnection } from '@principles/core/runtime';
25
+ import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
26
26
  const ISO_NOW = () => new Date().toISOString();
27
27
  export class OwnerDecisionViewModel {
28
28
  workspaceDir;
@@ -492,7 +492,7 @@ export class OwnerDecisionViewModel {
492
492
  }
493
493
  // ── batch snapshot (shared reads; one DB open per request) ────────────────
494
494
  readBatchSnapshot() {
495
- const dbPath = path.join(this.workspaceDir, '.pd', 'state.db');
495
+ const dbPath = resolveStateDbPath(this.workspaceDir);
496
496
  const dbAvailable = fs.existsSync(dbPath);
497
497
  const candidates = new Map();
498
498
  const genericArtifacts = new Map();
@@ -17,6 +17,7 @@
17
17
  * - ERR-014/016/017: Previews bounded, no raw JSON.stringify on unknown values
18
18
  */
19
19
  import { SqliteConnection } from '@principles/core/runtime';
20
+ import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
20
21
  import * as fs from 'node:fs';
21
22
  import * as path from 'node:path';
22
23
  import { errorMessage } from '../utils/response.js';
@@ -127,7 +128,7 @@ export class PrincipleTrajectoryModel {
127
128
  };
128
129
  }
129
130
  // 2. Open state.db
130
- const stateDbPath = path.join(this.workspaceDir, '.pd', 'state.db');
131
+ const stateDbPath = resolveStateDbPath(this.workspaceDir);
131
132
  let stateDbAvailable = false;
132
133
  let db = null;
133
134
  let conn = null;
@@ -19,9 +19,9 @@
19
19
  * rc-1: SQL rows are typed unknown and narrowed with typeof per column.
20
20
  */
21
21
  import * as fs from 'node:fs';
22
- import * as path from 'node:path';
23
22
  import { SqliteConnection, RECEIPT_RETENTION_POLICY_DAYS } from '@principles/core/runtime';
24
23
  import { SqliteInterventionEvidenceStore } from '@principles/core/runtime';
24
+ import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
25
25
  import { computeFlagsFromLoadResult, loadPdConfig } from '../config/pd-config-store.js';
26
26
  import { errorMessage } from '../utils/response.js';
27
27
  const KINDS = new Set(['rule_blocked', 'auto_correct_applied', 'self_reported', 'prompt_injected']);
@@ -381,7 +381,7 @@ export class ReceiptsConsoleModel {
381
381
  * observable behavior is unchanged).
382
382
  */
383
383
  precheck() {
384
- const stateDbPath = path.join(this.workspaceDir, '.pd', 'state.db');
384
+ const stateDbPath = resolveStateDbPath(this.workspaceDir);
385
385
  if (!fs.existsSync(stateDbPath)) {
386
386
  return {
387
387
  status: 'degraded',
@@ -2,6 +2,7 @@ import path from 'node:path';
2
2
  import { existsSync } from 'node:fs';
3
3
  import Database from 'better-sqlite3';
4
4
  import { createRuntimeStateHandle, PrincipleTreeLedgerAdapter, reviseRuleBindingOnce, resolveRuleBindingRevisionTarget, reviseRuleSourceOnce, previewRuleSourceCorrection, hydratePITaskRecord, candidateIdFromDreamerSeed, } from '@principles/core/runtime';
5
+ import { resolveStateDbPath, resolveTrajectoryDbPath } from '@principles/core/runtime/storage-paths';
5
6
  import { readLedgerFileState } from '@principles/core/principle-tree-ledger';
6
7
  import { ActivationsConsoleModel } from './ActivationsConsoleModel.js';
7
8
  function record(value) {
@@ -144,7 +145,7 @@ export class RuleCandidateBindingConsoleModel {
144
145
  const distinct = [...new Set(painIds.filter(id => id !== ''))];
145
146
  if (distinct.length === 0)
146
147
  return { sources: result, degraded: null };
147
- const dbPath = path.join(this.workspaceDir, '.state', 'trajectory.db');
148
+ const dbPath = resolveTrajectoryDbPath(this.workspaceDir);
148
149
  if (!existsSync(dbPath))
149
150
  return { sources: result, degraded: null };
150
151
  let db = null;
@@ -225,7 +226,7 @@ export class RuleCandidateBindingConsoleModel {
225
226
  async list() {
226
227
  // A fresh workspace with no state.db simply has no binding queue yet;
227
228
  // any other storage problem still surfaces as an error (503 at the route).
228
- if (!existsSync(path.join(this.workspaceDir, '.pd', 'state.db'))) {
229
+ if (!existsSync(resolveStateDbPath(this.workspaceDir))) {
229
230
  return { items: [], summary: { painGroups: 0, candidates: 0, bound: 0, unlinked: 0, blocked: 0 }, truncated: false };
230
231
  }
231
232
  const handle = await createRuntimeStateHandle({ workspaceDir: this.workspaceDir, readonly: true, bootstrapIfMissing: false });
@@ -122,7 +122,7 @@ export async function handleActivationsRoute(req, res, workspaceDir, subPath, au
122
122
  || (req.method === 'POST' && revisionMatch[2] === 'revise-rule-once'))) {
123
123
  const actor = authority?.ownerActor;
124
124
  if (!actor) {
125
- sendError(res, 403, 'owner_authentication_required', 'This revision requires the configured Owner identity.', { nextAction: 'Authenticate as the configured Owner in the Console.' });
125
+ sendError(res, 403, 'owner_authentication_required', 'This revision requires the configured Owner identity.', { nextAction: 'Configure PD_OWNER_ID and PD_OWNER_CREDENTIAL_ID, then retry from the local Console.' });
126
126
  return;
127
127
  }
128
128
  const [, rawId] = revisionMatch;
@@ -181,7 +181,7 @@ export async function handleActivationsRoute(req, res, workspaceDir, subPath, au
181
181
  const governance = operation === 'continue-observing' || operation === 'promote' || operation === 'reject-after-shadow' || operation === 'recover-to-shadow' || operation === 'release';
182
182
  const actor = governance ? authority?.ownerActor : (authority?.ownerActor ?? authority?.breakGlassActor);
183
183
  if (!actor) {
184
- sendError(res, 403, 'owner_authentication_required', 'This governance decision requires the configured Owner identity.', { nextAction: 'Configure PD_OWNER_ID and PD_OWNER_CREDENTIAL_ID, then authenticate with the Console token.' });
184
+ sendError(res, 403, 'owner_authentication_required', 'This governance decision requires the configured Owner identity.', { nextAction: 'Configure PD_OWNER_ID and PD_OWNER_CREDENTIAL_ID, then retry from the local Console.' });
185
185
  return;
186
186
  }
187
187
  const input = { actor, idempotencyKey: body.idempotencyKey, reasonCode: body.reasonCode, ...(body.note === undefined ? {} : { note: body.note }) };
@@ -21,6 +21,7 @@ import * as fs from 'fs';
21
21
  import * as path from 'path';
22
22
  import { fileURLToPath } from 'url';
23
23
  import { RuntimeStateManager, StalledDiagnosticianTaskReadModel, isRetryWaitBackoffElapsed, resolveAgentRuntimeBinding, resolveDiagnosticianCapability, } from '@principles/core/runtime';
24
+ import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
24
25
  import { loadPdConfig } from '../config/pd-config-store.js';
25
26
  import { resolveUpdateLayout } from '../utils/installed-layout.js';
26
27
  import { errorMessage, sendError, sendJson, sendMethodNotAllowed, sendNotFound } from '../utils/response.js';
@@ -213,7 +214,7 @@ function isJsonContentType(value) {
213
214
  return mediaType?.trim().toLowerCase() === 'application/json';
214
215
  }
215
216
  function stateDbPath(workspaceDir) {
216
- return path.join(workspaceDir, '.pd', 'state.db');
217
+ return resolveStateDbPath(workspaceDir);
217
218
  }
218
219
  function resolveConfiguration(deps) {
219
220
  const loadResult = loadPdConfig(deps.workspaceDir);
@@ -258,7 +259,7 @@ async function handleBacklog(res, deps) {
258
259
  async function handleRun(req, res, input) {
259
260
  const { deps, taskId } = input;
260
261
  req.resume(); // body is `{}` / empty; drain so the socket is not reset.
261
- // 1. Same-origin (TD §8.2.3). Bearer/loopback auth already ran upstream.
262
+ // 1. Same-origin (TD §8.2.3). The local-owner-session guard already ran upstream.
262
263
  if (!isSameOriginRequest(req)) {
263
264
  sendError(res, 403, 'cross_origin_rejected', 'Cross-origin request rejected');
264
265
  return;
@@ -3,6 +3,10 @@
3
3
  *
4
4
  * GET /api/evidence-chain
5
5
  * Returns evidence chain records from pain_events, tasks, candidates, and ledger.
6
+ *
7
+ * GET /api/evidence-chain/assistant-turn?id=<turnId>&session=<sessionId>
8
+ * P1-2: returns the referenced assistant turn verbatim so the Owner can
9
+ * compare the correction text with the original output.
6
10
  */
7
11
  import type { IncomingMessage, ServerResponse } from 'node:http';
8
12
  export declare function handleEvidenceChainRoute(req: IncomingMessage, res: ServerResponse, workspaceDir: string): Promise<void>;
@@ -9,12 +9,34 @@ function getModel(workspaceDir) {
9
9
  }
10
10
  return model;
11
11
  }
12
+ function isAssistantTurnPath(url) {
13
+ const pathname = url.split('?')[0] ?? '';
14
+ return pathname === '/assistant-turn' || pathname === '/api/evidence-chain/assistant-turn';
15
+ }
12
16
  export async function handleEvidenceChainRoute(req, res, workspaceDir) {
13
17
  if (req.method !== 'GET') {
14
18
  sendError(res, 405, 'method_not_allowed', 'Only GET is allowed for this route');
15
19
  return;
16
20
  }
17
21
  const model = getModel(workspaceDir);
22
+ if (isAssistantTurnPath(req.url ?? '')) {
23
+ const url = new URL(req.url ?? '/', 'http://localhost');
24
+ const rawId = url.searchParams.get('id') ?? '';
25
+ const session = url.searchParams.get('session') ?? undefined;
26
+ const turnId = Number(rawId);
27
+ try {
28
+ const result = await model.getAssistantTurn(turnId, session || undefined);
29
+ if (!result.ok) {
30
+ sendError(res, 404, 'assistant_turn_unavailable', result.reason, { nextAction: result.nextAction });
31
+ return;
32
+ }
33
+ sendSuccess(res, result.turn);
34
+ }
35
+ catch (err) {
36
+ sendError(res, 500, 'assistant_turn_error', errorMessage(err));
37
+ }
38
+ return;
39
+ }
18
40
  try {
19
41
  const result = await model.getEvidenceChain();
20
42
  sendSuccess(res, result);
@@ -5,8 +5,9 @@
5
5
  *
6
6
  * 最小获授权事实入口:Owner 可以对一个已存在的 Behavior Episode 提交
7
7
  * 明确的结果观察/反馈。安全模型(复用 owner-decisions 的模式):
8
- * - 全局 console token 认证由 server/index.ts 统一强制;
9
- * - Owner 身份从 server-side auth context 推导,body 中的身份字段一律
8
+ * - 来源守卫(Host/Origin/Sec-Fetch-Site/JSON Content-Type)由
9
+ * server/index.ts 统一强制;
10
+ * - Owner 身份从服务端身份解析结果推导,body 中的身份字段一律
10
11
  * 不信任 —— actorId 由服务端写入,请求方无法自称;
11
12
  * - 封闭字段集:任何 runtime 证明字段(runtime_verified / proof /
12
13
  * activation 决策等)都不存在于此 contract,LLM/Agent 无法伪装成
@@ -65,7 +65,7 @@ export async function handleEvidenceOutcomesRoute(req, res, ctx) {
65
65
  }
66
66
  // 身份门槛与 owner-decisions 一致:没有已验证 Owner 身份就拒绝写。
67
67
  if (!ctx.ownerIdentity) {
68
- sendError(res, 403, 'owner_authentication_required', 'Recording an Owner outcome requires a verified Owner identity (console token auth enabled and owner identity resolved).');
68
+ sendError(res, 403, 'owner_authentication_required', 'Recording an Owner outcome requires a registered Owner identity (owner identity configured and resolved).');
69
69
  return;
70
70
  }
71
71
  let rawBody;