You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tech-debt(ci): the duplicate-route guard is AST-based and blind to include_router — a better one exists, abandoned #17325
The duplicate-route guard landing in #17314 reads @router.<verb> decorators out of the AST. It therefore cannot see any route mounted with router.include_router(other), and 16 non-test modules under autobot-backend/api/ compose that way — agent_terminal.py:218, auth.py:302, and 14 others.
So its "1518 distinct (method, path) pairs, 1 duplicate" is a floor, not a total. A duplicate between two included sub-routers is invisible to it.
A better guard already exists, and was abandoned
Commit f4e2d6badb on the local branch issue-16908-duplicate-routes rebuilt exactly this guard on real router objects:
calls load_core_routers() / load_optional_routers() — the same functions app_factory calls, so the population is the real one
walks effective_routes(), which resolves nested include_router() including an inner router's own prefix
carries a population-collapse assertion, so a broken import cannot make the guard pass by finding nothing
That file was removed from the branch by a later commit ("split guard out of #16918 per review") and never landed anywhere. It is 228 lines and complete.
This is the repository's own prior work being redone worse. The AST version exists only because I did not find the abandoned branch before writing it — rule 1, check before writing.
Why it was not simply adopted
It cannot be verified on this machine. Importing real routers pulls llc.scheduler.base, which raises:
RuntimeError: llc.scheduler.base requires asyncio.Task.cancelling() (Python 3.11+);
the platform floor is 3.14, and CI runs 3.14, but this interpreter is Python 3.10.
CI runs 3.14 and would execute it fine. Shipping a 228-line guard that I could not run once is not better than shipping a lesser one that I could — so the AST version ships with its blind spot pinned (COMPOSING_MODULES_PIN = 16, asserted, so the gap cannot quietly grow) and this issue carries the upgrade.
Acceptance criteria
The guard enumerates routes from real router objects, resolving nested include_router() with its prefix
It is verified by an actual run, not by reading — on an interpreter at the platform floor, or in CI
A population-collapse assertion fails the guard when the registry yields implausibly few registrations, so a broken import cannot pass as "no duplicates"
The AST version and its COMPOSING_MODULES_PIN are removed in the same change, not left beside it — two guards for one property is what this repository calls a fork
f4e2d6badb's content is the starting point, credited, rather than a third independent implementation
The starting point is now durable: preserved/issue-16908-real-router-guard on origin.
f4e2d6badb previously existed only as a local branch on one machine. An issue that names a commit as its starting point should not depend on one developer's reflog, so the branch is pushed under a preserved/ prefix — it is a reference, not work in flight, and the name says so.
The guard file is at repo_tests/duplicate_route_registration_16908_test.py in that commit (228 lines). Note it is not at the branch tip — a later commit on the same branch (3a43f296a2, "split guard out of #16918 per review") removed it. Read it at the commit:
git show f4e2d6badb:repo_tests/duplicate_route_registration_16908_test.py
Why it could not be adopted directly, restated so nobody repeats the attempt and draws the wrong conclusion: it imports real routers, which pulls llc.scheduler.base, which refuses on anything below Python 3.11. This machine is 3.10 and CI is 3.14, so it will run in CI and cannot be run here. That is a limitation of the verification environment, not a defect in the guard.
Also worth recording for whoever takes this: the blind spot is currently 16 non-test modules under autobot-backend/api/ composing via router.include_router(...), pinned and asserted in repo_tests/no_duplicate_route_registration_16908_test.py as COMPOSING_MODULES_PIN. That pin exists so the gap cannot grow unobserved while this issue is open — and it should be deleted along with the AST guard when the real-router version lands, not left beside it.
Sighting (external API report via #18717, verified on origin/main 0196c7c234): the guard also can't see the same module registered twice, because it keys on module:var and a repeat collapses to one set entry. Confirmed double mounts: admin_retention_policies (core_routers.py:154 + feature_routers.py:703), chat_embed (core:166 + feature:680), voice_bundle_user (core:445 + feature:717); via composition: voice_bundle_admin, chat_sessions (chat.py:338-340 + feature:674), knowledge_boards (knowledge.py:225-227 + core:373), knowledge_search_aggregator (knowledge.py:3091-3093 + core:391). Second copies are unreachable, with identical handlers (OpenAPI noise, not behaviour). The fix and the guard belong here.
Further sightings, verified on origin/main @ 5be354b (2026-10-20). They are recorded here because this issue owns the double-mount / duplicate-route class.
llc agent_hires is included twice into the same parent:autobot-backend/llc/api/__init__.py:64 and :90. This duplicates GET /api/llc/agent-hires, POST /api/llc/agent-hires and POST /api/llc/companies/{company_id}/agent-hires. It is not in the earlier sighting list.
The existing guard is blind to these, in two ways.
repo_tests/no_duplicate_route_registration_16908_test.py::collisions() (:106-119) collects module:var per (method, path) in a set. A router mounted twice under the same name collapses to one entry, so it misses chat_embed, admin_retention_policies, voice_bundle_user and agent_hires.
It cannot see include_router at all; this is pinned at :211.
The class fix is a runtime check: build both apps, walk app.router.routes and flag a repeated (method, path). The routing walk autobot_shared/api_routing/route_order.py already exists, which makes this cheap.
Merge train #19048 (merge f323772) landed the #19032 part of this. AC status from origin/main:
AC1 is not met as written. repo_tests/no_duplicate_route_registration_16908_test.py now enumerates through autobot_shared/api_routing/route_order.py, which follows nested include_router with its prefix, but it reads source with ast (module docstring: "read from source alone"). It does not read real router objects.
AC2 depends on AC1.
AC3 population collapse: test_the_reader_reached_both_apps (:103-107) asserts the parsed-file reach BACKEND_PARSED_FLOOR = 290 / SLM_PARSED_FLOOR = 42 (:51-52, measured at 364 / 53), with the route-count floors kept as a second check.
AC4 is partly met. COMPOSING_MODULES_PIN is gone from main (git grep finds no hits), but the guard is still AST-based, so the "AST version removed" half depends on AC1.
AC5 is unverified. I did not check whether f4e2d6badb was used or credited.
Decision needed: is an AST resolver that follows nested include_router acceptable in place of real router objects (importing the backend pulls in the whole service stack)? If yes, AC1, AC2 and AC4 can be re-worded and ticked. If not, a runtime-objects guard is still owed.
Owner decision (2026-10-24): the guard is built on real router objects. Revive the f4e2d6badb guard: it uses the loaders app_factory calls, walks effective_routes(), and asserts the route population. A source-reading resolver is not an acceptable substitute.
The guard runs on the local 3.14 suite venv as well as in CI. The double-mount fixes edit core_routers.py and feature_routers.py, which #19425, #19382 and #19396 also touch, so those fixes land after those PRs. The guard and its findings are built now.
AC evidence, verified against origin/main @ b07673947b (train 85e, #19585) (landed via #19457):
Real router objects with nested include_router prefixes: repo_tests/_dump_real_routes.py and autobot_shared/api_routing/router_routes.py:79_hop_prefix (used at :148). Tests :215 and :224 in no_duplicate_route_registration_16908_test.py.
Verified by an actual run, in CI: all 12 python-suite shards succeeded on train 85e's run 40217777038, and repo_tests/ is in the suite's path list.
AC evidence, checked against main f88cd37. Run evidence is labelled; the rest is read from code.
AC
Evidence
The guard enumerates routes from real router objects, resolving nested include_router() with its prefix
MET. repo_tests/_dump_real_routes.py:59-63 imports load_core_routers and load_optional_routers and builds entries = [*load_core_routers(), *load_optional_routers()], then walks effective_routes(...) (:38-43; SLM app via main.app.router, :70-81). autobot_shared/api_routing/router_routes.py:152effective_routes resolves nested prefixes. Guard: repo_tests/no_duplicate_route_registration_16908_test.py, including nested-prefix tests (/api/p/inner/inner/own/leaf).
It is verified by an actual run, not by reading — on an interpreter at the platform floor, or in CI
MET (CI-run evidence). The guard landed through the merge train whose run 40217777038 concluded success with all 12 python-suite shards and the aggregate success (checked with gh run view); the train's title lists "route guard". I did not confirm which shard ran this file.
A population-collapse assertion fails the guard when the registry yields implausibly few registrations, so a broken import cannot pass as "no duplicates"
MET. no_duplicate_route_registration_16908_test.py:43-44 records floors (backend 276 registry entries / 2567 routes; SLM 56 / 428), reach_shortfall (:140-152) flags registrations <= floor and routes <= floor, and test_a_dump_below_the_floors_is_a_finding (:156) proves it fires.
The AST version and its COMPOSING_MODULES_PIN are removed in the same change, not left beside it — two guards for one property is what this repository calls a fork
MET. git grep COMPOSING_MODULES_PIN origin/main returns no hits; the guard file's imports are collections, functools, json, subprocess, sys and others, with no ast; its docstring says it replaces the AST guard.
f4e2d6badb's content is the starting point, credited, rather than a third independent implementation
MET. Credited in the guard docstring (no_duplicate_route_registration_16908_test.py:11) and repo_tests/_dump_real_routes.py:19 ("Design from commit f4e2d6b (#16908)"). Whether code was copied from that commit is not checkable here; the credit is explicit.
Activity
test(api): pin the duplicate-route guard's blind spot instead of hidi…
mrveiss commentedon Sep 23, 2026
The starting point is now durable:
preserved/issue-16908-real-router-guardon origin.f4e2d6badbpreviously existed only as a local branch on one machine. An issue that names a commit as its starting point should not depend on one developer's reflog, so the branch is pushed under apreserved/prefix — it is a reference, not work in flight, and the name says so.The guard file is at
repo_tests/duplicate_route_registration_16908_test.pyin that commit (228 lines). Note it is not at the branch tip — a later commit on the same branch (3a43f296a2, "split guard out of #16918 per review") removed it. Read it at the commit:Why it could not be adopted directly, restated so nobody repeats the attempt and draws the wrong conclusion: it imports real routers, which pulls
llc.scheduler.base, which refuses on anything below Python 3.11. This machine is 3.10 and CI is 3.14, so it will run in CI and cannot be run here. That is a limitation of the verification environment, not a defect in the guard.Also worth recording for whoever takes this: the blind spot is currently 16 non-test modules under
autobot-backend/api/composing viarouter.include_router(...), pinned and asserted inrepo_tests/no_duplicate_route_registration_16908_test.pyasCOMPOSING_MODULES_PIN. That pin exists so the gap cannot grow unobserved while this issue is open — and it should be deleted along with the AST guard when the real-router version lands, not left beside it.chore(tech-debt): collapse five hand-copied patterns onto one definit…
test(guards): prove the duplicate-route guard by mutation, both direc…
mrveiss commentedon Oct 17, 2026
Sighting (external API report via #18717, verified on origin/main
0196c7c234): the guard also can't see the same module registered twice, because it keys onmodule:varand a repeat collapses to one set entry. Confirmed double mounts:admin_retention_policies(core_routers.py:154 + feature_routers.py:703),chat_embed(core:166 + feature:680),voice_bundle_user(core:445 + feature:717); via composition:voice_bundle_admin,chat_sessions(chat.py:338-340 + feature:674),knowledge_boards(knowledge.py:225-227 + core:373),knowledge_search_aggregator(knowledge.py:3091-3093 + core:391). Second copies are unreachable, with identical handlers (OpenAPI noise, not behaviour). The fix and the guard belong here.mrveiss commentedon Oct 20, 2026
Further sightings, verified on
origin/main@ 5be354b (2026-10-20). They are recorded here because this issue owns the double-mount / duplicate-route class.agent_hiresis included twice into the same parent:autobot-backend/llc/api/__init__.py:64and:90. This duplicatesGET /api/llc/agent-hires,POST /api/llc/agent-hiresandPOST /api/llc/companies/{company_id}/agent-hires. It is not in the earlier sighting list.repo_tests/no_duplicate_route_registration_16908_test.py::collisions()(:106-119) collectsmodule:varper (method, path) in a set. A router mounted twice under the same name collapses to one entry, so it misseschat_embed,admin_retention_policies,voice_bundle_userandagent_hires.include_routerat all; this is pinned at :211.The class fix is a runtime check: build both apps, walk
app.router.routesand flag a repeated (method, path). The routing walkautobot_shared/api_routing/route_order.pyalready exists, which makes this cheap.route_order.py:37_VERBShas noapi_route, so@router.api_routeroutes are invisible toshadowed_literal_routes_18720_test.py. Example still live: SLMapi/personality_proxy.py:79/{path:path}(all 5 methods) is declared before:106/.{path:path}matches the empty string, sopersonality_proxy_rootnever runs. Today this is harmless, since the auth check is the same and the catch-all proxiespath="".fix(api): read websocket routes in the route-order walk so a duplicat…
fix(train): train-53 — the route resolver follows a router included b…
fix(train): train-53 review — api_route without methods is GET, an al…
mrveiss commentedon Oct 21, 2026
Merge train #19048 (merge f323772) landed the #19032 part of this. AC status from
origin/main:repo_tests/no_duplicate_route_registration_16908_test.pynow enumerates throughautobot_shared/api_routing/route_order.py, which follows nestedinclude_routerwith its prefix, but it reads source withast(module docstring: "read from source alone"). It does not read real router objects.test_the_reader_reached_both_apps(:103-107) asserts the parsed-file reachBACKEND_PARSED_FLOOR = 290/SLM_PARSED_FLOOR = 42(:51-52, measured at 364 / 53), with the route-count floors kept as a second check.COMPOSING_MODULES_PINis gone from main (git grepfinds no hits), but the guard is still AST-based, so the "AST version removed" half depends on AC1.f4e2d6badbwas used or credited.Decision needed: is an AST resolver that follows nested
include_routeracceptable in place of real router objects (importing the backend pulls in the whole service stack)? If yes, AC1, AC2 and AC4 can be re-worded and ticked. If not, a runtime-objects guard is still owed.mrveiss commentedon Oct 24, 2026
Owner decision (2026-10-24): the guard is built on real router objects. Revive the
f4e2d6badbguard: it uses the loadersapp_factorycalls, walkseffective_routes(), and asserts the route population. A source-reading resolver is not an acceptable substitute.The guard runs on the local 3.14 suite venv as well as in CI. The double-mount fixes edit
core_routers.pyandfeature_routers.py, which #19425, #19382 and #19396 also touch, so those fixes land after those PRs. The guard and its findings are built now.feat(ci): the SLM half reads real routers too; the two #18721 duplica…
perf(ci): the two route dumps run concurrently (#17325)
fix(ci): the route dump takes the repo root from its caller, never re…
fix(ci): realtime call keys the bundle user like the listing; guard s…
github-actions commentedon Oct 25, 2026
Landed in train train-2026-10-25-85e3 (#19585, merge
b07673947b) via #19457mrveiss commentedon Oct 25, 2026
AC evidence, verified against
origin/main@b07673947b(train 85e, #19585) (landed via #19457):include_routerprefixes:repo_tests/_dump_real_routes.pyandautobot_shared/api_routing/router_routes.py:79_hop_prefix(used at :148). Tests :215 and :224 inno_duplicate_route_registration_16908_test.py.repo_tests/is in the suite's path list.FLOORS(:45),test_a_dump_below_the_floors_is_a_finding(:156).COMPOSING_MODULES_PINremoved:git grep COMPOSING_MODULES_PIN origin/mainreturns 0 hits, and there is noimport astin the guard.f4e2d6badbcredited:_dump_real_routes.py:19and the guard docstring :11.mrveiss commentedon Nov 1, 2026
AC evidence, checked against main f88cd37. Run evidence is labelled; the rest is read from code.
include_router()with its prefixrepo_tests/_dump_real_routes.py:59-63importsload_core_routersandload_optional_routersand buildsentries = [*load_core_routers(), *load_optional_routers()], then walkseffective_routes(...)(:38-43; SLM app viamain.app.router,:70-81).autobot_shared/api_routing/router_routes.py:152effective_routesresolves nested prefixes. Guard:repo_tests/no_duplicate_route_registration_16908_test.py, including nested-prefix tests (/api/p/inner/inner/own/leaf).successwith all 12python-suiteshards and the aggregatesuccess(checked withgh run view); the train's title lists "route guard". I did not confirm which shard ran this file.no_duplicate_route_registration_16908_test.py:43-44records floors (backend 276 registry entries / 2567 routes; SLM 56 / 428),reach_shortfall(:140-152) flagsregistrations <= floorandroutes <= floor, andtest_a_dump_below_the_floors_is_a_finding(:156) proves it fires.COMPOSING_MODULES_PINare removed in the same change, not left beside it — two guards for one property is what this repository calls a forkgit grep COMPOSING_MODULES_PIN origin/mainreturns no hits; the guard file's imports arecollections, functools, json, subprocess, sysand others, with noast; its docstring says it replaces the AST guard.f4e2d6badb's content is the starting point, credited, rather than a third independent implementationno_duplicate_route_registration_16908_test.py:11) andrepo_tests/_dump_real_routes.py:19("Design from commit f4e2d6b (#16908)"). Whether code was copied from that commit is not checkable here; the credit is explicit.