"""
helix_cdc.routing - QUBO-Based Unified Route Selector
=====================================================

This package provides a QUBO-based routing system that unifies:
1. Classical compute (SIMD/GPU/CPU) - executes deterministically
2. Compressed-domain compute (CDNA/HXZ) - representation in encoded space
3. Optimization compute (QUBO/QPU) - combinatorial planner for routing

Key Insight: "Compressed compute is the substrate. QUBO/QPU is the substrate's
planner. Classical is the substrate's executor."

Components:
- build_route_qubo(): Construct QUBO for route selection
- solve_route_qubo(): Solve using classical/quantum backends
- generate_route_receipt(): Create tamper-evident receipts
- validate_route_receipt(): Verify receipt integrity

Usage:
    from helix_cdc.routing import build_route_qubo, solve_route_qubo

    Q, meta = build_route_qubo(request, k_specialists=5, fidelity_band="hybrid_cdna")
    result = solve_route_qubo(Q, backend="neal", seed=42)
    print(f"Selected: {result['selected_backend']}, specialists: {result['selected_specialists']}")
"""

from .qubo_route_builder import (
    build_route_qubo,
    RouteQUBOConfig,
)

from .route_solver import (
    solve_route_qubo,
    decode_solution,
)

from .route_receipt import (
    generate_route_receipt,
    validate_route_receipt,
    finalize_route_receipt,
)

from .cost_extractors import (
    extract_specialist_costs,
    extract_backend_costs,
    extract_telemetry_costs,
)

from .qubo_adapters import (
    QUBOProblem,
    routing_qubo_to_operator_format,
    operator_format_to_routing_qubo,
    canonical_to_routing_qubo,
    routing_qubo_to_canonical,
    routing_qubo_to_bqm,
    bqm_to_routing_qubo,
    load_qubo_file,
    save_qubo_file,
    validate_qubo,
    evaluate_qubo_energy,
)

from .plan_contract import (
    SubstratePlan,
    PlanBuilder,
    solution_to_plan,
    plan_diff,
    SUBSTRATE_OPS,
    REGEN_STRATEGIES,
)

__all__ = [
    # Builder
    "build_route_qubo",
    "RouteQUBOConfig",
    # Solver
    "solve_route_qubo",
    "decode_solution",
    # Receipt
    "generate_route_receipt",
    "validate_route_receipt",
    "finalize_route_receipt",
    # Cost extractors
    "extract_specialist_costs",
    "extract_backend_costs",
    "extract_telemetry_costs",
    # QUBO Adapters
    "QUBOProblem",
    "routing_qubo_to_operator_format",
    "operator_format_to_routing_qubo",
    "canonical_to_routing_qubo",
    "routing_qubo_to_canonical",
    "routing_qubo_to_bqm",
    "bqm_to_routing_qubo",
    "load_qubo_file",
    "save_qubo_file",
    "validate_qubo",
    "evaluate_qubo_energy",
    # Plan Contract
    "SubstratePlan",
    "PlanBuilder",
    "solution_to_plan",
    "plan_diff",
    "SUBSTRATE_OPS",
    "REGEN_STRATEGIES",
]
