Skip to content

fix: Restore three more pinned-twin failure contracts - #5046

Merged
Sinity merged 1 commit into
masterfrom
fix/pinned-twin-contracts
Sep 14, 2026
Merged

Sinity merged 1 commit into
masterfrom
fix/pinned-twin-contracts

Conversation

@Sinity

@Sinity Sinity commented Sep 14, 2026

Copy link
Copy Markdown
Owner

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 writes
is exactly what a from-scratch rebuild generates, and it is precisely the error
the path twin was written to convert.

Fixed (3 new)

Pinned twin Path twin Lost contract
analysis/schema_drift.py:72 schema_drift_status:102 sqlite3.Error → {"available": False, "reason": …} (path had two handlers, pinned had none)
operations/status_workload.py:315 daemon/status.py:888 (OSError, sqlite3.Error) → unavailable projection
storage/raw_retention.py:2209 _ops_cursor_byte_offsets:2168 (OSError, sqlite3.Error) → RawRetentionSafetyError

The raw_retention one is the nastiest shape: its only caller
_check_cursor_ahead_of_accepted does catch RawRetentionSafetyError, so the
call 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 inside
    their try; protected by wrapping, no other caller.
  • ops_workload_status_from_connection, convergence_status_from_connection — no
    path twin; already self-classify via capture_sqlite_read.
  • read_raw_failure_lifecycle_from_connection — delegates into the shared body
    and inherits its handler.
  • Both raw_authority_verdict_cache.py readers — siblings are one-line
    store-taking delegations; neither side has an except at all.
  • raw_authority.py:1333 and usage.py:1113 — path twins have no except
    either. 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.
  • Two twins from 1d901ec73 no longer exist at head;
    _raw_replay_backlog_status discards 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. Each
conversion was mutated away and exactly the three contract tests went red with a
raw OperationalError (schema_drift.py:116, raw_retention.py:2245, and the
injection site), while the two tests asserting preserved raises stayed green —
so those also pin that the wrappers do not over-swallow ValueError or the
missing-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_BUSY on the quarantine count, which lands on a genuinely bare
statement.

Two judgment calls

  1. devtools gate layering rejected the first fix — it ratchets hand-written
    except sqlite3.* handlers that return a value. So status_workload uses the
    sanctioned seam (capture_sqlite_read), and for schema_drift the path
    twin now delegates to the pinned one — one body, one contract, structurally
    unable to drift again. Delegation rather than the seam there because
    tier_access imports the readiness stack that schema_drift documents itself
    as avoiding.
  2. Residual: capture_sqlite_read catches only sqlite3.Error, not
    OSError, so status_workload's conversion is marginally narrower than its
    path twin. The repo's mandated seam was preferred over exact parity;
    sqlite3.Error is the class that fires under concurrent writes.

_drift_table_exists is deleted — dead, superseded by the pinned twin's inline
probe, private with no other callers.

Verification

devtools test tests/unit/storage/test_pinned_twin_failure_contracts.py   PASSED
regression across drift/retention/workload                               140 tests
devtools verify --quick                                                  15/15, exit 0

The only two failures in the regression run are the pre-existing
test_daemon_workload_probe cases, identical on the stashed baseline.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK

…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
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 33 minutes.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 9e1044c4-8b93-45e4-8db4-5d76b1a79ee7

📥 Commits

Reviewing files that changed from the base of the PR and between d995eb4 and df206f7.

📒 Files selected for processing (4)
  • polylogue/analysis/schema_drift.py
  • polylogue/operations/status_workload.py
  • polylogue/storage/raw_retention.py
  • tests/unit/storage/test_pinned_twin_failure_contracts.py

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.

@Sinity
Sinity merged commit aed00ce into master Sep 14, 2026
3 checks passed
@Sinity
Sinity deleted the fix/pinned-twin-contracts branch September 14, 2026 07:42
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