Skip to content

refactor(bridge): split translator.rs into submodules, inject Clock seam - #326

Merged
bug-ops merged 1 commit into
mainfrom
translator-split-clock
Aug 5, 2026
Merged

refactor(bridge): split translator.rs into submodules, inject Clock seam#326
bug-ops merged 1 commit into
mainfrom
translator-split-clock

Conversation

@bug-ops

@bug-ops bug-ops commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Splits the 7148-line crates/mcpls-core/src/bridge/translator.rs (setup/lifecycle, all 20 tool handlers, DTOs, and tests) into bridge/translator/mod.rs plus 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 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.
  • Adds an injectable Clock trait (bridge::translator::clock, defaulted to SystemClock in production) so respawn-backoff bookkeeping no longer calls std::time::Instant::now() directly, making the previously-untestable backoff-expiry path deterministically testable via a #[cfg(test)]-only FakeClock. No production behavior change.

Closes #300
Closes #292

Test plan

  • cargo +nightly fmt --all -- --check
  • cargo clippy --all-targets --all-features --workspace -- -D warnings
  • cargo nextest run --workspace --all-features --lib --bins (ci profile: 645/645 passed, 0 flaky)
  • RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --workspace
  • Independently verified mechanical-motion correctness: 204/204 pre-split functions accounted for, zero dropped error handling, bridge/mod.rs byte-identical, no other crate file touched
  • New end-to-end test drives respawn_if_dead through failure -> fail-fast -> elapsed-window -> successful-reattempt using FakeClock

@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Rust code changes mcpls-core mcpls-core crate changes labels Aug 5, 2026
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
bug-ops force-pushed the translator-split-clock branch from 9c08eea to ec062d0 Compare August 5, 2026 02:44
@bug-ops
bug-ops enabled auto-merge (squash) August 5, 2026 02:44
@bug-ops
bug-ops merged commit f91cadc into main Aug 5, 2026
28 checks passed
@bug-ops
bug-ops deleted the translator-split-clock branch August 5, 2026 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation mcpls-core mcpls-core crate changes rust Rust code changes

Projects

None yet

1 participant