Repository navigation
fix: Restore three more pinned-twin failure contracts - #5046
Conversation
…ontracts Each of these readers was copied from a path-taking sibling that converted a low-level sqlite3 error into a typed domain error or a degraded projection. The copies kept the queries and dropped the conversion, so a raw sqlite3.OperationalError (locked, busy, malformed page) escaped where callers were written to expect the converted form. - analysis/schema_drift.py: the pinned projection ran the drift-table probe and summary read bare. Its sole caller invokes it unguarded, so a readable ops tier that failed mid-read took down the whole status operation. The path twin now delegates to it instead of carrying a duplicate body, so there is one implementation and one contract. - operations/status_workload.py: the pinned raw-failure projection ran its raw_sessions sample and quarantine count bare. Routed through capture_sqlite_read, the storage seam this module already uses for its two sibling pinned readers. - storage/raw_retention.py: the pinned ops-cursor reader kept the typed refusal for a missing ingest_cursor table but not the (OSError, sqlite3.Error) -> RawRetentionSafetyError conversion. Its sole caller catches RawRetentionSafetyError, so the call site read as protected while a locked ops handle raised straight through it. Both twins agree on the happy path, so only failure injection separates them. The new tests drive a real sqlite3 error through each pinned reader and assert the contracted degraded value; each names its anti-vacuity condition, and all three were confirmed red with the conversion removed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedNext included review available in 33 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (4)
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. Comment |
A targeted sweep for one confirmed defect pattern: pinned-connection twins
copied without their path twin's failure contract. Three instances were already
fixed in PR #5044; this finds the rest.
The class is invisible to ordinary tests — both twins return identical values on
the happy path, so only failure injection distinguishes them. It matters now
because
sqlite3.OperationalError(locked/busy/IO) under heavy concurrent writesis exactly what a from-scratch rebuild generates, and it is precisely the error
the path twin was written to convert.
Fixed (3 new)
analysis/schema_drift.py:72schema_drift_status:102sqlite3.Error→{"available": False, "reason": …}(path had two handlers, pinned had none)operations/status_workload.py:315daemon/status.py:888(OSError, sqlite3.Error)→ unavailable projectionstorage/raw_retention.py:2209_ops_cursor_byte_offsets:2168(OSError, sqlite3.Error)→RawRetentionSafetyErrorThe
raw_retentionone is the nastiest shape: its only caller_check_cursor_ahead_of_accepteddoes catchRawRetentionSafetyError, so thecall site reads as protected while the typed error could no longer arrive.
Reviewing the caller alone concludes it is safe.
Established clean — so this need not be re-swept
_insight_freshness_from_connection— both path functions call it insidetheir
try; protected by wrapping, no other caller.ops_workload_status_from_connection,convergence_status_from_connection— nopath twin; already self-classify via
capture_sqlite_read.read_raw_failure_lifecycle_from_connection— delegates into the shared bodyand inherits its handler.
raw_authority_verdict_cache.pyreaders — siblings are one-linestore-taking delegations; neither side has an
exceptat all.raw_authority.py:1333andusage.py:1113— path twins have noexcepteither. Twins agree; nothing lost.
_pinned_parser_census_projection/_pinned_authority_frontier_projection—genuinely bare, but their sole caller is wrapped by PR fix: Restore five contracts the #4867 squash dropped #5044, so they are
covered on the merged result. Flagged rather than edited, to avoid colliding
with that branch.
1d901ec73no longer exist at head;_raw_replay_backlog_statusdiscards its pinned connection and re-opens by path.Anti-vacuity was executed, not asserted
tests/unit/storage/test_pinned_twin_failure_contracts.py— 5 tests. Eachconversion was mutated away and exactly the three contract tests went red with a
raw
OperationalError(schema_drift.py:116,raw_retention.py:2245, and theinjection site), while the two tests asserting preserved raises stayed green —
so those also pin that the wrappers do not over-swallow
ValueErroror themissing-table refusal.
One injection initially passed for the wrong reason: the protected lifecycle
read absorbed it first. It was replaced with a real source tier plus a proxy
raising
SQLITE_BUSYon the quarantine count, which lands on a genuinely barestatement.
Two judgment calls
devtools gate layeringrejected the first fix — it ratchets hand-writtenexcept sqlite3.*handlers that return a value. Sostatus_workloaduses thesanctioned seam (
capture_sqlite_read), and forschema_driftthe pathtwin now delegates to the pinned one — one body, one contract, structurally
unable to drift again. Delegation rather than the seam there because
tier_accessimports the readiness stack thatschema_driftdocuments itselfas avoiding.
capture_sqlite_readcatches onlysqlite3.Error, notOSError, sostatus_workload's conversion is marginally narrower than itspath twin. The repo's mandated seam was preferred over exact parity;
sqlite3.Erroris the class that fires under concurrent writes._drift_table_existsis deleted — dead, superseded by the pinned twin's inlineprobe, private with no other callers.
Verification
The only two failures in the regression run are the pre-existing
test_daemon_workload_probecases, identical on the stashed baseline.🤖 Generated with Claude Code
https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK