create-principles-disciple 1.93.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 (228) hide show
  1. package/console/dist/server/config/pd-config-store.d.ts +7 -1
  2. package/console/dist/server/config/pd-config-store.js +11 -1
  3. package/console/dist/server/index.js +10 -6
  4. package/console/dist/server/models/ApprovalsConsoleModel.js +4 -12
  5. package/console/dist/server/routes/feedback-reports.js +1 -1
  6. package/core/dist/index.d.ts +2 -2
  7. package/core/dist/index.d.ts.map +1 -1
  8. package/core/dist/index.js +1 -1
  9. package/core/dist/index.js.map +1 -1
  10. package/core/dist/prompt-builder/__tests__/model-config.test.d.ts +2 -0
  11. package/core/dist/prompt-builder/__tests__/model-config.test.d.ts.map +1 -0
  12. package/core/dist/prompt-builder/__tests__/model-config.test.js +158 -0
  13. package/core/dist/prompt-builder/__tests__/model-config.test.js.map +1 -0
  14. package/core/dist/prompt-builder/__tests__/xml-escape.test.d.ts +2 -0
  15. package/core/dist/prompt-builder/__tests__/xml-escape.test.d.ts.map +1 -0
  16. package/core/dist/prompt-builder/__tests__/xml-escape.test.js +42 -0
  17. package/core/dist/prompt-builder/__tests__/xml-escape.test.js.map +1 -0
  18. package/core/dist/prompt-builder/index.d.ts +3 -0
  19. package/core/dist/prompt-builder/index.d.ts.map +1 -1
  20. package/core/dist/prompt-builder/index.js +2 -0
  21. package/core/dist/prompt-builder/index.js.map +1 -1
  22. package/core/dist/prompt-builder/model-config.d.ts +42 -0
  23. package/core/dist/prompt-builder/model-config.d.ts.map +1 -0
  24. package/core/dist/prompt-builder/model-config.js +84 -0
  25. package/core/dist/prompt-builder/model-config.js.map +1 -0
  26. package/core/dist/prompt-builder/xml-escape.d.ts +12 -0
  27. package/core/dist/prompt-builder/xml-escape.d.ts.map +1 -0
  28. package/core/dist/prompt-builder/xml-escape.js +19 -0
  29. package/core/dist/prompt-builder/xml-escape.js.map +1 -0
  30. package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +87 -16
  31. package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
  32. package/core/dist/runtime-v2/__tests__/pain-signal-bridge-result-shaping.test.d.ts +2 -0
  33. package/core/dist/runtime-v2/__tests__/pain-signal-bridge-result-shaping.test.d.ts.map +1 -0
  34. package/core/dist/runtime-v2/__tests__/pain-signal-bridge-result-shaping.test.js +395 -0
  35. package/core/dist/runtime-v2/__tests__/pain-signal-bridge-result-shaping.test.js.map +1 -0
  36. package/core/dist/runtime-v2/bridge-result-shaper.d.ts +53 -0
  37. package/core/dist/runtime-v2/bridge-result-shaper.d.ts.map +1 -0
  38. package/core/dist/runtime-v2/bridge-result-shaper.js +117 -0
  39. package/core/dist/runtime-v2/bridge-result-shaper.js.map +1 -0
  40. package/core/dist/runtime-v2/detection/__tests__/detection-funnel-policy.test.d.ts +13 -0
  41. package/core/dist/runtime-v2/detection/__tests__/detection-funnel-policy.test.d.ts.map +1 -0
  42. package/core/dist/runtime-v2/detection/__tests__/detection-funnel-policy.test.js +111 -0
  43. package/core/dist/runtime-v2/detection/__tests__/detection-funnel-policy.test.js.map +1 -0
  44. package/core/dist/runtime-v2/detection/detection-funnel-policy.d.ts +103 -0
  45. package/core/dist/runtime-v2/detection/detection-funnel-policy.d.ts.map +1 -0
  46. package/core/dist/runtime-v2/detection/detection-funnel-policy.js +135 -0
  47. package/core/dist/runtime-v2/detection/detection-funnel-policy.js.map +1 -0
  48. package/core/dist/runtime-v2/detection/index.d.ts +10 -0
  49. package/core/dist/runtime-v2/detection/index.d.ts.map +1 -0
  50. package/core/dist/runtime-v2/detection/index.js +9 -0
  51. package/core/dist/runtime-v2/detection/index.js.map +1 -0
  52. package/core/dist/runtime-v2/evidence-triage/__tests__/observation-resolver.test.d.ts +12 -0
  53. package/core/dist/runtime-v2/evidence-triage/__tests__/observation-resolver.test.d.ts.map +1 -0
  54. package/core/dist/runtime-v2/evidence-triage/__tests__/observation-resolver.test.js +181 -0
  55. package/core/dist/runtime-v2/evidence-triage/__tests__/observation-resolver.test.js.map +1 -0
  56. package/core/dist/runtime-v2/evidence-triage/__tests__/triage-policy.test.js +104 -1
  57. package/core/dist/runtime-v2/evidence-triage/__tests__/triage-policy.test.js.map +1 -1
  58. package/core/dist/runtime-v2/evidence-triage/index.d.ts +3 -0
  59. package/core/dist/runtime-v2/evidence-triage/index.d.ts.map +1 -1
  60. package/core/dist/runtime-v2/evidence-triage/index.js +3 -0
  61. package/core/dist/runtime-v2/evidence-triage/index.js.map +1 -1
  62. package/core/dist/runtime-v2/evidence-triage/observation-resolver.d.ts +128 -0
  63. package/core/dist/runtime-v2/evidence-triage/observation-resolver.d.ts.map +1 -0
  64. package/core/dist/runtime-v2/evidence-triage/observation-resolver.js +203 -0
  65. package/core/dist/runtime-v2/evidence-triage/observation-resolver.js.map +1 -0
  66. package/core/dist/runtime-v2/evidence-triage/triage-policy.d.ts +4 -0
  67. package/core/dist/runtime-v2/evidence-triage/triage-policy.d.ts.map +1 -1
  68. package/core/dist/runtime-v2/evidence-triage/triage-policy.js +66 -9
  69. package/core/dist/runtime-v2/evidence-triage/triage-policy.js.map +1 -1
  70. package/core/dist/runtime-v2/evidence-triage/types.d.ts +14 -0
  71. package/core/dist/runtime-v2/evidence-triage/types.d.ts.map +1 -1
  72. package/core/dist/runtime-v2/evidence-triage/types.js.map +1 -1
  73. package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js +33 -4
  74. package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js.map +1 -1
  75. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts.map +1 -1
  76. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js +9 -2
  77. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
  78. package/core/dist/runtime-v2/feedback/__tests__/redact-sensitive.test.d.ts +15 -0
  79. package/core/dist/runtime-v2/feedback/__tests__/redact-sensitive.test.d.ts.map +1 -0
  80. package/core/dist/runtime-v2/feedback/__tests__/redact-sensitive.test.js +450 -0
  81. package/core/dist/runtime-v2/feedback/__tests__/redact-sensitive.test.js.map +1 -0
  82. package/core/dist/runtime-v2/feedback/__tests__/render-github-url.test.d.ts +13 -0
  83. package/core/dist/runtime-v2/feedback/__tests__/render-github-url.test.d.ts.map +1 -0
  84. package/core/dist/runtime-v2/feedback/__tests__/render-github-url.test.js +243 -0
  85. package/core/dist/runtime-v2/feedback/__tests__/render-github-url.test.js.map +1 -0
  86. package/core/dist/runtime-v2/feedback/__tests__/safe-stringify.test.d.ts +12 -0
  87. package/core/dist/runtime-v2/feedback/__tests__/safe-stringify.test.d.ts.map +1 -0
  88. package/core/dist/runtime-v2/feedback/__tests__/safe-stringify.test.js +172 -0
  89. package/core/dist/runtime-v2/feedback/__tests__/safe-stringify.test.js.map +1 -0
  90. package/core/dist/runtime-v2/index.d.ts +8 -4
  91. package/core/dist/runtime-v2/index.d.ts.map +1 -1
  92. package/core/dist/runtime-v2/index.js +4 -2
  93. package/core/dist/runtime-v2/index.js.map +1 -1
  94. package/core/dist/runtime-v2/internalization/__tests__/c2-live-runner-chain.test.d.ts +2 -0
  95. package/core/dist/runtime-v2/internalization/__tests__/c2-live-runner-chain.test.d.ts.map +1 -0
  96. package/core/dist/runtime-v2/internalization/__tests__/c2-live-runner-chain.test.js +306 -0
  97. package/core/dist/runtime-v2/internalization/__tests__/c2-live-runner-chain.test.js.map +1 -0
  98. package/core/dist/runtime-v2/internalization/index.d.ts +0 -16
  99. package/core/dist/runtime-v2/internalization/index.d.ts.map +1 -1
  100. package/core/dist/runtime-v2/internalization/index.js +0 -8
  101. package/core/dist/runtime-v2/internalization/index.js.map +1 -1
  102. package/core/dist/runtime-v2/pain-gate/__tests__/pain-diagnostic-gate-policy.test.d.ts +15 -0
  103. package/core/dist/runtime-v2/pain-gate/__tests__/pain-diagnostic-gate-policy.test.d.ts.map +1 -0
  104. package/core/dist/runtime-v2/pain-gate/__tests__/pain-diagnostic-gate-policy.test.js +179 -0
  105. package/core/dist/runtime-v2/pain-gate/__tests__/pain-diagnostic-gate-policy.test.js.map +1 -0
  106. package/core/dist/runtime-v2/pain-gate/index.d.ts +10 -0
  107. package/core/dist/runtime-v2/pain-gate/index.d.ts.map +1 -0
  108. package/core/dist/runtime-v2/pain-gate/index.js +9 -0
  109. package/core/dist/runtime-v2/pain-gate/index.js.map +1 -0
  110. package/core/dist/runtime-v2/pain-gate/pain-diagnostic-gate-policy.d.ts +121 -0
  111. package/core/dist/runtime-v2/pain-gate/pain-diagnostic-gate-policy.d.ts.map +1 -0
  112. package/core/dist/runtime-v2/pain-gate/pain-diagnostic-gate-policy.js +157 -0
  113. package/core/dist/runtime-v2/pain-gate/pain-diagnostic-gate-policy.js.map +1 -0
  114. package/core/dist/runtime-v2/pain-signal-bridge.d.ts.map +1 -1
  115. package/core/dist/runtime-v2/pain-signal-bridge.js +14 -88
  116. package/core/dist/runtime-v2/pain-signal-bridge.js.map +1 -1
  117. package/core/dist/runtime-v2/pain-signal-observability.d.ts.map +1 -1
  118. package/core/dist/runtime-v2/pain-signal-observability.js +15 -5
  119. package/core/dist/runtime-v2/pain-signal-observability.js.map +1 -1
  120. package/core/dist/runtime-v2/types/event-types.d.ts +0 -27
  121. package/core/dist/runtime-v2/types/event-types.d.ts.map +1 -1
  122. package/core/dist/runtime-v2/types/event-types.js +2 -17
  123. package/core/dist/runtime-v2/types/event-types.js.map +1 -1
  124. package/core/dist/runtime-v2/types/index.d.ts +2 -2
  125. package/core/dist/runtime-v2/types/index.d.ts.map +1 -1
  126. package/core/dist/runtime-v2/types/index.js +3 -1
  127. package/core/dist/runtime-v2/types/index.js.map +1 -1
  128. package/core/dist/runtime-v2/types/pain-signal.d.ts +2 -2
  129. package/core/dist/runtime-v2/types/pain-signal.js +2 -2
  130. package/dist/mvp-config.d.ts +0 -10
  131. package/dist/mvp-config.d.ts.map +1 -1
  132. package/dist/mvp-config.js +0 -65
  133. package/dist/mvp-config.js.map +1 -1
  134. package/package.json +1 -1
  135. package/pd-cli/dist/commands/mvp-smoke.js +1 -1
  136. package/pd-cli/dist/commands/mvp-smoke.js.map +1 -1
  137. package/pd-cli/dist/commands/rulecode.js +1 -1
  138. package/pd-cli/dist/commands/rulecode.js.map +1 -1
  139. package/pd-cli/dist/commands/runtime-canary.d.ts.map +1 -1
  140. package/pd-cli/dist/commands/runtime-canary.js +10 -11
  141. package/pd-cli/dist/commands/runtime-canary.js.map +1 -1
  142. package/pd-cli/dist/commands/runtime-internalization-queue.d.ts.map +1 -1
  143. package/pd-cli/dist/commands/runtime-internalization-queue.js +13 -16
  144. package/pd-cli/dist/commands/runtime-internalization-queue.js.map +1 -1
  145. package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
  146. package/pd-cli/dist/commands/runtime-internalization-run-once.js +3 -0
  147. package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
  148. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.d.ts.map +1 -1
  149. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js +61 -7
  150. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js.map +1 -1
  151. package/pd-cli/dist/commands/runtime.js +1 -1
  152. package/pd-cli/dist/commands/runtime.js.map +1 -1
  153. package/pd-cli/dist/index.js +67 -34
  154. package/pd-cli/dist/index.js.map +1 -1
  155. package/pd-cli/dist/services/__tests__/rulehost-readiness.test.d.ts +2 -0
  156. package/pd-cli/dist/services/__tests__/rulehost-readiness.test.d.ts.map +1 -0
  157. package/pd-cli/dist/services/__tests__/rulehost-readiness.test.js +314 -0
  158. package/pd-cli/dist/services/__tests__/rulehost-readiness.test.js.map +1 -0
  159. package/pd-cli/dist/services/__tests__/runtime-adapter-resolver.test.js +20 -12
  160. package/pd-cli/dist/services/__tests__/runtime-adapter-resolver.test.js.map +1 -1
  161. package/pd-cli/dist/services/rulehost-readiness.d.ts +62 -0
  162. package/pd-cli/dist/services/rulehost-readiness.d.ts.map +1 -0
  163. package/pd-cli/dist/services/rulehost-readiness.js +214 -0
  164. package/pd-cli/dist/services/rulehost-readiness.js.map +1 -0
  165. package/pd-cli/dist/services/runtime-adapter-resolver.d.ts +1 -1
  166. package/pd-cli/dist/services/runtime-adapter-resolver.js +3 -3
  167. package/pd-cli/dist/services/runtime-adapter-resolver.js.map +1 -1
  168. package/plugin/dist/commands/evolution-status.js +0 -2
  169. package/plugin/dist/core/detection-funnel.d.ts +25 -11
  170. package/plugin/dist/core/detection-funnel.js +32 -80
  171. package/plugin/dist/core/event-log.d.ts +1 -3
  172. package/plugin/dist/core/event-log.js +10 -21
  173. package/plugin/dist/core/evolution-reducer.d.ts +0 -8
  174. package/plugin/dist/core/evolution-reducer.js +9 -19
  175. package/plugin/dist/core/pain-diagnostic-gate.d.ts +37 -28
  176. package/plugin/dist/core/pain-diagnostic-gate.js +53 -89
  177. package/plugin/dist/core/pain.d.ts +0 -63
  178. package/plugin/dist/core/pain.js +0 -167
  179. package/plugin/dist/core/paths.d.ts +0 -1
  180. package/plugin/dist/core/paths.js +2 -1
  181. package/plugin/dist/core/schema/migrations/001-init-trajectory.js +3 -6
  182. package/plugin/dist/core/schema/schema-definitions.js +4 -9
  183. package/plugin/dist/core/trajectory.d.ts +0 -16
  184. package/plugin/dist/core/trajectory.js +9 -60
  185. package/plugin/dist/hooks/after-tool-call-helpers.d.ts +4 -1
  186. package/plugin/dist/hooks/after-tool-call-helpers.js +13 -17
  187. package/plugin/dist/hooks/gate-block-helper.js +57 -17
  188. package/plugin/dist/hooks/lifecycle.js +3 -6
  189. package/plugin/dist/hooks/llm.js +66 -26
  190. package/plugin/dist/hooks/pain.d.ts +3 -1
  191. package/plugin/dist/hooks/pain.js +119 -49
  192. package/plugin/dist/hooks/prompt-helpers.d.ts +87 -0
  193. package/plugin/dist/hooks/prompt-helpers.js +251 -0
  194. package/plugin/dist/hooks/prompt-types.d.ts +66 -0
  195. package/plugin/dist/hooks/prompt-types.js +12 -0
  196. package/plugin/dist/hooks/prompt.d.ts +7 -38
  197. package/plugin/dist/hooks/prompt.js +361 -325
  198. package/plugin/dist/hooks/raw-observation-adapter.d.ts +9 -50
  199. package/plugin/dist/hooks/raw-observation-adapter.js +9 -164
  200. package/plugin/dist/hooks/raw-observation-types.d.ts +6 -57
  201. package/plugin/dist/hooks/raw-observation-types.js +5 -9
  202. package/plugin/dist/hooks/triage-adapter.js +6 -26
  203. package/plugin/dist/hooks/trigger-cooldown-tracker.d.ts +12 -0
  204. package/plugin/dist/hooks/trigger-cooldown-tracker.js +25 -0
  205. package/plugin/dist/service/evolution-worker.js +6 -64
  206. package/plugin/dist/service/runtime-summary-service.d.ts +0 -2
  207. package/plugin/dist/service/runtime-summary-service.js +0 -4
  208. package/plugin/dist/types/event-types.d.ts +1 -1
  209. package/plugin/scripts/sync-plugin.mjs +33 -22
  210. package/plugin/scripts/validate-live-path.ts +0 -18
  211. package/plugin/templates/langs/en/skills/pd-cli-operator/SKILL.md +20 -11
  212. package/plugin/templates/langs/en/skills/pd-runtime-v2/SKILL.md +10 -0
  213. package/plugin/templates/langs/zh/skills/pd-cli-operator/SKILL.md +20 -11
  214. package/plugin/templates/langs/zh/skills/pd-runtime-v2/SKILL.md +10 -0
  215. package/console/dist/server/config/feature-flags.d.ts +0 -25
  216. package/console/dist/server/config/feature-flags.js +0 -101
  217. package/pd-cli/dist/commands/central-sync.d.ts +0 -10
  218. package/pd-cli/dist/commands/central-sync.d.ts.map +0 -1
  219. package/pd-cli/dist/commands/central-sync.js +0 -32
  220. package/pd-cli/dist/commands/central-sync.js.map +0 -1
  221. package/pd-cli/dist/services/feature-flag-loader.d.ts +0 -6
  222. package/pd-cli/dist/services/feature-flag-loader.d.ts.map +0 -1
  223. package/pd-cli/dist/services/feature-flag-loader.js +0 -53
  224. package/pd-cli/dist/services/feature-flag-loader.js.map +0 -1
  225. package/plugin/dist/core/observability.d.ts +0 -40
  226. package/plugin/dist/core/observability.js +0 -164
  227. package/plugin/dist/hooks/subagent.d.ts +0 -9
  228. package/plugin/dist/hooks/subagent.js +0 -122
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Escape special XML characters in a string.
3
+ *
4
+ * Pure logic — no I/O, no side effects.
5
+ *
6
+ * Used by prompt injection to safely embed user/principle text into XML-style
7
+ * prompt markers (e.g. `<directive id="...">...</directive>`). Also accepted
8
+ * as a callback by `trimToBudget` and `renderPrinciplesToDirectives` in
9
+ * `runtime-v2/activation/prompt-activation-reader-contract.ts`.
10
+ */
11
+ export declare function escapeXml(input: string): string;
12
+ //# sourceMappingURL=xml-escape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xml-escape.d.ts","sourceRoot":"","sources":["../../src/prompt-builder/xml-escape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO/C"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Escape special XML characters in a string.
3
+ *
4
+ * Pure logic — no I/O, no side effects.
5
+ *
6
+ * Used by prompt injection to safely embed user/principle text into XML-style
7
+ * prompt markers (e.g. `<directive id="...">...</directive>`). Also accepted
8
+ * as a callback by `trimToBudget` and `renderPrinciplesToDirectives` in
9
+ * `runtime-v2/activation/prompt-activation-reader-contract.ts`.
10
+ */
11
+ export function escapeXml(input) {
12
+ return input
13
+ .replace(/&/g, '&amp;')
14
+ .replace(/</g, '&lt;')
15
+ .replace(/>/g, '&gt;')
16
+ .replace(/"/g, '&quot;')
17
+ .replace(/'/g, '&apos;');
18
+ }
19
+ //# sourceMappingURL=xml-escape.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xml-escape.js","sourceRoot":"","sources":["../../src/prompt-builder/xml-escape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,OAAO,KAAK;SACT,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC7B,CAAC"}
@@ -195,6 +195,12 @@ const REQUIRED_SOURCE_FILES = [
195
195
  'activation/approval-completion-service.ts',
196
196
  // PRI-431: L2 principle reader (pure logic, extracted from pd-cli + plugin duplicates)
197
197
  'build-l2-principle-reader.ts',
198
+ // PRI-446: pure logic migrated from openclaw-plugin into core
199
+ 'evidence-triage/observation-resolver.ts',
200
+ 'pain-gate/pain-diagnostic-gate-policy.ts',
201
+ 'pain-gate/index.ts',
202
+ 'detection/detection-funnel-policy.ts',
203
+ 'detection/index.ts',
198
204
  ];
199
205
  // ── PRI-212: Plugin core anti-growth guard ────────────────────────────────────
200
206
  //
@@ -247,6 +253,9 @@ const KNOWN_PLUGIN_CORE_FILES = new Set([
247
253
  'schema/migration-runner.ts',
248
254
  'rule-host.ts',
249
255
  'principle-training-state.ts',
256
+ // PRI-446: now a thin adapter delegating pure decision logic to
257
+ // runtime-v2/pain-gate/pain-diagnostic-gate-policy.ts. Kept here because it
258
+ // owns the cooldown Map + SystemLogger + Date.now side effects.
250
259
  'pain-diagnostic-gate.ts',
251
260
  'hygiene/tracker.ts',
252
261
  'schema/migrations/002-init-central.ts',
@@ -289,6 +298,9 @@ const KNOWN_PLUGIN_CORE_FILES = new Set([
289
298
  'dictionary.ts',
290
299
  'thinking-os-parser.ts',
291
300
  'system-logger.ts',
301
+ // PRI-446: now a thin shell wiring DetectionFunnelCore (core runtime-v2/detection)
302
+ // with crypto.createHash + PainDictionary. Kept here because it owns the
303
+ // crypto + dictionary I/O boundary.
292
304
  'detection-funnel.ts',
293
305
  'risk-calculator.ts',
294
306
  'migration.ts',
@@ -361,6 +373,9 @@ describe('PRI-212 plugin core anti-growth guard', () => {
361
373
  // model-training-registry.ts, model-deployment-registry.ts,
362
374
  // shadow-observation-registry.ts (98 → 93)
363
375
  // PRI-449: Removed external-training-contract.ts (93 → 92)
376
+ // PRI-446: pain-diagnostic-gate.ts and detection-funnel.ts remain at 92 —
377
+ // they are now thin adapters delegating pure logic to core, but still live
378
+ // in plugin src/core/ and own I/O side effects, so they stay classified.
364
379
  expect(KNOWN_PLUGIN_CORE_FILES.size).toBe(92);
365
380
  });
366
381
  });
@@ -597,6 +612,30 @@ describe('PRI-42 internalization boundary', () => {
597
612
  expect(src).not.toContain('../../../openclaw-plugin');
598
613
  }
599
614
  });
615
+ it('PRI-446: pain-gate has zero openclaw-plugin imports', async () => {
616
+ const { existsSync, readdirSync, readFileSync } = await import('node:fs');
617
+ const { resolve, join } = await import('node:path');
618
+ const dir = resolve(__dirname, '..', 'pain-gate');
619
+ expect(existsSync(dir)).toBe(true);
620
+ const files = readdirSync(dir).filter((f) => f.endsWith('.ts') && !f.endsWith('.test.ts'));
621
+ for (const file of files) {
622
+ const src = readFileSync(join(dir, file), 'utf-8');
623
+ expect(src).not.toContain('openclaw-plugin');
624
+ expect(src).not.toContain('../../../openclaw-plugin');
625
+ }
626
+ });
627
+ it('PRI-446: detection has zero openclaw-plugin imports', async () => {
628
+ const { existsSync, readdirSync, readFileSync } = await import('node:fs');
629
+ const { resolve, join } = await import('node:path');
630
+ const dir = resolve(__dirname, '..', 'detection');
631
+ expect(existsSync(dir)).toBe(true);
632
+ const files = readdirSync(dir).filter((f) => f.endsWith('.ts') && !f.endsWith('.test.ts'));
633
+ for (const file of files) {
634
+ const src = readFileSync(join(dir, file), 'utf-8');
635
+ expect(src).not.toContain('openclaw-plugin');
636
+ expect(src).not.toContain('../../../openclaw-plugin');
637
+ }
638
+ });
600
639
  it('plugin does not re-define RuleHost contract types locally', async () => {
601
640
  const { existsSync, readFileSync } = await import('node:fs');
602
641
  const { resolve } = await import('node:path');
@@ -1598,6 +1637,16 @@ describe('PRI-75/PRI-74/PRI-81 prompt-builder core boundary', () => {
1598
1637
  // Must NOT have the old multi-line fallback block with attitudeDirective interpolation
1599
1638
  expect(src).not.toMatch(/## 【CONTEXT SECTIONS】\n\n\[WARNING: Context sections stripped/);
1600
1639
  });
1640
+ it('plugin prompt-helpers.ts imports escapeXml from core, not reimplemented', async () => {
1641
+ const { readFileSync } = await import('node:fs');
1642
+ const { resolve } = await import('node:path');
1643
+ const src = readFileSync(resolve(__dirname, '../../../../openclaw-plugin/src/hooks/prompt-helpers.ts'), 'utf-8');
1644
+ // Must import escapeXml from core
1645
+ expect(src).toContain('@principles/core/prompt-builder');
1646
+ expect(src).toMatch(/import\s*\{[^}]*escapeXml[^}]*\}\s*from\s*['"]@principles\/core\/prompt-builder['"]/);
1647
+ // Must NOT reimplement escapeXml inline
1648
+ expect(src).not.toMatch(/\b(function\s+escapeXml\s*\(|const\s+escapeXml\s*=\s*(?:async\s*)?(?:\([^)]*\)|[a-zA-Z_$][\w$]*)\s*=>)/);
1649
+ });
1601
1650
  it('plugin empathy-keyword-matcher.ts is a thin adapter (re-exports from core)', async () => {
1602
1651
  const { readFileSync } = await import('node:fs');
1603
1652
  const { resolve } = await import('node:path');
@@ -1755,6 +1804,19 @@ describe('PRI-111 ArtificerRunner boundary', () => {
1755
1804
  expect(src).toContain('ArtificerRuleOutputSchema');
1756
1805
  });
1757
1806
  });
1807
+ // ── PRI-458: PhilosopherRunner barrel boundary (MVP-Quiet) ─────────────────────
1808
+ describe('PRI-458 PhilosopherRunner barrel boundary', () => {
1809
+ it('BARREL_EXPORTS: internalization/index.ts does NOT export PhilosopherRunner (PRI-458 MVP-Quiet)', async () => {
1810
+ // PRI-458: PhilosopherRunner is de-surfaced from the internal barrel (MVP-Quiet).
1811
+ // It remains in runtime-v2/index.ts (public barrel) because rulehost-pipeline-runner.ts
1812
+ // imports it from there (EP-02 exception).
1813
+ const { readFileSync } = await import('node:fs');
1814
+ const { resolve } = await import('node:path');
1815
+ const src = readFileSync(resolve(__dirname, '..', 'internalization', 'index.ts'), 'utf-8');
1816
+ expect(src).not.toContain("from './philosopher-runner.js'");
1817
+ expect(src).not.toContain("from './philosopher-output.js'");
1818
+ });
1819
+ });
1758
1820
  // ── PRI-EVAL: EvaluatorRunner boundary guards ──────────────────────────────────
1759
1821
  describe('PRI-EVAL EvaluatorRunner boundary', () => {
1760
1822
  it('evaluator source files exist in internalization directory', async () => {
@@ -1795,13 +1857,17 @@ describe('PRI-EVAL EvaluatorRunner boundary', () => {
1795
1857
  expect(src).not.toContain('node:fs');
1796
1858
  expect(src).not.toContain('node:cron');
1797
1859
  });
1798
- it('BARREL_EXPORTS: internalization/index.ts exports EvaluatorRunner and EvaluatorOutput', async () => {
1860
+ it('BARREL_EXPORTS: internalization/index.ts does NOT export EvaluatorRunner (PRI-458 MVP-Quiet)', async () => {
1861
+ // PRI-458: EvaluatorRunner is de-surfaced from the internal barrel (MVP-Quiet).
1862
+ // It remains in runtime-v2/index.ts (public barrel) because rulehost-pipeline-runner.ts
1863
+ // imports it from there (EP-02 exception). These negative assertions lock the boundary:
1864
+ // if someone re-aggregates the evaluator exports into this barrel, the test will fail.
1799
1865
  const { readFileSync } = await import('node:fs');
1800
1866
  const { resolve } = await import('node:path');
1801
1867
  const src = readFileSync(resolve(__dirname, '..', 'internalization', 'index.ts'), 'utf-8');
1802
- expect(src).toContain('EvaluatorRunner');
1803
- expect(src).toContain('EvaluatorOutput');
1804
- expect(src).toContain('DefaultEvaluatorValidator');
1868
+ expect(src).not.toContain("from './evaluator-runner.js'");
1869
+ expect(src).not.toContain("from './evaluator-output.js'");
1870
+ expect(src).not.toContain("from './evaluator-prompt-builder.js'");
1805
1871
  });
1806
1872
  it('SCHEMA_REGISTRY: pi-ai-runtime-adapter.ts registers evaluator-output-v1 schema', async () => {
1807
1873
  const { readFileSync } = await import('node:fs');
@@ -1851,13 +1917,16 @@ describe('PRI-RR RolloutReviewerRunner boundary', () => {
1851
1917
  expect(src).not.toContain('node:fs');
1852
1918
  expect(src).not.toContain('node:cron');
1853
1919
  });
1854
- it('BARREL_EXPORTS: internalization/index.ts exports RolloutReviewerRunner and RolloutReviewerOutput', async () => {
1920
+ it('BARREL_EXPORTS: internalization/index.ts does NOT export RolloutReviewerRunner (PRI-458 MVP-Quiet)', async () => {
1921
+ // PRI-458: RolloutReviewerRunner is de-surfaced from the internal barrel (MVP-Quiet).
1922
+ // It remains in runtime-v2/index.ts (public barrel) because runtime-internalization-run-once.ts
1923
+ // imports it from there and package.json has no deep import path available (EP-02 exception).
1855
1924
  const { readFileSync } = await import('node:fs');
1856
1925
  const { resolve } = await import('node:path');
1857
1926
  const src = readFileSync(resolve(__dirname, '..', 'internalization', 'index.ts'), 'utf-8');
1858
- expect(src).toContain('RolloutReviewerRunner');
1859
- expect(src).toContain('RolloutReviewerOutput');
1860
- expect(src).toContain('DefaultRolloutReviewerValidator');
1927
+ expect(src).not.toContain("from './rollout-reviewer-runner.js'");
1928
+ expect(src).not.toContain("from './rollout-reviewer-output.js'");
1929
+ expect(src).not.toContain("from './rollout-reviewer-prompt-builder.js'");
1861
1930
  });
1862
1931
  it('SCHEMA_REGISTRY: pi-ai-runtime-adapter.ts registers rollout-reviewer-output-v1 schema', async () => {
1863
1932
  const { readFileSync } = await import('node:fs');
@@ -2127,12 +2196,14 @@ describe('PRI-117 Nocturnal god-class freeze', () => {
2127
2196
  expect(src).not.toContain('invokeStubScribe');
2128
2197
  }
2129
2198
  });
2130
- it('RUNTIME_V2_USES_PEER_RUNNERS: DreamerRunner/PhilosopherRunner/ScribeRunner are the canonical entry points', async () => {
2199
+ it('RUNTIME_V2_USES_PEER_RUNNERS: DreamerRunner/ScribeRunner/ArtificerRunner are the canonical MVP-Core entry points', async () => {
2200
+ // PRI-458: narrowed to MVP-Core runners only. PhilosopherRunner (MVP-Quiet)
2201
+ // remains in runtime-v2/index.ts for rulehost-pipeline-runner.ts compatibility
2202
+ // but is no longer asserted as a canonical entry point.
2131
2203
  const { readFileSync } = await import('node:fs');
2132
2204
  const { resolve } = await import('node:path');
2133
2205
  const src = readFileSync(resolve(__dirname, '..', 'index.ts'), 'utf-8');
2134
2206
  expect(src).toContain('DreamerRunner');
2135
- expect(src).toContain('PhilosopherRunner');
2136
2207
  expect(src).toContain('ScribeRunner');
2137
2208
  expect(src).toContain('ArtificerRunner');
2138
2209
  });
@@ -2878,7 +2949,7 @@ describe('PRI-225: No unsafe type assertions on untrusted metadata arrays', () =
2878
2949
  // ── PRI-239: Feature flag registry architecture boundary ──────────────────
2879
2950
  //
2880
2951
  // Core: packages/principles-core/src/runtime-v2/feature-flags/feature-flag-contract.ts
2881
- // I/O Loader: packages/pd-cli/src/services/feature-flag-loader.ts
2952
+ // I/O Loader: packages/pd-cli/src/services/pd-config-loader.ts (PRI-460: replaced feature-flag-loader.ts)
2882
2953
  // CLI Command: packages/pd-cli/src/commands/runtime-features.ts
2883
2954
  // Consumption: packages/pd-cli/src/commands/runtime-canary.ts (GFI check)
2884
2955
  describe('PRI-239: Feature flag registry architecture boundary', () => {
@@ -2900,10 +2971,10 @@ describe('PRI-239: Feature flag registry architecture boundary', () => {
2900
2971
  expect(src).not.toContain('InternalizationOrchestrator');
2901
2972
  expect(src).not.toContain('SqliteConnection');
2902
2973
  });
2903
- it('IO_LOADER_OUTSIDE_CORE: I/O loader exists at pd-cli/src/services/feature-flag-loader.ts', async () => {
2974
+ it('IO_LOADER_OUTSIDE_CORE: I/O loader exists at pd-cli/src/services/pd-config-loader.ts', async () => {
2904
2975
  const { existsSync } = await import('node:fs');
2905
2976
  const { resolve } = await import('node:path');
2906
- expect(existsSync(resolve(__dirname, '../../../../pd-cli/src/services/feature-flag-loader.ts'))).toBe(true);
2977
+ expect(existsSync(resolve(__dirname, '../../../../pd-cli/src/services/pd-config-loader.ts'))).toBe(true);
2907
2978
  });
2908
2979
  it('CLI_COMMAND_OUTSIDE_CORE: CLI command exists at pd-cli/src/commands/runtime-features.ts', async () => {
2909
2980
  const { existsSync } = await import('node:fs');
@@ -2918,12 +2989,12 @@ describe('PRI-239: Feature flag registry architecture boundary', () => {
2918
2989
  expect(src).not.toContain('nocturnal-arbiter');
2919
2990
  expect(src).not.toContain('nocturnal-service');
2920
2991
  });
2921
- it('CONSUMPTION_WIRED: runtime-canary.ts imports feature flag loader', async () => {
2992
+ it('CONSUMPTION_WIRED: runtime-canary.ts imports canonical PD config loader', async () => {
2922
2993
  const { readFileSync } = await import('node:fs');
2923
2994
  const { resolve } = await import('node:path');
2924
2995
  const src = readFileSync(resolve(__dirname, '../../../../pd-cli/src/commands/runtime-canary.ts'), 'utf-8');
2925
- expect(src).toContain('feature-flag-loader');
2926
- expect(src).toContain('loadEffectiveFeatureFlags');
2996
+ expect(src).toContain('pd-config-loader');
2997
+ expect(src).toContain('loadPdConfig');
2927
2998
  });
2928
2999
  });
2929
3000
  describe('PRI-304: PD-Owned Config Contract barrel exports and purity', () => {