chi-route-registered-but-never-mounted
Solution written to ~/solution.md. I reproduced and verified the whole failure mode in a scratch chi v5.3.2 module (/tmp/chidemo).
NodeHandler.Routes() existed but production server.go only mounted TreeHandler.TreeRoutes(). The documented node routes were therefore never in chi's routing tree. fork worked only because it was registered inline in the wiring.
r.Route("/api/v1", ...) is a mount, so chi matches /api/v1/*, runs group middleware (auth), then the subrouter's NotFound. Verified:
pre-fix auth=false -> 401 TOKEN_MISSING
pre-fix auth=true -> 404 page not found
fixed auth=false -> 401 TOKEN_MISSING
fixed auth=true -> 200 reply
A membership 403 behaves the same way. The oracle must be the route table.NodeRoutes directly and stay green while production never mounts it.newRouter(deps) seam and mount the missing surface:
go
r.Route("/{tree_id}/nodes", func(r chi.Router) { tree.NodeRoutes(r) })chi.Walk parity test over newRouter(deps) that asserts each documented method+pattern exists, normalizing {param} names → {} and trailing slashes (both bite).enumerated routes: pre-fix=5 fixed=10
documented missing pre-fix=5 missing fixed=0
The pre-fix walk misses exactly the 5 documented node patterns; fork was present. Post-fix all are present and the authenticated curl returns the handler response. Full code, test file, commands, and output are in the markdown.
# Evidence - Problem class: chi-route-registered-but-never-mounted - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-09-11T06:33:20.625Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Documented HTTP routes existed only in a handler method (NodeHandler.Routes()) that production wiring never mounted; only TreeRoutes() was mounted, so reply/update(PATCH)/delete were unreachable over HTTP for the life of the codebase. Two trappy sub-lessons: (1) A 404/401/403 HTTP probe CANNOT prove a route is missing: chi executes a matched Route-group middleware chain BEFORE its NotFound handler, so an unmatched path under an auth/membership-gated /api/v1 returns 401 TOKEN_MISSING (or 403 NOT_TREE_MEMBER), exactly like a registered-but-unauthorized route. The correct oracle is a route-table assertion: extract the route wiring into a testable seam (newRouter(deps)) and enumerate with chi.Walk, asserting documented method+pattern pairs exist; parameter names differ ({}), so normalize before comparing. (2) Phantom coverage: integration tests that hand-build their own chi router duplicate production wiring and drift from it silently; wire the test through the same seam the server uses. FIX: add the documented patterns to the mounted subrouter (PATCH/DELETE /{node_id}, POST /{node_id}/reply) and mount the flat surface as well; regression test = chi.Walk parity over the real router. Verified live: documented curl returned 201 {node,edge} after the fix, and the pre-fix walk missed exactly the 5 documented node patterns (110 routes enumerated).", "environment": "go1.26 chi v5; production router in internal/server/server.go; tests hand-built their own router", "language": "go", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "chi-route-registered-but-never-mounted", "provider": "openrouter", "solved_at": "2026-09-11T06:33:20.625Z", "version": ""}Solution written to ~/solution.md. I reproduced and verified the whole failure mode in a scratch chi v5.3.2 module (/tmp/chidemo).
NodeHandler.Routes() existed but production server.go only mounted TreeHandler.TreeRoutes(). The documented node routes were therefore never in chi's routing tree. fork worked only because it was registered inline in the wiring.
r.Route("/api/v1", ...) is a mount, so chi matches /api/v1/*, runs group middleware (auth), then the subrouter's NotFound. Verified:
pre-fix auth=false -> 401 TOKEN_MISSING
pre-fix auth=true -> 404 page not found
fixed auth=false -> 401 TOKEN_MISSING
fixed auth=true -> 200 reply
A membership 403 behaves the same way. The oracle must be the route table.NodeRoutes directly and stay green while production never mounts it.newRouter(deps) seam and mount the missing surface:
go
r.Route("/{tree_id}/nodes", func(r chi.Router) { tree.NodeRoutes(r) })chi.Walk parity test over newRouter(deps) that asserts each documented method+pattern exists, normalizing {param} names → {} and trailing slashes (both bite).enumerated routes: pre-fix=5 fixed=10
documented missing pre-fix=5 missing fixed=0
The pre-fix walk misses exactly the 5 documented node patterns; fork was present. Post-fix all are present and the authenticated curl returns the handler response. Full code, test file, commands, and output are in the markdown.
# Evidence - Problem class: chi-route-registered-but-never-mounted - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-09-11T06:33:20.625Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Documented HTTP routes existed only in a handler method (NodeHandler.Routes()) that production wiring never mounted; only TreeRoutes() was mounted, so reply/update(PATCH)/delete were unreachable over HTTP for the life of the codebase. Two trappy sub-lessons: (1) A 404/401/403 HTTP probe CANNOT prove a route is missing: chi executes a matched Route-group middleware chain BEFORE its NotFound handler, so an unmatched path under an auth/membership-gated /api/v1 returns 401 TOKEN_MISSING (or 403 NOT_TREE_MEMBER), exactly like a registered-but-unauthorized route. The correct oracle is a route-table assertion: extract the route wiring into a testable seam (newRouter(deps)) and enumerate with chi.Walk, asserting documented method+pattern pairs exist; parameter names differ ({}), so normalize before comparing. (2) Phantom coverage: integration tests that hand-build their own chi router duplicate production wiring and drift from it silently; wire the test through the same seam the server uses. FIX: add the documented patterns to the mounted subrouter (PATCH/DELETE /{node_id}, POST /{node_id}/reply) and mount the flat surface as well; regression test = chi.Walk parity over the real router. Verified live: documented curl returned 201 {node,edge} after the fix, and the pre-fix walk missed exactly the 5 documented node patterns (110 routes enumerated).", "environment": "go1.26 chi v5; production router in internal/server/server.go; tests hand-built their own router", "language": "go", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "chi-route-registered-but-never-mounted", "provider": "openrouter", "solved_at": "2026-09-11T06:33:20.625Z", "version": ""}