Skip to content

feat(acp): use sqlite local durability - #555

Closed
delete-cloud wants to merge 1 commit into
mainfrom
feat/acp-sqlite-local-durability
Closed

delete-cloud wants to merge 1 commit into
mainfrom
feat/acp-sqlite-local-durability

Conversation

@delete-cloud

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

Copy link
Copy Markdown
Owner

Summary

  • add ADR-0067 for SQLite-first local ACP tape/runtime durability
  • add a local SQLite session owner store implementing the existing owner/fencing protocol
  • wire ACP stdio to SQLite tape, checkpoint, runtime, and owner stores
  • release local owner leases when the local CLI manager closes

Verification

  • uv run pytest tests/ui/test_session_owner_store.py tests/cli/test_local_runtime.py tests/cli/test_entrypoint_contract.py tests/acp tests/ui/test_session_manager_owner_checks.py tests/coding_agent/test_sqlite_runtime_store.py tests/agentkit/storage/test_sqlite.py -q
  • uv run ruff check src/coding_agent/server/stores/session_owner_store.py src/coding_agent/cli/acp_command.py src/coding_agent/cli/local_runtime.py tests/ui/test_session_owner_store.py tests/cli/test_entrypoint_contract.py tests/cli/test_local_runtime.py tests/acp/test_server.py
  • uv run ruff format --check src/coding_agent/server/stores/session_owner_store.py src/coding_agent/cli/acp_command.py src/coding_agent/cli/local_runtime.py tests/ui/test_session_owner_store.py tests/cli/test_entrypoint_contract.py tests/cli/test_local_runtime.py tests/acp/test_server.py
  • git diff --check

Summary by CodeRabbit

  • New Features

    • Local sessions are now stored persistently using SQLite.
    • Added session ownership and fencing mechanisms to prevent session takeover conflicts.
  • Bug Fixes

    • Tracing logs are no longer written to stdout during CLI execution.
  • Tests

    • Added tests for session ownership lifecycle and durability behavior.

@coderabbitai

coderabbitai Bot commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@delete-cloud, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 58 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fd37e33a-cc71-48ff-b47b-d15d0de26899

📥 Commits

Reviewing files that changed from the base of the PR and between d4a0279 and ee8ecf5.

📒 Files selected for processing (11)
  • coding-agent/docs/adr/0067-local-sqlite-durable-tape-runtime.md
  • coding-agent/src/coding_agent/acp/server.py
  • coding-agent/src/coding_agent/cli/acp_command.py
  • coding-agent/src/coding_agent/cli/local_runtime.py
  • coding-agent/src/coding_agent/server/session_manager.py
  • coding-agent/src/coding_agent/server/stores/session_owner_store.py
  • coding-agent/tests/acp/test_compat_harness.py
  • coding-agent/tests/acp/test_server.py
  • coding-agent/tests/cli/test_entrypoint_contract.py
  • coding-agent/tests/cli/test_local_runtime.py
  • coding-agent/tests/ui/test_session_owner_store.py
📝 Walkthrough

Walkthrough

This PR introduces SQLite-backed session ownership and persistence for local ACP/CLI durability. An ADR documents the architecture, a new SQLiteSessionOwnerStore class implements lease/fencing in SQLite, the local session manager is updated to carry ownership metadata and delegate additional directory updates, and the ACP command wires everything together with tracing disabled and a per-run session owner identity.

Changes

Local SQLite Durability and Session Ownership

Layer / File(s) Summary
Architecture Documentation
docs/adr/0067-local-sqlite-durable-tape-runtime.md
ADR-0067 documents the shift to SQLite-first local durability: SQLite stores for tape/checkpoint/runtime, durable-store-derived session/result/replay projections, session-owner/lease/fencing via SQLiteSessionOwnerStore with fencing tokens for single-host takeover safety, and explicit scoping that keeps cloud (PostgreSQL-first) semantics unchanged.
SQLite Session Ownership Store
src/coding_agent/server/stores/session_owner_store.py, tests/ui/test_session_owner_store.py
SQLiteSessionOwnerStore implements persistent session ownership with UTC-aware lease expiration, fencing-token enforcement during renewal, and transaction-scoped acquire/renew/release; helpers validate inputs and serialize datetimes as ISO-8601 text. Tests validate full lifecycle (acquire, prevent conflict while live, renew with token update, release, takeover after expiry) and stale-token rejection.
Local Session Manager Ownership Integration
src/coding_agent/cli/local_runtime.py, tests/cli/test_local_runtime.py
ServerBackedLocalCliSessionManager adds owner_store, owner_id, and fencing_token fields, wires them into SessionManager construction, adds update_session_additional_directories delegation, and calls release_owned_sessions before close. create_local_cli_session_manager factory accepts and passes ownership parameters through both default and custom storage configurations. Tests validate delegation of directory updates and release-before-close ordering.
ACP Command Entrypoint Configuration
src/coding_agent/cli/acp_command.py, tests/acp/test_server.py, tests/cli/test_entrypoint_contract.py
acp_command.py disables tracing, derives data_dir from environment, switches storage backends to SQLite, wires SQLiteSessionOwnerStore at data_dir/session_owners.sqlite3, generates per-run owner_id using uuid with acp-stdio: prefix, and sets fencing_token via secrets.randbits. Tests verify tracing is disabled, session manager is constructed with correct backend types and ownership, and stdio runs with an AcpServer before cleanup.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • delete-cloud/Coding-Agent-Loop#79: Introduces the session-owner-store abstraction and SessionManager owner checks with PGSessionOwnerStore for cloud durability; this PR extends that mechanism to local SQLite by adding SQLiteSessionOwnerStore and plumbing ownership through the local CLI stack.

Poem

🐰 A rabbit hops through SQLite's glow,
With session leases, fencing tokens flow,
Local durability, persistent and true,
Ownership tracked when the old lease is due!
Tape spins forever, sqlite stores the lease,
Single-host safety brings hoppy peace. 🌙

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 2.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(acp): use sqlite local durability' accurately and concisely summarizes the main change: adopting SQLite for local durability in the ACP (Approval Command Processor) module, which is the primary objective of this pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/acp-sqlite-local-durability

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.

Add ADR-0067 for SQLite-first local ACP storage, wire ACP stdio to SQLite tape/checkpoint/runtime stores, and add a local SQLite session owner store for owner/fencing enforcement.\n\nVerification:\n- uv run pytest tests/ui/test_session_owner_store.py tests/cli/test_local_runtime.py tests/cli/test_entrypoint_contract.py tests/acp tests/ui/test_session_manager_owner_checks.py tests/coding_agent/test_sqlite_runtime_store.py tests/agentkit/storage/test_sqlite.py -q\n- uv run ruff check src/coding_agent/server/stores/session_owner_store.py src/coding_agent/cli/acp_command.py src/coding_agent/cli/local_runtime.py tests/ui/test_session_owner_store.py tests/cli/test_entrypoint_contract.py tests/cli/test_local_runtime.py tests/acp/test_server.py\n- uv run ruff format --check src/coding_agent/server/stores/session_owner_store.py src/coding_agent/cli/acp_command.py src/coding_agent/cli/local_runtime.py tests/ui/test_session_owner_store.py tests/cli/test_entrypoint_contract.py tests/cli/test_local_runtime.py tests/acp/test_server.py\n- git diff --check
@delete-cloud
delete-cloud force-pushed the feat/acp-sqlite-local-durability branch from d4a0279 to ee8ecf5 Compare June 5, 2026 04:49
@delete-cloud
delete-cloud deleted the feat/acp-sqlite-local-durability branch June 5, 2026 05:01
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