Files
synapse/rust
Erik JohnstonandClaude Opus 5.5 7f6b56d1f8 Calculate the chain cover index in Rust
Port `calculate_chain_cover_index_for_events` and the class methods it
calls from `PersistEventsStore` to `rust/src/persist/chain_cover.rs`,
with `_LinkMap` and `sorted_topologically`. As in Python, the step runs
in a write transaction of its own. It allocates chain IDs from the
`event_auth_chain_id` sequence and puts off events whose auth events are
missing, but does not write the index.

The reads and writes go through a `ChainCoverStore` trait, which
`WriteTxn` implements and the unit tests implement in memory. The step
takes a `ChainCoverEvent` view that reads the auth events up front but
fails only when they are used. An MSC4242 event can't give its auth
events before auth has run, and Python reads them only for events not
yet in the index.

The result matches Python's except in two orders Python leaves to
chance: which new chain gets which ID, and the order of an event's
links. The redundant-link reduction stays quadratic, as in Python.

`PersistReaderForTest` gains the step, and `ChainCoverTestCase` compares
it with Python on the same database. New chains are compared by the
lowest event ID on them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UHKYPSc37kWqGACn9aKxKL
2026-10-16 17:28:33 +00:00
..
2026-10-15 14:54:15 +00:00