Types
WitnessReport
A belief report from a single witness about a target node.WitnessRecord
Tracks a single witness node and its history.TrustScore
Represents how much we trust a witness (0.1 to 1.0).Registry
Tracks all known witnesses and their trust levels. Implements P12: Witness trust decays.Type Definition
Constructor
NewRegistry
Creates an empty witness registry.Methods
Register
Adds a new witness with default trust.id- The witness to register
- If witness already exists, does nothing
- New witnesses start with
DefaultTrust(0.8)
GetTrust
Returns the trust score for a witness.DefaultTrust if witness is unknown
Example:
RecordCorrect
Marks a witness report as correct. Trust increases slightly.- Increments
CorrectReportscounter - Increases trust by
RecoveryRate(0.05) - Trust capped at
MaxTrust(1.0)
RecordWrong
Marks a witness report as wrong. Implements P12: Trust decays for bad witnesses.- Increments
WrongReportscounter - Decreases trust by
DecayRate(0.1) - Trust floored at
MinTrust(0.1)
RecordReport
Stores the latest report from a witness.id- The witnessbelief- The latest belief reported
AllWitnesses
Returns all registered witness IDs.GetRecord
Returns the full witness record.nil if not found
Example:
Aggregator
Combines multiple witness reports into a single belief. Implements:- P10: Disagreement is preserved
- P11: Correlated witnesses weaken confidence
Type Definition
Constructor
NewAggregator
Creates an aggregator with a witness registry.AggregateResult
The result of aggregating witness reports.Belief- The weighted average beliefDisagreement- Measures variance in witness opinions:- 0.0 = All witnesses agree
- 1.0 = Maximum disagreement
WitnessCount- Number of reports usedReports- The original reports for transparency
Methods
Aggregate
Combines multiple witness reports into a single belief.reports- Witness reports to aggregate
AggregateResult with combined belief and disagreement info
Key behaviors:
- Weighted averaging: Reports are weighted by witness trust scores
- P10 - Disagreement preserved: High variance increases uncertainty
- P11 - Correlation detection: Too-similar witnesses reduce confidence
- Empty reports: Returns
UnknownBelief() - Single report: Returns that belief with zero disagreement
Implementation Details
Weighted Aggregation
Reports are combined using weighted averages based on trust:Disagreement Calculation (P10)
Disagreement is measured as variance across witnesses:- Reduces alive and dead confidences
- Increases unknown confidence