Repository navigation
Conversation
|
@salty-hambot review |
There was a problem hiding this comment.
Findings outside the diff:
wherobots/db/connection.py:752
medium: Validate ownership negotiation on replacement transports
A protected Connection can be constructed with a negotiated initial WebSocket and a transport_factory that later returns a WebSocket without the ownership subprotocol. On reconnect, __resume installs that socket and sends each pending query's signed ownership claim without checking its subprotocol; subsequent protected requests use it too. The constructor checks only the initial socket (lines 320–324). Although connect_direct's factory checks replacements, the public Connection constructor accepts other factories, so its fail-closed ownership guarantee does not hold across reconnects.
|
@salty-hambot review |
|
@salty-hambot review |
|
@salty-hambot review |
Problem
DBAPI can restore a running SQL execution on a fresh connection, but recovery needs to carry the current owner's proof. WBC-1983
Solution and why this one
Add an opt-in connection mode that requires the SQL-session ownership subprotocol before submitting. The driver keeps the coordinator's signed generation with each execution and reuses it for attach, result retrieval, cancellation, and transport recovery. SQL-session supplies the trust decision from its own configuration.
Protected connections require the SQL-session changes in https://github.com/wherobots/sql-session/pull/239.
Alternatives considered
The URL version is insufficient because older SQL-session builds can accept it and ignore added fields. The driver checks positive WebSocket negotiation instead.
Proof it works
uv run --locked pytest -qpassed 363 tests. New tests cover fail-closed negotiation, malformed claims, signed terminal retrieval, and reattaching without replaying SQL.Claude Opus 5.5 at high effort reviewed twice. Addressed malformed claims, authenticated terminal result retrieval, and the typed error for reused protected IDs. The error tells callers the original query may have run.
Revision
ab5856fSalty Hambot found that a caller-supplied replacement transport skipped the capability check. The driver now rejects it before sending any claim. The new reconnect regression checks that the replacement receives no messages. The driver carries the issuer's signature and generation without a verification key from the caller.
Revision
5e0a82dAdded a regression for the protected failure reply and verified it over TLS with the real SQL-session WebSocket handler and a failing Spark query. The runtime puts the original SQL exception in the authorized result reply. The driver surfaces it as an
OperationalError. Claude Opus 5.5 at high effort reviewed the test and confirmed this revision preserves the existing driver behavior. Review discussionRevision
8c7f70fThe initial and replacement transport checks now use the same socket abort when ownership negotiation fails. The constructor regression supplies a transport with no close timeout and verifies rejection without a WebSocket close handshake or SQL request. The connect-direct and reconnect tests also verify the abort.
All seven GitHub checks passed on
8c7f70f, including Python 3.10–3.14 and pre-commit. Salty Hambot found no issues. GitHub ActionsWhat I did NOT test / where this is weakest
Hosted ingress and the Postgres signing coordinator are outside the local proof. Protected mode depends on SQL-session supporting the subprotocol.
Risk & confidence
New dependencies
None.
Reviewer focus
Check negotiation on reconnect and confirm that all ownership-bearing requests keep their proof out of application logs.
Author checklist
Implemented by GPT-6.2 Sol through T3 Code's Codex harness.