Architecture Overview
Styx is built on a multi-layered architecture that combines evidence gathering, witness aggregation, partition detection, and finality enforcement.Core Components
Oracle
The Oracle is the main API interface. It never returns a boolean, always a belief distribution:The Oracle can refuse to answer when there’s insufficient evidence or a network partition is detected. This is a feature, not a bug.
Evidence System
Evidence is the foundation of Styx’s belief system. Each piece of evidence has:- Kind: DirectResponse, Timeout, WitnessReport, CausalEvent, etc.
- Weight: How much this evidence matters (0.0 to 1.0)
- Timestamp: When the evidence was observed
- Details: Kind-specific metadata
source/evidence/evidence.go
Witness System
Witnesses report their observations about other nodes. Each witness has a trust score that:- Starts at 0.8 (DefaultTrust)
- Increases by 0.05 for correct reports (RecoveryRate)
- Decreases by 0.1 for incorrect reports (DecayRate)
- Never drops below 0.1 (MinTrust)
Partition Detection
Styx actively detects network partitions by analyzing witness disagreement. When witnesses split into groups with conflicting views (some see ALIVE, some see DEAD), Styx refuses to answer rather than guess. See Partition Detection for more details.Finality Engine
Once a node is declared dead (with overwhelming evidence from multiple witnesses), that decision is irreversible. The node must use a new identity (incremented generation) to rejoin. See Death Finality for more details.Key Principles
Styx is built on several core principles:Property 4: No Evidence = No Conclusion
Property 4: No Evidence = No Conclusion
If there’s no evidence about a node, Styx returns
UnknownBelief() with 100% unknown. It never guesses.Property 6: Load ≠ Failure
Property 6: Load ≠ Failure
GC pauses and scheduling jitter do NOT indicate failure. Styx actively detects and compensates for these.
Property 10: Disagreement is Preserved
Property 10: Disagreement is Preserved
When witnesses disagree, Styx tracks and reports the disagreement level rather than hiding it.
Property 11: Correlated Witnesses Weaken Confidence
Property 11: Correlated Witnesses Weaken Confidence
Property 12: Witness Trust Decays
Property 12: Witness Trust Decays
Witnesses that provide incorrect reports gradually lose trust, reducing their influence on future decisions.
Property 13: False Death is Forbidden
Property 13: False Death is Forbidden
Declaring a live node dead is catastrophic. Requires 85%+ dead confidence, 3+ witnesses, and non-timeout evidence.
Property 14: Death is Final
Property 14: Death is Final
Once declared dead, a node cannot be resurrected. It must rejoin with a new identity (incremented generation).
Property 15: Silence ≠ Death
Property 15: Silence ≠ Death
Timeouts and silence alone can NEVER trigger death. Non-timeout evidence (crash signals, OS reports) is required.
Belief Distribution Example
Here’s how Styx represents beliefs:Query Flow
- Check Finality: Is the node already declared dead?
- Gather Reports: Collect all witness reports for the target
- Detect Partition: Are witnesses split into conflicting groups?
- Aggregate Beliefs: Combine witness reports (trust-weighted average)
- Check Confidence: Does the result meet the required confidence thresholds?
- Return or Refuse: Return belief distribution, or refuse if uncertain
source/oracle/oracle.go
Next Steps
Beliefs
Learn about probability distributions and confidence values
Witnesses
Understand the witness reporting and trust system
Finality
Explore death finality and irreversible decisions
Partition Detection
See how Styx detects and handles network partitions