@veraxhq/verax 0.2.1 → 0.3.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 (152) hide show
  1. package/README.md +14 -18
  2. package/bin/verax.js +7 -0
  3. package/package.json +3 -3
  4. package/src/cli/commands/baseline.js +104 -0
  5. package/src/cli/commands/default.js +79 -25
  6. package/src/cli/commands/ga.js +243 -0
  7. package/src/cli/commands/gates.js +95 -0
  8. package/src/cli/commands/inspect.js +131 -2
  9. package/src/cli/commands/release-check.js +213 -0
  10. package/src/cli/commands/run.js +246 -35
  11. package/src/cli/commands/security-check.js +211 -0
  12. package/src/cli/commands/truth.js +114 -0
  13. package/src/cli/entry.js +304 -67
  14. package/src/cli/util/angular-component-extractor.js +179 -0
  15. package/src/cli/util/angular-navigation-detector.js +141 -0
  16. package/src/cli/util/angular-network-detector.js +161 -0
  17. package/src/cli/util/angular-state-detector.js +162 -0
  18. package/src/cli/util/ast-interactive-detector.js +546 -0
  19. package/src/cli/util/ast-network-detector.js +603 -0
  20. package/src/cli/util/ast-usestate-detector.js +602 -0
  21. package/src/cli/util/bootstrap-guard.js +86 -0
  22. package/src/cli/util/determinism-runner.js +123 -0
  23. package/src/cli/util/determinism-writer.js +129 -0
  24. package/src/cli/util/env-url.js +4 -0
  25. package/src/cli/util/expectation-extractor.js +369 -73
  26. package/src/cli/util/findings-writer.js +126 -16
  27. package/src/cli/util/learn-writer.js +3 -1
  28. package/src/cli/util/observe-writer.js +3 -1
  29. package/src/cli/util/paths.js +3 -12
  30. package/src/cli/util/project-discovery.js +3 -0
  31. package/src/cli/util/project-writer.js +3 -1
  32. package/src/cli/util/run-resolver.js +64 -0
  33. package/src/cli/util/source-requirement.js +55 -0
  34. package/src/cli/util/summary-writer.js +1 -0
  35. package/src/cli/util/svelte-navigation-detector.js +163 -0
  36. package/src/cli/util/svelte-network-detector.js +80 -0
  37. package/src/cli/util/svelte-sfc-extractor.js +147 -0
  38. package/src/cli/util/svelte-state-detector.js +243 -0
  39. package/src/cli/util/vue-navigation-detector.js +177 -0
  40. package/src/cli/util/vue-sfc-extractor.js +162 -0
  41. package/src/cli/util/vue-state-detector.js +215 -0
  42. package/src/verax/cli/finding-explainer.js +56 -3
  43. package/src/verax/core/artifacts/registry.js +154 -0
  44. package/src/verax/core/artifacts/verifier.js +980 -0
  45. package/src/verax/core/baseline/baseline.enforcer.js +137 -0
  46. package/src/verax/core/baseline/baseline.snapshot.js +231 -0
  47. package/src/verax/core/capabilities/gates.js +499 -0
  48. package/src/verax/core/capabilities/registry.js +475 -0
  49. package/src/verax/core/confidence/confidence-compute.js +137 -0
  50. package/src/verax/core/confidence/confidence-invariants.js +234 -0
  51. package/src/verax/core/confidence/confidence-report-writer.js +112 -0
  52. package/src/verax/core/confidence/confidence-weights.js +44 -0
  53. package/src/verax/core/confidence/confidence.defaults.js +65 -0
  54. package/src/verax/core/confidence/confidence.loader.js +79 -0
  55. package/src/verax/core/confidence/confidence.schema.js +94 -0
  56. package/src/verax/core/confidence-engine-refactor.js +484 -0
  57. package/src/verax/core/confidence-engine.js +486 -0
  58. package/src/verax/core/confidence-engine.js.backup +471 -0
  59. package/src/verax/core/contracts/index.js +29 -0
  60. package/src/verax/core/contracts/types.js +185 -0
  61. package/src/verax/core/contracts/validators.js +381 -0
  62. package/src/verax/core/decision-snapshot.js +30 -3
  63. package/src/verax/core/decisions/decision.trace.js +276 -0
  64. package/src/verax/core/determinism/contract-writer.js +89 -0
  65. package/src/verax/core/determinism/contract.js +139 -0
  66. package/src/verax/core/determinism/diff.js +364 -0
  67. package/src/verax/core/determinism/engine.js +221 -0
  68. package/src/verax/core/determinism/finding-identity.js +148 -0
  69. package/src/verax/core/determinism/normalize.js +438 -0
  70. package/src/verax/core/determinism/report-writer.js +92 -0
  71. package/src/verax/core/determinism/run-fingerprint.js +118 -0
  72. package/src/verax/core/dynamic-route-intelligence.js +528 -0
  73. package/src/verax/core/evidence/evidence-capture-service.js +307 -0
  74. package/src/verax/core/evidence/evidence-intent-ledger.js +165 -0
  75. package/src/verax/core/evidence-builder.js +487 -0
  76. package/src/verax/core/execution-mode-context.js +77 -0
  77. package/src/verax/core/execution-mode-detector.js +190 -0
  78. package/src/verax/core/failures/exit-codes.js +86 -0
  79. package/src/verax/core/failures/failure-summary.js +76 -0
  80. package/src/verax/core/failures/failure.factory.js +225 -0
  81. package/src/verax/core/failures/failure.ledger.js +132 -0
  82. package/src/verax/core/failures/failure.types.js +196 -0
  83. package/src/verax/core/failures/index.js +10 -0
  84. package/src/verax/core/ga/ga-report-writer.js +43 -0
  85. package/src/verax/core/ga/ga.artifact.js +49 -0
  86. package/src/verax/core/ga/ga.contract.js +434 -0
  87. package/src/verax/core/ga/ga.enforcer.js +86 -0
  88. package/src/verax/core/guardrails/guardrails-report-writer.js +109 -0
  89. package/src/verax/core/guardrails/policy.defaults.js +210 -0
  90. package/src/verax/core/guardrails/policy.loader.js +83 -0
  91. package/src/verax/core/guardrails/policy.schema.js +110 -0
  92. package/src/verax/core/guardrails/truth-reconciliation.js +136 -0
  93. package/src/verax/core/guardrails-engine.js +505 -0
  94. package/src/verax/core/observe/run-timeline.js +316 -0
  95. package/src/verax/core/perf/perf.contract.js +186 -0
  96. package/src/verax/core/perf/perf.display.js +65 -0
  97. package/src/verax/core/perf/perf.enforcer.js +91 -0
  98. package/src/verax/core/perf/perf.monitor.js +209 -0
  99. package/src/verax/core/perf/perf.report.js +198 -0
  100. package/src/verax/core/pipeline-tracker.js +238 -0
  101. package/src/verax/core/product-definition.js +127 -0
  102. package/src/verax/core/release/provenance.builder.js +271 -0
  103. package/src/verax/core/release/release-report-writer.js +40 -0
  104. package/src/verax/core/release/release.enforcer.js +159 -0
  105. package/src/verax/core/release/reproducibility.check.js +221 -0
  106. package/src/verax/core/release/sbom.builder.js +283 -0
  107. package/src/verax/core/report/cross-index.js +192 -0
  108. package/src/verax/core/report/human-summary.js +222 -0
  109. package/src/verax/core/route-intelligence.js +419 -0
  110. package/src/verax/core/security/secrets.scan.js +326 -0
  111. package/src/verax/core/security/security-report.js +50 -0
  112. package/src/verax/core/security/security.enforcer.js +124 -0
  113. package/src/verax/core/security/supplychain.defaults.json +38 -0
  114. package/src/verax/core/security/supplychain.policy.js +326 -0
  115. package/src/verax/core/security/vuln.scan.js +265 -0
  116. package/src/verax/core/truth/truth.certificate.js +250 -0
  117. package/src/verax/core/ui-feedback-intelligence.js +515 -0
  118. package/src/verax/detect/confidence-engine.js +628 -40
  119. package/src/verax/detect/confidence-helper.js +33 -0
  120. package/src/verax/detect/detection-engine.js +18 -1
  121. package/src/verax/detect/dynamic-route-findings.js +335 -0
  122. package/src/verax/detect/expectation-chain-detector.js +417 -0
  123. package/src/verax/detect/expectation-model.js +3 -1
  124. package/src/verax/detect/findings-writer.js +141 -5
  125. package/src/verax/detect/index.js +229 -5
  126. package/src/verax/detect/journey-stall-detector.js +558 -0
  127. package/src/verax/detect/route-findings.js +218 -0
  128. package/src/verax/detect/ui-feedback-findings.js +207 -0
  129. package/src/verax/detect/verdict-engine.js +57 -3
  130. package/src/verax/detect/view-switch-correlator.js +242 -0
  131. package/src/verax/index.js +413 -45
  132. package/src/verax/learn/action-contract-extractor.js +682 -64
  133. package/src/verax/learn/route-validator.js +4 -1
  134. package/src/verax/observe/index.js +88 -843
  135. package/src/verax/observe/interaction-runner.js +25 -8
  136. package/src/verax/observe/observe-context.js +205 -0
  137. package/src/verax/observe/observe-helpers.js +191 -0
  138. package/src/verax/observe/observe-runner.js +226 -0
  139. package/src/verax/observe/observers/budget-observer.js +185 -0
  140. package/src/verax/observe/observers/console-observer.js +102 -0
  141. package/src/verax/observe/observers/coverage-observer.js +107 -0
  142. package/src/verax/observe/observers/interaction-observer.js +471 -0
  143. package/src/verax/observe/observers/navigation-observer.js +132 -0
  144. package/src/verax/observe/observers/network-observer.js +87 -0
  145. package/src/verax/observe/observers/safety-observer.js +82 -0
  146. package/src/verax/observe/observers/ui-feedback-observer.js +99 -0
  147. package/src/verax/observe/ui-feedback-detector.js +742 -0
  148. package/src/verax/observe/ui-signal-sensor.js +148 -2
  149. package/src/verax/scan-summary-writer.js +42 -8
  150. package/src/verax/shared/artifact-manager.js +8 -5
  151. package/src/verax/shared/css-spinner-rules.js +204 -0
  152. package/src/verax/shared/view-switch-rules.js +208 -0
@@ -0,0 +1,475 @@
1
+ /**
2
+ * PHASE 7 — Capability Registry
3
+ *
4
+ * Single source of truth for all VERAX capabilities.
5
+ *
6
+ * This registry defines what VERAX can detect and observe.
7
+ * Every capability MUST have:
8
+ * - A test in the test matrix
9
+ * - A fixture that demonstrates it
10
+ * - Required artifacts documented
11
+ *
12
+ * No capability exists unless it appears here AND passes tests.
13
+ */
14
+
15
+ /**
16
+ * Capability maturity levels:
17
+ * - stable: Production-ready, fully tested, deterministic
18
+ * - partial: Works for common cases, may have edge case limitations
19
+ * - experimental: Early implementation, may have significant limitations
20
+ */
21
+ export const CAPABILITY_MATURITY = {
22
+ STABLE: 'stable',
23
+ PARTIAL: 'partial',
24
+ EXPERIMENTAL: 'experimental'
25
+ };
26
+
27
+ /**
28
+ * Capability categories
29
+ */
30
+ export const CAPABILITY_CATEGORY = {
31
+ NAVIGATION: 'navigation',
32
+ NETWORK: 'network',
33
+ STATE: 'state',
34
+ UI_FEEDBACK: 'ui-feedback',
35
+ ROUTES: 'routes',
36
+ EVIDENCE: 'evidence',
37
+ VALIDATION: 'validation',
38
+ ANALYSIS: 'analysis', // PHASE 15: Analysis capabilities (confidence, scoring)
39
+ RELIABILITY: 'reliability', // PHASE 21: Reliability capabilities (determinism)
40
+ SECURITY: 'security', // PHASE 22: Security capabilities
41
+ RELEASE: 'release', // PHASE 22: Release/GA capabilities
42
+ OPERATIONS: 'operations', // PHASE 22: Operational guarantees
43
+ PERFORMANCE: 'performance' // PHASE 22: Performance capabilities
44
+ };
45
+
46
+ /**
47
+ * Canonical Capability Registry
48
+ *
49
+ * Each entry defines a capability VERAX can detect/observe.
50
+ *
51
+ * @typedef {Object} Capability
52
+ * @property {string} id - Stable identifier (kebab-case)
53
+ * @property {string} category - One of CAPABILITY_CATEGORY
54
+ * @property {string} description - One sentence description
55
+ * @property {string[]} requiredArtifacts - Artifact keys from ARTIFACT_REGISTRY
56
+ * @property {string} maturity - One of CAPABILITY_MATURITY
57
+ */
58
+
59
+ export const CAPABILITY_REGISTRY = {
60
+ // NAVIGATION CAPABILITIES
61
+ 'link-detection-href': {
62
+ id: 'link-detection-href',
63
+ category: CAPABILITY_CATEGORY.NAVIGATION,
64
+ description: 'Detects HTML links with href attributes and extracts navigation expectations',
65
+ requiredArtifacts: ['learn', 'findings', 'traces'],
66
+ maturity: CAPABILITY_MATURITY.STABLE
67
+ },
68
+ 'interactive-element-no-href': {
69
+ id: 'interactive-element-no-href',
70
+ category: CAPABILITY_CATEGORY.NAVIGATION,
71
+ description: 'Detects interactive elements (buttons, divs with onClick) that should navigate but lack href',
72
+ requiredArtifacts: ['learn', 'findings', 'traces'],
73
+ maturity: CAPABILITY_MATURITY.STABLE
74
+ },
75
+ 'navigation-silent-failure': {
76
+ id: 'navigation-silent-failure',
77
+ category: CAPABILITY_CATEGORY.NAVIGATION,
78
+ description: 'Detects when navigation is promised but fails silently (no URL change, no feedback)',
79
+ requiredArtifacts: ['findings', 'traces', 'evidence'],
80
+ maturity: CAPABILITY_MATURITY.STABLE
81
+ },
82
+ 'external-navigation-blocking': {
83
+ id: 'external-navigation-blocking',
84
+ category: CAPABILITY_CATEGORY.NAVIGATION,
85
+ description: 'Detects when external navigation is blocked by safety policies',
86
+ requiredArtifacts: ['findings', 'traces'],
87
+ maturity: CAPABILITY_MATURITY.STABLE
88
+ },
89
+
90
+ // ROUTE DETECTION CAPABILITIES
91
+ 'route-detection-react-router': {
92
+ id: 'route-detection-react-router',
93
+ category: CAPABILITY_CATEGORY.ROUTES,
94
+ description: 'Extracts routes from React Router configuration',
95
+ requiredArtifacts: ['learn', 'project'],
96
+ maturity: CAPABILITY_MATURITY.STABLE
97
+ },
98
+ 'route-detection-nextjs': {
99
+ id: 'route-detection-nextjs',
100
+ category: CAPABILITY_CATEGORY.ROUTES,
101
+ description: 'Extracts routes from Next.js file-based routing (app/ and pages/)',
102
+ requiredArtifacts: ['learn', 'project'],
103
+ maturity: CAPABILITY_MATURITY.STABLE
104
+ },
105
+ 'route-detection-vue-router': {
106
+ id: 'route-detection-vue-router',
107
+ category: CAPABILITY_CATEGORY.ROUTES,
108
+ description: 'Extracts routes from Vue Router configuration',
109
+ requiredArtifacts: ['learn', 'project'],
110
+ maturity: CAPABILITY_MATURITY.STABLE
111
+ },
112
+
113
+ // PHASE 20: Vue-specific capabilities
114
+ 'vue-navigation-detection': {
115
+ id: 'vue-navigation-detection',
116
+ category: CAPABILITY_CATEGORY.NAVIGATION,
117
+ description: 'Detects Vue Router navigation promises from <router-link> and router.push/replace in Vue SFCs',
118
+ requiredArtifacts: ['learn', 'findings', 'traces'],
119
+ maturity: CAPABILITY_MATURITY.STABLE
120
+ },
121
+ 'vue-network-detection': {
122
+ id: 'vue-network-detection',
123
+ category: CAPABILITY_CATEGORY.NETWORK,
124
+ description: 'Detects network calls (fetch/axios) inside Vue handlers, setup functions, and methods',
125
+ requiredArtifacts: ['learn', 'findings', 'traces'],
126
+ maturity: CAPABILITY_MATURITY.STABLE
127
+ },
128
+ 'vue-state-detection': {
129
+ id: 'vue-state-detection',
130
+ category: CAPABILITY_CATEGORY.STATE,
131
+ description: 'Detects Vue ref/reactive state mutations that are UI-bound via template bindings',
132
+ requiredArtifacts: ['learn', 'findings', 'traces'],
133
+ maturity: CAPABILITY_MATURITY.STABLE
134
+ },
135
+
136
+ // PHASE 20: Svelte-specific capabilities
137
+ 'svelte-navigation-detection': {
138
+ id: 'svelte-navigation-detection',
139
+ category: CAPABILITY_CATEGORY.NAVIGATION,
140
+ description: 'Detects Svelte navigation promises from <a href> links and goto() calls in Svelte SFCs',
141
+ requiredArtifacts: ['learn', 'findings', 'traces'],
142
+ maturity: CAPABILITY_MATURITY.STABLE
143
+ },
144
+ 'svelte-network-detection': {
145
+ id: 'svelte-network-detection',
146
+ category: CAPABILITY_CATEGORY.NETWORK,
147
+ description: 'Detects network calls (fetch/axios) inside Svelte handlers, functions, and reactive statements',
148
+ requiredArtifacts: ['learn', 'findings', 'traces'],
149
+ maturity: CAPABILITY_MATURITY.STABLE
150
+ },
151
+ 'svelte-state-detection': {
152
+ id: 'svelte-state-detection',
153
+ category: CAPABILITY_CATEGORY.STATE,
154
+ description: 'Detects Svelte reactive store mutations and variable assignments that are UI-bound via markup bindings',
155
+ requiredArtifacts: ['learn', 'findings', 'traces'],
156
+ maturity: CAPABILITY_MATURITY.STABLE
157
+ },
158
+
159
+ // PHASE 20: Angular-specific capabilities
160
+ 'angular-navigation-detection': {
161
+ id: 'angular-navigation-detection',
162
+ category: CAPABILITY_CATEGORY.NAVIGATION,
163
+ description: 'Detects Angular navigation promises from routerLink directives and Router.navigate() calls in Angular components',
164
+ requiredArtifacts: ['learn', 'findings', 'traces'],
165
+ maturity: CAPABILITY_MATURITY.STABLE
166
+ },
167
+ 'angular-network-detection': {
168
+ id: 'angular-network-detection',
169
+ category: CAPABILITY_CATEGORY.NETWORK,
170
+ description: 'Detects network calls (HttpClient, fetch) inside Angular component methods and services',
171
+ requiredArtifacts: ['learn', 'findings', 'traces'],
172
+ maturity: CAPABILITY_MATURITY.STABLE
173
+ },
174
+ 'angular-state-detection': {
175
+ id: 'angular-state-detection',
176
+ category: CAPABILITY_CATEGORY.STATE,
177
+ description: 'Detects Angular component property mutations that are UI-bound via template bindings',
178
+ requiredArtifacts: ['learn', 'findings', 'traces'],
179
+ maturity: CAPABILITY_MATURITY.STABLE
180
+ },
181
+
182
+ 'route-validation-reachability': {
183
+ id: 'route-validation-reachability',
184
+ category: CAPABILITY_CATEGORY.ROUTES,
185
+ description: 'Validates that discovered routes are reachable via HTTP',
186
+ requiredArtifacts: ['learn', 'summary'],
187
+ maturity: CAPABILITY_MATURITY.STABLE
188
+ },
189
+ 'dynamic-route-normalization': {
190
+ id: 'dynamic-route-normalization',
191
+ category: CAPABILITY_CATEGORY.ROUTES,
192
+ description: 'Normalizes dynamic route patterns (/:param, /[slug]) to example paths',
193
+ requiredArtifacts: ['learn'],
194
+ maturity: CAPABILITY_MATURITY.STABLE
195
+ },
196
+ 'route-intelligence-correlation': {
197
+ id: 'route-intelligence-correlation',
198
+ category: CAPABILITY_CATEGORY.ROUTES,
199
+ description: 'Correlates navigation promises with route definitions and evaluates outcomes',
200
+ requiredArtifacts: ['learn', 'detect'],
201
+ maturity: CAPABILITY_MATURITY.STABLE
202
+ },
203
+ 'dynamic-route-intelligence': {
204
+ id: 'dynamic-route-intelligence',
205
+ category: CAPABILITY_CATEGORY.ROUTES,
206
+ description: 'Classifies dynamic routes by verifiability and produces evidence-backed findings or explicit skips',
207
+ requiredArtifacts: ['learn', 'detect', 'evidence'],
208
+ maturity: CAPABILITY_MATURITY.STABLE
209
+ },
210
+
211
+ // NETWORK CAPABILITIES
212
+ 'network-detection-top-level': {
213
+ id: 'network-detection-top-level',
214
+ category: CAPABILITY_CATEGORY.NETWORK,
215
+ description: 'Detects network calls (fetch/axios) at top-level of component or module',
216
+ requiredArtifacts: ['learn', 'findings', 'traces'],
217
+ maturity: CAPABILITY_MATURITY.STABLE
218
+ },
219
+ 'network-detection-handler': {
220
+ id: 'network-detection-handler',
221
+ category: CAPABILITY_CATEGORY.NETWORK,
222
+ description: 'Detects network calls inside event handlers (onClick, onSubmit, etc.)',
223
+ requiredArtifacts: ['learn', 'findings', 'traces'],
224
+ maturity: CAPABILITY_MATURITY.STABLE
225
+ },
226
+ 'network-detection-useeffect': {
227
+ id: 'network-detection-useeffect',
228
+ category: CAPABILITY_CATEGORY.NETWORK,
229
+ description: 'Detects network calls inside React useEffect hooks',
230
+ requiredArtifacts: ['learn', 'findings', 'traces'],
231
+ maturity: CAPABILITY_MATURITY.STABLE
232
+ },
233
+ 'network-silent-failure': {
234
+ id: 'network-silent-failure',
235
+ category: CAPABILITY_CATEGORY.NETWORK,
236
+ description: 'Detects when network requests fail silently (no user feedback)',
237
+ requiredArtifacts: ['findings', 'traces', 'evidence'],
238
+ maturity: CAPABILITY_MATURITY.STABLE
239
+ },
240
+ 'network-request-observation': {
241
+ id: 'network-request-observation',
242
+ category: CAPABILITY_CATEGORY.NETWORK,
243
+ description: 'Observes actual network requests during interaction execution',
244
+ requiredArtifacts: ['traces', 'evidence'],
245
+ maturity: CAPABILITY_MATURITY.STABLE
246
+ },
247
+
248
+ // STATE CAPABILITIES
249
+ 'state-detection-usestate': {
250
+ id: 'state-detection-usestate',
251
+ category: CAPABILITY_CATEGORY.STATE,
252
+ description: 'Detects React useState hooks and extracts state mutation promises',
253
+ requiredArtifacts: ['learn', 'findings', 'traces'],
254
+ maturity: CAPABILITY_MATURITY.STABLE
255
+ },
256
+ 'state-detection-redux': {
257
+ id: 'state-detection-redux',
258
+ category: CAPABILITY_CATEGORY.STATE,
259
+ description: 'Detects Redux store dispatch calls and extracts state mutation promises',
260
+ requiredArtifacts: ['learn', 'findings', 'traces'],
261
+ maturity: CAPABILITY_MATURITY.PARTIAL
262
+ },
263
+ 'state-detection-zustand': {
264
+ id: 'state-detection-zustand',
265
+ category: CAPABILITY_CATEGORY.STATE,
266
+ description: 'Detects Zustand store set calls and extracts state mutation promises',
267
+ requiredArtifacts: ['learn', 'findings', 'traces'],
268
+ maturity: CAPABILITY_MATURITY.PARTIAL
269
+ },
270
+ 'state-mutation-observation': {
271
+ id: 'state-mutation-observation',
272
+ category: CAPABILITY_CATEGORY.STATE,
273
+ description: 'Observes actual state mutations during interaction execution',
274
+ requiredArtifacts: ['traces', 'evidence'],
275
+ maturity: CAPABILITY_MATURITY.PARTIAL
276
+ },
277
+ 'state-silent-failure': {
278
+ id: 'state-silent-failure',
279
+ category: CAPABILITY_CATEGORY.STATE,
280
+ description: 'Detects when state mutations are promised but fail silently',
281
+ requiredArtifacts: ['findings', 'traces', 'evidence'],
282
+ maturity: CAPABILITY_MATURITY.PARTIAL
283
+ },
284
+ 'state-driven-view-switch': {
285
+ id: 'state-driven-view-switch',
286
+ category: CAPABILITY_CATEGORY.STATE,
287
+ description: 'Detects state-driven navigation/view switches without URL changes (setView, setTab, dispatch(NAVIGATE), etc.)',
288
+ requiredArtifacts: ['learn', 'findings', 'traces', 'evidence'],
289
+ maturity: CAPABILITY_MATURITY.STABLE
290
+ },
291
+
292
+ // UI FEEDBACK CAPABILITIES
293
+ 'ui-feedback-loading': {
294
+ id: 'ui-feedback-loading',
295
+ category: CAPABILITY_CATEGORY.UI_FEEDBACK,
296
+ description: 'Detects loading indicators (spinners, progress bars, aria-busy)',
297
+ requiredArtifacts: ['traces', 'evidence'],
298
+ maturity: CAPABILITY_MATURITY.STABLE
299
+ },
300
+ 'ui-feedback-css-spinner': {
301
+ id: 'ui-feedback-css-spinner',
302
+ category: CAPABILITY_CATEGORY.UI_FEEDBACK,
303
+ description: 'Detects CSS-only loading indicators (spinners) without semantic attributes using visual patterns',
304
+ requiredArtifacts: ['traces', 'evidence'],
305
+ maturity: CAPABILITY_MATURITY.STABLE
306
+ },
307
+ 'ui-feedback-disabled': {
308
+ id: 'ui-feedback-disabled',
309
+ category: CAPABILITY_CATEGORY.UI_FEEDBACK,
310
+ description: 'Detects button/input disabled state changes',
311
+ requiredArtifacts: ['traces', 'evidence'],
312
+ maturity: CAPABILITY_MATURITY.STABLE
313
+ },
314
+ 'ui-feedback-toast': {
315
+ id: 'ui-feedback-toast',
316
+ category: CAPABILITY_CATEGORY.UI_FEEDBACK,
317
+ description: 'Detects toast notifications and alert messages',
318
+ requiredArtifacts: ['traces', 'evidence'],
319
+ maturity: CAPABILITY_MATURITY.STABLE
320
+ },
321
+ 'ui-feedback-dom-change': {
322
+ id: 'ui-feedback-dom-change',
323
+ category: CAPABILITY_CATEGORY.UI_FEEDBACK,
324
+ description: 'Detects meaningful DOM changes (element additions, text changes)',
325
+ requiredArtifacts: ['traces', 'evidence'],
326
+ maturity: CAPABILITY_MATURITY.STABLE
327
+ },
328
+ 'ui-feedback-missing': {
329
+ id: 'ui-feedback-missing',
330
+ category: CAPABILITY_CATEGORY.UI_FEEDBACK,
331
+ description: 'Detects when user actions should show feedback but none is observed',
332
+ requiredArtifacts: ['findings', 'traces'],
333
+ maturity: CAPABILITY_MATURITY.STABLE
334
+ },
335
+ 'ui-feedback-intelligence': {
336
+ id: 'ui-feedback-intelligence',
337
+ category: CAPABILITY_CATEGORY.UI_FEEDBACK,
338
+ description: 'Correlates promises with UI feedback signals and produces evidence-backed findings',
339
+ requiredArtifacts: ['findings', 'traces', 'evidence'],
340
+ maturity: CAPABILITY_MATURITY.STABLE
341
+ },
342
+
343
+ // CONFIDENCE CAPABILITIES
344
+ 'confidence-unified-system': {
345
+ id: 'confidence-unified-system',
346
+ category: CAPABILITY_CATEGORY.ANALYSIS,
347
+ description: 'Unified confidence system computing score (0..1), level (HIGH/MEDIUM/LOW/UNPROVEN), and stable reason codes',
348
+ requiredArtifacts: ['findings'],
349
+ maturity: CAPABILITY_MATURITY.STABLE
350
+ },
351
+
352
+ // VALIDATION CAPABILITIES
353
+ 'validation-feedback-detection': {
354
+ id: 'validation-feedback-detection',
355
+ category: CAPABILITY_CATEGORY.VALIDATION,
356
+ description: 'Detects form validation feedback (error messages, visual indicators)',
357
+ requiredArtifacts: ['traces', 'evidence'],
358
+ maturity: CAPABILITY_MATURITY.STABLE
359
+ },
360
+ 'validation-silent-failure': {
361
+ id: 'validation-silent-failure',
362
+ category: CAPABILITY_CATEGORY.VALIDATION,
363
+ description: 'Detects when validation should block submission but does not',
364
+ requiredArtifacts: ['findings', 'traces'],
365
+ maturity: CAPABILITY_MATURITY.STABLE
366
+ },
367
+
368
+ // EVIDENCE LAW CAPABILITIES
369
+ 'evidence-law-enforcement': {
370
+ id: 'evidence-law-enforcement',
371
+ category: CAPABILITY_CATEGORY.EVIDENCE,
372
+ description: 'Enforces Evidence Law: CONFIRMED findings must have sufficient evidence',
373
+ requiredArtifacts: ['findings'],
374
+ maturity: CAPABILITY_MATURITY.STABLE
375
+ },
376
+ 'evidence-substantive-check': {
377
+ id: 'evidence-substantive-check',
378
+ category: CAPABILITY_CATEGORY.EVIDENCE,
379
+ description: 'Validates that evidence contains substantive signals (not empty)',
380
+ requiredArtifacts: ['findings'],
381
+ maturity: CAPABILITY_MATURITY.STABLE
382
+ },
383
+ 'evidence-downgrade-suspected': {
384
+ id: 'evidence-downgrade-suspected',
385
+ category: CAPABILITY_CATEGORY.EVIDENCE,
386
+ description: 'Downgrades findings from CONFIRMED to SUSPECTED when evidence is insufficient',
387
+ requiredArtifacts: ['findings'],
388
+ maturity: CAPABILITY_MATURITY.STABLE
389
+ },
390
+ 'guardrails-truth-reconciliation': {
391
+ id: 'guardrails-truth-reconciliation',
392
+ category: CAPABILITY_CATEGORY.ANALYSIS,
393
+ description: 'Reconciles confidence with guardrails outcome to ensure consistent truth boundaries',
394
+ requiredArtifacts: ['findings', 'guardrailsReport'],
395
+ maturity: CAPABILITY_MATURITY.STABLE
396
+ },
397
+ 'confidence-engine-hardening': {
398
+ id: 'confidence-engine-hardening',
399
+ category: CAPABILITY_CATEGORY.ANALYSIS,
400
+ description: 'Enforces formal confidence invariants and provides audit-grade confidence artifacts',
401
+ requiredArtifacts: ['findings', 'confidenceReport'],
402
+ maturity: CAPABILITY_MATURITY.STABLE
403
+ },
404
+ 'determinism-hardening': {
405
+ id: 'determinism-hardening',
406
+ category: CAPABILITY_CATEGORY.RELIABILITY,
407
+ description: 'Ensures VERAX produces provably deterministic outputs and reports non-determinism explicitly',
408
+ requiredArtifacts: ['determinismReport', 'determinismContract'],
409
+ maturity: CAPABILITY_MATURITY.STABLE
410
+ },
411
+ 'security-baseline-enforcement': {
412
+ id: 'security-baseline-enforcement',
413
+ category: CAPABILITY_CATEGORY.SECURITY,
414
+ description: 'Enforces security baseline checks including secret scanning, vulnerability scanning, and supply-chain policy',
415
+ requiredArtifacts: ['securityReport'],
416
+ maturity: CAPABILITY_MATURITY.STABLE
417
+ },
418
+ 'ga-release-readiness': {
419
+ id: 'ga-release-readiness',
420
+ category: CAPABILITY_CATEGORY.RELEASE,
421
+ description: 'Evaluates and enforces GA readiness criteria for releases, including gates, determinism, verifier, and security',
422
+ requiredArtifacts: ['gaReport'],
423
+ maturity: CAPABILITY_MATURITY.STABLE
424
+ },
425
+ 'enterprise-operational-guarantees': {
426
+ id: 'enterprise-operational-guarantees',
427
+ category: CAPABILITY_CATEGORY.OPERATIONS,
428
+ description: 'Ensures crash-proof CLI, structured logging, and never-silent failure reporting for all commands',
429
+ requiredArtifacts: [], // Operational guarantees are mostly about internal behavior and logging
430
+ maturity: CAPABILITY_MATURITY.STABLE
431
+ },
432
+ 'performance-budget-clarity': {
433
+ id: 'performance-budget-clarity',
434
+ category: CAPABILITY_CATEGORY.PERFORMANCE,
435
+ description: 'Provides clear performance reports with scan budget, actual usage, stage timings, and memory snapshots',
436
+ requiredArtifacts: ['performanceReport'],
437
+ maturity: CAPABILITY_MATURITY.STABLE
438
+ }
439
+ };
440
+
441
+ /**
442
+ * Get all capability IDs
443
+ * @returns {string[]}
444
+ */
445
+ export function getAllCapabilityIds() {
446
+ return Object.keys(CAPABILITY_REGISTRY);
447
+ }
448
+
449
+ /**
450
+ * Get capabilities by category
451
+ * @param {string} category
452
+ * @returns {Object[]}
453
+ */
454
+ export function getCapabilitiesByCategory(category) {
455
+ return Object.values(CAPABILITY_REGISTRY).filter(cap => cap.category === category);
456
+ }
457
+
458
+ /**
459
+ * Get capability by ID
460
+ * @param {string} id
461
+ * @returns {Capability|null}
462
+ */
463
+ export function getCapability(id) {
464
+ return CAPABILITY_REGISTRY[id] || null;
465
+ }
466
+
467
+ /**
468
+ * Validate that a capability exists
469
+ * @param {string} id
470
+ * @returns {boolean}
471
+ */
472
+ export function isValidCapability(id) {
473
+ return id in CAPABILITY_REGISTRY;
474
+ }
475
+
@@ -0,0 +1,137 @@
1
+ /**
2
+ * PHASE 24 — Centralized Confidence Computation
3
+ *
4
+ * Single entry point for all confidence calculations.
5
+ * No capability may compute confidence independently.
6
+ */
7
+
8
+ import { computeConfidenceForFinding } from '../confidence-engine.js';
9
+ import { CONFIDENCE_WEIGHTS } from './confidence-weights.js';
10
+ import { checkConfidenceInvariants, enforceConfidenceInvariants } from './confidence-invariants.js';
11
+
12
+ /**
13
+ * Compute final confidence with full truth-aware reconciliation
14
+ *
15
+ * @param {Object} params - Confidence computation parameters
16
+ * @param {Object} params.rawSignals - Raw sensor signals
17
+ * @param {Object} params.evidenceIntent - Evidence intent (from evidence.intent.json)
18
+ * @param {Object} params.guardrailsOutcome - Guardrails outcome (from guardrails.report.json)
19
+ * @param {string} params.truthStatus - Final truth status (CONFIRMED/SUSPECTED/INFORMATIONAL/IGNORED)
20
+ * @param {Object} params.expectation - Expectation object
21
+ * @param {Object} params.sensors - Sensor data
22
+ * @param {Object} params.comparisons - Comparison data
23
+ * @param {Object} params.evidence - Evidence data
24
+ * @param {Object} params.options - Options { policyPath, projectDir, determinismVerdict, verificationStatus }
25
+ * @returns {Object} { confidenceBefore, confidenceAfter, appliedInvariants, explanation, invariantViolations }
26
+ */
27
+ export function computeFinalConfidence(params) {
28
+ const {
29
+ rawSignals = {},
30
+ evidenceIntent = null,
31
+ guardrailsOutcome = null,
32
+ truthStatus = null,
33
+ expectation = null,
34
+ sensors = {},
35
+ comparisons = {},
36
+ evidence = {},
37
+ options = {}
38
+ } = params;
39
+
40
+ // Step 1: Compute raw confidence using unified engine
41
+ const rawConfidenceResult = computeConfidenceForFinding({
42
+ findingType: params.findingType || 'unknown',
43
+ expectation,
44
+ sensors: rawSignals || sensors,
45
+ comparisons,
46
+ evidence,
47
+ options
48
+ });
49
+
50
+ const confidenceBefore = rawConfidenceResult.score || 0;
51
+ const explanation = [...(rawConfidenceResult.reasons || [])];
52
+
53
+ // Step 2: Apply evidence intent adjustments
54
+ let adjustedConfidence = confidenceBefore;
55
+ if (evidenceIntent) {
56
+ const captureFailures = Object.values(evidenceIntent.captureOutcomes || {})
57
+ .filter(outcome => outcome.captured === false).length;
58
+ if (captureFailures > 0) {
59
+ const penalty = Math.min(0.2, captureFailures * 0.05);
60
+ adjustedConfidence = Math.max(0, adjustedConfidence - penalty);
61
+ explanation.push(`EVIDENCE_INTENT_FAILURES: ${captureFailures} capture failures, penalty: ${penalty}`);
62
+ }
63
+ }
64
+
65
+ // Step 3: Apply guardrails outcome adjustments
66
+ let guardrailsAdjustedConfidence = adjustedConfidence;
67
+ if (guardrailsOutcome) {
68
+ const guardrailsDelta = guardrailsOutcome.confidenceDelta || 0;
69
+ guardrailsAdjustedConfidence = Math.max(0, Math.min(1, adjustedConfidence + guardrailsDelta));
70
+ if (guardrailsDelta !== 0) {
71
+ explanation.push(`GUARDRAILS_ADJUSTMENT: delta=${guardrailsDelta.toFixed(3)}`);
72
+ }
73
+ }
74
+
75
+ // Step 4: Determine truth status (use guardrails outcome if available, otherwise use provided)
76
+ const finalTruthStatus = truthStatus ||
77
+ guardrailsOutcome?.finalDecision ||
78
+ guardrailsOutcome?.recommendedStatus ||
79
+ 'SUSPECTED';
80
+
81
+ // Step 5: Check and enforce invariants
82
+ const expectationProof = expectation?.proof || null;
83
+ const verificationStatus = options.verificationStatus || null;
84
+
85
+ const invariantCheck = checkConfidenceInvariants(
86
+ guardrailsAdjustedConfidence,
87
+ finalTruthStatus,
88
+ {
89
+ expectationProof,
90
+ verificationStatus,
91
+ guardrailsOutcome
92
+ }
93
+ );
94
+
95
+ const confidenceAfter = invariantCheck.correctedConfidence;
96
+ const appliedInvariants = [];
97
+ const invariantViolations = [];
98
+
99
+ if (invariantCheck.violated) {
100
+ for (const violation of invariantCheck.violations) {
101
+ appliedInvariants.push(violation.code);
102
+ invariantViolations.push({
103
+ code: violation.code,
104
+ message: violation.message,
105
+ originalConfidence: guardrailsAdjustedConfidence,
106
+ correctedConfidence: violation.corrected
107
+ });
108
+ explanation.push(`INVARIANT_ENFORCED: ${violation.message}`);
109
+ }
110
+ }
111
+
112
+ // Step 6: Determine final confidence level
113
+ const confidenceLevel = determineConfidenceLevel(confidenceAfter);
114
+
115
+ return {
116
+ confidenceBefore,
117
+ confidenceAfter,
118
+ confidenceLevel,
119
+ appliedInvariants,
120
+ invariantViolations,
121
+ explanation: explanation.slice(0, 20), // Limit to 20 for determinism
122
+ truthStatus: finalTruthStatus,
123
+ expectationProof,
124
+ verificationStatus
125
+ };
126
+ }
127
+
128
+ /**
129
+ * Determine confidence level from score
130
+ */
131
+ function determineConfidenceLevel(score) {
132
+ if (score >= 0.80) return 'HIGH';
133
+ if (score >= 0.50) return 'MEDIUM';
134
+ if (score >= 0.20) return 'LOW';
135
+ return 'UNPROVEN';
136
+ }
137
+