@veraxhq/verax 0.2.1 → 0.4.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.
- package/README.md +10 -6
- package/bin/verax.js +11 -11
- package/package.json +29 -8
- package/src/cli/commands/baseline.js +103 -0
- package/src/cli/commands/default.js +51 -6
- package/src/cli/commands/doctor.js +29 -0
- package/src/cli/commands/ga.js +246 -0
- package/src/cli/commands/gates.js +95 -0
- package/src/cli/commands/inspect.js +4 -2
- package/src/cli/commands/release-check.js +215 -0
- package/src/cli/commands/run.js +45 -6
- package/src/cli/commands/security-check.js +212 -0
- package/src/cli/commands/truth.js +113 -0
- package/src/cli/entry.js +30 -20
- package/src/cli/util/angular-component-extractor.js +179 -0
- package/src/cli/util/angular-navigation-detector.js +141 -0
- package/src/cli/util/angular-network-detector.js +161 -0
- package/src/cli/util/angular-state-detector.js +162 -0
- package/src/cli/util/ast-interactive-detector.js +544 -0
- package/src/cli/util/ast-network-detector.js +603 -0
- package/src/cli/util/ast-promise-extractor.js +581 -0
- package/src/cli/util/ast-usestate-detector.js +602 -0
- package/src/cli/util/atomic-write.js +12 -1
- package/src/cli/util/bootstrap-guard.js +86 -0
- package/src/cli/util/console-reporter.js +72 -0
- package/src/cli/util/detection-engine.js +105 -41
- package/src/cli/util/determinism-runner.js +124 -0
- package/src/cli/util/determinism-writer.js +129 -0
- package/src/cli/util/digest-engine.js +359 -0
- package/src/cli/util/dom-diff.js +226 -0
- package/src/cli/util/evidence-engine.js +287 -0
- package/src/cli/util/expectation-extractor.js +151 -5
- package/src/cli/util/findings-writer.js +3 -0
- package/src/cli/util/framework-detector.js +572 -0
- package/src/cli/util/idgen.js +1 -1
- package/src/cli/util/interaction-planner.js +529 -0
- package/src/cli/util/learn-writer.js +2 -0
- package/src/cli/util/ledger-writer.js +110 -0
- package/src/cli/util/monorepo-resolver.js +162 -0
- package/src/cli/util/observation-engine.js +127 -278
- package/src/cli/util/observe-writer.js +2 -0
- package/src/cli/util/project-discovery.js +284 -0
- package/src/cli/util/project-writer.js +2 -0
- package/src/cli/util/run-id.js +23 -27
- package/src/cli/util/run-resolver.js +64 -0
- package/src/cli/util/run-result.js +778 -0
- package/src/cli/util/selector-resolver.js +235 -0
- package/src/cli/util/source-requirement.js +55 -0
- package/src/cli/util/summary-writer.js +2 -0
- package/src/cli/util/svelte-navigation-detector.js +163 -0
- package/src/cli/util/svelte-network-detector.js +80 -0
- package/src/cli/util/svelte-sfc-extractor.js +146 -0
- package/src/cli/util/svelte-state-detector.js +242 -0
- package/src/cli/util/trust-activation-integration.js +496 -0
- package/src/cli/util/trust-activation-wrapper.js +85 -0
- package/src/cli/util/trust-integration-hooks.js +164 -0
- package/src/cli/util/types.js +153 -0
- package/src/cli/util/url-validation.js +40 -0
- package/src/cli/util/vue-navigation-detector.js +178 -0
- package/src/cli/util/vue-sfc-extractor.js +161 -0
- package/src/cli/util/vue-state-detector.js +215 -0
- package/src/types/fs-augment.d.ts +23 -0
- package/src/types/global.d.ts +137 -0
- package/src/types/internal-types.d.ts +35 -0
- package/src/verax/cli/init.js +4 -18
- package/src/verax/core/action-classifier.js +4 -3
- package/src/verax/core/artifacts/registry.js +139 -0
- package/src/verax/core/artifacts/verifier.js +990 -0
- package/src/verax/core/baseline/baseline.enforcer.js +137 -0
- package/src/verax/core/baseline/baseline.snapshot.js +233 -0
- package/src/verax/core/capabilities/gates.js +505 -0
- package/src/verax/core/capabilities/registry.js +475 -0
- package/src/verax/core/confidence/confidence-compute.js +144 -0
- package/src/verax/core/confidence/confidence-invariants.js +234 -0
- package/src/verax/core/confidence/confidence-report-writer.js +112 -0
- package/src/verax/core/confidence/confidence-weights.js +44 -0
- package/src/verax/core/confidence/confidence.defaults.js +65 -0
- package/src/verax/core/confidence/confidence.loader.js +80 -0
- package/src/verax/core/confidence/confidence.schema.js +94 -0
- package/src/verax/core/confidence-engine-refactor.js +489 -0
- package/src/verax/core/confidence-engine.js +625 -0
- package/src/verax/core/contracts/index.js +29 -0
- package/src/verax/core/contracts/types.js +186 -0
- package/src/verax/core/contracts/validators.js +456 -0
- package/src/verax/core/decisions/decision.trace.js +278 -0
- package/src/verax/core/determinism/contract-writer.js +89 -0
- package/src/verax/core/determinism/contract.js +139 -0
- package/src/verax/core/determinism/diff.js +405 -0
- package/src/verax/core/determinism/engine.js +222 -0
- package/src/verax/core/determinism/finding-identity.js +149 -0
- package/src/verax/core/determinism/normalize.js +466 -0
- package/src/verax/core/determinism/report-writer.js +93 -0
- package/src/verax/core/determinism/run-fingerprint.js +123 -0
- package/src/verax/core/dynamic-route-intelligence.js +529 -0
- package/src/verax/core/evidence/evidence-capture-service.js +308 -0
- package/src/verax/core/evidence/evidence-intent-ledger.js +166 -0
- package/src/verax/core/evidence-builder.js +487 -0
- package/src/verax/core/execution-mode-context.js +77 -0
- package/src/verax/core/execution-mode-detector.js +192 -0
- package/src/verax/core/failures/exit-codes.js +88 -0
- package/src/verax/core/failures/failure-summary.js +76 -0
- package/src/verax/core/failures/failure.factory.js +225 -0
- package/src/verax/core/failures/failure.ledger.js +133 -0
- package/src/verax/core/failures/failure.types.js +196 -0
- package/src/verax/core/failures/index.js +10 -0
- package/src/verax/core/ga/ga-report-writer.js +43 -0
- package/src/verax/core/ga/ga.artifact.js +49 -0
- package/src/verax/core/ga/ga.contract.js +435 -0
- package/src/verax/core/ga/ga.enforcer.js +87 -0
- package/src/verax/core/guardrails/guardrails-report-writer.js +109 -0
- package/src/verax/core/guardrails/policy.defaults.js +210 -0
- package/src/verax/core/guardrails/policy.loader.js +84 -0
- package/src/verax/core/guardrails/policy.schema.js +110 -0
- package/src/verax/core/guardrails/truth-reconciliation.js +136 -0
- package/src/verax/core/guardrails-engine.js +505 -0
- package/src/verax/core/incremental-store.js +1 -0
- package/src/verax/core/integrity/budget.js +138 -0
- package/src/verax/core/integrity/determinism.js +342 -0
- package/src/verax/core/integrity/integrity.js +208 -0
- package/src/verax/core/integrity/poisoning.js +108 -0
- package/src/verax/core/integrity/transaction.js +140 -0
- package/src/verax/core/observe/run-timeline.js +318 -0
- package/src/verax/core/perf/perf.contract.js +186 -0
- package/src/verax/core/perf/perf.display.js +65 -0
- package/src/verax/core/perf/perf.enforcer.js +91 -0
- package/src/verax/core/perf/perf.monitor.js +209 -0
- package/src/verax/core/perf/perf.report.js +200 -0
- package/src/verax/core/pipeline-tracker.js +243 -0
- package/src/verax/core/product-definition.js +127 -0
- package/src/verax/core/release/provenance.builder.js +130 -0
- package/src/verax/core/release/release-report-writer.js +40 -0
- package/src/verax/core/release/release.enforcer.js +164 -0
- package/src/verax/core/release/reproducibility.check.js +222 -0
- package/src/verax/core/release/sbom.builder.js +292 -0
- package/src/verax/core/replay-validator.js +2 -0
- package/src/verax/core/replay.js +4 -0
- package/src/verax/core/report/cross-index.js +195 -0
- package/src/verax/core/report/human-summary.js +362 -0
- package/src/verax/core/route-intelligence.js +420 -0
- package/src/verax/core/run-id.js +6 -3
- package/src/verax/core/run-manifest.js +4 -3
- package/src/verax/core/security/secrets.scan.js +329 -0
- package/src/verax/core/security/security-report.js +50 -0
- package/src/verax/core/security/security.enforcer.js +128 -0
- package/src/verax/core/security/supplychain.defaults.json +38 -0
- package/src/verax/core/security/supplychain.policy.js +334 -0
- package/src/verax/core/security/vuln.scan.js +265 -0
- package/src/verax/core/truth/truth.certificate.js +252 -0
- package/src/verax/core/ui-feedback-intelligence.js +481 -0
- package/src/verax/detect/conditional-ui-silent-failure.js +84 -0
- package/src/verax/detect/confidence-engine.js +62 -34
- package/src/verax/detect/confidence-helper.js +34 -0
- package/src/verax/detect/dynamic-route-findings.js +338 -0
- package/src/verax/detect/expectation-chain-detector.js +417 -0
- package/src/verax/detect/expectation-model.js +2 -2
- package/src/verax/detect/failure-cause-inference.js +293 -0
- package/src/verax/detect/findings-writer.js +131 -35
- package/src/verax/detect/flow-detector.js +2 -2
- package/src/verax/detect/form-silent-failure.js +98 -0
- package/src/verax/detect/index.js +46 -5
- package/src/verax/detect/invariants-enforcer.js +147 -0
- package/src/verax/detect/journey-stall-detector.js +558 -0
- package/src/verax/detect/navigation-silent-failure.js +82 -0
- package/src/verax/detect/problem-aggregator.js +361 -0
- package/src/verax/detect/route-findings.js +219 -0
- package/src/verax/detect/summary-writer.js +477 -0
- package/src/verax/detect/test-failure-cause-inference.js +314 -0
- package/src/verax/detect/ui-feedback-findings.js +207 -0
- package/src/verax/detect/view-switch-correlator.js +242 -0
- package/src/verax/flow/flow-engine.js +2 -1
- package/src/verax/flow/flow-spec.js +0 -6
- package/src/verax/index.js +4 -0
- package/src/verax/intel/ts-program.js +1 -0
- package/src/verax/intel/vue-navigation-extractor.js +3 -0
- package/src/verax/learn/action-contract-extractor.js +3 -0
- package/src/verax/learn/ast-contract-extractor.js +1 -1
- package/src/verax/learn/flow-extractor.js +1 -0
- package/src/verax/learn/project-detector.js +5 -0
- package/src/verax/learn/react-router-extractor.js +2 -0
- package/src/verax/learn/source-instrumenter.js +1 -0
- package/src/verax/learn/state-extractor.js +2 -1
- package/src/verax/learn/static-extractor.js +1 -0
- package/src/verax/observe/coverage-gaps.js +132 -0
- package/src/verax/observe/expectation-handler.js +126 -0
- package/src/verax/observe/incremental-skip.js +46 -0
- package/src/verax/observe/index.js +51 -155
- package/src/verax/observe/interaction-executor.js +192 -0
- package/src/verax/observe/interaction-runner.js +782 -513
- package/src/verax/observe/network-firewall.js +86 -0
- package/src/verax/observe/observation-builder.js +169 -0
- package/src/verax/observe/observe-context.js +205 -0
- package/src/verax/observe/observe-helpers.js +192 -0
- package/src/verax/observe/observe-runner.js +230 -0
- package/src/verax/observe/observers/budget-observer.js +185 -0
- package/src/verax/observe/observers/console-observer.js +102 -0
- package/src/verax/observe/observers/coverage-observer.js +107 -0
- package/src/verax/observe/observers/interaction-observer.js +471 -0
- package/src/verax/observe/observers/navigation-observer.js +132 -0
- package/src/verax/observe/observers/network-observer.js +87 -0
- package/src/verax/observe/observers/safety-observer.js +82 -0
- package/src/verax/observe/observers/ui-feedback-observer.js +99 -0
- package/src/verax/observe/page-traversal.js +138 -0
- package/src/verax/observe/snapshot-ops.js +94 -0
- package/src/verax/observe/ui-feedback-detector.js +742 -0
- package/src/verax/scan-summary-writer.js +2 -0
- package/src/verax/shared/artifact-manager.js +25 -5
- package/src/verax/shared/caching.js +1 -0
- package/src/verax/shared/css-spinner-rules.js +204 -0
- package/src/verax/shared/expectation-tracker.js +1 -0
- package/src/verax/shared/view-switch-rules.js +208 -0
- package/src/verax/shared/zip-artifacts.js +6 -0
- package/src/verax/shared/config-loader.js +0 -169
- /package/src/verax/shared/{expectation-proof.js → expectation-validation.js} +0 -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,144 @@
|
|
|
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 as _CONFIDENCE_WEIGHTS } from './confidence-weights.js';
|
|
10
|
+
import { checkConfidenceInvariants, enforceConfidenceInvariants as _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
|
+
// @ts-expect-error - Optional params structure
|
|
43
|
+
findingType: params.findingType || 'unknown',
|
|
44
|
+
expectation,
|
|
45
|
+
sensors: rawSignals || sensors,
|
|
46
|
+
comparisons,
|
|
47
|
+
evidence,
|
|
48
|
+
options
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const confidenceBefore = rawConfidenceResult.score || 0;
|
|
52
|
+
const explanation = [...(rawConfidenceResult.reasons || [])];
|
|
53
|
+
|
|
54
|
+
// Step 2: Apply evidence intent adjustments
|
|
55
|
+
let adjustedConfidence = confidenceBefore;
|
|
56
|
+
if (evidenceIntent) {
|
|
57
|
+
const captureFailures = Object.values(evidenceIntent.captureOutcomes || {})
|
|
58
|
+
.filter(outcome => outcome.captured === false).length;
|
|
59
|
+
if (captureFailures > 0) {
|
|
60
|
+
const penalty = Math.min(0.2, captureFailures * 0.05);
|
|
61
|
+
adjustedConfidence = Math.max(0, adjustedConfidence - penalty);
|
|
62
|
+
explanation.push(`EVIDENCE_INTENT_FAILURES: ${captureFailures} capture failures, penalty: ${penalty}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Step 3: Apply guardrails outcome adjustments
|
|
67
|
+
let guardrailsAdjustedConfidence = adjustedConfidence;
|
|
68
|
+
if (guardrailsOutcome) {
|
|
69
|
+
const guardrailsDelta = guardrailsOutcome.confidenceDelta || 0;
|
|
70
|
+
guardrailsAdjustedConfidence = Math.max(0, Math.min(1, adjustedConfidence + guardrailsDelta));
|
|
71
|
+
if (guardrailsDelta !== 0) {
|
|
72
|
+
explanation.push(`GUARDRAILS_ADJUSTMENT: delta=${guardrailsDelta.toFixed(3)}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Step 4: Determine truth status (use guardrails outcome if available, otherwise use provided)
|
|
77
|
+
const finalTruthStatus = truthStatus ||
|
|
78
|
+
guardrailsOutcome?.finalDecision ||
|
|
79
|
+
guardrailsOutcome?.recommendedStatus ||
|
|
80
|
+
'SUSPECTED';
|
|
81
|
+
|
|
82
|
+
// Step 5: Check and enforce invariants
|
|
83
|
+
const expectationProof = expectation?.proof || null;
|
|
84
|
+
const verificationStatus = options.verificationStatus || null;
|
|
85
|
+
|
|
86
|
+
const invariantCheck = checkConfidenceInvariants(
|
|
87
|
+
guardrailsAdjustedConfidence,
|
|
88
|
+
finalTruthStatus,
|
|
89
|
+
{
|
|
90
|
+
expectationProof,
|
|
91
|
+
verificationStatus,
|
|
92
|
+
guardrailsOutcome
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const confidenceAfter = invariantCheck.correctedConfidence;
|
|
97
|
+
const appliedInvariants = [];
|
|
98
|
+
const invariantViolations = [];
|
|
99
|
+
|
|
100
|
+
if (invariantCheck.violated) {
|
|
101
|
+
for (const violation of invariantCheck.violations) {
|
|
102
|
+
appliedInvariants.push(violation.code);
|
|
103
|
+
invariantViolations.push({
|
|
104
|
+
code: violation.code,
|
|
105
|
+
message: violation.message,
|
|
106
|
+
originalConfidence: guardrailsAdjustedConfidence,
|
|
107
|
+
correctedConfidence: violation.corrected
|
|
108
|
+
});
|
|
109
|
+
explanation.push(`INVARIANT_ENFORCED: ${violation.message}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Step 6: Determine final confidence level
|
|
114
|
+
const confidenceLevel = determineConfidenceLevel(confidenceAfter);
|
|
115
|
+
|
|
116
|
+
// Extract top 2-4 reasons for contract compliance
|
|
117
|
+
const topReasons = explanation.slice(0, 4).filter((r, idx) => idx < 2 || idx < 4);
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
confidenceBefore,
|
|
121
|
+
confidenceAfter,
|
|
122
|
+
confidenceLevel,
|
|
123
|
+
appliedInvariants,
|
|
124
|
+
invariantViolations,
|
|
125
|
+
explanation: explanation.slice(0, 20), // Limit to 20 for determinism
|
|
126
|
+
topReasons, // Contract v1: 2-4 reasons
|
|
127
|
+
truthStatus: finalTruthStatus,
|
|
128
|
+
expectationProof,
|
|
129
|
+
verificationStatus
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Determine confidence level from score01 (Contract v1)
|
|
135
|
+
* HIGH: score01 >= 0.85
|
|
136
|
+
* MEDIUM: 0.60 <= score01 < 0.85
|
|
137
|
+
* LOW: score01 < 0.60
|
|
138
|
+
*/
|
|
139
|
+
function determineConfidenceLevel(score) {
|
|
140
|
+
if (score >= 0.85) return 'HIGH';
|
|
141
|
+
if (score >= 0.60) return 'MEDIUM';
|
|
142
|
+
return 'LOW';
|
|
143
|
+
}
|
|
144
|
+
|