Skip to main content
The Consensus Engine orchestrates multiple verification engines for high-confidence results with fault tolerance.
Changed in v4.0.4: Python code verification within consensus now runs exclusively through the secure Docker executor (SecureCodeExecutor). If the Docker sandbox is unavailable, consensus returns a blocked_secure_execution status and the API responds with HTTP 503.

Features

  • Async parallel execution — Run engines concurrently
  • Circuit breaker — Auto-disable failing engines
  • Engine health monitoring — Track reliability
  • Weighted consensus — Consider engine reliability
  • Secure code execution — Python engine runs through the Docker sandbox only

Usage

Verification modes

The high and maximum modes include the Python engine, which requires the secure Docker sandbox. If Docker is unavailable, these modes return blocked_secure_execution instead of falling back to in-process execution.
The Python engine in high and maximum modes requires Docker. If the secure Docker sandbox is unavailable, consensus verification returns HTTP 503 instead of falling back to in-process code execution.

Async execution

Circuit breaker

When an engine fails repeatedly, it’s automatically disabled:

Async failure handling

When an unexpected error occurs during async engine aggregation, the Consensus Engine records the failure as a dedicated EngineResult entry rather than silently dropping it. This ensures that:
  • The failure is visible in the results array returned to the caller
  • Aggregate confidence scores account for the failed engine
  • The error is logged via logger.exception for post-mortem debugging
The recorded result uses engine_name: "consensus_orchestrator", method: "async_aggregation", success: false, and includes the error message in the error field.

Engine selection

The consensus engine automatically selects which engines to run based on the verification mode:
The fact engine is excluded from automatic engine selection. Fact verification requires external context, and including it in consensus without that context would create self-referential verification loops. If fact verification is invoked during consensus, it returns an error indicating that external context is required.

Consensus calculation

The engine uses weighted voting: Final confidence = weighted average of agreeing engines.

Agreement statuses