Problem
BiasId represents a DID relative to an observer/bias. In crates/core/src/dht/did.rs, BiasId::cmp converts the right operand to the left operand's bias when biases differ. Reversing the operands then uses a different reference point, so the result can violate the Ord contract.
For a ring of size (M = 2^160), for example:
a = BiasId::new(0, 1)
b = BiasId::new(M / 2, M - 1)
Comparing in a's reference frame yields a < b; comparing in b's reference frame can yield b < a. This makes mixed-bias values unsafe to sort or use in ordered collections.
Proposed direction
Do not provide a total Ord across different observers. Require a common observer at the comparison site, or expose an explicit comparator/ordered wrapper that carries that observer.
Acceptance criteria
- Mixed-bias values cannot silently be ordered under different reference frames.
- Same-bias Chord ordering remains available and is covered by tests.
- Add a regression test demonstrating the former antisymmetry failure.
- Audit ordered collection and sorting call sites and make their chosen observer explicit.
Problem
BiasIdrepresents a DID relative to an observer/bias. Incrates/core/src/dht/did.rs,BiasId::cmpconverts the right operand to the left operand's bias when biases differ. Reversing the operands then uses a different reference point, so the result can violate theOrdcontract.For a ring of size (M = 2^160), for example:
Comparing in
a's reference frame yieldsa < b; comparing inb's reference frame can yieldb < a. This makes mixed-bias values unsafe to sort or use in ordered collections.Proposed direction
Do not provide a total
Ordacross different observers. Require a common observer at the comparison site, or expose an explicit comparator/ordered wrapper that carries that observer.Acceptance criteria