Skip to content

P0: Preserve route assembly and qualified dependency provenance #277

Description

@shaggitza

Priority

P0 — route identity and dependency propagation correctness.

Problem

Endpoint materialization discards the provenance that assembled a public route, and dependency analysis does not consistently preserve FastAPI dependency identity.

Evidence:

  • src/fastapi_endpoint_detector/parser/secure_ast_extractor.py:394-453,2391-2579
  • src/fastapi_endpoint_detector/models/endpoint.py:135-226
  • src/fastapi_endpoint_detector/parser/fastapi_extractor.py:169-208
  • src/fastapi_endpoint_detector/analyzer/mypy_analyzer.py:719-797,799-963,1092-1108

Reproduced failures:

  • Editing include_router(..., prefix='/old') can change every public route without a changed handler seed.
  • Multiline route decorators, import retargets, re-exports, class bases, module globals, and __all__ changes were often missed.
  • An app-level Depends(app_dep) was visible as a short runtime dependency name, but changing its transitive helper produced no endpoint candidate and was orphaned.
  • Router/include-level dependencies, callable instances, dependency factories, partials, and duplicate short names cannot be represented safely by list[str].

Required design

Add immutable, side-qualified registration provenance to native endpoints:

  • route decorator or imperative registration occurrence;
  • include/mount edge chain and prefix expressions;
  • selected app/factory/bootstrap root;
  • app/router/include/route dependency expressions;
  • baseline/target side and endpoint lifecycle.

Add an AST change-to-owner pass for complete decorator/signature spans, assignment RHS spans, import bindings, exports, class bases/decorators, and route assembly edges. Store qualified callable dependency evidence; runtime mode should traverse FastAPI's recursive dependant graph.

Acceptance criteria

  • Prefix, mount, include, registration-order, factory-return, and bootstrap changes affect exactly their descendant endpoints.
  • App, router, include, route, Security, Annotated, nested, duplicate-name, override, factory, partial, and callable-instance dependencies have tests.
  • Multiline route/decorator/global/base/import/export changes receive structural ownership evidence.
  • Ambiguous or dynamic assembly/dependency expressions remain LOW/conditional, never guessed.
  • Report output distinguishes removed/renamed endpoints from runnable target endpoints.

Related: #104, #107.

Metadata

Metadata

Assignees

No one assigned

    Labels

    adapterFramework or protocol adapterarchitectureArchitecture and extensibilityenhancementNew feature or requestpriority: P0Highest priority: correctness or release-blocking work

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions