@principles/core 1.123.0 → 1.125.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 (231) hide show
  1. package/dist/runtime-v2/__tests__/architecture-regression.test.js +42 -74
  2. package/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
  3. package/dist/runtime-v2/__tests__/attack-e2e-pipeline-smoke.test.js +115 -21
  4. package/dist/runtime-v2/__tests__/attack-e2e-pipeline-smoke.test.js.map +1 -1
  5. package/dist/runtime-v2/__tests__/golden-path-diagnostician-e2e.test.js.map +1 -1
  6. package/dist/runtime-v2/__tests__/pain-signal-bridge-retried.test.js +7 -6
  7. package/dist/runtime-v2/__tests__/pain-signal-bridge-retried.test.js.map +1 -1
  8. package/dist/runtime-v2/__tests__/pain-signal-bridge-short-circuit.test.js.map +1 -1
  9. package/dist/runtime-v2/__tests__/pain-signal-bridge-workspace-dir.test.js.map +1 -1
  10. package/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
  11. package/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js +4 -0
  12. package/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js.map +1 -1
  13. package/dist/runtime-v2/cli/diagnose.d.ts +2 -2
  14. package/dist/runtime-v2/cli/diagnose.d.ts.map +1 -1
  15. package/dist/runtime-v2/config/__tests__/pd-config-contract.test.js +3 -3
  16. package/dist/runtime-v2/config/__tests__/pd-config-contract.test.js.map +1 -1
  17. package/dist/runtime-v2/config/pd-config-defaults.js +3 -3
  18. package/dist/runtime-v2/config/pd-config-defaults.js.map +1 -1
  19. package/dist/runtime-v2/config/pd-config-types.d.ts +2 -0
  20. package/dist/runtime-v2/config/pd-config-types.d.ts.map +1 -1
  21. package/dist/runtime-v2/config/pd-config-types.js.map +1 -1
  22. package/dist/runtime-v2/diagnostician/__tests__/diag-distiller-output.test.d.ts +2 -0
  23. package/dist/runtime-v2/diagnostician/__tests__/diag-distiller-output.test.d.ts.map +1 -0
  24. package/dist/runtime-v2/diagnostician/__tests__/diag-distiller-output.test.js +45 -0
  25. package/dist/runtime-v2/diagnostician/__tests__/diag-distiller-output.test.js.map +1 -0
  26. package/dist/runtime-v2/diagnostician/__tests__/diag-rootcause-output.test.d.ts +2 -0
  27. package/dist/runtime-v2/diagnostician/__tests__/diag-rootcause-output.test.d.ts.map +1 -0
  28. package/dist/runtime-v2/diagnostician/__tests__/diag-rootcause-output.test.js +57 -0
  29. package/dist/runtime-v2/diagnostician/__tests__/diag-rootcause-output.test.js.map +1 -0
  30. package/dist/runtime-v2/diagnostician/__tests__/distiller-prompt-builder.test.d.ts +2 -0
  31. package/dist/runtime-v2/diagnostician/__tests__/distiller-prompt-builder.test.d.ts.map +1 -0
  32. package/dist/runtime-v2/diagnostician/__tests__/distiller-prompt-builder.test.js +39 -0
  33. package/dist/runtime-v2/diagnostician/__tests__/distiller-prompt-builder.test.js.map +1 -0
  34. package/dist/runtime-v2/diagnostician/__tests__/rootcause-prompt-builder.test.d.ts +2 -0
  35. package/dist/runtime-v2/diagnostician/__tests__/rootcause-prompt-builder.test.d.ts.map +1 -0
  36. package/dist/runtime-v2/diagnostician/__tests__/rootcause-prompt-builder.test.js +34 -0
  37. package/dist/runtime-v2/diagnostician/__tests__/rootcause-prompt-builder.test.js.map +1 -0
  38. package/dist/runtime-v2/diagnostician/__tests__/router-prompt-builder.test.d.ts +2 -0
  39. package/dist/runtime-v2/diagnostician/__tests__/router-prompt-builder.test.d.ts.map +1 -0
  40. package/dist/runtime-v2/diagnostician/__tests__/router-prompt-builder.test.js +57 -0
  41. package/dist/runtime-v2/diagnostician/__tests__/router-prompt-builder.test.js.map +1 -0
  42. package/dist/runtime-v2/diagnostician/diag-distiller-output.d.ts +80 -0
  43. package/dist/runtime-v2/diagnostician/diag-distiller-output.d.ts.map +1 -0
  44. package/dist/runtime-v2/diagnostician/diag-distiller-output.js +103 -0
  45. package/dist/runtime-v2/diagnostician/diag-distiller-output.js.map +1 -0
  46. package/dist/runtime-v2/diagnostician/diag-rootcause-output.d.ts +115 -0
  47. package/dist/runtime-v2/diagnostician/diag-rootcause-output.d.ts.map +1 -0
  48. package/dist/runtime-v2/diagnostician/diag-rootcause-output.js +166 -0
  49. package/dist/runtime-v2/diagnostician/diag-rootcause-output.js.map +1 -0
  50. package/dist/runtime-v2/diagnostician/distiller-prompt-builder.d.ts +134 -0
  51. package/dist/runtime-v2/diagnostician/distiller-prompt-builder.d.ts.map +1 -0
  52. package/dist/runtime-v2/diagnostician/distiller-prompt-builder.js +156 -0
  53. package/dist/runtime-v2/diagnostician/distiller-prompt-builder.js.map +1 -0
  54. package/dist/runtime-v2/diagnostician/rootcause-prompt-builder.d.ts +96 -0
  55. package/dist/runtime-v2/diagnostician/rootcause-prompt-builder.d.ts.map +1 -0
  56. package/dist/runtime-v2/diagnostician/rootcause-prompt-builder.js +216 -0
  57. package/dist/runtime-v2/diagnostician/rootcause-prompt-builder.js.map +1 -0
  58. package/dist/runtime-v2/diagnostician/router-prompt-builder.d.ts +127 -0
  59. package/dist/runtime-v2/diagnostician/router-prompt-builder.d.ts.map +1 -0
  60. package/dist/runtime-v2/diagnostician/router-prompt-builder.js +131 -0
  61. package/dist/runtime-v2/diagnostician/router-prompt-builder.js.map +1 -0
  62. package/dist/runtime-v2/diagnostician-prompt-builder.d.ts +1 -64
  63. package/dist/runtime-v2/diagnostician-prompt-builder.d.ts.map +1 -1
  64. package/dist/runtime-v2/diagnostician-prompt-builder.js +0 -186
  65. package/dist/runtime-v2/diagnostician-prompt-builder.js.map +1 -1
  66. package/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js +13 -7
  67. package/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js.map +1 -1
  68. package/dist/runtime-v2/feature-flags/feature-flag-contract.js +3 -3
  69. package/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
  70. package/dist/runtime-v2/index.d.ts +14 -10
  71. package/dist/runtime-v2/index.d.ts.map +1 -1
  72. package/dist/runtime-v2/index.js +9 -6
  73. package/dist/runtime-v2/index.js.map +1 -1
  74. package/dist/runtime-v2/internalization/__tests__/__fixtures__/split-pipeline-mock-outputs.d.ts +25 -0
  75. package/dist/runtime-v2/internalization/__tests__/__fixtures__/split-pipeline-mock-outputs.d.ts.map +1 -0
  76. package/dist/runtime-v2/internalization/__tests__/__fixtures__/split-pipeline-mock-outputs.js +123 -0
  77. package/dist/runtime-v2/internalization/__tests__/__fixtures__/split-pipeline-mock-outputs.js.map +1 -0
  78. package/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.d.ts +2 -0
  79. package/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.d.ts.map +1 -0
  80. package/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.js +734 -0
  81. package/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.js.map +1 -0
  82. package/dist/runtime-v2/internalization/__tests__/diag-distiller-runner.test.d.ts +2 -0
  83. package/dist/runtime-v2/internalization/__tests__/diag-distiller-runner.test.d.ts.map +1 -0
  84. package/dist/runtime-v2/internalization/__tests__/diag-distiller-runner.test.js +437 -0
  85. package/dist/runtime-v2/internalization/__tests__/diag-distiller-runner.test.js.map +1 -0
  86. package/dist/runtime-v2/internalization/__tests__/diag-rootcause-runner.test.d.ts +2 -0
  87. package/dist/runtime-v2/internalization/__tests__/diag-rootcause-runner.test.d.ts.map +1 -0
  88. package/dist/runtime-v2/internalization/__tests__/diag-rootcause-runner.test.js +336 -0
  89. package/dist/runtime-v2/internalization/__tests__/diag-rootcause-runner.test.js.map +1 -0
  90. package/dist/runtime-v2/internalization/__tests__/diag-router-runner.test.d.ts +2 -0
  91. package/dist/runtime-v2/internalization/__tests__/diag-router-runner.test.d.ts.map +1 -0
  92. package/dist/runtime-v2/internalization/__tests__/diag-router-runner.test.js +437 -0
  93. package/dist/runtime-v2/internalization/__tests__/diag-router-runner.test.js.map +1 -0
  94. package/dist/runtime-v2/internalization/__tests__/runnerkind-seam.test.js +3 -3
  95. package/dist/runtime-v2/internalization/__tests__/runnerkind-seam.test.js.map +1 -1
  96. package/dist/runtime-v2/internalization/diag-distiller-runner.d.ts +83 -0
  97. package/dist/runtime-v2/internalization/diag-distiller-runner.d.ts.map +1 -0
  98. package/dist/runtime-v2/internalization/diag-distiller-runner.js +274 -0
  99. package/dist/runtime-v2/internalization/diag-distiller-runner.js.map +1 -0
  100. package/dist/runtime-v2/internalization/diag-rootcause-runner.d.ts +73 -0
  101. package/dist/runtime-v2/internalization/diag-rootcause-runner.d.ts.map +1 -0
  102. package/dist/runtime-v2/internalization/diag-rootcause-runner.js +229 -0
  103. package/dist/runtime-v2/internalization/diag-rootcause-runner.js.map +1 -0
  104. package/dist/runtime-v2/internalization/diag-router-runner.d.ts +85 -0
  105. package/dist/runtime-v2/internalization/diag-router-runner.d.ts.map +1 -0
  106. package/dist/runtime-v2/internalization/diag-router-runner.js +353 -0
  107. package/dist/runtime-v2/internalization/diag-router-runner.js.map +1 -0
  108. package/dist/runtime-v2/internalization/evaluator-runner.d.ts +1 -1
  109. package/dist/runtime-v2/internalization/evaluator-runner.d.ts.map +1 -1
  110. package/dist/runtime-v2/internalization/evaluator-runner.js +1 -1
  111. package/dist/runtime-v2/internalization/evaluator-runner.js.map +1 -1
  112. package/dist/runtime-v2/internalization/split-diagnostician-runner.d.ts +66 -0
  113. package/dist/runtime-v2/internalization/split-diagnostician-runner.d.ts.map +1 -0
  114. package/dist/runtime-v2/internalization/split-diagnostician-runner.js +241 -0
  115. package/dist/runtime-v2/internalization/split-diagnostician-runner.js.map +1 -0
  116. package/dist/runtime-v2/observer/__tests__/empathy-observer.real-e2e.test.js +28 -21
  117. package/dist/runtime-v2/observer/__tests__/empathy-observer.real-e2e.test.js.map +1 -1
  118. package/dist/runtime-v2/pain-signal-bridge.d.ts +22 -3
  119. package/dist/runtime-v2/pain-signal-bridge.d.ts.map +1 -1
  120. package/dist/runtime-v2/pain-signal-bridge.js +16 -7
  121. package/dist/runtime-v2/pain-signal-bridge.js.map +1 -1
  122. package/dist/runtime-v2/pain-signal-runtime-factory.d.ts +13 -1
  123. package/dist/runtime-v2/pain-signal-runtime-factory.d.ts.map +1 -1
  124. package/dist/runtime-v2/pain-signal-runtime-factory.js +64 -34
  125. package/dist/runtime-v2/pain-signal-runtime-factory.js.map +1 -1
  126. package/dist/runtime-v2/runner/__tests__/base-peer-runner-trust-boundary.test.js +2 -2
  127. package/dist/runtime-v2/runner/__tests__/base-peer-runner-trust-boundary.test.js.map +1 -1
  128. package/dist/runtime-v2/runner/__tests__/diagnose.test.js.map +1 -1
  129. package/dist/runtime-v2/runner/base-peer-runner.d.ts +3 -3
  130. package/dist/runtime-v2/runner/base-peer-runner.d.ts.map +1 -1
  131. package/dist/runtime-v2/runner/base-peer-runner.js +6 -6
  132. package/dist/runtime-v2/runner/base-peer-runner.js.map +1 -1
  133. package/dist/runtime-v2/runner/peer-runner-types.d.ts +3 -3
  134. package/dist/runtime-v2/runner/peer-runner-types.d.ts.map +1 -1
  135. package/dist/runtime-v2/store/candidate/sqlite-candidate-store.js +2 -2
  136. package/dist/runtime-v2/store/candidate/sqlite-candidate-store.js.map +1 -1
  137. package/dist/runtime-v2/types/principle-enums.d.ts +2 -2
  138. package/dist/runtime-v2/types/principle-enums.d.ts.map +1 -1
  139. package/dist/runtime-v2/types/principle-enums.js +1 -0
  140. package/dist/runtime-v2/types/principle-enums.js.map +1 -1
  141. package/dist/runtime-v2/types/principle-schema.d.ts +1 -1
  142. package/dist/runtime-v2/types/principle-tree-store.d.ts +1 -1
  143. package/dist/telemetry-event.d.ts +2 -2
  144. package/dist/telemetry-event.d.ts.map +1 -1
  145. package/dist/telemetry-event.js +1 -0
  146. package/dist/telemetry-event.js.map +1 -1
  147. package/package.json +1 -1
  148. package/dist/runtime-v2/__tests__/diagnostician-core-grounding.test.d.ts +0 -2
  149. package/dist/runtime-v2/__tests__/diagnostician-core-grounding.test.d.ts.map +0 -1
  150. package/dist/runtime-v2/__tests__/diagnostician-core-grounding.test.js +0 -122
  151. package/dist/runtime-v2/__tests__/diagnostician-core-grounding.test.js.map +0 -1
  152. package/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-builder.integration.test.d.ts +0 -2
  153. package/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-builder.integration.test.d.ts.map +0 -1
  154. package/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-builder.integration.test.js +0 -169
  155. package/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-builder.integration.test.js.map +0 -1
  156. package/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-builder.test.d.ts +0 -2
  157. package/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-builder.test.d.ts.map +0 -1
  158. package/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-builder.test.js +0 -462
  159. package/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-builder.test.js.map +0 -1
  160. package/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-language.test.d.ts +0 -13
  161. package/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-language.test.d.ts.map +0 -1
  162. package/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-language.test.js +0 -97
  163. package/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-language.test.js.map +0 -1
  164. package/dist/runtime-v2/runner/__tests__/diagnostician-runner.integration.test.d.ts +0 -2
  165. package/dist/runtime-v2/runner/__tests__/diagnostician-runner.integration.test.d.ts.map +0 -1
  166. package/dist/runtime-v2/runner/__tests__/diagnostician-runner.integration.test.js +0 -378
  167. package/dist/runtime-v2/runner/__tests__/diagnostician-runner.integration.test.js.map +0 -1
  168. package/dist/runtime-v2/runner/__tests__/diagnostician-runner.test.d.ts +0 -2
  169. package/dist/runtime-v2/runner/__tests__/diagnostician-runner.test.d.ts.map +0 -1
  170. package/dist/runtime-v2/runner/__tests__/diagnostician-runner.test.js +0 -682
  171. package/dist/runtime-v2/runner/__tests__/diagnostician-runner.test.js.map +0 -1
  172. package/dist/runtime-v2/runner/__tests__/diagnostician-telemetry.test.d.ts +0 -2
  173. package/dist/runtime-v2/runner/__tests__/diagnostician-telemetry.test.d.ts.map +0 -1
  174. package/dist/runtime-v2/runner/__tests__/diagnostician-telemetry.test.js +0 -286
  175. package/dist/runtime-v2/runner/__tests__/diagnostician-telemetry.test.js.map +0 -1
  176. package/dist/runtime-v2/runner/__tests__/dual-track-e2e.test.d.ts +0 -2
  177. package/dist/runtime-v2/runner/__tests__/dual-track-e2e.test.d.ts.map +0 -1
  178. package/dist/runtime-v2/runner/__tests__/dual-track-e2e.test.js +0 -320
  179. package/dist/runtime-v2/runner/__tests__/dual-track-e2e.test.js.map +0 -1
  180. package/dist/runtime-v2/runner/__tests__/lease-expiration-recovery.integration.test.d.ts +0 -2
  181. package/dist/runtime-v2/runner/__tests__/lease-expiration-recovery.integration.test.d.ts.map +0 -1
  182. package/dist/runtime-v2/runner/__tests__/lease-expiration-recovery.integration.test.js +0 -261
  183. package/dist/runtime-v2/runner/__tests__/lease-expiration-recovery.integration.test.js.map +0 -1
  184. package/dist/runtime-v2/runner/__tests__/m5-05-e2e.test.d.ts +0 -2
  185. package/dist/runtime-v2/runner/__tests__/m5-05-e2e.test.d.ts.map +0 -1
  186. package/dist/runtime-v2/runner/__tests__/m5-05-e2e.test.js +0 -405
  187. package/dist/runtime-v2/runner/__tests__/m5-05-e2e.test.js.map +0 -1
  188. package/dist/runtime-v2/runner/__tests__/m6-06-e2e.test.d.ts +0 -2
  189. package/dist/runtime-v2/runner/__tests__/m6-06-e2e.test.d.ts.map +0 -1
  190. package/dist/runtime-v2/runner/__tests__/m6-06-e2e.test.js +0 -347
  191. package/dist/runtime-v2/runner/__tests__/m6-06-e2e.test.js.map +0 -1
  192. package/dist/runtime-v2/runner/__tests__/m6-06-legacy.test.d.ts +0 -2
  193. package/dist/runtime-v2/runner/__tests__/m6-06-legacy.test.d.ts.map +0 -1
  194. package/dist/runtime-v2/runner/__tests__/m6-06-legacy.test.js +0 -186
  195. package/dist/runtime-v2/runner/__tests__/m6-06-legacy.test.js.map +0 -1
  196. package/dist/runtime-v2/runner/__tests__/m6-06-real-path.test.d.ts +0 -2
  197. package/dist/runtime-v2/runner/__tests__/m6-06-real-path.test.d.ts.map +0 -1
  198. package/dist/runtime-v2/runner/__tests__/m6-06-real-path.test.js +0 -355
  199. package/dist/runtime-v2/runner/__tests__/m6-06-real-path.test.js.map +0 -1
  200. package/dist/runtime-v2/runner/__tests__/m8-02-e2e.test.d.ts +0 -2
  201. package/dist/runtime-v2/runner/__tests__/m8-02-e2e.test.d.ts.map +0 -1
  202. package/dist/runtime-v2/runner/__tests__/m8-02-e2e.test.js +0 -486
  203. package/dist/runtime-v2/runner/__tests__/m8-02-e2e.test.js.map +0 -1
  204. package/dist/runtime-v2/runner/__tests__/m9-adapter-integration.test.d.ts +0 -2
  205. package/dist/runtime-v2/runner/__tests__/m9-adapter-integration.test.d.ts.map +0 -1
  206. package/dist/runtime-v2/runner/__tests__/m9-adapter-integration.test.js +0 -171
  207. package/dist/runtime-v2/runner/__tests__/m9-adapter-integration.test.js.map +0 -1
  208. package/dist/runtime-v2/runner/__tests__/m9-e2e.test.d.ts +0 -2
  209. package/dist/runtime-v2/runner/__tests__/m9-e2e.test.d.ts.map +0 -1
  210. package/dist/runtime-v2/runner/__tests__/m9-e2e.test.js +0 -175
  211. package/dist/runtime-v2/runner/__tests__/m9-e2e.test.js.map +0 -1
  212. package/dist/runtime-v2/runner/__tests__/max-attempts-exceeded.integration.test.d.ts +0 -2
  213. package/dist/runtime-v2/runner/__tests__/max-attempts-exceeded.integration.test.d.ts.map +0 -1
  214. package/dist/runtime-v2/runner/__tests__/max-attempts-exceeded.integration.test.js +0 -276
  215. package/dist/runtime-v2/runner/__tests__/max-attempts-exceeded.integration.test.js.map +0 -1
  216. package/dist/runtime-v2/runner/__tests__/retry-wait-recovery.integration.test.d.ts +0 -2
  217. package/dist/runtime-v2/runner/__tests__/retry-wait-recovery.integration.test.d.ts.map +0 -1
  218. package/dist/runtime-v2/runner/__tests__/retry-wait-recovery.integration.test.js +0 -272
  219. package/dist/runtime-v2/runner/__tests__/retry-wait-recovery.integration.test.js.map +0 -1
  220. package/dist/runtime-v2/runner/__tests__/start-run-input.test.d.ts +0 -2
  221. package/dist/runtime-v2/runner/__tests__/start-run-input.test.d.ts.map +0 -1
  222. package/dist/runtime-v2/runner/__tests__/start-run-input.test.js +0 -67
  223. package/dist/runtime-v2/runner/__tests__/start-run-input.test.js.map +0 -1
  224. package/dist/runtime-v2/runner/diagnostician-runner-options.d.ts +0 -57
  225. package/dist/runtime-v2/runner/diagnostician-runner-options.d.ts.map +0 -1
  226. package/dist/runtime-v2/runner/diagnostician-runner-options.js +0 -21
  227. package/dist/runtime-v2/runner/diagnostician-runner-options.js.map +0 -1
  228. package/dist/runtime-v2/runner/diagnostician-runner.d.ts +0 -89
  229. package/dist/runtime-v2/runner/diagnostician-runner.d.ts.map +0 -1
  230. package/dist/runtime-v2/runner/diagnostician-runner.js +0 -470
  231. package/dist/runtime-v2/runner/diagnostician-runner.js.map +0 -1
@@ -0,0 +1,127 @@
1
+ /**
2
+ * RouterPromptBuilder — Stage C prompt builder for the split diagnostician pipeline.
3
+ *
4
+ * The Router stage receives both Stage A (Root Cause) and Stage B (Distiller)
5
+ * artifacts and produces the final `DiagnosticianOutputV1` — the unchanged
6
+ * downstream contract consumed by the rest of the system.
7
+ *
8
+ * Unlike the monolithic DiagnosticianPromptBuilder which runs the full 5-phase
9
+ * protocol, the Router does NOT re-derive root causes or invent new principles.
10
+ * It routes what the distiller produced into the appropriate recommendation
11
+ * taxonomy kind(s).
12
+ *
13
+ * @see PRI-372 — Split diagnostician into Stage A (Root Cause) + Stage B (Distiller) + Stage C (Router)
14
+ */
15
+ import type { TSchema } from '@sinclair/typebox';
16
+ import type { SchemaPromptAdapter } from '../adapter/schema-prompt-adapter.js';
17
+ import type { DiagRootCauseOutputV1 } from './diag-rootcause-output.js';
18
+ import type { DiagDistillerOutputV1 } from './diag-distiller-output.js';
19
+ import type { BuildPromptOptions } from '../diagnostician-prompt-builder.js';
20
+ import type { OutputLanguage } from '../language-directive.js';
21
+ /**
22
+ * Options for RouterPromptBuilder constructor and buildRouterInstruction().
23
+ *
24
+ * Uses opts-object pattern to stay within max-params limit and allow
25
+ * partial overrides at both construction and method-call time.
26
+ *
27
+ * @see PRI-372
28
+ */
29
+ export interface RouterPromptBuilderOptions {
30
+ /** Schema prompt adapter (default: DefaultSchemaPromptAdapter) */
31
+ adapter?: SchemaPromptAdapter;
32
+ /** TypeBox schema for output validation (default: DiagnosticianOutputV1Schema) */
33
+ schema?: TSchema;
34
+ /** Output language directive (default: none) */
35
+ outputLanguage?: OutputLanguage;
36
+ }
37
+ /**
38
+ * Structured input for the Router stage, carrying both Stage A and Stage B
39
+ * artifacts with their IDs for lineage tracing.
40
+ *
41
+ * @see PRI-372
42
+ */
43
+ export interface RouterContextInput {
44
+ /** Artifact ID of the Stage A (Root Cause) output */
45
+ rootCauseArtifactId: string;
46
+ /** Stage A output — the root cause analysis result */
47
+ rootCauseOutput: DiagRootCauseOutputV1;
48
+ /** Artifact ID of the Stage B (Distiller) output */
49
+ distillerArtifactId: string;
50
+ /** Stage B output — the distilled principle and grounding */
51
+ distillerOutput: DiagDistillerOutputV1;
52
+ }
53
+ /**
54
+ * Prompt input for the Router stage — the JSON message sent to the LLM.
55
+ *
56
+ * Unlike the monolithic DiagnosticianPromptBuilder's PromptInput, the router
57
+ * carries Stage A and Stage B artifacts directly rather than a full
58
+ * DiagnosticianContextPayload with conversation window and source refs.
59
+ *
60
+ * @see PRI-372
61
+ */
62
+ export interface RouterPromptInput {
63
+ /** Task being diagnosed — from Stage A output */
64
+ taskId: string;
65
+ /** Artifact ID of the Stage A (Root Cause) output for lineage */
66
+ rootCauseArtifactId: string;
67
+ /** Stage A output — root cause analysis result */
68
+ rootCauseOutput: DiagRootCauseOutputV1;
69
+ /** Artifact ID of the Stage B (Distiller) output for lineage */
70
+ distillerArtifactId: string;
71
+ /** Stage B output — distilled principle and grounding */
72
+ distillerOutput: DiagDistillerOutputV1;
73
+ /** Router instruction — the system-level directive for the LLM */
74
+ routerInstruction: string;
75
+ }
76
+ /**
77
+ * Build result for the Router stage — follows the same pattern as PromptBuildResult.
78
+ *
79
+ * @see PRI-372
80
+ */
81
+ export interface RouterPromptBuildResult {
82
+ /** JSON string — the exact value to pass as openclaw agent --message argument */
83
+ readonly message: string;
84
+ /** The RouterPromptInput object that was serialized to JSON */
85
+ readonly promptInput: RouterPromptInput;
86
+ }
87
+ /**
88
+ * Prompt builder for Stage C (Router) of the split diagnostician pipeline.
89
+ *
90
+ * The Router takes the root cause from Stage A and the distilled principle
91
+ * from Stage B, then decides the concrete carrier(s) — the recommendation
92
+ * taxonomy kind(s) — and assembles the final `DiagnosticianOutputV1`.
93
+ *
94
+ * Key constraint: the Router MUST NOT re-derive the root cause or invent
95
+ * new principles. It routes what the distiller produced.
96
+ *
97
+ * @see PRI-372
98
+ */
99
+ export declare class RouterPromptBuilder {
100
+ private readonly adapter;
101
+ private readonly schema;
102
+ constructor(opts?: RouterPromptBuilderOptions);
103
+ /**
104
+ * Build the router instruction string — the system-level directive that
105
+ * tells the LLM its role, input format, routing rules, output requirements,
106
+ * and constraints.
107
+ *
108
+ * @param opts - Optional overrides for adapter, schema, and outputLanguage.
109
+ * When provided, these override the constructor defaults for this call only.
110
+ * @returns The router instruction string.
111
+ *
112
+ * @see PRI-372
113
+ */
114
+ buildRouterInstruction(opts?: RouterPromptBuilderOptions): string;
115
+ /**
116
+ * Build the full prompt for the Router stage, combining the router
117
+ * instruction with the structured Stage A + Stage B context.
118
+ *
119
+ * @param context - Structured input carrying Stage A and Stage B artifacts.
120
+ * @param opts - Build options including outputLanguage.
121
+ * @returns RouterPromptBuildResult with JSON message and RouterPromptInput object.
122
+ *
123
+ * @see PRI-372
124
+ */
125
+ buildPrompt(context: RouterContextInput, opts?: BuildPromptOptions): RouterPromptBuildResult;
126
+ }
127
+ //# sourceMappingURL=router-prompt-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router-prompt-builder.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/diagnostician/router-prompt-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAG/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAK/D;;;;;;;GAOG;AACH,MAAM,WAAW,0BAA0B;IACzC,kEAAkE;IAClE,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,kFAAkF;IAClF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gDAAgD;IAChD,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAID;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,qDAAqD;IACrD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,sDAAsD;IACtD,eAAe,EAAE,qBAAqB,CAAC;IACvC,oDAAoD;IACpD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,6DAA6D;IAC7D,eAAe,EAAE,qBAAqB,CAAC;CACxC;AAID;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB;IAChC,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kDAAkD;IAClD,eAAe,EAAE,qBAAqB,CAAC;IACvC,gEAAgE;IAChE,mBAAmB,EAAE,MAAM,CAAC;IAC5B,yDAAyD;IACzD,eAAe,EAAE,qBAAqB,CAAC;IACvC,kEAAkE;IAClE,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,iFAAiF;IACjF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,+DAA+D;IAC/D,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;CACzC;AAID;;;;;;;;;;;GAWG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsB;IAC9C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;gBAErB,IAAI,GAAE,0BAA+B;IAKjD;;;;;;;;;;OAUG;IACH,sBAAsB,CAAC,IAAI,GAAE,0BAA+B,GAAG,MAAM;IA4DrE;;;;;;;;;OASG;IACH,WAAW,CACT,OAAO,EAAE,kBAAkB,EAC3B,IAAI,GAAE,kBAAuB,GAC5B,uBAAuB;CAkB3B"}
@@ -0,0 +1,131 @@
1
+ /**
2
+ * RouterPromptBuilder — Stage C prompt builder for the split diagnostician pipeline.
3
+ *
4
+ * The Router stage receives both Stage A (Root Cause) and Stage B (Distiller)
5
+ * artifacts and produces the final `DiagnosticianOutputV1` — the unchanged
6
+ * downstream contract consumed by the rest of the system.
7
+ *
8
+ * Unlike the monolithic DiagnosticianPromptBuilder which runs the full 5-phase
9
+ * protocol, the Router does NOT re-derive root causes or invent new principles.
10
+ * It routes what the distiller produced into the appropriate recommendation
11
+ * taxonomy kind(s).
12
+ *
13
+ * @see PRI-372 — Split diagnostician into Stage A (Root Cause) + Stage B (Distiller) + Stage C (Router)
14
+ */
15
+ import { DefaultSchemaPromptAdapter } from '../adapter/schema-prompt-adapter.js';
16
+ import { DiagnosticianOutputV1Schema } from '../diagnostician-output.js';
17
+ import { buildLanguageDirective } from '../language-directive.js';
18
+ // ── Builder class ────────────────────────────────────────────────────────────
19
+ /**
20
+ * Prompt builder for Stage C (Router) of the split diagnostician pipeline.
21
+ *
22
+ * The Router takes the root cause from Stage A and the distilled principle
23
+ * from Stage B, then decides the concrete carrier(s) — the recommendation
24
+ * taxonomy kind(s) — and assembles the final `DiagnosticianOutputV1`.
25
+ *
26
+ * Key constraint: the Router MUST NOT re-derive the root cause or invent
27
+ * new principles. It routes what the distiller produced.
28
+ *
29
+ * @see PRI-372
30
+ */
31
+ export class RouterPromptBuilder {
32
+ adapter;
33
+ schema;
34
+ constructor(opts = {}) {
35
+ this.adapter = opts.adapter ?? new DefaultSchemaPromptAdapter();
36
+ this.schema = opts.schema ?? DiagnosticianOutputV1Schema;
37
+ }
38
+ /**
39
+ * Build the router instruction string — the system-level directive that
40
+ * tells the LLM its role, input format, routing rules, output requirements,
41
+ * and constraints.
42
+ *
43
+ * @param opts - Optional overrides for adapter, schema, and outputLanguage.
44
+ * When provided, these override the constructor defaults for this call only.
45
+ * @returns The router instruction string.
46
+ *
47
+ * @see PRI-372
48
+ */
49
+ buildRouterInstruction(opts = {}) {
50
+ const adapter = opts.adapter ?? this.adapter;
51
+ const schema = opts.schema ?? this.schema;
52
+ const { outputLanguage } = opts;
53
+ const example = adapter.generateExample(schema);
54
+ const constraints = adapter.generateConstraints(schema);
55
+ const languageDirective = buildLanguageDirective(outputLanguage);
56
+ return `You are a principle router. Your job is to take an abstracted principle and root cause, and decide the concrete carrier(s).
57
+
58
+ INPUT:
59
+ You receive two structured artifacts:
60
+ 1. Stage A Root Cause output — contains the causal chain, root cause classification, and evidence.
61
+ 2. Stage B Distiller output — contains the abstracted principle, rationale, core axiom grounding, scope, and confidence.
62
+
63
+ ROUTING RULES:
64
+ Based on the distiller's abstracted principle and the root cause from Stage A, decide the recommendation kind:
65
+
66
+ - If the principle is broadly applicable across scenarios → kind: "principle"
67
+ (MUST include abstractedPrinciple field)
68
+ - If a specific trigger pattern can be identified for deterministic interception → kind: "rule"
69
+ (MUST include triggerPattern and action fields)
70
+ - If code/tool enforcement is possible and practical → kind: "implementation"
71
+ - If a prompt directive can enforce the behavior → kind: "prompt"
72
+ - If insufficient confidence or the finding is too specific/single-instance → kind: "defer"
73
+
74
+ Default: "principle" is the preferred kind. Only use "defer" for noise signals or genuinely insufficient evidence.
75
+
76
+ OUTPUT REQUIREMENTS:
77
+ Your output MUST match DiagnosticianOutputV1Schema. You only need to generate these fields:
78
+
79
+ - violatedPrinciples: array of violated principles, derived from Stage A's rootCause + Stage B's grounding
80
+ - title: short descriptive name for the violated principle (REQUIRED, 3-8 words)
81
+ - principleId: if the principle corresponds to a core axiom (e.g. T-01 through T-10), include the axiom ID; otherwise omit
82
+ - rationale: explanation of why this principle was violated (REQUIRED)
83
+ - recommendations: one or more entries with the appropriate kind from the routing rules above
84
+ - summary: a concise summary combining Stage A's root cause and Stage B's abstracted principle
85
+
86
+ The following fields are auto-filled by the system from upstream artifacts — do NOT generate them:
87
+ - rootCause (copied from Stage A)
88
+ - evidence (copied from Stage A)
89
+ - confidence (copied from Stage B)
90
+
91
+ CONSTRAINT:
92
+ You MUST NOT re-derive the root cause or invent new principles. Route what the distiller produced.
93
+
94
+ CRITICAL: Your ENTIRE response must be ONLY the JSON object below. Do NOT include any text before or after the JSON. Do NOT wrap the JSON in markdown code fences. Do NOT add explanatory prose. Output the raw JSON object and nothing else.
95
+
96
+ COMPLETE EXAMPLE OUTPUT (follow this exact structure):
97
+ ${example}
98
+
99
+ IMPORTANT: The example above is ILLUSTRATIVE ONLY. Your output MUST be based on the actual Stage A and Stage B data provided — do not copy the example text verbatim.
100
+
101
+ CONSTRAINTS:
102
+ - Output ONLY valid JSON — no markdown, no explanatory text, no code fences, no prose before or after
103
+ - Do NOT read files, call tools, or write to any database
104
+ ${constraints}${languageDirective}`;
105
+ }
106
+ /**
107
+ * Build the full prompt for the Router stage, combining the router
108
+ * instruction with the structured Stage A + Stage B context.
109
+ *
110
+ * @param context - Structured input carrying Stage A and Stage B artifacts.
111
+ * @param opts - Build options including outputLanguage.
112
+ * @returns RouterPromptBuildResult with JSON message and RouterPromptInput object.
113
+ *
114
+ * @see PRI-372
115
+ */
116
+ buildPrompt(context, opts = {}) {
117
+ const { outputLanguage } = opts;
118
+ const routerInstruction = this.buildRouterInstruction({ outputLanguage });
119
+ const promptInput = {
120
+ taskId: context.rootCauseOutput.taskId,
121
+ rootCauseArtifactId: context.rootCauseArtifactId,
122
+ rootCauseOutput: context.rootCauseOutput,
123
+ distillerArtifactId: context.distillerArtifactId,
124
+ distillerOutput: context.distillerOutput,
125
+ routerInstruction,
126
+ };
127
+ const message = JSON.stringify(promptInput);
128
+ return { message, promptInput };
129
+ }
130
+ }
131
+ //# sourceMappingURL=router-prompt-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router-prompt-builder.js","sourceRoot":"","sources":["../../../src/runtime-v2/diagnostician/router-prompt-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAKzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AA8ElE,gFAAgF;AAEhF;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,mBAAmB;IACb,OAAO,CAAsB;IAC7B,MAAM,CAAU;IAEjC,YAAY,OAAmC,EAAE;QAC/C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,0BAA0B,EAAE,CAAC;QAChE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,2BAA2B,CAAC;IAC3D,CAAC;IAED;;;;;;;;;;OAUG;IACH,sBAAsB,CAAC,OAAmC,EAAE;QAC1D,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC;QAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;QAC1C,MAAM,EAAC,cAAc,EAAC,GAAG,IAAI,CAAC;QAE9B,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QAChD,MAAM,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;QACxD,MAAM,iBAAiB,GAAG,sBAAsB,CAAC,cAAc,CAAC,CAAC;QAEjE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCT,OAAO;;;;;;;EAOP,WAAW,GAAG,iBAAiB,EAAE,CAAC;IAClC,CAAC;IAED;;;;;;;;;OASG;IACH,WAAW,CACT,OAA2B,EAC3B,OAA2B,EAAE;QAE7B,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;QAEhC,MAAM,iBAAiB,GAAG,IAAI,CAAC,sBAAsB,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC;QAE1E,MAAM,WAAW,GAAsB;YACrC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,MAAM;YACtC,mBAAmB,EAAE,OAAO,CAAC,mBAAmB;YAChD,eAAe,EAAE,OAAO,CAAC,eAAe;YACxC,mBAAmB,EAAE,OAAO,CAAC,mBAAmB;YAChD,eAAe,EAAE,OAAO,CAAC,eAAe;YACxC,iBAAiB;SAClB,CAAC;QAEF,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAE5C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;IAClC,CAAC;CACF"}
@@ -4,32 +4,14 @@
4
4
  * Phase: m6-03
5
5
  * Requirements: DPB-01, DPB-02, DPB-03, DPB-04, DPB-05
6
6
  *
7
- * ## Contract
8
- *
9
- * buildPrompt() takes DiagnosticianContextPayload and returns a JSON string
10
- * to be passed as `openclaw agent --message <json>`.
11
- *
12
7
  * ## Output Structure (DPB-06)
13
8
  *
14
9
  * PromptInput has explicit top-level fields (taskId, contextHash, diagnosisTarget,
15
10
  * conversationWindow, sourceRefs) plus nested `context: DiagnosticianContextPayload`.
16
11
  *
17
- * ## Diagnostic Instruction (5 Whys / Root Cause Protocol)
18
- *
19
- * Per SKILL.md (pd-diagnostician): The LLM MUST follow the 5-phase protocol
20
- * (Phase 0 context → Phase 1 evidence → Phase 2 causal chain → Phase 3 classification
21
- * → Phase 4 principle extraction). The diagnosticInstruction field makes this explicit
22
- * so the LLM follows the protocol even if OpenClaw does not load SKILL.md automatically.
23
- *
24
- * ## Constraints (LOCKED)
25
- *
26
- * - DPB-02: Output is ONLY JSON — no markdown, no file ops, no tool calls
27
- * - DPB-07: NO extraSystemPrompt field — system prompt is agent profile's responsibility
28
- * - DPB-05: LLM only analyzes — PD database commits are handled by caller code
12
+ * (Note: monolithic DiagnosticianPromptBuilder and buildDiagnosticProtocolInstruction have been deleted per PRI-373).
29
13
  */
30
14
  import type { DiagnosticianContextPayload, HistoryQueryEntry, DiagnosisTarget } from './context-payload.js';
31
- import type { TSchema } from '@sinclair/typebox';
32
- import type { SchemaPromptAdapter } from './adapter/schema-prompt-adapter.js';
33
15
  import type { OutputLanguage } from './language-directive.js';
34
16
  /** Options for DiagnosticianPromptBuilder.buildPrompt() beyond the required payload. */
35
17
  export interface BuildPromptOptions {
@@ -98,32 +80,6 @@ export interface PromptBuildResult {
98
80
  /** The PromptInput object that was serialized to JSON */
99
81
  readonly promptInput: PromptInput;
100
82
  }
101
- /**
102
- * Options for buildDiagnosticProtocolInstruction.
103
- * Uses an options object to stay within max-params limit.
104
- */
105
- export interface DiagnosticProtocolInstructionOptions {
106
- /** Schema prompt adapter (default: DefaultSchemaPromptAdapter) */
107
- adapter?: SchemaPromptAdapter;
108
- /** TypeBox schema for output validation (default: DiagnosticianOutputV1Schema) */
109
- schema?: TSchema;
110
- /** Output language directive (default: none) */
111
- outputLanguage?: OutputLanguage;
112
- /** T-E (PRI-371): Inject core axiom grounding as PHASE 3.5 (default: false) */
113
- coreGrounding?: boolean;
114
- }
115
- /**
116
- * 5-phase diagnostic protocol instruction for the LLM.
117
- *
118
- * Per DPB-02 (LOCKED): Output is ONLY JSON — no markdown, no file ops, no tool calls.
119
- * Per DPB-04: LLM can only analyze the context provided in the prompt; it must NOT
120
- * read files, call tools, or write to databases. All evidence must be drawn from
121
- * the context payload (sourceRefs, conversationWindow).
122
- *
123
- * The 5-phase protocol is embedded directly in the prompt so the LLM follows it
124
- * regardless of whether OpenClaw loads SKILL.md as the agent system prompt.
125
- */
126
- export declare function buildDiagnosticProtocolInstruction(opts?: DiagnosticProtocolInstructionOptions): string;
127
83
  /**
128
84
  * Summarizes a conversation window for inclusion in the prompt.
129
85
  * DPB-04: Prompt includes conversationWindow summary.
@@ -132,23 +88,4 @@ export declare function buildDiagnosticProtocolInstruction(opts?: DiagnosticProt
132
88
  * Subclasses or configuration can provide condensation logic.
133
89
  */
134
90
  export declare function summarizeConversationWindow(entries: HistoryQueryEntry[]): HistoryQueryEntry[];
135
- export declare class DiagnosticianPromptBuilder {
136
- private readonly adapter;
137
- private readonly schema;
138
- constructor(adapter?: SchemaPromptAdapter, schema?: TSchema);
139
- /**
140
- * Transform DiagnosticianContextPayload into a PromptInput object,
141
- * then serialize to JSON for the --message argument.
142
- *
143
- * @param payload — DiagnosticianContextPayload from context assembly (DPB-01)
144
- * @param opts — Build options (limits, outputLanguage, coreGrounding)
145
- * @returns PromptBuildResult with JSON string + PromptInput object (DPB-02, DPB-03, DPB-04, DPB-06)
146
- *
147
- * Per DPB-05: This method only builds the prompt; it does NOT commit to PD database.
148
- * The caller (DiagnosticianRunner or CLI layer) handles database commits.
149
- *
150
- * Per DPB-07: NO extraSystemPrompt is added — agent profile is the source of truth.
151
- */
152
- buildPrompt(payload: DiagnosticianContextPayload, opts?: BuildPromptOptions): PromptBuildResult;
153
- }
154
91
  //# sourceMappingURL=diagnostician-prompt-builder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostician-prompt-builder.d.ts","sourceRoot":"","sources":["../../src/runtime-v2/diagnostician-prompt-builder.ts"],"names":[],"mappings":"AAAA;;;;;;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F;IACjF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;CACnC;AAED;;;GAGG;AACH,MAAM,WAAW,oCAAoC;IACnD,kEAAkE;IAClE,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,kFAAkF;IAClF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gDAAgD;IAChD,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,+EAA+E;IAC/E,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kCAAkC,CAChD,IAAI,GAAE,oCAAyC,GAC9C,MAAM,CAgFR;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,iBAAiB,EAAE,GAC3B,iBAAiB,EAAE,CAErB;AAED,qBAAa,0BAA0B;IACrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsB;IAC9C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;gBAG/B,OAAO,GAAE,mBAAsD,EAC/D,MAAM,GAAE,OAAqC;IAM/C;;;;;;;;;;;;OAYG;IACH,WAAW,CACT,OAAO,EAAE,2BAA2B,EACpC,IAAI,GAAE,kBAAuB,GAC5B,iBAAiB;CAuFrB"}
1
+ {"version":3,"file":"diagnostician-prompt-builder.d.ts","sourceRoot":"","sources":["../../src/runtime-v2/diagnostician-prompt-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EACV,2BAA2B,EAC3B,iBAAiB,EACjB,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,wFAAwF;AACxF,MAAM,WAAW,kBAAkB;IACjC,qFAAqF;IACrF,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,gDAAgD;IAChD,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,+EAA+E;IAC/E,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,eAAe,EAAE,eAAe,CAAC;IACjC;;;;OAIG;IACH,kBAAkB,EAAE,iBAAiB,EAAE,CAAC;IACxC,0CAA0C;IAC1C,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,kEAAkE;IAClE,OAAO,EAAE,2BAA2B,CAAC;IACrC;;;;;OAKG;IACH,qBAAqB,EAAE,MAAM,CAAC;IAC9B,kFAAkF;IAClF,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED,+DAA+D;AAC/D,MAAM,WAAW,mBAAmB;IAClC,2DAA2D;IAC3D,sBAAsB,EAAE,MAAM,CAAC;IAC/B,wDAAwD;IACxD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,wDAAwD;IACxD,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,6BAA6B,EAAE,mBAIlC,CAAC;AAEX;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,iFAAiF;IACjF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;CACnC;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,iBAAiB,EAAE,GAC3B,iBAAiB,EAAE,CAErB"}
@@ -1,101 +1,8 @@
1
- import { DefaultSchemaPromptAdapter } from './adapter/schema-prompt-adapter.js';
2
- import { DiagnosticianOutputV1Schema } from './diagnostician-output.js';
3
- import { buildLanguageDirective } from './language-directive.js';
4
- import { CORE_PRINCIPLES } from './core-principles/core-principle-registry.js';
5
1
  export const DEFAULT_PROMPT_BUILDER_LIMITS = {
6
2
  maxConversationEntries: 30,
7
3
  maxEntryTextChars: 2000,
8
4
  maxMessageChars: 80_000,
9
5
  };
10
- /**
11
- * 5-phase diagnostic protocol instruction for the LLM.
12
- *
13
- * Per DPB-02 (LOCKED): Output is ONLY JSON — no markdown, no file ops, no tool calls.
14
- * Per DPB-04: LLM can only analyze the context provided in the prompt; it must NOT
15
- * read files, call tools, or write to databases. All evidence must be drawn from
16
- * the context payload (sourceRefs, conversationWindow).
17
- *
18
- * The 5-phase protocol is embedded directly in the prompt so the LLM follows it
19
- * regardless of whether OpenClaw loads SKILL.md as the agent system prompt.
20
- */
21
- export function buildDiagnosticProtocolInstruction(opts = {}) {
22
- const adapter = opts.adapter ?? new DefaultSchemaPromptAdapter();
23
- const schema = opts.schema ?? DiagnosticianOutputV1Schema;
24
- const { outputLanguage, coreGrounding } = opts;
25
- const example = adapter.generateExample(schema);
26
- const constraints = adapter.generateConstraints(schema);
27
- const languageDirective = buildLanguageDirective(outputLanguage);
28
- // T-E (PRI-371): When coreGrounding is true, insert PHASE 3.5 between
29
- // PHASE 3 and PHASE 4. When false or undefined, output is byte-identical
30
- // to the original (EP-03: no silent fallback).
31
- const phase35Block = coreGrounding
32
- ? `
33
- PHASE 3.5 — Core Axiom Grounding:
34
- The following core axioms are the system's foundational behavioral principles.
35
- If the root cause relates to any of these axioms, note the axiom ID (e.g. T-01)
36
- in the ambiguityNotes field of your output.
37
-
38
- Core Axioms:
39
- ${CORE_PRINCIPLES.map(p => `${p.id}: ${p.statement}`).join('\n')}
40
-
41
- `
42
- : '\n';
43
- return `You are a root cause analysis expert. Follow this protocol:
44
-
45
- PHASE 1 — Evidence Review:
46
- Review the provided sourceRefs, diagnosisTarget.evidence entries, and conversationWindow
47
- entries from the context payload. Do NOT read any files or call any tools.
48
- Record all evidence by referencing the sourceRef identifiers and conversation
49
- entries already present in the context. Each evidence item must cite its source.
50
- Pay special attention to diagnosisTarget.evidence — these are the primary behavioral
51
- evidence (owner messages and agent actions) that the root cause analysis must address.
52
-
53
- PHASE 2 — Causal Chain (5 Whys):
54
- Build a Why-1 through Why-5 causal chain. Each Why MUST have evidence from Phase 1.
55
- - Why 1: Surface phenomenon (visible error)
56
- - Why 2: Direct cause (nearest trigger)
57
- - Why 3: Process gap (missing check/gate)
58
- - Why 4: Design flaw (why gap exists)
59
- - Why 5: Root cause (systemic defect)
60
- Stop early if you find a directly fixable problem.
61
-
62
- PHASE 3 — Root Cause Classification:
63
- Classify into ONE: People | Design | Assumption | Tooling
64
- - People: capability blind spots, habit issues
65
- - Design: architecture defects, missing gates, process gaps
66
- - Assumption: wrong assumptions about env/versions/deps
67
- - Tooling: tool misconfiguration, API changes
68
- ${phase35Block}PHASE 4 — Recommendation Taxonomy & Distillation:
69
- Analyze the root cause and propose actionable recommendations. Classify each recommendation into one of FIVE categories based on the taxonomy below.
70
-
71
- TAXONOMY DEFINITIONS:
72
- 1. "rule": Deterministic constraints. Use for specific tool blocks or path protections. A "rule" MUST have a precise 'triggerPattern' and 'action' for physical interception.
73
- 2. "principle": Abstract, reusable wisdom. Use for high-level architectural guidelines. MUST have 'abstractedPrinciple'.
74
- 3. "implementation": Code-level candidate. Use for extremely specific code patches.
75
- 4. "prompt": Context/Skill injection. Use to influence the agent's workflow habits.
76
- 5. "defer": Insufficient evidence. Use for network timeouts or noise.
77
-
78
- EVIDENCE SCOPE GUARD:
79
- - The root cause MUST describe an agent behavior or decision, not a system monitoring or diagnostic mechanism.
80
- - If the evidence only describes internal metrics (GFI, friction scores, threshold crossings) with no
81
- owner message or agent action context, return confidence < 0.3 and kind="defer".
82
- - If diagnosisTarget.evidence is an empty array (length === 0), you MUST NOT fabricate evidence entries.
83
- You MUST output confidence < 0.3 and kind = "defer".
84
- Set description to: "Insufficient evidence: diagnosisTarget.evidence is empty.
85
- Re-trigger diagnosis after evidence is collected."
86
-
87
- CRITICAL: Your ENTIRE response must be ONLY the JSON object below. Do NOT include any text before or after the JSON. Do NOT wrap the JSON in markdown code fences. Do NOT add explanatory prose. Output the raw JSON object and nothing else.
88
-
89
- COMPLETE EXAMPLE OUTPUT (follow this exact structure):
90
- ${example}
91
-
92
- IMPORTANT: The example above is ILLUSTRATIVE ONLY. Your recommendations MUST be based on the actual root cause analysis and evidence in this context — do not copy the example text verbatim.
93
-
94
- CONSTRAINTS:
95
- - Output ONLY valid JSON — no markdown, no explanatory text, no code fences, no prose before or after
96
- - Do NOT read files, call tools, or write to any database
97
- ${constraints}${languageDirective}`;
98
- }
99
6
  /**
100
7
  * Summarizes a conversation window for inclusion in the prompt.
101
8
  * DPB-04: Prompt includes conversationWindow summary.
@@ -106,97 +13,4 @@ ${constraints}${languageDirective}`;
106
13
  export function summarizeConversationWindow(entries) {
107
14
  return entries;
108
15
  }
109
- export class DiagnosticianPromptBuilder {
110
- adapter;
111
- schema;
112
- constructor(adapter = new DefaultSchemaPromptAdapter(), schema = DiagnosticianOutputV1Schema) {
113
- this.adapter = adapter;
114
- this.schema = schema;
115
- }
116
- /**
117
- * Transform DiagnosticianContextPayload into a PromptInput object,
118
- * then serialize to JSON for the --message argument.
119
- *
120
- * @param payload — DiagnosticianContextPayload from context assembly (DPB-01)
121
- * @param opts — Build options (limits, outputLanguage, coreGrounding)
122
- * @returns PromptBuildResult with JSON string + PromptInput object (DPB-02, DPB-03, DPB-04, DPB-06)
123
- *
124
- * Per DPB-05: This method only builds the prompt; it does NOT commit to PD database.
125
- * The caller (DiagnosticianRunner or CLI layer) handles database commits.
126
- *
127
- * Per DPB-07: NO extraSystemPrompt is added — agent profile is the source of truth.
128
- */
129
- buildPrompt(payload, opts = {}) {
130
- const limits = opts.limits ?? DEFAULT_PROMPT_BUILDER_LIMITS;
131
- const { outputLanguage, coreGrounding } = opts;
132
- const truncationWarnings = [];
133
- // DPB-04: Apply truncation to conversationWindow to prevent token overflow
134
- const rawWindow = summarizeConversationWindow(payload.conversationWindow);
135
- const windowEntries = rawWindow.slice(0, limits.maxConversationEntries);
136
- if (rawWindow.length > limits.maxConversationEntries) {
137
- truncationWarnings.push(`conversationWindow truncated from ${rawWindow.length} to ${limits.maxConversationEntries} entries`);
138
- }
139
- // Truncate individual entry text
140
- const conversationWindow = windowEntries.map((entry) => {
141
- if (entry.text && entry.text.length > limits.maxEntryTextChars) {
142
- return {
143
- ...entry,
144
- text: entry.text.slice(0, limits.maxEntryTextChars) + '...[truncated]',
145
- };
146
- }
147
- return entry;
148
- });
149
- // Build compact context — replace conversationWindow with truncated version
150
- // to avoid duplicating full content at top-level AND in context
151
- const compactContext = {
152
- ...payload,
153
- conversationWindow,
154
- };
155
- const diagnosticInstruction = buildDiagnosticProtocolInstruction({
156
- adapter: this.adapter,
157
- schema: this.schema,
158
- outputLanguage,
159
- coreGrounding,
160
- });
161
- // DPB-04: Explicit top-level fields at the prompt level
162
- const promptInput = {
163
- taskId: payload.taskId,
164
- contextHash: payload.contextHash,
165
- diagnosisTarget: payload.diagnosisTarget,
166
- conversationWindow,
167
- sourceRefs: payload.sourceRefs,
168
- context: compactContext,
169
- diagnosticInstruction,
170
- ...(truncationWarnings.length > 0 ? { truncationWarnings } : {}),
171
- };
172
- // DPB-02: Output is ONLY JSON — no markdown, no file ops, no tool calls
173
- // DPB-03: JSON must conform to what DiagnosticianOutputV1 expects (caller validates)
174
- let message = JSON.stringify(promptInput);
175
- // If message exceeds maxMessageChars, truncate the diagnostic instruction
176
- // PRI-342: Extract and preserve EVIDENCE SCOPE GUARD before truncating
177
- if (message.length > limits.maxMessageChars) {
178
- const surplus = message.length - limits.maxMessageChars;
179
- const instruction = diagnosticInstruction;
180
- // Extract EVIDENCE SCOPE GUARD to preserve it through truncation
181
- const guardMatch = /EVIDENCE SCOPE GUARD:\s*[\s\S]*?(?=\nCRITICAL:|\nCOMPLETE EXAMPLE)/.exec(instruction);
182
- const guardBlock = guardMatch ? guardMatch[0] : '';
183
- // Keep at least the first 200 chars of the instruction + a note
184
- const keepLength = Math.max(200, instruction.length - surplus - 100);
185
- let truncatedInstruction = instruction.slice(0, keepLength) +
186
- '\n\n[OUTPUT FORMAT section is REQUIRED; other sections may be summarized if needed]';
187
- // If the guard block was cut off by truncation, re-append it
188
- if (guardBlock && !truncatedInstruction.includes('EVIDENCE SCOPE GUARD')) {
189
- truncatedInstruction = truncatedInstruction +
190
- `\n\n${guardBlock}`;
191
- }
192
- promptInput.diagnosticInstruction = truncatedInstruction;
193
- promptInput.truncationWarnings = [
194
- ...truncationWarnings,
195
- `diagnosticInstruction truncated due to size (${message.length} > ${limits.maxMessageChars})`,
196
- ];
197
- message = JSON.stringify(promptInput);
198
- }
199
- return { message, promptInput };
200
- }
201
- }
202
16
  //# sourceMappingURL=diagnostician-prompt-builder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostician-prompt-builder.js","sourceRoot":"","sources":["../../src/runtime-v2/diagnostician-prompt-builder.ts"],"names":[],"mappings":"AAoCA,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAExE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AA2D/E,MAAM,CAAC,MAAM,6BAA6B,GAAwB;IAChE,sBAAsB,EAAE,EAAE;IAC1B,iBAAiB,EAAE,IAAI;IACvB,eAAe,EAAE,MAAM;CACf,CAAC;AA8BX;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kCAAkC,CAChD,OAA6C,EAAE;IAE/C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,0BAA0B,EAAE,CAAC;IACjE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,2BAA2B,CAAC;IAC1D,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC;IAE/C,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAChD,MAAM,WAAW,GAAG,OAAO,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nostician-prompt-builder.js","sourceRoot":"","sources":["../../src/runtime-v2/diagnostician-prompt-builder.ts"],"names":[],"mappings":"AA6EA,MAAM,CAAC,MAAM,6BAA6B,GAAwB;IAChE,sBAAsB,EAAE,EAAE;IAC1B,iBAAiB,EAAE,IAAI;IACvB,eAAe,EAAE,MAAM;CACf,CAAC;AAeX;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CACzC,OAA4B;IAE5B,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -184,6 +184,12 @@ describe('computeEffectiveFlags', () => {
184
184
  continue;
185
185
  if (flag.id === 'correction_observer')
186
186
  continue;
187
+ if (flag.id === 'diagnostician_async_cli')
188
+ continue;
189
+ if (flag.id === 'diagnostician_core_grounding')
190
+ continue;
191
+ if (flag.id === 'diagnostician_split_pipeline')
192
+ continue;
187
193
  expect(flag.enabled, `quiet flag ${flag.id} should default off`).toBe(false);
188
194
  }
189
195
  });
@@ -211,7 +217,7 @@ describe('computeEffectiveFlags', () => {
211
217
  it('disables diagnostician_split_pipeline when diagnostician_async_cli is not enabled', () => {
212
218
  const userFlags = {
213
219
  diagnostician_split_pipeline: { enabled: true },
214
- // diagnostician_async_cli NOT enabled
220
+ diagnostician_async_cli: { enabled: false },
215
221
  };
216
222
  const result = computeEffectiveFlags(userFlags, DEFAULT_FEATURE_FLAGS, '/test/.pd/feature-flags.yaml');
217
223
  const splitFlag = result.flags.diagnostician_split_pipeline;
@@ -322,31 +328,31 @@ describe('DEFAULT_FEATURE_FLAGS', () => {
322
328
  expect(flag.since).toBe('2026-06-06');
323
329
  expect(flag.description).toContain('PEAT-B1');
324
330
  });
325
- it('PRI-369: diagnostician_async_cli is registered as quiet, default-off', () => {
331
+ it('PRI-369: diagnostician_async_cli is registered as quiet, default-on', () => {
326
332
  const flag = DEFAULT_FEATURE_FLAGS.find(f => f.id === 'diagnostician_async_cli');
327
333
  expect(flag).toBeDefined();
328
334
  if (!flag)
329
335
  throw new Error('diagnostician_async_cli flag not found');
330
336
  expect(flag.category).toBe('quiet');
331
- expect(flag.enabled).toBe(false);
337
+ expect(flag.enabled).toBe(true);
332
338
  expect(flag.since).toBe('2026-06-11');
333
339
  expect(flag.description).toContain('Async pain-record CLI');
334
340
  });
335
- it('PRI-369: diagnostician_core_grounding is registered as quiet, default-off', () => {
341
+ it('PRI-369: diagnostician_core_grounding is registered as quiet, default-on', () => {
336
342
  const flag = DEFAULT_FEATURE_FLAGS.find(f => f.id === 'diagnostician_core_grounding');
337
343
  expect(flag).toBeDefined();
338
344
  if (!flag)
339
345
  throw new Error('diagnostician_core_grounding flag not found');
340
346
  expect(flag.category).toBe('quiet');
341
- expect(flag.enabled).toBe(false);
347
+ expect(flag.enabled).toBe(true);
342
348
  });
343
- it('PRI-369: diagnostician_split_pipeline is registered as quiet, default-off', () => {
349
+ it('PRI-369: diagnostician_split_pipeline is registered as quiet, default-on', () => {
344
350
  const flag = DEFAULT_FEATURE_FLAGS.find(f => f.id === 'diagnostician_split_pipeline');
345
351
  expect(flag).toBeDefined();
346
352
  if (!flag)
347
353
  throw new Error('diagnostician_split_pipeline flag not found');
348
354
  expect(flag.category).toBe('quiet');
349
- expect(flag.enabled).toBe(false);
355
+ expect(flag.enabled).toBe(true);
350
356
  });
351
357
  });
352
358
  describe('VALID_CATEGORIES', () => {