refactor(bridge): encapsulate DocumentState fields behind constructor and accessors - #317
Merged
Merged
Conversation
… and accessors DocumentState previously exposed all six fields as pub with no constructor, letting any caller inside bridge::state violate the documented invariants (monotonic version, disk provenance, per-server synced tracking) by writing fields directly. Fields are now private; a constructor and internal mutators (apply_local_edit, commit_reload, set_disk, mark_synced, forget_server) enforce those invariants, and read access goes through must_use getters. Closes #304
bug-ops
enabled auto-merge (squash)
August 5, 2026 01:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DocumentState(crates/mcpls-core/src/bridge/state.rs) previously exposed all six fields aspubwith no constructor, letting any caller insidebridge::stateviolate its documented invariants (monotonicversion,diskprovenance, per-serversyncedtracking) by writing fields directly.apply_local_edit,commit_reload,set_disk,mark_synced,forget_server) enforce those invariants; read access goes through#[must_use]getters (uri(),language_id(),version(),content(),synced_version()).disk()getter — would leak the crate-internalDiskSynctype.DocumentTracker's only constructor takesResourceLimits, which is not re-exported outsidebridge::state, soDocumentState/DocumentTrackerwere already unreachable from outside the crate before this change — the CHANGELOG entry reflects that this is an internal improvement, not an externally-breaking API change.Test plan
cargo +nightly fmt --all -- --checkcargo clippy --all-targets --all-features --workspace -- -D warningscargo nextest run --workspace --all-features --lib --bins(642/642 passed)RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --workspaceCloses #304