Skip to content

TEST: Cover SQLite branch contention and cancellation - #3344

Open
Roman Lutz (romanlutz) wants to merge 3 commits into
microsoft:mainfrom
romanlutz:romanlutz-sqlite-atomic-branch-locking
Open

Roman Lutz (romanlutz) wants to merge 3 commits into
microsoft:mainfrom
romanlutz:romanlutz-sqlite-atomic-branch-locking

Conversation

@romanlutz

Copy link
Copy Markdown
Contributor

Description

Add controlled SQLite contention coverage for conversation branch registration and promotion, protecting atomic membership updates when writes fail, wait, or are cancelled.

  • Hold a real competing write transaction and check that the original SQLITE_BUSY error propagates without partial changes. Cover both holder commit and rollback, then explicitly resubmit and verify reference ordering.
  • Observe the guard UPDATE through SQLite's native trace callback before releasing the holder or cancelling the contender. Verify that the same waiting call completes without retrying, preserves the holder's newly committed branch, and retains the original cancellation message without orphaned branch data.
  • Use the production async engine factory in the file-backed fixture so these tests exercise its cursor cleanup and cancellation hooks. Keep the fixture's existing 30-second busy timeout.

This is test coverage, not a fix for the historical CI lock failure. Controlled probes did not establish a production locking defect; the cause of that CI failure remains unresolved. Production locking/retry behavior and the original concurrent test's assertions and timeouts are unchanged. No API or schema changes.

Tests and Documentation

Added eight parameterized contention cases covering lock errors, commit/rollback, native waiting, and cancellation. Validation on Windows with Python 3.14.4:

  • uv run --frozen pytest tests\unit\memory\test_conversation_branching.py tests\unit\memory\test_async_memory.py tests\unit\memory\test_sqlite_cancellation.py tests\unit\memory\memory_interface\test_interface_attack_results.py -q: 337 passed, 44 existing deprecation warnings.
  • uv run --frozen ruff check tests\unit\memory\test_conversation_branching.py: passed.
  • uv run --frozen ruff format --check tests\unit\memory\test_conversation_branching.py: passed.
  • uv run --frozen ty check tests\unit\memory\test_conversation_branching.py: passed.
  • git diff --check: passed.

Full unit suite, live SQL Server integration tests, and JupyText were not run. Documentation changes are not applicable to this test-only change.

Exercise controlled SQLite writer contention without changing production lock acquisition, retries, or correctness-test timeouts. Verify SQLITE_BUSY propagation, rollback/commit membership ordering, and cancellation cleanup for branch registration and promotion.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 53404e18-54fd-4013-aae7-97be8c012f4d
Keep the production async connection factory and cleanup hooks in the branching fixture while preserving its existing busy timeout. Observe SQLite's native UPDATE execution before releasing a competing writer or cancelling, and verify that completed and cancelled calls preserve the holder's committed branch membership without retrying.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 53404e18-54fd-4013-aae7-97be8c012f4d
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Oct 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 20, 2026

This branch has not been deployed

No deployments
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.

2 participants