Repository navigation
refactor(server): registry drives dispatch and the read-only gate (#1344) - #1437
Merged
Merged
Conversation
) The api_registry table is now consulted by the router (unregistered method+path is a 404 before any handler runs) and by the read-only-token gate (derived from a new per-row writes flag). The source-scanning coverage test is replaced by tests built from the table. Refs #1344 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This was referenced Oct 12, 2026
This was referenced Oct 13, 2026
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.
What
Makes
crates/uteke-server/src/api_registry.rs(ENDPOINTS) the table the router and the read-only gate actually read, and deletes the test that greppedhandlers.rssource text.writes: bool(#[serde(skip)], soGET /routes,docs/api-reference.mdanddocs/core-contract.jsonare unchanged).handlers::routeis nowapi_registry::read_only_allows(method, path), derived fromwrites. The hard-coded 16-pathread_only_post_pathsarray is gone.Not foundbefore any handler runs. A handler can no longer be reachable while unregistered or ungated.registry_covers_handler_routes(source-text scan) is deleted, along with the six "build the URL separately so the route scanner does not trip" workarounds in handler tests.(method, path)pairs absent from the table 404 without reaching a handler; the read-only token gets the gate 403 on exactly the non-GET rows that are not non-writing POST rows; GET rows never write; rows are unique; a reviewed pin of the 16 read-only POST rows so that flipping awritesflag is a deliberate, visible edit.Behaviour is preserved bit-for-bit, including two quirks of the old gate: it matched the raw path (query string included) and ignored the request verb for the read-only POST paths (so
PUT /liststill passes the gate and then 404s).Refs #1344 (not
Closes, see "Remaining").Why
api_registry.rswas a second hand-maintained route list kept in sync by a source-grepping test, and the read-only gate was a third list. Now one table drives/routes, docgen, reachability and the gate, so a new write route is read-only-gated by construction: it needs a row to be reachable at all, andwrites: trueis what the gate reads.Testing
cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace,cargo test -p uteke-core --no-default-features --features "onnx,vecq" --lib: all pass.cargo run -p docgen:docs/unchanged (no diff indocs/api-reference.mdordocs/core-contract.json).uteke-servebuilt fromorigin/developand from this branch, freshUTEKE_HOMEeach,--auth-token T1 --read-only-token T2, python fake OpenAI embedder (768-dim). For every one of the 78 rows ofGET /routes: minimal request ({}body and no body for non-GET) with no token / read-only token / full token, plus every other method on the same path in the three modes, plus extras (query-string gate quirk,/recallfoo,/api/v1|v2prefixes, PATCH, unknown paths). 1146 cases, 0 differences in status and normalised body (ids/timestamps masked).GET /routesis byte-identical (20197 bytes) between the two servers.Gate vs
writesflag: owner decisionswriteswas set to match today's gating exactly (to keep behaviour), so nothing disagrees in effect. But these POST rows are blocked for the read-only token although their handler does not obviously mutate, i.e.writes = trueis conservative for them. Left as is; an owner decision whether any should become read-only:POST /verify(the handler comment calls it a read-only check, deliberately a write-token endpoint)POST /context(builds a context string)POST /dream(dry_run: truedoes not mutate; otherwise it does)POST /extract,POST /mcp(the bridge can reach both reads and writes)No GET row writes (enforced by a test).
Remaining for a follow-up (why this is not
Closes)The table does not yet hold a typed handler: the dispatch is still the ~80-arm
match (method, path)inhandlers::route, andrequest_typeis still a string. Converting each arm into a function with a row-owned handler pointer touches ~2800 lines of inline handlers and was not a safe single slice. After this PR there is no second source of truth for reachability,/routes, docgen or the gate, only the arm bodies remain to be moved behind the table (theevery_registry_row_has_a_handler_armtest covers the interim sync).🤖 Generated with Claude Code