Skip to content

Fix session snapshot/catalogue revision races - #36

Merged
ElSargo merged 1 commit into
mainfrom
fix/session-catalogue-revision-gate
Sep 16, 2026
Merged

ElSargo merged 1 commit into
mainfrom
fix/session-catalogue-revision-gate

Conversation

@ElSargo

@ElSargo ElSargo commented Sep 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • Track per-backend snapshot revisions in the session switcher; reject older SessionSnapshot applies (including late empty snapshots after catalogue-installed rows).
  • Add optional backward-compatible snapshot_revision on BackendCatalogueEntry; reject stale/unstamped catalogues that would regress a newer live snapshot.
  • Client: stamp catalogue entries from SessionSnapshot.revision and skip older BackendSnapshot map inserts / actor broadcasts.
  • Remit Session and backend catalogues can regress each other in docs/frictions/ui-concurrency.md.
  • Add regression tests for stale non-empty catalogue and late older empty snapshot.

Fixes #30

Residual risk

Pane/route/renderer state from a delayed BackendSnapshot event may still be applied before the session-map revision gate; only the session catalogue / actor broadcast path is revision-gated in this PR.

Test plan

  • cargo test -p brood-protocol --lib backend_catalogue
  • cd plugins/session-switcher && RUSTFLAGS='-C linker=cc' cargo test --lib — 46 passed
  • Manual: reconnect / multi-backend discovery; confirm delayed catalogue cannot replace a newer live session list

@ElSargo ElSargo left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brood QA (static) — code looks good

Verdict: COMMENT LGTM for remit of #30 (session snapshot / catalogue revision races). Not a formal APPROVE (reviewer is ElSargo).

Evidence

  • Switcher tracks backend_session_revisions and rejects snapshot.revision < last in apply_snapshot; empty unstamped snapshot without a baseline preserves live rows.
  • Catalogue path rejects stamped older revisions and unstamped catalogues when a live revision exists; empty catalogue bootstrap preserve limited to current backend with last.is_none().
  • Client stamps BackendCatalogueEntry.snapshot_revision from SessionSnapshot.revision and skips older map inserts / actor broadcasts when both revisions are non-zero.
  • Protocol field is #[serde(default)] with a wire-compat test; regression tests cover stale non-empty catalogue and late older empty snapshot.

Residuals (acknowledged in PR)

  • Pane/route/renderer apply from delayed BackendSnapshot still not revision-gated — only catalogue / actor broadcast path.

CI

FAILED — GHA Nix ENOSPC (No space left on device while extracting rust-std wasm targets). Not treated as a code blocker.

Stacking

Overlaps plugins/session-switcher/src/lib.rs + docs/frictions/ui-concurrency.md with #37 / #40 (and friction doc with #43 / #45). Prefer merge order #36 → #37 → #40 then reconcile friction remits; expect conflicts on those two files.

Desktop verify: not run (no clear smoke without full client + multi-backend reconnect).

Gate switcher apply_snapshot / apply_backend_sessions on per-backend
snapshot revisions, stamp BackendCatalogueEntry.snapshot_revision from
the client map, and reject older BackendSnapshot inserts so delayed
non-empty catalogues and late empty snapshots cannot regress live rows.

Fixes #30
@ElSargo
ElSargo force-pushed the fix/session-catalogue-revision-gate branch from 91ed730 to a9a0dcc Compare September 16, 2026 21:58
@ElSargo

ElSargo commented Sep 16, 2026

Copy link
Copy Markdown
Owner Author

Merged to main as 6232495 after rebase conflict resolution.

@ElSargo
ElSargo merged commit 6232495 into main Sep 16, 2026
1 check failed
ElSargo added a commit that referenced this pull request Sep 16, 2026
stale_catalogue_after_create needed BackendCatalogueEntry::snapshot_revision
introduced by #36.
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.

session-switcher: session snapshots and backend catalogues can regress each other

1 participant