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.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAGlC,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,YAAY,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AACvG,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGjH,YAAY,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AACzG,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAGxE,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,oBAAo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3B,2BAA2B,GAC5B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,qBAAqB,EACrB,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,wCAAwC,CAAC;AAChD,YAAY,EACV,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,6BAA6B,EAC7B,cAAc,GACf,MAAM,uCAAuC,CAAC"}
@@ -27,18 +27,10 @@ export { PI_METADATA_KEY, serializePITaskMetadata, parsePITaskMetadata, hydrateP
27
27
  export { PassThroughDreamerValidator, DefaultDreamerValidator } from './dreamer-output.js';
28
28
  export { resolveDreamerRunnerOptions, DEFAULT_DREAMER_RUNNER_OPTIONS, } from './dreamer-runner.js';
29
29
  export { DreamerRunner } from './dreamer-runner.js';
30
- export { DefaultPhilosopherValidator, } from './philosopher-output.js';
31
- export { PhilosopherRunner, resolvePhilosopherRunnerOptions, DEFAULT_PHILOSOPHER_RUNNER_OPTIONS, } from './philosopher-runner.js';
32
30
  export { DefaultScribeValidator, } from './scribe-output.js';
33
31
  export { ScribeRunner, resolveScribeRunnerOptions, DEFAULT_SCRIBE_RUNNER_OPTIONS, } from './scribe-runner.js';
34
32
  export { DefaultArtificerValidator, ArtificerRuleOutputSchema, ArtificerSourceTraceSchema, } from './artificer-output.js';
35
33
  export { ArtificerRunner, resolveArtificerRunnerOptions, DEFAULT_ARTIFICER_RUNNER_OPTIONS, } from './artificer-runner.js';
36
- export { DefaultEvaluatorValidator, EvaluatorOutputV1Schema, EvaluatorEvaluationSchema, EvaluatorSourceTraceSchema, EVALUATOR_DECISIONS, isEvaluatorOutputV2, } from './evaluator-output.js';
37
- export { EvaluatorRunner, resolveEvaluatorRunnerOptions, DEFAULT_EVALUATOR_RUNNER_OPTIONS, } from './evaluator-runner.js';
38
- export { EvaluatorPromptBuilder, EVALUATOR_PROTOCOL_INSTRUCTION, EVALUATOR_PROMPT_CONTRACT_VERSION, } from './evaluator-prompt-builder.js';
39
- export { DefaultRolloutReviewerValidator, RolloutReviewerOutputV1Schema, RolloutReviewerReviewSchema, RolloutReviewerSourceTraceSchema, ROLLOUT_REVIEWER_DECISIONS, } from './rollout-reviewer-output.js';
40
- export { RolloutReviewerRunner, resolveRolloutReviewerRunnerOptions, DEFAULT_ROLLOUT_REVIEWER_RUNNER_OPTIONS, } from './rollout-reviewer-runner.js';
41
- export { RolloutReviewerPromptBuilder, ROLLOUT_REVIEWER_PROTOCOL_INSTRUCTION, ROLLOUT_REVIEWER_PROMPT_CONTRACT_VERSION, } from './rollout-reviewer-prompt-builder.js';
42
34
  export { InternalizationOrchestrator, WAKE_ONCE_DECISIONS } from './internalization-orchestrator.js';
43
35
  export { MemoryPIArtifactStore } from './pi-artifact-store.js';
44
36
  export { SqlitePIArtifactStore } from '../store/artifact/sqlite-pi-artifact-store.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAaH,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAI/D,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAIjH,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAIxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAI/D,OAAO,EAAE,sBAAsB,EAAE,kCAAkC,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAOlI,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAmBlE,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAIvF,OAAO,EAAE,yBAAyB,EAAE,M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AA+C,CAAC;AActF,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEtE,8EAA8E;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAGxE,8EAA8E;AAC9E,sEAAsE;AACtE,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,qBAAqB,EACrB,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,wCAAwC,CAAC;AAMhD,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,6BAA6B,EAC7B,cAAc,GACf,MAAM,uCAAuC,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Pain Diagnostic Gate Policy Tests — PRI-446
3
+ *
4
+ * Tests the pure core decision logic directly (not through the plugin adapter).
5
+ * The plugin's pain-diagnostic-gate.test.ts (40 tests) exercises the same logic
6
+ * via the stateful adapter; this file gives core its own direct coverage with
7
+ * deterministic time (nowMs passed in, no Date.now).
8
+ *
9
+ * ERR checklist:
10
+ * - ERR-001: inputs validated with Number.isFinite.
11
+ * - ERR-002: every decision carries reason + detail.
12
+ * - ERR-025: tests the real evaluatePainDiagnosticGateDecision path.
13
+ */
14
+ export {};
15
+ //# sourceMappingURL=pain-diagnostic-gate-policy.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pain-diagnostic-gate-policy.test.d.ts","sourceRoot":"","sources":["../../../../src/runtime-v2/pain-gate/__tests__/pain-diagnostic-gate-policy.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Pain Diagnostic Gate Policy Tests — PRI-446
3
+ *
4
+ * Tests the pure core decision logic directly (not through the plugin adapter).
5
+ * The plugin's pain-diagnostic-gate.test.ts (40 tests) exercises the same logic
6
+ * via the stateful adapter; this file gives core its own direct coverage with
7
+ * deterministic time (nowMs passed in, no Date.now).
8
+ *
9
+ * ERR checklist:
10
+ * - ERR-001: inputs validated with Number.isFinite.
11
+ * - ERR-002: every decision carries reason + detail.
12
+ * - ERR-025: tests the real evaluatePainDiagnosticGateDecision path.
13
+ */
14
+ import { describe, it, expect } from 'vitest';
15
+ import { evaluatePainDiagnosticGateDecision, buildEpisodeKey, normalizedSource, isCooldownActive, DEFAULT_COOLDOWN_MS, DEFAULT_PAIN_TRIGGER, DEFAULT_HIGH_SEVERITY, DEFAULT_REPEATED_FAILURE, } from '../pain-diagnostic-gate-policy.js';
16
+ function makeInput(overrides = {}) {
17
+ return {
18
+ source: 'tool_failure',
19
+ score: 0,
20
+ currentGfi: 0,
21
+ nowMs: 1_000_000,
22
+ ...overrides,
23
+ };
24
+ }
25
+ describe('normalizedSource', () => {
26
+ it('maps llm_* (not llm_paralysis) to semantic', () => {
27
+ expect(normalizedSource('llm_repetition').source).toBe('semantic');
28
+ expect(normalizedSource('llm_repetition').unknown).toBe(false);
29
+ });
30
+ it('keeps llm_paralysis as llm_paralysis', () => {
31
+ expect(normalizedSource('llm_paralysis').source).toBe('llm_paralysis');
32
+ });
33
+ it('flags unknown sources', () => {
34
+ const r = normalizedSource('totally_unknown');
35
+ expect(r.source).toBe('totally_unknown');
36
+ expect(r.unknown).toBe(true);
37
+ });
38
+ it('recognizes all known sources', () => {
39
+ for (const s of ['manual', 'tool_failure', 'gate_blocked', 'semantic', 'subagent_error']) {
40
+ expect(normalizedSource(s).unknown).toBe(false);
41
+ }
42
+ });
43
+ });
44
+ describe('buildEpisodeKey', () => {
45
+ it('scopes by session, source, and hash', () => {
46
+ const key = buildEpisodeKey({ source: 'tool_failure', sessionId: 's1', errorHash: 'h1', score: 0, currentGfi: 0 });
47
+ expect(key).toBe('s1:tool_failure:h1');
48
+ });
49
+ it('falls back to unknown session and no-hash', () => {
50
+ const key = buildEpisodeKey({ source: 'manual', score: 0, currentGfi: 0 });
51
+ expect(key).toBe('unknown:manual:no-hash');
52
+ });
53
+ it('normalizes llm_* source to semantic in the key', () => {
54
+ const key = buildEpisodeKey({ source: 'llm_loop', sessionId: 's', score: 0, currentGfi: 0 });
55
+ expect(key).toBe('s:semantic:no-hash');
56
+ });
57
+ });
58
+ describe('evaluatePainDiagnosticGateDecision: source branches', () => {
59
+ it('manual always approves (bypasses automatic gate)', () => {
60
+ const d = evaluatePainDiagnosticGateDecision(makeInput({ source: 'manual', score: 0 }));
61
+ expect(d.shouldDiagnose).toBe(true);
62
+ expect(d.reason).toBe('manual');
63
+ });
64
+ it('subagent_error approves when score >= painTrigger', () => {
65
+ const d = evaluatePainDiagnosticGateDecision(makeInput({ source: 'subagent_error', score: 40 }));
66
+ expect(d.shouldDiagnose).toBe(true);
67
+ expect(d.reason).toBe('subagent_error');
68
+ });
69
+ it('subagent_error below gate stays below_gate', () => {
70
+ const d = evaluatePainDiagnosticGateDecision(makeInput({ source: 'subagent_error', score: 39 }));
71
+ expect(d.shouldDiagnose).toBe(false);
72
+ expect(d.reason).toBe('below_gate');
73
+ });
74
+ it('llm_paralysis approves when score >= painTrigger', () => {
75
+ const d = evaluatePainDiagnosticGateDecision(makeInput({ source: 'llm_paralysis', score: 40 }));
76
+ expect(d.reason).toBe('llm_paralysis');
77
+ });
78
+ it('gate_blocked approves when score >= painTrigger', () => {
79
+ const d = evaluatePainDiagnosticGateDecision(makeInput({ source: 'gate_blocked', score: 40 }));
80
+ expect(d.reason).toBe('gate_blocked');
81
+ });
82
+ it('semantic / user_empathy approve when score >= semanticPain', () => {
83
+ const d = evaluatePainDiagnosticGateDecision(makeInput({ source: 'semantic', score: 60 }));
84
+ expect(d.reason).toBe('semantic_pain');
85
+ });
86
+ it('risky high-score approves (isRisky && score >= 70)', () => {
87
+ const d = evaluatePainDiagnosticGateDecision(makeInput({ source: 'tool_failure', score: 70, isRisky: true }));
88
+ expect(d.shouldDiagnose).toBe(true);
89
+ expect(d.reason).toBe('risky_high_score');
90
+ });
91
+ it('repeated failure approves (consecutiveErrors >= 4)', () => {
92
+ const d = evaluatePainDiagnosticGateDecision(makeInput({ source: 'tool_failure', score: 0, consecutiveErrors: 4 }));
93
+ expect(d.shouldDiagnose).toBe(true);
94
+ expect(d.reason).toBe('repeated_failure');
95
+ });
96
+ it('high GFI approves (currentGfi >= highGfi)', () => {
97
+ const d = evaluatePainDiagnosticGateDecision(makeInput({ source: 'tool_failure', currentGfi: 100 }));
98
+ expect(d.shouldDiagnose).toBe(true);
99
+ expect(d.reason).toBe('high_gfi');
100
+ });
101
+ it('nothing triggers → below_gate', () => {
102
+ const d = evaluatePainDiagnosticGateDecision(makeInput({ source: 'tool_failure', score: 0, currentGfi: 0 }));
103
+ expect(d.shouldDiagnose).toBe(false);
104
+ expect(d.reason).toBe('below_gate');
105
+ expect(d.detail).toContain('score=0');
106
+ });
107
+ });
108
+ describe('evaluatePainDiagnosticGateDecision: input hardening', () => {
109
+ it('NaN score treated as 0', () => {
110
+ const d = evaluatePainDiagnosticGateDecision(makeInput({ source: 'subagent_error', score: Number.NaN }));
111
+ expect(d.reason).toBe('below_gate');
112
+ expect(d.detail).toContain('score=0');
113
+ });
114
+ it('NaN currentGfi treated as 0', () => {
115
+ const d = evaluatePainDiagnosticGateDecision(makeInput({ source: 'tool_failure', currentGfi: Number.NaN }));
116
+ expect(d.reason).toBe('below_gate');
117
+ });
118
+ it('NaN consecutiveErrors treated as 0', () => {
119
+ const d = evaluatePainDiagnosticGateDecision(makeInput({ source: 'tool_failure', consecutiveErrors: Number.NaN }));
120
+ expect(d.reason).toBe('below_gate');
121
+ });
122
+ });
123
+ describe('evaluatePainDiagnosticGateDecision: cooldown', () => {
124
+ it('within cooldown returns shouldDiagnose=false with reason cooldown', () => {
125
+ const nowMs = 10_000;
126
+ const last = 9_000; // 1000ms ago, well within 15min default
127
+ const d = evaluatePainDiagnosticGateDecision(makeInput({ source: 'manual', nowMs }), last);
128
+ expect(d.shouldDiagnose).toBe(false);
129
+ expect(d.reason).toBe('cooldown');
130
+ expect(d.detail).toContain('recently diagnosed');
131
+ });
132
+ it('outside cooldown approves and the caller should record nowMs', () => {
133
+ const nowMs = 10_000_000;
134
+ const last = 0; // very old
135
+ const d = evaluatePainDiagnosticGateDecision(makeInput({ source: 'manual', nowMs }), last);
136
+ expect(d.shouldDiagnose).toBe(true);
137
+ expect(d.reason).toBe('manual');
138
+ });
139
+ it('cooldownMs <= 0 disables cooldown entirely', () => {
140
+ const nowMs = 10_000;
141
+ const last = 9_999; // 1ms ago
142
+ const d = evaluatePainDiagnosticGateDecision(makeInput({ source: 'manual', nowMs, cooldownMs: 0 }), last);
143
+ expect(d.shouldDiagnose).toBe(true);
144
+ expect(d.reason).toBe('manual');
145
+ });
146
+ it('never-diagnosed episode (last undefined) is never in cooldown', () => {
147
+ const d = evaluatePainDiagnosticGateDecision(makeInput({ source: 'manual' }), undefined);
148
+ expect(d.shouldDiagnose).toBe(true);
149
+ });
150
+ });
151
+ describe('isCooldownActive', () => {
152
+ it('true when within window', () => {
153
+ expect(isCooldownActive({ source: 'manual', sessionId: 's', errorHash: 'h', nowMs: 10_000, lastDiagnosedAtMs: 9_000 })).toBe(true);
154
+ });
155
+ it('false when outside window', () => {
156
+ expect(isCooldownActive({ source: 'manual', sessionId: 's', errorHash: 'h', nowMs: 10_000_000, lastDiagnosedAtMs: 0 })).toBe(false);
157
+ });
158
+ it('false when never diagnosed (last undefined)', () => {
159
+ expect(isCooldownActive({ source: 'manual', sessionId: 's', errorHash: 'h', nowMs: 10_000 })).toBe(false);
160
+ });
161
+ it('false when cooldownMs <= 0', () => {
162
+ expect(isCooldownActive({ source: 'manual', sessionId: 's', errorHash: 'h', cooldownMs: 0, nowMs: 10_000, lastDiagnosedAtMs: 9_999 })).toBe(false);
163
+ });
164
+ });
165
+ describe('default thresholds (migrated constants)', () => {
166
+ it('DEFAULT_COOLDOWN_MS is 15 minutes', () => {
167
+ expect(DEFAULT_COOLDOWN_MS).toBe(15 * 60 * 1000);
168
+ });
169
+ it('DEFAULT_PAIN_TRIGGER is 40', () => {
170
+ expect(DEFAULT_PAIN_TRIGGER).toBe(40);
171
+ });
172
+ it('DEFAULT_HIGH_SEVERITY is 70', () => {
173
+ expect(DEFAULT_HIGH_SEVERITY).toBe(70);
174
+ });
175
+ it('DEFAULT_REPEATED_FAILURE is 4', () => {
176
+ expect(DEFAULT_REPEATED_FAILURE).toBe(4);
177
+ });
178
+ });
179
+ //# sourceMappingURL=pain-diagnostic-gate-policy.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pain-diagnostic-gate-policy.test.js","sourceRoot":"","sources":["../../../../src/runtime-v2/pain-gate/__tests__/pain-diagnostic-gate-policy.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,kCAAkC,EAClC,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,GAEzB,MAAM,mCAAmC,CAAC;AAE3C,SAAS,SAAS,CAAC,YAA8C,EAAE;IACjE,OAAO;QACL,MAAM,EAAE,cAAc;QACtB,KAAK,EAAE,CAAC;QACR,UAAU,EAAE,CAAC;QACb,KAAK,EAAE,SAAS;QAChB,GAAG,SAAS;KACb,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACnE,MAAM,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjE,CA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-diagnostic gate decision logic (cooldown + threshold tree).
5
+ * No I/O, no plugin imports. The plugin adapter owns the cooldown Map and
6
+ * injects time/state into these pure functions.
7
+ */
8
+ export type { PainDiagnosticSource, PainDiagnosticGateReason, PainDiagnosticGateInput, PainDiagnosticGateDecision, CooldownCheckInput, } from './pain-diagnostic-gate-policy.js';
9
+ export { DEFAULT_COOLDOWN_MS, DEFAULT_PAIN_TRIGGER, DEFAULT_HIGH_SEVERITY, DEFAULT_REPEATED_FAILURE, DEFAULT_SEMANTIC_PAIN_FLOOR, normalizedSource, buildEpisodeKey, evaluatePainDiagnosticGateDecision, isCooldownActive, } from './pain-diagnostic-gate-policy.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/pain-gate/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EACV,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,EACxB,2BAA2B,EAC3B,gBAAgB,EAChB,eAAe,EACf,kCAAkC,EAClC,gBAAgB,GACjB,MAAM,kCAAkC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Pain Gate — PRI-446
3
+ *
4
+ * Pure pain-diagnostic gate decision logic (cooldown + threshold tree).
5
+ * No I/O, no plugin imports. The plugin adapter owns the cooldown Map and
6
+ * injects time/state into these pure functions.
7
+ */
8
+ export { DEFAULT_COOLDOWN_MS, DEFAULT_PAIN_TRIGGER, DEFAULT_HIGH_SEVERITY, DEFAULT_REPEATED_FAILURE, DEFAULT_SEMANTIC_PAIN_FLOOR, normalizedSource, buildEpisodeKey, evaluatePainDiagnosticGateDecision, isCooldownActive, } from './pain-diagnostic-gate-policy.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime-v2/pain-gate/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,EACxB,2BAA2B,EAC3B,gBAAgB,EAChB,eAAe,EACf,kCAAkC,EAClC,gBAAgB,GACjB,MAAM,kCAAkC,CAAC"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Pain Diagnostic Gate Policy — PRI-446 (migrated from the plugin adapter)
3
+ *
4
+ * @deprecated PRI-454 — Gate A (PainDiagnosticGate) is superseded by Gate B
5
+ * (TriggerController + EvidenceTriage). This module remains as the rollback
6
+ * path when `painEvidenceAdmission` or `painEvidenceAdmissionDefault` flags
7
+ * are OFF. Do not add new callers. New admission logic must use
8
+ * `evaluateTriggerController` from runtime-v2/evidence-triage.
9
+ *
10
+ * Disposition: Archive (do not delete) per PRI-454 plan step 6.
11
+ * Removal conditions: Both flags confirmed ON in production for 30 days,
12
+ * and all 5 MVP paths verified on Gate B. See
13
+ * docs/plans/2026-06-pain-evidence-admission-track.md.
14
+ *
15
+ * Pure decision logic for pain-diagnostic cooldown and gate evaluation.
16
+ *
17
+ * This module is the single source of truth for the gate's threshold decision
18
+ * tree. It is fully pure: no I/O, no Date.now(), no module-level mutable state.
19
+ * All time and cooldown state is passed in as parameters. The plugin-side
20
+ * pain-diagnostic-gate.ts is now a thin adapter that owns the cooldown Map and
21
+ * feeds Date.now() / the last-diagnosed timestamp into this function.
22
+ *
23
+ * Field precedence / thresholds are copied byte-for-byte from the prior plugin
24
+ * implementation; the plugin's pain-diagnostic-gate.test.ts (40 tests) passes
25
+ * unchanged through the adapter as the equivalence proof.
26
+ *
27
+ * ERR checklist:
28
+ * - ERR-001: inputs validated with Number.isFinite, not `as` casts.
29
+ * - ERR-002: every decision carries reason + detail.
30
+ * - EP-01: source string normalized with a Set membership check.
31
+ */
32
+ /** Default cooldown window: 15 minutes. */
33
+ export declare const DEFAULT_COOLDOWN_MS: number;
34
+ /** Default pain-trigger threshold. */
35
+ export declare const DEFAULT_PAIN_TRIGGER = 40;
36
+ /** Default high-severity threshold (risky high-score). */
37
+ export declare const DEFAULT_HIGH_SEVERITY = 70;
38
+ /** Default repeated-failure threshold (consecutive errors). */
39
+ export declare const DEFAULT_REPEATED_FAILURE = 4;
40
+ /** Default semantic-pain floor. */
41
+ export declare const DEFAULT_SEMANTIC_PAIN_FLOOR = 60;
42
+ declare const PAIN_DIAGNOSTIC_SOURCES: readonly ["manual", "tool_failure", "dispatch_error", "gate_blocked", "user_empathy", "llm_paralysis", "semantic", "subagent_error"];
43
+ export type PainDiagnosticSource = typeof PAIN_DIAGNOSTIC_SOURCES[number];
44
+ export type PainDiagnosticGateReason = 'manual' | 'high_gfi' | 'repeated_failure' | 'semantic_pain' | 'llm_paralysis' | 'risky_high_score' | 'subagent_error' | 'gate_blocked' | 'cooldown' | 'below_gate';
45
+ export interface PainDiagnosticGateInput {
46
+ source: PainDiagnosticSource | string;
47
+ score: number;
48
+ currentGfi: number;
49
+ consecutiveErrors?: number;
50
+ isRisky?: boolean;
51
+ errorHash?: string;
52
+ sessionId?: string;
53
+ nowMs?: number;
54
+ cooldownMs?: number;
55
+ thresholds?: {
56
+ painTrigger?: number;
57
+ highSeverity?: number;
58
+ highGfi?: number;
59
+ repeatedFailure?: number;
60
+ semanticPain?: number;
61
+ };
62
+ }
63
+ export interface PainDiagnosticGateDecision {
64
+ shouldDiagnose: boolean;
65
+ reason: PainDiagnosticGateReason;
66
+ episodeKey: string;
67
+ detail: string;
68
+ }
69
+ /**
70
+ * Normalize a raw source string to a known PainDiagnosticSource.
71
+ *
72
+ * Unknown sources are passed through unchanged (the caller may still match them
73
+ * against custom thresholds) but flagged via the returned `unknown` flag so the
74
+ * plugin adapter can log it. Core itself does not log.
75
+ */
76
+ export declare function normalizedSource(source: string): {
77
+ source: PainDiagnosticSource | string;
78
+ unknown: boolean;
79
+ };
80
+ /**
81
+ * Build the episode key that scopes cooldown to a (session, source, hash) triple.
82
+ */
83
+ export declare function buildEpisodeKey(input: PainDiagnosticGateInput): string;
84
+ /**
85
+ * Evaluate the pure gate decision.
86
+ *
87
+ * @param input - gate input (time in nowMs is the caller's responsibility)
88
+ * @param lastDiagnosedAtMs - the last time this episode was diagnosed, or undefined
89
+ * if never. Provided by the plugin adapter which owns the cooldown Map.
90
+ * @returns the gate decision. If shouldDiagnose is true, the caller MUST record
91
+ * nowMs against this episode (the plugin adapter does this in markDiagnosed).
92
+ *
93
+ * Note on the "unknown source" side effect: the prior plugin implementation
94
+ * logged unknown sources via SystemLogger. Core cannot log, so it surfaces the
95
+ * unknown flag through normalizedSource; the plugin adapter is responsible for
96
+ * logging when it observes an unknown source before calling this function.
97
+ */
98
+ export declare function evaluatePainDiagnosticGateDecision(input: PainDiagnosticGateInput, lastDiagnosedAtMs?: number): PainDiagnosticGateDecision;
99
+ /**
100
+ * Pure cooldown check for an episode.
101
+ *
102
+ * Used by the trigger controller (PEAT-B2) and re-exported by the plugin adapter
103
+ * as isCooldownActiveForEpisode so its cooldown decision aligns with the gate.
104
+ */
105
+ export interface CooldownCheckInput {
106
+ /** Source string used to build the episode key. */
107
+ readonly source: string;
108
+ /** Session id used to build the episode key. */
109
+ readonly sessionId?: string;
110
+ /** Error hash used to build the episode key. */
111
+ readonly errorHash?: string;
112
+ /** Cooldown window in ms. Falls back to DEFAULT_COOLDOWN_MS when undefined. */
113
+ readonly cooldownMs?: number;
114
+ /** Current time in ms (caller-injected; core has no clock). */
115
+ readonly nowMs: number;
116
+ /** Last time this episode was diagnosed, or undefined if never. */
117
+ readonly lastDiagnosedAtMs?: number;
118
+ }
119
+ export declare function isCooldownActive(input: CooldownCheckInput): boolean;
120
+ export {};
121
+ //# sourceMappingURL=pain-diagnostic-gate-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pain-diagnostic-gate-policy.d.ts","sour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MAAM,WAAW,0BAA0B;IACzC,cAAc,EAAE,OAAO,CAAC;IACxB,MAAM,EAAE,wBAAwB,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAID;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,oBAAoB,GAAG,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAM5G;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,uBAAuB,GAAG,MAAM,CAKtE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,uBAAuB,EAC9B,iBAAiB,CAAC,EAAE,MAAM,GACzB,0BAA0B,CAoE5B;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,mDAAmD;IACnD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,gDAAgD;IAChD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,+EAA+E;IAC/E,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,+DAA+D;IAC/D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,mEAAmE;IACnE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACrC;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAKnE"}
@@ -0,0 +1,157 @@
1
+ /**
2
+ * Pain Diagnostic Gate Policy — PRI-446 (migrated from the plugin adapter)
3
+ *
4
+ * @deprecated PRI-454 — Gate A (PainDiagnosticGate) is superseded by Gate B
5
+ * (TriggerController + EvidenceTriage). This module remains as the rollback
6
+ * path when `painEvidenceAdmission` or `painEvidenceAdmissionDefault` flags
7
+ * are OFF. Do not add new callers. New admission logic must use
8
+ * `evaluateTriggerController` from runtime-v2/evidence-triage.
9
+ *
10
+ * Disposition: Archive (do not delete) per PRI-454 plan step 6.
11
+ * Removal conditions: Both flags confirmed ON in production for 30 days,
12
+ * and all 5 MVP paths verified on Gate B. See
13
+ * docs/plans/2026-06-pain-evidence-admission-track.md.
14
+ *
15
+ * Pure decision logic for pain-diagnostic cooldown and gate evaluation.
16
+ *
17
+ * This module is the single source of truth for the gate's threshold decision
18
+ * tree. It is fully pure: no I/O, no Date.now(), no module-level mutable state.
19
+ * All time and cooldown state is passed in as parameters. The plugin-side
20
+ * pain-diagnostic-gate.ts is now a thin adapter that owns the cooldown Map and
21
+ * feeds Date.now() / the last-diagnosed timestamp into this function.
22
+ *
23
+ * Field precedence / thresholds are copied byte-for-byte from the prior plugin
24
+ * implementation; the plugin's pain-diagnostic-gate.test.ts (40 tests) passes
25
+ * unchanged through the adapter as the equivalence proof.
26
+ *
27
+ * ERR checklist:
28
+ * - ERR-001: inputs validated with Number.isFinite, not `as` casts.
29
+ * - ERR-002: every decision carries reason + detail.
30
+ * - EP-01: source string normalized with a Set membership check.
31
+ */
32
+ // ── Defaults (migrated verbatim; previously inline magic numbers) ──────────
33
+ /** Default cooldown window: 15 minutes. */
34
+ export const DEFAULT_COOLDOWN_MS = 15 * 60 * 1000;
35
+ /** Default pain-trigger threshold. */
36
+ export const DEFAULT_PAIN_TRIGGER = 40;
37
+ /** Default high-severity threshold (risky high-score). */
38
+ export const DEFAULT_HIGH_SEVERITY = 70;
39
+ /** Default repeated-failure threshold (consecutive errors). */
40
+ export const DEFAULT_REPEATED_FAILURE = 4;
41
+ /** Default semantic-pain floor. */
42
+ export const DEFAULT_SEMANTIC_PAIN_FLOOR = 60;
43
+ const PAIN_DIAGNOSTIC_SOURCES = [
44
+ 'manual',
45
+ 'tool_failure',
46
+ 'dispatch_error',
47
+ 'gate_blocked',
48
+ 'user_empathy',
49
+ 'llm_paralysis',
50
+ 'semantic',
51
+ 'subagent_error',
52
+ ];
53
+ // ── Pure helpers ────────────────────────────────────────────────────────────
54
+ /**
55
+ * Normalize a raw source string to a known PainDiagnosticSource.
56
+ *
57
+ * Unknown sources are passed through unchanged (the caller may still match them
58
+ * against custom thresholds) but flagged via the returned `unknown` flag so the
59
+ * plugin adapter can log it. Core itself does not log.
60
+ */
61
+ export function normalizedSource(source) {
62
+ if (source.startsWith('llm_') && source !== 'llm_paralysis') {
63
+ return { source: 'semantic', unknown: false };
64
+ }
65
+ const isKnown = PAIN_DIAGNOSTIC_SOURCES.includes(source);
66
+ return { source, unknown: !isKnown };
67
+ }
68
+ /**
69
+ * Build the episode key that scopes cooldown to a (session, source, hash) triple.
70
+ */
71
+ export function buildEpisodeKey(input) {
72
+ const { source } = normalizedSource(input.source);
73
+ const sessionId = input.sessionId || 'unknown';
74
+ const hash = input.errorHash || 'no-hash';
75
+ return `${sessionId}:${source}:${hash}`;
76
+ }
77
+ /**
78
+ * Evaluate the pure gate decision.
79
+ *
80
+ * @param input - gate input (time in nowMs is the caller's responsibility)
81
+ * @param lastDiagnosedAtMs - the last time this episode was diagnosed, or undefined
82
+ * if never. Provided by the plugin adapter which owns the cooldown Map.
83
+ * @returns the gate decision. If shouldDiagnose is true, the caller MUST record
84
+ * nowMs against this episode (the plugin adapter does this in markDiagnosed).
85
+ *
86
+ * Note on the "unknown source" side effect: the prior plugin implementation
87
+ * logged unknown sources via SystemLogger. Core cannot log, so it surfaces the
88
+ * unknown flag through normalizedSource; the plugin adapter is responsible for
89
+ * logging when it observes an unknown source before calling this function.
90
+ */
91
+ export function evaluatePainDiagnosticGateDecision(input, lastDiagnosedAtMs) {
92
+ const { source } = normalizedSource(input.source);
93
+ const episodeKey = buildEpisodeKey(input);
94
+ const painTrigger = input.thresholds?.painTrigger ?? DEFAULT_PAIN_TRIGGER;
95
+ const highSeverity = input.thresholds?.highSeverity ?? DEFAULT_HIGH_SEVERITY;
96
+ const highGfi = input.thresholds?.highGfi ?? Math.max(highSeverity, painTrigger + 30);
97
+ const repeatedFailure = input.thresholds?.repeatedFailure ?? DEFAULT_REPEATED_FAILURE;
98
+ const semanticPain = input.thresholds?.semanticPain ?? Math.max(painTrigger, DEFAULT_SEMANTIC_PAIN_FLOOR);
99
+ const score = Number.isFinite(input.score) ? input.score : 0;
100
+ const currentGfi = Number.isFinite(input.currentGfi) ? input.currentGfi : 0;
101
+ const consecutiveErrors = typeof input.consecutiveErrors === 'number' && Number.isFinite(input.consecutiveErrors)
102
+ ? input.consecutiveErrors
103
+ : 0;
104
+ const cooldownMs = input.cooldownMs ?? DEFAULT_COOLDOWN_MS;
105
+ const nowMs = input.nowMs ?? 0;
106
+ const withinCooldown = cooldownMs > 0 && lastDiagnosedAtMs !== undefined && nowMs - lastDiagnosedAtMs < cooldownMs;
107
+ const approve = (reason, detail) => {
108
+ if (withinCooldown) {
109
+ return {
110
+ shouldDiagnose: false,
111
+ reason: 'cooldown',
112
+ episodeKey,
113
+ detail: `recently diagnosed; ${detail}`,
114
+ };
115
+ }
116
+ return { shouldDiagnose: true, reason, episodeKey, detail };
117
+ };
118
+ if (source === 'manual') {
119
+ return approve('manual', 'manual pain signal bypasses automatic gate');
120
+ }
121
+ if (source === 'subagent_error' && score >= painTrigger) {
122
+ return approve('subagent_error', `subagent error score ${score} >= ${painTrigger}`);
123
+ }
124
+ if (source === 'llm_paralysis' && score >= painTrigger) {
125
+ return approve('llm_paralysis', `llm paralysis score ${score} >= ${painTrigger}`);
126
+ }
127
+ if (source === 'gate_blocked' && score >= painTrigger) {
128
+ return approve('gate_blocked', `gate blocked score ${score} >= ${painTrigger}`);
129
+ }
130
+ if ((source === 'user_empathy' || source === 'semantic') && score >= semanticPain) {
131
+ return approve('semantic_pain', `semantic pain score ${score} >= ${semanticPain}`);
132
+ }
133
+ if (input.isRisky === true && score >= highSeverity) {
134
+ return approve('risky_high_score', `risky operation score ${score} >= ${highSeverity}`);
135
+ }
136
+ if (consecutiveErrors >= repeatedFailure) {
137
+ return approve('repeated_failure', `consecutive errors ${consecutiveErrors} >= ${repeatedFailure}`);
138
+ }
139
+ if (currentGfi >= highGfi) {
140
+ return approve('high_gfi', `GFI ${currentGfi.toFixed(1)} >= ${highGfi}`);
141
+ }
142
+ return {
143
+ shouldDiagnose: false,
144
+ reason: 'below_gate',
145
+ episodeKey,
146
+ detail: `score=${score}; gfi=${currentGfi.toFixed(1)}; consecutive=${consecutiveErrors}`,
147
+ };
148
+ }
149
+ export function isCooldownActive(input) {
150
+ const effectiveCooldown = input.cooldownMs ?? DEFAULT_COOLDOWN_MS;
151
+ if (effectiveCooldown <= 0)
152
+ return false;
153
+ if (input.lastDiagnosedAtMs === undefined)
154
+ return false;
155
+ return input.nowMs - input.lastDiagnosedAtMs < effectiveCooldown;
156
+ }
157
+ //# sourceMappingURL=pain-diagnostic-gate-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pain-diagnostic-gate-policy.js","sourceRoot":"","sources":["../../../src/runtime-v2/pain-gate/pain-diagnostic-gate-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,8EAA8E;AAE9E,2CAA2C;AAC3C,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAClD,sCAAsC;AACtC,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AACvC,0DAA0D;AAC1D,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACxC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAC1C,mCAAmC;AACnC,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AAE9C,MAAM,uBAAuB,GAAG;IAC9B,QAAQ;IACR,cAAc;IACd,gBAAgB;IAChB,cAAc;IACd,cAAc;IACd,eAAe;IACf,UAAU;IACV,gBAAgB;CACR,CAAC;AA0CX,+EAA+E;AAE/E;;;;;;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