Skip to content

state_accessor: bound retained history by the end of the last join - #731

Open
basnijholt wants to merge 2 commits into
matrix-construct:mainfrom
mindroom-ai:upstream-retained-departure
Open

basnijholt wants to merge 2 commits into
matrix-construct:mainfrom
mindroom-ai:upstream-retained-departure

Conversation

@basnijholt

Copy link
Copy Markdown
Contributor

What does this PR do?

Based on #729; only the second commit is new here.

A former member's history and left-room state were bounded by the leave row, which is a notification cursor, not the end of their membership. A later knock and its withdrawal write a newer leave row, so a user who had left could widen the room history and state they were served up to the withdrawal.

The leave or ban that ended the user's last join is now found by walking membership predecessors, with a bounded walk, and used for both shared history and the departure snapshot. If the departure cannot be established, the leave notification is kept without later room state or history. No separate since clamp is needed.

Found through MindRoom. Fork changes: mindroom-ai/mindroom-tuwunel#59, #81, #125 and #126.

Tests:

  • rooms::state_accessor::user_can::tests (departure lookup, missing_snapshot_keeps_the_notification) and cases in src/main/tests/sync_v5_rescinded_invite.rs. They fail on the parent commit (position 8, the notification, instead of the departure at 4).

Validation:

  • Nightly rustfmt (nightly-2026-11-03): cargo fmt --all -- --check passes.
  • cargo clippy --offline --locked on the touched crates with --all-targets --all-features -- -D warnings passes.
  • cargo test -p tuwunel_service --lib: 1,007 passed, plus three related integration tests.
  • Complement was not run.

Checklist

  • Code is formatted with nightly cargo fmt and satisfies clippy and rustc lints; any allowed lint is justified by an obvious reason or a comment.
  • Complement compliance changes (new passes or new failures), if any, are noted in the description above.
  • Config option changes were made in src/core/config/mod.rs doc comments and the regenerated tuwunel-example.toml is committed. (No config changes.)
  • User-facing changes are reflected in docs/. (No user-facing docs change.)
  • I agree that my changes may be licensed under the Apache-2.0 licence and my conduct is in line with the Contributor's Covenant and Tuwunel's Code of Conduct.

A recorded leave does not mean that the user joined the room. Keep
only the requester’s membership in left room state unless the user
once joined or the room is world-readable. Apply the check to events
copied from a zero-limit timeline as well as to the state snapshot.

Assisted-by: MindRoom DevAgent:openai/gpt-6.2-astra <https://github.com/mindroom-ai/mindroom>
The leave row is a notification cursor. Locate the leave or ban that
ended the last join by walking membership predecessors and use it for
both shared history and the departure snapshot. Bound the walk and
keep the departure notice, not later room state, on a lookup failure.

Assisted-by: MindRoom DevAgent:openai/gpt-6.2-astra <https://github.com/mindroom-ai/mindroom>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant