agentic-qe 3.7.21 → 3.8.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/.claude/helpers/brain-checkpoint.cjs +4 -1
- package/.claude/helpers/statusline-v3.cjs +3 -1
- package/.claude/skills/skills-manifest.json +1 -1
- package/CHANGELOG.md +45 -0
- package/README.md +2 -14
- package/assets/helpers/statusline-v3.cjs +3 -1
- package/dist/cli/brain-commands.js +6 -10
- package/dist/cli/bundle.js +7441 -4327
- package/dist/cli/commands/audit.d.ts +43 -0
- package/dist/cli/commands/audit.js +125 -0
- package/dist/cli/commands/hooks.js +29 -6
- package/dist/cli/commands/init.js +1 -73
- package/dist/cli/commands/learning.js +270 -13
- package/dist/cli/commands/ruvector-commands.d.ts +15 -0
- package/dist/cli/commands/ruvector-commands.js +271 -0
- package/dist/cli/handlers/init-handler.d.ts +0 -1
- package/dist/cli/handlers/init-handler.js +0 -6
- package/dist/cli/index.js +4 -2
- package/dist/context/sources/defect-source.js +2 -2
- package/dist/context/sources/memory-source.js +2 -2
- package/dist/context/sources/requirements-source.js +2 -2
- package/dist/coordination/behavior-tree/decorators.d.ts +108 -0
- package/dist/coordination/behavior-tree/decorators.js +251 -0
- package/dist/coordination/behavior-tree/index.d.ts +12 -0
- package/dist/coordination/behavior-tree/index.js +15 -0
- package/dist/coordination/behavior-tree/nodes.d.ts +165 -0
- package/dist/coordination/behavior-tree/nodes.js +338 -0
- package/dist/coordination/behavior-tree/qe-trees.d.ts +105 -0
- package/dist/coordination/behavior-tree/qe-trees.js +181 -0
- package/dist/coordination/coherence-action-gate.d.ts +284 -0
- package/dist/coordination/coherence-action-gate.js +512 -0
- package/dist/coordination/index.d.ts +4 -0
- package/dist/coordination/index.js +8 -0
- package/dist/coordination/reasoning-qec.d.ts +315 -0
- package/dist/coordination/reasoning-qec.js +585 -0
- package/dist/coordination/task-executor.d.ts +16 -0
- package/dist/coordination/task-executor.js +99 -0
- package/dist/coordination/workflow-orchestrator.d.ts +29 -0
- package/dist/coordination/workflow-orchestrator.js +42 -0
- package/dist/domains/visual-accessibility/cnn-visual-regression.d.ts +135 -0
- package/dist/domains/visual-accessibility/cnn-visual-regression.js +327 -0
- package/dist/domains/visual-accessibility/index.d.ts +1 -0
- package/dist/domains/visual-accessibility/index.js +4 -0
- package/dist/governance/coherence-validator.d.ts +112 -0
- package/dist/governance/coherence-validator.js +180 -0
- package/dist/governance/index.d.ts +1 -0
- package/dist/governance/index.js +2 -0
- package/dist/governance/witness-chain.d.ts +311 -0
- package/dist/governance/witness-chain.js +509 -0
- package/dist/init/index.d.ts +0 -2
- package/dist/init/index.js +0 -1
- package/dist/init/init-wizard-steps.d.ts +10 -0
- package/dist/init/init-wizard-steps.js +87 -1
- package/dist/init/init-wizard.d.ts +1 -9
- package/dist/init/init-wizard.js +3 -69
- package/dist/init/orchestrator.js +0 -1
- package/dist/init/phases/01-detection.js +0 -27
- package/dist/init/phases/07-hooks.js +6 -4
- package/dist/init/phases/phase-interface.d.ts +0 -1
- package/dist/init/settings-merge.js +1 -1
- package/dist/integrations/browser/qe-dashboard/clustering.d.ts +48 -0
- package/dist/integrations/browser/qe-dashboard/clustering.js +183 -0
- package/dist/integrations/browser/qe-dashboard/index.d.ts +12 -0
- package/dist/integrations/browser/qe-dashboard/index.js +15 -0
- package/dist/integrations/browser/qe-dashboard/pattern-explorer.d.ts +165 -0
- package/dist/integrations/browser/qe-dashboard/pattern-explorer.js +260 -0
- package/dist/integrations/browser/qe-dashboard/wasm-vector-store.d.ts +144 -0
- package/dist/integrations/browser/qe-dashboard/wasm-vector-store.js +277 -0
- package/dist/integrations/ruvector/cognitive-container-codec.d.ts +51 -0
- package/dist/integrations/ruvector/cognitive-container-codec.js +180 -0
- package/dist/integrations/ruvector/cognitive-container.d.ts +125 -0
- package/dist/integrations/ruvector/cognitive-container.js +306 -0
- package/dist/integrations/ruvector/coherence-gate.d.ts +309 -0
- package/dist/integrations/ruvector/coherence-gate.js +631 -0
- package/dist/integrations/ruvector/compressed-hnsw-integration.d.ts +176 -0
- package/dist/integrations/ruvector/compressed-hnsw-integration.js +301 -0
- package/dist/integrations/ruvector/dither-adapter.d.ts +122 -0
- package/dist/integrations/ruvector/dither-adapter.js +295 -0
- package/dist/integrations/ruvector/domain-transfer.d.ts +129 -0
- package/dist/integrations/ruvector/domain-transfer.js +220 -0
- package/dist/integrations/ruvector/feature-flags.d.ts +214 -2
- package/dist/integrations/ruvector/feature-flags.js +167 -2
- package/dist/integrations/ruvector/filter-adapter.d.ts +71 -0
- package/dist/integrations/ruvector/filter-adapter.js +285 -0
- package/dist/integrations/ruvector/gnn-wrapper.d.ts +20 -0
- package/dist/integrations/ruvector/gnn-wrapper.js +40 -0
- package/dist/integrations/ruvector/hnsw-health-monitor.d.ts +237 -0
- package/dist/integrations/ruvector/hnsw-health-monitor.js +394 -0
- package/dist/integrations/ruvector/index.d.ts +8 -2
- package/dist/integrations/ruvector/index.js +18 -2
- package/dist/integrations/ruvector/interfaces.d.ts +40 -0
- package/dist/integrations/ruvector/sona-persistence.d.ts +54 -0
- package/dist/integrations/ruvector/sona-persistence.js +162 -0
- package/dist/integrations/ruvector/sona-three-loop.d.ts +392 -0
- package/dist/integrations/ruvector/sona-three-loop.js +814 -0
- package/dist/integrations/ruvector/sona-wrapper.d.ts +97 -0
- package/dist/integrations/ruvector/sona-wrapper.js +147 -3
- package/dist/integrations/ruvector/spectral-math.d.ts +101 -0
- package/dist/integrations/ruvector/spectral-math.js +254 -0
- package/dist/integrations/ruvector/temporal-compression.d.ts +163 -0
- package/dist/integrations/ruvector/temporal-compression.js +318 -0
- package/dist/integrations/ruvector/thompson-sampler.d.ts +61 -0
- package/dist/integrations/ruvector/thompson-sampler.js +118 -0
- package/dist/integrations/ruvector/transfer-coherence-stub.d.ts +80 -0
- package/dist/integrations/ruvector/transfer-coherence-stub.js +63 -0
- package/dist/integrations/ruvector/transfer-verification.d.ts +119 -0
- package/dist/integrations/ruvector/transfer-verification.js +115 -0
- package/dist/kernel/hnsw-adapter.d.ts +52 -1
- package/dist/kernel/hnsw-adapter.js +139 -4
- package/dist/kernel/hnsw-index-provider.d.ts +5 -0
- package/dist/kernel/native-hnsw-backend.d.ts +110 -0
- package/dist/kernel/native-hnsw-backend.js +408 -0
- package/dist/kernel/unified-memory.js +5 -6
- package/dist/learning/aqe-learning-engine.d.ts +2 -0
- package/dist/learning/aqe-learning-engine.js +65 -0
- package/dist/learning/experience-capture-middleware.js +20 -0
- package/dist/learning/experience-capture.d.ts +10 -0
- package/dist/learning/experience-capture.js +34 -0
- package/dist/learning/index.d.ts +2 -2
- package/dist/learning/index.js +4 -4
- package/dist/learning/metrics-tracker.d.ts +11 -0
- package/dist/learning/metrics-tracker.js +29 -13
- package/dist/learning/pattern-lifecycle.d.ts +30 -1
- package/dist/learning/pattern-lifecycle.js +92 -20
- package/dist/learning/pattern-store.d.ts +8 -0
- package/dist/learning/pattern-store.js +8 -2
- package/dist/learning/qe-unified-memory.js +1 -28
- package/dist/learning/regret-tracker.d.ts +201 -0
- package/dist/learning/regret-tracker.js +361 -0
- package/dist/mcp/bundle.js +5915 -474
- package/dist/routing/index.d.ts +4 -2
- package/dist/routing/index.js +3 -1
- package/dist/routing/neural-tiny-dancer-router.d.ts +268 -0
- package/dist/routing/neural-tiny-dancer-router.js +514 -0
- package/dist/routing/queen-integration.js +5 -5
- package/dist/routing/routing-config.d.ts +6 -0
- package/dist/routing/routing-config.js +1 -0
- package/dist/routing/simple-neural-router.d.ts +76 -0
- package/dist/routing/simple-neural-router.js +202 -0
- package/dist/routing/tiny-dancer-router.d.ts +20 -1
- package/dist/routing/tiny-dancer-router.js +21 -2
- package/dist/test-scheduling/dag-attention-scheduler.d.ts +81 -0
- package/dist/test-scheduling/dag-attention-scheduler.js +358 -0
- package/dist/test-scheduling/dag-attention-types.d.ts +81 -0
- package/dist/test-scheduling/dag-attention-types.js +10 -0
- package/dist/test-scheduling/index.d.ts +1 -0
- package/dist/test-scheduling/index.js +4 -0
- package/dist/test-scheduling/pipeline.d.ts +8 -0
- package/dist/test-scheduling/pipeline.js +28 -0
- package/package.json +6 -2
- package/dist/cli/commands/migrate.d.ts +0 -9
- package/dist/cli/commands/migrate.js +0 -566
- package/dist/init/init-wizard-migration.d.ts +0 -52
- package/dist/init/init-wizard-migration.js +0 -345
- package/dist/init/migration/config-migrator.d.ts +0 -31
- package/dist/init/migration/config-migrator.js +0 -149
- package/dist/init/migration/data-migrator.d.ts +0 -72
- package/dist/init/migration/data-migrator.js +0 -232
- package/dist/init/migration/detector.d.ts +0 -44
- package/dist/init/migration/detector.js +0 -105
- package/dist/init/migration/index.d.ts +0 -8
- package/dist/init/migration/index.js +0 -8
- package/dist/learning/v2-to-v3-migration.d.ts +0 -86
- package/dist/learning/v2-to-v3-migration.js +0 -529
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agentic QE v3 - CNN Visual Regression Testing
|
|
3
|
+
*
|
|
4
|
+
* TypeScript spatial pooling visual regression with optional Sobel edge detection.
|
|
5
|
+
* No native CNN package exists — the spatial pooling implementation IS the
|
|
6
|
+
* production implementation.
|
|
7
|
+
*
|
|
8
|
+
* - TypeScript spatial-pooling (8x8 grid, RGB channels)
|
|
9
|
+
* - Optional Sobel edge detection for gradient/structural change sensitivity
|
|
10
|
+
* - Supports regions of interest masking to ignore dynamic areas
|
|
11
|
+
* - Contrastive threshold learning from labeled positive/negative pairs
|
|
12
|
+
*
|
|
13
|
+
* @module domains/visual-accessibility/cnn-visual-regression
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Compute cosine similarity between two vectors of equal length.
|
|
17
|
+
* Returns 0 if either vector has zero norm.
|
|
18
|
+
*/
|
|
19
|
+
export function cosineSimilarity(a, b) {
|
|
20
|
+
if (a.length !== b.length) {
|
|
21
|
+
throw new Error(`Vector length mismatch: ${a.length} vs ${b.length}`);
|
|
22
|
+
}
|
|
23
|
+
let dot = 0, normA = 0, normB = 0;
|
|
24
|
+
for (let i = 0; i < a.length; i++) {
|
|
25
|
+
dot += a[i] * b[i];
|
|
26
|
+
normA += a[i] * a[i];
|
|
27
|
+
normB += b[i] * b[i];
|
|
28
|
+
}
|
|
29
|
+
const denom = Math.sqrt(normA) * Math.sqrt(normB);
|
|
30
|
+
return denom === 0 ? 0 : dot / denom;
|
|
31
|
+
}
|
|
32
|
+
/** L2-normalize a vector in place and return it. */
|
|
33
|
+
function l2Normalize(vec) {
|
|
34
|
+
let norm = 0;
|
|
35
|
+
for (let i = 0; i < vec.length; i++)
|
|
36
|
+
norm += vec[i] * vec[i];
|
|
37
|
+
norm = Math.sqrt(norm);
|
|
38
|
+
if (norm > 0) {
|
|
39
|
+
for (let i = 0; i < vec.length; i++)
|
|
40
|
+
vec[i] /= norm;
|
|
41
|
+
}
|
|
42
|
+
return vec;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* CNN-based visual regression testing using embedding comparison.
|
|
46
|
+
*
|
|
47
|
+
* Images are projected into a compact embedding space via spatial average
|
|
48
|
+
* pooling. Cosine similarity determines whether two images represent the
|
|
49
|
+
* same visual state.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const cnn = new CNNVisualRegression();
|
|
54
|
+
* const baseline = cnn.computeEmbedding(baselinePixels, 1024, 768);
|
|
55
|
+
* const current = cnn.computeEmbedding(currentPixels, 1024, 768);
|
|
56
|
+
* if (cnn.isRegression(baseline, current)) {
|
|
57
|
+
* console.log('Visual regression detected!');
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export class CNNVisualRegression {
|
|
62
|
+
defaultThreshold;
|
|
63
|
+
defaultGridSize;
|
|
64
|
+
tryNative;
|
|
65
|
+
useEdgeDetection;
|
|
66
|
+
nativeBackend = null;
|
|
67
|
+
nativeLoadAttempted = false;
|
|
68
|
+
constructor(config) {
|
|
69
|
+
this.defaultThreshold = config?.defaultThreshold ?? 0.95;
|
|
70
|
+
this.defaultGridSize = config?.defaultGridSize ?? 8;
|
|
71
|
+
this.tryNative = config?.tryNativeBackend ?? true;
|
|
72
|
+
this.useEdgeDetection = config?.useEdgeDetection ?? false;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Check for native CNN backend.
|
|
76
|
+
* No native package exists — always returns false.
|
|
77
|
+
* The TypeScript spatial pooling implementation is used.
|
|
78
|
+
*/
|
|
79
|
+
async tryLoadNativeBackend() {
|
|
80
|
+
if (this.nativeLoadAttempted)
|
|
81
|
+
return this.nativeBackend !== null;
|
|
82
|
+
this.nativeLoadAttempted = true;
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Compute a feature embedding for an image using spatial average pooling.
|
|
87
|
+
* When edge detection is enabled (via config or options), the embedding
|
|
88
|
+
* concatenates spatial pooling of the original pixels with spatial pooling
|
|
89
|
+
* of the Sobel edge map, then L2-normalizes the result.
|
|
90
|
+
*
|
|
91
|
+
* @param imageData Raw pixel data in RGBA format (4 bytes per pixel)
|
|
92
|
+
* @param width Image width in pixels
|
|
93
|
+
* @param height Image height in pixels
|
|
94
|
+
* @param options Configuration for grid size, masking, and edge detection
|
|
95
|
+
* @returns L2-normalized embedding vector
|
|
96
|
+
*/
|
|
97
|
+
computeEmbedding(imageData, width, height, options) {
|
|
98
|
+
this.validateImageInput(imageData, width, height);
|
|
99
|
+
const gridSize = options?.gridSize ?? this.defaultGridSize;
|
|
100
|
+
const channels = options?.channels ?? 3;
|
|
101
|
+
let pixels = imageData;
|
|
102
|
+
if (options?.maskRegions && options.maskRegions.length > 0) {
|
|
103
|
+
pixels = this.applyMask(imageData, width, height, options.maskRegions);
|
|
104
|
+
}
|
|
105
|
+
const edgeEnabled = this.useEdgeDetection || (options?.useEdgeDetection === true);
|
|
106
|
+
if (edgeEnabled) {
|
|
107
|
+
const spatialEmbed = this.computeSpatialPoolingEmbedding(pixels, width, height, gridSize, channels);
|
|
108
|
+
const edgeMap = this.applySobelEdgeDetection(pixels, width, height);
|
|
109
|
+
const edgeEmbed = this.computeSpatialPoolingEmbedding(edgeMap, width, height, gridSize, channels);
|
|
110
|
+
const combined = new Float32Array(spatialEmbed.length + edgeEmbed.length);
|
|
111
|
+
combined.set(spatialEmbed, 0);
|
|
112
|
+
combined.set(edgeEmbed, spatialEmbed.length);
|
|
113
|
+
return l2Normalize(combined);
|
|
114
|
+
}
|
|
115
|
+
return this.computeSpatialPoolingEmbedding(pixels, width, height, gridSize, channels);
|
|
116
|
+
}
|
|
117
|
+
/** Compute embedding asynchronously, attempting native backend first. */
|
|
118
|
+
async computeEmbeddingAsync(imageData, width, height, options) {
|
|
119
|
+
this.validateImageInput(imageData, width, height);
|
|
120
|
+
const hasNative = await this.tryLoadNativeBackend();
|
|
121
|
+
if (hasNative && this.nativeBackend) {
|
|
122
|
+
let pixels = imageData;
|
|
123
|
+
if (options?.maskRegions && options.maskRegions.length > 0) {
|
|
124
|
+
pixels = this.applyMask(imageData, width, height, options.maskRegions);
|
|
125
|
+
}
|
|
126
|
+
return this.nativeBackend.computeEmbedding(pixels, width, height);
|
|
127
|
+
}
|
|
128
|
+
return this.computeEmbedding(imageData, width, height, options);
|
|
129
|
+
}
|
|
130
|
+
/** Compare two embeddings and produce a detailed comparison result. */
|
|
131
|
+
compare(baseline, current, threshold) {
|
|
132
|
+
const t = threshold ?? this.defaultThreshold;
|
|
133
|
+
const similarity = cosineSimilarity(baseline, current);
|
|
134
|
+
return { similarity, isMatch: similarity >= t, threshold: t };
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Compare embeddings with per-region analysis. Computes per-region
|
|
138
|
+
* similarity alongside the global similarity.
|
|
139
|
+
*/
|
|
140
|
+
compareWithRegions(baseline, current, regions, imageWidth, imageHeight, threshold) {
|
|
141
|
+
const t = threshold ?? this.defaultThreshold;
|
|
142
|
+
const globalSimilarity = cosineSimilarity(baseline, current);
|
|
143
|
+
const gridSize = this.defaultGridSize;
|
|
144
|
+
const channels = 3;
|
|
145
|
+
const regionSimilarities = regions.map((region, regionIndex) => ({
|
|
146
|
+
regionIndex,
|
|
147
|
+
similarity: this.computeRegionSimilarity(baseline, current, region, imageWidth, imageHeight, gridSize, channels),
|
|
148
|
+
}));
|
|
149
|
+
return { similarity: globalSimilarity, isMatch: globalSimilarity >= t, threshold: t, regionSimilarities };
|
|
150
|
+
}
|
|
151
|
+
/** Check if a visual regression has occurred (similarity below threshold). */
|
|
152
|
+
isRegression(baseline, current, threshold) {
|
|
153
|
+
return cosineSimilarity(baseline, current) < (threshold ?? this.defaultThreshold);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Learn an optimal threshold from labeled positive/negative pairs.
|
|
157
|
+
* Sweeps candidate thresholds and picks the one maximizing accuracy.
|
|
158
|
+
* @throws Error if no examples or all examples share the same label
|
|
159
|
+
*/
|
|
160
|
+
learnThreshold(examples) {
|
|
161
|
+
if (examples.length === 0) {
|
|
162
|
+
throw new Error('At least one labeled pair is required');
|
|
163
|
+
}
|
|
164
|
+
if (!examples.some((e) => e.isMatch) || !examples.some((e) => !e.isMatch)) {
|
|
165
|
+
throw new Error('Examples must contain both matching and non-matching pairs');
|
|
166
|
+
}
|
|
167
|
+
const scored = examples
|
|
168
|
+
.map((ex) => ({ similarity: cosineSimilarity(ex.embedA, ex.embedB), isMatch: ex.isMatch }))
|
|
169
|
+
.sort((a, b) => a.similarity - b.similarity);
|
|
170
|
+
let bestThreshold = 0;
|
|
171
|
+
let bestAccuracy = 0;
|
|
172
|
+
for (const { similarity: candidate } of scored) {
|
|
173
|
+
let correct = 0;
|
|
174
|
+
for (const item of scored) {
|
|
175
|
+
if ((item.similarity >= candidate) === item.isMatch)
|
|
176
|
+
correct++;
|
|
177
|
+
}
|
|
178
|
+
const accuracy = correct / scored.length;
|
|
179
|
+
if (accuracy > bestAccuracy) {
|
|
180
|
+
bestAccuracy = accuracy;
|
|
181
|
+
bestThreshold = candidate;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return bestThreshold;
|
|
185
|
+
}
|
|
186
|
+
computeRegionSimilarity(baseline, current, region, imageWidth, imageHeight, gridSize, channels) {
|
|
187
|
+
const cellW = imageWidth / gridSize;
|
|
188
|
+
const cellH = imageHeight / gridSize;
|
|
189
|
+
const gxStart = Math.max(0, Math.floor(region.x / cellW));
|
|
190
|
+
const gxEnd = Math.min(gridSize, Math.ceil((region.x + region.width) / cellW));
|
|
191
|
+
const gyStart = Math.max(0, Math.floor(region.y / cellH));
|
|
192
|
+
const gyEnd = Math.min(gridSize, Math.ceil((region.y + region.height) / cellH));
|
|
193
|
+
const regionBaseline = [];
|
|
194
|
+
const regionCurrent = [];
|
|
195
|
+
for (let gy = gyStart; gy < gyEnd; gy++) {
|
|
196
|
+
for (let gx = gxStart; gx < gxEnd; gx++) {
|
|
197
|
+
const base = (gy * gridSize + gx) * channels;
|
|
198
|
+
for (let c = 0; c < channels; c++) {
|
|
199
|
+
regionBaseline.push(baseline[base + c]);
|
|
200
|
+
regionCurrent.push(current[base + c]);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (regionBaseline.length === 0)
|
|
205
|
+
return 1.0;
|
|
206
|
+
return cosineSimilarity(new Float32Array(regionBaseline), new Float32Array(regionCurrent));
|
|
207
|
+
}
|
|
208
|
+
/** Spatial average pooling: divides image into grid, averages RGB per cell, L2-normalizes. */
|
|
209
|
+
computeSpatialPoolingEmbedding(pixels, width, height, gridSize, channels) {
|
|
210
|
+
const embedding = new Float32Array(gridSize * gridSize * channels);
|
|
211
|
+
const cellW = width / gridSize;
|
|
212
|
+
const cellH = height / gridSize;
|
|
213
|
+
for (let gy = 0; gy < gridSize; gy++) {
|
|
214
|
+
for (let gx = 0; gx < gridSize; gx++) {
|
|
215
|
+
const sums = new Float64Array(channels);
|
|
216
|
+
let count = 0;
|
|
217
|
+
const yStart = Math.floor(gy * cellH);
|
|
218
|
+
const yEnd = Math.floor((gy + 1) * cellH);
|
|
219
|
+
const xStart = Math.floor(gx * cellW);
|
|
220
|
+
const xEnd = Math.floor((gx + 1) * cellW);
|
|
221
|
+
for (let y = yStart; y < yEnd; y++) {
|
|
222
|
+
for (let x = xStart; x < xEnd; x++) {
|
|
223
|
+
const idx = (y * width + x) * 4;
|
|
224
|
+
for (let c = 0; c < channels; c++)
|
|
225
|
+
sums[c] += pixels[idx + c];
|
|
226
|
+
count++;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const base = (gy * gridSize + gx) * channels;
|
|
230
|
+
for (let c = 0; c < channels; c++) {
|
|
231
|
+
embedding[base + c] = count > 0 ? sums[c] / count / 255 : 0;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return l2Normalize(embedding);
|
|
236
|
+
}
|
|
237
|
+
/** Zero out pixel data in masked regions. Returns a copy. */
|
|
238
|
+
applyMask(pixels, width, height, regions) {
|
|
239
|
+
const masked = new Uint8Array(pixels);
|
|
240
|
+
for (const region of regions) {
|
|
241
|
+
const xStart = Math.max(0, Math.min(region.x, width));
|
|
242
|
+
const xEnd = Math.max(0, Math.min(region.x + region.width, width));
|
|
243
|
+
const yStart = Math.max(0, Math.min(region.y, height));
|
|
244
|
+
const yEnd = Math.max(0, Math.min(region.y + region.height, height));
|
|
245
|
+
for (let y = yStart; y < yEnd; y++) {
|
|
246
|
+
for (let x = xStart; x < xEnd; x++) {
|
|
247
|
+
const idx = (y * width + x) * 4;
|
|
248
|
+
masked[idx] = 0;
|
|
249
|
+
masked[idx + 1] = 0;
|
|
250
|
+
masked[idx + 2] = 0;
|
|
251
|
+
masked[idx + 3] = 0;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return masked;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Apply Sobel edge detection to an RGBA image.
|
|
259
|
+
* Converts to grayscale, applies 3x3 Sobel kernels for horizontal and
|
|
260
|
+
* vertical gradients, computes the magnitude, and returns the result
|
|
261
|
+
* as RGBA (edge magnitude in R,G,B channels, alpha=255).
|
|
262
|
+
*/
|
|
263
|
+
applySobelEdgeDetection(pixels, width, height) {
|
|
264
|
+
// Convert RGBA to grayscale
|
|
265
|
+
const gray = new Float64Array(width * height);
|
|
266
|
+
for (let i = 0; i < width * height; i++) {
|
|
267
|
+
const idx = i * 4;
|
|
268
|
+
gray[i] = 0.299 * pixels[idx] + 0.587 * pixels[idx + 1] + 0.114 * pixels[idx + 2];
|
|
269
|
+
}
|
|
270
|
+
const output = new Uint8Array(width * height * 4);
|
|
271
|
+
// Sobel kernels
|
|
272
|
+
// Gx = [[-1,0,1],[-2,0,2],[-1,0,1]]
|
|
273
|
+
// Gy = [[-1,-2,-1],[0,0,0],[1,2,1]]
|
|
274
|
+
for (let y = 0; y < height; y++) {
|
|
275
|
+
for (let x = 0; x < width; x++) {
|
|
276
|
+
let gx = 0;
|
|
277
|
+
let gy = 0;
|
|
278
|
+
// Apply 3x3 kernel centered at (x, y)
|
|
279
|
+
for (let ky = -1; ky <= 1; ky++) {
|
|
280
|
+
for (let kx = -1; kx <= 1; kx++) {
|
|
281
|
+
const sy = Math.min(Math.max(y + ky, 0), height - 1);
|
|
282
|
+
const sx = Math.min(Math.max(x + kx, 0), width - 1);
|
|
283
|
+
const val = gray[sy * width + sx];
|
|
284
|
+
// Gx kernel
|
|
285
|
+
if (kx === -1) {
|
|
286
|
+
gx -= val * (ky === 0 ? 2 : 1);
|
|
287
|
+
}
|
|
288
|
+
else if (kx === 1) {
|
|
289
|
+
gx += val * (ky === 0 ? 2 : 1);
|
|
290
|
+
}
|
|
291
|
+
// Gy kernel
|
|
292
|
+
if (ky === -1) {
|
|
293
|
+
gy -= val * (kx === 0 ? 2 : 1);
|
|
294
|
+
}
|
|
295
|
+
else if (ky === 1) {
|
|
296
|
+
gy += val * (kx === 0 ? 2 : 1);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
const magnitude = Math.min(Math.sqrt(gx * gx + gy * gy), 255);
|
|
301
|
+
const outIdx = (y * width + x) * 4;
|
|
302
|
+
const mag = Math.round(magnitude);
|
|
303
|
+
output[outIdx] = mag;
|
|
304
|
+
output[outIdx + 1] = mag;
|
|
305
|
+
output[outIdx + 2] = mag;
|
|
306
|
+
output[outIdx + 3] = 255;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return output;
|
|
310
|
+
}
|
|
311
|
+
validateImageInput(imageData, width, height) {
|
|
312
|
+
if (width <= 0 || height <= 0) {
|
|
313
|
+
throw new Error(`Invalid image dimensions: ${width}x${height}`);
|
|
314
|
+
}
|
|
315
|
+
const expectedLength = width * height * 4;
|
|
316
|
+
if (imageData.length < expectedLength) {
|
|
317
|
+
throw new Error(`Image data too small: expected at least ${expectedLength} bytes for ${width}x${height} RGBA, got ${imageData.length}`);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
getDefaultThreshold() { return this.defaultThreshold; }
|
|
321
|
+
getEmbeddingDimension(gridSize) {
|
|
322
|
+
const base = (gridSize ?? this.defaultGridSize) ** 2 * 3;
|
|
323
|
+
return this.useEdgeDetection ? base * 2 : base;
|
|
324
|
+
}
|
|
325
|
+
isNativeBackendLoaded() { return this.nativeBackend !== null; }
|
|
326
|
+
}
|
|
327
|
+
//# sourceMappingURL=cnn-visual-regression.js.map
|
|
@@ -12,6 +12,7 @@ export { ResponsiveTesterService, DEVICE_VIEWPORTS, type IResponsiveTestingServi
|
|
|
12
12
|
export { ViewportCaptureService, createViewportCaptureService, VIEWPORT_PRESETS, DEFAULT_BREAKPOINTS, type IViewportCaptureService, type ViewportPreset, type ViewportCaptureResult, type MultiViewportCaptureResult, type ResponsiveAnalysis as ViewportResponsiveAnalysis, type DetectedBreakpoint, type LayoutShift, type ScreenshotComparisonResult, type ViewportCaptureConfig, type CaptureAllOptions, type BreakpointCaptureOptions, type SingleCaptureOptions, } from './services/viewport-capture.js';
|
|
13
13
|
export { VisualRegressionService, createVisualRegressionService, type VisualRegressionConfig, type BaselineMetadata, type VisualRegressionResult, type VisualRegressionTestOptions, type IVisualRegressionService, } from './services/visual-regression.js';
|
|
14
14
|
export { EUComplianceService, EN_301_549_WEB_CLAUSES, EAA_WEB_REQUIREMENTS, WCAG_TO_EN301549_MAP, getWCAGLevel, type EUComplianceServiceConfig, } from './services/eu-compliance.js';
|
|
15
|
+
export { CNNVisualRegression, cosineSimilarity, type ComparisonResult, type LabeledPair, type RegionOfInterest, type EmbeddingOptions, type CNNVisualRegressionConfig, } from './cnn-visual-regression.js';
|
|
15
16
|
export type { Screenshot, Viewport, ScreenshotMetadata, VisualDiff, DiffRegion, DiffStatus, CaptureOptions, IVisualTestingService, AccessibilityViolation, WCAGCriterion, ViolationNode, ContrastAnalysis, AccessibilityReport, PassedRule, IncompleteCheck, WCAGValidationResult, KeyboardNavigationReport, TabOrderItem, KeyboardIssue, FocusTrap, AuditOptions, IAccessibilityAuditingService, IScreenshotDiffService, AIComparisonResult, DetectedChange, VisualTestReport, VisualTestResult, AccessibilityAuditReport, TopAccessibilityIssue, RemediationPlan, ViolationRemediation, VisualTestingStatus, IVisualAccessibilityCoordinator, IScreenshotRepository, IVisualDiffRepository, IAccessibilityReportRepository, VisualRegressionDetectedEvent, AccessibilityAuditCompletedEvent, BaselineUpdatedEvent, ContrastFailureEvent, EN301549Clause, EAARequirement, EAAProductCategory, EUComplianceResult, EN301549ClauseResult, WCAGtoEN301549Mapping, EUComplianceRecommendation, EUComplianceReport, EAAComplianceResult, EAARequirementResult, EAAExemption, EUComplianceOptions, } from './interfaces.js';
|
|
16
17
|
export { injectAxeCore, runAxeAudit, parseAxeResults, runCompleteAxeAudit, AxeCoreInjectionError, AxeCoreAuditError, WCAG_TAG_MAP, WCAG_CRITERIA_MAP, FIX_SUGGESTIONS, AXE_CORE_CDN_URL, DEFAULT_AXE_CONFIG, type AxeOptions, type AxeResults, type AxeViolation, type AxePass, type AxeIncomplete, type AxeInapplicable, type AxeNode, type AxeCheck, type AxeRelatedNode, type AxeTestEnvironment, type AxeTestRunner, type AxeToolOptions, type AxeCoreConfig, } from './services/axe-core-integration.js';
|
|
17
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -22,6 +22,10 @@ export { ViewportCaptureService, createViewportCaptureService, VIEWPORT_PRESETS,
|
|
|
22
22
|
export { VisualRegressionService, createVisualRegressionService, } from './services/visual-regression.js';
|
|
23
23
|
export { EUComplianceService, EN_301_549_WEB_CLAUSES, EAA_WEB_REQUIREMENTS, WCAG_TO_EN301549_MAP, getWCAGLevel, } from './services/eu-compliance.js';
|
|
24
24
|
// ============================================================================
|
|
25
|
+
// CNN Visual Regression (Task 4.3)
|
|
26
|
+
// ============================================================================
|
|
27
|
+
export { CNNVisualRegression, cosineSimilarity, } from './cnn-visual-regression.js';
|
|
28
|
+
// ============================================================================
|
|
25
29
|
// axe-core Integration
|
|
26
30
|
// ============================================================================
|
|
27
31
|
export {
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coherence Validator - Governance Pipeline for Test Artifact Validation
|
|
3
|
+
*
|
|
4
|
+
* Provides a validation pipeline that uses CoherenceGate to validate
|
|
5
|
+
* AI-generated test artifacts. Operates in two modes:
|
|
6
|
+
*
|
|
7
|
+
* - **Advisory mode** (default): Logs coherence violations but does not block.
|
|
8
|
+
* The artifact is always approved with a warning attached.
|
|
9
|
+
*
|
|
10
|
+
* - **Blocking mode**: Rejects artifacts that exceed the coherence threshold.
|
|
11
|
+
* Must be explicitly enabled via configuration.
|
|
12
|
+
*
|
|
13
|
+
* @module governance/coherence-validator
|
|
14
|
+
* @see ADR-083-coherence-gated-agent-actions.md
|
|
15
|
+
*/
|
|
16
|
+
import { CoherenceGate, type TestArtifact, type ValidationResult, type CoherenceDecision } from '../integrations/ruvector/coherence-gate.js';
|
|
17
|
+
/**
|
|
18
|
+
* Configuration for the coherence validation pipeline.
|
|
19
|
+
*/
|
|
20
|
+
export interface CoherenceValidatorConfig {
|
|
21
|
+
/** Whether to block on coherence violations (default: false = advisory) */
|
|
22
|
+
blocking: boolean;
|
|
23
|
+
/** Coherence energy threshold (default: 0.4) */
|
|
24
|
+
threshold: number;
|
|
25
|
+
/** Whether to emit warnings to the log in advisory mode (default: true) */
|
|
26
|
+
logWarnings: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Result from the validation pipeline.
|
|
30
|
+
*/
|
|
31
|
+
export interface ValidationPipelineResult {
|
|
32
|
+
/** Whether the artifact is approved (always true in advisory mode) */
|
|
33
|
+
approved: boolean;
|
|
34
|
+
/** The mode used for this validation */
|
|
35
|
+
mode: 'advisory' | 'blocking';
|
|
36
|
+
/** The underlying coherence validation result */
|
|
37
|
+
validation: ValidationResult;
|
|
38
|
+
/** Warnings generated (populated in advisory mode when energy exceeds threshold) */
|
|
39
|
+
warnings: string[];
|
|
40
|
+
/** Whether the coherence gate feature flag was enabled */
|
|
41
|
+
featureFlagEnabled: boolean;
|
|
42
|
+
}
|
|
43
|
+
/** Default configuration: advisory mode */
|
|
44
|
+
export declare const DEFAULT_COHERENCE_VALIDATOR_CONFIG: CoherenceValidatorConfig;
|
|
45
|
+
/**
|
|
46
|
+
* Validation pipeline that uses CoherenceGate for test artifact validation.
|
|
47
|
+
*
|
|
48
|
+
* Wraps the CoherenceGate with configurable advisory/blocking behavior
|
|
49
|
+
* and integrates with the governance logging infrastructure.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const validator = new CoherenceValidator(); // advisory mode by default
|
|
54
|
+
* const result = validator.validateTestArtifact({
|
|
55
|
+
* assertions: ['expect(x).toBe(1)'],
|
|
56
|
+
* observedBehavior: ['x was 1'],
|
|
57
|
+
* coverage: 0.9,
|
|
58
|
+
* domain: 'test-generation',
|
|
59
|
+
* confidence: 0.95,
|
|
60
|
+
* });
|
|
61
|
+
* if (result.warnings.length > 0) {
|
|
62
|
+
* console.warn('Coherence warnings:', result.warnings);
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare class CoherenceValidator {
|
|
67
|
+
private readonly config;
|
|
68
|
+
private readonly gate;
|
|
69
|
+
private validationCount;
|
|
70
|
+
private warningCount;
|
|
71
|
+
private blockCount;
|
|
72
|
+
constructor(config?: Partial<CoherenceValidatorConfig>);
|
|
73
|
+
/**
|
|
74
|
+
* Validate a test artifact through the coherence pipeline.
|
|
75
|
+
*
|
|
76
|
+
* In advisory mode (default), always approves but attaches warnings
|
|
77
|
+
* when coherence energy exceeds the threshold.
|
|
78
|
+
*
|
|
79
|
+
* In blocking mode, rejects artifacts that exceed the threshold.
|
|
80
|
+
*
|
|
81
|
+
* @param artifact - The test artifact to validate
|
|
82
|
+
* @returns Pipeline result with approval status and warnings
|
|
83
|
+
*/
|
|
84
|
+
validateTestArtifact(artifact: TestArtifact): ValidationPipelineResult;
|
|
85
|
+
/**
|
|
86
|
+
* Get the decision log from the underlying coherence gate.
|
|
87
|
+
*/
|
|
88
|
+
getDecisionLog(): CoherenceDecision[];
|
|
89
|
+
/**
|
|
90
|
+
* Get validation statistics.
|
|
91
|
+
*/
|
|
92
|
+
getStats(): {
|
|
93
|
+
validationCount: number;
|
|
94
|
+
warningCount: number;
|
|
95
|
+
blockCount: number;
|
|
96
|
+
mode: 'advisory' | 'blocking';
|
|
97
|
+
threshold: number;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Get the underlying coherence gate (for advanced usage or testing).
|
|
101
|
+
*/
|
|
102
|
+
getGate(): CoherenceGate;
|
|
103
|
+
/**
|
|
104
|
+
* Create a passthrough result when the feature flag is disabled.
|
|
105
|
+
*/
|
|
106
|
+
private createPassthroughResult;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Create a coherence validator with the given configuration.
|
|
110
|
+
*/
|
|
111
|
+
export declare function createCoherenceValidator(config?: Partial<CoherenceValidatorConfig>): CoherenceValidator;
|
|
112
|
+
//# sourceMappingURL=coherence-validator.d.ts.map
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coherence Validator - Governance Pipeline for Test Artifact Validation
|
|
3
|
+
*
|
|
4
|
+
* Provides a validation pipeline that uses CoherenceGate to validate
|
|
5
|
+
* AI-generated test artifacts. Operates in two modes:
|
|
6
|
+
*
|
|
7
|
+
* - **Advisory mode** (default): Logs coherence violations but does not block.
|
|
8
|
+
* The artifact is always approved with a warning attached.
|
|
9
|
+
*
|
|
10
|
+
* - **Blocking mode**: Rejects artifacts that exceed the coherence threshold.
|
|
11
|
+
* Must be explicitly enabled via configuration.
|
|
12
|
+
*
|
|
13
|
+
* @module governance/coherence-validator
|
|
14
|
+
* @see ADR-083-coherence-gated-agent-actions.md
|
|
15
|
+
*/
|
|
16
|
+
import { LoggerFactory } from '../logging/index.js';
|
|
17
|
+
import { createCoherenceGate, DEFAULT_COHERENCE_THRESHOLD, } from '../integrations/ruvector/coherence-gate.js';
|
|
18
|
+
import { getRuVectorFeatureFlags } from '../integrations/ruvector/feature-flags.js';
|
|
19
|
+
const logger = LoggerFactory.create('coherence-validator');
|
|
20
|
+
/** Default configuration: advisory mode */
|
|
21
|
+
export const DEFAULT_COHERENCE_VALIDATOR_CONFIG = {
|
|
22
|
+
blocking: false,
|
|
23
|
+
threshold: DEFAULT_COHERENCE_THRESHOLD,
|
|
24
|
+
logWarnings: true,
|
|
25
|
+
};
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// Coherence Validator
|
|
28
|
+
// ============================================================================
|
|
29
|
+
/**
|
|
30
|
+
* Validation pipeline that uses CoherenceGate for test artifact validation.
|
|
31
|
+
*
|
|
32
|
+
* Wraps the CoherenceGate with configurable advisory/blocking behavior
|
|
33
|
+
* and integrates with the governance logging infrastructure.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const validator = new CoherenceValidator(); // advisory mode by default
|
|
38
|
+
* const result = validator.validateTestArtifact({
|
|
39
|
+
* assertions: ['expect(x).toBe(1)'],
|
|
40
|
+
* observedBehavior: ['x was 1'],
|
|
41
|
+
* coverage: 0.9,
|
|
42
|
+
* domain: 'test-generation',
|
|
43
|
+
* confidence: 0.95,
|
|
44
|
+
* });
|
|
45
|
+
* if (result.warnings.length > 0) {
|
|
46
|
+
* console.warn('Coherence warnings:', result.warnings);
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export class CoherenceValidator {
|
|
51
|
+
config;
|
|
52
|
+
gate;
|
|
53
|
+
validationCount = 0;
|
|
54
|
+
warningCount = 0;
|
|
55
|
+
blockCount = 0;
|
|
56
|
+
constructor(config = {}) {
|
|
57
|
+
this.config = { ...DEFAULT_COHERENCE_VALIDATOR_CONFIG, ...config };
|
|
58
|
+
this.gate = createCoherenceGate(this.config.threshold);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Validate a test artifact through the coherence pipeline.
|
|
62
|
+
*
|
|
63
|
+
* In advisory mode (default), always approves but attaches warnings
|
|
64
|
+
* when coherence energy exceeds the threshold.
|
|
65
|
+
*
|
|
66
|
+
* In blocking mode, rejects artifacts that exceed the threshold.
|
|
67
|
+
*
|
|
68
|
+
* @param artifact - The test artifact to validate
|
|
69
|
+
* @returns Pipeline result with approval status and warnings
|
|
70
|
+
*/
|
|
71
|
+
validateTestArtifact(artifact) {
|
|
72
|
+
const flags = getRuVectorFeatureFlags();
|
|
73
|
+
const featureFlagEnabled = flags.useCoherenceGate;
|
|
74
|
+
// If feature flag is disabled, pass through
|
|
75
|
+
if (!featureFlagEnabled) {
|
|
76
|
+
return this.createPassthroughResult(artifact);
|
|
77
|
+
}
|
|
78
|
+
this.validationCount++;
|
|
79
|
+
const validation = this.gate.validate(artifact, this.config.threshold);
|
|
80
|
+
const warnings = [];
|
|
81
|
+
const mode = this.config.blocking ? 'blocking' : 'advisory';
|
|
82
|
+
if (!validation.passed) {
|
|
83
|
+
const warning = `Coherence validation warning for domain '${artifact.domain}': ${validation.reason}`;
|
|
84
|
+
warnings.push(warning);
|
|
85
|
+
if (this.config.logWarnings) {
|
|
86
|
+
logger.warn(warning, {
|
|
87
|
+
energy: validation.energy,
|
|
88
|
+
threshold: validation.threshold,
|
|
89
|
+
domain: artifact.domain,
|
|
90
|
+
mode,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
if (this.config.blocking) {
|
|
94
|
+
this.blockCount++;
|
|
95
|
+
logger.info('Artifact blocked by coherence gate', {
|
|
96
|
+
energy: validation.energy,
|
|
97
|
+
domain: artifact.domain,
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
approved: false,
|
|
101
|
+
mode: 'blocking',
|
|
102
|
+
validation,
|
|
103
|
+
warnings,
|
|
104
|
+
featureFlagEnabled,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
// Advisory mode: approve but warn
|
|
108
|
+
this.warningCount++;
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
approved: true,
|
|
112
|
+
mode,
|
|
113
|
+
validation,
|
|
114
|
+
warnings,
|
|
115
|
+
featureFlagEnabled,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get the decision log from the underlying coherence gate.
|
|
120
|
+
*/
|
|
121
|
+
getDecisionLog() {
|
|
122
|
+
return this.gate.getDecisionLog();
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get validation statistics.
|
|
126
|
+
*/
|
|
127
|
+
getStats() {
|
|
128
|
+
return {
|
|
129
|
+
validationCount: this.validationCount,
|
|
130
|
+
warningCount: this.warningCount,
|
|
131
|
+
blockCount: this.blockCount,
|
|
132
|
+
mode: this.config.blocking ? 'blocking' : 'advisory',
|
|
133
|
+
threshold: this.config.threshold,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Get the underlying coherence gate (for advanced usage or testing).
|
|
138
|
+
*/
|
|
139
|
+
getGate() {
|
|
140
|
+
return this.gate;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Create a passthrough result when the feature flag is disabled.
|
|
144
|
+
*/
|
|
145
|
+
createPassthroughResult(artifact) {
|
|
146
|
+
// Construct a minimal validation result for passthrough
|
|
147
|
+
const validation = {
|
|
148
|
+
passed: true,
|
|
149
|
+
energy: 0,
|
|
150
|
+
threshold: this.config.threshold,
|
|
151
|
+
witness: {
|
|
152
|
+
id: 'passthrough',
|
|
153
|
+
timestamp: Date.now(),
|
|
154
|
+
artifactHash: 'disabled',
|
|
155
|
+
energy: 0,
|
|
156
|
+
threshold: this.config.threshold,
|
|
157
|
+
passed: true,
|
|
158
|
+
previousHash: '0'.repeat(64),
|
|
159
|
+
recordHash: '0'.repeat(64),
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
return {
|
|
163
|
+
approved: true,
|
|
164
|
+
mode: this.config.blocking ? 'blocking' : 'advisory',
|
|
165
|
+
validation,
|
|
166
|
+
warnings: [],
|
|
167
|
+
featureFlagEnabled: false,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// ============================================================================
|
|
172
|
+
// Factory
|
|
173
|
+
// ============================================================================
|
|
174
|
+
/**
|
|
175
|
+
* Create a coherence validator with the given configuration.
|
|
176
|
+
*/
|
|
177
|
+
export function createCoherenceValidator(config) {
|
|
178
|
+
return new CoherenceValidator(config);
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=coherence-validator.js.map
|
|
@@ -35,4 +35,5 @@ export { ShardEmbeddingsManager, shardEmbeddingsManager, DEFAULT_SHARD_EMBEDDING
|
|
|
35
35
|
export { AdversarialDefenseIntegration, adversarialDefenseIntegration, quickThreatAssess, isSafeInput, sanitizeUserInput, type ThreatContext, type DetectedPattern, type ThreatAssessment, type DetectionPattern, type ThreatCategory, type PatternStats, type DefenseStats, } from './adversarial-defense-integration.js';
|
|
36
36
|
export { ComplianceReporter, complianceReporter, createComplianceReporter, isComplianceReporterEnabled as isComplianceReporterFeatureEnabled, DEFAULT_COMPLIANCE_REPORTER_FLAGS, type ViolationType, type ViolationSeverity, type ComplianceViolation, type ViolationFilter, type TimeWindow, type ComplianceScore, type ReportOptions, type ComplianceReport, type Alert, type ComplianceStats, type ComplianceReporterFlags, } from './compliance-reporter.js';
|
|
37
37
|
export { ConstitutionalEnforcer, constitutionalEnforcer, createConstitutionalEnforcer, isConstitutionalEnforcementEnabled, isStrictEnforcementEnabled, DEFAULT_CONSTITUTIONAL_ENFORCER_FLAGS, type Invariant, type InvariantCheck, type EnforcementResult, type EnforcementStats, type ExecutionProof, type SecurityScan, type Backup, type DeleteOperation, type AgentStats as ConstitutionalAgentStats, type MemoryPattern as ConstitutionalMemoryPattern, type Verification, type ConstitutionalEnforcerFlags, } from './constitutional-enforcer.js';
|
|
38
|
+
export { WitnessChain, PersistentWitnessChain, createWitnessChain, createPersistentWitnessChain, createWitnessChainSQLitePersistence, isWitnessChainFeatureEnabled, SPRTAccumulator, type IWitnessChainPersistence, type WitnessDecision, type WitnessReceipt, type ChainVerificationResult as WitnessChainVerificationResult, type WitnessChainExport, } from './witness-chain.js';
|
|
38
39
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/governance/index.js
CHANGED
|
@@ -45,4 +45,6 @@ export { AdversarialDefenseIntegration, adversarialDefenseIntegration, quickThre
|
|
|
45
45
|
export { ComplianceReporter, complianceReporter, createComplianceReporter, isComplianceReporterEnabled as isComplianceReporterFeatureEnabled, DEFAULT_COMPLIANCE_REPORTER_FLAGS, } from './compliance-reporter.js';
|
|
46
46
|
// Constitutional Enforcer
|
|
47
47
|
export { ConstitutionalEnforcer, constitutionalEnforcer, createConstitutionalEnforcer, isConstitutionalEnforcementEnabled, isStrictEnforcementEnabled, DEFAULT_CONSTITUTIONAL_ENFORCER_FLAGS, } from './constitutional-enforcer.js';
|
|
48
|
+
// Witness Chain - Hash-linked audit trail
|
|
49
|
+
export { WitnessChain, PersistentWitnessChain, createWitnessChain, createPersistentWitnessChain, createWitnessChainSQLitePersistence, isWitnessChainFeatureEnabled, SPRTAccumulator, } from './witness-chain.js';
|
|
48
50
|
//# sourceMappingURL=index.js.map
|