From 32acdc1c44889f9d479188b0e84fdeaefec721c5 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Sat, 21 Nov 2026 12:16:15 -0700 Subject: [PATCH] fix(mcp): the remote door's limits, disk cost, names and front line after review (P15 B1) Per-address limits count an IPv4 address or an IPv6 /64 (mapped addresses as the IPv4 one) and the table evicts per-address entries only, never a connection's own call limit; waiting requests give way to a new one (an address's oldest, or the fullest address's) instead of filling the window; a stale client document is used when the fetch budget is spent and nothing is fetched from /token. Registrations nobody allowed live in memory only, a redirect is at most 512 bytes and a client's together 4 KiB. An error of a sign-in for a client nobody approved is a page, never a redirect. Names lose invisible and direction-changing characters and are cut to forty; a revoked key frees its place; calls refused for rate or another company's books are counted, not written, the limit asked first. The client document fetch refuses ::/96 and 2002::/16, uses no proxy; the host is read from the request's authority under HTTP/2; remote.json is private on Windows too; every connection must begin with a per-start secret before the PROXY header, given to the app over the admin socket. Co-Authored-By: Claude Fable 5.2 --- crates/ledger-gui/src/connect.rs | 7 +- crates/ledger-gui/tests/assistants.rs | 40 +- crates/ledger-mcp/src/admin.rs | 6 + crates/ledger-mcp/src/local/remote/cimd.rs | 6 +- crates/ledger-mcp/src/local/remote/http.rs | 56 +- crates/ledger-mcp/src/local/remote/mod.rs | 101 ++-- crates/ledger-mcp/src/local/remote/proxy.rs | 87 +++- crates/ledger-mcp/src/local/remote/tests.rs | 548 ++++++++++++++++++-- 8 files changed, 734 insertions(+), 117 deletions(-) diff --git a/crates/ledger-gui/src/connect.rs b/crates/ledger-gui/src/connect.rs index 119e1237..00adcbdd 100644 --- a/crates/ledger-gui/src/connect.rs +++ b/crates/ledger-gui/src/connect.rs @@ -647,7 +647,10 @@ impl State { let what = if approve { format!("Allow the assistant sent back to {}", request.redirect_host) } else { - format!("Don't allow the assistant sent back to {}", request.redirect_host) + format!( + "Don't allow the assistant sent back to {}", + request.redirect_host + ) }; Some(( what, @@ -891,7 +894,7 @@ pub const MOST_CARDS: usize = 3; fn newest_waiting(all: &[crate::owner::WebRequest]) -> (Vec<&crate::owner::WebRequest>, usize) { let mut sorted: Vec<&crate::owner::WebRequest> = all.iter().collect(); // Most time left is the newest. - sorted.sort_by(|a, b| b.expires_in_secs.cmp(&a.expires_in_secs)); + sorted.sort_by_key(|r| std::cmp::Reverse(r.expires_in_secs)); let more = sorted.len().saturating_sub(MOST_CARDS); sorted.truncate(MOST_CARDS); (sorted, more) diff --git a/crates/ledger-gui/tests/assistants.rs b/crates/ledger-gui/tests/assistants.rs index 4e08b722..7bc1903a 100644 --- a/crates/ledger-gui/tests/assistants.rs +++ b/crates/ledger-gui/tests/assistants.rs @@ -1107,11 +1107,7 @@ fn with_pending(owner: &Fake, pending: Vec, approvals: Vec