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
|
@@ -20,6 +20,8 @@ import { createLogger } from '../logging/logger-factory.js';
|
|
|
20
20
|
import { createAgentBoosterAdapter, } from '../integrations/agentic-flow/agent-booster';
|
|
21
21
|
// ADR-051: Task Router for outcome recording
|
|
22
22
|
import { getTaskRouter } from '../mcp/services/task-router';
|
|
23
|
+
// ADR-083 Task 3.2: Coherence-gated agent actions
|
|
24
|
+
import { evaluateTaskAction, createCoherenceActionGate, } from './coherence-action-gate';
|
|
23
25
|
// CQ-005: Use DomainServiceRegistry instead of dynamic imports from domains/
|
|
24
26
|
import { DomainServiceRegistry, ServiceKeys } from '../shared/domain-service-registry';
|
|
25
27
|
// Handler registration functions (extracted from the monolithic registerHandlers)
|
|
@@ -124,6 +126,8 @@ export class DomainTaskExecutor {
|
|
|
124
126
|
taskRouter = null;
|
|
125
127
|
// ADR-023: Quality Feedback Loop for routing outcome recording
|
|
126
128
|
qualityFeedbackLoop = null;
|
|
129
|
+
// ADR-083 Task 3.2: Coherence action gate (lazy-initialized)
|
|
130
|
+
coherenceActionGate = null;
|
|
127
131
|
// Instance-level task handler registry
|
|
128
132
|
taskHandlers = new Map();
|
|
129
133
|
constructor(kernel, eventBus, config) {
|
|
@@ -335,6 +339,14 @@ export class DomainTaskExecutor {
|
|
|
335
339
|
console.debug(`[TaskExecutor] Executing task ${task.id}: type=${task.type}, ` +
|
|
336
340
|
`tier=${routingTier}, model=${modelId}, useAgentBooster=${useAgentBooster}` +
|
|
337
341
|
`${compiledContext ? ', hasContext=true' : ''}`);
|
|
342
|
+
// ADR-083 Task 3.2: Coherence-gated action evaluation (advisory by default)
|
|
343
|
+
const gateEvaluation = this.evaluateCoherenceGate(task, domain);
|
|
344
|
+
if (gateEvaluation) {
|
|
345
|
+
console.debug(`[TaskExecutor] Coherence gate: task=${task.id}, decision=${gateEvaluation.decision}, ` +
|
|
346
|
+
`combined=${gateEvaluation.combinedScore.toFixed(3)}, advisory=${gateEvaluation.advisory}`);
|
|
347
|
+
}
|
|
348
|
+
// Task 4.5: Multi-path reasoning validation (advisory, never blocks)
|
|
349
|
+
this.validateWithReasoningQEC(task, domain);
|
|
338
350
|
try {
|
|
339
351
|
// ADR-051: Tier 0 - Try Agent Booster for mechanical transforms
|
|
340
352
|
if (routingTier === 0 || useAgentBooster) {
|
|
@@ -440,6 +452,8 @@ export class DomainTaskExecutor {
|
|
|
440
452
|
this.testGenerator = null;
|
|
441
453
|
this.knowledgeGraph = null;
|
|
442
454
|
this.qualityAnalyzer = null;
|
|
455
|
+
// ADR-083: Reset coherence action gate
|
|
456
|
+
this.coherenceActionGate = null;
|
|
443
457
|
// ADR-051: Also reset Agent Booster and Task Router
|
|
444
458
|
if (this.agentBooster) {
|
|
445
459
|
try {
|
|
@@ -464,6 +478,91 @@ export class DomainTaskExecutor {
|
|
|
464
478
|
this.qualityAnalyzer = null;
|
|
465
479
|
this.agentBooster = null;
|
|
466
480
|
this.taskRouter = null;
|
|
481
|
+
this.coherenceActionGate = null;
|
|
482
|
+
}
|
|
483
|
+
// ==========================================================================
|
|
484
|
+
// ADR-083 Task 3.2: Coherence Gate Integration
|
|
485
|
+
// ==========================================================================
|
|
486
|
+
/**
|
|
487
|
+
* Evaluate task action through the coherence gate.
|
|
488
|
+
* Returns null when the feature flag is off, otherwise returns the evaluation.
|
|
489
|
+
* Advisory mode by default: logs decision but never blocks execution.
|
|
490
|
+
*/
|
|
491
|
+
evaluateCoherenceGate(task, domain) {
|
|
492
|
+
try {
|
|
493
|
+
if (!this.coherenceActionGate) {
|
|
494
|
+
this.coherenceActionGate = createCoherenceActionGate({ advisory: true });
|
|
495
|
+
}
|
|
496
|
+
const payload = task.payload;
|
|
497
|
+
const confidence = typeof payload?.confidence === 'number'
|
|
498
|
+
? payload.confidence
|
|
499
|
+
: 0.7;
|
|
500
|
+
const riskLevel = payload?.riskLevel
|
|
501
|
+
?? 'medium';
|
|
502
|
+
return evaluateTaskAction(task.type, domain, confidence, riskLevel, payload ?? {}, this.coherenceActionGate);
|
|
503
|
+
}
|
|
504
|
+
catch (error) {
|
|
505
|
+
// Coherence gate must never block task execution
|
|
506
|
+
logger.warn('Coherence gate evaluation error (continuing)', {
|
|
507
|
+
error: error instanceof Error ? error.message : String(error),
|
|
508
|
+
taskId: task.id,
|
|
509
|
+
});
|
|
510
|
+
return null;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Validate task reasoning through multi-path consensus (ReasoningQEC).
|
|
515
|
+
* Only runs when useReasoningQEC flag is on and task has reasoning steps.
|
|
516
|
+
* Advisory mode: logs validation result but never blocks execution.
|
|
517
|
+
*/
|
|
518
|
+
/** Lazily cached ReasoningQEC instance */
|
|
519
|
+
_reasoningQEC = null;
|
|
520
|
+
_reasoningQECLoaded = false;
|
|
521
|
+
validateWithReasoningQEC(task, domain) {
|
|
522
|
+
try {
|
|
523
|
+
// Lazy-load once and cache (avoids require() on every task)
|
|
524
|
+
if (!this._reasoningQECLoaded) {
|
|
525
|
+
this._reasoningQECLoaded = true;
|
|
526
|
+
try {
|
|
527
|
+
const { isReasoningQECEnabled } = require('../integrations/ruvector/feature-flags.js');
|
|
528
|
+
if (isReasoningQECEnabled()) {
|
|
529
|
+
const { createReasoningQEC } = require('./reasoning-qec.js');
|
|
530
|
+
this._reasoningQEC = createReasoningQEC();
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
catch (loadErr) {
|
|
534
|
+
logger.debug('ReasoningQEC module unavailable', {
|
|
535
|
+
error: loadErr instanceof Error ? loadErr.message : String(loadErr),
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
if (!this._reasoningQEC)
|
|
540
|
+
return;
|
|
541
|
+
const payload = task.payload;
|
|
542
|
+
const steps = payload?.reasoningSteps;
|
|
543
|
+
if (!steps || steps.length < 2)
|
|
544
|
+
return;
|
|
545
|
+
const result = this._reasoningQEC.validate({
|
|
546
|
+
type: domain,
|
|
547
|
+
context: payload,
|
|
548
|
+
steps,
|
|
549
|
+
});
|
|
550
|
+
if (!result.valid) {
|
|
551
|
+
logger.warn('ReasoningQEC validation found issues (advisory)', {
|
|
552
|
+
taskId: task.id,
|
|
553
|
+
domain,
|
|
554
|
+
confidence: result.confidence,
|
|
555
|
+
issues: result.issues.length,
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
catch (error) {
|
|
560
|
+
// QEC must never block task execution
|
|
561
|
+
logger.debug('ReasoningQEC evaluation error', {
|
|
562
|
+
error: error instanceof Error ? error.message : String(error),
|
|
563
|
+
taskId: task.id,
|
|
564
|
+
});
|
|
565
|
+
}
|
|
467
566
|
}
|
|
468
567
|
getTaskDomain(taskType) {
|
|
469
568
|
const domainMap = {
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { Result, DomainName } from '../shared/types/index.js';
|
|
11
11
|
import { EventBus, MemoryBackend, AgentCoordinator } from '../kernel/interfaces.js';
|
|
12
|
+
import type { BehaviorNode } from './behavior-tree/nodes.js';
|
|
12
13
|
export type { StepExecutionMode, StepStatus, WorkflowStatus, ConditionOperator, StepCondition, WorkflowStepDefinition, WorkflowDefinition, WorkflowTrigger, StepExecutionResult, WorkflowContext, WorkflowExecutionStatus, WorkflowListItem, WorkflowStartedPayload, WorkflowCompletedPayload, WorkflowFailedPayload, StepEventPayload, IWorkflowOrchestrator, DomainAction, DomainActionRegistry, WorkflowOrchestratorConfig, } from './workflow-types.js';
|
|
13
14
|
export { WorkflowEvents, DEFAULT_WORKFLOW_CONFIG, } from './workflow-types.js';
|
|
14
15
|
import type { WorkflowDefinition, WorkflowExecutionStatus, WorkflowListItem, IWorkflowOrchestrator, DomainAction, WorkflowOrchestratorConfig } from './workflow-types.js';
|
|
@@ -42,6 +43,17 @@ export declare class WorkflowOrchestrator implements IWorkflowOrchestrator {
|
|
|
42
43
|
stopWorkflowAgent(agentId: string): Promise<Result<void, Error>>;
|
|
43
44
|
getAvailableAgentCapacity(): number;
|
|
44
45
|
registerAction(domain: DomainName, action: string, handler: DomainAction): void;
|
|
46
|
+
/**
|
|
47
|
+
* Execute a workflow from a behavior tree instead of a WorkflowDefinition.
|
|
48
|
+
*
|
|
49
|
+
* This provides an alternative execution strategy that uses composable
|
|
50
|
+
* behavior tree nodes for orchestration. The existing workflow execution
|
|
51
|
+
* path remains unchanged.
|
|
52
|
+
*
|
|
53
|
+
* @param tree - Root node of the behavior tree to execute
|
|
54
|
+
* @returns ExecutionResult with status and timing information
|
|
55
|
+
*/
|
|
56
|
+
executeFromBehaviorTree(tree: BehaviorNode): Promise<BehaviorTreeExecutionResult>;
|
|
45
57
|
private runWorkflow;
|
|
46
58
|
private executeSteps;
|
|
47
59
|
private executeStep;
|
|
@@ -72,4 +84,21 @@ export declare class WorkflowOrchestrator implements IWorkflowOrchestrator {
|
|
|
72
84
|
private delay;
|
|
73
85
|
}
|
|
74
86
|
export declare function createWorkflowOrchestrator(eventBus: EventBus, memory: MemoryBackend, agentCoordinator: AgentCoordinator, config?: Partial<WorkflowOrchestratorConfig>): IWorkflowOrchestrator;
|
|
87
|
+
/** Result of executing a behavior tree through the orchestrator */
|
|
88
|
+
export interface BehaviorTreeExecutionResult {
|
|
89
|
+
/** Overall execution status */
|
|
90
|
+
status: 'completed' | 'running' | 'failed';
|
|
91
|
+
/** When execution started */
|
|
92
|
+
startedAt: Date;
|
|
93
|
+
/** When execution completed */
|
|
94
|
+
completedAt: Date;
|
|
95
|
+
/** Duration in milliseconds */
|
|
96
|
+
duration: number;
|
|
97
|
+
/** Raw behavior tree node status */
|
|
98
|
+
treeStatus: 'SUCCESS' | 'FAILURE' | 'RUNNING';
|
|
99
|
+
/** Name of the root tree node */
|
|
100
|
+
treeName: string;
|
|
101
|
+
/** Error message if failed */
|
|
102
|
+
error?: string;
|
|
103
|
+
}
|
|
75
104
|
//# sourceMappingURL=workflow-orchestrator.d.ts.map
|
|
@@ -210,6 +210,48 @@ export class WorkflowOrchestrator {
|
|
|
210
210
|
this.actionRegistry[domain][action] = handler;
|
|
211
211
|
}
|
|
212
212
|
// ============================================================================
|
|
213
|
+
// Behavior Tree Execution
|
|
214
|
+
// ============================================================================
|
|
215
|
+
/**
|
|
216
|
+
* Execute a workflow from a behavior tree instead of a WorkflowDefinition.
|
|
217
|
+
*
|
|
218
|
+
* This provides an alternative execution strategy that uses composable
|
|
219
|
+
* behavior tree nodes for orchestration. The existing workflow execution
|
|
220
|
+
* path remains unchanged.
|
|
221
|
+
*
|
|
222
|
+
* @param tree - Root node of the behavior tree to execute
|
|
223
|
+
* @returns ExecutionResult with status and timing information
|
|
224
|
+
*/
|
|
225
|
+
async executeFromBehaviorTree(tree) {
|
|
226
|
+
const startedAt = new Date();
|
|
227
|
+
try {
|
|
228
|
+
const status = await tree.tick();
|
|
229
|
+
const completedAt = new Date();
|
|
230
|
+
const duration = completedAt.getTime() - startedAt.getTime();
|
|
231
|
+
return {
|
|
232
|
+
status: status === 'SUCCESS' ? 'completed' : status === 'RUNNING' ? 'running' : 'failed',
|
|
233
|
+
startedAt,
|
|
234
|
+
completedAt,
|
|
235
|
+
duration,
|
|
236
|
+
treeStatus: status,
|
|
237
|
+
treeName: tree.name,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
const completedAt = new Date();
|
|
242
|
+
const duration = completedAt.getTime() - startedAt.getTime();
|
|
243
|
+
return {
|
|
244
|
+
status: 'failed',
|
|
245
|
+
startedAt,
|
|
246
|
+
completedAt,
|
|
247
|
+
duration,
|
|
248
|
+
treeStatus: 'FAILURE',
|
|
249
|
+
treeName: tree.name,
|
|
250
|
+
error: toErrorMessage(error),
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
// ============================================================================
|
|
213
255
|
// Private Methods - Workflow Execution
|
|
214
256
|
// ============================================================================
|
|
215
257
|
async runWorkflow(workflow, execution) {
|
|
@@ -0,0 +1,135 @@
|
|
|
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
|
+
/** Result of comparing two image embeddings */
|
|
16
|
+
export interface ComparisonResult {
|
|
17
|
+
readonly similarity: number;
|
|
18
|
+
readonly isMatch: boolean;
|
|
19
|
+
readonly threshold: number;
|
|
20
|
+
readonly regionSimilarities?: ReadonlyArray<{
|
|
21
|
+
readonly regionIndex: number;
|
|
22
|
+
readonly similarity: number;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
/** A labeled pair of images for contrastive threshold learning */
|
|
26
|
+
export interface LabeledPair {
|
|
27
|
+
readonly embedA: Float32Array;
|
|
28
|
+
readonly embedB: Float32Array;
|
|
29
|
+
readonly isMatch: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** Region of interest definition for selective comparison */
|
|
32
|
+
export interface RegionOfInterest {
|
|
33
|
+
readonly x: number;
|
|
34
|
+
readonly y: number;
|
|
35
|
+
readonly width: number;
|
|
36
|
+
readonly height: number;
|
|
37
|
+
}
|
|
38
|
+
/** Options for embedding computation */
|
|
39
|
+
export interface EmbeddingOptions {
|
|
40
|
+
readonly gridSize?: number;
|
|
41
|
+
readonly channels?: number;
|
|
42
|
+
readonly maskRegions?: ReadonlyArray<RegionOfInterest>;
|
|
43
|
+
readonly useEdgeDetection?: boolean;
|
|
44
|
+
}
|
|
45
|
+
/** Configuration for the CNN visual regression engine */
|
|
46
|
+
export interface CNNVisualRegressionConfig {
|
|
47
|
+
readonly defaultThreshold?: number;
|
|
48
|
+
readonly defaultGridSize?: number;
|
|
49
|
+
readonly tryNativeBackend?: boolean;
|
|
50
|
+
readonly useEdgeDetection?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Compute cosine similarity between two vectors of equal length.
|
|
54
|
+
* Returns 0 if either vector has zero norm.
|
|
55
|
+
*/
|
|
56
|
+
export declare function cosineSimilarity(a: Float32Array, b: Float32Array): number;
|
|
57
|
+
/**
|
|
58
|
+
* CNN-based visual regression testing using embedding comparison.
|
|
59
|
+
*
|
|
60
|
+
* Images are projected into a compact embedding space via spatial average
|
|
61
|
+
* pooling. Cosine similarity determines whether two images represent the
|
|
62
|
+
* same visual state.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const cnn = new CNNVisualRegression();
|
|
67
|
+
* const baseline = cnn.computeEmbedding(baselinePixels, 1024, 768);
|
|
68
|
+
* const current = cnn.computeEmbedding(currentPixels, 1024, 768);
|
|
69
|
+
* if (cnn.isRegression(baseline, current)) {
|
|
70
|
+
* console.log('Visual regression detected!');
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare class CNNVisualRegression {
|
|
75
|
+
private readonly defaultThreshold;
|
|
76
|
+
private readonly defaultGridSize;
|
|
77
|
+
private readonly tryNative;
|
|
78
|
+
private readonly useEdgeDetection;
|
|
79
|
+
private nativeBackend;
|
|
80
|
+
private nativeLoadAttempted;
|
|
81
|
+
constructor(config?: CNNVisualRegressionConfig);
|
|
82
|
+
/**
|
|
83
|
+
* Check for native CNN backend.
|
|
84
|
+
* No native package exists — always returns false.
|
|
85
|
+
* The TypeScript spatial pooling implementation is used.
|
|
86
|
+
*/
|
|
87
|
+
private tryLoadNativeBackend;
|
|
88
|
+
/**
|
|
89
|
+
* Compute a feature embedding for an image using spatial average pooling.
|
|
90
|
+
* When edge detection is enabled (via config or options), the embedding
|
|
91
|
+
* concatenates spatial pooling of the original pixels with spatial pooling
|
|
92
|
+
* of the Sobel edge map, then L2-normalizes the result.
|
|
93
|
+
*
|
|
94
|
+
* @param imageData Raw pixel data in RGBA format (4 bytes per pixel)
|
|
95
|
+
* @param width Image width in pixels
|
|
96
|
+
* @param height Image height in pixels
|
|
97
|
+
* @param options Configuration for grid size, masking, and edge detection
|
|
98
|
+
* @returns L2-normalized embedding vector
|
|
99
|
+
*/
|
|
100
|
+
computeEmbedding(imageData: Uint8Array, width: number, height: number, options?: EmbeddingOptions): Float32Array;
|
|
101
|
+
/** Compute embedding asynchronously, attempting native backend first. */
|
|
102
|
+
computeEmbeddingAsync(imageData: Uint8Array, width: number, height: number, options?: EmbeddingOptions): Promise<Float32Array>;
|
|
103
|
+
/** Compare two embeddings and produce a detailed comparison result. */
|
|
104
|
+
compare(baseline: Float32Array, current: Float32Array, threshold?: number): ComparisonResult;
|
|
105
|
+
/**
|
|
106
|
+
* Compare embeddings with per-region analysis. Computes per-region
|
|
107
|
+
* similarity alongside the global similarity.
|
|
108
|
+
*/
|
|
109
|
+
compareWithRegions(baseline: Float32Array, current: Float32Array, regions: ReadonlyArray<RegionOfInterest>, imageWidth: number, imageHeight: number, threshold?: number): ComparisonResult;
|
|
110
|
+
/** Check if a visual regression has occurred (similarity below threshold). */
|
|
111
|
+
isRegression(baseline: Float32Array, current: Float32Array, threshold?: number): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Learn an optimal threshold from labeled positive/negative pairs.
|
|
114
|
+
* Sweeps candidate thresholds and picks the one maximizing accuracy.
|
|
115
|
+
* @throws Error if no examples or all examples share the same label
|
|
116
|
+
*/
|
|
117
|
+
learnThreshold(examples: LabeledPair[]): number;
|
|
118
|
+
private computeRegionSimilarity;
|
|
119
|
+
/** Spatial average pooling: divides image into grid, averages RGB per cell, L2-normalizes. */
|
|
120
|
+
private computeSpatialPoolingEmbedding;
|
|
121
|
+
/** Zero out pixel data in masked regions. Returns a copy. */
|
|
122
|
+
private applyMask;
|
|
123
|
+
/**
|
|
124
|
+
* Apply Sobel edge detection to an RGBA image.
|
|
125
|
+
* Converts to grayscale, applies 3x3 Sobel kernels for horizontal and
|
|
126
|
+
* vertical gradients, computes the magnitude, and returns the result
|
|
127
|
+
* as RGBA (edge magnitude in R,G,B channels, alpha=255).
|
|
128
|
+
*/
|
|
129
|
+
applySobelEdgeDetection(pixels: Uint8Array, width: number, height: number): Uint8Array;
|
|
130
|
+
private validateImageInput;
|
|
131
|
+
getDefaultThreshold(): number;
|
|
132
|
+
getEmbeddingDimension(gridSize?: number): number;
|
|
133
|
+
isNativeBackendLoaded(): boolean;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=cnn-visual-regression.d.ts.map
|