Skip to content

Fix hosted PostgreSQL connection lifecycle - #674

Merged
nicho1ab merged 1 commit into
mainfrom
issue-673-postgres-connection-lifecycle
Aug 8, 2026
Merged

nicho1ab merged 1 commit into
mainfrom
issue-673-postgres-connection-lifecycle

Conversation

@nicho1ab

@nicho1ab nicho1ab commented Aug 8, 2026 •

Copy link
Copy Markdown
Owner

Pull Request Evidence

Governing issue and intended outcome

Implementation scope

  • Major files or components changed: src/ccld_complaints/hosted_app/app.py, tests/unit/test_hosted_postgres_connection_lifecycle.py, tests/unit/test_hosted_reviewer_ui.py, and TESTING_STRATEGY.md.
  • Important behavior intentionally left unchanged or out of scope: No schema or migration change; no source-ingestion change; no production-data change; no max_connections adjustment; no backend-termination workaround; no QNAP, Cloudflare, deployment, or production runtime mutation.
  • Reviewer UI regression contracts: RT-RC-001 affected - authorized reviewer destinations and supported context remain protected while PostgreSQL connection ownership becomes request-scoped and deterministic; lifecycle regressions prove cleanup without changing reviewer navigation or authorization outcomes.

Acceptance-criteria evidence

Acceptance criterion Evidence and result
Root cause identified PASS - health polling created short-lived SQLAlchemy engines whose pools retained physical sessions, while reviewer routes cached one live connection across threaded requests.
Deterministic cleanup PASS - one process-owned engine is reused and request-owned connections are context-managed.
Failed transactions roll back PASS - forced route failure proves the write is rolled back, connection closes, and no connection remains checked out.
Early-return cleanup PASS - POST authorization early return rolls back and leaves zero checked-out connections.
Repeated calls remain bounded PASS - 25 health polls and 25 hosted requests complete with connection checkout/checkin parity and zero outstanding checkouts.
Repository validation PASS - Ruff, mypy, pytest, documentation check, and workflow-contract verification pass.
Deployment verification Pending - #640 remains blocked until governed merge and human-operated QNAP deployment proves the required pre-activation pg_dump succeeds.

Validation and failure classification

Exact command Result Failure classification, if applicable
ruff check . Pass none
mypy src Pass none
pytest Pass - 2034 passed, 9 skipped in GitHub CI none
python scripts/check_docs.py Pass none
python scripts/check_independent_verification.py Pass for required workflow contract none
PR live evidence verification Fail before this correction PR-body formatting/evidence failure only; implementation validation passed
  • Implementation-caused failures: None identified in application code, lint, typing, tests, or documentation validation.
  • Pre-existing failures: None relied upon for passage.
  • Environmental failures: Earlier local repository-scoped pytest basetemp conflicted with a portable-path test; unchanged full-suite validation subsequently passed.
  • Tests intentionally not run and why: QNAP/production validation was not run by Codex because Issue Fix hosted PostgreSQL connection leakage blocking deployment #673 reserves those operations for the human operator.

UI and accessibility evidence (when applicable)

Not applicable - no UI or accessibility presentation change; reviewer-route changes are limited to database connection ownership and transaction lifecycle.

Reviewer-facing redesign artifact classification (when applicable)

Not applicable - no reviewer-facing removal, merge, rename, relocation, replacement, or redesign.

Documentation, assumptions, and remaining risks

  • Documentation impact: TESTING_STRATEGY.md adds the hosted PostgreSQL connection-lifecycle regression requirement for engine reuse, request-owned cleanup, rollback, bounded repeated calls, and POST early-return behavior.
  • Assumptions and limitations: Repository tests establish SQLAlchemy connection and transaction lifecycle behavior but do not replace required live QNAP verification. Existing leaked sessions belong to the currently deployed pre-fix application.
  • Remaining risks or follow-up: After merge, Epic: Bring hosted Compare Facilities to stakeholder-review readiness #640 remains blocked until the human operator deploys the corrected merged SHA and proves the mandatory pre-activation pg_dump and subsequent hosted acceptance gates succeed.

Governed-boundary review

Governed boundary Status Specific explanation or evidence
Schemas and migrations No change No schema or Alembic migration changed.
Ingestion and source-connector contracts No change No connector, retrieval, import, or source contract changed.
Security and privacy No change No authentication, authorization, secret, or private-data handling change.
Production data and correction behavior No change No production data or correction behavior changed.
Deployment and infrastructure No change No Compose, QNAP, Cloudflare, deployment script, PostgreSQL configuration, or max_connections change.
Repository governance Authorized change TESTING_STRATEGY.md was narrowly updated for Issue #673 regression requirements.
Required GitHub workflows and checks No change No workflow or required check was changed.
Tests or checks weakened to obtain passage Authorized change Test files changed to add and update connection-lifecycle regression coverage; no existing test or check was disabled, relaxed, skipped, renamed, removed, or weakened.

Required GitHub checks

  • validate - rerun required after PR-body correction
  • docs-check
  • fixtures
  • security

@nicho1ab
nicho1ab merged commit f42c8eb into main Aug 8, 2026
4 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix hosted PostgreSQL connection leakage blocking deployment

1 participant