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
@@ -18,6 +18,34 @@ import { createHash } from 'node:crypto';
18
18
  import * as fs from 'node:fs';
19
19
  import * as os from 'node:os';
20
20
  import * as path from 'node:path';
21
+ const UNREADABLE_MARKER_NEXT_ACTION = 'Inspect the marker file and the workspace governance store. Enforcement ran fail-open when this was recorded; the recorder never clears the marker automatically — after investigating, an Owner may delete the marker file to reset this signal.';
22
+ function isRecord(value) {
23
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
24
+ }
25
+ /**
26
+ * Validate the persisted record as untrusted runtime data (rc-1..rc-4).
27
+ * A record missing/malforming any field is NOT silently repaired: repairing it
28
+ * would invent evidence about an enforcement bypass.
29
+ */
30
+ function parseDegradedEnforcementRecord(value) {
31
+ if (!isRecord(value))
32
+ return null;
33
+ const { workspaceDir, reason, firstSeenAt, lastSeenAt, occurrences } = value;
34
+ if (typeof workspaceDir !== 'string' || workspaceDir === '')
35
+ return null;
36
+ if (typeof reason !== 'string' || reason === '')
37
+ return null;
38
+ if (typeof firstSeenAt !== 'string' || !Number.isFinite(Date.parse(firstSeenAt)))
39
+ return null;
40
+ if (typeof lastSeenAt !== 'string' || !Number.isFinite(Date.parse(lastSeenAt)))
41
+ return null;
42
+ if (typeof occurrences !== 'number' || !Number.isSafeInteger(occurrences) || occurrences < 1)
43
+ return null;
44
+ return { workspaceDir, reason, firstSeenAt, lastSeenAt, occurrences };
45
+ }
46
+ function unknownReading(markerPath, unreadableReason) {
47
+ return { state: 'unknown', markerPath, unreadableReason, nextAction: UNREADABLE_MARKER_NEXT_ACTION };
48
+ }
21
49
  function markerDir() {
22
50
  return path.join(path.resolve(os.homedir()), '.pd', 'enforcement-health');
23
51
  }
@@ -64,3 +92,54 @@ export function recordDegradedEnforcement(workspaceDir, reason, now = new Date()
64
92
  // Observability only — the gate's fail-open decision stands regardless.
65
93
  }
66
94
  }
95
+ /**
96
+ * Read the durable degraded-enforcement marker for one workspace (PRI-1210).
97
+ *
98
+ * - no marker file → `healthy` (the gate never fail-opened here);
99
+ * - valid marker file → `degraded` with the recorded reason and timing;
100
+ * - unreadable / malformed → `unknown` (never folded into healthy or into 0).
101
+ *
102
+ * The marker is a historical record, not a live probe: `lastSeenAt` is the most
103
+ * recent observed fail-open, and this reader does not prove the current state
104
+ * of the governance store. Read-only by contract.
105
+ */
106
+ export function readDegradedEnforcement(workspaceDir) {
107
+ const markerPath = markerPathFor(workspaceDir);
108
+ let raw;
109
+ try {
110
+ raw = fs.readFileSync(markerPath, 'utf8');
111
+ }
112
+ catch (error) {
113
+ // rc-5: Object.hasOwn, not `in`, on a runtime-provided error object.
114
+ if (isRecord(error) && Object.hasOwn(error, 'code') && error.code === 'ENOENT') {
115
+ return { state: 'healthy', markerPath };
116
+ }
117
+ const message = error instanceof Error ? error.message : String(error);
118
+ return unknownReading(markerPath, `marker_unreadable: ${message}`.slice(0, 300));
119
+ }
120
+ let parsed;
121
+ try {
122
+ parsed = JSON.parse(raw);
123
+ }
124
+ catch {
125
+ return unknownReading(markerPath, 'marker_malformed_json');
126
+ }
127
+ const record = parseDegradedEnforcementRecord(parsed);
128
+ if (record === null)
129
+ return unknownReading(markerPath, 'marker_shape_invalid');
130
+ // rc-6 lineage consistency: the marker path is keyed by the resolved
131
+ // workspace string, so a record naming another workspace means the file was
132
+ // tampered with or copied — report unknown instead of trusting the reason.
133
+ if (path.resolve(record.workspaceDir) !== path.resolve(workspaceDir)) {
134
+ return unknownReading(markerPath, 'marker_workspace_mismatch');
135
+ }
136
+ return {
137
+ state: 'degraded',
138
+ markerPath,
139
+ reason: record.reason,
140
+ firstSeenAt: record.firstSeenAt,
141
+ lastSeenAt: record.lastSeenAt,
142
+ occurrences: record.occurrences,
143
+ nextAction: UNREADABLE_MARKER_NEXT_ACTION,
144
+ };
145
+ }
@@ -28,6 +28,7 @@ export * from './signal-stage2-cycle.js';
28
28
  export * from './host-liveness-contract.js';
29
29
  export * from './internalization-consumer-governance.js';
30
30
  export * from './internalization-consumer-cycle.js';
31
+ export * from './adaptive-consumer-schedule.js';
31
32
  export * from './diagnostician-auto-run.js';
32
33
  export * from './host-tool-declaration.js';
33
34
  export * from './host-tool-semantic-resolver.js';
@@ -45,6 +46,7 @@ export * from './workbuddy-worker-status.js';
45
46
  export * from './codex-legacy-registration.js';
46
47
  export * from './codex-transcript-locate.js';
47
48
  export * from './intervention-evidence-ingress.js';
49
+ export * from './degraded-enforcement-marker.js';
48
50
  export declare const HOST_RUNTIME_ROUTES: readonly ['before_prompt_build', 'before_tool_call', 'after_tool_call'];
49
51
  export type HostRuntimeRoute = (typeof HOST_RUNTIME_ROUTES)[number];
50
52
  export type HostRuntimePort = (event: HostEvent) => HostEventResult | Promise<HostEventResult>;
@@ -49,6 +49,9 @@ export * from './host-liveness-contract.js';
49
49
  // auto-consumer + Companion workspace worker call the same cycle).
50
50
  export * from './internalization-consumer-governance.js';
51
51
  export * from './internalization-consumer-cycle.js';
52
+ // SPEC-PD-PIPELINE-RELIABILITY-AND-EFFICIENCY-001 §4: pure adaptive schedule
53
+ // policy for the existing consumer timer chain (no new background service).
54
+ export * from './adaptive-consumer-schedule.js';
52
55
  export * from './diagnostician-auto-run.js';
53
56
  // PRI-634-F R2: durable host-authored tool declaration — hosts persist, host-
54
57
  // neutral consumers (pd-cli/pd-console) resolve through the ONE resolver.
@@ -88,6 +91,11 @@ export * from './codex-transcript-locate.js';
88
91
  // entry point every host source (OpenClaw hooks, Codex pd-hook) uses to
89
92
  // append normalized evidence. Never throws; never delays a hook.
90
93
  export * from './intervention-evidence-ingress.js';
94
+ // PRI-1210: the durable degraded-enforcement marker was write-only. The reader
95
+ // is exported so `pd health`, `pd health --host codex` and the Console report
96
+ // the SAME three-state fact (healthy / degraded / unknown) instead of each
97
+ // re-deriving the marker path and parse rules.
98
+ export * from './degraded-enforcement-marker.js';
91
99
  export const HOST_RUNTIME_ROUTES = [
92
100
  'before_prompt_build',
93
101
  'before_tool_call',
@@ -90,6 +90,28 @@ export interface InternalizationConsumerCycleOutcome {
90
90
  readonly taskId?: string;
91
91
  readonly taskKind?: string;
92
92
  readonly runStatus?: 'succeeded' | 'failed' | 'retried';
93
+ /**
94
+ * SPEC-PD-PIPELINE-RELIABILITY-AND-EFFICIENCY-001 §4: the failure category of
95
+ * the executed task (absent on success/skip). The host scheduler uses it to
96
+ * distinguish a provider rate limit from ordinary work.
97
+ */
98
+ readonly errorCategory?: string;
99
+ /**
100
+ * Facts the adaptive scheduler needs, observed by THIS cycle. A cycle that
101
+ * never reached the queue snapshot (disabled flag, malformed config) reports
102
+ * zeros — it genuinely observed nothing.
103
+ *
104
+ * `recovered` is filled by the finally-block recovery sweep, which runs after
105
+ * the return value is constructed; the object is intentionally mutated before
106
+ * the promise settles so the caller sees the sweep result.
107
+ */
108
+ readonly signals: InternalizationConsumerCycleSignals;
109
+ }
110
+ export interface InternalizationConsumerCycleSignals {
111
+ readonly readyQueueDepth: number;
112
+ readonly retryQueueDepth: number;
113
+ readonly oldestReadyAgeMs: number | null;
114
+ readonly recovered: number;
93
115
  }
94
116
  /**
95
117
  * PRI-954 (F10) oldest-ready-stage-first ordering. Returns the configured
@@ -103,10 +125,23 @@ export declare function orderKindsByOldestReadyStage<T extends string>(runnerKin
103
125
  taskKind: T;
104
126
  createdAt?: string;
105
127
  }[]): T[];
128
+ /**
129
+ * SPEC §4: age of the oldest ready task, or null when no row carries a usable
130
+ * createdAt. Unknown age must never be reported as 0 (that would make a stalled
131
+ * queue look fresh and suppress the overload branch).
132
+ */
133
+ export declare function oldestReadyAgeMs(readyTasks: readonly {
134
+ createdAt?: string;
135
+ }[], nowMs: number): number | null;
106
136
  /**
107
137
  * Run ONE bounded consumer cycle for a workspace. At most one downstream task
108
138
  * is leased and executed per cycle (DEFAULT_CONSUMER_MAX_TASKS_PER_CYCLE=1);
109
139
  * backlog converges over repeated cycles and never starves reconciliation
110
140
  * (bounded budget in the finally block).
141
+ *
142
+ * SPEC-PD-PIPELINE-RELIABILITY-AND-EFFICIENCY-001 §4: the outcome now carries
143
+ * the queue facts the NEXT scheduling decision needs. They are collected in a
144
+ * single object that the inner cycle mutates, so the recovery sweep (finally
145
+ * block, after the return value is built) is still visible to the caller.
111
146
  */
112
147
  export declare function runInternalizationConsumerCycle(workspaceDir: string, ports: InternalizationConsumerCyclePorts): Promise<InternalizationConsumerCycleOutcome>;
@@ -70,10 +70,12 @@ async function safeRunRecoverySweep(stateManager, ports) {
70
70
  }));
71
71
  logger.info(`[PD:${logLabel}] Recovery sweep: recovered=${sweep.recovered} failed=${sweep.errors.length}`);
72
72
  }
73
+ return sweep.recovered;
73
74
  }
74
75
  catch (sweepErr) {
75
76
  emitEvent('INTERNALIZATION_CONSUMER_RECOVER_FAILED', String(sweepErr));
76
77
  logger.warn(`[PD:${logLabel}] Recovery sweep failed: ${String(sweepErr)}`);
78
+ return 0;
77
79
  }
78
80
  }
79
81
  /**
@@ -116,6 +118,26 @@ export function orderKindsByOldestReadyStage(runnerKinds, readyTasks) {
116
118
  return [...runnerKinds];
117
119
  return [...runnerKinds.slice(startIndex), ...runnerKinds.slice(0, startIndex)];
118
120
  }
121
+ /**
122
+ * SPEC §4: age of the oldest ready task, or null when no row carries a usable
123
+ * createdAt. Unknown age must never be reported as 0 (that would make a stalled
124
+ * queue look fresh and suppress the overload branch).
125
+ */
126
+ export function oldestReadyAgeMs(readyTasks, nowMs) {
127
+ let oldestMs = null;
128
+ for (const task of readyTasks) {
129
+ if (typeof task.createdAt !== 'string' || task.createdAt.length === 0)
130
+ continue;
131
+ const parsed = Date.parse(task.createdAt);
132
+ if (!Number.isFinite(parsed))
133
+ continue;
134
+ if (oldestMs === null || parsed < oldestMs)
135
+ oldestMs = parsed;
136
+ }
137
+ if (oldestMs === null)
138
+ return null;
139
+ return Math.max(0, nowMs - oldestMs);
140
+ }
119
141
  async function runReconciliationBudget(workspaceDir, orchestrator, ports) {
120
142
  const { logger, emitEvent, logLabel } = ports;
121
143
  try {
@@ -167,8 +189,24 @@ async function runReconciliationBudget(workspaceDir, orchestrator, ports) {
167
189
  * is leased and executed per cycle (DEFAULT_CONSUMER_MAX_TASKS_PER_CYCLE=1);
168
190
  * backlog converges over repeated cycles and never starves reconciliation
169
191
  * (bounded budget in the finally block).
192
+ *
193
+ * SPEC-PD-PIPELINE-RELIABILITY-AND-EFFICIENCY-001 §4: the outcome now carries
194
+ * the queue facts the NEXT scheduling decision needs. They are collected in a
195
+ * single object that the inner cycle mutates, so the recovery sweep (finally
196
+ * block, after the return value is built) is still visible to the caller.
170
197
  */
171
198
  export async function runInternalizationConsumerCycle(workspaceDir, ports) {
199
+ const signals = {
200
+ readyQueueDepth: 0,
201
+ retryQueueDepth: 0,
202
+ oldestReadyAgeMs: null,
203
+ recovered: 0,
204
+ };
205
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define -- the wrapper is the public entry point; the inner cycle is declared below so the exported surface reads first
206
+ const outcome = await executeConsumerCycle(workspaceDir, ports, signals);
207
+ return { ...outcome, signals };
208
+ }
209
+ async function executeConsumerCycle(workspaceDir, ports, signals) {
172
210
  const { logger, emitEvent, logLabel, owner } = ports;
173
211
  const { hostToolCatalog, toolSemantics } = ports;
174
212
  // PRI-741: artificer host semantic projection — built once from the SAME
@@ -246,6 +284,11 @@ export async function runInternalizationConsumerCycle(workspaceDir, ports) {
246
284
  actionableTaskKinds: new Set(MVP_CORE_TASK_KINDS),
247
285
  });
248
286
  const snapshot = await readModel.getSnapshot();
287
+ // SPEC §4: scheduling facts come from the SAME snapshot the decision used.
288
+ // A malformed createdAt is skipped (unknown age never becomes "0ms old").
289
+ signals.readyQueueDepth = snapshot.readyTasks.length;
290
+ signals.retryQueueDepth = snapshot.retryWaitCount;
291
+ signals.oldestReadyAgeMs = oldestReadyAgeMs(snapshot.readyTasks, Date.now());
249
292
  if (snapshot.readyTasks.length > 5) {
250
293
  logger.warn(`[PD:${logLabel}] Backlog detected: ${snapshot.readyTasks.length} tasks ready. Processing only one task.`);
251
294
  }
@@ -834,21 +877,12 @@ export async function runInternalizationConsumerCycle(workspaceDir, ports) {
834
877
  }
835
878
  catch (runErr) {
836
879
  logger.error(`[PD:${logLabel}] Runner crashed for task ${taskId}: ${String(runErr)}`);
837
- try {
838
- const task = await stateManager.getTask(taskId);
839
- const failureReason = `Unhandled runner exception: ${runErr instanceof Error ? runErr.message : String(runErr)}`;
840
- if (task && stateManager.getRetryPolicy().shouldRetry(task)) {
841
- await stateManager.markTaskRetryWait(taskId, 'execution_failed', failureReason);
842
- logger.info(`[PD:${logLabel}] Marked task ${taskId} as retry_wait.`);
843
- }
844
- else {
845
- await stateManager.markTaskFailed(taskId, 'execution_failed', failureReason);
846
- logger.info(`[PD:${logLabel}] Marked task ${taskId} as failed.`);
847
- }
848
- }
849
- catch (dbErr) {
850
- logger.error(`[PD:${logLabel}] Failed to update state for crashed task ${taskId}: ${String(dbErr)}`);
851
- }
880
+ // SPEC §5.3 / task-book §1.1: this layer holds no execution identity
881
+ // (no lease fence, no runId), so it MUST NOT write task state. A crash
882
+ // that happens after acquisition is resolved by the task's own lease,
883
+ // and an unowned/stale lease is reclaimed by the recovery sweep above —
884
+ // both report what happened. Writing `failed`/`retry_wait` from here
885
+ // was the exact "unowned terminal write" this remediation removes.
852
886
  throw runErr;
853
887
  }
854
888
  if (runResult.status === 'succeeded') {
@@ -881,7 +915,7 @@ export async function runInternalizationConsumerCycle(workspaceDir, ports) {
881
915
  nextAction,
882
916
  }));
883
917
  logger.warn(`[PD:${logLabel}] Task ${taskId} status: ${runResult.status}. Category: ${errorCategory}. Reason: ${failureReason}. Next Action: ${nextAction}`);
884
- return { ran: true, taskId, taskKind, runStatus: runResult.status === 'retried' ? 'retried' : 'failed' };
918
+ return { ran: true, taskId, taskKind, runStatus: runResult.status === 'retried' ? 'retried' : 'failed', ...(errorCategory !== undefined ? { errorCategory } : {}) };
885
919
  }
886
920
  catch (err) {
887
921
  emitEvent('INTERNALIZATION_CONSUMER_ERROR', String(err));
@@ -896,7 +930,7 @@ export async function runInternalizationConsumerCycle(workspaceDir, ports) {
896
930
  // executes if the orchestrator constructor threw — enumerate every early
897
931
  // return between resource-open and the finally steps (ERR-024).
898
932
  if (handle) {
899
- await safeRunRecoverySweep(handle.stateManager, ports);
933
+ signals.recovered = await safeRunRecoverySweep(handle.stateManager, ports);
900
934
  }
901
935
  // A (最终复核): 每周期固定小预算 — continuous backlog 下 reconciliation
902
936
  // 不会被 ready 任务永久饿死 (公平性);游标 restart-durable。
@@ -21,6 +21,14 @@ export interface PromptDeliverabilityCandidateArtifact {
21
21
  validationStatus: string;
22
22
  /** Formal ledger identity column; identity never comes from content titles. */
23
23
  sourcePrincipleId?: string;
24
+ /**
25
+ * Ledger identity resolved through the artifact's candidate lineage (the same
26
+ * authority the activation dispatcher uses). Legacy artifacts were written
27
+ * before the identity column was stamped; the precheck must measure them
28
+ * under the identity they will actually activate as, not refuse them as if
29
+ * they had none.
30
+ */
31
+ resolvedPrincipleId?: string;
24
32
  }
25
33
  export type PromptArtifactDeliverability = {
26
34
  status: 'deliverable';
@@ -148,4 +156,6 @@ export declare function checkPromptArtifactDeliverabilityById(input: {
148
156
  targetHost?: PromptInjectionTargetHost;
149
157
  /** See `checkPromptArtifactDeliverability.authority` (approve-time = 'owner'). */
150
158
  authority?: 'owner' | 'system_policy';
159
+ /** Ledger identity already resolved from the artifact's candidate lineage. */
160
+ resolvedPrincipleId?: string;
151
161
  }): Promise<PromptArtifactDeliverability>;
@@ -24,7 +24,7 @@ export function resolvePromptCandidatePrinciple(artifact) {
24
24
  artifact_kind: artifact.artifactKind,
25
25
  content_json: artifact.contentJson,
26
26
  validation_status: artifact.validationStatus,
27
- source_principle_id: artifact.sourcePrincipleId,
27
+ source_principle_id: artifact.resolvedPrincipleId ?? artifact.sourcePrincipleId,
28
28
  }, syntheticPendingActivation(artifact.artifactId));
29
29
  }
30
30
  function selfReportEnabledFor(workspaceDir) {
@@ -222,6 +222,9 @@ export async function checkPromptArtifactDeliverabilityById(input) {
222
222
  }
223
223
  return checkPromptArtifactDeliverability({
224
224
  ...input,
225
- artifact: loaded.artifact,
225
+ artifact: {
226
+ ...loaded.artifact,
227
+ ...(input.resolvedPrincipleId !== undefined ? { resolvedPrincipleId: input.resolvedPrincipleId } : {}),
228
+ },
226
229
  });
227
230
  }
@@ -49,3 +49,37 @@ export interface InjectionEventEvidenceReport {
49
49
  export declare function readInjectionEventEvidence(input: {
50
50
  stateDir: string;
51
51
  }): InjectionEventEvidenceReport;
52
+ /**
53
+ * One Adaptive Activation turn, as recorded on the SAME injection event that
54
+ * carries the final assembly. `appendedActivationId` is the assembly fact
55
+ * (present only when the id reached `activationIds`), never a model-selection
56
+ * claim; `scored` states whether a scoring request actually left the process.
57
+ */
58
+ export interface AdaptiveInjectionRecord {
59
+ ts: string | null;
60
+ runId: string | null;
61
+ sessionId: string;
62
+ resultCode: string;
63
+ scored: boolean;
64
+ appendedActivationId: string | null;
65
+ activationIds: string[];
66
+ }
67
+ export interface AdaptiveInjectionRecordsReport {
68
+ filesRead: string[];
69
+ lines: number;
70
+ parseFailures: number;
71
+ /** Newest first. Absence means "no Adaptive fact was recorded", not "no append". */
72
+ records: AdaptiveInjectionRecord[];
73
+ }
74
+ /**
75
+ * Read-model for the Console's "what happened last time" card. Reads only the
76
+ * bounded `adaptive` fact already present on injection events (ids + codes),
77
+ * and never re-derives it from model output. Old events without the field are
78
+ * simply absent — there is no back-fill and no guess (rc-9).
79
+ */
80
+ export declare function readAdaptiveInjectionRecords(input: {
81
+ stateDir: string;
82
+ workspaceDir?: string;
83
+ hostKind?: 'openclaw' | 'codex' | 'workbuddy';
84
+ limit?: number;
85
+ }): AdaptiveInjectionRecordsReport;
@@ -143,3 +143,99 @@ export function readInjectionEventEvidence(input) {
143
143
  note: 'absence from rows means UNKNOWN (no logs), never zero; self-report is a separate signal and is not compliance evidence; rows never merge workspaces',
144
144
  };
145
145
  }
146
+ /**
147
+ * Read-model for the Console's "what happened last time" card. Reads only the
148
+ * bounded `adaptive` fact already present on injection events (ids + codes),
149
+ * and never re-derives it from model output. Old events without the field are
150
+ * simply absent — there is no back-fill and no guess (rc-9).
151
+ */
152
+ export function readAdaptiveInjectionRecords(input) {
153
+ const logsRoot = path.resolve(input.stateDir, 'logs');
154
+ const filesRead = [];
155
+ const limit = Math.max(1, Math.min(input.limit ?? 20, 100));
156
+ if (!fs.existsSync(logsRoot)) {
157
+ return { filesRead, lines: 0, parseFailures: 0, records: [] };
158
+ }
159
+ const files = fs.readdirSync(logsRoot)
160
+ .filter((name) => name.startsWith('events_') && name.endsWith('.jsonl'))
161
+ .sort();
162
+ let lines = 0;
163
+ let parseFailures = 0;
164
+ const records = [];
165
+ for (const name of files) {
166
+ const filePath = path.resolve(logsRoot, name);
167
+ if (!filePath.startsWith(logsRoot + path.sep) || path.basename(name) !== name)
168
+ continue;
169
+ filesRead.push(filePath);
170
+ const raw = fs.readFileSync(filePath, 'utf8');
171
+ for (const line of raw.split('\n')) {
172
+ if (line.trim().length === 0)
173
+ continue;
174
+ lines += 1;
175
+ let parsed;
176
+ try {
177
+ parsed = JSON.parse(line);
178
+ }
179
+ catch {
180
+ parseFailures += 1;
181
+ continue;
182
+ }
183
+ if (!isRecord(parsed)) {
184
+ parseFailures += 1;
185
+ continue;
186
+ }
187
+ if (nonEmptyString(parsed.type) !== 'runtime_v2_prompt_activations_injected')
188
+ continue;
189
+ const { data } = parsed;
190
+ if (!isRecord(data)) {
191
+ parseFailures += 1;
192
+ continue;
193
+ }
194
+ const { adaptive } = data;
195
+ // No Adaptive fact on this event = this turn did not run Adaptive (or
196
+ // predates it). Not a parse failure: nothing was recorded.
197
+ if (adaptive === undefined)
198
+ continue;
199
+ if (!isRecord(adaptive)) {
200
+ parseFailures += 1;
201
+ continue;
202
+ }
203
+ const resultCode = nonEmptyString(adaptive.resultCode);
204
+ const sessionId = nonEmptyString(data.sessionId) ?? nonEmptyString(parsed.sessionId);
205
+ const workspaceDir = nonEmptyString(data.workspaceDir);
206
+ const { activationIds } = data;
207
+ if (resultCode === undefined || sessionId === undefined || workspaceDir === undefined
208
+ || typeof adaptive.scored !== 'boolean' || !Array.isArray(activationIds)
209
+ || !activationIds.every((id) => typeof id === 'string')) {
210
+ // rc-3/rc-4: a malformed Adaptive fact is skipped loudly, never guessed.
211
+ parseFailures += 1;
212
+ continue;
213
+ }
214
+ if (input.workspaceDir !== undefined && workspaceDir !== input.workspaceDir)
215
+ continue;
216
+ const rawHostKind = data.hostKind;
217
+ const hostKind = isPromptInjectionTargetHost(rawHostKind) ? rawHostKind : 'unknown';
218
+ if (input.hostKind !== undefined && hostKind !== input.hostKind)
219
+ continue;
220
+ records.push({
221
+ ts: nonEmptyString(parsed.ts) ?? null,
222
+ runId: nonEmptyString(data.runId) ?? null,
223
+ sessionId,
224
+ resultCode,
225
+ scored: adaptive.scored,
226
+ appendedActivationId: nonEmptyString(adaptive.appendedActivationId) ?? null,
227
+ activationIds,
228
+ });
229
+ }
230
+ }
231
+ records.sort((a, b) => {
232
+ if (a.ts === b.ts)
233
+ return 0;
234
+ if (a.ts === null)
235
+ return 1;
236
+ if (b.ts === null)
237
+ return -1;
238
+ return a.ts < b.ts ? 1 : -1;
239
+ });
240
+ return { filesRead, lines, parseFailures, records: records.slice(0, limit) };
241
+ }
@@ -13,7 +13,7 @@
13
13
  * No second model runtime is introduced (ADR-0029: pi-ai is the only backend).
14
14
  */
15
15
  import path from 'node:path';
16
- import { PiAiRuntimeAdapter, RUNTIME_CONTRACT_SCHEMA_VERSION, SIGNAL_CLASSIFIER_SYSTEM_PROMPT, buildLlmPrompt, resolveLlmClassificationPayload, safeStringifyPreview, } from '@principles/core/runtime';
16
+ import { PiAiRuntimeAdapter, RUNTIME_CONTRACT_SCHEMA_VERSION, SIGNAL_CLASSIFIER_SYSTEM_PROMPT, buildLlmPrompt, resolveLlmClassificationPayload, pdProviderCredentials, safeStringifyPreview, } from '@principles/core/runtime';
17
17
  import { loadPdConfigForPlugin } from './pd-config.js';
18
18
  /**
19
19
  * The Stage-2 structured-output contract this classifier requests. It MUST stay
@@ -153,12 +153,12 @@ export function createSignalClassifierForWorkspace(workspaceDir, options = {}) {
153
153
  nextAction: `Set provider and model on runtime profile '${runtimeProfileId}'`,
154
154
  };
155
155
  }
156
- if (!Object.hasOwn(process.env, profile.apiKeyEnv) || !process.env[profile.apiKeyEnv]) {
156
+ if (pdProviderCredentials.resolve(profile.apiKeyEnv).value === null) {
157
157
  return {
158
158
  ok: false,
159
159
  readiness: 'needs_setup',
160
- reason: `Environment variable '${profile.apiKeyEnv}' is not set or empty`,
161
- nextAction: `Set the environment variable '${profile.apiKeyEnv}' with a valid API key`,
160
+ reason: `No API key for '${profile.apiKeyEnv}' in env or ~/.pd/credentials.yaml`,
161
+ nextAction: `Save an API key for '${profile.apiKeyEnv}' in the console, or set the environment variable`,
162
162
  };
163
163
  }
164
164
  const resolved = {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/host-runtime",
3
- "version": "4.1.3",
3
+ "version": "4.2.1",
4
4
  "description": "Shared host-neutral orchestration for Principles Disciple MVP-Core hook paths.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -9,22 +9,11 @@
9
9
  * - the launcher's binding gate and this declaration must produce the SAME
10
10
  * verdict for the SAME input — `mcp-binding-contract-parity.test.ts` runs
11
11
  * the real launcher over the fixtures below and fails on any divergence;
12
- * - `pd health` consumes this module directly, so it can never be more
13
- * permissive than the launcher; the packaged installer consumes the pinned
14
- * mirror noted below instead of importing this module at runtime.
12
+ * - `pd health` and the packaged installer consume this module directly, so
13
+ * neither can be more permissive than the launcher.
15
14
  *
16
- * SAME-SOURCE POINTER — a pinned mirror of this declaration lives at
17
- * packages/create-principles-disciple/src/installers/mcp-binding-shape-mirror.ts
18
- * The packaged installer cannot import this module at runtime (it must load
19
- * against the PUBLISHED install-layout, PRI-669/RF-02, and a normal PR may not
20
- * raise the dependency floor), so it mirrors these rules verbatim. The two
21
- * files MUST change together, in the same commit; the 33-cell parity test
22
- * (`mcp-binding-shape-mirror-parity.test.ts`) pins identical verdicts. The
23
- * mirror is retired by PRI-1191 once the export is published and the installer
24
- * floor is raised.
25
- *
26
- * Adding a reason code on either side without a fixture/exemption makes that
27
- * parity test red — divergence is a defect, not something to remember.
15
+ * Adding a reason code without a fixture/exemption makes the launcher parity
16
+ * test red — divergence is a defect, not something to remember.
28
17
  */
29
18
  import * as path from 'node:path';
30
19
  export const MCP_BINDING_SCHEMA_VERSION = 'pd.mcp-binding.v1';
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/install-layout",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-principles-disciple",
3
- "version": "1.152.2",
3
+ "version": "1.152.4",
4
4
  "description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
5
5
  "type": "module",
6
6
  "bin": {
@@ -63,7 +63,7 @@
63
63
  "dependencies": {
64
64
  "@earendil-works/pi-agent-core": "1.2.0",
65
65
  "@earendil-works/pi-ai": "1.4.0",
66
- "@principles/install-layout": "^0.8.1",
66
+ "@principles/install-layout": "^0.8.2",
67
67
  "@sinclair/typebox": "^0.34.52",
68
68
  "@tufjs/models": "3.0.1",
69
69
  "@inquirer/prompts": "^8.7.2",
@@ -101,5 +101,5 @@
101
101
  "pd": {
102
102
  "bundledPluginVersion": "2.2.13"
103
103
  },
104
- "gitHead": "a0984037f10c71f565da77ffaaf285369e265c49"
104
+ "gitHead": "8ad7b7924a5edb2231486ef0ed99c2462ad78318"
105
105
  }
@@ -1 +1 @@
1
- {"version":3,"file":"health-codex.d.ts","sourceRoot":"","sources":["../../src/commands/health-codex.ts"],"names":[],"mappings":"AAmDA,UAAU,kBAAkB;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AA+PD,wBAAsB,iBAAiB,CAAC,IAAI,GAAE,kBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoZpF"}
1
+ {"version":3,"file":"health-codex.d.ts","sourceRoot":"","sources":["../../src/commands/health-codex.ts"],"names":[],"mappings":"AAqDA,UAAU,kBAAkB;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAuQD,wBAAsB,iBAAiB,CAAC,IAAI,GAAE,kBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwapF"}
@@ -29,7 +29,7 @@ import * as path from 'path';
29
29
  import * as os from 'os';
30
30
  import { createRequire } from 'module';
31
31
  import { resolveWorkspaceDir } from '../resolve-workspace.js';
32
- import { loadPdConfigForPlugin, resolveNearestPdWorkspace, readCodexIngestionConsent, deriveCodexIngestionConsentState, listGovernanceCheckpoints, readGovernanceObservationStats, readGovernanceAdmissionCounts, detectLegacyCodexHookRegistration, CODEX_INGESTION_DISCLOSURE_VERSION, } from '@principles/host-runtime';
32
+ import { loadPdConfigForPlugin, resolveNearestPdWorkspace, readCodexIngestionConsent, deriveCodexIngestionConsentState, listGovernanceCheckpoints, readGovernanceObservationStats, readGovernanceAdmissionCounts, detectLegacyCodexHookRegistration, CODEX_INGESTION_DISCLOSURE_VERSION, readDegradedEnforcement, } from '@principles/host-runtime';
33
33
  import { assessCodexInstall, CODEX_INSTALL_NEXT_ACTIONS } from './health-codex-install.js';
34
34
  import { assessMcpHealth, formatMcpHealthLines } from './health-mcp.js';
35
35
  import { getInstallLayoutPaths, parseInstallManifest } from '@principles/install-layout';
@@ -307,6 +307,16 @@ export async function handleHealthCodex(opts = {}) {
307
307
  noteReadyBlocker('worker', 'manual_action_required');
308
308
  if (manifest.error !== undefined)
309
309
  warnings.push(`install_manifest: ${manifest.error}`);
310
+ // ── Rule enforcement (durable degraded marker, PRI-1210) ───────────────────
311
+ // Read the workspace's own marker. A recorded fail-open means rule
312
+ // enforcement was bypassed for this workspace; an unreadable marker means we
313
+ // do not know. Both block §15 `ready` — unknown is never healthy.
314
+ const enforcement = readDegradedEnforcement(resolvedWorkspace);
315
+ if (enforcement.state !== 'healthy') {
316
+ noteReadyBlocker('enforcement', enforcement.state === 'unknown'
317
+ ? `unknown (${enforcement.unreadableReason ?? 'marker unreadable'})`
318
+ : enforcement.reason);
319
+ }
310
320
  // ── Hook trust + dual registration ─────────────────────────────────────────
311
321
  const codexConfigDir = detectCodexConfigDir();
312
322
  const hooksTrust = detectHooksTrust(codexConfigDir);
@@ -484,6 +494,7 @@ export async function handleHealthCodex(opts = {}) {
484
494
  hooksTrust,
485
495
  dualRegistration,
486
496
  worker,
497
+ enforcement,
487
498
  rollouts,
488
499
  observations,
489
500
  admissions,
@@ -559,6 +570,20 @@ export async function handleHealthCodex(opts = {}) {
559
570
  if (report.dualRegistration.detected)
560
571
  line('dualRegistration.nextAction', report.dualRegistration.nextAction ?? '');
561
572
  line('worker.mode', `${report.worker.mode}${report.worker.reason !== undefined ? ` (${report.worker.reason})` : ''}`);
573
+ line('enforcement.state', report.enforcement.state);
574
+ line('enforcement.markerPath', report.enforcement.markerPath);
575
+ if (report.enforcement.reason !== undefined)
576
+ line('enforcement.reason', report.enforcement.reason);
577
+ if (report.enforcement.firstSeenAt !== undefined)
578
+ line('enforcement.firstSeenAt', report.enforcement.firstSeenAt);
579
+ if (report.enforcement.lastSeenAt !== undefined)
580
+ line('enforcement.lastSeenAt', report.enforcement.lastSeenAt);
581
+ if (report.enforcement.occurrences !== undefined)
582
+ line('enforcement.occurrences', String(report.enforcement.occurrences));
583
+ if (report.enforcement.unreadableReason !== undefined)
584
+ line('enforcement.unreadableReason', report.enforcement.unreadableReason);
585
+ if (report.enforcement.nextAction !== undefined)
586
+ line('enforcement.nextAction', report.enforcement.nextAction);
562
587
  if ('checkpoints' in report.rollouts) {
563
588
  line('rollouts', String(report.rollouts.checkpoints.length));
564
589
  for (const checkpoint of report.rollouts.checkpoints.slice(0, 10)) {