Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

7.0 KB
Raw Blame

ADR-0011: Source provenance across the FastAPI migration

Date: 2026-08-21 Status: Accepted Amendment: 2026-08-30, tracked in #6007

Context

ADR-0010 accounts for test coverage in PR #3299. Source code needs a separate measurement because a framework migration can replace one Flask module with several FastAPI owners, and Git rename similarity does not establish that every function, method, or class received a successor.

Decision

For each function, method, or class removed from an in-scope source module, identify either the successor that owns its responsibility or the mechanism that makes the responsibility obsolete. “Framework-specific” is not a complete disposition; the replacement might be an ASGI middleware, dependency, lifespan handler, router, or background service.

Keep the durable result as this method, the exact historical revisions, aggregate measurements, mechanism-level summary, limitations, and executable successor checks. Do not retain a raw per-symbol working register as normal documentation. It would describe one branch revision while looking like a current inventory after squash merge.

Current non-sensitive work belongs in GitHub issues. Potential current security concerns follow SECURITY.md. This ADR is historical evidence, not current product or security status.

Historical snapshot

The source measurement compares measured migration tree e5133246d03aea8bbcec8cfed8a4ea2df7b3a94d with its exact merge base 956f4f99c571990d11f672338eec3d3469d6787d.

While GitHub retains PR #3299's head ref, missing objects can be requested with git fetch origin refs/pull/3299/head:refs/remotes/origin/pr-3299 and checked with git cat-file -e <SHA>^{commit}. GitHub does not promise indefinite PR-ref retention, so ordinary CI pins the metadata without requiring either object.

The path counts include every Python A, D, M, and R status entry: all 30 deletions are counted, 29 have at least one extracted symbol, and research_library/deletion/routes/__init__.py has none. Rename-paired modules were reviewed as modified pairs rather than counted again as a deletion and an addition; that comparison contains 11 such pairs. These source measurements predate ADR-0010's later test measurement and intentionally use different historical revisions.

Measurement Count
Source modules deleted 30
Source modules added 25
Source modules modified 54
Rename-paired modules reviewed separately 11
Symbols in deleted modules 290
Leaf name present somewhere on the migration tree 206
Leaf name absent from the migration tree 84
Symbols removed from modified modules 28
Removed symbols whose leaf name was absent 6

The 206 + 84 = 290 partition covers symbols from deleted modules. Leaf-name presence is only a candidate signal; a same-named symbol elsewhere does not by itself prove equivalent behavior.

Method

  1. Enumerate Python path status with git diff --name-status -M between the exact revisions above, scoped to src/.
  2. Extract module-level ast.FunctionDef, ast.AsyncFunctionDef, and ast.ClassDef nodes. Recurse through class bodies to include qualified direct and nested class members; do not descend into function or method bodies.
  3. Compare qualified-name sets for deleted (D) and modified (M) modules. Treat rename (R) pairs separately; added (A) paths have no removed-symbol set.
  4. For the candidate survival signal, use the final qualified-name component as the leaf name. Use that signal to narrow manual review, never as the final disposition.
  5. Trace unmatched responsibilities to successor modules and executable tests.
  6. Review module-level registration, decorators, middleware, and lifespan code separately because they are not represented by symbol counts.

The largest groups moved to these successor mechanisms:

Removed mechanism Count Successor mechanism
Flask-SocketIO service methods 15 web/services/socketio_asgi.py
Flask-Limiter integration 9 web/dependencies/rate_limit.py and uvicorn proxy configuration
Flask application factory 8 web/fastapi_app.py, middleware, routers, and lifespan
WSGI security-header class 7 ASGI middleware in web/fastapi_app.py
Flask authentication decorators 6 web/dependencies/auth.py and utilities/request_context.py
Settings metadata shaping 4 _apply_env_override, _shape_egress_scope_setting, and _shape_pdf_storage_mode_setting in web/routers/settings.py
Settings model-list timing 1 _log_available_models_duration in web/routers/settings.py
Template CSRF injection 1 _LDRTemplates.TemplateResponse in web/template_config.py; _setup_template_globals in web/fastapi_app.py provides the default template global
News Flask exception handlers 3 _register_exception_handlers in web/fastapi_app.py
News research-start and scheduler-control helpers 2 _start_research_in_process and require_scheduler_control in web/routers/news_flask_api.py
Flask request hooks 5 dependencies and queue-processing services

Executable invariant

tests/test_source_provenance_map.py verifies the exact historical metadata, the arithmetic partition, exact top-level successor names and kinds, and focused regression evidence for the replacement mechanisms.

The earlier origin/main...HEAD re-derivation cannot remain meaningful after a squash merge: the historical branch boundary is no longer the future merge base, so the check either sees no migration or includes unrelated later work. The exact PR revisions identify the measurement and permit reproduction when the objects remain available; current-tree checks keep the replacement mechanisms and tests from disappearing silently.

Limitations

  • Leaf-name matching can pair unrelated symbols and cannot establish behavior.
  • Rename detection can hide deletion-and-replacement work.
  • Module-level registrations and middleware calls are outside the AST symbol inventory.
  • The historical revisions may be absent locally, and the GitHub PR ref may not remain fetchable indefinitely; the recorded IDs and counts remain immutable metadata rather than a promise that the objects are always retrievable.
  • Source accounting does not prove behavioral equivalence. Runtime tests provide separate evidence.

Consequences

  • Removed responsibilities have a concise, reproducible review summary.
  • Current code and tests, rather than a stale per-symbol table, remain the authority for present behavior.
  • Future source migrations should preserve exact comparison revisions and executable successor invariants before merge.

Issue #6007 tracks this documentation-boundary change.