Tasks: Refactor Backend from FastAPI to Django¶
Historical note (2026-09-05, BL-20260602-04).
backend/app/was the pre-Django FastAPI package. It was deleted by this spec's own T-016; the Django project package lives atbackend/law_ai/. Everybackend/app/...path below is therefore rendered as inline code, not as a link — the files it names no longer exist, and the ~110 dead hrefs 404'd on every platform. The text is otherwise unedited: it records the migration as it was specified.Each task references one or more
FR-*/NFR-*/AC-*IDs from spec.md.scripts/spec_validator.pyenforces full coverage.Sequence: T-001 must merge first (constitutional gate). T-002 → T-016 land on a long-lived
feat/011-django-backendbranch with green CI per commit; T-016 (legacy delete) is the cutover commit.
Conventions¶
- Status:
[ ]todo /[~]in-progress /[x]done. - Owner: GitHub handle or
@copilot/@agent:<role>. - Each task lists exact files to touch and how to verify.
T-001 — Constitutional amendment + ADR + docs sweep¶
- Refs: FR-1, AC-8, NFR-DOC-1
- Owner: @copilot (paired with maintainer for merge)
- Status:
[x] - Files:
docs/adr/0001-adopt-django-backend.md(new — first ADR; createdocs/adr/directory and a briefdocs/adr/README.mdindex)- docs/constitution.md §2 backend stack and §11 mission-drift guard
- AGENTS.md "Tech Stack (Non-Negotiable)" + Quick Reference rows (uvicorn → daphne) + "Project Structure" (
backend/app/→backend/law_ai/) - PRD.md backend stack mention
- .github/copilot-instructions.md FastAPI references
- docs/architecture.md, docs/local-ai.md, docs/agent-roles.md — surgical edits to file paths only
- Steps:
- Author ADR with: context (why Django), decision, consequences (Channels/Celery/admin/auth come for free), alternatives considered, and an explicit "supersedes constitution §2 lock until next ADR" clause.
- Edit constitution §2 to list "Django 5 (ASGI), DRF, Channels, Celery, Pydantic v2 (domain), CrewAI + LangGraph, Neo4j, Postgres (Django ORM async + raw asyncpg where required), Chroma, Ollama".
- Edit constitution §11 mission-drift guard: replace the "Django-style frameworks" sentence with "frameworks not listed in §2 must be rejected".
- Update AGENTS.md, PRD.md, and
.github/copilot-instructions.mdto drop FastAPI prescriptions. grep -RIn "FastAPI\|uvicorn" docs/ AGENTS.md PRD.md .github/copilot-instructions.md— only historical/changelog references remain.- Verify:
python scripts/spec_validator.py specs/011-django-backendexits 0.python scripts/backlog_lint.pyexits 0.- Manual review by maintainer (HITL §10 Level-2 gate).
T-002 — Dependency swap in backend/pyproject.toml¶
- Refs: FR-2, NFR-OSS-1
- Owner: @copilot
- Status:
[x] - Files:
- backend/pyproject.toml
- Steps:
- Add base deps:
django>=5.1,<6,djangorestframework>=3.15,channels>=4.1,channels-redis>=4.2,daphne>=4.1,celery[redis]>=5.4,django-environ>=0.11,psycopg[binary,pool]>=3.2,drf-pydantic>=2.7. - Remove base deps:
fastapi,uvicorn[standard],python-multipart. - Move
python-jose[cryptography],passlib[bcrypt]to[project.optional-dependencies].future-auth. - Add
pytest-django>=4.9to[project.optional-dependencies].dev. pip install -e ".[dev,local-ai]"in a clean venv to confirm resolves.- Verify:
pip checkclean.python -c "import django, rest_framework, channels, celery, daphne, drf_pydantic"succeeds.- License check: each new dep listed under NFR-OSS-1 is BSD/MIT/Apache.
T-003 — Django project skeleton + apps + settings split¶
- Refs: FR-3, FR-5, R-7
- Owner: @copilot
- Status:
[x] - Files:
backend/manage.py(new)backend/law_ai/__init__.py,asgi.py,wsgi.py,urls.py,celery.py(new —celery.pyskeleton only here; full wiring in T-011)backend/law_ai/settings/__init__.py,base.py,dev.py,test.py,prod.py(new)backend/law_ai/{core,audit,analysis,graph,lsat,ingestionapp,agentsapi,agents_runtime}/{__init__.py,apps.py}(new)backend/law_ai/core/settings_proxy.py(new — re-exportsfrom django.conf import settings)backend/tests/test_settings.py(new)- Steps:
cd backend && django-admin startproject law_ai .; movelaw_ai/settings.pyintolaw_ai/settings/base.pyand create dev/test/prod variants.python manage.py startappfor each of the eight apps; ensure eachapps.pydeclaresdefault_auto_field = "django.db.models.BigAutoField".base.py: readDATABASE_URL,REDIS_URL,NEO4J_*,OLLAMA_*,PHOENIX_*, all four*_API_KEYenvs,LANGGRAPH_CHECKPOINTER,LANGGRAPH_CHECKPOINTER_SCHEMAviadjango-environ. ConfigureINSTALLED_APPS,MIDDLEWARE(CORS allowhttp://localhost:3000),ASGI_APPLICATION="law_ai.asgi.application",CHANNEL_LAYERSRedis backend,REST_FRAMEWORKdefaults (DRF + custom auth + permissions).test.py: in-memory channel layer,CELERY_TASK_ALWAYS_EAGER=True, SQLite or Postgres test DB based on env.prod.py:DEBUG=False,ALLOWED_HOSTSfrom env, security cookie/SSL flags.- Write
backend/tests/test_settings.pyimporting each variant and asserting key fields. - Verify:
cd backend && DJANGO_SETTINGS_MODULE=law_ai.settings.dev python manage.py checkexits 0.pytest backend/tests/test_settings.py -qpasses.python -c "from law_ai.core.settings_proxy import settings_proxy; print(settings_proxy.NEO4J_URI)"works.
T-004 — Relocate framework-agnostic modules (no logic change)¶
- Refs: FR-4
- Owner: @copilot (HUMAN-PAIRED — large
git mvset) - Status:
[x] - Files (every file under each src moves to corresponding dst):
backend/app/agents/→backend/law_ai/agents_runtime/backend/app/db/neo4j.py→backend/law_ai/core/neo4j/driver.pybackend/app/db/graph_queries.py→backend/law_ai/core/neo4j/graph_queries.pybackend/app/db/queries.py→backend/law_ai/core/neo4j/queries.pybackend/app/db/citation_resolver.py→backend/law_ai/core/neo4j/citation_resolver.pybackend/app/db/checkpointer.py→backend/law_ai/agents_runtime/checkpointer.pybackend/app/lsat/→backend/law_ai/lsat/services/backend/app/ingestion/→backend/law_ai/ingestionapp/services/backend/app/models/extraction.py→backend/law_ai/core/schemas/extraction.pybackend/app/eval/→backend/law_ai/eval/backend/app/core/telemetry.py→backend/law_ai/core/telemetry.pybackend/app/db/neo4j_migrations/→backend/law_ai/core/neo4j/migrations/- Steps:
git mveach path; preserve git history (use--followin reviews).grep -RIln "from app\." backend/law_aiand rewrite each import tofrom law_ai.<dst>.per the move table.- Replace
from app.core.config import settingswithfrom law_ai.core.settings_proxy import settings_proxy as settingsin every relocated module. - Run
ruff check --fix backend/law_aiandblack backend/law_ai. - Verify:
grep -RIn "from app\." backend/law_aireturns empty.python -c "from law_ai.agents_runtime.crews.legal_analyst import LegalAnalyst"succeeds.python -c "from law_ai.core.neo4j.driver import get_neo4j_driver"succeeds.mypy backend/law_ai --strictpasses for relocated modules (ignore-list extended for crewai/langgraph/neo4j/eyecite).
T-005 — Audit, ApiToken, PendingReview ORM models + migrations¶
- Refs: FR-6, FR-13, NFR-MIGRATION-SAFETY-1, AC-4
- Owner: @copilot
- Status:
[x] - Files:
backend/law_ai/audit/models.py+migrations/0001_initial.py(new)backend/law_ai/ingestionapp/models.py+migrations/0001_initial.py(new — usesRunSQLto encode existing schema; usesstate_operations/database_operationsto adopt an existing legacy table)backend/law_ai/core/models.py+migrations/0001_initial.py(new —ApiToken)backend/law_ai/audit/admin.py,backend/law_ai/ingestionapp/admin.py,backend/law_ai/core/admin.py(new — register models with sensible list_display/filters)backend/tests/integration/test_migrate_parity.py(new)- Steps:
- Define
AuditEvent,PendingReview,ApiTokenper FR-6. python manage.py makemigrations audit ingestionapp corethen hand-editingestionapp/0001_initial.pyto embed verbatim DDL frombackend/app/db/postgres_migrations/001_pending_review.sqlandbackend/app/db/postgres_migrations/002_pg_trgm.sqlinside aRunSQLoperation, withstate_operationsdescribing the resulting model so legacy tables can be adopted.- Register all three models in admin with reviewer-friendly defaults.
- Write integration test: spin two Postgres containers, run
migrateon one and the legacy SQL on the other,pg_dump --schema-onlyboth, normalize table name, diff. - Verify:
python manage.py migrate --noinputagainst fresh Postgres exits 0.python manage.py migrate --noinputagainst a Postgres pre-loaded with legacypending_reviewrows exits 0 and preserves the rows.pytest backend/tests/integration/test_migrate_parity.py -qpasses./admin/audit/auditevent/,/admin/ingestionapp/pendingreview/,/admin/core/apitoken/are all reachable and list-viewable.
T-006 — Provenance reimpl on Django ORM (signature unchanged)¶
- Refs: FR-7, NFR-AUDIT-1
- Owner: @copilot
- Status:
[x] - Files:
backend/law_ai/core/provenance.py(new — supersedesbackend/app/core/provenance.py)backend/law_ai/core/audit_jsonl.py(new — JSONL Celery sink fallback, lifted frombackend/app/core/audit_store.py)backend/law_ai/core/middleware.py(new — ASGI ProvenanceMiddleware)backend/tests/core/test_provenance.py(port + extend)- Steps:
- Implement
ProvenanceLogger.log_request,.log_agent_call,.log_graph_query,@logged_node(name)with the same signatures as today. - Internally call
await AuditEvent.objects.acreate(...)inside atry/exceptthat, on failure, enqueuescore.tasks.persist_audit_jsonl.delay(payload)to write the legacy JSONL file (preserving spec-003 forensic continuity). - Wire
ProvenanceMiddlewareintoMIDDLEWAREinsettings/base.py. - Verify:
pytest backend/tests/core/test_provenance.py -qpasses.- In a shell,
await ProvenanceLogger.log_agent_call("foo", {}, {}, "model", 1.0, 0.9, [])produces anAuditEventrow. - With Postgres killed, the same call enqueues a Celery task that writes JSONL.
T-007 — API-key auth: ApiKeyAuthentication + HasScope + seed_api_keys¶
- Refs: FR-8, AC-2, NFR-PARITY-1
- Owner: @copilot
- Status:
[x] - Files:
backend/law_ai/core/auth.py(new)backend/law_ai/core/management/__init__.py,commands/__init__.py,commands/seed_api_keys.py(new)backend/tests/core/test_auth.py(new — covers constant-time compare, scope allow/deny, "all envs unset → open" parity)- Steps:
- Implement
ApiKeyAuthentication(BaseAuthentication): readX-API-Key, hash, look upApiToken.key_hashviaaget, attach a synthetic user (orAnonymousUser) plusrequest.auth = token. - Implement
HasScopepermission factory; behavior: if noApiTokenrow exists for the required scope and the matching env var is also empty, allow (parity withbackend/app/core/security.py). seed_api_keyscommand reads each*_API_KEYenv var, hashes via the same algorithm as auth, upsertsApiToken(scope=..., name="env", key_hash=...). Idempotent.- Verify:
pytest backend/tests/core/test_auth.py -qpasses.AGENT_API_KEY=foo python manage.py seed_api_keysexits 0; second invocation is a no-op.- With keys seeded, GET
/api/agents/withX-API-Key: fooreturns 200; without header returns 401; with all four envs unset, returns 200 (open fallback).
T-008 — Port routers to DRF views (5 routers, 18 endpoints)¶
- Refs: FR-9, NFR-PARITY-1, AC-2, AC-9
- Owner: @copilot (one PR per router on the feature branch; this task tracks all five)
- Status:
[x] - Files:
backend/law_ai/core/views.py+urls.py—HealthView(port ofbackend/app/api/health.py)backend/law_ai/agentsapi/views.py+urls.py— port ofbackend/app/api/agents.pybackend/law_ai/analysis/views.py+urls.py+serializers.py— port ofbackend/app/api/analysis.py; preservesawait asyncio.gather(LegalAnalyst.run, PrecedentHunter.run)backend/law_ai/graph/views.py+urls.py— port ofbackend/app/api/graph.pybackend/law_ai/lsat/views.py+urls.py+serializers.py— port ofbackend/app/api/lsat.py; tutor stays async httpx → Ollamabackend/law_ai/urls.py— root URLconf wiring/health,/api/agents/,/api/analysis/,/api/graph/,/api/lsat/,/admin/- Use
drf-pydanticto wrap existing Pydantic models fromlaw_ai.core.schemas(relocatedAnalysisRequest/Response,AgentTraceEntry,GradeRequest/Response,TutorRequest/Response, etc.) - Steps:
- For each router, create a DRF
APIView(orasync-capable view) class withauthentication_classes = [ApiKeyAuthentication],permission_classes = [HasScope("<scope>")]. - Reuse Pydantic models via
drf-pydantic.DrfPydanticSerializerso request/response validation matchesmain. - Preserve
degradedJSON shapes frombackend/app/api/graph.pywhen Neo4j is down. - Async views (
/api/analysis,/api/lsat/tutor) declareasync defhandlers; daphne handles them natively. - Verify:
- For each ported endpoint, the corresponding test from backend/tests/api/ (rewritten in T-013) passes with byte-for-byte JSON equality.
- Manual smoke per AC-2.
T-009 — Replace FastAPI lifespan with AppConfig.ready() + ensure_checkpointer command¶
- Refs: FR-10, FR-13, AC-6
- Owner: @copilot
- Status:
[x] - Files:
backend/law_ai/core/apps.py(extend withready()callingregister_all_agents()+init_tracing())backend/law_ai/core/management/commands/ensure_checkpointer.py(new)backend/tests/integration/test_checkpointer_isolation.py(new)- Steps:
- In
CoreConfig.ready(), lazily importlaw_ai.agents_runtime.registry.register_all_agentsand call it; same forlaw_ai.core.telemetry.init_tracing. Guard against double-init underrunserver --noreload. ensure_checkpointercommand: connect to Postgres,CREATE SCHEMA IF NOT EXISTS langgraph, setsearch_path=langgraph, callPostgresSaver.setup(), restore search_path.- Integration test spins fresh Postgres, runs
manage.py migratethenmanage.py ensure_checkpointer, assertslanggraph.checkpointsexists andpublic.checkpointsdoes not. - Verify:
pytest backend/tests/integration/test_checkpointer_isolation.py -qpasses.python manage.py ensure_checkpointerexits 0 idempotently.
T-010 — Channels skeleton: /ws/agents/{run_id} consumer¶
- Refs: FR-12, AC-7
- Owner: @copilot
- Status:
[x] - Files:
backend/law_ai/agentsapi/consumers.py(new —AgentRunConsumer(AsyncJsonWebsocketConsumer))backend/law_ai/agentsapi/routing.py(new — websocket urlpatterns)backend/law_ai/asgi.py— wireProtocolTypeRouter({"http": ..., "websocket": AuthMiddlewareStack(URLRouter(websocket_urlpatterns))})backend/tests/integration/test_channels_ws.py(new)- Steps:
- Consumer accepts the WS, joins group
agent-run-<run_id>, sends{"type":"ready","run_id":"<id>"}. - Wire
channels-redisRedisChannelLayeragainstREDIS_URL. - Test uses
channels.testing.WebsocketCommunicatorto assert connect + ready frame. - Verify:
pytest backend/tests/integration/test_channels_ws.py -qpasses.wscat -c ws://localhost:8000/ws/agents/test-run-idshows the ready frame manually.
T-011 — Celery wiring + ingestion quarantine task¶
- Refs: FR-11, AC-5
- Owner: @copilot
- Status:
[x] - Files:
backend/law_ai/celery.py(full implementation)backend/law_ai/__init__.py(load celery app)backend/law_ai/ingestionapp/tasks.py(new —quarantine_extraction(payload))backend/law_ai/core/tasks.py(new —persist_audit_jsonl(payload)for T-006 fallback)backend/law_ai/ingestionapp/services/scout.py— replace inline_quarantine_postgres/_quarantinecalls withquarantine_extraction.delay(payload)backend/tests/ingestionapp/test_tasks.py(port + extend)- Steps:
celery.py:app = Celery("law_ai");app.config_from_object("django.conf:settings", namespace="CELERY");app.autodiscover_tasks().quarantine_extractionwrites aPendingReviewrow + a correspondingAuditEventrow.- In
testsettings,CELERY_TASK_ALWAYS_EAGER=Trueso unit tests assert behavior synchronously; integration test uses a real worker. - Verify:
pytest backend/tests/ingestionapp/test_tasks.py -qpasses.celery -A law_ai worker -l infostarts cleanly inmake dev.
T-012 — Container, compose, and tooling updates¶
- Refs: FR-14
- Owner: @copilot
- Status:
[x] - Files:
- backend/Dockerfile —
CMD ["sh","-c","python manage.py migrate --noinput && python manage.py ensure_checkpointer && python manage.py seed_api_keys && daphne -b 0.0.0.0 -p 8000 law_ai.asgi:application"] - docker-compose.yml — backend
command:aligned; newworkerservice:command: celery -A law_ai worker -l info, same env + depends_on - .vscode/tasks.json — "Start Backend (Dev)" →
cd backend && python manage.py runserver 0.0.0.0:8000 - Makefile — add
migrate: cd backend && python manage.py migrate; updatelint/testto point atlaw_ainotapp - pytest.ini —
addopts = ... --ds=law_ai.settings.test --cov=law_ai ... - .github/workflows/ — sweep for
app.main,uvicorn,pytest --cov=app; replace appropriately - Steps:
- Edit each file; rerun
docker compose build backend workerlocally. - Update CI workflow YAML; re-run on a draft PR to confirm green.
- Verify:
docker compose up backend workershows daphne + celery ready.make testruns the new pytest config end-to-end.- GitHub Actions on the feature branch is green.
T-013 — Test infrastructure migration + per-router test rewrites¶
- Refs: FR-15, NFR-TEST-COV-1, NFR-PARITY-1, AC-3
- Owner: @copilot
- Status:
[x] - Files:
- backend/tests/conftest.py — replace
clientfixture; addapi_client(DRF) +async_client(httpx againstlaw_ai.asgi.application); replace_reset_api_keyswith_reset_api_tokens - backend/tests/api/test_agents.py, test_analysis.py, test_graph.py, test_health.py, test_local_ai_health.py, test_lsat.py — rewrite imports + fixture names; assertions unchanged
- All other tests under backend/tests/ — import-path sweep
from app.→from law_ai. - Steps:
- Rewrite
conftest.py; ensurepytest_plugins = ["pytest_django"]-style discovery viapytest.ini. - For each
tests/api/test_*.py: changefrom httpx ...→ use newapi_client/async_clientfixtures; preserve everyassert response.json() == ...line verbatim. - Run pytest-cov and confirm ≥ 75% coverage.
- Verify:
cd backend && pytest --ds=law_ai.settings.test --cov=law_aipasses with all original assertions.- Coverage HTML in
backend/htmlcov/shows no module under 70%. - Test count matches
main(no test deleted without justification in PR).
T-014 — Frontend parity smoke + spec-010 LangGraph parity + analysis perf check¶
- Refs: NFR-PARITY-2, NFR-PERF-1, NFR-LEGALBENCH-1, AC-9, AC-10
- Owner: @copilot
- Status:
[x] - Files: none modified — verification only
- Steps:
cd frontend && npm test -- --run— Vitest + RTL + MSW must pass without source edits.make devthen manual smoke per AC-1 + AC-2.Run LegalBench Evaltask — record delta in PR description.POST /api/analysisp95 latency benchmark on the same Apple Silicon laptop hardware as spec 010; assert ≤ 10% regression vsmain(NFR-PERF-1).- Verify:
- Frontend tests green, frontend
/and/agentspages load against the new backend with no JSON shape changes. - LegalBench delta ≥ 0 pp (NFR-LEGALBENCH-1).
- Analysis p95 latency regression ≤ 10% (NFR-PERF-1).
T-015 — Hardening: manage.py check --deploy + security headers¶
- Refs: NFR-SEC-1
- Owner: @copilot
- Status:
[x] - Files:
backend/law_ai/settings/prod.py—SECURE_PROXY_SSL_HEADER,SESSION_COOKIE_SECURE=True,CSRF_COOKIE_SECURE=True,SECURE_HSTS_SECONDS,SECURE_CONTENT_TYPE_NOSNIFF,X_FRAME_OPTIONS="DENY"backend/tests/test_deploy_check.py(new — runscall_command("check", "--deploy")under prod settings)- Steps:
- Set the security flags; ensure
SECRET_KEYloads from env. - Confirm DRF API views are exempt from CSRF (header-token model);
/admin/keeps CSRF. - Verify:
DJANGO_SETTINGS_MODULE=law_ai.settings.prod python manage.py check --deployexits 0.pytest backend/tests/test_deploy_check.py -qpasses.
T-016 — Cutover: delete backend/app/¶
- Refs: FR-16, AC-11
- Owner: @copilot (HUMAN-PAIRED; final review gate)
- Status:
[x] - Files:
- Delete entire
backend/app/directory. - Remove
backend/app/law_ai.egg-info/(artifact). backend/pyproject.toml[tool.setuptools]packages = ["law_ai"](was["app"]).- Final sweep:
grep -RIn "from app\." backend/ tests/returns empty;grep -RIln "uvicorn\|FastAPI" backend/only returns ADR/changelog. - Steps:
- Confirm T-002 → T-015 fully green on feature branch CI.
git rm -r backend/app/ backend/app/law_ai.egg-info/.- Update
pyproject.tomlpackage include. - Re-run full test suite.
- Verify:
cd backend && pytest --ds=law_ai.settings.test --cov=law_aipasses; coverage ≥ 75%.make lintandmake testclean.grep -RIn "from app\." backend/ tests/empty.- Manual maintainer sign-off (HITL Constitution §10 Level-2 gate).
Done-When (Definition of Done)¶
- All tasks
[x]. - All
AC-*from spec.md covered by passing tests. make lint && make testgreen.- LegalBench delta recorded in PR description (NFR-LEGALBENCH-1).
- Provenance logging verified manually for
/api/analysisand/api/lsat/tutorpaths (writes appear inaudit.AuditEventand Phoenix). manage.py check --deployexits 0 inprodsettings.## Follow-ups Discoveredsection below populated and mirrored in BACKLOG.md.
Follow-ups Discovered¶
Append-only. Mirror each item into BACKLOG.md with a
BL-YYYYMMDD-NNid. CI (scripts/spec_validator.py) checks this section exists. CI (scripts/backlog_lint.py) checks the BACKLOG mirror.
- BL-20260503-09 — feature, med — Real Channels producers for
/ws/agents/{run_id}: streamLegalAnalyst→PrecedentHunterprogress events fromanalysis/views.pyso the consumer skeleton lands in T-010 gets traffic. Resolves overlap with BL-20260429-24. - BL-20260503-10 — feature, med — Django admin actions on
ingestionapp.PendingReview(approve,reject,re-extract) + matchingcore.tasksto apply the decision back to Neo4j. Resolves overlap with BL-20260429-15. - BL-20260503-11 — feature, low — Add
/agents/runs/{trace_id}view backed byaudit.AuditEventjoined ontrace_id, so the dashboard from spec 003 can drill into a single run. Resolves overlap with BL-20260429-14. - BL-20260503-12 — feature, med — Per-token rate limiting via
django-ratelimitkeyed onrequest.auth.key_hash. Resolves overlap with BL-20260430-09. - BL-20260503-13 — feature, med — JWT/OAuth on top of
core.ApiToken(revives thepython-jose+passlibdeps under the new[future-auth]extra). Future spec. - BL-20260503-14 — infra, low — Periodic Celery beat job that runs
scripts/backlog_lint.py+scripts/spec_validator.pyand opens a triage issue when stale. Resolves overlap with BL-20260429-09. - BL-20260503-15 — refactor, low — Retire raw
asyncpgcalls outside the LangGraph checkpointer in favor of Django's connection pool now that the ORM is on hand. Partially resolves BL-20260429-17. - BL-20260503-16 — doc-gap, med — Flesh out
docs/security.md(started under NFR-DOC-1) with the API-token rotation procedure, scope matrix, and theseed_api_keysrunbook. Resolves BL-20260430-10. - BL-20260503-17 — test-gap, med — Add a Playwright end-to-end test that exercises the Django admin HITL flow against a docker stack (login → list quarantine → approve → assert Neo4j commit).
- BL-20260503-18 — doc-gap, low — Add
docs/django-conventions.mdcapturing the patterns settled in this refactor (settings split, settings_proxy usage,acreatediscipline, Channels routing, Celery task naming) so future PRs do not relitigate them. - BL-20260503-19 — infra, high — Hand-edit
law_ai/ingestionapp/migrations/0001_initial.pyto useRunSQLwith verbatim DDL frombackend/app/db/postgres_migrations/{001_pending_review,002_pg_trgm}.sqland astate_operations/database_operationssplit, so live Postgres rows survive cutover instead of relying on Django to drop+recreate the table. - BL-20260503-20 — refactor, med — Refactor
law_ai/ingestionapp/services/scout.pyto delegate quarantine writes to thequarantine_extractionCelery task (currently still uses inline asyncpg + JSONL). Closes the loop on T-011. - BL-20260503-21 — test-gap, high —
Re-establish ≥75% backend coverage on the Django app(resolved 2026-05-03): backend at 84.08% (126 tests). Added consumer / task / management-command unit tests inbackend/tests/agentsapi/test_consumer.py,backend/tests/ingestion/test_quarantine_task.py,backend/tests/core/test_management_commands.py. - BL-20260503-22 — test-gap, med — Pre-existing frontend failure (
__tests__/components/LsatLab.test.tsx: long-passage assertion) was carried through this refactor without fix. Triage and resolve sonpm test -- --runis green again. - BL-20260503-23 — refactor, low — Strip the dead-code FastAPI path from
law_ai/core/telemetry.py(TYPE_CHECKING import +FastAPIInstrumentor.instrument_appbranch) and replace withDjangoInstrumentorso OTEL spans cover the new ASGI app once Phoenix is wired in. Sweep remaining historical FastAPI/uvicorn references in core docstrings to point to the Django entrypoints. - BL-20260503-24 — infra, med —
Wire Django static files for the dockerized stack(resolved 2026-05-03): addedwhitenoisedep +WhiteNoiseMiddleware+CompressedManifestStaticFilesStorage;collectstatic --noinputnow runs in the backend container start command. - BL-20260503-25 — infra, low — Document the Postgres major-version pin in docker-compose.yml (currently 16-alpine because the existing dev volume was initialized on pg16) and add a
make reset-dbrunbook so operators can wipepgdatawhen they need to bump.