create-principles-disciple 1.92.0 → 1.94.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (335) hide show
  1. package/console/dist/server/config/AuthConfig.js +6 -0
  2. package/console/dist/server/config/pd-config-store.d.ts +7 -1
  3. package/console/dist/server/config/pd-config-store.js +11 -1
  4. package/console/dist/server/index.js +41 -22
  5. package/console/dist/server/models/ApprovalsConsoleModel.js +4 -12
  6. package/console/dist/server/models/ApprovalsGroupedConsoleModel.js +6 -3
  7. package/console/dist/server/models/ConsoleLifecycleDatasource.js +1 -1
  8. package/console/dist/server/routes/activations.js +4 -0
  9. package/console/dist/server/routes/approvals.js +24 -4
  10. package/console/dist/server/routes/feedback-reports.js +7 -5
  11. package/console/dist/server/routes/lifecycle.js +6 -1
  12. package/console/dist/server/routes/principles.js +10 -2
  13. package/console/dist/server/routes/workspaces.js +4 -0
  14. package/console/dist/ui/components/ui/charts.js +4 -1
  15. package/console/dist/ui/components/ui/markdown.js +9 -5
  16. package/console/dist/ui/utils/enum-labels.js +4 -1
  17. package/console/dist/web/assets/app.js +5 -2
  18. package/core/dist/index.d.ts +2 -3
  19. package/core/dist/index.d.ts.map +1 -1
  20. package/core/dist/index.js +1 -3
  21. package/core/dist/index.js.map +1 -1
  22. package/core/dist/pain-signal.d.ts +11 -71
  23. package/core/dist/pain-signal.d.ts.map +1 -1
  24. package/core/dist/pain-signal.js +10 -120
  25. package/core/dist/pain-signal.js.map +1 -1
  26. package/core/dist/principle-tree-ledger.d.ts +4 -87
  27. package/core/dist/principle-tree-ledger.d.ts.map +1 -1
  28. package/core/dist/principle-tree-ledger.js +51 -148
  29. package/core/dist/principle-tree-ledger.js.map +1 -1
  30. package/core/dist/prompt-builder/__tests__/model-config.test.d.ts +2 -0
  31. package/core/dist/prompt-builder/__tests__/model-config.test.d.ts.map +1 -0
  32. package/core/dist/prompt-builder/__tests__/model-config.test.js +158 -0
  33. package/core/dist/prompt-builder/__tests__/model-config.test.js.map +1 -0
  34. package/core/dist/prompt-builder/__tests__/xml-escape.test.d.ts +2 -0
  35. package/core/dist/prompt-builder/__tests__/xml-escape.test.d.ts.map +1 -0
  36. package/core/dist/prompt-builder/__tests__/xml-escape.test.js +42 -0
  37. package/core/dist/prompt-builder/__tests__/xml-escape.test.js.map +1 -0
  38. package/core/dist/prompt-builder/index.d.ts +3 -0
  39. package/core/dist/prompt-builder/index.d.ts.map +1 -1
  40. package/core/dist/prompt-builder/index.js +2 -0
  41. package/core/dist/prompt-builder/index.js.map +1 -1
  42. package/core/dist/prompt-builder/model-config.d.ts +42 -0
  43. package/core/dist/prompt-builder/model-config.d.ts.map +1 -0
  44. package/core/dist/prompt-builder/model-config.js +84 -0
  45. package/core/dist/prompt-builder/model-config.js.map +1 -0
  46. package/core/dist/prompt-builder/xml-escape.d.ts +12 -0
  47. package/core/dist/prompt-builder/xml-escape.d.ts.map +1 -0
  48. package/core/dist/prompt-builder/xml-escape.js +19 -0
  49. package/core/dist/prompt-builder/xml-escape.js.map +1 -0
  50. package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +265 -20
  51. package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
  52. package/core/dist/runtime-v2/__tests__/barrel-io-cleanup.test.d.ts +12 -0
  53. package/core/dist/runtime-v2/__tests__/barrel-io-cleanup.test.d.ts.map +1 -0
  54. package/core/dist/runtime-v2/__tests__/barrel-io-cleanup.test.js +46 -0
  55. package/core/dist/runtime-v2/__tests__/barrel-io-cleanup.test.js.map +1 -0
  56. package/core/dist/runtime-v2/__tests__/io-deletion.test.d.ts +12 -0
  57. package/core/dist/runtime-v2/__tests__/io-deletion.test.d.ts.map +1 -0
  58. package/core/dist/runtime-v2/__tests__/io-deletion.test.js +92 -0
  59. package/core/dist/runtime-v2/__tests__/io-deletion.test.js.map +1 -0
  60. package/core/dist/runtime-v2/__tests__/ledger-codec.test.d.ts +2 -0
  61. package/core/dist/runtime-v2/__tests__/ledger-codec.test.d.ts.map +1 -0
  62. package/core/dist/runtime-v2/__tests__/ledger-codec.test.js +429 -0
  63. package/core/dist/runtime-v2/__tests__/ledger-codec.test.js.map +1 -0
  64. package/core/dist/runtime-v2/__tests__/ledger-store.test.d.ts +2 -0
  65. package/core/dist/runtime-v2/__tests__/ledger-store.test.d.ts.map +1 -0
  66. package/core/dist/runtime-v2/__tests__/ledger-store.test.js +65 -0
  67. package/core/dist/runtime-v2/__tests__/ledger-store.test.js.map +1 -0
  68. package/core/dist/runtime-v2/__tests__/pain-signal-bridge-result-shaping.test.d.ts +2 -0
  69. package/core/dist/runtime-v2/__tests__/pain-signal-bridge-result-shaping.test.d.ts.map +1 -0
  70. package/core/dist/runtime-v2/__tests__/pain-signal-bridge-result-shaping.test.js +395 -0
  71. package/core/dist/runtime-v2/__tests__/pain-signal-bridge-result-shaping.test.js.map +1 -0
  72. package/core/dist/runtime-v2/__tests__/pain-signal-observability.test.js +146 -0
  73. package/core/dist/runtime-v2/__tests__/pain-signal-observability.test.js.map +1 -1
  74. package/core/dist/runtime-v2/__tests__/pain-signal-unification.test.d.ts +2 -0
  75. package/core/dist/runtime-v2/__tests__/pain-signal-unification.test.d.ts.map +1 -0
  76. package/core/dist/runtime-v2/__tests__/pain-signal-unification.test.js +150 -0
  77. package/core/dist/runtime-v2/__tests__/pain-signal-unification.test.js.map +1 -0
  78. package/core/dist/runtime-v2/adapter/__tests__/test-double-runtime-adapter.test.js +199 -0
  79. package/core/dist/runtime-v2/adapter/__tests__/test-double-runtime-adapter.test.js.map +1 -1
  80. package/core/dist/runtime-v2/bridge-result-shaper.d.ts +53 -0
  81. package/core/dist/runtime-v2/bridge-result-shaper.d.ts.map +1 -0
  82. package/core/dist/runtime-v2/bridge-result-shaper.js +117 -0
  83. package/core/dist/runtime-v2/bridge-result-shaper.js.map +1 -0
  84. package/core/dist/runtime-v2/detection/__tests__/detection-funnel-policy.test.d.ts +13 -0
  85. package/core/dist/runtime-v2/detection/__tests__/detection-funnel-policy.test.d.ts.map +1 -0
  86. package/core/dist/runtime-v2/detection/__tests__/detection-funnel-policy.test.js +111 -0
  87. package/core/dist/runtime-v2/detection/__tests__/detection-funnel-policy.test.js.map +1 -0
  88. package/core/dist/runtime-v2/detection/detection-funnel-policy.d.ts +103 -0
  89. package/core/dist/runtime-v2/detection/detection-funnel-policy.d.ts.map +1 -0
  90. package/core/dist/runtime-v2/detection/detection-funnel-policy.js +135 -0
  91. package/core/dist/runtime-v2/detection/detection-funnel-policy.js.map +1 -0
  92. package/core/dist/runtime-v2/detection/index.d.ts +10 -0
  93. package/core/dist/runtime-v2/detection/index.d.ts.map +1 -0
  94. package/core/dist/runtime-v2/detection/index.js +9 -0
  95. package/core/dist/runtime-v2/detection/index.js.map +1 -0
  96. package/core/dist/runtime-v2/diagnostician/__tests__/diag-rootcause-output.test.js +156 -0
  97. package/core/dist/runtime-v2/diagnostician/__tests__/diag-rootcause-output.test.js.map +1 -1
  98. package/core/dist/runtime-v2/evidence-triage/__tests__/observation-resolver.test.d.ts +12 -0
  99. package/core/dist/runtime-v2/evidence-triage/__tests__/observation-resolver.test.d.ts.map +1 -0
  100. package/core/dist/runtime-v2/evidence-triage/__tests__/observation-resolver.test.js +181 -0
  101. package/core/dist/runtime-v2/evidence-triage/__tests__/observation-resolver.test.js.map +1 -0
  102. package/core/dist/runtime-v2/evidence-triage/__tests__/triage-policy.test.js +104 -1
  103. package/core/dist/runtime-v2/evidence-triage/__tests__/triage-policy.test.js.map +1 -1
  104. package/core/dist/runtime-v2/evidence-triage/index.d.ts +3 -0
  105. package/core/dist/runtime-v2/evidence-triage/index.d.ts.map +1 -1
  106. package/core/dist/runtime-v2/evidence-triage/index.js +3 -0
  107. package/core/dist/runtime-v2/evidence-triage/index.js.map +1 -1
  108. package/core/dist/runtime-v2/evidence-triage/observation-resolver.d.ts +128 -0
  109. package/core/dist/runtime-v2/evidence-triage/observation-resolver.d.ts.map +1 -0
  110. package/core/dist/runtime-v2/evidence-triage/observation-resolver.js +203 -0
  111. package/core/dist/runtime-v2/evidence-triage/observation-resolver.js.map +1 -0
  112. package/core/dist/runtime-v2/evidence-triage/triage-policy.d.ts +4 -0
  113. package/core/dist/runtime-v2/evidence-triage/triage-policy.d.ts.map +1 -1
  114. package/core/dist/runtime-v2/evidence-triage/triage-policy.js +66 -9
  115. package/core/dist/runtime-v2/evidence-triage/triage-policy.js.map +1 -1
  116. package/core/dist/runtime-v2/evidence-triage/types.d.ts +14 -0
  117. package/core/dist/runtime-v2/evidence-triage/types.d.ts.map +1 -1
  118. package/core/dist/runtime-v2/evidence-triage/types.js.map +1 -1
  119. package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js +33 -4
  120. package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js.map +1 -1
  121. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts.map +1 -1
  122. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js +9 -2
  123. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
  124. package/core/dist/runtime-v2/feedback/__tests__/redact-sensitive.test.d.ts +15 -0
  125. package/core/dist/runtime-v2/feedback/__tests__/redact-sensitive.test.d.ts.map +1 -0
  126. package/core/dist/runtime-v2/feedback/__tests__/redact-sensitive.test.js +450 -0
  127. package/core/dist/runtime-v2/feedback/__tests__/redact-sensitive.test.js.map +1 -0
  128. package/core/dist/runtime-v2/feedback/__tests__/render-github-url.test.d.ts +13 -0
  129. package/core/dist/runtime-v2/feedback/__tests__/render-github-url.test.d.ts.map +1 -0
  130. package/core/dist/runtime-v2/feedback/__tests__/render-github-url.test.js +243 -0
  131. package/core/dist/runtime-v2/feedback/__tests__/render-github-url.test.js.map +1 -0
  132. package/core/dist/runtime-v2/feedback/__tests__/safe-stringify.test.d.ts +12 -0
  133. package/core/dist/runtime-v2/feedback/__tests__/safe-stringify.test.d.ts.map +1 -0
  134. package/core/dist/runtime-v2/feedback/__tests__/safe-stringify.test.js +172 -0
  135. package/core/dist/runtime-v2/feedback/__tests__/safe-stringify.test.js.map +1 -0
  136. package/core/dist/runtime-v2/index.d.ts +9 -6
  137. package/core/dist/runtime-v2/index.d.ts.map +1 -1
  138. package/core/dist/runtime-v2/index.js +8 -4
  139. package/core/dist/runtime-v2/index.js.map +1 -1
  140. package/core/dist/runtime-v2/internalization/__tests__/c2-live-runner-chain.test.d.ts +2 -0
  141. package/core/dist/runtime-v2/internalization/__tests__/c2-live-runner-chain.test.d.ts.map +1 -0
  142. package/core/dist/runtime-v2/internalization/__tests__/c2-live-runner-chain.test.js +306 -0
  143. package/core/dist/runtime-v2/internalization/__tests__/c2-live-runner-chain.test.js.map +1 -0
  144. package/core/dist/runtime-v2/internalization/index.d.ts +0 -16
  145. package/core/dist/runtime-v2/internalization/index.d.ts.map +1 -1
  146. package/core/dist/runtime-v2/internalization/index.js +0 -8
  147. package/core/dist/runtime-v2/internalization/index.js.map +1 -1
  148. package/core/dist/runtime-v2/pain-gate/__tests__/pain-diagnostic-gate-policy.test.d.ts +15 -0
  149. package/core/dist/runtime-v2/pain-gate/__tests__/pain-diagnostic-gate-policy.test.d.ts.map +1 -0
  150. package/core/dist/runtime-v2/pain-gate/__tests__/pain-diagnostic-gate-policy.test.js +179 -0
  151. package/core/dist/runtime-v2/pain-gate/__tests__/pain-diagnostic-gate-policy.test.js.map +1 -0
  152. package/core/dist/runtime-v2/pain-gate/index.d.ts +10 -0
  153. package/core/dist/runtime-v2/pain-gate/index.d.ts.map +1 -0
  154. package/core/dist/runtime-v2/pain-gate/index.js +9 -0
  155. package/core/dist/runtime-v2/pain-gate/index.js.map +1 -0
  156. package/core/dist/runtime-v2/pain-gate/pain-diagnostic-gate-policy.d.ts +121 -0
  157. package/core/dist/runtime-v2/pain-gate/pain-diagnostic-gate-policy.d.ts.map +1 -0
  158. package/core/dist/runtime-v2/pain-gate/pain-diagnostic-gate-policy.js +157 -0
  159. package/core/dist/runtime-v2/pain-gate/pain-diagnostic-gate-policy.js.map +1 -0
  160. package/core/dist/runtime-v2/pain-signal-bridge.d.ts.map +1 -1
  161. package/core/dist/runtime-v2/pain-signal-bridge.js +14 -88
  162. package/core/dist/runtime-v2/pain-signal-bridge.js.map +1 -1
  163. package/core/dist/runtime-v2/pain-signal-observability.d.ts.map +1 -1
  164. package/core/dist/runtime-v2/pain-signal-observability.js +15 -5
  165. package/core/dist/runtime-v2/pain-signal-observability.js.map +1 -1
  166. package/core/dist/runtime-v2/principle-tree/ledger-codec.d.ts +30 -0
  167. package/core/dist/runtime-v2/principle-tree/ledger-codec.d.ts.map +1 -0
  168. package/core/dist/runtime-v2/principle-tree/ledger-codec.js +154 -0
  169. package/core/dist/runtime-v2/principle-tree/ledger-codec.js.map +1 -0
  170. package/core/dist/runtime-v2/types/event-types.d.ts +0 -27
  171. package/core/dist/runtime-v2/types/event-types.d.ts.map +1 -1
  172. package/core/dist/runtime-v2/types/event-types.js +2 -17
  173. package/core/dist/runtime-v2/types/event-types.js.map +1 -1
  174. package/core/dist/runtime-v2/types/index.d.ts +4 -2
  175. package/core/dist/runtime-v2/types/index.d.ts.map +1 -1
  176. package/core/dist/runtime-v2/types/index.js +4 -1
  177. package/core/dist/runtime-v2/types/index.js.map +1 -1
  178. package/core/dist/runtime-v2/types/ledger-store.d.ts +101 -0
  179. package/core/dist/runtime-v2/types/ledger-store.d.ts.map +1 -0
  180. package/core/dist/runtime-v2/types/ledger-store.js +15 -0
  181. package/core/dist/runtime-v2/types/ledger-store.js.map +1 -0
  182. package/core/dist/runtime-v2/types/pain-signal.d.ts +7 -5
  183. package/core/dist/runtime-v2/types/pain-signal.d.ts.map +1 -1
  184. package/core/dist/runtime-v2/types/pain-signal.js +25 -5
  185. package/core/dist/runtime-v2/types/pain-signal.js.map +1 -1
  186. package/core/package.json +3 -3
  187. package/dist/installer.d.ts.map +1 -1
  188. package/dist/installer.js +9 -3
  189. package/dist/installer.js.map +1 -1
  190. package/dist/mvp-config.d.ts +0 -10
  191. package/dist/mvp-config.d.ts.map +1 -1
  192. package/dist/mvp-config.js +0 -64
  193. package/dist/mvp-config.js.map +1 -1
  194. package/dist/utils/env.d.ts.map +1 -1
  195. package/dist/utils/env.js +10 -4
  196. package/dist/utils/env.js.map +1 -1
  197. package/package.json +1 -1
  198. package/pd-cli/dist/commands/__tests__/legacy-cleanup.test.js +11 -3
  199. package/pd-cli/dist/commands/__tests__/legacy-cleanup.test.js.map +1 -1
  200. package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
  201. package/pd-cli/dist/commands/candidate.js +2 -1
  202. package/pd-cli/dist/commands/candidate.js.map +1 -1
  203. package/pd-cli/dist/commands/health.d.ts.map +1 -1
  204. package/pd-cli/dist/commands/health.js +2 -1
  205. package/pd-cli/dist/commands/health.js.map +1 -1
  206. package/pd-cli/dist/commands/mvp-smoke.js +1 -1
  207. package/pd-cli/dist/commands/mvp-smoke.js.map +1 -1
  208. package/pd-cli/dist/commands/rulecode.js +1 -1
  209. package/pd-cli/dist/commands/rulecode.js.map +1 -1
  210. package/pd-cli/dist/commands/runtime-canary.d.ts.map +1 -1
  211. package/pd-cli/dist/commands/runtime-canary.js +10 -11
  212. package/pd-cli/dist/commands/runtime-canary.js.map +1 -1
  213. package/pd-cli/dist/commands/runtime-internalization-integrity.d.ts.map +1 -1
  214. package/pd-cli/dist/commands/runtime-internalization-integrity.js +3 -1
  215. package/pd-cli/dist/commands/runtime-internalization-integrity.js.map +1 -1
  216. package/pd-cli/dist/commands/runtime-internalization-queue.d.ts.map +1 -1
  217. package/pd-cli/dist/commands/runtime-internalization-queue.js +13 -16
  218. package/pd-cli/dist/commands/runtime-internalization-queue.js.map +1 -1
  219. package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
  220. package/pd-cli/dist/commands/runtime-internalization-run-once.js +3 -0
  221. package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
  222. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.d.ts.map +1 -1
  223. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js +61 -7
  224. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js.map +1 -1
  225. package/pd-cli/dist/commands/runtime-uat.d.ts.map +1 -1
  226. package/pd-cli/dist/commands/runtime-uat.js +4 -1
  227. package/pd-cli/dist/commands/runtime-uat.js.map +1 -1
  228. package/pd-cli/dist/commands/runtime.js +1 -1
  229. package/pd-cli/dist/commands/runtime.js.map +1 -1
  230. package/pd-cli/dist/index.js +67 -34
  231. package/pd-cli/dist/index.js.map +1 -1
  232. package/pd-cli/dist/legacy/session-history-import.js +7 -5
  233. package/pd-cli/dist/legacy/session-history-import.js.map +1 -1
  234. package/pd-cli/dist/services/__tests__/rulehost-readiness.test.d.ts +2 -0
  235. package/pd-cli/dist/services/__tests__/rulehost-readiness.test.d.ts.map +1 -0
  236. package/pd-cli/dist/services/__tests__/rulehost-readiness.test.js +314 -0
  237. package/pd-cli/dist/services/__tests__/rulehost-readiness.test.js.map +1 -0
  238. package/pd-cli/dist/services/__tests__/runtime-adapter-resolver.test.js +33 -14
  239. package/pd-cli/dist/services/__tests__/runtime-adapter-resolver.test.js.map +1 -1
  240. package/pd-cli/dist/services/pain-flood-simulation-runner.d.ts.map +1 -1
  241. package/pd-cli/dist/services/pain-flood-simulation-runner.js +6 -2
  242. package/pd-cli/dist/services/pain-flood-simulation-runner.js.map +1 -1
  243. package/pd-cli/dist/services/rulehost-readiness.d.ts +62 -0
  244. package/pd-cli/dist/services/rulehost-readiness.d.ts.map +1 -0
  245. package/pd-cli/dist/services/rulehost-readiness.js +214 -0
  246. package/pd-cli/dist/services/rulehost-readiness.js.map +1 -0
  247. package/pd-cli/dist/services/runtime-adapter-resolver.d.ts +1 -1
  248. package/pd-cli/dist/services/runtime-adapter-resolver.d.ts.map +1 -1
  249. package/pd-cli/dist/services/runtime-adapter-resolver.js +9 -7
  250. package/pd-cli/dist/services/runtime-adapter-resolver.js.map +1 -1
  251. package/plugin/dist/commands/capabilities.js +3 -2
  252. package/plugin/dist/commands/disable-impl.js +1 -1
  253. package/plugin/dist/commands/evolution-status.js +0 -2
  254. package/plugin/dist/commands/focus.js +10 -2
  255. package/plugin/dist/commands/rollback-impl.js +1 -1
  256. package/plugin/dist/commands/thinking-os.js +5 -1
  257. package/plugin/dist/core/correction-cue-learner.js +2 -0
  258. package/plugin/dist/core/detection-funnel.d.ts +25 -11
  259. package/plugin/dist/core/detection-funnel.js +32 -80
  260. package/plugin/dist/core/event-log.d.ts +1 -3
  261. package/plugin/dist/core/event-log.js +27 -31
  262. package/plugin/dist/core/evolution-reducer.d.ts +0 -8
  263. package/plugin/dist/core/evolution-reducer.js +9 -19
  264. package/plugin/dist/core/focus-history.js +1 -1
  265. package/plugin/dist/core/hygiene/tracker.js +3 -3
  266. package/plugin/dist/core/pain-diagnostic-gate.d.ts +37 -28
  267. package/plugin/dist/core/pain-diagnostic-gate.js +53 -89
  268. package/plugin/dist/core/pain.d.ts +0 -63
  269. package/plugin/dist/core/pain.js +0 -167
  270. package/plugin/dist/core/paths.d.ts +0 -1
  271. package/plugin/dist/core/paths.js +2 -1
  272. package/plugin/dist/core/principle-compiler/compiler.js +2 -0
  273. package/plugin/dist/core/replay-engine.js +1 -1
  274. package/plugin/dist/core/rule-host.js +3 -1
  275. package/plugin/dist/core/schema/migrations/001-init-trajectory.js +3 -6
  276. package/plugin/dist/core/schema/schema-definitions.js +4 -9
  277. package/plugin/dist/core/thinking-os-parser.js +13 -4
  278. package/plugin/dist/core/trajectory.d.ts +0 -16
  279. package/plugin/dist/core/trajectory.js +9 -60
  280. package/plugin/dist/hooks/after-tool-call-helpers.d.ts +4 -1
  281. package/plugin/dist/hooks/after-tool-call-helpers.js +13 -17
  282. package/plugin/dist/hooks/gate-block-helper.js +57 -17
  283. package/plugin/dist/hooks/lifecycle.js +3 -6
  284. package/plugin/dist/hooks/llm.js +66 -26
  285. package/plugin/dist/hooks/pain.d.ts +3 -1
  286. package/plugin/dist/hooks/pain.js +119 -49
  287. package/plugin/dist/hooks/prompt-helpers.d.ts +87 -0
  288. package/plugin/dist/hooks/prompt-helpers.js +251 -0
  289. package/plugin/dist/hooks/prompt-types.d.ts +66 -0
  290. package/plugin/dist/hooks/prompt-types.js +12 -0
  291. package/plugin/dist/hooks/prompt.d.ts +7 -38
  292. package/plugin/dist/hooks/prompt.js +361 -325
  293. package/plugin/dist/hooks/raw-observation-adapter.d.ts +9 -50
  294. package/plugin/dist/hooks/raw-observation-adapter.js +9 -164
  295. package/plugin/dist/hooks/raw-observation-types.d.ts +6 -57
  296. package/plugin/dist/hooks/raw-observation-types.js +5 -9
  297. package/plugin/dist/hooks/trajectory-collector.d.ts +20 -4
  298. package/plugin/dist/hooks/trajectory-collector.js +95 -156
  299. package/plugin/dist/hooks/triage-adapter.js +6 -26
  300. package/plugin/dist/hooks/trigger-cooldown-tracker.d.ts +12 -0
  301. package/plugin/dist/hooks/trigger-cooldown-tracker.js +25 -0
  302. package/plugin/dist/index.js +7 -2
  303. package/plugin/dist/openclaw-sdk.d.ts +4 -1
  304. package/plugin/dist/service/evolution-worker.js +8 -62
  305. package/plugin/dist/service/internalization-auto-consumer-service.js +2 -1
  306. package/plugin/dist/service/runtime-summary-service.d.ts +0 -2
  307. package/plugin/dist/service/runtime-summary-service.js +8 -5
  308. package/plugin/dist/service/workflow-watchdog.js +2 -1
  309. package/plugin/dist/types/event-types.d.ts +1 -1
  310. package/plugin/dist/utils/retry.js +7 -2
  311. package/plugin/dist/utils/session-key.js +4 -1
  312. package/plugin/scripts/sync-plugin.mjs +33 -22
  313. package/plugin/scripts/validate-live-path.ts +0 -18
  314. package/plugin/templates/langs/en/skills/pd-cli-operator/SKILL.md +20 -11
  315. package/plugin/templates/langs/en/skills/pd-runtime-v2/SKILL.md +10 -0
  316. package/plugin/templates/langs/zh/skills/pd-cli-operator/SKILL.md +20 -11
  317. package/plugin/templates/langs/zh/skills/pd-runtime-v2/SKILL.md +10 -0
  318. package/console/dist/server/config/feature-flags.d.ts +0 -25
  319. package/console/dist/server/config/feature-flags.js +0 -101
  320. package/core/dist/io.d.ts +0 -35
  321. package/core/dist/io.d.ts.map +0 -1
  322. package/core/dist/io.js +0 -95
  323. package/core/dist/io.js.map +0 -1
  324. package/pd-cli/dist/commands/central-sync.d.ts +0 -10
  325. package/pd-cli/dist/commands/central-sync.d.ts.map +0 -1
  326. package/pd-cli/dist/commands/central-sync.js +0 -32
  327. package/pd-cli/dist/commands/central-sync.js.map +0 -1
  328. package/pd-cli/dist/services/feature-flag-loader.d.ts +0 -6
  329. package/pd-cli/dist/services/feature-flag-loader.d.ts.map +0 -1
  330. package/pd-cli/dist/services/feature-flag-loader.js +0 -53
  331. package/pd-cli/dist/services/feature-flag-loader.js.map +0 -1
  332. package/plugin/dist/core/observability.d.ts +0 -40
  333. package/plugin/dist/core/observability.js +0 -164
  334. package/plugin/dist/hooks/subagent.d.ts +0 -9
  335. package/plugin/dist/hooks/subagent.js +0 -122
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime-v2/evidence-triage/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI1C,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAElF,gBAAgB;AAChB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAQpD,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AAUjC,OAAO,EACL,4BAA4B,EAC5B,+BAA+B,EAC/B,+BAA+B,EAC/B,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime-v2/evidence-triage/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI1C,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAElF,gBAAgB;AAChB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,6EAA6E;AAC7E,OAAO,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAI5F,OAAO,EACL,iBAAiB,EACjB,2BAA2B,EAC3B,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,2BAA2B,CAAC;AAQnC,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AAUjC,OAAO,EACL,4BAA4B,EAC5B,+BAA+B,EAC/B,+BAA+B,EAC/B,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Observation Resolver — PRI-446 (migrated from the plugin adapter)
3
+ *
4
+ * Unified source-kind resolution from RawObservation.
5
+ *
6
+ * Pure data mapping — no I/O, no plugin imports, no side effects. This module
7
+ * replaces the scattered resolveSourceKindFrom* helpers that previously lived in
8
+ * the plugin-side raw-observation-adapter.ts. The plugin file now re-exports
9
+ * these symbols so existing callers and source-string characterization tests
10
+ * keep working unchanged.
11
+ *
12
+ * Field precedence (highest to lowest):
13
+ * 1. isManualEntry → owner_reported
14
+ * 2. isGateBlock → rulehost_block
15
+ * 3. isSubagentError → subagent_error
16
+ * 4. isRateLimit → rate_limit / provider_failure
17
+ * 5. toolName === 'pain' / 'skill:pain' → agent_on_owner_request / owner_reported
18
+ * 6. isGfiTriggered → gfi_threshold
19
+ * 7. failureSource → tool_failure / dispatch_error
20
+ * 8. detectionSource → llm_paralysis / semantic / empathy_inferred / unknown
21
+ * 9. Fallback → unknown
22
+ *
23
+ * ERR checklist:
24
+ * - ERR-001: Source kind resolved from runtime values, no `as` casts.
25
+ * - ERR-002: Every path returns a valid SourceKind (fallback to 'unknown').
26
+ * - EP-01: Runtime values validated before use.
27
+ */
28
+ import type { SourceKind } from './types.js';
29
+ /**
30
+ * Raw observation from a source adapter.
31
+ *
32
+ * This is the input to resolveSourceKind. It contains all possible
33
+ * context fields that different sources may provide. The resolver
34
+ * reads only the fields it needs based on the observation source.
35
+ */
36
+ export interface RawObservation {
37
+ /** When the observation was made (ISO timestamp) */
38
+ readonly observedAt: string;
39
+ /** Workspace identifier */
40
+ readonly workspaceId?: string;
41
+ /** Session identifier */
42
+ readonly sessionId?: string;
43
+ /** Trace identifier for correlation */
44
+ readonly traceId?: string;
45
+ /** Tool name (for after_tool_call hook) */
46
+ readonly toolName?: string;
47
+ /** Failure source classification */
48
+ readonly failureSource?: 'tool_failure' | 'dispatch_error';
49
+ /** Whether the tool call exited with non-zero code */
50
+ readonly nonZeroExit?: boolean;
51
+ /** Whether the tool call timed out */
52
+ readonly timedOut?: boolean;
53
+ /** Whether the tool does not exist */
54
+ readonly toolNotFound?: boolean;
55
+ /** Detection source identifier */
56
+ readonly detectionSource?: string;
57
+ /** Whether GFI threshold was crossed */
58
+ readonly isGfiTriggered?: boolean;
59
+ /** Whether the failure was a rate limit (429) */
60
+ readonly isRateLimit?: boolean;
61
+ /** Whether this observation came from a gate block */
62
+ readonly isGateBlock?: boolean;
63
+ /** Whether this was a manual CLI entry */
64
+ readonly isManualEntry?: boolean;
65
+ /** Provenance: how trustworthy and context-bound is the observation */
66
+ readonly provenance?: 'openclaw_context_bound' | 'owner_reported_no_host_trace' | 'automatic_hook';
67
+ /** Whether this observation came from a subagent error */
68
+ readonly isSubagentError?: boolean;
69
+ /**
70
+ * Raw payload from the source.
71
+ *
72
+ * This is always `unknown` (ERR-005). Source adapters validate only
73
+ * enough to identify the source and capture bounded context.
74
+ */
75
+ readonly payload?: unknown;
76
+ }
77
+ /**
78
+ * Resolve SourceKind from a unified RawObservation.
79
+ *
80
+ * This function replaces the scattered resolveSourceKindFrom* functions
81
+ * and provides a single entry point for source-kind classification.
82
+ *
83
+ * Field precedence is explicitly defined in the function body to ensure
84
+ * deterministic behavior and make the logic easy to understand and test.
85
+ */
86
+ export declare function resolveSourceKind(observation: RawObservation): SourceKind;
87
+ /**
88
+ * Build a RawObservation for a tool failure context.
89
+ *
90
+ * This replaces classifyToolFailureSource and the inline classification
91
+ * in after-tool-call-helpers. All tool error → dispatch/tool_failure
92
+ * classification is centralized here.
93
+ */
94
+ export declare function buildToolFailureObservation(options: {
95
+ toolName: string | undefined;
96
+ error: unknown;
97
+ exitCode?: number;
98
+ provenance?: RawObservation['provenance'];
99
+ }): RawObservation;
100
+ /**
101
+ * Build a RawObservation for an LLM detection context.
102
+ */
103
+ export declare function buildLlmDetectionObservation(options: {
104
+ detectionSource: string;
105
+ isGfiTriggered: boolean;
106
+ }): RawObservation;
107
+ /**
108
+ * Build a RawObservation for an empathy/GFI-triggered context (PRI-454).
109
+ *
110
+ * Used by prompt.ts paths 2 and 3 (GFI threshold crossing + empathy keyword match).
111
+ * When isGfiTriggered=true, resolveSourceKind returns 'gfi_threshold' (evidence_only).
112
+ * When isGfiTriggered=false, resolveSourceKind returns 'empathy_inferred' (owner_confirm).
113
+ */
114
+ export declare function buildEmpathyObservation(options: {
115
+ detectionSource: string;
116
+ isGfiTriggered: boolean;
117
+ sessionId?: string;
118
+ }): RawObservation;
119
+ /**
120
+ * Build a RawObservation for a manual pain entry (PRI-454).
121
+ *
122
+ * Used by pain.ts path 5 (manual /pd-pain command).
123
+ * resolveSourceKind returns 'owner_reported' (triage: admit).
124
+ */
125
+ export declare function buildManualPainObservation(options: {
126
+ sessionId?: string;
127
+ }): RawObservation;
128
+ //# sourceMappingURL=observation-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observation-resolver.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/evidence-triage/observation-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAA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AC5B;AAID;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,cAAc,GAAG,UAAU,CAkGzE;AAwBD;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE;IACnD,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;CAC3C,GAAG,cAAc,CA0BjB;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE;IACpD,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;CACzB,GAAG,cAAc,CAMjB;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAC/C,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,cAAc,CAOjB;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,cAAc,CAMjB"}
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Observation Resolver — PRI-446 (migrated from the plugin adapter)
3
+ *
4
+ * Unified source-kind resolution from RawObservation.
5
+ *
6
+ * Pure data mapping — no I/O, no plugin imports, no side effects. This module
7
+ * replaces the scattered resolveSourceKindFrom* helpers that previously lived in
8
+ * the plugin-side raw-observation-adapter.ts. The plugin file now re-exports
9
+ * these symbols so existing callers and source-string characterization tests
10
+ * keep working unchanged.
11
+ *
12
+ * Field precedence (highest to lowest):
13
+ * 1. isManualEntry → owner_reported
14
+ * 2. isGateBlock → rulehost_block
15
+ * 3. isSubagentError → subagent_error
16
+ * 4. isRateLimit → rate_limit / provider_failure
17
+ * 5. toolName === 'pain' / 'skill:pain' → agent_on_owner_request / owner_reported
18
+ * 6. isGfiTriggered → gfi_threshold
19
+ * 7. failureSource → tool_failure / dispatch_error
20
+ * 8. detectionSource → llm_paralysis / semantic / empathy_inferred / unknown
21
+ * 9. Fallback → unknown
22
+ *
23
+ * ERR checklist:
24
+ * - ERR-001: Source kind resolved from runtime values, no `as` casts.
25
+ * - ERR-002: Every path returns a valid SourceKind (fallback to 'unknown').
26
+ * - EP-01: Runtime values validated before use.
27
+ */
28
+ // ── Source Kind Resolution ──────────────────────────────────────────────────
29
+ /**
30
+ * Resolve SourceKind from a unified RawObservation.
31
+ *
32
+ * This function replaces the scattered resolveSourceKindFrom* functions
33
+ * and provides a single entry point for source-kind classification.
34
+ *
35
+ * Field precedence is explicitly defined in the function body to ensure
36
+ * deterministic behavior and make the logic easy to understand and test.
37
+ */
38
+ export function resolveSourceKind(observation) {
39
+ const { isManualEntry, isGateBlock, isSubagentError, isRateLimit, toolName, failureSource, isGfiTriggered, detectionSource, nonZeroExit, timedOut, toolNotFound, } = observation;
40
+ // Priority 1: Manual entry (CLI, owner-reported)
41
+ if (isManualEntry) {
42
+ return 'owner_reported';
43
+ }
44
+ // Priority 2: Gate block
45
+ if (isGateBlock) {
46
+ return 'rulehost_block';
47
+ }
48
+ // Priority 3: Subagent error
49
+ if (isSubagentError) {
50
+ return 'subagent_error';
51
+ }
52
+ // Priority 4: Provider rate limit (explicit true/false)
53
+ if (isRateLimit === true) {
54
+ return 'rate_limit';
55
+ }
56
+ if (isRateLimit === false) {
57
+ return 'provider_failure';
58
+ }
59
+ // Priority 5: Manual pain tool
60
+ if (toolName === 'pain' || toolName === 'skill:pain') {
61
+ // Match resolveSourceKindFromToolFailure behavior:
62
+ // openclaw_context_bound → agent_on_owner_request
63
+ // other provenance or undefined → owner_reported
64
+ if (observation.provenance === 'openclaw_context_bound') {
65
+ return 'agent_on_owner_request';
66
+ }
67
+ return 'owner_reported';
68
+ }
69
+ // Priority 6: GFI threshold (must check before failure source for LLM detection path)
70
+ if (isGfiTriggered) {
71
+ return 'gfi_threshold';
72
+ }
73
+ // Priority 7: Tool failure / dispatch error
74
+ if (failureSource) {
75
+ // Match resolveSourceKindFromToolFailure behavior:
76
+ // dispatch_error → dispatch_error, anything else → tool_failure
77
+ if (failureSource === 'dispatch_error') {
78
+ return 'dispatch_error';
79
+ }
80
+ return 'tool_failure';
81
+ }
82
+ // Infer failureSource from tool failure indicators if not explicitly set
83
+ if (toolNotFound) {
84
+ return 'dispatch_error';
85
+ }
86
+ // Match classifyToolFailureSource behavior: unknown tool name → dispatch_error
87
+ // BUT only if this looks like a tool failure context (has other tool fields)
88
+ // Otherwise, this is likely a non-tool observation (e.g., LLM detection)
89
+ const hasToolContext = toolName !== undefined || nonZeroExit || timedOut || toolNotFound;
90
+ if (hasToolContext && (!toolName || toolName.trim() === '')) {
91
+ return 'dispatch_error';
92
+ }
93
+ // Exit code-based detection: non-zero exit or timeout → tool_failure
94
+ if (nonZeroExit || timedOut) {
95
+ return 'tool_failure';
96
+ }
97
+ // Priority 8: LLM detection source
98
+ if (detectionSource) {
99
+ // Match resolveSourceKindFromLlmDetection behavior:
100
+ if (detectionSource === 'llm_paralysis') {
101
+ return 'llm_paralysis';
102
+ }
103
+ if (detectionSource.startsWith('llm_')) {
104
+ return 'semantic';
105
+ }
106
+ if (detectionSource === 'user_empathy') {
107
+ return 'empathy_inferred';
108
+ }
109
+ }
110
+ // Fallback: unknown
111
+ return 'unknown';
112
+ }
113
+ // ── Builder Functions ──────────────────────────────────────────────────────
114
+ //
115
+ // PRI-360 S1: These builders construct RawObservation from specific contexts,
116
+ // centralizing source classification rules in the adapter layer.
117
+ // Hooks should NOT hold source classification logic — use these builders.
118
+ /**
119
+ * Classify error message as dispatch_error vs tool_failure.
120
+ *
121
+ * This centralizes the regex-based classification that was previously
122
+ * scattered in classifyToolFailureSource and after-tool-call-helpers.
123
+ * Now hooks call this builder + resolveSourceKind instead of holding rules.
124
+ */
125
+ function classifyErrorForDispatch(error) {
126
+ if (!error)
127
+ return 'tool_failure';
128
+ const msg = String(error);
129
+ if (/\btool\s+(?:\S+\s+)?not\s+found\b/i.test(msg) || /\bunknown\s+tool\b/i.test(msg)) {
130
+ return 'dispatch_error';
131
+ }
132
+ return 'tool_failure';
133
+ }
134
+ /**
135
+ * Build a RawObservation for a tool failure context.
136
+ *
137
+ * This replaces classifyToolFailureSource and the inline classification
138
+ * in after-tool-call-helpers. All tool error → dispatch/tool_failure
139
+ * classification is centralized here.
140
+ */
141
+ export function buildToolFailureObservation(options) {
142
+ const { toolName, error, provenance } = options;
143
+ const nonZeroExit = typeof options.exitCode === 'number' && options.exitCode !== 0;
144
+ // Classify dispatch vs tool_failure centrally
145
+ let failureSource;
146
+ if (!toolName || toolName.trim() === '') {
147
+ // Empty/whitespace tool name → dispatch error
148
+ failureSource = 'dispatch_error';
149
+ }
150
+ else {
151
+ failureSource = classifyErrorForDispatch(error);
152
+ }
153
+ // If neither error nor non-zero exit, this is not a failure context
154
+ if (!error && !nonZeroExit) {
155
+ failureSource = undefined;
156
+ }
157
+ return {
158
+ observedAt: new Date().toISOString(),
159
+ toolName,
160
+ failureSource,
161
+ nonZeroExit,
162
+ provenance,
163
+ };
164
+ }
165
+ /**
166
+ * Build a RawObservation for an LLM detection context.
167
+ */
168
+ export function buildLlmDetectionObservation(options) {
169
+ return {
170
+ observedAt: new Date().toISOString(),
171
+ detectionSource: options.detectionSource,
172
+ isGfiTriggered: options.isGfiTriggered,
173
+ };
174
+ }
175
+ /**
176
+ * Build a RawObservation for an empathy/GFI-triggered context (PRI-454).
177
+ *
178
+ * Used by prompt.ts paths 2 and 3 (GFI threshold crossing + empathy keyword match).
179
+ * When isGfiTriggered=true, resolveSourceKind returns 'gfi_threshold' (evidence_only).
180
+ * When isGfiTriggered=false, resolveSourceKind returns 'empathy_inferred' (owner_confirm).
181
+ */
182
+ export function buildEmpathyObservation(options) {
183
+ return {
184
+ observedAt: new Date().toISOString(),
185
+ detectionSource: options.detectionSource,
186
+ isGfiTriggered: options.isGfiTriggered,
187
+ sessionId: options.sessionId,
188
+ };
189
+ }
190
+ /**
191
+ * Build a RawObservation for a manual pain entry (PRI-454).
192
+ *
193
+ * Used by pain.ts path 5 (manual /pd-pain command).
194
+ * resolveSourceKind returns 'owner_reported' (triage: admit).
195
+ */
196
+ export function buildManualPainObservation(options) {
197
+ return {
198
+ observedAt: new Date().toISOString(),
199
+ isManualEntry: true,
200
+ sessionId: options.sessionId,
201
+ };
202
+ }
203
+ //# sourceMappingURL=observation-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observation-resolver.js","sourceRoot":"","sources":["../../../src/runtime-v2/evidence-triage/observation-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAqEH,+EAA+E;AAE/E;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAA2B;IAC3D,MAAM,EACJ,aAAa,EACb,WAAW,EACX,eAAe,EACf,WAAW,EACX,QAAQ,EACR,aAAa,EACb,cAAc,EACd,eAAe,EACf,WAAW,EACX,QAAQ,EACR,YAAY,GACb,GAAG,WAAW,CAAC;IAEhB,iDAAiD;IACjD,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,yBAAyB;IACzB,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,6BAA6B;IAC7B,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,wDAAwD;IACxD,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;QACzB,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,IAAI,WAAW,KAAK,KAAK,EAAE,CAAC;QAC1B,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED,+BAA+B;IAC/B,IAAI,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,YAAY,EAAE,CAAC;QACrD,mDAAmD;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ACL,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACpC,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,cAAc,EAAE,OAAO,CAAC,cAAc;KACvC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAIvC;IACC,OAAO;QACL,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACpC,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,cAAc,EAAE,OAAO,CAAC,cAAc;QACtC,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAC,OAE1C;IACC,OAAO;QACL,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACpC,aAAa,EAAE,IAAI;QACnB,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC;AACJ,CAAC"}
@@ -14,6 +14,10 @@
14
14
  * - ERR-005: Input is unknown, validated field-by-field.
15
15
  */
16
16
  import type { TriageInput, TriageResult } from './types.js';
17
+ /** Pain score at or above which a risky action upgrades to admit. */
18
+ export declare const RISKY_HIGH_SCORE_THRESHOLD = 70;
19
+ /** Consecutive failures at or above which a tool failure upgrades to admit. */
20
+ export declare const REPEATED_FAILURE_THRESHOLD = 4;
17
21
  /**
18
22
  * Evaluate triage policy for incoming evidence.
19
23
  *
@@ -1 +1 @@
1
- {"version":3,"file":"triage-policy.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/evidence-triage/triage-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAA8B,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAuCxF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,CAmC/D"}
1
+ {"version":3,"file":"triage-policy.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/evidence-triage/triage-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAA8B,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAWxF,qEAAqE;AACrE,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAC7C,+EAA+E;AAC/E,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAyF5C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,CA4C/D"}
@@ -15,33 +15,82 @@
15
15
  */
16
16
  import { isSourceKind } from './types.js';
17
17
  import { getSourceDescriptor } from './source-descriptors.js';
18
+ // ── Upgrade Thresholds (PRI-446 — migrated verbatim from the plugin adapter) ──
19
+ //
20
+ // These constants previously lived inline in the plugin-side triage-adapter
21
+ // as magic numbers `70` and `4`. They are moved here byte-for-byte so the
22
+ // upgrade decision has a single source of truth. The adapter now passes
23
+ // isRisky / consecutiveErrors through to core instead of overriding the result.
24
+ /** Pain score at or above which a risky action upgrades to admit. */
25
+ export const RISKY_HIGH_SCORE_THRESHOLD = 70;
26
+ /** Consecutive failures at or above which a tool failure upgrades to admit. */
27
+ export const REPEATED_FAILURE_THRESHOLD = 4;
18
28
  // ── Upgrade Rules ───────────────────────────────────────────────────────────
19
29
  /**
20
30
  * Apply upgrade rules for upgradable source kinds.
21
31
  *
22
- * Currently only 'rulehost_block' can be upgraded:
23
- * - If isUnsafeHighConfidence is true, upgrade from 'evidence_only' to 'admit'
32
+ * Three rules (PRI-446 consolidated all of them into core):
33
+ * 1. rulehost_block + isUnsafeHighConfidence → admit
34
+ * 2. tool_failure (or any evidence_only upgradeable kind) + isRisky + score >= 70 → admit
35
+ * 3. tool_failure (or any evidence_only upgradeable kind) + consecutiveErrors >= 4 → admit
24
36
  *
25
37
  * This is the ONLY place where context-dependent upgrades happen in core.
26
- * The plugin adapter sets isUnsafeHighConfidence based on hook context.
38
+ * The plugin adapter sets the context flags based on hook context.
39
+ *
40
+ * Rule precedence matches the prior plugin implementation: risky high-score is
41
+ * checked before repeated failure, but since both produce the same upgraded
42
+ * decision with the same nextAction, the order is only observable via the
43
+ * reason string. We preserve the plugin's prior order (risky first).
27
44
  */
28
45
  function applyUpgradeRules(input, defaultDecision) {
46
+ if (defaultDecision !== 'evidence_only') {
47
+ return defaultDecision;
48
+ }
49
+ // Rule 1: rulehost_block unsafe action (pre-existing).
29
50
  if (input.sourceKind === 'rulehost_block' && input.isUnsafeHighConfidence === true) {
30
51
  return 'admit';
31
52
  }
53
+ // Rule 2: risky high-score (migrated from plugin, PRI-446).
54
+ if (input.isRisky === true && input.score >= RISKY_HIGH_SCORE_THRESHOLD) {
55
+ return 'admit';
56
+ }
57
+ // Rule 3: repeated failure (migrated from plugin, PRI-446).
58
+ if (input.consecutiveErrors !== undefined && input.consecutiveErrors >= REPEATED_FAILURE_THRESHOLD) {
59
+ return 'admit';
60
+ }
32
61
  return defaultDecision;
33
62
  }
34
63
  function getUpgradeReason(sourceKind, decision, input) {
35
- if (sourceKind === 'rulehost_block' && decision === 'admit') {
64
+ if (decision !== 'admit') {
65
+ return `Upgraded decision for ${sourceKind}: ${decision}`;
66
+ }
67
+ if (sourceKind === 'rulehost_block' && input.isUnsafeHighConfidence === true) {
36
68
  return `RuleHost blocked a high-confidence unsafe action (score=${input.score}). Upgrading to direct diagnosis.`;
37
69
  }
70
+ // PRI-446: verbatim string from the plugin triage-adapter
71
+ if (input.isRisky === true && input.score >= RISKY_HIGH_SCORE_THRESHOLD) {
72
+ return 'Risky high-score operation overrides evidence-only decision. Immediate diagnosis required.';
73
+ }
74
+ // PRI-446: verbatim string from the plugin triage-adapter
75
+ if (input.consecutiveErrors !== undefined && input.consecutiveErrors >= REPEATED_FAILURE_THRESHOLD) {
76
+ return 'Repeated failures override evidence-only decision. Pattern suggests systemic issue requiring diagnosis.';
77
+ }
38
78
  // Should not reach here — fallback
39
79
  return `Upgraded decision for ${sourceKind}: ${decision}`;
40
80
  }
41
- function getUpgradeNextAction(sourceKind, decision) {
42
- if (sourceKind === 'rulehost_block' && decision === 'admit') {
81
+ function getUpgradeNextAction(sourceKind, decision, input) {
82
+ if (decision !== 'admit') {
43
83
  return 'none';
44
84
  }
85
+ if (sourceKind === 'rulehost_block' && input.isUnsafeHighConfidence === true) {
86
+ return 'none';
87
+ }
88
+ // PRI-446: verbatim nextAction from the plugin triage-adapter
89
+ // (both risky-high-score and repeated-failure used 'create_diagnostic_task').
90
+ if ((input.isRisky === true && input.score >= RISKY_HIGH_SCORE_THRESHOLD) ||
91
+ (input.consecutiveErrors !== undefined && input.consecutiveErrors >= REPEATED_FAILURE_THRESHOLD)) {
92
+ return 'create_diagnostic_task';
93
+ }
45
94
  return 'none';
46
95
  }
47
96
  // ── Evaluation ──────────────────────────────────────────────────────────────
@@ -73,15 +122,23 @@ export function evaluateTriage(input) {
73
122
  nextAction: 'classify_source_kind_and_store_as_evidence',
74
123
  };
75
124
  }
76
- // Apply upgrade rules for upgradable kinds
77
- if (descriptor.canUpgrade) {
125
+ // Apply upgrade rules. PRI-446: rule 1 (rulehost_block) is gated by
126
+ // descriptor.canUpgrade; rules 2/3 (risky high-score / repeated failure) are
127
+ // context-driven and apply to any evidence_only kind when the relevant flag is
128
+ // present, matching the prior plugin behavior. applyUpgradeRules internally
129
+ // guards on defaultDecision === 'evidence_only', so non-upgradeable kinds
130
+ // (admit/health_only/owner_confirm) are never affected.
131
+ const upgradeable = descriptor.canUpgrade ||
132
+ input.isRisky !== undefined ||
133
+ input.consecutiveErrors !== undefined;
134
+ if (upgradeable) {
78
135
  const upgraded = applyUpgradeRules(input, descriptor.defaultDecision);
79
136
  if (upgraded !== descriptor.defaultDecision) {
80
137
  return {
81
138
  decision: upgraded,
82
139
  sourceKind,
83
140
  reason: getUpgradeReason(sourceKind, upgraded, input),
84
- nextAction: getUpgradeNextAction(sourceKind, upgraded),
141
+ nextAction: getUpgradeNextAction(sourceKind, upgraded, input),
85
142
  };
86
143
  }
87
144
  }
@@ -1 +1 @@
1
- {"version":3,"file":"triage-policy.js","sourceRoot":"","sources":["../../../src/runtime-v2/evidence-triage/triage-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,+EAA+E;AAE/E;;;;;;;;GAQG;AACH,SAAS,iBAAiB,CAAC,KAAkB,EAAE,eAA+B;IAC5E,IAAI,KAAK,CAAC,UAAU,KAAK,gBAAgB,IAAI,KAAK,CAAC,sBAAsB,KAAK,IAAI,EAAE,CAAC;QACnF,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,SAAS,gBAAgB,CAAC,UAAsB,EAAE,QAAwB,EAAE,KAAkB;IAC5F,IAAI,UAAU,KAAK,gBAAgB,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QAC5D,OAAO,2DAA2D,KAAK,CAAC,KAAK,mCAAmC,CAAC;IACnH,CAAC;IACD,mCAAmC;IACnC,OAAO,yBAAyB,UAAU,KAAK,QAAQ,EAAE,CAAC;AAC5D,CAAC;AAED,SAAS,oBAAoB,CAAC,UAAsB,EAAE,QAAwB;IAC5E,IAAI,UAAU,KAAK,gBAAgB,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QAC5D,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,+EAA+E;AAE/E;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,cAAc,CAAC,KAAkB;IAC/C,kDAAkD;IAClD,MAAM,UAAU,GAAe,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;IAE7F,qBAAqB;IACrB,MAAM,UAA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5E,0EAA0E;IAC1E,wDAAwD;IACxD,MAAM,WAAW,GACf,UAAU,CAAC,UAAU;QACrB,KAAK,CAAC,OAAO,KAAK,SAAS;QAC3B,KAAK,CAAC,iBAAiB,KAAK,SAAS,CAAC;IACxC,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,QAAQ,GAAG,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC;QACtE,IAAI,QAAQ,KAAK,UAAU,CAAC,eAAe,EAAE,CAAC;YAC5C,OAAO;gBACL,QAAQ,EAAE,QAAQ;gBAClB,UAAU;gBACV,MAAM,EAAE,gBAAgB,CAAC,UAAU,EAAE,QAAQ,EAAE,KAAK,CAAC;gBACrD,UAAU,EAAE,oBAAoB,CAAC,UAAU,EAAE,QAAQ,EAAE,KAAK,CAAC;aAC9D,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,UAAU,CAAC,eAAe;QACpC,UAAU;QACV,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,UAAU,EAAE,UAAU,CAAC,UAAU;KAClC,CAAC;AACJ,CAAC"}
@@ -56,6 +56,20 @@ export interface TriageInput {
56
56
  readonly isUnsafeHighConfidence?: boolean;
57
57
  /** Provenance: how was this pain observed? */
58
58
  readonly provenance?: 'openclaw_context_bound' | 'owner_reported_no_host_trace' | 'automatic_hook';
59
+ /**
60
+ * Whether the failed action was risky/irreversible.
61
+ *
62
+ * Migrated from the plugin triage-adapter (PRI-446): a risky action with
63
+ * a high pain score upgrades an evidence_only decision to admit.
64
+ */
65
+ readonly isRisky?: boolean;
66
+ /**
67
+ * Number of consecutive failures observed for the current session/tool.
68
+ *
69
+ * Migrated from the plugin triage-adapter (PRI-446): repeated failures
70
+ * (>= RISKY_HIGH_SCORE_THRESHOLD) upgrade an evidence_only decision to admit.
71
+ */
72
+ readonly consecutiveErrors?: number;
59
73
  }
60
74
  /**
61
75
  * Runtime guard for SourceKind.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/evidence-triage/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAClB,gBAAgB,GAChB,wBAAwB,GACxB,cAAc,GACd,gBAAgB,GAChB,kBAAkB,GAClB,YAAY,GACZ,gBAAgB,GAChB,kBAAkB,GAClB,UAAU,GACV,eAAe,GACf,gBAAgB,GAChB,eAAe,GACf,SAAS,CAAC;AAId;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GACtB,OAAO,GACP,eAAe,GACf,eAAe,GACf,aAAa,GACb,QAAQ,CAAC;AAIb;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,yCAAyC;IACzC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,8BAA8B;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAID;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,6BAA6B;IAC7B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,yBAAyB;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAC1C,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,CAAC,EAAE,wBAAwB,GAAG,8BAA8B,GAAG,gBAAgB,CAAC;CACpG;AAoBD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAEhE"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/evidence-triage/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAa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"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA6EH,gFAAgF;AAEhF,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAa;IAClE,gBAAgB;IAChB,wBAAwB;IACxB,cAAc;IACd,gBAAgB;IAChB,kBAAkB;IAClB,YAAY;IACZ,gBAAgB;IAChB,kBAAkB;IAClB,UAAU;IACV,eAAe;IACf,gBAAgB;IAChB,eAAe;IACf,SAAS;CACV,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACpE,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/runtime-v2/evidence-triage/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA2FH,gFAAgF;AAEhF,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAa;IAClE,gBAAgB;IAChB,wBAAwB;IACxB,cAAc;IACd,gBAAgB;IAChB,kBAAkB;IAClB,YAAY;IACZ,gBAAgB;IAChB,kBAAkB;IAClB,UAAU;IACV,eAAe;IACf,gBAAgB;IAChB,eAAe;IACf,SAAS;CACV,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACpE,CAAC"}
@@ -206,6 +206,15 @@ describe('computeEffectiveFlags', () => {
206
206
  continue;
207
207
  if (flag.id === 'story_a_approval_completion')
208
208
  continue;
209
+ // PRI-454: painEvidenceAdmission + painEvidenceAdmissionDefault flipped to default-on
210
+ if (flag.id === 'painEvidenceAdmission')
211
+ continue;
212
+ if (flag.id === 'pain_evidence_admission')
213
+ continue;
214
+ if (flag.id === 'painEvidenceAdmissionDefault')
215
+ continue;
216
+ if (flag.id === 'pain_evidence_admission_default')
217
+ continue;
209
218
  expect(flag.enabled, `quiet flag ${flag.id} should default off`).toBe(false);
210
219
  }
211
220
  });
@@ -323,26 +332,46 @@ describe('DEFAULT_FEATURE_FLAGS', () => {
323
332
  }
324
333
  }
325
334
  });
326
- it('PEAT-B1: painEvidenceAdmission is registered as quiet, default-off', () => {
335
+ it('PEAT-B1: painEvidenceAdmission is registered as quiet, default-on (PRI-454 flip)', () => {
327
336
  const flag = DEFAULT_FEATURE_FLAGS.find(f => f.id === 'painEvidenceAdmission');
328
337
  expect(flag).toBeDefined();
329
338
  if (!flag)
330
339
  throw new Error('painEvidenceAdmission flag not found');
331
340
  expect(flag.category).toBe('quiet');
332
- expect(flag.enabled).toBe(false);
341
+ expect(flag.enabled).toBe(true);
333
342
  expect(flag.since).toBe('2026-06-06');
334
343
  expect(flag.description).toContain('PEAT-B1');
335
344
  });
336
- it('PRI-404: pain_evidence_admission snake_case alias is registered as quiet, default-off', () => {
345
+ it('PRI-404: pain_evidence_admission snake_case alias is registered as quiet, default-on (PRI-454 flip)', () => {
337
346
  const flag = DEFAULT_FEATURE_FLAGS.find(f => f.id === 'pain_evidence_admission');
338
347
  expect(flag).toBeDefined();
339
348
  if (!flag)
340
349
  throw new Error('pain_evidence_admission flag not found');
341
350
  expect(flag.category).toBe('quiet');
342
- expect(flag.enabled).toBe(false);
351
+ expect(flag.enabled).toBe(true);
343
352
  expect(flag.since).toBe('2026-06-15');
344
353
  expect(flag.description).toContain('Snake-case');
345
354
  });
355
+ it('PRI-454: painEvidenceAdmissionDefault is registered as quiet, default-on', () => {
356
+ const flag = DEFAULT_FEATURE_FLAGS.find(f => f.id === 'painEvidenceAdmissionDefault');
357
+ expect(flag).toBeDefined();
358
+ if (!flag)
359
+ throw new Error('painEvidenceAdmissionDefault flag not found');
360
+ expect(flag.category).toBe('quiet');
361
+ expect(flag.enabled).toBe(true);
362
+ expect(flag.since).toBe('2026-06-24');
363
+ expect(flag.description).toContain('PRI-454');
364
+ });
365
+ it('PRI-454: pain_evidence_admission_default snake_case alias is registered as quiet, default-on', () => {
366
+ const flag = DEFAULT_FEATURE_FLAGS.find(f => f.id === 'pain_evidence_admission_default');
367
+ expect(flag).toBeDefined();
368
+ if (!flag)
369
+ throw new Error('pain_evidence_admission_default flag not found');
370
+ expect(flag.category).toBe('quiet');
371
+ expect(flag.enabled).toBe(true);
372
+ expect(flag.since).toBe('2026-06-24');
373
+ expect(flag.description).toContain('PRI-454');
374
+ });
346
375
  it('PRI-404: pain_evidence_admission is recognized by computeEffectiveFlags (no unknown warning)', () => {
347
376
  const userFlags = {
348
377
  pain_evidence_admission: { enabled: true },