Repository navigation
fix(check-repo): honor named path= in declared routes - #307
Merged
Merged
Conversation
Route discovery ignored path= decorators because it only inspected the first positional argument. Read the path keyword only when no positional argument exists, retaining the literal-string requirement. Extend the existing adversarial contract test across GET/POST and both argument forms. Exact route sets continue to exclude comments and mapping access. No public API, dependency or file outside the two-file scope changes. Regression command (before and after the fix): uv run --offline --no-sync pytest tests/test_repo_contract.py::test_public_api_must_be_an_actual_route_not_a_comment_or_mapping_access -q Before: exit 1, 2 failed (named GET/POST), 2 passed (positional). After: exit 0, 4 passed. Offline validation, without installation: uv run --offline --no-sync ruff format --check src tests scripts Exit 0: 152 files already formatted (after formatting the changed file). uv run --offline --no-sync ruff check src tests scripts Exit 0: All checks passed! uv run --offline --no-sync mypy Exit 0: Success: no issues found in 83 source files. uv run --offline --no-sync pytest tests/test_repo_contract.py -q Exit 0: 26 passed. uv run --offline --no-sync pytest -m 'not live' Exit 1: 9 failed, 1069 passed; python-multipart unavailable in this context. uv run --offline --no-sync python scripts/check_repo.py --final Exit 0: Repository contracts passed (final Python-only gate). uv run --offline --no-sync python scripts/check_deploy.py --check-examples Exit 0: deployment contracts validated; no services started. uv build --offline --no-build-isolation --out-dir /tmp/cortex-named-path.6YdwjA/dist Exit 2: ModuleNotFoundError: No module named 'hatchling'. Full-suite/build validation remains blocked by unavailable dependencies. Generic hygiene audit exits 2 because it requires a .git directory and does not support this linked worktree; native repository gate passes. git diff --check: exit 0, empty output. Static independent review: no finding. Delivery is a draft only; no merge or deployment requested. Refs: named path= route-discovery regression
Merge origin/main at 0874160 without rewriting published history. Keep both the proportional trust-root test and named-path route cases. Preserve PROPORTIONAL_SHARES and owner version >=2 activation checks. Keyword-only paths require a bare router or router_* receiver name. Positional paths retain legacy acceptance of any receiver. Document this syntactic convention and the boundary for future APIRouter resolution. Adversarial GET/POST receiver checks: before guard 8 failed, 8 passed (exit 1); after guard 16 passed (exit 0). Offline checks all exit 0: ruff format/check, mypy, 41 repository tests, 1127 non-live tests, check_repo --final and check_deploy --check-examples.
This comment has been minimized.
This comment has been minimized.
Greptile P1: the named-path receiver check accepted any object called router/router_*, so an API module could drop its FastAPI endpoints and still satisfy check_public_contracts with unrelated methods. declared_routes now collects names assigned from APIRouter(...) in the module and only credits path= decorators whose receiver is one of them. Positional-path decorators keep their previous behavior. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Mathis (echobt)
marked this pull request as ready for review
September 21, 2026 18:34
Contributor
Author
|
Greptile (@greptileai) review |
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.
Problem and behavior
declared_routesn'inspectait que le premier argument positionnel litteral :@router.get(path="/v1/status")produisaitset()et etait ignore.Le correctif lit
pathuniquement sans argument positionnel, toujours avecl'exigence d'une chaine litterale. Exactement deux fichiers modifies.
Le test adversarial couvre GET/POST, positionnel/nomme, avec exclusion des
commentaires et acces dictionnaire : avant 2 echecs / 2 reussites, exit 1 ;
apres 4 reussites, exit 0.
Validation
Commandes executees avec
UV_OFFLINE=true, sans telechargement :uv run --no-sync ruff format --check src tests scriptsuv run --no-sync ruff check src tests scriptsuv run --no-sync mypyuv run --no-sync pytest -m 'not live'uv run --no-sync python scripts/check_repo.py --finaluv run --no-sync python scripts/check_deploy.py --check-examplesLe hook pre-push a ensuite repasse integralement : 1078 tests, exit 0 ; push exit 0.
Les neuf echecs initiaux provenaient de
python-multipartabsent.Seul
python-multipart==0.0.32, conforme au lockfile, a ete installe depuisle cache local dans le venv projet Python 3.12. Les autres dependances deja
presentes sont reutilisees ; Python systeme inchange.
Public contract and limits
aucune migration, aucun changement de contrat public.
Validation hors ligne uniquement ; execution live non testee.
Le test d'inventaire preexistant recree une entree d'index locale
AD src/__pycache__/tracked.pycpendant le hook ; elle est absente du commit.Draft uniquement, aucun merge ni deploiement demande.
Safe to merge.
Findings
Summary
This change makes named
path=route decorators count toward the public API contract only when their receiver is bound toAPIRouter(...). Positional route-path discovery remains unchanged, and coverage includes valid router bindings and unrelated-object negatives.Reviews (3) · Last reviewed commit: "fix(check_repo): resolve APIRouter bindi..."