Files
zeekayandHanzo Dev 9e78250c91 refactor(zap): one router — MsgType 200 falls through to the native router
The ad-hoc ZAP gateway registry (MsgType 200) was a SECOND router: a
hand-maintained map of ~180 path prefixes to handlers, matched longest-prefix on
the PATH ALONE.

That worked only while every route encoded its verb in its name. /v1/get-store
and /v1/update-store are different prefixes, so a path was a complete request
description. A RESTful surface breaks both halves of that assumption at once:
/v1/rag/stores/:owner/:name answers GET, PATCH and DELETE at one path, which
prefix matching cannot tell apart — and /v1/rag/stores/acme/thing prefix-matches
/v1/rag/stores, so a member request would silently reach the LIST handler with
the id segments discarded. A wrong handler, not an error.

The fix is not to teach the second router about verbs and path parameters — that
is two routers to keep in agreement forever. A miss now falls through to the
FIRST one. routers.App already resolves method + path + parameters and runs every
filter (auth, tenant, balance), which is exactly what InitForwardBridge does for
MsgTypeForward and what cloud's zapface dispatcher does for its own ZAP surface.

So the 181 stale registrations are deleted rather than rewritten. They named
routes that no longer exist, and everything they used to claim is now served by
the router that already knows how.

Worth recording why this was load-bearing: the gateway sends MsgType 200 (see
gateway/zap_backend.go), and its /v1/cloud/{path} endpoint carries the CRUD
surface. Without the fallback, every one of those calls would 404 — this is not
a cleanup, it is what makes the REST surface reachable over ZAP at all.

Two obsolete test concerns went with it: the registry-size assertions (the
gateway table is now correctly EMPTY for these groups), and the plural/singular
longest-prefix disambiguation checks — that hazard is gone with the compound
names that caused it.

The registry keeps serving what it is actually good at: the hot inference paths
that skip the HTTP machinery on purpose.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-27 08:30:01 -07:00
..