# VEX Consensus Engine ## Module VexLens ## Status IMPLEMENTED ## Description A multi-mode VEX consensus engine is implemented with trust-weighted scoring, conflict resolution, and persistence via dual-write consensus projection stores. ## Implementation Details - **Consensus engine**: `src/VexLens/StellaOps.VexLens/Consensus/VexConsensusEngine.cs`, `IVexConsensusEngine.cs` -- multi-mode consensus with trust-weighted scoring and conflict resolution - **Core consensus**: `src/VexLens/StellaOps.VexLens/StellaOps.VexLens.Core/Consensus/VexConsensusEngine.cs`, `IVexConsensusEngine.cs` - **Dual-write store**: `src/VexLens/StellaOps.VexLens/Storage/DualWriteConsensusProjectionStore.cs` -- writes consensus projections to both in-memory and persistent stores - **In-memory store**: `src/VexLens/StellaOps.VexLens/Storage/InMemoryConsensusProjectionStore.cs` - **Postgres store proxy**: `src/VexLens/StellaOps.VexLens/Storage/PostgresConsensusProjectionStoreProxy.cs` - **Postgres persistence**: `src/VexLens/StellaOps.VexLens.Persistence/Postgres/PostgresConsensusProjectionStore.cs` - **Persistence repository**: `src/VexLens/StellaOps.VexLens.Persistence/Repositories/ConsensusProjectionRepository.cs`, `IConsensusProjectionRepository.cs` - **Consensus API models**: `src/VexLens/StellaOps.VexLens/Api/ConsensusApiModels.cs` -- API request/response models - **Orchestration**: `src/VexLens/StellaOps.VexLens/Orchestration/ConsensusJobTypes.cs`, `IConsensusJobService.cs`, `OrchestratorLedgerEventEmitter.cs` - **Signal emitter**: `src/VexLens/StellaOps.VexLens/Integration/VexSignalEmitter.cs` -- emits VEX signals to downstream systems - **Policy integration**: `src/VexLens/StellaOps.VexLens/Integration/PolicyEngineIntegration.cs`, `IPolicyEngineIntegration.cs` -- feeds consensus into policy engine - **Noise gate**: `src/VexLens/StellaOps.VexLens/NoiseGate/NoiseGateService.cs`, `INoiseGate.cs`, `NoiseGateOptions.cs` -- suppresses low-signal VEX noise - **Metrics**: `src/VexLens/StellaOps.VexLens/Observability/VexLensMetrics.cs` -- consensus engine metrics - **WebService API**: `src/VexLens/StellaOps.VexLens.WebService/Program.cs`, `Extensions/VexLensEndpointExtensions.cs`, `ExportEndpointExtensions.cs` - **Tests**: `src/VexLens/StellaOps.VexLens/__Tests/StellaOps.VexLens.Tests/Storage/DualWriteConsensusProjectionStoreTests.cs`, `PostgresConsensusProjectionStoreProxyTests.cs`, `NoiseGate/NoiseGateServiceTests.cs` - **Source**: Feature matrix scan ## E2E Test Plan - [ ] Verify consensus engine produces trust-weighted verdicts from multiple VEX sources - [ ] Test dual-write store persists to both in-memory and PostgreSQL - [ ] Verify conflict resolution handles contradictory VEX statements - [ ] Test noise gate suppresses low-confidence VEX signals - [ ] Verify policy engine integration receives consensus results - [ ] Test consensus API endpoints return valid projections