@veraxhq/verax 0.3.0 → 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 +28 -20
- package/bin/verax.js +11 -18
- package/package.json +28 -7
- package/src/cli/commands/baseline.js +1 -2
- package/src/cli/commands/default.js +72 -81
- package/src/cli/commands/doctor.js +29 -0
- package/src/cli/commands/ga.js +3 -0
- package/src/cli/commands/gates.js +1 -1
- package/src/cli/commands/inspect.js +6 -133
- package/src/cli/commands/release-check.js +2 -0
- package/src/cli/commands/run.js +74 -246
- package/src/cli/commands/security-check.js +2 -1
- package/src/cli/commands/truth.js +0 -1
- package/src/cli/entry.js +82 -309
- package/src/cli/util/angular-component-extractor.js +2 -2
- package/src/cli/util/angular-navigation-detector.js +2 -2
- package/src/cli/util/ast-interactive-detector.js +4 -6
- package/src/cli/util/ast-network-detector.js +3 -3
- package/src/cli/util/ast-promise-extractor.js +581 -0
- package/src/cli/util/ast-usestate-detector.js +3 -3
- package/src/cli/util/atomic-write.js +12 -1
- 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 +2 -1
- package/src/cli/util/determinism-writer.js +1 -1
- package/src/cli/util/digest-engine.js +359 -0
- package/src/cli/util/dom-diff.js +226 -0
- package/src/cli/util/env-url.js +0 -4
- package/src/cli/util/evidence-engine.js +287 -0
- package/src/cli/util/expectation-extractor.js +217 -367
- package/src/cli/util/findings-writer.js +19 -126
- 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 -2
- 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 -2
- package/src/cli/util/paths.js +12 -3
- package/src/cli/util/project-discovery.js +284 -3
- package/src/cli/util/project-writer.js +2 -2
- package/src/cli/util/run-id.js +23 -27
- package/src/cli/util/run-result.js +778 -0
- package/src/cli/util/selector-resolver.js +235 -0
- package/src/cli/util/summary-writer.js +2 -1
- package/src/cli/util/svelte-navigation-detector.js +3 -3
- package/src/cli/util/svelte-sfc-extractor.js +0 -1
- package/src/cli/util/svelte-state-detector.js +1 -2
- 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 +4 -3
- package/src/cli/util/vue-sfc-extractor.js +1 -2
- package/src/cli/util/vue-state-detector.js +1 -1
- 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/finding-explainer.js +3 -56
- package/src/verax/cli/init.js +4 -18
- package/src/verax/core/action-classifier.js +4 -3
- package/src/verax/core/artifacts/registry.js +0 -15
- package/src/verax/core/artifacts/verifier.js +18 -8
- package/src/verax/core/baseline/baseline.snapshot.js +2 -0
- package/src/verax/core/capabilities/gates.js +7 -1
- package/src/verax/core/confidence/confidence-compute.js +14 -7
- package/src/verax/core/confidence/confidence.loader.js +1 -0
- package/src/verax/core/confidence-engine-refactor.js +8 -3
- package/src/verax/core/confidence-engine.js +162 -23
- package/src/verax/core/contracts/types.js +1 -0
- package/src/verax/core/contracts/validators.js +79 -4
- package/src/verax/core/decision-snapshot.js +3 -30
- package/src/verax/core/decisions/decision.trace.js +2 -0
- package/src/verax/core/determinism/contract-writer.js +2 -2
- package/src/verax/core/determinism/contract.js +1 -1
- package/src/verax/core/determinism/diff.js +42 -1
- package/src/verax/core/determinism/engine.js +7 -6
- package/src/verax/core/determinism/finding-identity.js +3 -2
- package/src/verax/core/determinism/normalize.js +32 -4
- package/src/verax/core/determinism/report-writer.js +1 -0
- package/src/verax/core/determinism/run-fingerprint.js +7 -2
- package/src/verax/core/dynamic-route-intelligence.js +8 -7
- package/src/verax/core/evidence/evidence-capture-service.js +1 -0
- package/src/verax/core/evidence/evidence-intent-ledger.js +2 -1
- package/src/verax/core/evidence-builder.js +2 -2
- package/src/verax/core/execution-mode-context.js +1 -1
- package/src/verax/core/execution-mode-detector.js +5 -3
- package/src/verax/core/failures/exit-codes.js +39 -37
- package/src/verax/core/failures/failure-summary.js +1 -1
- package/src/verax/core/failures/failure.factory.js +3 -3
- package/src/verax/core/failures/failure.ledger.js +3 -2
- package/src/verax/core/ga/ga.artifact.js +1 -1
- package/src/verax/core/ga/ga.contract.js +3 -2
- package/src/verax/core/ga/ga.enforcer.js +1 -0
- package/src/verax/core/guardrails/policy.loader.js +1 -0
- package/src/verax/core/guardrails/truth-reconciliation.js +1 -1
- package/src/verax/core/guardrails-engine.js +2 -2
- 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 +2 -0
- package/src/verax/core/perf/perf.report.js +2 -0
- package/src/verax/core/pipeline-tracker.js +5 -0
- package/src/verax/core/release/provenance.builder.js +73 -214
- package/src/verax/core/release/release.enforcer.js +14 -9
- package/src/verax/core/release/reproducibility.check.js +1 -0
- package/src/verax/core/release/sbom.builder.js +32 -23
- 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 +6 -3
- package/src/verax/core/report/human-summary.js +141 -1
- package/src/verax/core/route-intelligence.js +4 -3
- 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 +10 -7
- package/src/verax/core/security/security.enforcer.js +4 -0
- package/src/verax/core/security/supplychain.policy.js +9 -1
- package/src/verax/core/security/vuln.scan.js +2 -2
- package/src/verax/core/truth/truth.certificate.js +3 -1
- package/src/verax/core/ui-feedback-intelligence.js +12 -46
- package/src/verax/detect/conditional-ui-silent-failure.js +84 -0
- package/src/verax/detect/confidence-engine.js +100 -660
- package/src/verax/detect/confidence-helper.js +1 -0
- package/src/verax/detect/detection-engine.js +1 -18
- package/src/verax/detect/dynamic-route-findings.js +17 -14
- package/src/verax/detect/expectation-chain-detector.js +1 -1
- package/src/verax/detect/expectation-model.js +3 -5
- package/src/verax/detect/failure-cause-inference.js +293 -0
- package/src/verax/detect/findings-writer.js +126 -166
- 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 +51 -234
- package/src/verax/detect/invariants-enforcer.js +147 -0
- package/src/verax/detect/journey-stall-detector.js +4 -4
- 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 +7 -6
- 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 +18 -18
- package/src/verax/detect/verdict-engine.js +3 -57
- package/src/verax/detect/view-switch-correlator.js +2 -2
- package/src/verax/flow/flow-engine.js +2 -1
- package/src/verax/flow/flow-spec.js +0 -6
- package/src/verax/index.js +48 -412
- 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 +67 -682
- 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/route-validator.js +1 -4
- 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 +735 -84
- package/src/verax/observe/interaction-executor.js +192 -0
- package/src/verax/observe/interaction-runner.js +782 -530
- 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 +1 -1
- package/src/verax/observe/observe-helpers.js +2 -1
- package/src/verax/observe/observe-runner.js +28 -24
- package/src/verax/observe/observers/budget-observer.js +3 -3
- package/src/verax/observe/observers/console-observer.js +4 -4
- package/src/verax/observe/observers/coverage-observer.js +4 -4
- package/src/verax/observe/observers/interaction-observer.js +3 -3
- package/src/verax/observe/observers/navigation-observer.js +4 -4
- package/src/verax/observe/observers/network-observer.js +4 -4
- package/src/verax/observe/observers/safety-observer.js +1 -1
- package/src/verax/observe/observers/ui-feedback-observer.js +4 -4
- package/src/verax/observe/page-traversal.js +138 -0
- package/src/verax/observe/snapshot-ops.js +94 -0
- package/src/verax/observe/ui-signal-sensor.js +2 -148
- package/src/verax/scan-summary-writer.js +10 -42
- package/src/verax/shared/artifact-manager.js +30 -13
- package/src/verax/shared/caching.js +1 -0
- package/src/verax/shared/expectation-tracker.js +1 -0
- package/src/verax/shared/zip-artifacts.js +6 -0
- package/src/verax/core/confidence-engine.js.backup +0 -471
- package/src/verax/shared/config-loader.js +0 -169
- /package/src/verax/shared/{expectation-proof.js → expectation-validation.js} +0 -0
package/src/verax/cli/init.js
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
import { existsSync, writeFileSync, mkdirSync } from 'fs';
|
|
8
8
|
import { resolve } from 'path';
|
|
9
|
-
import { getDefaultConfig } from '../shared/config-loader.js';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Initialize VERAX configuration
|
|
@@ -27,16 +26,8 @@ export async function runInit(options = {}) {
|
|
|
27
26
|
// Create .verax directory if needed
|
|
28
27
|
const veraxDir = resolve(projectRoot, '.verax');
|
|
29
28
|
mkdirSync(veraxDir, { recursive: true });
|
|
30
|
-
|
|
31
|
-
//
|
|
32
|
-
const configPath = resolve(veraxDir, 'config.json');
|
|
33
|
-
if (existsSync(configPath) && !yes) {
|
|
34
|
-
skipped.push('config.json');
|
|
35
|
-
} else {
|
|
36
|
-
const defaultConfig = getDefaultConfig();
|
|
37
|
-
writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2) + '\n');
|
|
38
|
-
created.push('config.json');
|
|
39
|
-
}
|
|
29
|
+
|
|
30
|
+
// Zero-config enforcement: do not scaffold config files
|
|
40
31
|
|
|
41
32
|
// Create CI template if requested
|
|
42
33
|
if (ciTemplate === 'github') {
|
|
@@ -75,7 +66,7 @@ jobs:
|
|
|
75
66
|
- name: Start fixture server
|
|
76
67
|
id: fixture-server
|
|
77
68
|
run: |
|
|
78
|
-
node test/
|
|
69
|
+
node test/infrastructure/fixture-server.js &
|
|
79
70
|
SERVER_PID=$!
|
|
80
71
|
echo "SERVER_PID=$SERVER_PID" >> $GITHUB_ENV
|
|
81
72
|
sleep 3
|
|
@@ -211,12 +202,7 @@ export function printInitResults(results) {
|
|
|
211
202
|
});
|
|
212
203
|
}
|
|
213
204
|
|
|
214
|
-
|
|
215
|
-
console.error('\n📝 Next Steps:');
|
|
216
|
-
console.error(' 1. Review .verax/config.json and adjust settings');
|
|
217
|
-
console.error(' 2. Run: verax doctor (to verify setup)');
|
|
218
|
-
console.error(' 3. Run: verax run --url <your-url>');
|
|
219
|
-
}
|
|
205
|
+
// No config scaffolding in zero-config mode
|
|
220
206
|
|
|
221
207
|
if (results.created.includes('.github/workflows/verax-ci.yml')) {
|
|
222
208
|
console.error('\n🔧 CI Setup:');
|
|
@@ -67,18 +67,19 @@ export function classifyAction(interaction) {
|
|
|
67
67
|
/**
|
|
68
68
|
* Check if action should be blocked based on safety mode and flags
|
|
69
69
|
* @param {Object} interaction - Interaction to check
|
|
70
|
-
* @param {Object} flags - Safety flags {
|
|
70
|
+
* @param {Object} flags - Safety flags { allowRiskyActions: boolean }
|
|
71
71
|
* @returns {Object} { shouldBlock: boolean, classification: string, reason: string }
|
|
72
72
|
*/
|
|
73
73
|
export function shouldBlockAction(interaction, flags = {}) {
|
|
74
|
-
const {
|
|
74
|
+
const { allowRiskyActions = false } = flags;
|
|
75
75
|
const { classification, reason } = classifyAction(interaction);
|
|
76
76
|
|
|
77
77
|
if (classification === 'RISKY' && !allowRiskyActions) {
|
|
78
78
|
return { shouldBlock: true, classification, reason };
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
// CONSTITUTIONAL: Always block write intents (read-only mode enforced)
|
|
82
|
+
if (classification === 'WRITE_INTENT') {
|
|
82
83
|
return { shouldBlock: true, classification, reason };
|
|
83
84
|
}
|
|
84
85
|
|
|
@@ -105,20 +105,6 @@ export const ARTIFACT_REGISTRY = {
|
|
|
105
105
|
stage: 'observe',
|
|
106
106
|
contractVersion: 1,
|
|
107
107
|
type: 'file'
|
|
108
|
-
},
|
|
109
|
-
determinismReport: {
|
|
110
|
-
key: 'determinismReport',
|
|
111
|
-
filename: 'determinism.report.json',
|
|
112
|
-
stage: 'verify',
|
|
113
|
-
contractVersion: 1,
|
|
114
|
-
type: 'file'
|
|
115
|
-
},
|
|
116
|
-
runMeta: {
|
|
117
|
-
key: 'runMeta',
|
|
118
|
-
filename: 'run.meta.json',
|
|
119
|
-
stage: 'learn',
|
|
120
|
-
contractVersion: 1,
|
|
121
|
-
type: 'file'
|
|
122
108
|
}
|
|
123
109
|
};
|
|
124
110
|
|
|
@@ -148,7 +134,6 @@ export function buildRunArtifactPaths(baseDir) {
|
|
|
148
134
|
confidenceReportJson: join(baseDir, ARTIFACT_REGISTRY.confidenceReport.filename),
|
|
149
135
|
determinismContractJson: join(baseDir, ARTIFACT_REGISTRY.determinismContract.filename),
|
|
150
136
|
determinismReportJson: join(baseDir, ARTIFACT_REGISTRY.determinismReport.filename),
|
|
151
|
-
runMetaJson: join(baseDir, ARTIFACT_REGISTRY.runMeta.filename),
|
|
152
137
|
artifactVersions: getArtifactVersions()
|
|
153
138
|
};
|
|
154
139
|
}
|
|
@@ -90,6 +90,7 @@ export function verifyRun(runDir, registrySnapshot = null) {
|
|
|
90
90
|
if (def.filename.endsWith('.json')) {
|
|
91
91
|
try {
|
|
92
92
|
const content = readFileSync(artifactPath, 'utf-8');
|
|
93
|
+
// @ts-expect-error - readFileSync with encoding returns string
|
|
93
94
|
const data = JSON.parse(content);
|
|
94
95
|
|
|
95
96
|
// Check contractVersion
|
|
@@ -162,6 +163,7 @@ export function verifyRun(runDir, registrySnapshot = null) {
|
|
|
162
163
|
if (existsSync(evidenceIntentPath)) {
|
|
163
164
|
try {
|
|
164
165
|
const intentContent = readFileSync(evidenceIntentPath, 'utf-8');
|
|
166
|
+
// @ts-expect-error - readFileSync with encoding returns string
|
|
165
167
|
evidenceIntentLedger = JSON.parse(intentContent);
|
|
166
168
|
} catch (e) {
|
|
167
169
|
// Will be caught by artifact validation
|
|
@@ -213,7 +215,7 @@ export function verifyRun(runDir, registrySnapshot = null) {
|
|
|
213
215
|
// PHASE 21.1: HARD FAILURE - blocking error, not warning
|
|
214
216
|
enforcementSummary.findingsWithoutEvidence++;
|
|
215
217
|
errors.push(
|
|
216
|
-
`
|
|
218
|
+
`Evidence Law violation: Finding marked CONFIRMED but evidencePackage is incomplete. ` +
|
|
217
219
|
`Missing fields: ${error.missingFields?.join(', ') || 'unknown'}. ` +
|
|
218
220
|
`(finding type: ${finding.type || 'unknown'}, index: ${i})`
|
|
219
221
|
);
|
|
@@ -222,7 +224,7 @@ export function verifyRun(runDir, registrySnapshot = null) {
|
|
|
222
224
|
// PHASE 21.1: CONFIRMED without evidencePackage and without substantive evidence → HARD FAILURE
|
|
223
225
|
enforcementSummary.findingsWithoutEvidence++;
|
|
224
226
|
errors.push(
|
|
225
|
-
`
|
|
227
|
+
`Evidence Law violation: Finding marked CONFIRMED but lacks evidencePackage and has insufficient evidence. ` +
|
|
226
228
|
`(finding type: ${finding.type || 'unknown'}, index: ${i})`
|
|
227
229
|
);
|
|
228
230
|
}
|
|
@@ -372,11 +374,11 @@ export function verifyRun(runDir, registrySnapshot = null) {
|
|
|
372
374
|
}
|
|
373
375
|
|
|
374
376
|
// Determine overall verdict
|
|
375
|
-
// PHASE 21.1:
|
|
377
|
+
// PHASE 21.1: Evidence Law violation errors are blocking - do not allow VALID_WITH_WARNINGS
|
|
376
378
|
// PHASE 22: EVIDENCE_INTENT_MISMATCH errors mark run as VERIFIED_WITH_ERRORS
|
|
377
379
|
// PHASE 23: GUARDRAILS_REPORT_MISMATCH errors mark run as VERIFIED_WITH_ERRORS
|
|
378
380
|
// PHASE 24: CONFIDENCE_INVARIANT_VIOLATION and CONFIDENCE_REPORT_MISMATCH errors mark run as VERIFIED_WITH_ERRORS
|
|
379
|
-
const hasEvidenceLawViolations = errors.some(e => e.includes('
|
|
381
|
+
const hasEvidenceLawViolations = errors.some(e => e.includes('Evidence Law violation'));
|
|
380
382
|
const hasEvidenceIntentMismatches = errors.some(e => e.includes('EVIDENCE_INTENT_MISMATCH'));
|
|
381
383
|
const hasGuardrailsReportMismatches = errors.some(e => e.includes('GUARDRAILS_REPORT_MISMATCH'));
|
|
382
384
|
const hasConfidenceInvariantViolations = errors.some(e => e.includes('CONFIDENCE_INVARIANT_VIOLATION'));
|
|
@@ -398,7 +400,7 @@ export function verifyRun(runDir, registrySnapshot = null) {
|
|
|
398
400
|
enforcementSummary,
|
|
399
401
|
verifiedAt: new Date().toISOString(),
|
|
400
402
|
// PHASE 21.1: Track evidence law violations separately
|
|
401
|
-
evidenceLawViolations: hasEvidenceLawViolations ? errors.filter(e => e.includes('
|
|
403
|
+
evidenceLawViolations: hasEvidenceLawViolations ? errors.filter(e => e.includes('Evidence Law violation')) : [],
|
|
402
404
|
// PHASE 22: Track evidence intent mismatches separately
|
|
403
405
|
evidenceIntentMismatches: hasEvidenceIntentMismatches ? errors.filter(e => e.includes('EVIDENCE_INTENT_MISMATCH')) : [],
|
|
404
406
|
// PHASE 23: Track guardrails report mismatches separately
|
|
@@ -453,9 +455,9 @@ function validateFindingsArtifact(findingsData, runDir) {
|
|
|
453
455
|
validateEvidencePackageStrict(finding.evidencePackage, severity);
|
|
454
456
|
// If we get here, evidencePackage is complete
|
|
455
457
|
} catch (error) {
|
|
456
|
-
// PHASE 21.1: HARD FAILURE - blocking error with
|
|
458
|
+
// PHASE 21.1: HARD FAILURE - blocking error with Evidence Law violation code
|
|
457
459
|
errors.push(
|
|
458
|
-
`
|
|
460
|
+
`Evidence Law violation: Finding at index ${i} is marked CONFIRMED but evidencePackage is incomplete. ` +
|
|
459
461
|
`Missing fields: ${error.missingFields?.join(', ') || 'unknown'}. ` +
|
|
460
462
|
`(type: ${finding.type || 'unknown'})`
|
|
461
463
|
);
|
|
@@ -463,7 +465,7 @@ function validateFindingsArtifact(findingsData, runDir) {
|
|
|
463
465
|
} else if (!finding.evidence || !isEvidenceSubstantive(finding.evidence)) {
|
|
464
466
|
// PHASE 21.1: CONFIRMED without evidencePackage and without substantive evidence → HARD FAILURE
|
|
465
467
|
errors.push(
|
|
466
|
-
`
|
|
468
|
+
`Evidence Law violation: Finding at index ${i} is marked CONFIRMED but lacks evidencePackage and has insufficient evidence. ` +
|
|
467
469
|
`(type: ${finding.type || 'unknown'})`
|
|
468
470
|
);
|
|
469
471
|
}
|
|
@@ -658,6 +660,7 @@ function validateGuardrailsReportArtifact(reportData, runDir) {
|
|
|
658
660
|
if (existsSync(findingsPath)) {
|
|
659
661
|
try {
|
|
660
662
|
const findingsContent = readFileSync(findingsPath, 'utf-8');
|
|
663
|
+
// @ts-expect-error - readFileSync with encoding returns string
|
|
661
664
|
const findingsData = JSON.parse(findingsContent);
|
|
662
665
|
|
|
663
666
|
if (findingsData.findings && Array.isArray(findingsData.findings)) {
|
|
@@ -763,6 +766,7 @@ function validateConfidenceReportArtifact(reportData, runDir) {
|
|
|
763
766
|
if (existsSync(findingsPath)) {
|
|
764
767
|
try {
|
|
765
768
|
const findingsContent = readFileSync(findingsPath, 'utf-8');
|
|
769
|
+
// @ts-expect-error - readFileSync with encoding returns string
|
|
766
770
|
const findingsData = JSON.parse(findingsContent);
|
|
767
771
|
|
|
768
772
|
if (findingsData.findings && Array.isArray(findingsData.findings)) {
|
|
@@ -820,6 +824,7 @@ function checkCrossArtifactConsistency(runDir) {
|
|
|
820
824
|
|
|
821
825
|
if (existsSync(statusPath)) {
|
|
822
826
|
try {
|
|
827
|
+
// @ts-expect-error - readFileSync with encoding returns string
|
|
823
828
|
const statusData = JSON.parse(readFileSync(statusPath, 'utf-8'));
|
|
824
829
|
runId = statusData.runId;
|
|
825
830
|
|
|
@@ -832,6 +837,7 @@ function checkCrossArtifactConsistency(runDir) {
|
|
|
832
837
|
const findingsPath = join(runDir, ARTIFACT_REGISTRY.findings.filename);
|
|
833
838
|
if (existsSync(findingsPath)) {
|
|
834
839
|
try {
|
|
840
|
+
// @ts-expect-error - readFileSync with encoding returns string
|
|
835
841
|
const findingsData = JSON.parse(readFileSync(findingsPath, 'utf-8'));
|
|
836
842
|
// Findings don't always have runId, so this is optional
|
|
837
843
|
if (findingsData.runId && findingsData.runId !== runId) {
|
|
@@ -848,6 +854,7 @@ function checkCrossArtifactConsistency(runDir) {
|
|
|
848
854
|
const summaryPath = join(runDir, ARTIFACT_REGISTRY.summary.filename);
|
|
849
855
|
if (existsSync(summaryPath)) {
|
|
850
856
|
try {
|
|
857
|
+
// @ts-expect-error - readFileSync with encoding returns string
|
|
851
858
|
const summaryData = JSON.parse(readFileSync(summaryPath, 'utf-8'));
|
|
852
859
|
if (summaryData.runId && summaryData.runId !== runId) {
|
|
853
860
|
warnings.push(
|
|
@@ -870,6 +877,7 @@ function checkCrossArtifactConsistency(runDir) {
|
|
|
870
877
|
const findingsPathForTimestamp = join(runDir, ARTIFACT_REGISTRY.findings.filename);
|
|
871
878
|
if (existsSync(findingsPathForTimestamp)) {
|
|
872
879
|
try {
|
|
880
|
+
// @ts-expect-error - readFileSync with encoding returns string
|
|
873
881
|
const findingsDataForTimestamp = JSON.parse(readFileSync(findingsPathForTimestamp, 'utf-8'));
|
|
874
882
|
if (findingsDataForTimestamp.detectedAt) timestamps.push({ artifact: 'findings', time: findingsDataForTimestamp.detectedAt });
|
|
875
883
|
} catch (e) {
|
|
@@ -881,6 +889,7 @@ function checkCrossArtifactConsistency(runDir) {
|
|
|
881
889
|
const findingsPathForTimestamp = join(runDir, ARTIFACT_REGISTRY.findings.filename);
|
|
882
890
|
if (existsSync(findingsPathForTimestamp)) {
|
|
883
891
|
try {
|
|
892
|
+
// @ts-expect-error - readFileSync with encoding returns string
|
|
884
893
|
const findingsDataForTimestamp = JSON.parse(readFileSync(findingsPathForTimestamp, 'utf-8'));
|
|
885
894
|
if (findingsDataForTimestamp.detectedAt) timestamps.push({ artifact: 'findings', time: findingsDataForTimestamp.detectedAt });
|
|
886
895
|
} catch (e) {
|
|
@@ -891,6 +900,7 @@ function checkCrossArtifactConsistency(runDir) {
|
|
|
891
900
|
|
|
892
901
|
// Sort timestamps and check monotonicity
|
|
893
902
|
if (timestamps.length > 1) {
|
|
903
|
+
// @ts-expect-error - Date arithmetic for sorting
|
|
894
904
|
timestamps.sort((a, b) => new Date(a.time) - new Date(b.time));
|
|
895
905
|
for (let i = 1; i < timestamps.length; i++) {
|
|
896
906
|
if (new Date(timestamps[i].time) < new Date(timestamps[i - 1].time)) {
|
|
@@ -62,6 +62,7 @@ function isGitDirty() {
|
|
|
62
62
|
*/
|
|
63
63
|
function getVeraxVersion() {
|
|
64
64
|
try {
|
|
65
|
+
// @ts-expect-error - readFileSync with encoding returns string
|
|
65
66
|
const packageJson = JSON.parse(readFileSync(resolve(process.cwd(), 'package.json'), 'utf-8'));
|
|
66
67
|
return packageJson.version || 'unknown';
|
|
67
68
|
} catch {
|
|
@@ -223,6 +224,7 @@ export function loadBaselineSnapshot(projectDir) {
|
|
|
223
224
|
}
|
|
224
225
|
|
|
225
226
|
try {
|
|
227
|
+
// @ts-expect-error - readFileSync with encoding returns string
|
|
226
228
|
return JSON.parse(readFileSync(snapshotPath, 'utf-8'));
|
|
227
229
|
} catch {
|
|
228
230
|
return null;
|
|
@@ -60,7 +60,7 @@ export function evaluateCapabilityGates(capabilityId, context) {
|
|
|
60
60
|
testMatrix,
|
|
61
61
|
fixtureIndex,
|
|
62
62
|
docsIndex,
|
|
63
|
-
|
|
63
|
+
_artifactsRegistry,
|
|
64
64
|
guardrailsRules,
|
|
65
65
|
determinismTests,
|
|
66
66
|
} = context;
|
|
@@ -333,6 +333,7 @@ function buildFixtureIndex(projectRoot) {
|
|
|
333
333
|
const readmeContent = readFileSync(readmePath, 'utf-8');
|
|
334
334
|
// Extract capability IDs from README (look for patterns like "capability-id" or "capabilityId")
|
|
335
335
|
// Also check for capability mentions in test matrix format
|
|
336
|
+
// @ts-expect-error - readFileSync with encoding returns string
|
|
336
337
|
const capabilityMatches = readmeContent.match(/(['"])([a-z0-9-]+)(['"])/g);
|
|
337
338
|
if (capabilityMatches) {
|
|
338
339
|
capabilities = capabilityMatches.map(m => {
|
|
@@ -342,6 +343,7 @@ function buildFixtureIndex(projectRoot) {
|
|
|
342
343
|
}
|
|
343
344
|
|
|
344
345
|
// Also look for capability registry format
|
|
346
|
+
// @ts-expect-error - readFileSync with encoding returns string
|
|
345
347
|
const registryMatches = readmeContent.match(/([a-z0-9-]+-[a-z0-9-]+)/g);
|
|
346
348
|
if (registryMatches) {
|
|
347
349
|
capabilities.push(...registryMatches.filter(m => m.includes('-')));
|
|
@@ -382,6 +384,7 @@ function buildDocsIndex(projectRoot) {
|
|
|
382
384
|
|
|
383
385
|
// Extract capability IDs from docs (look for patterns)
|
|
384
386
|
const capabilities = [];
|
|
387
|
+
// @ts-expect-error - readFileSync with encoding returns string
|
|
385
388
|
const capabilityMatches = docContent.match(/([a-z0-9-]+-[a-z0-9-]+)/g);
|
|
386
389
|
if (capabilityMatches) {
|
|
387
390
|
// Filter to likely capability IDs (contain hyphens, reasonable length)
|
|
@@ -427,6 +430,7 @@ function buildGuardrailsIndex(projectRoot) {
|
|
|
427
430
|
// Extract capability categories from test content
|
|
428
431
|
const capabilities = [];
|
|
429
432
|
// Look for capability mentions or category mentions
|
|
433
|
+
// @ts-expect-error - readFileSync with encoding returns string
|
|
430
434
|
const categoryMatches = testContent.match(/(network|navigation|routes|ui-feedback|validation)/gi);
|
|
431
435
|
if (categoryMatches) {
|
|
432
436
|
capabilities.push(...categoryMatches.map(m => m.toLowerCase()));
|
|
@@ -467,6 +471,7 @@ function buildDeterminismTestsIndex(projectRoot) {
|
|
|
467
471
|
// Extract capability IDs from test content by looking at test matrix references
|
|
468
472
|
const capabilities = [];
|
|
469
473
|
// Look for test matrix references or capability mentions
|
|
474
|
+
// @ts-expect-error - readFileSync with encoding returns string
|
|
470
475
|
const testMatrixMatches = testContent.match(/testMatrix\[['"]([a-z0-9-]+)['"]\]/g);
|
|
471
476
|
if (testMatrixMatches) {
|
|
472
477
|
for (const match of testMatrixMatches) {
|
|
@@ -478,6 +483,7 @@ function buildDeterminismTestsIndex(projectRoot) {
|
|
|
478
483
|
}
|
|
479
484
|
|
|
480
485
|
// Also look for capability mentions in test descriptions
|
|
486
|
+
// @ts-expect-error - readFileSync with encoding returns string
|
|
481
487
|
const capabilityMentions = testContent.match(/([a-z0-9-]+-[a-z0-9-]+)/g);
|
|
482
488
|
if (capabilityMentions) {
|
|
483
489
|
capabilities.push(...capabilityMentions.filter(m => m.includes('-')));
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { computeConfidenceForFinding } from '../confidence-engine.js';
|
|
9
|
-
import { CONFIDENCE_WEIGHTS } from './confidence-weights.js';
|
|
10
|
-
import { checkConfidenceInvariants, enforceConfidenceInvariants } from './confidence-invariants.js';
|
|
9
|
+
import { CONFIDENCE_WEIGHTS as _CONFIDENCE_WEIGHTS } from './confidence-weights.js';
|
|
10
|
+
import { checkConfidenceInvariants, enforceConfidenceInvariants as _enforceConfidenceInvariants } from './confidence-invariants.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Compute final confidence with full truth-aware reconciliation
|
|
@@ -39,6 +39,7 @@ export function computeFinalConfidence(params) {
|
|
|
39
39
|
|
|
40
40
|
// Step 1: Compute raw confidence using unified engine
|
|
41
41
|
const rawConfidenceResult = computeConfidenceForFinding({
|
|
42
|
+
// @ts-expect-error - Optional params structure
|
|
42
43
|
findingType: params.findingType || 'unknown',
|
|
43
44
|
expectation,
|
|
44
45
|
sensors: rawSignals || sensors,
|
|
@@ -112,6 +113,9 @@ export function computeFinalConfidence(params) {
|
|
|
112
113
|
// Step 6: Determine final confidence level
|
|
113
114
|
const confidenceLevel = determineConfidenceLevel(confidenceAfter);
|
|
114
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
|
+
|
|
115
119
|
return {
|
|
116
120
|
confidenceBefore,
|
|
117
121
|
confidenceAfter,
|
|
@@ -119,6 +123,7 @@ export function computeFinalConfidence(params) {
|
|
|
119
123
|
appliedInvariants,
|
|
120
124
|
invariantViolations,
|
|
121
125
|
explanation: explanation.slice(0, 20), // Limit to 20 for determinism
|
|
126
|
+
topReasons, // Contract v1: 2-4 reasons
|
|
122
127
|
truthStatus: finalTruthStatus,
|
|
123
128
|
expectationProof,
|
|
124
129
|
verificationStatus
|
|
@@ -126,12 +131,14 @@ export function computeFinalConfidence(params) {
|
|
|
126
131
|
}
|
|
127
132
|
|
|
128
133
|
/**
|
|
129
|
-
* Determine confidence level from
|
|
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
|
|
130
138
|
*/
|
|
131
139
|
function determineConfidenceLevel(score) {
|
|
132
|
-
if (score >= 0.
|
|
133
|
-
if (score >= 0.
|
|
134
|
-
|
|
135
|
-
return 'UNPROVEN';
|
|
140
|
+
if (score >= 0.85) return 'HIGH';
|
|
141
|
+
if (score >= 0.60) return 'MEDIUM';
|
|
142
|
+
return 'LOW';
|
|
136
143
|
}
|
|
137
144
|
|
|
@@ -36,6 +36,7 @@ export function loadConfidencePolicy(policyPath = null, projectDir = null) {
|
|
|
36
36
|
let policy;
|
|
37
37
|
try {
|
|
38
38
|
const policyContent = readFileSync(resolvedPath, 'utf-8');
|
|
39
|
+
// @ts-expect-error - readFileSync with encoding returns string
|
|
39
40
|
policy = JSON.parse(policyContent);
|
|
40
41
|
} catch (error) {
|
|
41
42
|
throw new Error(`Failed to load confidence policy: ${error.message}`);
|
|
@@ -283,7 +283,7 @@ function assessCorrelationQuality(expectation, sensors, comparisons, evidence, r
|
|
|
283
283
|
/**
|
|
284
284
|
* Assess guardrails & contradictions (Pillar D) using policy
|
|
285
285
|
*/
|
|
286
|
-
function assessGuardrails(sensors, comparisons, findingType, reasons,
|
|
286
|
+
function assessGuardrails(sensors, comparisons, findingType, reasons, _policy) {
|
|
287
287
|
let guardrailScore = 1.0;
|
|
288
288
|
|
|
289
289
|
const networkSensor = sensors.network || {};
|
|
@@ -406,6 +406,7 @@ export function computeConfidenceForFinding(params) {
|
|
|
406
406
|
}
|
|
407
407
|
|
|
408
408
|
// === TRUTH LOCKS: Evidence Law cap ===
|
|
409
|
+
// @ts-expect-error - Optional params structure
|
|
409
410
|
const evidencePackage = options.evidencePackage || params.evidence?.evidencePackage || {};
|
|
410
411
|
if (evidencePackage.severity === 'CONFIRMED' || evidencePackage.status === 'CONFIRMED') {
|
|
411
412
|
if (policy.truthLocks.evidenceCompleteRequired && !evidencePackage.isComplete) {
|
|
@@ -415,10 +416,14 @@ export function computeConfidenceForFinding(params) {
|
|
|
415
416
|
}
|
|
416
417
|
|
|
417
418
|
// Determine level using policy thresholds
|
|
419
|
+
// @ts-expect-error - params has expectation property
|
|
420
|
+
const promiseStrength = assessPromiseStrength(params.expectation, [], policy);
|
|
421
|
+
// @ts-expect-error - params has evidence and sensors properties
|
|
422
|
+
const evidenceComplete = assessEvidenceCompleteness(params.evidence || {}, params.sensors || {}, [], policy);
|
|
418
423
|
const level = determineConfidenceLevel(
|
|
419
424
|
normalizedScore,
|
|
420
|
-
|
|
421
|
-
|
|
425
|
+
promiseStrength,
|
|
426
|
+
evidenceComplete,
|
|
422
427
|
policy
|
|
423
428
|
);
|
|
424
429
|
|