π Horizon Engine
Last Updated: March 23, 2026 12:00 UTC
Multi-objective Pareto optimisation with doctrine-based design point ranking. Turns a candidate design space into an actionable ranked selection.
π― What it does
-
π Pareto frontier computation: identifies non-dominated design points across multiple objectives (maximize / minimize)
-
ποΈ Doctrine scoring: applies a configurable doctrine (balanced / defensive / aggressive / quality-first) to rank the Pareto frontier
-
π Recommendation: selects the highest-ranked design point as the recommended configuration
-
π Deterministic hashing: each run is reproducible via a SHA-256 input hash of the design space + seed
-
βοΈ Epistemic layer: Reason (Optimisation / Pareto Analysis)
-
π‘οΈ Mandate: find the best trade-off configurations in a multi-dimensional objective space, then rank them according to an explicit, auditable doctrine
-
π¦ Outputs:
HorizonEngineOutput,ParetoFrontier,DesignPoint(no I/O in LIVELLO 1)
π Charter (mandate + non-goals)
β Mandate
- Compute the strict Pareto frontier from any input design space
- Apply a named doctrine to rank all frontier points (transparent, deterministic weights)
- Emit a reproducible, frozen output that downstream services can trust and store
- Be objective agnostic: any KPI can be minimized or maximized
π« Non-goals
- no writes in LIVELLO 1 (no DB, no Qdrant, no StreamBus)
- not a simulation engine β does not generate design points, only ranks given ones
- not a constraint solver β does not handle hard constraints between objectives
- not a forecasting engine β output has no time dimension
π Interfaces
- HTTP (LIVELLO 2):
services/api_horizon_engine/exposesPOST /optimise,GET /health - Cognitive Bus (LIVELLO 2): adapters emit
horizon.pareto.computed,horizon.solution.selected,horizon.optimisation.completed - Doctrine selection: configurable via
DEFAULT_DOCTRINEenv var (balanced/defensive/aggressive/quality_first)
π‘ Event contract (Cognitive Bus)
Defined in vitruvyan_core/core/governance/horizon_engine/events/channels.py:
| Event | Direction | Meaning |
|---|---|---|
horizon.optimisation.requested | inbound | trigger a new optimisation run |
horizon.pareto.computed | outbound | frontier computed, size available |
horizon.solution.selected | outbound | recommended design point identified |
horizon.optimisation.completed | outbound | full output ready |
horizon.batch.processed | outbound | batch summary metrics |
π§© Code map
- LIVELLO 1 (pure, no I/O):
vitruvyan_core/core/governance/horizon_engine/- Consumers:
consumers/pareto_analyser.py,consumers/doctrine_scorer.py,consumers/optimisation_orchestrator.py - Domain objects:
domain/objects.py(KPIObjective,DesignSpaceDefinition,OptimisationRequest,ParetoAnalysisResult) - Governance:
governance/doctrines.py(Doctrine,BALANCED_DOCTRINE,DEFENSIVE_DOCTRINE,AGGRESSIVE_DOCTRINE,QUALITY_FIRST_DOCTRINE) - Events:
events/channels.py - Monitoring:
monitoring/metrics.py(10 metric name constants)
- Consumers:
- LIVELLO 2 (service + adapters + I/O):
services/api_horizon_engine/- HTTP routes:
api/routes.py - Bus orchestration:
adapters/bus_adapter.py - Persistence (audit log):
adapters/persistence.py
- HTTP routes:
π Pipeline (happy path)
π Optimisation run
POST /optimise
β
βΌ
HorizonBusAdapter.run_optimisation()
β
ββ 1. Build domain objects (KPIObjective, DesignSpaceDefinition, OptimisationRequest)
β
ββ 2. pareto_analyser.compute_pareto_frontier(design_points, objectives)
β β Tuple[ParetoFrontier, ParetoAnalysisResult]
β (normalize all objectives to maximize; O(nΒ²) dominance check)
β
ββ 3. doctrine_scorer.apply_doctrine(frontier, doctrine)
β β ParetoFrontier (with doctrine_score + doctrine_rank per point)
β
ββ 4. doctrine_scorer.select_recommended(frontier)
β β Optional[DesignPoint] (rank 1)
β
ββ 5. optimisation_orchestrator.run_optimisation(request)
β HorizonEngineOutput (frozen, auditable)
β
ββ emit horizon.pareto.computed
ββ emit horizon.solution.selected
ββ HTTP response β OptimisationRunResponseπ€ Consumers (LIVELLO 1)
π pareto_analyser β frontier computation
- File:
vitruvyan_core/core/governance/horizon_engine/consumers/pareto_analyser.py - Entry:
compute_pareto_frontier(design_points, objectives) β Tuple[ParetoFrontier, ParetoAnalysisResult] - Helper:
input_hash(design_points, seed) β str
Algorithm:
- Normalize all objectives:
minimizeβ flip sign (value Γ -1) - For each pair
(A, B): A dominates B if A β₯ B on all objectives and A > B on at least one - Points with no dominator β Pareto frontier
Result tags each DesignPoint with is_pareto: bool.
ποΈ doctrine_scorer β ranking the frontier
- File:
vitruvyan_core/core/governance/horizon_engine/consumers/doctrine_scorer.py - Entry:
apply_doctrine(frontier, doctrine) β ParetoFrontier - Entry:
select_recommended(frontier) β Optional[DesignPoint]
Doctrine scoring: for each Pareto point, doctrine_score = Ξ£ (kpi_value Γ doctrine_weight[kpi]). Points are ranked ascending by score (rank 1 = best).
Built-in doctrines:
| Doctrine | Description | Key weights |
|---|---|---|
balanced | equal weight on all KPIs | all = 1.0 (normalized) |
defensive | penalizes risk, rewards return | risk: -2.0, return: +1.0 |
aggressive | maximizes return, discounts risk | return: +2.0, risk: -0.5 |
quality_first | maximizes signal quality score | quality_score: +3.0 |
Custom doctrines can be registered via governance/doctrines.py.
π optimisation_orchestrator β full run
- File:
vitruvyan_core/core/governance/horizon_engine/consumers/optimisation_orchestrator.py - Entry:
run_optimisation(request: OptimisationRequest) β HorizonEngineOutput - Helper:
build_run_id(prefix="he") β str
Produces HorizonEngineOutput (from contracts.schemas):
run_id,doctrine,pareto_frontier,recommended,total_design_points,input_hash,produced_at,diagnostics
βοΈ Governance: Doctrines
Frozen dataclass Doctrine (file: governance/doctrines.py):
| Preset | Key weights | Use case |
|---|---|---|
BALANCED_DOCTRINE | equal | neutral exploration |
DEFENSIVE_DOCTRINE | risk=-2.0, return=+1.0 | risk-averse selection |
AGGRESSIVE_DOCTRINE | return=+2.0, risk=-0.5 | growth-first selection |
QUALITY_FIRST_DOCTRINE | quality_score=+3.0 | data-quality gating |
Activate via env var: DEFAULT_DOCTRINE=balanced|defensive|aggressive|quality_first.
π Integration with other engines
| Engine | Integration |
|---|---|
| Veritas Engine | Veritas regime classification can automatically select the Horizon doctrine (crisis β defensive, normal β balanced) |
| Neural Engine | NE scores can be used as KPI values fed into Horizon's design space (return = NE_composite_score) |
| Vault Keepers | Horizon output (selected design point) can be archived via Vault for audit and replay |
π§ͺ Tests
- Unit tests:
vitruvyan_core/core/governance/horizon_engine/tests/test_horizon_livello1.py(10 tests, incl. Pareto correctness) - Run:
pytest vitruvyan_core/core/governance/horizon_engine/tests/ -v - All tests are pure Python β no Docker / Redis / Postgres required
π¦ vit package
- Package descriptor:
service-horizon-engine.vit(root ofvitruvyan-core) - Install:
vit install service-horizon-engine