create-principles-disciple 1.152.2 → 1.152.4

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 (386) hide show
  1. package/_release/product-identity.json +1 -1
  2. package/codex-adapter/dist/pd-hook.js +34 -4
  3. package/codex-adapter/package.json +1 -1
  4. package/console/dist/server/config/pd-config-store.d.ts +48 -0
  5. package/console/dist/server/config/pd-config-store.js +273 -93
  6. package/console/dist/server/index.js +16 -1
  7. package/console/dist/server/models/ActivationsConsoleModel.d.ts +72 -1
  8. package/console/dist/server/models/ActivationsConsoleModel.js +92 -14
  9. package/console/dist/server/models/AdaptiveActivationConsoleModel.d.ts +79 -0
  10. package/console/dist/server/models/AdaptiveActivationConsoleModel.js +151 -0
  11. package/console/dist/server/models/ApprovalsConsoleModel.d.ts +28 -0
  12. package/console/dist/server/models/ApprovalsConsoleModel.js +118 -3
  13. package/console/dist/server/models/ApprovalsGroupedConsoleModel.d.ts +38 -0
  14. package/console/dist/server/models/ApprovalsGroupedConsoleModel.js +158 -26
  15. package/console/dist/server/models/IntentDecisionModel.d.ts +6 -1
  16. package/console/dist/server/models/IntentDecisionModel.js +17 -9
  17. package/console/dist/server/models/pipeline-health-metrics.d.ts +128 -0
  18. package/console/dist/server/models/pipeline-health-metrics.js +225 -0
  19. package/console/dist/server/routes/approvals.js +14 -0
  20. package/console/dist/server/routes/config.js +212 -1
  21. package/console/dist/server/routes/diagnostician.js +13 -2
  22. package/console/dist/server/routes/intent-decisions.js +19 -1
  23. package/console/dist/server/routes/pipeline-health.d.ts +9 -0
  24. package/console/dist/server/routes/pipeline-health.js +124 -0
  25. package/console/dist/web/assets/app.css +484 -67
  26. package/console/dist/web/assets/app.js +36 -31
  27. package/console/dist/web/assets/evidence-art-1.webp +0 -0
  28. package/console/dist/web/assets/evidence-art-2.webp +0 -0
  29. package/console/dist/web/assets/evidence-art-3.webp +0 -0
  30. package/console/dist/web/assets/evidence-art-4.webp +0 -0
  31. package/console/dist/web/assets/principle-grove.jpg +0 -0
  32. package/console/dist/web/assets/principle-stone-steps.jpg +0 -0
  33. package/console/dist/web/assets/principles-art-1.webp +0 -0
  34. package/console/dist/web/assets/principles-art-2.webp +0 -0
  35. package/console/dist/web/assets/principles-art-3.webp +0 -0
  36. package/console/dist/web/assets/principles-art-4.webp +0 -0
  37. package/console/dist/web/assets/today-art-1.webp +0 -0
  38. package/console/dist/web/assets/today-art-2.webp +0 -0
  39. package/console/dist/web/assets/today-art-3.webp +0 -0
  40. package/console/dist/web/assets/today-art-4.webp +0 -0
  41. package/core/dist/runtime/activation/activation-types.d.ts +6 -0
  42. package/core/dist/runtime/activation/activation-types.d.ts.map +1 -1
  43. package/core/dist/runtime/activation/activation-types.js.map +1 -1
  44. package/core/dist/runtime/activation/index.d.ts +2 -1
  45. package/core/dist/runtime/activation/index.d.ts.map +1 -1
  46. package/core/dist/runtime/activation/index.js +1 -1
  47. package/core/dist/runtime/activation/index.js.map +1 -1
  48. package/core/dist/runtime/activation/ledger-identity.d.ts +8 -0
  49. package/core/dist/runtime/activation/ledger-identity.d.ts.map +1 -1
  50. package/core/dist/runtime/activation/ledger-identity.js +20 -1
  51. package/core/dist/runtime/activation/ledger-identity.js.map +1 -1
  52. package/core/dist/runtime/activation/sqlite-approval-store.d.ts +18 -0
  53. package/core/dist/runtime/activation/sqlite-approval-store.d.ts.map +1 -1
  54. package/core/dist/runtime/activation/sqlite-approval-store.js +146 -20
  55. package/core/dist/runtime/activation/sqlite-approval-store.js.map +1 -1
  56. package/core/dist/runtime/adapter/artificer-l2-adapter.d.ts.map +1 -1
  57. package/core/dist/runtime/adapter/artificer-l2-adapter.js +11 -4
  58. package/core/dist/runtime/adapter/artificer-l2-adapter.js.map +1 -1
  59. package/core/dist/runtime/adapter/l2-agent-loop-adapter.d.ts.map +1 -1
  60. package/core/dist/runtime/adapter/l2-agent-loop-adapter.js +11 -4
  61. package/core/dist/runtime/adapter/l2-agent-loop-adapter.js.map +1 -1
  62. package/core/dist/runtime/adapter/output-repair-contract.d.ts +21 -1
  63. package/core/dist/runtime/adapter/output-repair-contract.d.ts.map +1 -1
  64. package/core/dist/runtime/adapter/output-repair-contract.js.map +1 -1
  65. package/core/dist/runtime/adapter/pi-ai-catalog.d.ts +42 -0
  66. package/core/dist/runtime/adapter/pi-ai-catalog.d.ts.map +1 -1
  67. package/core/dist/runtime/adapter/pi-ai-catalog.js +68 -0
  68. package/core/dist/runtime/adapter/pi-ai-catalog.js.map +1 -1
  69. package/core/dist/runtime/adapter/pi-ai-connection-probe.d.ts +45 -0
  70. package/core/dist/runtime/adapter/pi-ai-connection-probe.d.ts.map +1 -0
  71. package/core/dist/runtime/adapter/pi-ai-connection-probe.js +321 -0
  72. package/core/dist/runtime/adapter/pi-ai-connection-probe.js.map +1 -0
  73. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts +27 -2
  74. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
  75. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js +71 -10
  76. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js.map +1 -1
  77. package/core/dist/runtime/adapter/schema-prompt-adapter.d.ts.map +1 -1
  78. package/core/dist/runtime/adapter/schema-prompt-adapter.js +39 -6
  79. package/core/dist/runtime/adapter/schema-prompt-adapter.js.map +1 -1
  80. package/core/dist/runtime/adapter/structured-output-repair.d.ts +26 -0
  81. package/core/dist/runtime/adapter/structured-output-repair.d.ts.map +1 -1
  82. package/core/dist/runtime/adapter/structured-output-repair.js +140 -2
  83. package/core/dist/runtime/adapter/structured-output-repair.js.map +1 -1
  84. package/core/dist/runtime/config/execution-timing.d.ts +56 -0
  85. package/core/dist/runtime/config/execution-timing.d.ts.map +1 -0
  86. package/core/dist/runtime/config/execution-timing.js +76 -0
  87. package/core/dist/runtime/config/execution-timing.js.map +1 -0
  88. package/core/dist/runtime/config/index.d.ts +4 -0
  89. package/core/dist/runtime/config/index.d.ts.map +1 -1
  90. package/core/dist/runtime/config/index.js +2 -0
  91. package/core/dist/runtime/config/index.js.map +1 -1
  92. package/core/dist/runtime/config/pd-config-redaction.d.ts.map +1 -1
  93. package/core/dist/runtime/config/pd-config-redaction.js +4 -0
  94. package/core/dist/runtime/config/pd-config-redaction.js.map +1 -1
  95. package/core/dist/runtime/config/pd-config-types.d.ts +5 -0
  96. package/core/dist/runtime/config/pd-config-types.d.ts.map +1 -1
  97. package/core/dist/runtime/config/pd-config-types.js.map +1 -1
  98. package/core/dist/runtime/config/pd-credentials.d.ts +105 -0
  99. package/core/dist/runtime/config/pd-credentials.d.ts.map +1 -0
  100. package/core/dist/runtime/config/pd-credentials.js +409 -0
  101. package/core/dist/runtime/config/pd-credentials.js.map +1 -0
  102. package/core/dist/runtime/diagnostician/diag-rootcause-output.d.ts +13 -2
  103. package/core/dist/runtime/diagnostician/diag-rootcause-output.d.ts.map +1 -1
  104. package/core/dist/runtime/diagnostician/diag-rootcause-output.js.map +1 -1
  105. package/core/dist/runtime/diagnostician/diagnostic-context-budget.d.ts +45 -0
  106. package/core/dist/runtime/diagnostician/diagnostic-context-budget.d.ts.map +1 -0
  107. package/core/dist/runtime/diagnostician/diagnostic-context-budget.js +74 -0
  108. package/core/dist/runtime/diagnostician/diagnostic-context-budget.js.map +1 -0
  109. package/core/dist/runtime/diagnostician/prompt-projection.d.ts +51 -0
  110. package/core/dist/runtime/diagnostician/prompt-projection.d.ts.map +1 -0
  111. package/core/dist/runtime/diagnostician/prompt-projection.js +192 -0
  112. package/core/dist/runtime/diagnostician/prompt-projection.js.map +1 -0
  113. package/core/dist/runtime/diagnostician-output.d.ts +1 -1
  114. package/core/dist/runtime/diagnostician-output.d.ts.map +1 -1
  115. package/core/dist/runtime/diagnostician-output.js +2 -2
  116. package/core/dist/runtime/diagnostician-output.js.map +1 -1
  117. package/core/dist/runtime/index.d.ts +5 -2
  118. package/core/dist/runtime/index.d.ts.map +1 -1
  119. package/core/dist/runtime/index.js +11 -1
  120. package/core/dist/runtime/index.js.map +1 -1
  121. package/core/dist/runtime/intent/index.d.ts +2 -0
  122. package/core/dist/runtime/intent/index.d.ts.map +1 -1
  123. package/core/dist/runtime/intent/index.js +2 -0
  124. package/core/dist/runtime/intent/index.js.map +1 -1
  125. package/core/dist/runtime/intent/intent-decision-record.d.ts +51 -3
  126. package/core/dist/runtime/intent/intent-decision-record.d.ts.map +1 -1
  127. package/core/dist/runtime/intent/intent-snapshot.d.ts +104 -0
  128. package/core/dist/runtime/intent/intent-snapshot.d.ts.map +1 -0
  129. package/core/dist/runtime/intent/intent-snapshot.js +164 -0
  130. package/core/dist/runtime/intent/intent-snapshot.js.map +1 -0
  131. package/core/dist/runtime/intent/strategic-conflict-gate.d.ts +70 -0
  132. package/core/dist/runtime/intent/strategic-conflict-gate.d.ts.map +1 -0
  133. package/core/dist/runtime/intent/strategic-conflict-gate.js +148 -0
  134. package/core/dist/runtime/intent/strategic-conflict-gate.js.map +1 -0
  135. package/core/dist/runtime/internalization/artificer-runner.js +1 -1
  136. package/core/dist/runtime/internalization/artificer-runner.js.map +1 -1
  137. package/core/dist/runtime/internalization/diag-distiller-runner.d.ts +6 -0
  138. package/core/dist/runtime/internalization/diag-distiller-runner.d.ts.map +1 -1
  139. package/core/dist/runtime/internalization/diag-distiller-runner.js +62 -5
  140. package/core/dist/runtime/internalization/diag-distiller-runner.js.map +1 -1
  141. package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts +41 -1
  142. package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts.map +1 -1
  143. package/core/dist/runtime/internalization/diag-rootcause-runner.js +190 -43
  144. package/core/dist/runtime/internalization/diag-rootcause-runner.js.map +1 -1
  145. package/core/dist/runtime/internalization/diag-router-runner.d.ts +6 -0
  146. package/core/dist/runtime/internalization/diag-router-runner.d.ts.map +1 -1
  147. package/core/dist/runtime/internalization/diag-router-runner.js +114 -69
  148. package/core/dist/runtime/internalization/diag-router-runner.js.map +1 -1
  149. package/core/dist/runtime/internalization/dreamer-prompt-builder.d.ts.map +1 -1
  150. package/core/dist/runtime/internalization/dreamer-prompt-builder.js +3 -0
  151. package/core/dist/runtime/internalization/dreamer-prompt-builder.js.map +1 -1
  152. package/core/dist/runtime/internalization/dreamer-runner.js +1 -1
  153. package/core/dist/runtime/internalization/dreamer-runner.js.map +1 -1
  154. package/core/dist/runtime/internalization/evaluator-runner.js +4 -4
  155. package/core/dist/runtime/internalization/evaluator-runner.js.map +1 -1
  156. package/core/dist/runtime/internalization/formation-context.d.ts +54 -0
  157. package/core/dist/runtime/internalization/formation-context.d.ts.map +1 -1
  158. package/core/dist/runtime/internalization/formation-context.js +135 -3
  159. package/core/dist/runtime/internalization/formation-context.js.map +1 -1
  160. package/core/dist/runtime/internalization/index.d.ts +2 -2
  161. package/core/dist/runtime/internalization/index.d.ts.map +1 -1
  162. package/core/dist/runtime/internalization/index.js +1 -1
  163. package/core/dist/runtime/internalization/index.js.map +1 -1
  164. package/core/dist/runtime/internalization/intent-contract.d.ts +107 -0
  165. package/core/dist/runtime/internalization/intent-contract.d.ts.map +1 -1
  166. package/core/dist/runtime/internalization/intent-contract.js +315 -4
  167. package/core/dist/runtime/internalization/intent-contract.js.map +1 -1
  168. package/core/dist/runtime/internalization/peer-runner-contracts.d.ts +8 -0
  169. package/core/dist/runtime/internalization/peer-runner-contracts.d.ts.map +1 -1
  170. package/core/dist/runtime/internalization/peer-runner-contracts.js.map +1 -1
  171. package/core/dist/runtime/internalization/philosopher-prompt-builder.d.ts +22 -1
  172. package/core/dist/runtime/internalization/philosopher-prompt-builder.d.ts.map +1 -1
  173. package/core/dist/runtime/internalization/philosopher-prompt-builder.js +22 -3
  174. package/core/dist/runtime/internalization/philosopher-prompt-builder.js.map +1 -1
  175. package/core/dist/runtime/internalization/philosopher-runner.d.ts +15 -0
  176. package/core/dist/runtime/internalization/philosopher-runner.d.ts.map +1 -1
  177. package/core/dist/runtime/internalization/philosopher-runner.js +74 -2
  178. package/core/dist/runtime/internalization/philosopher-runner.js.map +1 -1
  179. package/core/dist/runtime/internalization/pitask-metadata.d.ts +32 -0
  180. package/core/dist/runtime/internalization/pitask-metadata.d.ts.map +1 -1
  181. package/core/dist/runtime/internalization/pitask-metadata.js +44 -0
  182. package/core/dist/runtime/internalization/pitask-metadata.js.map +1 -1
  183. package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts +6 -1
  184. package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts.map +1 -1
  185. package/core/dist/runtime/internalization/rollout-reviewer-runner.js +31 -15
  186. package/core/dist/runtime/internalization/rollout-reviewer-runner.js.map +1 -1
  187. package/core/dist/runtime/internalization/scribe-output.d.ts +21 -0
  188. package/core/dist/runtime/internalization/scribe-output.d.ts.map +1 -1
  189. package/core/dist/runtime/internalization/scribe-output.js +125 -2
  190. package/core/dist/runtime/internalization/scribe-output.js.map +1 -1
  191. package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts +26 -1
  192. package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts.map +1 -1
  193. package/core/dist/runtime/internalization/scribe-prompt-builder.js +33 -3
  194. package/core/dist/runtime/internalization/scribe-prompt-builder.js.map +1 -1
  195. package/core/dist/runtime/internalization/scribe-runner.d.ts +32 -2
  196. package/core/dist/runtime/internalization/scribe-runner.d.ts.map +1 -1
  197. package/core/dist/runtime/internalization/scribe-runner.js +106 -8
  198. package/core/dist/runtime/internalization/scribe-runner.js.map +1 -1
  199. package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts +46 -0
  200. package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts.map +1 -1
  201. package/core/dist/runtime/internalization/split-diagnostician-runner.js +220 -20
  202. package/core/dist/runtime/internalization/split-diagnostician-runner.js.map +1 -1
  203. package/core/dist/runtime/internalization-integrity-remediation.d.ts +7 -0
  204. package/core/dist/runtime/internalization-integrity-remediation.d.ts.map +1 -1
  205. package/core/dist/runtime/internalization-integrity-remediation.js +44 -12
  206. package/core/dist/runtime/internalization-integrity-remediation.js.map +1 -1
  207. package/core/dist/runtime/pain-signal-runtime-factory.d.ts.map +1 -1
  208. package/core/dist/runtime/pain-signal-runtime-factory.js +25 -4
  209. package/core/dist/runtime/pain-signal-runtime-factory.js.map +1 -1
  210. package/core/dist/runtime/pain-submit-capability.js +5 -5
  211. package/core/dist/runtime/pain-submit-capability.js.map +1 -1
  212. package/core/dist/runtime/runner/base-peer-runner.d.ts +90 -2
  213. package/core/dist/runtime/runner/base-peer-runner.d.ts.map +1 -1
  214. package/core/dist/runtime/runner/base-peer-runner.js +463 -170
  215. package/core/dist/runtime/runner/base-peer-runner.js.map +1 -1
  216. package/core/dist/runtime/runner/peer-runner-types.d.ts +19 -0
  217. package/core/dist/runtime/runner/peer-runner-types.d.ts.map +1 -1
  218. package/core/dist/runtime/runtime-protocol.d.ts +19 -0
  219. package/core/dist/runtime/runtime-protocol.d.ts.map +1 -1
  220. package/core/dist/runtime/signal-collector/llm-stage.d.ts +5 -0
  221. package/core/dist/runtime/signal-collector/llm-stage.d.ts.map +1 -1
  222. package/core/dist/runtime/signal-collector/llm-stage.js.map +1 -1
  223. package/core/dist/runtime/store/artifact/sqlite-pi-artifact-store.d.ts +14 -0
  224. package/core/dist/runtime/store/artifact/sqlite-pi-artifact-store.d.ts.map +1 -1
  225. package/core/dist/runtime/store/artifact/sqlite-pi-artifact-store.js +16 -1
  226. package/core/dist/runtime/store/artifact/sqlite-pi-artifact-store.js.map +1 -1
  227. package/core/dist/runtime/store/commit/diagnostician-committer.d.ts +19 -0
  228. package/core/dist/runtime/store/commit/diagnostician-committer.d.ts.map +1 -1
  229. package/core/dist/runtime/store/commit/diagnostician-committer.js +11 -0
  230. package/core/dist/runtime/store/commit/diagnostician-committer.js.map +1 -1
  231. package/core/dist/runtime/store/intent/sqlite-intent-decision-store.d.ts +2 -2
  232. package/core/dist/runtime/store/intent/sqlite-intent-decision-store.d.ts.map +1 -1
  233. package/core/dist/runtime/store/intent/sqlite-intent-decision-store.js +285 -35
  234. package/core/dist/runtime/store/intent/sqlite-intent-decision-store.js.map +1 -1
  235. package/core/dist/runtime/store/lifecycle/fenced-task-writer.d.ts +64 -0
  236. package/core/dist/runtime/store/lifecycle/fenced-task-writer.d.ts.map +1 -0
  237. package/core/dist/runtime/store/lifecycle/fenced-task-writer.js +231 -0
  238. package/core/dist/runtime/store/lifecycle/fenced-task-writer.js.map +1 -0
  239. package/core/dist/runtime/store/lifecycle/index.d.ts +2 -0
  240. package/core/dist/runtime/store/lifecycle/index.d.ts.map +1 -1
  241. package/core/dist/runtime/store/lifecycle/index.js +1 -0
  242. package/core/dist/runtime/store/lifecycle/index.js.map +1 -1
  243. package/core/dist/runtime/store/lifecycle/lease-fence.d.ts +80 -0
  244. package/core/dist/runtime/store/lifecycle/lease-fence.d.ts.map +1 -0
  245. package/core/dist/runtime/store/lifecycle/lease-fence.js +79 -0
  246. package/core/dist/runtime/store/lifecycle/lease-fence.js.map +1 -0
  247. package/core/dist/runtime/store/lifecycle/lease-heartbeat.d.ts +118 -0
  248. package/core/dist/runtime/store/lifecycle/lease-heartbeat.d.ts.map +1 -0
  249. package/core/dist/runtime/store/lifecycle/lease-heartbeat.js +187 -0
  250. package/core/dist/runtime/store/lifecycle/lease-heartbeat.js.map +1 -0
  251. package/core/dist/runtime/store/lifecycle/lease-manager.d.ts +30 -20
  252. package/core/dist/runtime/store/lifecycle/lease-manager.d.ts.map +1 -1
  253. package/core/dist/runtime/store/lifecycle/lease-manager.js +94 -53
  254. package/core/dist/runtime/store/lifecycle/lease-manager.js.map +1 -1
  255. package/core/dist/runtime/store/lifecycle/recovery-sweep.d.ts.map +1 -1
  256. package/core/dist/runtime/store/lifecycle/recovery-sweep.js +32 -15
  257. package/core/dist/runtime/store/lifecycle/recovery-sweep.js.map +1 -1
  258. package/core/dist/runtime/store/run/sqlite-run-store.d.ts +29 -0
  259. package/core/dist/runtime/store/run/sqlite-run-store.d.ts.map +1 -1
  260. package/core/dist/runtime/store/run/sqlite-run-store.js +40 -0
  261. package/core/dist/runtime/store/run/sqlite-run-store.js.map +1 -1
  262. package/core/dist/runtime/store/runtime-state-manager.d.ts +64 -10
  263. package/core/dist/runtime/store/runtime-state-manager.d.ts.map +1 -1
  264. package/core/dist/runtime/store/runtime-state-manager.js +154 -89
  265. package/core/dist/runtime/store/runtime-state-manager.js.map +1 -1
  266. package/core/dist/runtime/store/sqlite-connection.d.ts.map +1 -1
  267. package/core/dist/runtime/store/sqlite-connection.js +73 -4
  268. package/core/dist/runtime/store/sqlite-connection.js.map +1 -1
  269. package/core/dist/runtime/store/task/sqlite-task-store.d.ts.map +1 -1
  270. package/core/dist/runtime/store/task/sqlite-task-store.js +6 -3
  271. package/core/dist/runtime/store/task/sqlite-task-store.js.map +1 -1
  272. package/core/dist/runtime/task-status.d.ts +16 -0
  273. package/core/dist/runtime/task-status.d.ts.map +1 -1
  274. package/core/dist/runtime/task-status.js +8 -0
  275. package/core/dist/runtime/task-status.js.map +1 -1
  276. package/core/dist/runtime/trajectory-schema.d.ts.map +1 -1
  277. package/core/dist/runtime/trajectory-schema.js +20 -1
  278. package/core/dist/runtime/trajectory-schema.js.map +1 -1
  279. package/core/dist/runtime/types/event-types.d.ts +20 -0
  280. package/core/dist/runtime/types/event-types.d.ts.map +1 -1
  281. package/core/dist/runtime/types/event-types.js +7 -0
  282. package/core/dist/runtime/types/event-types.js.map +1 -1
  283. package/core/dist/telemetry-event.d.ts +2 -2
  284. package/core/dist/telemetry-event.d.ts.map +1 -1
  285. package/core/dist/telemetry-event.js +27 -2
  286. package/core/dist/telemetry-event.js.map +1 -1
  287. package/core/dist/trajectory-types.d.ts +33 -0
  288. package/core/dist/trajectory-types.d.ts.map +1 -1
  289. package/core/package.json +1 -1
  290. package/dist/installer.d.ts.map +1 -1
  291. package/dist/installer.js +12 -5
  292. package/dist/installer.js.map +1 -1
  293. package/dist/installers/codex-host-installer.d.ts.map +1 -1
  294. package/dist/installers/codex-host-installer.js +9 -12
  295. package/dist/installers/codex-host-installer.js.map +1 -1
  296. package/host-runtime/dist/adaptive-consumer-schedule.d.ts +103 -0
  297. package/host-runtime/dist/adaptive-consumer-schedule.js +145 -0
  298. package/host-runtime/dist/adaptive-priority-provider.d.ts +7 -1
  299. package/host-runtime/dist/adaptive-priority-provider.js +6 -3
  300. package/host-runtime/dist/adaptive-selection.d.ts +1 -1
  301. package/host-runtime/dist/adaptive-selection.js +2 -1
  302. package/host-runtime/dist/degraded-enforcement-marker.d.ts +35 -0
  303. package/host-runtime/dist/degraded-enforcement-marker.js +79 -0
  304. package/host-runtime/dist/index.d.ts +2 -0
  305. package/host-runtime/dist/index.js +8 -0
  306. package/host-runtime/dist/internalization-consumer-cycle.d.ts +35 -0
  307. package/host-runtime/dist/internalization-consumer-cycle.js +51 -17
  308. package/host-runtime/dist/prompt-activation-deliverability.d.ts +10 -0
  309. package/host-runtime/dist/prompt-activation-deliverability.js +5 -2
  310. package/host-runtime/dist/prompt-injection-event-evidence.d.ts +34 -0
  311. package/host-runtime/dist/prompt-injection-event-evidence.js +96 -0
  312. package/host-runtime/dist/signal-classifier.js +4 -4
  313. package/host-runtime/package.json +1 -1
  314. package/install-layout/dist/mcp-binding-contract.js +4 -15
  315. package/install-layout/package.json +1 -1
  316. package/package.json +3 -3
  317. package/pd-cli/dist/commands/health-codex.d.ts.map +1 -1
  318. package/pd-cli/dist/commands/health-codex.js +26 -1
  319. package/pd-cli/dist/commands/health-codex.js.map +1 -1
  320. package/pd-cli/dist/commands/health.d.ts.map +1 -1
  321. package/pd-cli/dist/commands/health.js +32 -2
  322. package/pd-cli/dist/commands/health.js.map +1 -1
  323. package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
  324. package/pd-cli/dist/commands/pain-retry.js +6 -4
  325. package/pd-cli/dist/commands/pain-retry.js.map +1 -1
  326. package/pd-cli/dist/commands/runtime-init.d.ts.map +1 -1
  327. package/pd-cli/dist/commands/runtime-init.js +29 -1
  328. package/pd-cli/dist/commands/runtime-init.js.map +1 -1
  329. package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
  330. package/pd-cli/dist/commands/runtime-internalization-run-once.js +9 -14
  331. package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
  332. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.d.ts.map +1 -1
  333. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js +5 -5
  334. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js.map +1 -1
  335. package/pd-cli/dist/commands/runtime-usage.d.ts +62 -0
  336. package/pd-cli/dist/commands/runtime-usage.d.ts.map +1 -0
  337. package/pd-cli/dist/commands/runtime-usage.js +315 -0
  338. package/pd-cli/dist/commands/runtime-usage.js.map +1 -0
  339. package/pd-cli/dist/commands/runtime.js +6 -6
  340. package/pd-cli/dist/commands/runtime.js.map +1 -1
  341. package/pd-cli/dist/index.d.ts.map +1 -1
  342. package/pd-cli/dist/index.js +51 -17
  343. package/pd-cli/dist/index.js.map +1 -1
  344. package/pd-cli/dist/program.d.ts.map +1 -1
  345. package/pd-cli/dist/program.js +4 -0
  346. package/pd-cli/dist/program.js.map +1 -1
  347. package/pd-cli/dist/services/cli-invocation-log.d.ts +66 -0
  348. package/pd-cli/dist/services/cli-invocation-log.d.ts.map +1 -0
  349. package/pd-cli/dist/services/cli-invocation-log.js +139 -0
  350. package/pd-cli/dist/services/cli-invocation-log.js.map +1 -0
  351. package/pd-cli/dist/services/config-doctor.d.ts.map +1 -1
  352. package/pd-cli/dist/services/config-doctor.js +5 -4
  353. package/pd-cli/dist/services/config-doctor.js.map +1 -1
  354. package/pd-cli/dist/services/demo-story-a-runner.d.ts.map +1 -1
  355. package/pd-cli/dist/services/demo-story-a-runner.js +6 -2
  356. package/pd-cli/dist/services/demo-story-a-runner.js.map +1 -1
  357. package/pd-cli/dist/services/pd-config-loader.d.ts +3 -1
  358. package/pd-cli/dist/services/pd-config-loader.d.ts.map +1 -1
  359. package/pd-cli/dist/services/pd-config-loader.js +20 -8
  360. package/pd-cli/dist/services/pd-config-loader.js.map +1 -1
  361. package/pd-cli/dist/services/runtime-adapter-resolver.d.ts.map +1 -1
  362. package/pd-cli/dist/services/runtime-adapter-resolver.js +5 -5
  363. package/pd-cli/dist/services/runtime-adapter-resolver.js.map +1 -1
  364. package/pd-cli/package.json +1 -1
  365. package/plugin/dist/bundle.js +632 -536
  366. package/plugin/dist/core/signal-collector-host.d.ts +5 -0
  367. package/plugin/dist/governance-audit.js +2 -2
  368. package/plugin/dist/openclaw.plugin.json +1 -1
  369. package/plugin/dist/rulehost-evidence.js +13 -10
  370. package/plugin/dist/service/internalization-auto-consumer-service.d.ts +2 -1
  371. package/plugin/dist/templates/langs/en/skills/pd-pain-signal/SKILL.md +1 -1
  372. package/plugin/dist/templates/langs/zh/skills/pd-pain-signal/SKILL.md +1 -1
  373. package/plugin/openclaw.plugin.json +1 -1
  374. package/plugin/package.json +1 -1
  375. package/plugin/templates/langs/en/skills/pd-pain-signal/SKILL.md +1 -1
  376. package/plugin/templates/langs/zh/skills/pd-pain-signal/SKILL.md +1 -1
  377. package/release-manager/dist/installer.js +12 -5
  378. package/release-manager/dist/installers/codex-host-installer.js +9 -12
  379. package/release-manager/package.json +1 -1
  380. package/workbuddy-adapter/package.json +1 -1
  381. package/workbuddy-adapter/plugin/skills/pd-pain-signal/SKILL.md +1 -1
  382. package/dist/installers/mcp-binding-shape-mirror.d.ts +0 -27
  383. package/dist/installers/mcp-binding-shape-mirror.d.ts.map +0 -1
  384. package/dist/installers/mcp-binding-shape-mirror.js +0 -105
  385. package/dist/installers/mcp-binding-shape-mirror.js.map +0 -1
  386. package/release-manager/dist/installers/mcp-binding-shape-mirror.js +0 -105
@@ -163,10 +163,12 @@ export class ApprovalsConsoleModel {
163
163
  // error (409) untouched by both gates.
164
164
  let supersedeActivationId;
165
165
  let supersedeArtifactId;
166
+ let precheckSnapshot;
166
167
  if (existing.channel === 'prompt' && (existing.status === 'pending' || (existing.status === 'approved' && options?.retryActivation === true))) {
167
168
  const precheck = await this.precheckPromptCapacity(existing.artifactId, targetHost);
168
- if (precheck !== undefined)
169
+ if (precheck.ok === false)
169
170
  return precheck;
171
+ precheckSnapshot = precheck.snapshot;
170
172
  const { connection } = this.createReadContext();
171
173
  try {
172
174
  const piArtifactStore = new SqlitePIArtifactStore(connection);
@@ -229,6 +231,15 @@ export class ApprovalsConsoleModel {
229
231
  catch { /* best-effort */ }
230
232
  }
231
233
  }
234
+ // P1 review: the precheck above measured a read snapshot; this write runs
235
+ // on a later connection. Re-prove the snapshot first so a lineage/ledger/
236
+ // artifact change in between yields the distinct `precheck_stale` result
237
+ // (reload and re-judge) instead of a wrong allow or a false permanent block.
238
+ if (precheckSnapshot !== undefined) {
239
+ const stale = await this.verifyPromptPrecheckFreshness(precheckSnapshot);
240
+ if (stale !== undefined)
241
+ return stale;
242
+ }
232
243
  const { queue: writeQueue, connection: writeConnection } = this.createWriteContext();
233
244
  let approvalResult;
234
245
  try {
@@ -245,6 +256,9 @@ export class ApprovalsConsoleModel {
245
256
  if (!approvalResult.ok) {
246
257
  if (approvalResult.error === 'stale_review')
247
258
  return approvalResult;
259
+ if (approvalResult.error === 'strategic_conflict_unconfirmed') {
260
+ return { ok: false, error: approvalResult.error, reason: approvalResult.reason, nextAction: approvalResult.nextAction };
261
+ }
248
262
  if (approvalResult.error === 'already_decided') {
249
263
  return { ok: false, error: 'already_decided', status: approvalResult.status };
250
264
  }
@@ -335,7 +349,59 @@ export class ApprovalsConsoleModel {
335
349
  */
336
350
  async precheckPromptCapacity(artifactId, targetHost) {
337
351
  let deliverability;
352
+ let snapshot;
338
353
  try {
354
+ // The capacity precheck must bill the entry under the identity it will
355
+ // ACTUALLY activate as. Legacy scribe artifacts predate the identity
356
+ // column, but their ledger principle is still reachable through the
357
+ // candidate lineage — the dispatcher resolves it that way. Without this,
358
+ // the precheck refused such artifacts as `artifact_missing_principle_id`
359
+ // even though activation would have succeeded.
360
+ let resolvedPrincipleId;
361
+ let identityUnresolvedReason;
362
+ const { connection } = this.createReadContext();
363
+ try {
364
+ const piArtifactStore = new SqlitePIArtifactStore(connection);
365
+ const artifact = await piArtifactStore.getArtifactById(artifactId);
366
+ if (artifact !== null) {
367
+ const resolution = await resolveLedgerPrincipleId(artifact, createArtifactPrincipleResolutionDeps(connection, piArtifactStore, this.workspaceDir));
368
+ if (resolution.status === 'resolved') {
369
+ resolvedPrincipleId = resolution.principleId;
370
+ snapshot = {
371
+ artifactId: artifact.artifactId,
372
+ artifactUpdatedAt: artifact.updatedAt,
373
+ contentJson: artifact.contentJson,
374
+ resolvedPrincipleId: resolution.principleId,
375
+ };
376
+ }
377
+ else
378
+ identityUnresolvedReason = resolution.reason;
379
+ }
380
+ }
381
+ finally {
382
+ try {
383
+ connection.close();
384
+ }
385
+ catch { /* best-effort */ }
386
+ }
387
+ // The activation boundary would refuse this identity too. Refusing here
388
+ // keeps the approval from being written and then failing activation; the
389
+ // reason matches what the Owner must repair (or they reject instead).
390
+ if (identityUnresolvedReason !== undefined) {
391
+ // An unreadable ledger is a TRANSIENT failure, not missing provenance.
392
+ // Emitting `artifact_content_unresolved` here would tell the Owner the
393
+ // record can never be approved; the honest code is retry-after-repair.
394
+ const transientLedgerFailure = identityUnresolvedReason.includes('ledger_unavailable');
395
+ return {
396
+ ok: false,
397
+ error: 'prompt_capacity_refused',
398
+ reason: `${transientLedgerFailure ? 'authority_unreadable' : 'artifact_content_unresolved'}: ${identityUnresolvedReason}`,
399
+ nextAction: transientLedgerFailure
400
+ ? 'repair the principle ledger readability, then retry the approval'
401
+ : 'repair this material\'s source identity or reject the approval',
402
+ capacity: { category: 'content_unconfirmed' },
403
+ };
404
+ }
339
405
  deliverability = await checkPromptArtifactDeliverabilityById({
340
406
  workspaceDir: this.workspaceDir,
341
407
  artifactId,
@@ -345,6 +411,7 @@ export class ApprovalsConsoleModel {
345
411
  // the pre-approval default (system_policy) overstated the entry by
346
412
  // the attribute delta and could refuse a borderline-fitting entry.
347
413
  authority: 'owner',
414
+ ...(resolvedPrincipleId !== undefined ? { resolvedPrincipleId } : {}),
348
415
  });
349
416
  }
350
417
  catch (error) {
@@ -358,15 +425,16 @@ export class ApprovalsConsoleModel {
358
425
  capacity: { category: 'content_unconfirmed' },
359
426
  };
360
427
  }
428
+ const success = () => ({ ok: true, ...(snapshot !== undefined ? { snapshot } : {}) });
361
429
  if (deliverability.status === 'deliverable')
362
- return undefined;
430
+ return success();
363
431
  // SPEC-PD-MODEL-AWARE-PROMPT-BUDGET-001 §6.3: model_dependent is NOT a
364
432
  // refusal — the entry fits within the supported budget range and whether
365
433
  // it injects depends on the runtime model. The approval proceeds; the
366
434
  // honest uncertainty is already visible on the pre-approval badge
367
435
  // (promptBudgetTierFit) and the activation status surface.
368
436
  if (deliverability.status === 'model_dependent')
369
- return undefined;
437
+ return success();
370
438
  if (deliverability.status === 'undeliverable') {
371
439
  return {
372
440
  ok: false,
@@ -396,6 +464,53 @@ export class ApprovalsConsoleModel {
396
464
  },
397
465
  };
398
466
  }
467
+ /**
468
+ * P1 review: the precheck measures one read snapshot, the approval write runs
469
+ * on another connection. Re-resolve on a fresh read snapshot immediately
470
+ * before the write and refuse with a DISTINCT `precheck_stale` result when
471
+ * the material or its ledger identity moved. This never turns a transient
472
+ * change into a permanent "cannot approve" verdict and never writes an
473
+ * approval whose measured identity/mission no longer holds.
474
+ */
475
+ async verifyPromptPrecheckFreshness(snapshot) {
476
+ const stale = (reason, nextAction) => ({
477
+ ok: false,
478
+ error: 'precheck_stale',
479
+ reason,
480
+ nextAction,
481
+ });
482
+ const { connection } = this.createReadContext();
483
+ try {
484
+ const piArtifactStore = new SqlitePIArtifactStore(connection);
485
+ const artifact = await piArtifactStore.getArtifactById(snapshot.artifactId);
486
+ if (artifact === null) {
487
+ return stale('artifact_unavailable: the material disappeared after the precheck', 'reload this approval; the card will show the current availability');
488
+ }
489
+ if (artifact.updatedAt !== snapshot.artifactUpdatedAt || artifact.contentJson !== snapshot.contentJson) {
490
+ return stale('artifact_replaced: the material content changed after the precheck', 'reload this approval and review the new material before approving');
491
+ }
492
+ const resolution = await resolveLedgerPrincipleId(artifact, createArtifactPrincipleResolutionDeps(connection, piArtifactStore, this.workspaceDir));
493
+ if (resolution.status !== 'resolved') {
494
+ const transient = resolution.reason.includes('ledger_unavailable');
495
+ return stale(`${transient ? 'authority_unreadable' : 'artifact_content_unresolved'}: ${resolution.reason}`, transient
496
+ ? 'repair the principle ledger readability, then reload and retry'
497
+ : 'reload this approval; its source identity no longer resolves, then reject or repair it');
498
+ }
499
+ if (snapshot.resolvedPrincipleId !== undefined && resolution.principleId !== snapshot.resolvedPrincipleId) {
500
+ return stale(`ledger_identity_changed: the material now resolves to ${resolution.principleId} instead of ${snapshot.resolvedPrincipleId}`, 'reload this approval and review it against the current identity before approving');
501
+ }
502
+ return undefined;
503
+ }
504
+ catch (error) {
505
+ return stale(`precheck_freshness_unreadable: ${errorMessage(error)}`, 'check the workspace .pd/state.db readability, then reload and retry');
506
+ }
507
+ finally {
508
+ try {
509
+ connection.close();
510
+ }
511
+ catch { /* best-effort */ }
512
+ }
513
+ }
399
514
  /**
400
515
  * PRI-890 (PRI-768 v6-02): recompute the production prompt injection
401
516
  * projection and report whether `activationId` made it into the injected
@@ -1,5 +1,21 @@
1
1
  import { type PromptInjectionTargetHost } from '@principles/host-runtime';
2
+ import type { StrategicConflictView } from '@principles/core/runtime';
2
3
  import type { PromptInjectionBudgetStatus } from '../../shared/prompt-injection-contract.js';
4
+ export type ApprovalApproveBlockCode = 'identity_unresolved' | 'artifact_unavailable' | 'budget_exceeded' | 'route_unconfirmed' | 'authority_unreadable' | 'content_unconfirmed'
5
+ /**
6
+ * SIA v1.2 (TECH §8.3/§8.5): a CONFIRMED strategic conflict has no effective
7
+ * resolution for this exact contract. Computed by the SAME server function
8
+ * `SqliteApprovalStore.approve()` runs, so the card can never promise an
9
+ * approval the write path refuses.
10
+ */
11
+ | 'strategic_conflict_unconfirmed';
12
+ export interface ApprovalApproveBlock {
13
+ code: ApprovalApproveBlockCode;
14
+ /** Machine-readable server reason (technical details; not the card copy). */
15
+ reason: string;
16
+ /** The server precheck's executable next step. */
17
+ nextAction: string;
18
+ }
3
19
  export interface ApprovalGroup {
4
20
  principleId: string;
5
21
  principleTitle: string;
@@ -50,12 +66,34 @@ export interface ApprovalGroup {
50
66
  artifactId: string;
51
67
  channel: string;
52
68
  createdAt: string;
69
+ /**
70
+ * Why THIS record cannot be approved from the review card right now. The
71
+ * server's approve precheck refuses the same conditions, so the card must
72
+ * not offer a button whose only outcome is a failure. Absent when approval
73
+ * is available. Computed per artifact: a group can hold several pending
74
+ * records, and a block proved for one of them must never fence its
75
+ * siblings. Rejecting stays legal — that is the Owner's exit for a record
76
+ * that can never be approved (the history is kept, not hidden).
77
+ */
78
+ approveBlock?: ApprovalApproveBlock;
53
79
  /**
54
80
  * This record's own revision review is incomplete (the group flag also
55
81
  * covers the multi-pending ambiguity, so readers must not use it to block
56
82
  * an intact sibling approval).
57
83
  */
58
84
  revisionReviewUnavailable?: boolean;
85
+ /**
86
+ * SIA v1.2: the strategic assessment carried by THIS record's V2 contract
87
+ * (relevance / conflictStatus / conflict targets) plus whether a confirmed
88
+ * conflict is effectively resolved. Absent for V1 artifacts. Read-only
89
+ * projection of the same predicate the approval write path enforces.
90
+ *
91
+ * REVIEW FIX (PR #2652 P1-5): the verdict is per-approval, never per-group.
92
+ * Two pending artifacts in one candidate group can have different conflict
93
+ * states; a group-level copy fenced the sibling with the first artifact's
94
+ * verdict.
95
+ */
96
+ strategicConflict?: StrategicConflictView;
59
97
  }[];
60
98
  }
61
99
  export interface ApprovalsGroupedResponse {
@@ -1,11 +1,12 @@
1
- import { SqliteConnection, SqliteApprovalQueueStore, SqlitePIArtifactStore, ApprovalQueue, RUNTIME_PRINCIPLE_BUDGET, detectPromptReplacementTarget, computeArtifactDigest, SqliteActivationStateStore, } from '@principles/core/runtime';
1
+ import { SqliteConnection, SqliteApprovalQueueStore, SqlitePIArtifactStore, ApprovalQueue, RUNTIME_PRINCIPLE_BUDGET, detectPromptReplacementTarget, computeArtifactDigest, SqliteActivationStateStore, readStrategicConflictView, } from '@principles/core/runtime';
2
2
  import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
3
3
  import { checkPromptArtifactDeliverability, hostRotationCapability, operatorDeclaredBudgetResolution, resolveLivePromptInjectionProjection, RUNTIME_BUDGET_OBSERVATION_STALE_REASON, runtimeBudgetObservationToResolution, selectConsoleRuntimeBudgetFacts, } from '@principles/host-runtime';
4
4
  import { PROMPT_BUDGET_HOST_KINDS } from '@principles/core/runtime';
5
5
  import { loadLedger } from '@principles/core/principle-tree-ledger';
6
6
  import { loadPdConfig } from '../config/pd-config-store.js';
7
7
  import { errorMessage } from '../utils/response.js';
8
- import { createArtifactPrincipleResolutionDeps, resolveArtifactPrincipleId, } from './artifact-principle-resolver.js';
8
+ import { createArtifactPrincipleResolutionDeps, } from './artifact-principle-resolver.js';
9
+ import { resolveLedgerPrincipleId } from './principle-id-resolution.js';
9
10
  import * as fs from 'node:fs';
10
11
  import * as path from 'node:path';
11
12
  /** Type guard: non-null object (not array). Replaces `as Record<string, unknown>` assertions. */
@@ -122,45 +123,121 @@ function extractCandidateDescription(contentJson) {
122
123
  * conservative answer when the precheck itself fails — an unknown size must
123
124
  * never become a rotation promise (rc-9).
124
125
  */
125
- async function candidatePromptBudgetTierFit(workspaceDir, artifact, targetHost) {
126
+ /**
127
+ * Map the precheck's honest verdict onto the review card's "cannot approve"
128
+ * signal. `deliverable` and `model_dependent` are approvable; everything else
129
+ * is refused by the approve precheck, so the card must not offer the action.
130
+ * The code only selects owner-facing copy — the raw reason and nextAction ride
131
+ * along for the technical-details layer.
132
+ */
133
+ function approveBlockFromDeliverability(deliverability) {
134
+ if (deliverability.status === 'deliverable' || deliverability.status === 'model_dependent')
135
+ return undefined;
136
+ if (deliverability.status === 'undeliverable') {
137
+ return { code: 'budget_exceeded', reason: deliverability.reason, nextAction: deliverability.nextAction };
138
+ }
139
+ const { reason } = deliverability;
140
+ if (deliverability.perHost && deliverability.perHost.length > 0
141
+ && deliverability.perHost.every((entry) => entry.tierFit === 'exceeds_max_tier')) {
142
+ return { code: 'budget_exceeded', reason, nextAction: deliverability.nextAction };
143
+ }
144
+ if (reason.startsWith('route_unconfirmed')) {
145
+ return { code: 'route_unconfirmed', reason, nextAction: deliverability.nextAction };
146
+ }
147
+ if (reason.includes('artifact_unavailable')) {
148
+ return { code: 'artifact_unavailable', reason, nextAction: deliverability.nextAction };
149
+ }
150
+ // A readable-store / unreadable-ledger failure is TRANSIENT: the identity may
151
+ // resolve after repair. Telling the Owner "this can never be approved" would
152
+ // be false and would push them to reject real history.
153
+ if (reason.includes('ledger_unavailable')) {
154
+ return { code: 'authority_unreadable', reason, nextAction: deliverability.nextAction };
155
+ }
156
+ if (reason.includes('artifact_missing_principle_id') || reason.includes('artifact_content_unresolved')) {
157
+ return { code: 'identity_unresolved', reason, nextAction: deliverability.nextAction };
158
+ }
159
+ if (reason.includes('authority') || reason.includes('read_failed')) {
160
+ return { code: 'authority_unreadable', reason, nextAction: deliverability.nextAction };
161
+ }
162
+ return { code: 'content_unconfirmed', reason, nextAction: deliverability.nextAction };
163
+ }
164
+ async function candidatePromptBudgetForecast(input) {
165
+ const { workspaceDir, artifact, resolvedPrincipleId, identityUnresolvedReason, targetHost } = input;
126
166
  const deliverability = await checkPromptArtifactDeliverability({
127
167
  workspaceDir,
128
168
  targetHost,
169
+ // The review card's approve button runs the owner-authority precheck, so
170
+ // the forecast must measure the SAME post-approval entry. Measuring the
171
+ // pre-decision default here could promise an approval gate that then
172
+ // refuses (or vice versa) at the boundary.
173
+ authority: 'owner',
129
174
  artifact: artifact
130
175
  ? {
131
176
  artifactId: artifact.artifactId,
132
177
  artifactKind: artifact.artifactKind,
133
178
  contentJson: artifact.contentJson,
134
179
  validationStatus: artifact.validationStatus,
180
+ ...(artifact.sourcePrincipleId !== null ? { sourcePrincipleId: artifact.sourcePrincipleId } : {}),
181
+ // Legacy scribe artifacts were written before the identity column was
182
+ // stamped. Their real identity is the ledger principle reachable
183
+ // through the candidate lineage — the same authority the activation
184
+ // dispatcher uses. Passing it keeps this precheck from refusing a
185
+ // record that would activate successfully.
186
+ ...(resolvedPrincipleId !== null ? { resolvedPrincipleId } : {}),
135
187
  }
136
188
  : null,
137
189
  });
138
- if (deliverability.status === 'deliverable')
139
- return 'fits_all_tiers';
140
- if (deliverability.status === 'model_dependent')
141
- return 'model_dependent';
142
- if (deliverability.status === 'undeliverable')
143
- return 'exceeds_max_tier';
144
190
  // Route/artifact unconfirmed: aggregate the per-host tier verdicts
145
191
  // MONOTONICALLY. The list route bills ~700 fewer chars than the shared
146
192
  // route for the same entry (fixed wrapper delta), so "shared exceeds but
147
- // list does not" is REACHABLE (e.g. a ~15300-char statement: list ≈15341
148
- // = model_dependent, shared ≈16058 = exceeds). Collapsing that to
149
- // exceeds_max_tier would tell an OpenClaw owner their entry can never
150
- // inject when a large-window list-route host could carry it. Only when
151
- // EVERY applicable host exceeds is "oversized everywhere" true; any
152
- // disagreement leaves the honest model_dependent. Without per-host
153
- // facts, do not promise at all.
154
- if (deliverability.perHost && deliverability.perHost.length > 0) {
155
- if (deliverability.perHost.every((entry) => entry.tierFit === 'exceeds_max_tier')) {
156
- return 'exceeds_max_tier';
157
- }
158
- if (deliverability.perHost.every((entry) => entry.tierFit === 'fits_all_tiers')) {
159
- return 'fits_all_tiers';
193
+ // list does not" is REACHABLE. Collapsing that to exceeds_max_tier would
194
+ // tell an OpenClaw owner their entry can never inject when a large-window
195
+ // list-route host could carry it. Only when EVERY applicable host exceeds
196
+ // is "oversized everywhere" true; any disagreement leaves the honest
197
+ // model_dependent. Without per-host facts, do not promise at all.
198
+ const tierFit = deliverability.status === 'deliverable'
199
+ ? 'fits_all_tiers'
200
+ : deliverability.status === 'model_dependent'
201
+ ? 'model_dependent'
202
+ : deliverability.status === 'undeliverable'
203
+ ? 'exceeds_max_tier'
204
+ : (deliverability.perHost && deliverability.perHost.length > 0
205
+ ? (deliverability.perHost.every((entry) => entry.tierFit === 'exceeds_max_tier')
206
+ ? 'exceeds_max_tier'
207
+ : deliverability.perHost.every((entry) => entry.tierFit === 'fits_all_tiers')
208
+ ? 'fits_all_tiers'
209
+ : 'model_dependent')
210
+ : 'unconfirmed');
211
+ const block = approveBlockFromDeliverability(deliverability);
212
+ // A prompt approval is only executable when the activation boundary can
213
+ // name its ledger principle. `resolvedPrincipleId === null` means the direct
214
+ // column already failed ledger membership AND the candidate lineage is
215
+ // unresolved, so activation would refuse even if the deliverability precheck
216
+ // accepted the stale column. Surface the identity failure as the block.
217
+ if (artifact !== null && resolvedPrincipleId === null) {
218
+ // An UNREADABLE ledger is not data drift: the identity may resolve after
219
+ // the ledger is repaired, so the honest verdict is "refresh later", not the
220
+ // permanent "never approvable" copy reserved for genuinely unlinked rows.
221
+ if (identityUnresolvedReason?.includes('ledger_unavailable') === true) {
222
+ return {
223
+ tierFit,
224
+ block: {
225
+ code: 'authority_unreadable',
226
+ reason: identityUnresolvedReason,
227
+ nextAction: 'repair the principle ledger readability, then reload this page',
228
+ },
229
+ };
160
230
  }
161
- return 'model_dependent';
231
+ return {
232
+ tierFit,
233
+ block: {
234
+ code: 'identity_unresolved',
235
+ reason: identityUnresolvedReason ?? 'artifact has no ledger-valid identity (direct column not in ledger, candidate lineage unresolved)',
236
+ nextAction: 'repair this material\'s source identity or reject the approval',
237
+ },
238
+ };
162
239
  }
163
- return 'unconfirmed';
240
+ return { tierFit, ...(block !== undefined ? { block } : {}) };
164
241
  }
165
242
  export class ApprovalsGroupedConsoleModel {
166
243
  workspaceDir;
@@ -201,19 +278,28 @@ export class ApprovalsGroupedConsoleModel {
201
278
  // the pre-approval badge never promises rotation for an entry that is
202
279
  // oversized (rotation cannot rescue a per-entry overflow).
203
280
  const artifactFitsBudgetMap = new Map();
281
+ const artifactApproveBlockMap = new Map();
204
282
  const revisionReviewUnavailable = new Set();
205
283
  const revisionReviews = new Map();
206
284
  // PRI-940: which approval artifacts are MISSING from the store (superseded
207
285
  // or pruned) — those cards have no contentJson, so the UI must degrade
208
286
  // visibly instead of rendering the `unlinked:` machine id as a title.
209
287
  const artifactUnavailableMap = new Map();
288
+ // SIA v1.2: per-artifact strategic assessment computed read-only with the
289
+ // SAME server predicate the approval write path enforces (TECH §8.5).
290
+ const artifactStrategicMap = new Map();
210
291
  const stateDir = path.join(this.workspaceDir, '.state');
211
292
  const resolutionDeps = createArtifactPrincipleResolutionDeps(conn, artifactStore, this.workspaceDir);
212
293
  for (const approval of allApprovals) {
213
294
  if (!artifactPrincipleMap.has(approval.artifactId)) {
214
295
  try {
215
296
  const artifact = await artifactStore.getArtifactById(approval.artifactId);
216
- const mappedId = artifact ? await resolveArtifactPrincipleId(artifact, resolutionDeps) : null;
297
+ // Keep the resolution STATUS, not just the id: an unreadable ledger
298
+ // and a genuinely unlinked artifact have the same null id but must
299
+ // not share the same Owner-facing verdict.
300
+ const resolution = artifact ? await resolveLedgerPrincipleId(artifact, resolutionDeps) : null;
301
+ const mappedId = resolution?.status === 'resolved' ? resolution.principleId : null;
302
+ const identityUnresolvedReason = resolution?.status === 'unresolved' ? resolution.reason : undefined;
217
303
  artifactPrincipleMap.set(approval.artifactId, mappedId);
218
304
  if (artifact?.contentJson) {
219
305
  artifactDescriptionMap.set(approval.artifactId, extractCandidateDescription(artifact.contentJson));
@@ -221,6 +307,14 @@ export class ApprovalsGroupedConsoleModel {
221
307
  else {
222
308
  artifactDescriptionMap.set(approval.artifactId, null);
223
309
  }
310
+ if (artifact !== null) {
311
+ artifactStrategicMap.set(approval.artifactId, readStrategicConflictView({
312
+ db: conn.getDb(),
313
+ artifactId: artifact.artifactId,
314
+ contentJson: artifact.contentJson,
315
+ artifactDigest: computeArtifactDigest(artifact),
316
+ }));
317
+ }
224
318
  if (artifact?.artifactKind === 'principle' && approval.channel === 'prompt' && approval.status === 'pending') {
225
319
  const detection = await detectPromptReplacementTarget({
226
320
  approvalArtifactId: artifact.artifactId,
@@ -253,7 +347,16 @@ export class ApprovalsGroupedConsoleModel {
253
347
  if (!detection.ok || (detection.target !== null && !revisionReviews.has(artifact.artifactId)))
254
348
  revisionReviewUnavailable.add(artifact.artifactId);
255
349
  }
256
- artifactFitsBudgetMap.set(approval.artifactId, await candidatePromptBudgetTierFit(this.workspaceDir, artifact, targetHost));
350
+ const forecast = await candidatePromptBudgetForecast({
351
+ workspaceDir: this.workspaceDir,
352
+ artifact,
353
+ resolvedPrincipleId: mappedId,
354
+ ...(identityUnresolvedReason !== undefined ? { identityUnresolvedReason } : {}),
355
+ targetHost,
356
+ });
357
+ artifactFitsBudgetMap.set(approval.artifactId, forecast.tierFit);
358
+ if (forecast.block !== undefined)
359
+ artifactApproveBlockMap.set(approval.artifactId, forecast.block);
257
360
  artifactUnavailableMap.set(approval.artifactId, artifact === null);
258
361
  }
259
362
  catch (err) {
@@ -261,6 +364,11 @@ export class ApprovalsGroupedConsoleModel {
261
364
  artifactPrincipleMap.set(approval.artifactId, null);
262
365
  artifactDescriptionMap.set(approval.artifactId, null);
263
366
  artifactFitsBudgetMap.set(approval.artifactId, 'unconfirmed');
367
+ artifactApproveBlockMap.set(approval.artifactId, {
368
+ code: 'artifact_unavailable',
369
+ reason: 'approval_artifact_store_unreadable',
370
+ nextAction: 'check the workspace .pd/state.db readability, then reload',
371
+ });
264
372
  artifactUnavailableMap.set(approval.artifactId, true);
265
373
  }
266
374
  else {
@@ -291,6 +399,28 @@ export class ApprovalsGroupedConsoleModel {
291
399
  const records = groupMap.get(principleId);
292
400
  if (!records)
293
401
  continue;
402
+ // Only a pending PROMPT record uses the prompt precheck; a rule or
403
+ // archive record is not gated by prompt deliverability. Approved /
404
+ // rejected records are history and must not be retro-labelled.
405
+ // The verdict is attached to the RECORD that was measured: a sibling
406
+ // pending record in the same group must not inherit this fence.
407
+ // SIA v1.2: a confirmed-but-unresolved strategic conflict blocks ANY
408
+ // channel — the server refuses the write on every approval channel.
409
+ // REVIEW FIX (PR #2652 P1-5): this verdict belongs to THIS approval's
410
+ // artifact; a sibling pending record must never inherit it.
411
+ const recordStrategic = artifactStrategicMap.get(approval.artifactId);
412
+ const strategicView = approval.status === 'pending' ? recordStrategic : undefined;
413
+ const strategicBlock = strategicView !== undefined && !strategicView.resolved
414
+ ? {
415
+ code: 'strategic_conflict_unconfirmed',
416
+ reason: strategicView.reason ?? 'no_effective_resolution',
417
+ nextAction: strategicView.nextAction ?? 'resolve the confirmed strategic conflict for this contract, then approve again',
418
+ }
419
+ : undefined;
420
+ const promptBlock = approval.status === 'pending' && approval.channel === 'prompt'
421
+ ? artifactApproveBlockMap.get(approval.artifactId)
422
+ : undefined;
423
+ const recordApproveBlock = strategicBlock ?? promptBlock;
294
424
  records.push({
295
425
  id: approval.approvalId,
296
426
  artifactId: approval.artifactId,
@@ -299,6 +429,8 @@ export class ApprovalsGroupedConsoleModel {
299
429
  status: approval.status === 'approved' || approval.status === 'rejected'
300
430
  ? approval.status
301
431
  : 'pending',
432
+ ...(recordApproveBlock !== undefined ? { approveBlock: recordApproveBlock } : {}),
433
+ ...(recordStrategic !== undefined ? { strategicConflict: recordStrategic } : {}),
302
434
  ...(revisionReviewUnavailable.has(approval.artifactId) ? { revisionReviewUnavailable: true } : {}),
303
435
  });
304
436
  }
@@ -23,6 +23,11 @@ export type IntentDecisionRecordResultModel = {
23
23
  ok: true;
24
24
  record: IntentDecisionRecord;
25
25
  created: boolean;
26
+ conflict?: {
27
+ reason: string;
28
+ message: string;
29
+ nextAction: string;
30
+ };
26
31
  } | {
27
32
  ok: false;
28
33
  reason: string;
@@ -43,7 +48,7 @@ export type FollowUpDispatchResultModel = {
43
48
  record: IntentDecisionRecord;
44
49
  } | {
45
50
  ok: false;
46
- reason: 'decision_not_found' | 'state_db_not_found' | 'intent_decisions_table_missing';
51
+ reason: 'decision_not_found' | 'candidate_already_bound' | 'state_db_not_found' | 'intent_decisions_table_missing';
47
52
  nextAction: string;
48
53
  };
49
54
  export declare class IntentDecisionModel {
@@ -59,7 +59,9 @@ export class IntentDecisionModel {
59
59
  try {
60
60
  const store = new SqliteIntentDecisionStore(connection);
61
61
  const result = await store.record(input);
62
- return { ok: true, record: result.record, created: result.created };
62
+ return result.conflict === undefined
63
+ ? { ok: true, record: result.record, created: result.created }
64
+ : { ok: true, record: result.record, created: result.created, conflict: result.conflict };
63
65
  }
64
66
  catch (err) {
65
67
  if (isMissingTableError(err)) {
@@ -177,15 +179,21 @@ export class IntentDecisionModel {
177
179
  const connection = new SqliteConnection({ workspaceDir: this.workspaceDir });
178
180
  try {
179
181
  const store = new SqliteIntentDecisionStore(connection);
180
- const record = await store.updateFollowUp(id, patch);
181
- if (record === null) {
182
- return {
183
- ok: false,
184
- reason: 'decision_not_found',
185
- nextAction: 'Intent decision ' + id + ' does not exist. Refresh the page and try again.',
186
- };
182
+ const result = await store.updateFollowUp(id, patch);
183
+ if (!result.ok) {
184
+ return result.reason === 'candidate_already_bound'
185
+ ? {
186
+ ok: false,
187
+ reason: 'candidate_already_bound',
188
+ nextAction: result.message + ' Record a new Owner decision for the other candidate instead.',
189
+ }
190
+ : {
191
+ ok: false,
192
+ reason: 'decision_not_found',
193
+ nextAction: 'Intent decision ' + id + ' does not exist. Refresh the page and try again.',
194
+ };
187
195
  }
188
- return { ok: true, record };
196
+ return { ok: true, record: result.record };
189
197
  }
190
198
  catch (err) {
191
199
  if (isMissingTableError(err)) {