Files
sales-trainer/docs/engineering-log/2026-08-15-s4-3-offline-dialect-remediation.md

2.3 KiB

S4.3 remediation — offline Alembic dialect guard

Date: 2026-08-15 Status: local remediation complete; fresh exact-current independent review passed; production gates remain blocked

Finding

Fresh reviewer deleg_c2e728d8 returned valid JSON with passed=false and one blocking logic error: backend/migrations/env.py:25-32 configured Alembic offline mode without using the supported-dialect guard in backend/app/db.py. A MySQL offline render therefore succeeded, and the generated SQL omitted the partial-index predicate for non-preview session uniqueness.

This finding supersedes the earlier S4.2 packet approval for final-gate purposes. It was a schema/migration-path issue, not a production runtime event; no MySQL or PostgreSQL production database was touched.

Test-first remediation

  • Added test_alembic_offline_path_rejects_unsupported_dialects in backend/tests/test_db_schema.py.
  • RED evidence: the test failed because command.upgrade(..., sql=True) did not raise and rendered MySQL SQL.
  • Added validate_database_url() in backend/app/db.py as the shared supported-dialect validator.
  • create_db_engine() and Alembic _database_url() now use the same validator, so online and offline paths reject unsupported dialects before engine creation or SQL rendering.

Verification

  • Offline regression: 1 passed.
  • Schema suite: 8 passed.
  • Full backend suite: 209 passed in 44.37s.
  • compileall and git diff --check: passed.
  • Changed-scope security scan: findings=[].
  • ruff/mypy: unavailable in the local environment; not represented as passing.

Review state

  • deleg_c2e728d8: valid fail; blocker remediated locally.
  • deleg_40e8edf9: fresh exact-current post-remediation review passed with empty blocking arrays and five non-blocking suggestions.
  • deleg_e672880a: valid prior S4.2 schema/dependency review; combined with deleg_40e8edf9 to close the code/schema review scope after remediation.

Operational limits

Docker, PostgreSQL runtime/parity, rollback rehearsal, JSON-to-SQL cutover, Redis persistence, real-provider QA, authenticated production smoke, credential/JWT rotation, deployment, and public access remain unverified or explicitly blocked. No commit, push, deploy, credential rotation, or production operation was performed.