mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-04 11:17:51 +00:00
The second commit of phase 2. The Rust transaction now runs the steps of `_persist_events_txn` from `_update_room_depths_txn` up to `_store_rejected_events_txn`: - `txn/events.rs`: the room's depth and its place in the events stream cache, de-outliering, redactions that already apply (the event is stored pruned) and the earlier events the chunk's redactions confirm (they stop being sticky, and a passed recheck is stored), the `event_json`, `events` and `state_events` rows, transaction IDs, state groups and partial state, the chain cover index and `event_auth`, and rejections. - `txn/edges.rs`: the forward and state DAG extremities, and the backward extremities and timeline gaps of a de-outliered event. `_handle_mult_prev_events` will use the latter for new events. - `txn/json.rs`: JSON as `json_encoder` writes it, with non-ASCII and DEL escaped. The event and its internal metadata keep the key order `get_dict_for_persistence()` and `get_dict()` give, so the `event_json` text is Python's byte for byte. Only number text from federation can differ (`1.50` against Python's `1.5`). An event with partial state in a room that is no longer partial stated fails with `PartialStateConflictError`, as in Python. `Persister.persist_events_txn_for_test` takes the chunk Rust prepared, which `PreparedChunk` now shares through an `Arc`. It returns which events were stored redacted and which were de-outliered, so the twin test's Python half can carry on from there. Making a de-outliered event sticky stays in Python until the sticky commit, as it needs the sticky stream's ID generator. Python makes those sticky before deleting redacted events' sticky rows, so the sticky commit has to insert them inside `update_outliers`. New twin scenarios: transaction IDs, URLs and non-ASCII text, a redaction recheck (alone and in a chunk with its target), a partial state conflict, a redacted sticky event, and a redaction of a later redaction, which needs censoring again, and an event de-outliered while its prev event is an outlier (a backward extremity and a timeline gap). The test checks that room B's transaction takes the chunk prepared for it. The fork scenario now advances the clock between its topics, as state resolution otherwise breaks the tie by event ID, which differs between the rooms. Each ID generator's stream is ranked separately. Nineteen mutants of the new steps each fail the comparison. `PersistenceJsonTestCase` compares the `event_json` text byte for byte. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LXMkcZVkcZhi21augBff4a