Archived
server: the guarded-route set is declared once, at registration
The front kept its own list of which routes answer the local operator
keyless -- guarded_route spelled out the same eight (method, path)
pairs Server::register_routes registers with a local_operator handler,
and its comment admitted the copy ("Kept in step with Server::register
routes"). A new guarded route meant editing the registration AND the
front's list AND the test that pins the list against drift; miss one and
the front wakes a parked model for a stranger who is then refused -- the
exact A-05 bug class -- silently.
Router::add now takes a `guarded` flag, set on the six registrations
that guard (and their DELETE siblings). Router::guarded(method, path)
asks the matcher -- the same split_path + :label match that reaches the
handler -- and the front copies the flag as it mirrors each model route,
so guarded_route is one line reading the front's own copied marks. One
declaration per guarded route, at its registration; the matcher that
decides the wake is the matcher that dispatches, so slash and :label
forms cannot disagree with the handler and the drift risk is gone.
front_test still pins every shape (guarded: slashes, /sessions/:label,
the trailing-slash collapse; not: GET /sessions, /stats, inference,
/sessions/a/b) and transport_test exercises real dispatch through them.
Behaviour unchanged -- the same eight routes wake nothing for a stranger.
This commit is contained in:
1 parent
0f011f27e1
commit
66b0dcf019
6 files changed
+70
-45
No files matched your search
+20
-16
@@ -72,31 +72,35 @@ TEST(the_dashboards_reads_do_not_count_as_wanting_a_model) {
|
||||
/* The set that must not wake a model for a caller its handler will refuse: exactly the routes
|
||||
* Server::register_routes guards with local_operator keyless, and nothing beside them. */
|
||||
TEST(guarded_routes_are_the_local_operator_ones) {
|
||||
/* guarded_route now reads the front's own copied routes, so the decision is made by an
|
||||
* instance's matcher -- a Front with no models installed still carries the full route table
|
||||
* (its prototype does), which is exactly the set whose handlers guard. */
|
||||
Front f(TransportOptions{}, 0);
|
||||
HttpRequest q;
|
||||
q.method = "GET"; q.path = "/diagnostics"; CHECK(Front::guarded_route(q));
|
||||
q.method = "GET"; q.path = "/diagnostics"; CHECK(f.guarded_route(q));
|
||||
/* The router collapses "//x" and "x/" into "/x" (split_path, http.cpp) -- the guard sees
|
||||
* the same path the handler reaches, or a slash buys the wake the guard denies. */
|
||||
q.path = "//diagnostics"; CHECK(Front::guarded_route(q));
|
||||
q.path = "/diagnostics/"; CHECK(Front::guarded_route(q));
|
||||
q.method = "POST"; q.path = "/reset_prefix_cache"; CHECK(Front::guarded_route(q));
|
||||
q.path = "/admin/control-vector"; CHECK(Front::guarded_route(q));
|
||||
q.method = "GET"; q.path = "/admin/control-vector"; CHECK(Front::guarded_route(q));
|
||||
q.method = "DELETE"; q.path = "/sessions"; CHECK(Front::guarded_route(q));
|
||||
q.path = "//diagnostics"; CHECK(f.guarded_route(q));
|
||||
q.path = "/diagnostics/"; CHECK(f.guarded_route(q));
|
||||
q.method = "POST"; q.path = "/reset_prefix_cache"; CHECK(f.guarded_route(q));
|
||||
q.path = "/admin/control-vector"; CHECK(f.guarded_route(q));
|
||||
q.method = "GET"; q.path = "/admin/control-vector"; CHECK(f.guarded_route(q));
|
||||
q.method = "DELETE"; q.path = "/sessions"; CHECK(f.guarded_route(q));
|
||||
/* The :label form is registered and guarded next to it (server.cpp); the front must not
|
||||
* wake a model for a stranger's DELETE /sessions/whatever either. */
|
||||
q.path = "/sessions/abc"; CHECK(Front::guarded_route(q));
|
||||
q.method = "POST"; q.path = "/v1/load_lora_adapter"; CHECK(Front::guarded_route(q));
|
||||
q.path = "/v1/unload_lora_adapter"; CHECK(Front::guarded_route(q));
|
||||
q.path = "/sessions/abc"; CHECK(f.guarded_route(q));
|
||||
q.method = "POST"; q.path = "/v1/load_lora_adapter"; CHECK(f.guarded_route(q));
|
||||
q.path = "/v1/unload_lora_adapter"; CHECK(f.guarded_route(q));
|
||||
/* The rest is unguarded: the open dashboard reads stay as they are, and inference keeps
|
||||
* waking its model for whoever asks -- that is what a keyless box is for. */
|
||||
q.method = "GET"; q.path = "/sessions"; CHECK(!Front::guarded_route(q));
|
||||
q.path = "/stats"; CHECK(!Front::guarded_route(q));
|
||||
q.method = "POST"; q.path = "/v1/chat/completions"; CHECK(!Front::guarded_route(q));
|
||||
q.method = "GET"; q.path = "/v1/models"; CHECK(!Front::guarded_route(q));
|
||||
q.method = "GET"; q.path = "/sessions"; CHECK(!f.guarded_route(q));
|
||||
q.path = "/stats"; CHECK(!f.guarded_route(q));
|
||||
q.method = "POST"; q.path = "/v1/chat/completions"; CHECK(!f.guarded_route(q));
|
||||
q.method = "GET"; q.path = "/v1/models"; CHECK(!f.guarded_route(q));
|
||||
/* Shapes the :label pattern cannot match are no route at all, so they wake nothing -- but a
|
||||
* trailing slash is not such a shape: the router collapses it to the guarded bare route. */
|
||||
q.method = "DELETE"; q.path = "/sessions/"; CHECK(Front::guarded_route(q));
|
||||
q.path = "/sessions/a/b"; CHECK(!Front::guarded_route(q));
|
||||
q.method = "DELETE"; q.path = "/sessions/"; CHECK(f.guarded_route(q));
|
||||
q.path = "/sessions/a/b"; CHECK(!f.guarded_route(q));
|
||||
}
|
||||
|
||||
TEST(a_finished_job_is_answered_by_its_id_with_no_model) {
|
||||
|
||||
Reference in new issue
Block a user