Skip to content

fix(check-repo): honor named path= in declared routes - #307

Merged
Mathis (echobt) merged 3 commits into
mainfrom
cursor/fix-check-repo-named-path
Sep 21, 2026
Merged

Mathis (echobt) merged 3 commits into
mainfrom
cursor/fix-check-repo-named-path

Conversation

@echobt

@echobt Mathis (echobt) commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem and behavior

declared_routes n'inspectait que le premier argument positionnel litteral :
@router.get(path="/v1/status") produisait set() et etait ignore.
Le correctif lit path uniquement sans argument positionnel, toujours avec
l'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 :

Commande Resultat Exit
uv run --no-sync ruff format --check src tests scripts 152 files already formatted 0
uv run --no-sync ruff check src tests scripts All checks passed! 0
uv run --no-sync mypy Success: no issues found in 83 source files 0
uv run --no-sync pytest -m 'not live' 1078 passed in 28.91s 0
uv run --no-sync python scripts/check_repo.py --final Repository contracts passed (final Python-only gate). 0
uv run --no-sync python scripts/check_deploy.py --check-examples Python images, roles, VM host and fail-closed pins validated; no services started. 0

Le hook pre-push a ensuite repasse integralement : 1078 tests, exit 0 ; push exit 0.

Les neuf echecs initiaux provenaient de python-multipart absent.
Seul python-multipart==0.0.32, conforme au lockfile, a ete installe depuis
le 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.pyc pendant le hook ; elle est absente du commit.
Draft uniquement, aucun merge ni deploiement demande.

RetriggerConfidence Score: 5/5

Safe to merge.

Findings

  1. P1 Verify router bindings ▶
Summary

This change makes named path= route decorators count toward the public API contract only when their receiver is bound to APIRouter(...). 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..."

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.
Comment thread scripts/check_repo.py
@greptile-apps

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>
@echobt
Mathis (echobt) marked this pull request as ready for review September 21, 2026 18:34
@echobt

Copy link
Copy Markdown
Contributor Author

Greptile (@greptileai) review

@echobt
Mathis (echobt) merged commit cc45e95 into main Sep 21, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant