FRAME supports peer-to-peer synchronization via receipt chain exchange.
File: ui/runtime/federation.js
Federation enables:
- Cross-instance sync — Sync receipts between instances
- Divergence detection — Detect state differences
- Merge — Merge receipt chains
- Verification — Verify peer state
File: ui/runtime/replay.js — exportAttestation(identity)
Attestation structure:
{
version: 1,
protocolVersion: "2.2.0",
receiptVersion: 2,
capabilityVersion: 2,
stateRootVersion: 3,
identityPublicKey: "hex...",
stateRoot: "hex...",
receiptChainCommitment: "hex...",
receiptCount: 100,
timestamp: 1234567890,
signature: "hex..."
}Peers exchange attestations:
- Send attestation to peer
- Receive attestation from peer
- Compare state roots — If match, instances are synchronized
If state roots differ:
- Request receipt chain from peer
- Receive receipt chain
- Verify chain — Structural and signature verification
- Replay receipts — Replay receipts in order
- Compare state roots — Must match peer's state root
File: ui/runtime/federation.js — mergeReceiptChains(localChain, remoteChain, identity)
Process:
- Find common ancestor — Last matching receipt hash
- Extract divergent receipts — Receipts after common ancestor
- Verify remote chain — Structural and signature verification
- Replay remote receipts — Replay in reconstruction mode
- Compare state roots — Must match peer's state root
- Merge chains — Append remote receipts to local chain
Divergence occurs when:
- State roots differ
- Receipt chains differ
- Receipt hashes don't match
Detection:
if (localStateRoot !== remoteStateRoot) {
// Divergence detected
// Merge receipts
}Receipt chain verification:
- Structural verification (field count, order)
- Chain link verification (previousReceiptHash)
- Signature verification (Ed25519)
- Capability validation
State root verification:
- Recompute state root after replay
- Compare with peer's state root
- Must match for sync success
Current: Simulated (no actual networking)
Future: WebRTC-based P2P transport
Modules:
FRAME_PEER_ROUTER— Peer routingFRAME_P2P— P2P transportFRAME_PEER_DISCOVERY— Peer discoveryFRAME_CAPABILITY_ADVERTISER— Capability advertisement
- Replay and Verification - Replay process
- Receipt Chain - Receipt structure
- Networking Model - Network layer