feat(code-facts): Django urlconfs, DRF routers and Flask mounts in the route matrix #412
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #412"
general
weight: 0.35
gurnben
First half of route ownership plan step 4 for Python (
plans/route-ownership-matrix-plan.md, owner Michele; decisions D36–D38). This is the route matrix the Django, DRF and Flask ownership readers will build on. The readers come next, one PR per family, judge-only (D35).Problem
Django rows came from a regex over files with "url" in their name:
path()line, with methodany;include()prefixes;include(...)lines read as routes;Guards were any name matching a guard-shaped regex, looked up by bare name across the checkout. So
csrf_exempt,require_POST,SSLRequiredMixin, a decorator's string argument or a module name (permissions.ReadOnly) all read as guards. A commented-out setting did too, and one project's settings guarded another project's routes.Flask rows carried no mount prefix. Hooks, view classes and functions were keyed by bare name.
What
providers.django_routes(new) reads each project's urlconfs withast, from its root:urlpatternsas built: assignments,+=,.append/.extend, conditional additions,reduce(add, ..),format_suffix_patterns,i18n_patterns, lists imported from another module, and the checkout's ownpath()helpers.include()chains: of modules, names, lists,router.urlsandrouter.get_urls(), joined to their prefixes.- list, detail,
@actionand.mappingrows;- helper-registered viewsets and
registry.extend;- DefaultRouter's root view,
trailing_slash, and nested routers' parent lookups.- class views in C3 order, one row per method they or a library generic answer, with
post = getaliases;- viewset mappings and re-exported definitions;
- function views take their verbs from
require_/api_view.ROOT_URLCONF), unconditional values only. A setting changed after it is set, or set in atry/ifstar import, is unknown. Only values every settings module of the project agrees on count.Flask (
route_guards):Apiand flask-restxNamespace/api.namespace, keyed by the module each receiver is bound in, through imports and aliases;app.route(rule)(fn),add_url_rulewith@app.endpoint, wrappedas_view,methods=constants;Guards (D37,
providers.python_guards, new): a guard counts only when it is a known auth-library guard and no checkout definition shadows its name. Names read through their imports: an alias reads as the name it imports, and a known name imported from a library that isn't an auth library is no guard:login_required,LoginRequiredMixin,IsAuthenticated, …Checkout decorators, mixins, permission classes and
before_requesthooks are never guards: their routes read judged. Among the known guards:AllowAny,…OrReadOnly,|/&/~).permission_classescounts only below@api_view. Overrides (get_permissions,initial,permission_denied, a skippingdispatch,as_view(), rebinding outside the class) leave permissions unknown.dispatchruns first, and not when a checkout class overrides their hooks or dispatches past them.LoginRequiredMiddleware: guards only checkout Django views. DRF views,login_not_required,view.login_required = Falseand Django's own auth views are exempt.- decorators count only below the route and inside any response cache;
-
optional=True/jwt_required(True)andLOGIN_DISABLEDunguard;- OPTIONS gets its own unguarded row;
-
method_decoratorscounts only on flask-restful/restxResource.pattern_dynamic, never dropped: library urlconfs and routers, computed includes and prefixes,static(), library viewset actions and blueprints, Flask-Admin, error handlers. A connexion app is a coverage gap.Behaviour changes
any) and their full mounted pattern.csrf_,require_*method decorators, string arguments and module names are no longer guards.before_requesthooks no longer guard.test_pathset, not dropped (a file likeab_test.pymay serve routes). A test module's definitions andLOGIN_DISABLEDcount only inside that module.Parity
On a public sample of Django apps compared with
development:developmentlists is still listed;On the Flask apps, rows gain their prefixes and none are lost. On a large monorepo the Django enumeration takes about 7 s.
Review
Three Qodo rounds are addressed in the last three commits, each fix with a regression test that fails before it. Four independent blind reviews found 56, 46, 28 and 38 holes as the guard rules narrowed (D36, D37). All are fixed. Per D38 there is no fifth round: guard reading is a reviewer aid, and each round finds new corners of library behaviour and Python name binding. All 168 review apps are kept as
tests/fixtures/code_facts/django_flask_matrix_review.json, each with the rows it must list.Known limits
ANYrow (unknown methods,dispatch_request) still shows its auth decorator, though OPTIONS may pass it. Every Flask auth guard is treated as OPTIONS-exempt.register_blueprint(<library call>)and Flask-Admin. Other extensions that add routes on init (flasgger, Flask-Security's blueprint) get no row.with … as, walrus,globals(),__getattr__andsetattr. A library star import is taken to bind nothing.method_decorator(cache_page, name="dispatch")on a DRF class is not read.LOGIN_DISABLEDis checkout-wide: one setting outside tests turns flask-login's guards off, as does a value computed at run time. Comments and literal false don't. Environment variables set outside the checkout aren't seen.pattern_dynamicunless the checkout calls that helper by name. pytest's tests and fixtures count as called; a helper only passed around as a value does not.LOGIN_DISABLEDtakes the last assignment in each statement list, plus any a laterif/tryblock may make.from oauth.utils import login_requiredinapp/auth.py) still reads as a guard where it is imported.LOGIN_DISABLEDonly for itself.nested_<n>and its pattern is marked dynamic.Tests
Changed tests (each approved by the owner):
| Test | Old | New | Why |
|---|---|---|---|
|
test_flask_methodview_one_row_per_method| guards from an unwritten checkouttoken_required| the libraryjwt_required(), assertion["jwt_required"]| D37: checkout decorators are no guards ||
test_flask_restx_method_decorators_and_inheritance|require_auth/require_scopefrom an unwritten module; family gapscope|flask_login.login_required,flask_security.roles_required; family gaprole| D37; the family comes from the guard's name ||
test_flask_restful_method_decorators_dict|admin_requiredfrom an unwritten module |roles_required('admin')| D37 ||
test_flask_blueprint_before_request_is_baseline| the hook is a scope guard, row not judged | no scope guard, judged | D37: hooks are no guards ||
test_flask_app_hook_scoped_to_its_app_and_registered_blueprints| both hooked routes showbefore_request:check_token| no scope guard, judged; the other app's route still judged | D37 |New tests:
test_django_routes.py: include chains, class-view methods, routers, settings per project, permission semantics, policy decorators, unplaceable routes, the D37/D38 cases, and the review fixture.test_python_guards.py: the allowlist, shadowing,LOGIN_DISABLEDand empty requirements.test_route_guards.py: Flask prefixes, receivers mounted two ways, decorator order, guards read through imports, methods never lending decorators, test-suite login switches, and the OPTIONS row.Smoke test: the built wheel, installed into a fresh environment, enumerates public Django and Flask apps (179, 234 and 1,534 rows).
Verification
development).🤖 Generated with Claude Code