Repository navigation
feat(cursor): restore SQL executions on a new connection - #95
Merged
Merged
Conversation
Member
Author
|
@salty-hambot review |
Member
Author
|
@salty-hambot review |
ClayMav
marked this pull request as ready for review
November 10, 2026 17:17
sfishel18
approved these changes
Nov 10, 2026
Member
Author
|
Yes. This PR exposes the existing attach primitive: it transfers event ownership, and its duplicate guard is connection-local. It does not fence other live connections. I’ll document those caller obligations in a follow-up. For MCP recovery, a Postgres lease alone is insufficient; before enabling takeover we need server-enforced ownership/generation checks so stale workers cannot reattach or cancel the recovered execution. That remains part of WBC-996. |
Member
Author
|
@salty-hambot review |
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A new client cannot recover a known SQL execution through the public driver API. The driver only reattaches queries already tracked in that process, which blocks MCP's Postgres-backed restart recovery.
Add
cursor.attach(execution_id, store=original_store)on a connection to the original SQL session. Fetching and cancellation reuse the existing recovery machinery. Attaching sendsretrieve_resultswithattach, neverexecute_sql. Missing or cancelled executions preserve their existing errors, and a rejected duplicate attach preserves the current execution and both cursors' result handlers.Related Issues
WBC-1934, a prerequisite for WBC-996 in Modern MCP architecture.
Verification
uv run pytest tests/test_attach.py tests/test_cursor.py tests/test_reconnect.py -q: 140 passed after the duplicate-attach fix, including preservation of pending/completed executions and successful replacement.uv run pytest -q: 349 passed before the final duplicate-attach fix on Python 3.11, with two existing WebSocket deprecation warnings. Covers public attachment to running/completed executions, stored results, cancellation, missing executions, duplicate tracking, invalid IDs, old-session polling, and another transport loss.uv run pre-commit run --all-files: all hooks passed.uv build: source distribution and wheel built successfully.execute_sqland oneretrieve_resultsrequest with the same ID, with no replay. Both clients, server, and temporary TLS files were cleaned up.Independent adversarial review of the implementation and duplicate-attach fix found no substantive issues. The fix review independently passed 10 focused tests and an immediate-result check.
On
b9763530db0209523fe2dec422392028ec51d765, CI passed on Python 3.10 through 3.14, hosted pre-commit passed, and Salty reviewed with no findings.No live SQL session, Postgres database, cloud credential, or deployed service was used. Authentication and real server orphan-grace/result-retention behavior need integration qualification. This API neither extends result retention nor provides a durable job store. The remaining MCP work must persist execution identity safely and reconcile uncertain submissions without replaying writes.
Requester Checklist
Visual Proof
Local restart smoke output:
Size Justification (if L/XL)
The change includes connection and cursor integration plus lifecycle tests. The cursor resets execution state through one shared method so execute and attach preserve the same result isolation.
Reviewer Checklist
Implemented by GPT-6.1 Sol through T3 Code's Codex harness, with an independent agent review.