refactor(bridge): split translator.rs into submodules, inject Clock seam - #326
Merged
Conversation
Split the 7148-line crates/mcpls-core/src/bridge/translator.rs (setup/
lifecycle, all 20 tool handlers, DTOs, and their tests) into bridge/
translator/mod.rs (Translator struct + lifecycle) plus twelve sibling
modules grouped by domain: clock, respawn, routing, dto, encoding_ctx,
navigation, diagnostics, edits, symbols, assist, call_hierarchy, and a
shared testing fixture module. Matches the per-file test convention
already used by bridge::state/bridge::notifications/bridge::encoding.
Pure code motion: bridge/mod.rs's pub use translator::{...} re-export
block and every Translator method signature are unchanged.
Respawn-backoff bookkeeping (record_respawn_failure/success,
reconcile_respawn_stability, respawn_backoff_remaining) previously
called std::time::Instant::now() directly, so the backoff-expiry path
could not be exercised deterministically in tests. Introduce a
bridge::translator::clock::Clock trait, defaulted to SystemClock in
production and backed by a #[cfg(test)]-only FakeClock, threaded
through a new private Translator field. Add an end-to-end test driving
respawn_if_dead through a full failure -> fail-fast -> elapsed-window
-> successful-reattempt sequence, plus a unit test for
reconcile_respawn_stability's proven-stable branch. No production
behavior change; the two call sites that used Instant::elapsed/
duration_since directly now use saturating_duration_since for
explicitness at the injection seam.
Closes #300
Closes #292
bug-ops
force-pushed
the
translator-split-clock
branch
from
August 5, 2026 02:44
9c08eea to
ec062d0
Compare
bug-ops
enabled auto-merge (squash)
August 5, 2026 02:44
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
crates/mcpls-core/src/bridge/translator.rs(setup/lifecycle, all 20 tool handlers, DTOs, and tests) intobridge/translator/mod.rsplus twelve domain-grouped sibling modules (clock,respawn,routing,dto,encoding_ctx,navigation,diagnostics,edits,symbols,assist,call_hierarchy,testing), matching the per-file convention already used bybridge::state/bridge::notifications/bridge::encoding. Pure code motion —bridge/mod.rs'spub use translator::{...}re-export block and everyTranslatormethod signature are unchanged.Clocktrait (bridge::translator::clock, defaulted toSystemClockin production) so respawn-backoff bookkeeping no longer callsstd::time::Instant::now()directly, making the previously-untestable backoff-expiry path deterministically testable via a#[cfg(test)]-onlyFakeClock. No production behavior change.Closes #300
Closes #292
Test plan
cargo +nightly fmt --all -- --checkcargo clippy --all-targets --all-features --workspace -- -D warningscargo nextest run --workspace --all-features --lib --bins(ciprofile: 645/645 passed, 0 flaky)RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --workspacebridge/mod.rsbyte-identical, no other crate file touchedrespawn_if_deadthrough failure -> fail-fast -> elapsed-window -> successful-reattempt usingFakeClock