mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-04 17:47:28 +00:00
A port of synapse/state/v2.py over the Rust state res store. The async layer separates the conflicted state, computes the auth chain difference (handling unpersisted events and the v2.1 conflicted subgraph) and then loads every event the algorithm can read: the conflicted set, the base state, their auth events, and the power levels chains the mainline sort walks. The Python fetches those lazily inside the sorts. The core (power sort, iterative auth checks, mainline sort) does no I/O. It runs on the tokio workers and yields every 100 iterations, as the Python does, rather than on spawn_blocking, which the crate avoids because blocking tasks outlive the runtime's shutdown. Resolutions of conflicted sets are cached under the same key as the Python's _conflict_cache_key, with the same size bound. The graphs in tests/state/test_v2.py are ported as cargo tests over the in-memory store. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ULdieJyQoHNzeHq42H2M1p