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
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Derive the final PainSignalBridgeResult from computed inputs.
3
+ *
4
+ * Byte-for-byte identical to the original inline logic in both call sites.
5
+ * The `path` discriminator selects the appropriate message strings and
6
+ * decision branches.
7
+ */
8
+ export function shapeBridgeResult(input) {
9
+ const { painId, taskId, candidateIds, ledgerEntryIds, runId, artifactId, autoIntakeEnabled } = input;
10
+ // Common: no candidates → failed (message differs by path)
11
+ if (candidateIds.length === 0) {
12
+ if (input.path === 'fresh') {
13
+ return {
14
+ status: 'failed',
15
+ painId,
16
+ taskId,
17
+ runId,
18
+ candidateIds,
19
+ ledgerEntryIds,
20
+ admissionResults: input.admissionResults,
21
+ message: 'Diagnostician succeeded but produced no principle candidates',
22
+ };
23
+ }
24
+ return {
25
+ status: 'failed',
26
+ painId,
27
+ taskId,
28
+ runId,
29
+ candidateIds,
30
+ ledgerEntryIds,
31
+ message: 'Task has no principle candidates — treating as failed',
32
+ };
33
+ }
34
+ if (input.path === 'fresh') {
35
+ const { admissionResults, seedFailureNote } = input;
36
+ const admittedCount = admissionResults.filter((a) => a.admission.decision === 'admitted').length;
37
+ const nonAdmittedCount = admissionResults.length - admittedCount;
38
+ // Admitted candidates exist but intake produced no ledger entries
39
+ if (autoIntakeEnabled && admittedCount > 0 && ledgerEntryIds.length === 0) {
40
+ return {
41
+ status: 'failed',
42
+ painId,
43
+ taskId,
44
+ runId,
45
+ artifactId,
46
+ candidateIds,
47
+ ledgerEntryIds,
48
+ admissionResults,
49
+ message: 'Candidate intake did not produce a ledger entry',
50
+ };
51
+ }
52
+ // All candidates gated (none admitted)
53
+ if (nonAdmittedCount > 0 && admittedCount === 0) {
54
+ return {
55
+ status: 'degraded',
56
+ painId,
57
+ taskId,
58
+ runId,
59
+ artifactId,
60
+ candidateIds,
61
+ ledgerEntryIds,
62
+ admissionResults,
63
+ message: `all_candidates_gated:${admissionResults.map((a) => `${a.candidateId}=${a.admission.decision}`).join(',')}${seedFailureNote ? `; ${seedFailureNote}` : ''}`,
64
+ };
65
+ }
66
+ // Partial admission (some admitted, some gated)
67
+ if (nonAdmittedCount > 0 && admittedCount > 0) {
68
+ return {
69
+ status: 'degraded',
70
+ painId,
71
+ taskId,
72
+ runId,
73
+ artifactId,
74
+ candidateIds,
75
+ ledgerEntryIds,
76
+ admissionResults,
77
+ message: `partial_admission:${admittedCount}_admitted_${nonAdmittedCount}_gated${seedFailureNote ? `; ${seedFailureNote}` : ''}`,
78
+ };
79
+ }
80
+ // Success (or degraded if seed failure occurred)
81
+ return {
82
+ status: seedFailureNote ? 'degraded' : 'succeeded',
83
+ painId,
84
+ taskId,
85
+ runId,
86
+ artifactId,
87
+ candidateIds,
88
+ ledgerEntryIds,
89
+ admissionResults,
90
+ message: seedFailureNote || undefined,
91
+ };
92
+ }
93
+ // Existing path: no admission results, simpler decision tree
94
+ if (autoIntakeEnabled && ledgerEntryIds.length === 0) {
95
+ return {
96
+ status: 'failed',
97
+ painId,
98
+ taskId,
99
+ runId,
100
+ artifactId,
101
+ candidateIds,
102
+ ledgerEntryIds,
103
+ message: 'Candidate intake did not produce a ledger entry — treating as failed',
104
+ };
105
+ }
106
+ return {
107
+ status: 'succeeded',
108
+ painId,
109
+ taskId,
110
+ runId,
111
+ artifactId,
112
+ candidateIds,
113
+ ledgerEntryIds,
114
+ message: 'Task already succeeded',
115
+ };
116
+ }
117
+ //# sourceMappingURL=bridge-result-shaper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge-result-shaper.js","sourceRoot":"","sources":["../../src/runtime-v2/bridge-result-shaper.ts"],"names":[],"mappings":"AAkDA;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,KAAK,CAAC;IAErG,2DAA2D;IAC3D,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC3B,OAAO;gBACL,MAAM,EAAE,QAAQ;gBAChB,MAAM;gBACN,MAAM;gBACN,KAAK;gBACL,YAAY;gBACZ,cAAc;gBACd,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;gBACxC,OAAO,EAAE,8DAA8D;aACxE,CAAC;QACJ,CAAC;QACD,OAAO;YACL,MAAM,EAAE,QAAQ;YAChB,MAAM;YACN,MAAM;YACN,KAAK;YACL,YAAY;YACZ,cAAc;YACd,OAAO,EAAE,uDAAuD;SACjE,CAAC;IACJ,CAAC;IAED,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC3B,MAAM,EAAE,gBAAgB,EAAE,eAAe,EAAE,GAAG,KAAK,CAAC;QACpD,MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,MAAM,CAAC;QACjG,M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MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW;YAClD,MAAM;YACN,MAAM;YACN,KAAK;YACL,UAAU;YACV,YAAY;YACZ,cAAc;YACd,gBAAgB;YAChB,OAAO,EAAE,eAAe,IAAI,SAAS;SACtC,CAAC;IACJ,CAAC;IAED,6DAA6D;IAC7D,IAAI,iBAAiB,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrD,OAAO;YACL,MAAM,EAAE,QAAQ;YAChB,MAAM;YACN,MAAM;YACN,KAAK;YACL,UAAU;YACV,YAAY;YACZ,cAAc;YACd,OAAO,EAAE,sEAAsE;SAChF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,MAAM,EAAE,WAAW;QACnB,MAAM;QACN,MAAM;QACN,KAAK;QACL,UAAU;QACV,YAAY;QACZ,cAAc;QACd,OAAO,EAAE,wBAAwB;KAClC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Detection Funnel Policy Tests — PRI-446
3
+ *
4
+ * Tests the pure core DetectionFunnelCore directly with injected stubs for
5
+ * matcher/hasher/gate (no crypto, no dictionary). The plugin's
6
+ * detection-funnel-characterization.test.ts (10 tests) exercises the same logic
7
+ * through the wired adapter; this file gives core its own direct coverage.
8
+ *
9
+ * ERR checklist:
10
+ * - ERR-025: tests the real DetectionFunnelCore path.
11
+ */
12
+ export {};
13
+ //# sourceMappingURL=detection-funnel-policy.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detection-funnel-policy.test.d.ts","sourceRoot":"","sources":["../../../../src/runtime-v2/detection/__tests__/detection-funnel-policy.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Detection Funnel Policy Tests — PRI-446
3
+ *
4
+ * Tests the pure core DetectionFunnelCore directly with injected stubs for
5
+ * matcher/hasher/gate (no crypto, no dictionary). The plugin's
6
+ * detection-funnel-characterization.test.ts (10 tests) exercises the same logic
7
+ * through the wired adapter; this file gives core its own direct coverage.
8
+ *
9
+ * ERR checklist:
10
+ * - ERR-025: tests the real DetectionFunnelCore path.
11
+ */
12
+ import { describe, it, expect } from 'vitest';
13
+ import { DetectionFunnelCore, SimpleLRU, } from '../detection-funnel-policy.js';
14
+ function makeConfig(overrides = {}) {
15
+ return {
16
+ match: () => undefined,
17
+ hash: (t) => `hash:${t}`,
18
+ shouldIgnoreProtocol: () => false,
19
+ ...overrides,
20
+ };
21
+ }
22
+ describe('DetectionFunnelCore: L1 exact', () => {
23
+ it('returns l1_exact with ruleId+severity on match', () => {
24
+ const funnel = new DetectionFunnelCore(makeConfig({
25
+ match: (t) => (t === 'i am confused' ? { ruleId: 'P_CONFUSION_EN', severity: 35 } : undefined),
26
+ }));
27
+ const r = funnel.detect('i am confused');
28
+ expect(r).toEqual({ detected: true, severity: 35, ruleId: 'P_CONFUSION_EN', source: 'l1_exact' });
29
+ });
30
+ it('protocol token gate short-circuits before L1', () => {
31
+ const funnel = new DetectionFunnelCore(makeConfig({
32
+ match: () => ({ ruleId: 'X', severity: 10 }),
33
+ shouldIgnoreProtocol: (t) => t === 'HEARTBEAT_OK',
34
+ }));
35
+ const r = funnel.detect('HEARTBEAT_OK');
36
+ expect(r).toEqual({ detected: false, source: 'l1_exact' });
37
+ });
38
+ });
39
+ describe('DetectionFunnelCore: L3 async queue', () => {
40
+ it('no match + no cache → l3_async_queued', () => {
41
+ const funnel = new DetectionFunnelCore(makeConfig());
42
+ expect(funnel.detect('unseen')).toEqual({ detected: false, source: 'l3_async_queued' });
43
+ });
44
+ it('flushQueue returns queued texts and clears', () => {
45
+ const funnel = new DetectionFunnelCore(makeConfig());
46
+ funnel.detect('a');
47
+ funnel.detect('b');
48
+ expect(funnel.flushQueue()).toEqual(['a', 'b']);
49
+ expect(funnel.flushQueue()).toEqual([]);
50
+ });
51
+ });
52
+ describe('DetectionFunnelCore: L2 cache', () => {
53
+ it('updateCache then detect returns l2_cache with stored result', () => {
54
+ const funnel = new DetectionFunnelCore(makeConfig());
55
+ funnel.updateCache('text', { detected: true, severity: 72 });
56
+ const r = funnel.detect('text');
57
+ expect(r.source).toBe('l2_cache');
58
+ expect(r).toMatchObject({ detected: true, severity: 72 });
59
+ });
60
+ it('L1 takes precedence over a poisoned L2 cache', () => {
61
+ const funnel = new DetectionFunnelCore(makeConfig({
62
+ match: (t) => (t === 'x' ? { ruleId: 'R', severity: 35 } : undefined),
63
+ }));
64
+ funnel.updateCache('x', { detected: false });
65
+ const r = funnel.detect('x');
66
+ expect(r.source).toBe('l1_exact');
67
+ expect(r.detected).toBe(true);
68
+ });
69
+ });
70
+ describe('DetectionFunnelCore: LRU eviction', () => {
71
+ it('evicts oldest beyond capacity', () => {
72
+ const funnel = new DetectionFunnelCore(makeConfig({ cacheSize: 2 }));
73
+ funnel.updateCache('a', { detected: true });
74
+ funnel.updateCache('b', { detected: true });
75
+ funnel.updateCache('c', { detected: true }); // evicts 'a'
76
+ expect(funnel.detect('a').source).toBe('l3_async_queued');
77
+ expect(funnel.detect('c').source).toBe('l2_cache');
78
+ });
79
+ it('refreshes LRU position on get', () => {
80
+ const funnel = new DetectionFunnelCore(makeConfig({ cacheSize: 2 }));
81
+ funnel.updateCache('a', { detected: true });
82
+ funnel.updateCache('b', { detected: true });
83
+ funnel.detect('a'); // refresh 'a' -> now 'b' is oldest
84
+ funnel.updateCache('c', { detected: true }); // evicts 'b'
85
+ expect(funnel.detect('a').source).toBe('l2_cache');
86
+ expect(funnel.detect('b').source).toBe('l3_async_queued');
87
+ });
88
+ });
89
+ describe('DetectionFunnelCore: queue capacity', () => {
90
+ it('bounds the queue at queueCapacity', () => {
91
+ const funnel = new DetectionFunnelCore(makeConfig({ queueCapacity: 2 }));
92
+ funnel.detect('a');
93
+ funnel.detect('b');
94
+ funnel.detect('c'); // exceeds capacity, dropped
95
+ expect(funnel.flushQueue()).toEqual(['a', 'b']);
96
+ });
97
+ });
98
+ describe('SimpleLRU', () => {
99
+ it('get returns undefined for missing key', () => {
100
+ const lru = new SimpleLRU(10);
101
+ expect(lru.get('missing')).toBeUndefined();
102
+ });
103
+ it('default capacity is 100', () => {
104
+ const lru = new SimpleLRU();
105
+ for (let i = 0; i < 150; i++)
106
+ lru.set(`k${i}`, i);
107
+ expect(lru.get('k0')).toBeUndefined(); // evicted
108
+ expect(lru.get('k149')).toBe(149);
109
+ });
110
+ });
111
+ //# sourceMappingURL=detection-funnel-policy.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detection-funnel-policy.test.js","sourceRoot":"","sources":["../../../../src/runtime-v2/detection/__tests__/detection-funnel-policy.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,mBAAmB,EACnB,SAAS,GAEV,MAAM,+BAA+B,CAAC;AAEvC,SAAS,UAAU,CAAC,YAA4C,EAAE;IAChE,OAAO;QACL,KAAK,EAAE,GAAG,EAAE,CAAC,SAAS;QACtB,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE;QACxB,oBAAoB,EAAE,GAAG,EAAE,CAAC,KAAK;QACjC,GAAG,SAAS;KACb,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;IAC7C,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,MAAM,MAAM,GAAG,IAAI,mBAAmB,CAAC,UAAU,CAAC;YAChD,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,eAAe,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;SAC/F,CAAC,CAAC,CAAC;QACJ,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM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C,CAAC,aAAa,EAAE,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACjC,MAAM,GAAG,GAAG,IAAI,SAAS,EAAkB,CAAC;QAC5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE;YAAE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAClD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,UAAU;QACjD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Detection Funnel Policy — PRI-446 (migrated from the plugin adapter)
3
+ *
4
+ * Pure three-layer detection funnel logic:
5
+ * L1 — exact dictionary match (sync, delegated via injected matchFn)
6
+ * L2 — LRU cache of prior L3 resolutions (sync)
7
+ * L3 — async semantic queue (caller drains via flushQueue + updateCache)
8
+ *
9
+ * This module is fully pure: no I/O, no crypto, no plugin imports. The two
10
+ * environment-coupled dependencies — the dictionary matcher and the text hasher —
11
+ * are injected, so core owns the funnel *logic* while the plugin owns the
12
+ * concrete crypto.createHash and the PainDictionary.
13
+ *
14
+ * The plugin-side detection-funnel.ts is now a thin shell that wires
15
+ * DetectionFunnelCore with crypto + dictionary and re-exports the DetectionFunnel
16
+ * name, so DetectionService and evolution-worker keep working unchanged.
17
+ *
18
+ * ERR checklist:
19
+ * - ERR-001: no `as` casts; cache reads validated.
20
+ * - ERR-002: results carry structured source + severity.
21
+ * - EP-01: queue is bounded.
22
+ */
23
+ export interface DetectionResult {
24
+ detected: boolean;
25
+ severity?: number;
26
+ ruleId?: string;
27
+ source: 'l1_exact' | 'l2_cache' | 'l3_async_queued' | 'l3_semantic_hit';
28
+ }
29
+ /** A matched pain rule (subset of PainDictionary's match return). */
30
+ export interface PainMatchResult {
31
+ ruleId: string;
32
+ severity: number;
33
+ }
34
+ /**
35
+ * Matcher contract injected by the plugin (backed by PainDictionary).
36
+ * Returns the matched rule + severity for L1 exact matching, or undefined.
37
+ */
38
+ export type PainMatcher = (text: string) => PainMatchResult | undefined;
39
+ /**
40
+ * Hash function injected by the plugin (backed by crypto.createHash).
41
+ * Used for L2 cache keys.
42
+ */
43
+ export type TextHasher = (text: string) => string;
44
+ /**
45
+ * Predicate injected by the plugin (backed by shouldIgnorePainProtocolText).
46
+ * Returns true for protocol tokens that short-circuit before any layer.
47
+ */
48
+ export type ProtocolTokenGate = (text: string) => boolean;
49
+ /**
50
+ * A simple LRU Cache implementation using Map.
51
+ * Migrated verbatim from the prior plugin detection-funnel.ts.
52
+ */
53
+ export declare class SimpleLRU<K, V> {
54
+ private readonly cache;
55
+ private readonly maxSize;
56
+ constructor(maxSize?: number);
57
+ get(key: K): V | undefined;
58
+ set(key: K, value: V): void;
59
+ }
60
+ export interface DetectionFunnelConfig {
61
+ /** L1 exact-match delegate. */
62
+ match: PainMatcher;
63
+ /** Text hasher for L2 cache keys. */
64
+ hash: TextHasher;
65
+ /** Protocol-token gate that runs before any layer. */
66
+ shouldIgnoreProtocol: ProtocolTokenGate;
67
+ /** L2 cache capacity. Default 100. */
68
+ cacheSize?: number;
69
+ /** L3 async queue capacity. Default 1000. */
70
+ queueCapacity?: number;
71
+ }
72
+ /**
73
+ * Orchestrates the three-layer detection funnel for pain signals.
74
+ *
75
+ * Pure logic: holds only in-memory cache and queue state. All environment
76
+ * coupling (dictionary, crypto) is injected via config.
77
+ */
78
+ export declare class DetectionFunnelCore {
79
+ private readonly cache;
80
+ private asyncQueue;
81
+ private readonly match;
82
+ private readonly hash;
83
+ private readonly shouldIgnoreProtocol;
84
+ private readonly queueCapacity;
85
+ constructor(config: DetectionFunnelConfig);
86
+ /**
87
+ * Detects pain in the given text using L1 (Exact), L2 (Cache), and L3 (Async).
88
+ */
89
+ detect(text: string): DetectionResult;
90
+ private enqueueAsync;
91
+ /**
92
+ * Internal method for the worker to update the cache after a semantic hit.
93
+ */
94
+ updateCache(text: string, result: {
95
+ detected: boolean;
96
+ severity?: number;
97
+ }): void;
98
+ /**
99
+ * Retrieves and clears the current asynchronous queue.
100
+ */
101
+ flushQueue(): string[];
102
+ }
103
+ //# sourceMappingURL=detection-funnel-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detection-funnel-policy.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/detection/detection-funnel-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,GAAG,UAAU,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;CACzE;AAED,qEAAqE;AACrE,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,eAAe,GAAG,SAAS,CAAC;AAExE;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;AAElD;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;AAI1D;;;GAGG;AACH,qBAAa,SAAS,CAAC,CAAC,EAAE,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAY;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBACrB,OAAO,SAAM;IAKzB,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAU1B,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;CAY5B;AAID,MAAM,WAAW,qBAAqB;IACpC,+BAA+B;IAC/B,KAAK,EAAE,WAAW,CAAC;IACnB,qCAAqC;IACrC,IAAI,EAAE,UAAU,CAAC;IACjB,sDAAsD;IACtD,oBAAoB,EAAE,iBAAiB,CAAC;IACxC,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAID;;;;;GAKG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA8D;IACpF,OAAO,CAAC,UAAU,CAAgB;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAc;IACpC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAClC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAoB;IACzD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;gBAE3B,MAAM,EAAE,qBAAqB;IAQzC;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe;IAoCrC,OAAO,CAAC,YAAY;IAOpB;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAKjF;;OAEG;IACH,UAAU,IAAI,MAAM,EAAE;CAKvB"}
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Detection Funnel Policy — PRI-446 (migrated from the plugin adapter)
3
+ *
4
+ * Pure three-layer detection funnel logic:
5
+ * L1 — exact dictionary match (sync, delegated via injected matchFn)
6
+ * L2 — LRU cache of prior L3 resolutions (sync)
7
+ * L3 — async semantic queue (caller drains via flushQueue + updateCache)
8
+ *
9
+ * This module is fully pure: no I/O, no crypto, no plugin imports. The two
10
+ * environment-coupled dependencies — the dictionary matcher and the text hasher —
11
+ * are injected, so core owns the funnel *logic* while the plugin owns the
12
+ * concrete crypto.createHash and the PainDictionary.
13
+ *
14
+ * The plugin-side detection-funnel.ts is now a thin shell that wires
15
+ * DetectionFunnelCore with crypto + dictionary and re-exports the DetectionFunnel
16
+ * name, so DetectionService and evolution-worker keep working unchanged.
17
+ *
18
+ * ERR checklist:
19
+ * - ERR-001: no `as` casts; cache reads validated.
20
+ * - ERR-002: results carry structured source + severity.
21
+ * - EP-01: queue is bounded.
22
+ */
23
+ // ── LRU cache ───────────────────────────────────────────────────────────────
24
+ /**
25
+ * A simple LRU Cache implementation using Map.
26
+ * Migrated verbatim from the prior plugin detection-funnel.ts.
27
+ */
28
+ export class SimpleLRU {
29
+ cache;
30
+ maxSize;
31
+ constructor(maxSize = 100) {
32
+ this.cache = new Map();
33
+ this.maxSize = maxSize;
34
+ }
35
+ get(key) {
36
+ const item = this.cache.get(key);
37
+ if (item !== undefined) {
38
+ // Refresh: delete and re-insert
39
+ this.cache.delete(key);
40
+ this.cache.set(key, item);
41
+ }
42
+ return item;
43
+ }
44
+ set(key, value) {
45
+ if (this.cache.has(key)) {
46
+ this.cache.delete(key);
47
+ }
48
+ else if (this.cache.size >= this.maxSize) {
49
+ // Remove the oldest (first) item
50
+ const firstKey = this.cache.keys().next().value;
51
+ if (firstKey !== undefined) {
52
+ this.cache.delete(firstKey);
53
+ }
54
+ }
55
+ this.cache.set(key, value);
56
+ }
57
+ }
58
+ // ── Funnel ──────────────────────────────────────────────────────────────────
59
+ /**
60
+ * Orchestrates the three-layer detection funnel for pain signals.
61
+ *
62
+ * Pure logic: holds only in-memory cache and queue state. All environment
63
+ * coupling (dictionary, crypto) is injected via config.
64
+ */
65
+ export class DetectionFunnelCore {
66
+ cache;
67
+ asyncQueue = [];
68
+ match;
69
+ hash;
70
+ shouldIgnoreProtocol;
71
+ queueCapacity;
72
+ constructor(config) {
73
+ this.match = config.match;
74
+ this.hash = config.hash;
75
+ this.shouldIgnoreProtocol = config.shouldIgnoreProtocol;
76
+ this.cache = new SimpleLRU(config.cacheSize ?? 100);
77
+ this.queueCapacity = config.queueCapacity ?? 1000;
78
+ }
79
+ /**
80
+ * Detects pain in the given text using L1 (Exact), L2 (Cache), and L3 (Async).
81
+ */
82
+ detect(text) {
83
+ if (this.shouldIgnoreProtocol(text)) {
84
+ return { detected: false, source: 'l1_exact' };
85
+ }
86
+ // --- Layer 1: Exact Match (Sync) ---
87
+ const exactMatch = this.match(text);
88
+ if (exactMatch) {
89
+ return {
90
+ detected: true,
91
+ severity: exactMatch.severity,
92
+ ruleId: exactMatch.ruleId,
93
+ source: 'l1_exact',
94
+ };
95
+ }
96
+ // --- Layer 2: LRU Cache (Sync) ---
97
+ const hash = this.hash(text);
98
+ const cached = this.cache.get(hash);
99
+ if (cached) {
100
+ return {
101
+ detected: cached.detected,
102
+ severity: cached.severity,
103
+ source: 'l2_cache',
104
+ };
105
+ }
106
+ // --- Layer 3: Async Semantic Queue ---
107
+ this.enqueueAsync(text);
108
+ return {
109
+ detected: false,
110
+ source: 'l3_async_queued',
111
+ };
112
+ }
113
+ enqueueAsync(text) {
114
+ if (this.asyncQueue.length < this.queueCapacity) {
115
+ this.asyncQueue.push(text);
116
+ }
117
+ // Worker will pick this up and perform semantic search, then updateCache.
118
+ }
119
+ /**
120
+ * Internal method for the worker to update the cache after a semantic hit.
121
+ */
122
+ updateCache(text, result) {
123
+ const hash = this.hash(text);
124
+ this.cache.set(hash, result);
125
+ }
126
+ /**
127
+ * Retrieves and clears the current asynchronous queue.
128
+ */
129
+ flushQueue() {
130
+ const queue = [...this.asyncQueue];
131
+ this.asyncQueue = [];
132
+ return queue;
133
+ }
134
+ }
135
+ //# sourceMappingURL=detection-funnel-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detection-funnel-policy.js","sourceRoot":"","sources":["../../../src/runtime-v2/detection/detection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AAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,MAAM,EAAE,UAAU;aACnB,CAAC;QACJ,CAAC;QAED,wCAAwC;QACxC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAExB,OAAO;YACL,QAAQ,EAAE,KAAK;YACf,MAAM,EAAE,iBAAiB;SAC1B,CAAC;IACJ,CAAC;IAEO,YAAY,CAAC,IAAY;QAC/B,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;YAChD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;QACD,0EAA0E;IAC5E,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,IAAY,EAAE,MAAgD;QACxE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,UAAU;QACR,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;QACnC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Detection — PRI-446
3
+ *
4
+ * Pure three-layer pain detection funnel logic. No I/O, no crypto, no plugin
5
+ * imports. Matcher/hasher/gate are injected so core owns the funnel logic while
6
+ * the plugin owns the concrete crypto + dictionary.
7
+ */
8
+ export type { DetectionResult, PainMatchResult, PainMatcher, TextHasher, ProtocolTokenGate, DetectionFunnelConfig, } from './detection-funnel-policy.js';
9
+ export { SimpleLRU, DetectionFunnelCore } from './detection-funnel-policy.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/detection/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EACV,eAAe,EACf,eAAe,EACf,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Detection — PRI-446
3
+ *
4
+ * Pure three-layer pain detection funnel logic. No I/O, no crypto, no plugin
5
+ * imports. Matcher/hasher/gate are injected so core owns the funnel logic while
6
+ * the plugin owns the concrete crypto + dictionary.
7
+ */
8
+ export { SimpleLRU, DetectionFunnelCore } from './detection-funnel-policy.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime-v2/detection/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC"}