create-principles-disciple 1.101.0 → 1.102.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/index.js +9 -0
  2. package/console/dist/server/models/ActivationsConsoleModel.d.ts +37 -1
  3. package/console/dist/server/models/ActivationsConsoleModel.js +114 -13
  4. package/console/dist/server/routes/onboarding.d.ts +34 -0
  5. package/console/dist/server/routes/onboarding.js +324 -0
  6. package/console/dist/ui/App.js +74 -15
  7. package/console/dist/ui/api.d.ts +17 -1
  8. package/console/dist/ui/api.js +6 -1
  9. package/console/dist/ui/components/onboarding/CircuitDiagram.d.ts +8 -0
  10. package/console/dist/ui/components/onboarding/CircuitDiagram.js +18 -0
  11. package/console/dist/ui/components/onboarding/DemoResultView.d.ts +22 -0
  12. package/console/dist/ui/components/onboarding/DemoResultView.js +15 -0
  13. package/console/dist/ui/i18n/en.json +127 -0
  14. package/console/dist/ui/i18n/zh-CN.json +127 -0
  15. package/console/dist/ui/pages/activation/ActivationValidators.js +1 -1
  16. package/console/dist/ui/pages/control-center/AgentCard.js +10 -3
  17. package/console/dist/ui/pages/control-center/ControlCenterPage.js +1 -1
  18. package/console/dist/ui/pages/settings/SettingsPage.js +64 -5
  19. package/console/dist/ui/pages/signal-keywords/KeywordEditDialog.d.ts +12 -0
  20. package/console/dist/ui/pages/signal-keywords/KeywordEditDialog.js +41 -0
  21. package/console/dist/ui/pages/signal-keywords/KeywordListSection.d.ts +10 -0
  22. package/console/dist/ui/pages/signal-keywords/KeywordListSection.js +39 -0
  23. package/console/dist/ui/pages/signal-keywords/PendingTermsSection.d.ts +14 -0
  24. package/console/dist/ui/pages/signal-keywords/PendingTermsSection.js +35 -0
  25. package/console/dist/ui/pages/signal-keywords/SignalKeywordsPage.d.ts +1 -0
  26. package/console/dist/ui/pages/signal-keywords/SignalKeywordsPage.js +49 -0
  27. package/console/dist/ui/pages/welcome/WelcomePage.d.ts +5 -0
  28. package/console/dist/ui/pages/welcome/WelcomePage.js +185 -0
  29. package/console/dist/ui/utils/__tests__/onboarding-state.test.d.ts +1 -0
  30. package/console/dist/ui/utils/__tests__/onboarding-state.test.js +72 -0
  31. package/console/dist/ui/utils/agent-metadata.d.ts +13 -0
  32. package/console/dist/ui/utils/agent-metadata.js +26 -0
  33. package/console/dist/ui/utils/onboarding-state.d.ts +25 -0
  34. package/console/dist/ui/utils/onboarding-state.js +77 -0
  35. package/console/dist/ui/utils/signal-keywords-api.d.ts +68 -0
  36. package/console/dist/ui/utils/signal-keywords-api.js +121 -0
  37. package/console/dist/ui/utils/signal-keywords-types.d.ts +57 -0
  38. package/console/dist/ui/utils/signal-keywords-types.js +10 -0
  39. package/console/dist/ui/utils/signal-keywords-validators.d.ts +20 -0
  40. package/console/dist/ui/utils/signal-keywords-validators.js +114 -0
  41. package/console/dist/web/assets/app.css +401 -0
  42. package/console/dist/web/assets/app.js +6904 -1835
  43. package/core/dist/index.d.ts +2 -0
  44. package/core/dist/index.d.ts.map +1 -1
  45. package/core/dist/index.js +1 -0
  46. package/core/dist/index.js.map +1 -1
  47. package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +14 -2
  48. package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
  49. package/core/dist/runtime-v2/__tests__/evaluator-runner-vslice-v2.test.js +28 -0
  50. package/core/dist/runtime-v2/__tests__/evaluator-runner-vslice-v2.test.js.map +1 -1
  51. package/core/dist/runtime-v2/__tests__/pain-to-principle-service.test.js +8 -0
  52. package/core/dist/runtime-v2/__tests__/pain-to-principle-service.test.js.map +1 -1
  53. package/core/dist/runtime-v2/activation/index.d.ts +1 -1
  54. package/core/dist/runtime-v2/activation/index.d.ts.map +1 -1
  55. package/core/dist/runtime-v2/activation/index.js +1 -1
  56. package/core/dist/runtime-v2/activation/index.js.map +1 -1
  57. package/core/dist/runtime-v2/activation/writers/__tests__/rule-host-writer.test.js +240 -1
  58. package/core/dist/runtime-v2/activation/writers/__tests__/rule-host-writer.test.js.map +1 -1
  59. package/core/dist/runtime-v2/activation/writers/rule-host-writer.d.ts +12 -0
  60. package/core/dist/runtime-v2/activation/writers/rule-host-writer.d.ts.map +1 -1
  61. package/core/dist/runtime-v2/activation/writers/rule-host-writer.js +81 -1
  62. package/core/dist/runtime-v2/activation/writers/rule-host-writer.js.map +1 -1
  63. package/core/dist/runtime-v2/config/__tests__/internal-agent-names.test.d.ts +2 -0
  64. package/core/dist/runtime-v2/config/__tests__/internal-agent-names.test.d.ts.map +1 -0
  65. package/core/dist/runtime-v2/config/__tests__/internal-agent-names.test.js +15 -0
  66. package/core/dist/runtime-v2/config/__tests__/internal-agent-names.test.js.map +1 -0
  67. package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.js +7 -0
  68. package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.js.map +1 -1
  69. package/core/dist/runtime-v2/config/__tests__/pd-config-contract.test.js +1 -0
  70. package/core/dist/runtime-v2/config/__tests__/pd-config-contract.test.js.map +1 -1
  71. package/core/dist/runtime-v2/config/__tests__/pd-config-redaction-deep.test.js +1 -0
  72. package/core/dist/runtime-v2/config/__tests__/pd-config-redaction-deep.test.js.map +1 -1
  73. package/core/dist/runtime-v2/config/__tests__/pd-config-validation-edge-cases.test.js +1 -0
  74. package/core/dist/runtime-v2/config/__tests__/pd-config-validation-edge-cases.test.js.map +1 -1
  75. package/core/dist/runtime-v2/config/index.d.ts +5 -3
  76. package/core/dist/runtime-v2/config/index.d.ts.map +1 -1
  77. package/core/dist/runtime-v2/config/index.js +8 -2
  78. package/core/dist/runtime-v2/config/index.js.map +1 -1
  79. package/core/dist/runtime-v2/config/pd-config-defaults.d.ts +2 -1
  80. package/core/dist/runtime-v2/config/pd-config-defaults.d.ts.map +1 -1
  81. package/core/dist/runtime-v2/config/pd-config-defaults.js +12 -0
  82. package/core/dist/runtime-v2/config/pd-config-defaults.js.map +1 -1
  83. package/core/dist/runtime-v2/config/pd-config-effective.d.ts.map +1 -1
  84. package/core/dist/runtime-v2/config/pd-config-effective.js +25 -1
  85. package/core/dist/runtime-v2/config/pd-config-effective.js.map +1 -1
  86. package/core/dist/runtime-v2/config/pd-config-redaction.d.ts.map +1 -1
  87. package/core/dist/runtime-v2/config/pd-config-redaction.js +9 -0
  88. package/core/dist/runtime-v2/config/pd-config-redaction.js.map +1 -1
  89. package/core/dist/runtime-v2/config/pd-config-types.d.ts +110 -1
  90. package/core/dist/runtime-v2/config/pd-config-types.d.ts.map +1 -1
  91. package/core/dist/runtime-v2/config/pd-config-types.js +7 -0
  92. package/core/dist/runtime-v2/config/pd-config-types.js.map +1 -1
  93. package/core/dist/runtime-v2/config/pd-config-validate.d.ts.map +1 -1
  94. package/core/dist/runtime-v2/config/pd-config-validate.js +114 -1
  95. package/core/dist/runtime-v2/config/pd-config-validate.js.map +1 -1
  96. package/core/dist/runtime-v2/config/pd-profile-constants.d.ts +27 -0
  97. package/core/dist/runtime-v2/config/pd-profile-constants.d.ts.map +1 -0
  98. package/core/dist/runtime-v2/config/pd-profile-constants.js +145 -0
  99. package/core/dist/runtime-v2/config/pd-profile-constants.js.map +1 -0
  100. package/core/dist/runtime-v2/config/pd-validate-profile.d.ts +28 -0
  101. package/core/dist/runtime-v2/config/pd-validate-profile.d.ts.map +1 -0
  102. package/core/dist/runtime-v2/config/pd-validate-profile.js +482 -0
  103. package/core/dist/runtime-v2/config/pd-validate-profile.js.map +1 -0
  104. package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js +26 -0
  105. package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js.map +1 -1
  106. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts.map +1 -1
  107. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js +8 -0
  108. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
  109. package/core/dist/runtime-v2/index.d.ts +5 -3
  110. package/core/dist/runtime-v2/index.d.ts.map +1 -1
  111. package/core/dist/runtime-v2/index.js +4 -2
  112. package/core/dist/runtime-v2/index.js.map +1 -1
  113. package/core/dist/runtime-v2/internalization/__tests__/artificer-prompt-builder-v2.test.js +25 -0
  114. package/core/dist/runtime-v2/internalization/__tests__/artificer-prompt-builder-v2.test.js.map +1 -1
  115. package/core/dist/runtime-v2/internalization/__tests__/artificer-rule-output.test.js +139 -0
  116. package/core/dist/runtime-v2/internalization/__tests__/artificer-rule-output.test.js.map +1 -1
  117. package/core/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.js +20 -1
  118. package/core/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.js.map +1 -1
  119. package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-intent-tension.test.js +7 -0
  120. package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-intent-tension.test.js.map +1 -1
  121. package/core/dist/runtime-v2/internalization/__tests__/internalization-task-guards.test.js +1 -53
  122. package/core/dist/runtime-v2/internalization/__tests__/internalization-task-guards.test.js.map +1 -1
  123. package/core/dist/runtime-v2/internalization/__tests__/rule-host-input-builder.test.js +23 -0
  124. package/core/dist/runtime-v2/internalization/__tests__/rule-host-input-builder.test.js.map +1 -1
  125. package/core/dist/runtime-v2/internalization/artificer-output.d.ts +7 -0
  126. package/core/dist/runtime-v2/internalization/artificer-output.d.ts.map +1 -1
  127. package/core/dist/runtime-v2/internalization/artificer-output.js +22 -1
  128. package/core/dist/runtime-v2/internalization/artificer-output.js.map +1 -1
  129. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts.map +1 -1
  130. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.js +2 -0
  131. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.js.map +1 -1
  132. package/core/dist/runtime-v2/internalization/artificer-runner.d.ts.map +1 -1
  133. package/core/dist/runtime-v2/internalization/artificer-runner.js +13 -0
  134. package/core/dist/runtime-v2/internalization/artificer-runner.js.map +1 -1
  135. package/core/dist/runtime-v2/internalization/evaluator-runner.d.ts.map +1 -1
  136. package/core/dist/runtime-v2/internalization/evaluator-runner.js +7 -1
  137. package/core/dist/runtime-v2/internalization/evaluator-runner.js.map +1 -1
  138. package/core/dist/runtime-v2/internalization/index.d.ts +1 -1
  139. package/core/dist/runtime-v2/internalization/index.d.ts.map +1 -1
  140. package/core/dist/runtime-v2/internalization/index.js +1 -1
  141. package/core/dist/runtime-v2/internalization/index.js.map +1 -1
  142. package/core/dist/runtime-v2/internalization/internalization-task-guards.d.ts +0 -19
  143. package/core/dist/runtime-v2/internalization/internalization-task-guards.d.ts.map +1 -1
  144. package/core/dist/runtime-v2/internalization/internalization-task-guards.js +1 -29
  145. package/core/dist/runtime-v2/internalization/internalization-task-guards.js.map +1 -1
  146. package/core/dist/runtime-v2/signal-collector/__tests__/keyword-stage.test.d.ts +2 -0
  147. package/core/dist/runtime-v2/signal-collector/__tests__/keyword-stage.test.d.ts.map +1 -0
  148. package/core/dist/runtime-v2/signal-collector/__tests__/keyword-stage.test.js +39 -0
  149. package/core/dist/runtime-v2/signal-collector/__tests__/keyword-stage.test.js.map +1 -0
  150. package/core/dist/runtime-v2/signal-collector/__tests__/llm-stage.test.d.ts +2 -0
  151. package/core/dist/runtime-v2/signal-collector/__tests__/llm-stage.test.d.ts.map +1 -0
  152. package/core/dist/runtime-v2/signal-collector/__tests__/llm-stage.test.js +34 -0
  153. package/core/dist/runtime-v2/signal-collector/__tests__/llm-stage.test.js.map +1 -0
  154. package/core/dist/runtime-v2/signal-collector/__tests__/signal-collector.test.d.ts +2 -0
  155. package/core/dist/runtime-v2/signal-collector/__tests__/signal-collector.test.d.ts.map +1 -0
  156. package/core/dist/runtime-v2/signal-collector/__tests__/signal-collector.test.js +222 -0
  157. package/core/dist/runtime-v2/signal-collector/__tests__/signal-collector.test.js.map +1 -0
  158. package/core/dist/runtime-v2/signal-collector/__tests__/types.test.d.ts +2 -0
  159. package/core/dist/runtime-v2/signal-collector/__tests__/types.test.d.ts.map +1 -0
  160. package/core/dist/runtime-v2/signal-collector/__tests__/types.test.js +35 -0
  161. package/core/dist/runtime-v2/signal-collector/__tests__/types.test.js.map +1 -0
  162. package/core/dist/runtime-v2/signal-collector/index.d.ts +5 -0
  163. package/core/dist/runtime-v2/signal-collector/index.d.ts.map +1 -0
  164. package/core/dist/runtime-v2/signal-collector/index.js +5 -0
  165. package/core/dist/runtime-v2/signal-collector/index.js.map +1 -0
  166. package/core/dist/runtime-v2/signal-collector/keyword-stage.d.ts +20 -0
  167. package/core/dist/runtime-v2/signal-collector/keyword-stage.d.ts.map +1 -0
  168. package/core/dist/runtime-v2/signal-collector/keyword-stage.js +61 -0
  169. package/core/dist/runtime-v2/signal-collector/keyword-stage.js.map +1 -0
  170. package/core/dist/runtime-v2/signal-collector/llm-stage.d.ts +16 -0
  171. package/core/dist/runtime-v2/signal-collector/llm-stage.d.ts.map +1 -0
  172. package/core/dist/runtime-v2/signal-collector/llm-stage.js +34 -0
  173. package/core/dist/runtime-v2/signal-collector/llm-stage.js.map +1 -0
  174. package/core/dist/runtime-v2/signal-collector/signal-collector.d.ts +16 -0
  175. package/core/dist/runtime-v2/signal-collector/signal-collector.d.ts.map +1 -0
  176. package/core/dist/runtime-v2/signal-collector/signal-collector.js +71 -0
  177. package/core/dist/runtime-v2/signal-collector/signal-collector.js.map +1 -0
  178. package/core/dist/runtime-v2/signal-collector/types.d.ts +61 -0
  179. package/core/dist/runtime-v2/signal-collector/types.d.ts.map +1 -0
  180. package/core/dist/runtime-v2/signal-collector/types.js +45 -0
  181. package/core/dist/runtime-v2/signal-collector/types.js.map +1 -0
  182. package/core/dist/runtime-v2/store/schema-conformance.test.js +43 -0
  183. package/core/dist/runtime-v2/store/schema-conformance.test.js.map +1 -1
  184. package/core/dist/runtime-v2/types/event-types.d.ts +40 -3
  185. package/core/dist/runtime-v2/types/event-types.d.ts.map +1 -1
  186. package/core/dist/runtime-v2/types/event-types.js +9 -0
  187. package/core/dist/runtime-v2/types/event-types.js.map +1 -1
  188. package/core/dist/runtime-v2/types/index.d.ts +2 -2
  189. package/core/dist/runtime-v2/types/index.d.ts.map +1 -1
  190. package/core/dist/runtime-v2/types/index.js +1 -1
  191. package/core/dist/runtime-v2/types/index.js.map +1 -1
  192. package/core/dist/workflow-funnel-loader.js +1 -1
  193. package/core/dist/workflow-funnel-loader.js.map +1 -1
  194. package/dist/i18n.d.ts.map +1 -1
  195. package/dist/i18n.js +6 -0
  196. package/dist/i18n.js.map +1 -1
  197. package/dist/index.js +12 -3
  198. package/dist/index.js.map +1 -1
  199. package/dist/installer.d.ts +3 -0
  200. package/dist/installer.d.ts.map +1 -1
  201. package/dist/installer.js +146 -1
  202. package/dist/installer.js.map +1 -1
  203. package/dist/mvp-config.d.ts +8 -0
  204. package/dist/mvp-config.d.ts.map +1 -1
  205. package/dist/mvp-config.js +12 -2
  206. package/dist/mvp-config.js.map +1 -1
  207. package/package.json +1 -1
  208. package/pd-cli/dist/commands/runtime-activation.d.ts +4 -0
  209. package/pd-cli/dist/commands/runtime-activation.d.ts.map +1 -1
  210. package/pd-cli/dist/commands/runtime-activation.js +181 -10
  211. package/pd-cli/dist/commands/runtime-activation.js.map +1 -1
  212. package/pd-cli/dist/index.js +5 -63
  213. package/pd-cli/dist/index.js.map +1 -1
  214. package/plugin/dist/commands/context.js +17 -11
  215. package/plugin/dist/commands/samples.js +25 -0
  216. package/plugin/dist/core/event-log.d.ts +11 -1
  217. package/plugin/dist/core/event-log.js +13 -0
  218. package/plugin/dist/core/init.js +3 -4
  219. package/plugin/dist/core/rule-host.d.ts +47 -0
  220. package/plugin/dist/core/rule-host.js +102 -18
  221. package/plugin/dist/core/signal-collector-host.d.ts +105 -0
  222. package/plugin/dist/core/signal-collector-host.js +337 -0
  223. package/plugin/dist/hooks/prompt.d.ts +3 -2
  224. package/plugin/dist/hooks/prompt.js +48 -586
  225. package/plugin/dist/types/event-types.d.ts +1 -1
  226. package/plugin/dist/types.d.ts +5 -25
  227. package/plugin/dist/types.js +4 -9
  228. package/plugin/dist/utils/hashing.js +1 -1
@@ -0,0 +1,145 @@
1
+ /**
2
+ * PD Profile Defaults — PRI-304 / PRI-466
3
+ *
4
+ * Deterministic defaults for agent behavioral profile config.
5
+ * Matches existing PROFILE_DEFAULTS in openclaw-plugin/src/core/profile.ts
6
+ * for backward compatibility with the transition to core types.
7
+ *
8
+ * All defaults are testable and explicit.
9
+ */
10
+ // ── Default Sub-Configs ─────────────────────────────────────────────────────
11
+ export const PROFILE_DEFAULT_GATE = {
12
+ require_plan_for_risk_paths: true,
13
+ require_audit_before_write: true,
14
+ require_reviewer_after_write: true,
15
+ };
16
+ export const PROFILE_DEFAULT_TESTS = {
17
+ on_change: 'smoke',
18
+ on_risk_change: 'unit',
19
+ commands: {},
20
+ };
21
+ export const PROFILE_DEFAULT_ADAPTIVE_PAIN = {
22
+ enabled: true,
23
+ spiral_boost: 20,
24
+ min_threshold: 15,
25
+ max_threshold: 70,
26
+ backlog_trigger: 6,
27
+ hard_failure_trigger: 1,
28
+ low_recent_success_boost: 15,
29
+ high_recent_pain_boost: 10,
30
+ };
31
+ export const PROFILE_DEFAULT_PAIN = {
32
+ soft_capture_threshold: 30,
33
+ adaptive: { ...PROFILE_DEFAULT_ADAPTIVE_PAIN },
34
+ };
35
+ export const PROFILE_DEFAULT_LIFECYCLE = {
36
+ enabled: true,
37
+ heartbeat_stale_hours: 72,
38
+ };
39
+ export const PROFILE_DEFAULT_PLAN_APPROVALS = {
40
+ enabled: false,
41
+ max_lines_override: -1,
42
+ allowed_patterns: [],
43
+ allowed_operations: [],
44
+ };
45
+ export const PROFILE_DEFAULT_PROGRESSIVE_GATE = {
46
+ enabled: true,
47
+ plan_approvals: { ...PROFILE_DEFAULT_PLAN_APPROVALS },
48
+ };
49
+ export const PROFILE_DEFAULT_EDIT_VERIFICATION = {
50
+ enabled: true,
51
+ max_file_size_bytes: 10 * 1024 * 1024, // 10MB
52
+ fuzzy_match_enabled: true,
53
+ fuzzy_match_threshold: 0.8,
54
+ skip_large_file_action: 'warn',
55
+ };
56
+ export const PROFILE_DEFAULT_THINKING_CHECKPOINT = {
57
+ enabled: false, // Default OFF to avoid blocking new users
58
+ window_ms: 5 * 60 * 1000, // 5 minutes
59
+ high_risk_tools: ['run_shell_command', 'delete_file', 'move_file'],
60
+ };
61
+ export const PROFILE_DEFAULT_CUSTOM_GUARDS = [];
62
+ // ── Full Profile Defaults ───────────────────────────────────────────────────
63
+ export const PROFILE_DEFAULTS = {
64
+ audit_level: 'medium',
65
+ risk_paths: [],
66
+ evolution_mode: 'realtime',
67
+ gate: { ...PROFILE_DEFAULT_GATE },
68
+ tests: { ...PROFILE_DEFAULT_TESTS },
69
+ pain: {
70
+ soft_capture_threshold: PROFILE_DEFAULT_PAIN.soft_capture_threshold,
71
+ adaptive: { ...PROFILE_DEFAULT_ADAPTIVE_PAIN },
72
+ },
73
+ lifecycle: { ...PROFILE_DEFAULT_LIFECYCLE },
74
+ progressive_gate: {
75
+ enabled: PROFILE_DEFAULT_PROGRESSIVE_GATE.enabled,
76
+ plan_approvals: { ...PROFILE_DEFAULT_PLAN_APPROVALS },
77
+ },
78
+ edit_verification: { ...PROFILE_DEFAULT_EDIT_VERIFICATION },
79
+ thinking_checkpoint: { ...PROFILE_DEFAULT_THINKING_CHECKPOINT },
80
+ custom_guards: [],
81
+ };
82
+ /**
83
+ * Deep-merge a partial user profile with PROFILE_DEFAULTS.
84
+ * Returns a fully resolved ProfileConfig.
85
+ */
86
+ export function resolveProfile(userProfile) {
87
+ if (!userProfile) {
88
+ return { ...PROFILE_DEFAULTS };
89
+ }
90
+ return {
91
+ audit_level: userProfile.audit_level ?? PROFILE_DEFAULTS.audit_level,
92
+ risk_paths: userProfile.risk_paths ?? PROFILE_DEFAULTS.risk_paths,
93
+ evolution_mode: userProfile.evolution_mode ?? PROFILE_DEFAULTS.evolution_mode,
94
+ gate: {
95
+ require_plan_for_risk_paths: userProfile.gate?.require_plan_for_risk_paths ?? PROFILE_DEFAULTS.gate.require_plan_for_risk_paths,
96
+ require_audit_before_write: userProfile.gate?.require_audit_before_write ?? PROFILE_DEFAULTS.gate.require_audit_before_write,
97
+ require_reviewer_after_write: userProfile.gate?.require_reviewer_after_write ?? PROFILE_DEFAULTS.gate.require_reviewer_after_write,
98
+ },
99
+ tests: {
100
+ on_change: userProfile.tests?.on_change ?? PROFILE_DEFAULTS.tests.on_change,
101
+ on_risk_change: userProfile.tests?.on_risk_change ?? PROFILE_DEFAULTS.tests.on_risk_change,
102
+ commands: { ...PROFILE_DEFAULTS.tests.commands, ...(userProfile.tests?.commands ?? {}) },
103
+ },
104
+ pain: {
105
+ soft_capture_threshold: userProfile.pain?.soft_capture_threshold ?? PROFILE_DEFAULTS.pain.soft_capture_threshold,
106
+ adaptive: {
107
+ enabled: userProfile.pain?.adaptive?.enabled ?? PROFILE_DEFAULTS.pain.adaptive.enabled,
108
+ spiral_boost: userProfile.pain?.adaptive?.spiral_boost ?? PROFILE_DEFAULTS.pain.adaptive.spiral_boost,
109
+ min_threshold: userProfile.pain?.adaptive?.min_threshold ?? PROFILE_DEFAULTS.pain.adaptive.min_threshold,
110
+ max_threshold: userProfile.pain?.adaptive?.max_threshold ?? PROFILE_DEFAULTS.pain.adaptive.max_threshold,
111
+ backlog_trigger: userProfile.pain?.adaptive?.backlog_trigger ?? PROFILE_DEFAULTS.pain.adaptive.backlog_trigger,
112
+ hard_failure_trigger: userProfile.pain?.adaptive?.hard_failure_trigger ?? PROFILE_DEFAULTS.pain.adaptive.hard_failure_trigger,
113
+ low_recent_success_boost: userProfile.pain?.adaptive?.low_recent_success_boost ?? PROFILE_DEFAULTS.pain.adaptive.low_recent_success_boost,
114
+ high_recent_pain_boost: userProfile.pain?.adaptive?.high_recent_pain_boost ?? PROFILE_DEFAULTS.pain.adaptive.high_recent_pain_boost,
115
+ },
116
+ },
117
+ lifecycle: {
118
+ enabled: userProfile.lifecycle?.enabled ?? PROFILE_DEFAULTS.lifecycle.enabled,
119
+ heartbeat_stale_hours: userProfile.lifecycle?.heartbeat_stale_hours ?? PROFILE_DEFAULTS.lifecycle.heartbeat_stale_hours,
120
+ },
121
+ progressive_gate: {
122
+ enabled: userProfile.progressive_gate?.enabled ?? PROFILE_DEFAULTS.progressive_gate.enabled,
123
+ plan_approvals: {
124
+ enabled: userProfile.progressive_gate?.plan_approvals?.enabled ?? PROFILE_DEFAULTS.progressive_gate.plan_approvals.enabled,
125
+ max_lines_override: userProfile.progressive_gate?.plan_approvals?.max_lines_override ?? PROFILE_DEFAULTS.progressive_gate.plan_approvals.max_lines_override,
126
+ allowed_patterns: userProfile.progressive_gate?.plan_approvals?.allowed_patterns ?? PROFILE_DEFAULTS.progressive_gate.plan_approvals.allowed_patterns,
127
+ allowed_operations: userProfile.progressive_gate?.plan_approvals?.allowed_operations ?? PROFILE_DEFAULTS.progressive_gate.plan_approvals.allowed_operations,
128
+ },
129
+ },
130
+ edit_verification: {
131
+ enabled: userProfile.edit_verification?.enabled ?? PROFILE_DEFAULTS.edit_verification.enabled,
132
+ max_file_size_bytes: userProfile.edit_verification?.max_file_size_bytes ?? PROFILE_DEFAULTS.edit_verification.max_file_size_bytes,
133
+ fuzzy_match_enabled: userProfile.edit_verification?.fuzzy_match_enabled ?? PROFILE_DEFAULTS.edit_verification.fuzzy_match_enabled,
134
+ fuzzy_match_threshold: userProfile.edit_verification?.fuzzy_match_threshold ?? PROFILE_DEFAULTS.edit_verification.fuzzy_match_threshold,
135
+ skip_large_file_action: userProfile.edit_verification?.skip_large_file_action ?? PROFILE_DEFAULTS.edit_verification.skip_large_file_action,
136
+ },
137
+ thinking_checkpoint: {
138
+ enabled: userProfile.thinking_checkpoint?.enabled ?? PROFILE_DEFAULTS.thinking_checkpoint.enabled,
139
+ window_ms: userProfile.thinking_checkpoint?.window_ms ?? PROFILE_DEFAULTS.thinking_checkpoint.window_ms,
140
+ high_risk_tools: userProfile.thinking_checkpoint?.high_risk_tools ?? PROFILE_DEFAULTS.thinking_checkpoint.high_risk_tools,
141
+ },
142
+ custom_guards: userProfile.custom_guards ?? PROFILE_DEFAULTS.custom_guards,
143
+ };
144
+ }
145
+ //# sourceMappingURL=pd-profile-constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pd-profile-constants.js","sourceRoot":"","sources":["../../../src/runtime-v2/config/pd-profile-constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAgBH,+EAA+E;AAE/E,MAAM,CAAC,MAAM,oBAAoB,GAAsB;IACrD,2BAA2B,EAAE,IAAI;IACjC,0BAA0B,EAAE,IAAI;IAChC,4BAA4B,EAAE,IAAI;CACnC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAuB;IACvD,SAAS,EAAE,OAAO;IAClB,cAAc,EAAE,MAAM;IACtB,QAAQ,EAAE,EAAE;CACb,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAA8B;IACtE,OAAO,EAAE,IAAI;IACb,YAAY,EAAE,EAAE;IAChB,aAAa,EAAE,EAAE;IACjB,aAAa,EAAE,EAAE;IACjB,eAAe,EAAE,CAAC;IAClB,oBAAoB,EAAE,CAAC;IACvB,wBAAwB,EAAE,EAAE;IAC5B,sBAAsB,EAAE,EAAE;CAC3B,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAsB;IACrD,sBAAsB,EAAE,EAAE;IAC1B,QAAQ,EAAE,EAAE,GAAG,6BAA6B,EAAE;CAC/C,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAA2B;IAC/D,OAAO,EAAE,IAAI;IACb,qBAAqB,EAAE,EAAE;CAC1B,CAAC;AAEF,MAAM,CAAC,MAAM,8BAA8B,GAA+B;IACxE,OAAO,EAAE,KAAK;IACd,kBAAkB,EAAE,CAAC,CAAC;IACtB,gBAAgB,EAAE,EAAE;IACpB,kBAAkB,EAAE,EAAE;CACvB,CAAC;AAEF,MAAM,CAAC,MAAM,gCAAgC,GAAiC;IAC5E,OAAO,EAAE,IAAI;IACb,cAAc,EAAE,EAAE,GAAG,8BAA8B,EAAE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-0,0 +1,28 @@
1
+ /**
2
+ * PD Profile Config Validation — PRI-304 / PRI-466
3
+ *
4
+ * Runtime validation from `unknown` (parsed YAML/JSON profile section).
5
+ * No `as` bypasses on untrusted input (ERR-001, ERR-005).
6
+ * Uses `Object.hasOwn()` for key checks (ERR-013).
7
+ * Unknown keys produce warnings rather than hard errors (forward compat).
8
+ */
9
+ import { type ProfileConfig } from './pd-config-types.js';
10
+ export interface ProfileValidationWarning {
11
+ path: string;
12
+ message: string;
13
+ }
14
+ export type ProfileValidationResult = {
15
+ ok: true;
16
+ value: Partial<ProfileConfig>;
17
+ warnings: ProfileValidationWarning[];
18
+ } | {
19
+ ok: false;
20
+ errors: ProfileValidationWarning[];
21
+ };
22
+ /**
23
+ * Validate a parsed profile config value from unknown input.
24
+ * Profile is optional — missing profile is OK (defaults applied in effective config).
25
+ * Partial input is accepted (warnings for invalid sub-fields, valid partial fields kept).
26
+ */
27
+ export declare function validateProfileConfig(raw: unknown, path?: string): ProfileValidationResult;
28
+ //# sourceMappingURL=pd-validate-profile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pd-validate-profile.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/config/pd-validate-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,KAAK,aAAa,EAOnB,MAAM,sBAAsB,CAAC;AAI9B,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,uBAAuB,GAC/B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAAC,QAAQ,EAAE,wBAAwB,EAAE,CAAA;CAAE,GACjF;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,wBAAwB,EAAE,CAAA;CAAE,CAAC;AA4NtD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,SAAY,GAAG,uBAAuB,CAsH7F"}
@@ -0,0 +1,482 @@
1
+ /**
2
+ * PD Profile Config Validation — PRI-304 / PRI-466
3
+ *
4
+ * Runtime validation from `unknown` (parsed YAML/JSON profile section).
5
+ * No `as` bypasses on untrusted input (ERR-001, ERR-005).
6
+ * Uses `Object.hasOwn()` for key checks (ERR-013).
7
+ * Unknown keys produce warnings rather than hard errors (forward compat).
8
+ */
9
+ import { PROFILE_AUDIT_LEVELS, PROFILE_EVOLUTION_MODES, PROFILE_TEST_LEVELS, } from './pd-config-types.js';
10
+ // ── Helpers ─────────────────────────────────────────────────────────────────
11
+ function isRecord(value) {
12
+ return value !== null && value !== undefined && typeof value === 'object' && !Array.isArray(value);
13
+ }
14
+ function isString(value) {
15
+ return typeof value === 'string';
16
+ }
17
+ function isBoolean(value) {
18
+ return typeof value === 'boolean';
19
+ }
20
+ function isNumber(value) {
21
+ return typeof value === 'number' && Number.isFinite(value);
22
+ }
23
+ function warn(path, message) {
24
+ return { path, message };
25
+ }
26
+ function readOwn(obj, key) {
27
+ // DANGEROUS_KEYS check: profile does not have __proto__/constructor risk at runtime
28
+ return Object.hasOwn(obj, key) ? obj[key] : undefined;
29
+ }
30
+ const VALID_SEVERITIES = new Set(['info', 'warning', 'error', 'fatal']);
31
+ // ── Sub-validators ──────────────────────────────────────────────────────────
32
+ function validateGate(raw, path) {
33
+ const warnings = [];
34
+ if (!isRecord(raw)) {
35
+ warnings.push(warn(path, `gate must be an object, got ${typeof raw}`));
36
+ return { warnings };
37
+ }
38
+ const value = {};
39
+ const bv = readOwn(raw, 'require_plan_for_risk_paths');
40
+ if (bv !== undefined) {
41
+ if (isBoolean(bv))
42
+ value.require_plan_for_risk_paths = bv;
43
+ else
44
+ warnings.push(warn(`${path}.require_plan_for_risk_paths`, `must be boolean`));
45
+ }
46
+ const ba = readOwn(raw, 'require_audit_before_write');
47
+ if (ba !== undefined) {
48
+ if (isBoolean(ba))
49
+ value.require_audit_before_write = ba;
50
+ else
51
+ warnings.push(warn(`${path}.require_audit_before_write`, `must be boolean`));
52
+ }
53
+ const br = readOwn(raw, 'require_reviewer_after_write');
54
+ if (br !== undefined) {
55
+ if (isBoolean(br))
56
+ value.require_reviewer_after_write = br;
57
+ else
58
+ warnings.push(warn(`${path}.require_reviewer_after_write`, `must be boolean`));
59
+ }
60
+ return { value, warnings };
61
+ }
62
+ function validateTests(raw, path) {
63
+ const warnings = [];
64
+ if (!isRecord(raw)) {
65
+ warnings.push(warn(path, `tests must be an object, got ${typeof raw}`));
66
+ return { warnings };
67
+ }
68
+ const value = {};
69
+ const oc = readOwn(raw, 'on_change');
70
+ if (oc !== undefined) {
71
+ if (isString(oc) && PROFILE_TEST_LEVELS.includes(oc))
72
+ value.on_change = oc;
73
+ else
74
+ warnings.push(warn(`${path}.on_change`, `must be one of: ${PROFILE_TEST_LEVELS.join(', ')}`));
75
+ }
76
+ const orc = readOwn(raw, 'on_risk_change');
77
+ if (orc !== undefined) {
78
+ if (isString(orc) && PROFILE_TEST_LEVELS.includes(orc))
79
+ value.on_risk_change = orc;
80
+ else
81
+ warnings.push(warn(`${path}.on_risk_change`, `must be one of: ${PROFILE_TEST_LEVELS.join(', ')}`));
82
+ }
83
+ const cmds = readOwn(raw, 'commands');
84
+ if (cmds !== undefined) {
85
+ if (isRecord(cmds)) {
86
+ const cleaned = {};
87
+ for (const k of Object.keys(cmds)) {
88
+ const v = cmds[k];
89
+ if (isString(v))
90
+ cleaned[k] = v;
91
+ else
92
+ warnings.push(warn(`${path}.commands.${k}`, `command value must be a string`));
93
+ }
94
+ value.commands = cleaned;
95
+ }
96
+ else {
97
+ warnings.push(warn(`${path}.commands`, `must be an object (string→string map)`));
98
+ }
99
+ }
100
+ return { value, warnings };
101
+ }
102
+ function validateAdaptivePain(raw, path) {
103
+ const warnings = [];
104
+ if (!isRecord(raw)) {
105
+ warnings.push(warn(path, `adaptive must be an object, got ${typeof raw}`));
106
+ return { warnings };
107
+ }
108
+ const value = {};
109
+ const en = readOwn(raw, 'enabled');
110
+ if (en !== undefined) {
111
+ if (isBoolean(en))
112
+ value.enabled = en;
113
+ else
114
+ warnings.push(warn(`${path}.enabled`, `must be boolean`));
115
+ }
116
+ const sb = readOwn(raw, 'spiral_boost');
117
+ if (sb !== undefined) {
118
+ if (isNumber(sb))
119
+ value.spiral_boost = sb;
120
+ else
121
+ warnings.push(warn(`${path}.spiral_boost`, `must be a finite number`));
122
+ }
123
+ const min = readOwn(raw, 'min_threshold');
124
+ if (min !== undefined) {
125
+ if (isNumber(min))
126
+ value.min_threshold = min;
127
+ else
128
+ warnings.push(warn(`${path}.min_threshold`, `must be a finite number`));
129
+ }
130
+ const max = readOwn(raw, 'max_threshold');
131
+ if (max !== undefined) {
132
+ if (isNumber(max))
133
+ value.max_threshold = max;
134
+ else
135
+ warnings.push(warn(`${path}.max_threshold`, `must be a finite number`));
136
+ }
137
+ const bt = readOwn(raw, 'backlog_trigger');
138
+ if (bt !== undefined) {
139
+ if (isNumber(bt))
140
+ value.backlog_trigger = bt;
141
+ else
142
+ warnings.push(warn(`${path}.backlog_trigger`, `must be a finite number`));
143
+ }
144
+ const hf = readOwn(raw, 'hard_failure_trigger');
145
+ if (hf !== undefined) {
146
+ if (isNumber(hf))
147
+ value.hard_failure_trigger = hf;
148
+ else
149
+ warnings.push(warn(`${path}.hard_failure_trigger`, `must be a finite number`));
150
+ }
151
+ const lrsb = readOwn(raw, 'low_recent_success_boost');
152
+ if (lrsb !== undefined) {
153
+ if (isNumber(lrsb))
154
+ value.low_recent_success_boost = lrsb;
155
+ else
156
+ warnings.push(warn(`${path}.low_recent_success_boost`, `must be a finite number`));
157
+ }
158
+ const hrpb = readOwn(raw, 'high_recent_pain_boost');
159
+ if (hrpb !== undefined) {
160
+ if (isNumber(hrpb))
161
+ value.high_recent_pain_boost = hrpb;
162
+ else
163
+ warnings.push(warn(`${path}.high_recent_pain_boost`, `must be a finite number`));
164
+ }
165
+ return { value, warnings };
166
+ }
167
+ function validatePain(raw, path) {
168
+ const warnings = [];
169
+ if (!isRecord(raw)) {
170
+ warnings.push(warn(path, `pain must be an object, got ${typeof raw}`));
171
+ return { warnings };
172
+ }
173
+ const value = {};
174
+ const sct = readOwn(raw, 'soft_capture_threshold');
175
+ if (sct !== undefined) {
176
+ if (isNumber(sct))
177
+ value.soft_capture_threshold = sct;
178
+ else
179
+ warnings.push(warn(`${path}.soft_capture_threshold`, `must be a finite number`));
180
+ }
181
+ const ad = readOwn(raw, 'adaptive');
182
+ if (ad !== undefined) {
183
+ const r = validateAdaptivePain(ad, `${path}.adaptive`);
184
+ if (r.value)
185
+ value.adaptive = r.value;
186
+ warnings.push(...r.warnings);
187
+ }
188
+ return { value, warnings };
189
+ }
190
+ function validateLifecycle(raw, path) {
191
+ const warnings = [];
192
+ if (!isRecord(raw)) {
193
+ warnings.push(warn(path, `lifecycle must be an object, got ${typeof raw}`));
194
+ return { warnings };
195
+ }
196
+ const value = {};
197
+ const en = readOwn(raw, 'enabled');
198
+ if (en !== undefined) {
199
+ if (isBoolean(en))
200
+ value.enabled = en;
201
+ else
202
+ warnings.push(warn(`${path}.enabled`, `must be boolean`));
203
+ }
204
+ const hb = readOwn(raw, 'heartbeat_stale_hours');
205
+ if (hb !== undefined) {
206
+ if (isNumber(hb))
207
+ value.heartbeat_stale_hours = hb;
208
+ else
209
+ warnings.push(warn(`${path}.heartbeat_stale_hours`, `must be a finite number`));
210
+ }
211
+ return { value, warnings };
212
+ }
213
+ function validatePlanApprovals(raw, path) {
214
+ const warnings = [];
215
+ if (!isRecord(raw)) {
216
+ warnings.push(warn(path, `plan_approvals must be an object, got ${typeof raw}`));
217
+ return { warnings };
218
+ }
219
+ const value = {};
220
+ const en = readOwn(raw, 'enabled');
221
+ if (en !== undefined) {
222
+ if (isBoolean(en))
223
+ value.enabled = en;
224
+ else
225
+ warnings.push(warn(`${path}.enabled`, `must be boolean`));
226
+ }
227
+ const ml = readOwn(raw, 'max_lines_override');
228
+ if (ml !== undefined) {
229
+ if (isNumber(ml) && Number.isInteger(ml))
230
+ value.max_lines_override = ml;
231
+ else
232
+ warnings.push(warn(`${path}.max_lines_override`, `must be an integer`));
233
+ }
234
+ const ap = readOwn(raw, 'allowed_patterns');
235
+ if (ap !== undefined) {
236
+ if (Array.isArray(ap))
237
+ value.allowed_patterns = ap.filter(isString);
238
+ else
239
+ warnings.push(warn(`${path}.allowed_patterns`, `must be an array of strings`));
240
+ }
241
+ const ao = readOwn(raw, 'allowed_operations');
242
+ if (ao !== undefined) {
243
+ if (Array.isArray(ao))
244
+ value.allowed_operations = ao.filter(isString);
245
+ else
246
+ warnings.push(warn(`${path}.allowed_operations`, `must be an array of strings`));
247
+ }
248
+ return { value, warnings };
249
+ }
250
+ function validateEditVerification(raw, path) {
251
+ const warnings = [];
252
+ if (!isRecord(raw)) {
253
+ warnings.push(warn(path, `edit_verification must be an object, got ${typeof raw}`));
254
+ return { warnings };
255
+ }
256
+ const value = {};
257
+ const en = readOwn(raw, 'enabled');
258
+ if (en !== undefined) {
259
+ if (isBoolean(en))
260
+ value.enabled = en;
261
+ else
262
+ warnings.push(warn(`${path}.enabled`, `must be boolean`));
263
+ }
264
+ const mfs = readOwn(raw, 'max_file_size_bytes');
265
+ if (mfs !== undefined) {
266
+ if (isNumber(mfs) && mfs >= 0)
267
+ value.max_file_size_bytes = mfs;
268
+ else
269
+ warnings.push(warn(`${path}.max_file_size_bytes`, `must be a non-negative number`));
270
+ }
271
+ const fm = readOwn(raw, 'fuzzy_match_enabled');
272
+ if (fm !== undefined) {
273
+ if (isBoolean(fm))
274
+ value.fuzzy_match_enabled = fm;
275
+ else
276
+ warnings.push(warn(`${path}.fuzzy_match_enabled`, `must be boolean`));
277
+ }
278
+ const fmt = readOwn(raw, 'fuzzy_match_threshold');
279
+ if (fmt !== undefined) {
280
+ if (isNumber(fmt) && fmt > 0 && fmt <= 1)
281
+ value.fuzzy_match_threshold = fmt;
282
+ else
283
+ warnings.push(warn(`${path}.fuzzy_match_threshold`, `must be a number in (0, 1]`));
284
+ }
285
+ const sla = readOwn(raw, 'skip_large_file_action');
286
+ if (sla !== undefined) {
287
+ if (sla === 'warn' || sla === 'block')
288
+ value.skip_large_file_action = sla;
289
+ else
290
+ warnings.push(warn(`${path}.skip_large_file_action`, `must be "warn" or "block"`));
291
+ }
292
+ return { value, warnings };
293
+ }
294
+ function validateThinkingCheckpoint(raw, path) {
295
+ const warnings = [];
296
+ if (!isRecord(raw)) {
297
+ warnings.push(warn(path, `thinking_checkpoint must be an object, got ${typeof raw}`));
298
+ return { warnings };
299
+ }
300
+ const value = {};
301
+ const en = readOwn(raw, 'enabled');
302
+ if (en !== undefined) {
303
+ if (isBoolean(en))
304
+ value.enabled = en;
305
+ else
306
+ warnings.push(warn(`${path}.enabled`, `must be boolean`));
307
+ }
308
+ const wm = readOwn(raw, 'window_ms');
309
+ if (wm !== undefined) {
310
+ if (isNumber(wm) && wm > 0)
311
+ value.window_ms = wm;
312
+ else
313
+ warnings.push(warn(`${path}.window_ms`, `must be a positive number`));
314
+ }
315
+ const hrt = readOwn(raw, 'high_risk_tools');
316
+ if (hrt !== undefined) {
317
+ if (Array.isArray(hrt))
318
+ value.high_risk_tools = hrt.filter(isString);
319
+ else
320
+ warnings.push(warn(`${path}.high_risk_tools`, `must be an array of strings`));
321
+ }
322
+ return { value, warnings };
323
+ }
324
+ function validateCustomGuards(raw, path) {
325
+ const warnings = [];
326
+ if (!Array.isArray(raw)) {
327
+ warnings.push(warn(path, `custom_guards must be an array, got ${typeof raw}`));
328
+ return { warnings };
329
+ }
330
+ const guards = [];
331
+ for (let i = 0; i < raw.length; i++) {
332
+ const item = raw[i];
333
+ if (!isRecord(item)) {
334
+ warnings.push(warn(`${path}[${i}]`, `must be an object`));
335
+ continue;
336
+ }
337
+ const pattern = readOwn(item, 'pattern');
338
+ const message = readOwn(item, 'message');
339
+ const severity = readOwn(item, 'severity');
340
+ if (!isString(pattern) || pattern.length === 0) {
341
+ warnings.push(warn(`${path}[${i}].pattern`, `must be a non-empty string`));
342
+ continue;
343
+ }
344
+ guards.push({
345
+ pattern,
346
+ message: isString(message) ? message : 'Custom guard triggered',
347
+ severity: isString(severity) && VALID_SEVERITIES.has(severity.toLowerCase()) ? severity.toLowerCase() : 'error',
348
+ });
349
+ }
350
+ return { value: guards, warnings };
351
+ }
352
+ // ── Top-Level Validator ─────────────────────────────────────────────────────
353
+ /**
354
+ * Validate a parsed profile config value from unknown input.
355
+ * Profile is optional — missing profile is OK (defaults applied in effective config).
356
+ * Partial input is accepted (warnings for invalid sub-fields, valid partial fields kept).
357
+ */
358
+ export function validateProfileConfig(raw, path = 'profile') {
359
+ const warnings = [];
360
+ if (!isRecord(raw)) {
361
+ return { ok: false, errors: [warn(path, `profile must be an object, got ${typeof raw}`)] };
362
+ }
363
+ const result = {};
364
+ // audit_level
365
+ const al = readOwn(raw, 'audit_level');
366
+ if (al !== undefined) {
367
+ if (isString(al) && PROFILE_AUDIT_LEVELS.includes(al)) {
368
+ result.audit_level = al;
369
+ }
370
+ else {
371
+ warnings.push(warn(`${path}.audit_level`, `must be one of: ${PROFILE_AUDIT_LEVELS.join(', ')}, got ${JSON.stringify(al)}`));
372
+ }
373
+ }
374
+ // evolution_mode
375
+ const em = readOwn(raw, 'evolution_mode');
376
+ if (em !== undefined) {
377
+ if (isString(em) && PROFILE_EVOLUTION_MODES.includes(em)) {
378
+ result.evolution_mode = em;
379
+ }
380
+ else {
381
+ warnings.push(warn(`${path}.evolution_mode`, `must be one of: ${PROFILE_EVOLUTION_MODES.join(', ')}, got ${JSON.stringify(em)}`));
382
+ }
383
+ }
384
+ // risk_paths
385
+ const rp = readOwn(raw, 'risk_paths');
386
+ if (rp !== undefined) {
387
+ if (Array.isArray(rp)) {
388
+ result.risk_paths = rp.filter(isString);
389
+ }
390
+ else if (isString(rp)) {
391
+ result.risk_paths = [rp];
392
+ }
393
+ else {
394
+ warnings.push(warn(`${path}.risk_paths`, `must be an array of strings or a single string`));
395
+ }
396
+ }
397
+ // Sub-objects
398
+ const gateRaw = readOwn(raw, 'gate');
399
+ if (gateRaw !== undefined) {
400
+ const r = validateGate(gateRaw, `${path}.gate`);
401
+ if (r.value)
402
+ result.gate = r.value;
403
+ warnings.push(...r.warnings);
404
+ }
405
+ const testsRaw = readOwn(raw, 'tests');
406
+ if (testsRaw !== undefined) {
407
+ const r = validateTests(testsRaw, `${path}.tests`);
408
+ if (r.value)
409
+ result.tests = r.value;
410
+ warnings.push(...r.warnings);
411
+ }
412
+ const painRaw = readOwn(raw, 'pain');
413
+ if (painRaw !== undefined) {
414
+ const r = validatePain(painRaw, `${path}.pain`);
415
+ if (r.value)
416
+ result.pain = r.value;
417
+ warnings.push(...r.warnings);
418
+ }
419
+ const lifecycleRaw = readOwn(raw, 'lifecycle');
420
+ if (lifecycleRaw !== undefined) {
421
+ const r = validateLifecycle(lifecycleRaw, `${path}.lifecycle`);
422
+ if (r.value)
423
+ result.lifecycle = r.value;
424
+ warnings.push(...r.warnings);
425
+ }
426
+ // progressive_gate
427
+ const pgRaw = readOwn(raw, 'progressive_gate');
428
+ if (pgRaw !== undefined) {
429
+ const warnings2 = [];
430
+ const pgResult = {};
431
+ if (isRecord(pgRaw)) {
432
+ // Inside isRecord guard, TypeScript narrows pgRaw to Record<string, unknown>
433
+ const pgEnabled = readOwn(pgRaw, 'enabled');
434
+ if (pgEnabled !== undefined) {
435
+ if (isBoolean(pgEnabled))
436
+ pgResult.enabled = pgEnabled;
437
+ else
438
+ warnings2.push(warn(`${path}.progressive_gate.enabled`, `must be boolean`));
439
+ }
440
+ const paRaw = readOwn(pgRaw, 'plan_approvals');
441
+ if (paRaw !== undefined) {
442
+ const r = validatePlanApprovals(paRaw, `${path}.progressive_gate.plan_approvals`);
443
+ if (r.value)
444
+ pgResult.plan_approvals = r.value;
445
+ warnings2.push(...r.warnings);
446
+ }
447
+ }
448
+ else {
449
+ warnings2.push(warn(`${path}.progressive_gate`, `must be an object`));
450
+ }
451
+ if (Object.keys(pgResult).length > 0)
452
+ result.progressive_gate = pgResult;
453
+ warnings.push(...warnings2);
454
+ }
455
+ const evRaw = readOwn(raw, 'edit_verification');
456
+ if (evRaw !== undefined) {
457
+ const r = validateEditVerification(evRaw, `${path}.edit_verification`);
458
+ if (r.value)
459
+ result.edit_verification = r.value;
460
+ warnings.push(...r.warnings);
461
+ }
462
+ const tcRaw = readOwn(raw, 'thinking_checkpoint');
463
+ if (tcRaw !== undefined) {
464
+ const r = validateThinkingCheckpoint(tcRaw, `${path}.thinking_checkpoint`);
465
+ if (r.value)
466
+ result.thinking_checkpoint = r.value;
467
+ warnings.push(...r.warnings);
468
+ }
469
+ const cgRaw = readOwn(raw, 'custom_guards');
470
+ if (cgRaw !== undefined) {
471
+ const r = validateCustomGuards(cgRaw, `${path}.custom_guards`);
472
+ if (r.value)
473
+ result.custom_guards = r.value;
474
+ warnings.push(...r.warnings);
475
+ }
476
+ return {
477
+ ok: true,
478
+ value: result,
479
+ warnings,
480
+ };
481
+ }
482
+ //# sourceMappingURL=pd-validate-profile.js.map