Skip to content

fix: fail loud on unfenced durable config - #568

Merged
delete-cloud merged 1 commit into
mainfrom
fix/durable-fencing-diagnostics
Jun 12, 2026
Merged

delete-cloud merged 1 commit into
mainfrom
fix/durable-fencing-diagnostics

Conversation

@delete-cloud

@delete-cloud delete-cloud commented Jun 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • centralize durable storage backend/path predicates in local_storage.py
  • make local/PG durable fencing diagnostics fail or warn according to the agreed matrix
  • make serve default empty storage config through the same sqlite bundle path used by SessionManager, so default sqlite fencing activates instead of silently running unfenced
  • update ADR implementation status notes for ADR-0015, ADR-0060, and ADR-0068

Verification

  • uv run pytest tests/ui/test_http_server.py -k build_session_manager -v (11 passed)
  • uv run pytest tests/coding_agent/test_durable_fencing_adr_contract.py tests/coding_agent/test_sqlite_local_durable_fencing.py tests/coding_agent/test_pg_durable_fencing.py -v (41 passed)
  • uv run pytest tests/ui/test_http_server.py tests/ui/test_http_server_failover.py tests/ui/test_session_manager_owner_checks.py -k "events or owner or failover or local_sqlite_bundle or partial_sqlite or default_sqlite_bundle" -v (74 passed)
  • uv run ruff check src/coding_agent/local_storage.py src/coding_agent/server/session_manager.py src/coding_agent/server/http_server.py tests/ui/test_http_server.py tests/ui/test_http_server_failover.py tests/ui/test_session_manager_runtime.py tests/coding_agent/test_sqlite_local_durable_fencing.py tests/coding_agent/test_pg_durable_fencing.py tests/coding_agent/test_durable_fencing_adr_contract.py
  • uv run ruff format --check src/coding_agent/local_storage.py src/coding_agent/server/session_manager.py src/coding_agent/server/http_server.py tests/ui/test_http_server.py tests/ui/test_http_server_failover.py tests/ui/test_session_manager_runtime.py tests/coding_agent/test_sqlite_local_durable_fencing.py tests/coding_agent/test_pg_durable_fencing.py tests/coding_agent/test_durable_fencing_adr_contract.py
  • git diff --check

Summary by CodeRabbit

Release Notes

  • New Features

    • Implemented owner enforcement for HTTP event streams with pre-registration and continuous validation.
    • Enabled durable fencing for both local SQLite and PostgreSQL storage backends to ensure data consistency.
  • Bug Fixes

    • Improved storage configuration validation with clearer error messages for misconfigurations.
    • Added warnings when custom stores disable durable fencing features.
  • Documentation

    • Updated architecture decision records to reflect accepted status and implementation completion for owner enforcement and durable fencing.
  • Tests

    • Added comprehensive test coverage for storage configuration scenarios, durable fencing validation, and configuration error handling.

@coderabbitai

coderabbitai Bot commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a551240a-f598-4aec-b910-d8848b5c7e2c

📥 Commits

Reviewing files that changed from the base of the PR and between a377960 and ca9b52b.

📒 Files selected for processing (12)
  • coding-agent/docs/adr/0015-enforce-owner-routed-http-event-streams.md
  • coding-agent/docs/adr/0060-native-platform-sandbox-backends.md
  • coding-agent/docs/adr/0068-local-sqlite-transactional-durable-fencing.md
  • coding-agent/src/coding_agent/local_storage.py
  • coding-agent/src/coding_agent/server/http_server.py
  • coding-agent/src/coding_agent/server/session_manager.py
  • coding-agent/tests/coding_agent/test_durable_fencing_adr_contract.py
  • coding-agent/tests/coding_agent/test_pg_durable_fencing.py
  • coding-agent/tests/coding_agent/test_sqlite_local_durable_fencing.py
  • coding-agent/tests/ui/test_http_server.py
  • coding-agent/tests/ui/test_http_server_failover.py
  • coding-agent/tests/ui/test_session_manager_runtime.py

📝 Walkthrough

Walkthrough

This PR implements durable fencing configuration validation by introducing centralized storage configuration constants and helpers, refactoring session manager and HTTP server initialization to use them, and adding comprehensive tests validating fencing enablement and configuration error handling for both local SQLite and PostgreSQL backends. ADRs 0015, 0060, and 0068 are marked as accepted.

Changes

Durable Fencing Configuration and Validation

Layer / File(s) Summary
Durable storage configuration constants and helpers
src/coding_agent/local_storage.py
Introduces DURABLE_STORAGE_BACKEND_PATH_KEYS, DURABLE_STORAGE_BACKEND_KEYS, and DURABLE_STORAGE_PATH_KEYS constants plus helpers (durable_storage_backend_values(), storage_has_any_sqlite_backend(), storage_uses_local_sqlite_bundle()) to normalize backends and detect SQLite configurations. Updates local_sqlite_path_from_storage_config() and with_local_sqlite_bundle_paths() to use shared constants.
Session manager durable fencing validation and wiring
src/coding_agent/server/session_manager.py
SessionManager.__init__ computes _custom_store_names to detect custom store dependencies. _create_local_durable_store() and _configure_pg_durable_store_if_available() validate durable backend selection using shared constants, raising ConfigError for mismatched backends/paths, disabling fencing (with warning) when custom stores supplied, returning None for non-matching backend types.
HTTP server session manager initialization with storage config fallback
src/coding_agent/server/http_server.py
Imports and uses local_sqlite_storage_config and storage_has_any_sqlite_backend(). Refactors _build_session_manager() to introduce effective_storage_config (defaults to local SQLite when no config present). Conditionally enables SQLiteSessionOwnerStore and owner lease config based on backend detection. Removes _storage_uses_local_sqlite_bundle() helper and ThinkingConfigSchema import.
Test fixture refactoring for isolated session managers
tests/ui/test_http_server.py, tests/ui/test_http_server_failover.py
Refactors clear_sessions autouse fixtures to accept tmp_path, create isolated per-test SQLite-backed SessionManager instances, and rebind both module-level and http_server references. Includes proper async teardown with metrics/limiter reset and manager closure.
Local SQLite durable fencing configuration validation tests
tests/coding_agent/test_sqlite_local_durable_fencing.py
Adds FakeTapeStore test double and new test cases validating ConfigError for partial SQLite backends or mismatched paths, warning/disablement when custom tape store supplied, and correct enablement for default bundle. Updates existing test to assert _local_durable_store presence.
PostgreSQL durable fencing configuration validation tests
tests/coding_agent/test_pg_durable_fencing.py
Moves fake PG store classes to module level, updates enable-fencing test to accept caplog fixture and verify no warning logged for correct configurations. Adds test verifying custom store disables PG fencing with expected warning. Imports InMemorySessionStore for custom store tests.
HTTP server session manager construction and integration tests
tests/ui/test_http_server.py
Adds test verifying owner store and local durable store enablement for default SQLite bundle when AGENT_DATA_DIR is set with empty storage config. Adds test validating ConfigError raised for mismatched SQLite configuration (local bundle with non-SQLite runtime backend). Updates fatal subagent summary test to reconfigure runtime context binding service.
ADR status updates and implementation recording
docs/adr/0015-enforce-owner-routed-http-event-streams.md, docs/adr/0060-native-platform-sandbox-backends.md, docs/adr/0068-local-sqlite-transactional-durable-fencing.md, tests/coding_agent/test_durable_fencing_adr_contract.py
Marks ADR-0015, ADR-0060, and ADR-0068 as "Accepted" with added "Implementation Status" sections. Updates acceptance criteria to mark all items completed. Updates test_durable_fencing_adr_contract.py to expect "Accepted" status.
Session manager runtime tests formatting updates
tests/ui/test_session_manager_runtime.py
Minor formatting updates to existing tests: explicit storage_config parameter, parenthesized multi-line expressions, reformatted return type annotations, and multi-line CloudWorkspaceRef arguments. No semantic logic changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • delete-cloud/Coding-Agent-Loop#79: Sticky owner enforcement for HTTP SSE endpoints depends on the same session ownership/fencing mechanism introduced in that PR's phase-2 owner substrate.
  • delete-cloud/Coding-Agent-Loop#557: Main PR's updates to ADR-0068 status and contract checks directly build on the durable fencing ADR contract introduced in that PR.
  • delete-cloud/Coding-Agent-Loop#560: Both PRs touch core local SQLite durable-fencing integration in session_manager.py and http_server.py to enable/configure SQLite owner store/fenced durable stores based on storage configuration.

Poem

🐰 Ah, durable fences take shape and form,
Constants and helpers weather the storm,
SQLite and Postgres now both stand tall,
Configuration validated, tests catch them all!
From "Proposed" to "Accepted," the ADRs proclaim—
Fencing is wired, and tested the same. ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/durable-fencing-diagnostics

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@delete-cloud
delete-cloud marked this pull request as ready for review June 12, 2026 02:00
@delete-cloud
delete-cloud merged commit a49f05d into main Jun 12, 2026
1 check was pending
@delete-cloud
delete-cloud deleted the fix/durable-fencing-diagnostics branch June 12, 2026 02:05
delete-cloud added a commit that referenced this pull request Jun 12, 2026
Fix the #568 test regression where module-level HTTP SessionManager defaults became fenced and sync test cleanup started raising RuntimeError.

Verification:
- uv run pytest tests/ui/test_developer_console.py tests/ui/test_security.py tests/integration/test_wire_http_integration.py tests/ui/test_http_server_workspace_transfer.py tests/integration/test_durable_runtime_smoke.py tests/ui/test_http_server.py tests/ui/test_http_server_failover.py -q
- uv run pytest tests/ -q (33 failed, 3622 passed, 4 skipped, 0 errors)
- uv run ruff check tests/conftest.py tests/ui/test_http_server.py tests/ui/test_http_server_failover.py tests/ui/test_security.py tests/ui/test_developer_console.py tests/integration/test_wire_http_integration.py tests/ui/test_http_server_workspace_transfer.py tests/integration/test_durable_runtime_smoke.py
- uv run ruff format --check tests/conftest.py tests/ui/test_http_server.py tests/ui/test_http_server_failover.py tests/ui/test_security.py tests/ui/test_developer_console.py tests/integration/test_wire_http_integration.py tests/ui/test_http_server_workspace_transfer.py tests/integration/test_durable_runtime_smoke.py
- git diff --check

Co-authored-by: Codex <codex@openai.com>
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.

1 participant