Skip to content

fix(mcp,core): resolve critical TODOs — MCP Await Discipline violation + stale comments#3537

Merged
bug-ops merged 1 commit intomainfrom
todo-critical
Apr 28, 2026
Merged

fix(mcp,core): resolve critical TODOs — MCP Await Discipline violation + stale comments#3537
bug-ops merged 1 commit intomainfrom
todo-critical

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Apr 28, 2026

Summary

  • Fix commit_added_server Await Discipline §4 violation (zeph-mcp): the previous code held the clients write guard across two .await points (server_trust.write().await, server_tools.write().await), creating a potential deadlock if another task held server_trust write while waiting for clients. Fixed by releasing the clients guard before all subsequent awaits; TOCTOU protection preserved.
  • Remove 3 stale TODO(critic) comments in zeph-core test aggregator files where the super::super::*crate:: migration was already complete.
  • Add deferred migration marker in tool_execution/native.rs for ~30 remaining super::super::* occurrences (separate follow-up, not part of original TODOs).

New issues filed

Test plan

  • cargo +nightly fmt --check — clean
  • cargo clippy --workspace -- -D warnings — 0 warnings
  • cargo nextest run -p zeph-mcp --lib — 429/429 passed
  • cargo nextest run -p zeph-core --lib — 1302/1302 passed
  • New test commit_added_server_rejects_duplicate covers sequential duplicate rejection and winner-state preservation

Closes #3534 (partial — the Await Discipline TODO is now resolved)

…n, stale test import comments

- Rewrite `commit_added_server` in zeph-mcp to satisfy Await Discipline §4:
  acquire and release `clients` write guard with no `.await` while held, then
  write `server_trust` and `server_tools` independently. Previous code held
  `clients` guard across two async awaits creating a deadlock hazard.
- Add `commit_added_server_rejects_duplicate` test covering sequential duplicate
  rejection and winner-state preservation for trust level and tools.
- Add `McpClient::new_disconnected_for_test` (#[cfg(test)] pub(crate)) stub.
- Document the narrow concurrent add/remove race window introduced by the fix
  with a TODO referencing #3536 for tracking.
- Remove three stale `TODO(critic): #3497 follow-up` comments from test
  aggregator mod.rs files where the path migration was already complete.
- Add deferred migration marker in tool_execution/native.rs for the ~30
  remaining `super::super::*` occurrences (follow-up to #3497).
@bug-ops bug-ops enabled auto-merge (squash) April 28, 2026 00:34
@github-actions github-actions Bot added rust Rust code changes core zeph-core crate bug Something isn't working size/M Medium PR (51-200 lines) labels Apr 28, 2026
@bug-ops bug-ops merged commit 1393af2 into main Apr 28, 2026
32 checks passed
@bug-ops bug-ops deleted the todo-critical branch April 28, 2026 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core zeph-core crate rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant