feat(mcp): the books door served in-process for fuzzing (P12)

The local socket and the tunnel already mount the same four routes; naming
that table `router` gives the fuzz targets the very door a client reaches,
not a copy of it. `local/fuzz_door` (behind the `fuzzing` feature, off in
every shipped build) builds a book, two live tokens and that router, and
answers one request through `tower::oneshot`: no socket, no port, no clock.

The target's oracle is then the code that enforces it: INVARIANT 8 (a book
only behind a live bearer token) is checked by asking `Books::bearer`, not
by a second model of the rule that could drift from it.
This commit is contained in:
swaits committed 2026-11-05 08:36:15 -07:00
1 parent 4b0196e416
commit 5e474cd1ac
3 files changed
+210 -7

No files matched your search

+17 -7
View File
@@ -1730,6 +1730,22 @@ async fn mcp(
})
}
/// The one router both doors serve (the local socket and the tunnel).
fn router(books: Arc<Books>) -> axum::Router {
axum::Router::new()
.route("/b/{book}/mcp", axum::routing::any(mcp))
.route("/b/{book}/u/{upload}", axum::routing::put(upload))
.route("/b/{book}/a/{attachment}", axum::routing::get(download))
.route("/b/{book}/x/{export}", axum::routing::get(export))
.fallback(not_found)
.with_state(books)
}
/// The door in-process, for the fuzz targets (P12): the same router, fed
/// bytes without a socket. Not built unless asked for.
#[cfg(feature = "fuzzing")]
pub mod fuzz_door;
/// Anything but `/b/{book}/mcp`.
async fn not_found() -> (axum::http::StatusCode, &'static str) {
(axum::http::StatusCode::NOT_FOUND, "not found")
@@ -2080,13 +2096,7 @@ async fn serve(
}
});
let app = axum::Router::new()
.route("/b/{book}/mcp", axum::routing::any(mcp))
.route("/b/{book}/u/{upload}", axum::routing::put(upload))
.route("/b/{book}/a/{attachment}", axum::routing::get(download))
.route("/b/{book}/x/{export}", axum::routing::get(export))
.fallback(not_found)
.with_state(books.clone());
let app = router(books.clone());
// The HTTP side keeps answering (refusing, once closing) until the
// close is done: a client is never cut off mid-request by it.
let shut = CancellationToken::new();