HYDRA first principles ← home
provable trust

The router doesn't guess.
It derives.

Every routing decision Hydra makes is a named result you can check — a proven theorem it applies, or a quantity it measures. Not heuristics with a confident tone. Here are the six, each one interactive.

⊢ proven established theorem ▣ measured computed in-repo ◈ synthetic seeded benchmark ○ modeled estimate / proxy
01

Confidence routing

Wald's sequential probability ratio test

Instead of polling a fixed number of models, Hydra accumulates the log-likelihood ratio across votes and stops the instant the evidence is conclusive. Wald proved this minimizes the expected number of samples among all tests with the same error bounds.

Λn = Σi=1n ln P(xi | correct)P(xi | incorrect)    accept if ΛnA,   reject if ΛnB
A = ln 1 − βα ,    B = ln β1 − α
samples used  ·  fixed-5 would use 5
Interactive: the SPRT log-odds walk crossing the accept/reject boundaries.

A doctor ordering one test at a time and stopping the moment the diagnosis is certain — instead of always running the full panel.

⊢ proven Wald (1945), optimal E[N] ◈ synthetic −24% blended / −49% easy vs fixed-5 at ≥98% accuracy
source internal/trustreproduce hyctl trust benchmark
02

Calibration

diagnostic power · KL divergence

Each source earns a sensitivity se and specificity sp from real outcomes. Its worth is the expected evidence per vote — the KL divergence between the vote distributions under the two hypotheses, in nats. A coin-flip source scores D = 0 and adds nothing however often it votes.

D = se · ln se1 − sp + (1 − se) · ln 1 − sesp
diagnostic power 1.76 nats
Interactive: vote distributions under both hypotheses — the gap between them is the diagnostic power D.

A witness's credibility measured in nats. A coin-flip witness tells you nothing however many times they testify.

⊢ proven information theory (KL divergence) ▣ measured 90% reliability → 1.76 nats (table test)
source internal/trusthyctl trust calibration
03

When to stop

the defect-cost bar · Bayes risk

Confidence isn't free and defects aren't equal. The expected loss of shipping an answer believed correct with confidence c is (1 − cCdefect; ship only when that clears a loss tolerance τ. A costlier defect ⟹ a higher bar ⟹ SPRT samples more before it stops.

c = 1 τCdefect
required confidence 96.0%  ·  ≈ 2 samples
Interactive: the required confidence rising as the defect cost grows.

You demand far more certainty before heart surgery than before a haircut — the bar scales with what a mistake costs.

⊢ proven Bayes decision theory ○ modeled Cdefect is an estimate
source internal/trusthyctl trust defect --pii --production
04

Blast radius

Molloy–Reed percolation criterion

Treat the code as a graph with degree mean ⟨k⟩ and second moment ⟨k2⟩. A giant connected component — a cascade-capable core where one change can ripple everywhere — exists precisely when κ ≥ 2. Files inside it get their confidence bar raised.

κ = k2k 2
2.7 = κ  ·  cascade core  ·  giant 72%
Interactive: a random dependency graph where the giant component appears as κ crosses 2.

The epidemic threshold R₀ — below it a change stays local; above it, one edit can infect the whole graph.

⊢ proven Molloy–Reed (1995) ▣ measured computed from graph.json
source internal/graphhyctl graph blast <file>
05

Optimal parallelism

Amdahl's law + coordination cost

Fanning work across n agents speeds the parallel part but adds coordination cost that grows with n. With serial fraction s and per-agent coupling k, minimizing wall-clock time gives a closed-form optimum. Independent files → ~6 agents; tightly-coupled edits → ~2. More is slower.

T(n) = s + 1 − sn + kn      n = 1 − sk
optimum 6.9 agents  ·  peak speedup ×3.1
Interactive: the speedup curve versus agent count, with the optimal n★ marked.

Adding cooks to a kitchen: past n★ they spend more time coordinating than cooking.

⊢ proven Amdahl (1967) + coordination term ▣ measured k from graph coupling
source internal/optimalhyctl graph parallel <files…>
06

Context governor

signal density, not length

A context window's value is its information density, not its token count. Hydra proxies the entropy rate with a compression ratio ρ and counts only the useful tokens. Highly compressible context (repetitive, stale) has low ρ — so Hydra compacts on falling ρ, not on raw length.

ρ = |gzip(C)||C| ,    useful = L · ρ
ρ = 0.60  ·  useful 120k of 200k
Interactive: useful tokens shrinking as context redundancy rises.

Signal-to-noise: a short, sharp briefing beats a rambling transcript ten times its length.

⊢ proven Shannon source-coding ○ modeled gzip is a proxy, not a proof
source internal/entropyhyctl context entropy <file>