Repository navigation
fix: Recover from per-item refusals instead of fencing whole inputs - #5056
Conversation
Problem: iter_retained_source_records collected ZipAdmission rejections and raised ValueError after the generator had already yielded every admitted member. One member over the compression-ratio ceiling (deflate reaches ~1032, so a repetitive JSON member attains it) therefore raised out of enumerate_ingest_input. Because AcceptedIngest.enumerate_item only writes complete_source_item_enumeration when the iterator exhausts normally, the source item was never closed, the exception fenced the generation, and each retry re-enumerated to the same raise: a terminal condition retried forever. Solution: a member refused by ZIP admission was never ingested by ordinary acquisition either, so retained enumeration skips and logs it rather than raising. Admitted members keep their central-directory ordinals, so the retained coordinates of the surviving members are unchanged. Verification: devtools test tests/unit/sources/test_retained_acquisition.py — the new test_one_rejected_zip_member_does_not_abort_its_whole_input reproduced "retained ZIP enumeration rejected 1 member(s): zip entry compression ratio 1027.8 exceeds limit" before the change and passes after. Residual: a skipped member is logged, not recorded as a per-member refused disposition row; polylogue-bwu75 keeps that design question. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
Problem: core.sqlite_locking.is_transient_sqlite_lock masks SQLite's primary
result code and documents why text is a last resort, but four copies ignored
it and matched message text instead.
- convergence_standing_queries tested bare "locked"/"busy" substrings, so
`no such table: busy_cursors` read as contention. The stage returns False
with false_means_pending=True, so a permanent schema error was deferred
forever and never surfaced: terminal misclassified as retryable.
- cursor_lag_baseline matched only "database is locked", so SQLITE_LOCKED
("database table is locked") escaped its two best-effort call sites.
- daemon.http decided 503 archive_busy vs 500 on text, so an extended
SQLITE_LOCKED_SHAREDCACHE returned 500 and the client stopped retrying a
retryable condition.
- convergence_stages missed the same extended codes.
Solution: all four delegate to the shared result-code predicate.
Verification: devtools test tests/unit/core/test_sqlite_lock_classification.py
tests/unit/daemon/{test_convergence_stages,test_cursor_lag_baseline,
test_daemon_http,test_daemon_http_contracts}.py — all passed. The new test
asserts BUSY/LOCKED/LOCKED_SHAREDCACHE are transient and that
`no such table: busy_locked_cursors` and a malformed image are not; reverting
any predicate to its substring form turns it red.
Residual: sources/live/watcher.py carries a fifth copy and is IN the derived
schema identity closure, so it is left to a change that can pay reconvergence.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
…ration
Problem: prepare_raw_census modelled parse failure as `parsed is None ->
RawCensusStatus.FAILED`, but the sole production callable,
parse_retained_raw_sessions (sources/revision_backfill.py:3570), is typed
`-> list[ParsedSession]` and raises. The FAILED arm was therefore unreachable
and the exception escaped to operations/daemon_ingest.py:662, whose
`except Exception` marks the checkpoint unknown and fences the generation as
refused. One unparseable input cost every other input of its source
generation, on the accepted-ingest route a reacquisition uses.
The branch was dead twice over: publish_raw_census forwarded
`projections=prepared.projections`, and the FAILED arm builds that as the empty
tuple, which trips replace_raw_membership_census's "projections must align with
the complete parser census" check whenever sessions is None. Had the arm ever
been entered it would have raised on publication.
Solution: catch the parse exception at the census boundary and return the
intended FAILED disposition with the exception text as its detail, matching the
legacy retryable-debt route this replaced (revision_backfill.py:1297-1309).
Transient SQLite contention is re-raised rather than quarantined, so a lock is
retried instead of being recorded as a permanent parse verdict. publish_raw_census
now passes projections=None alongside a None census.
Verification: devtools test tests/unit/storage/test_ingest_governance.py
tests/unit/daemon/{test_daemon_status,test_daemon_http_contracts}.py — passed;
devtools verify --quick — all 15 gates ok. The new
test_raising_production_parser_records_a_failed_census_instead_of_escaping
raised before the change (and then surfaced the projections defect); every
pre-existing test in that file uses a _parse_from double that can only return,
so none reached the arm.
Residual: the _selector_raw_ids / _session_for_key concern in polylogue-163ku
is untouched; that bead stays open for it.
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 14 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 (9)
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 |
Two PRs, each green on its own, were red once both had landed. #5056 added `logging.getLogger` to `sources/retained_acquisition.py` for the ZIP member-skip warning; #5059 recorded the `legacy-stdlib-logger` baseline at 23 entries. Neither PR's CI saw the other's change, so master ended up scanning 24 matches against a 23-entry baseline and `gate patterns` began blocking every PR opened afterwards, including ones touching neither file. Convert that site to `source.zip.members_refused`. No new allowlist field is needed: `path` and `skipped` are registered, and the refused-member list rides in `error_detail`, the one existing quarantined field. Also prune 22 stale baseline entries whose sites no longer exist, several of them naming the long-deleted `storage/repair.py`. Pruning shrinks the ratchet, which is the permitted direction; silencing the gate by adding an entry is the forbidden one. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
…ty (#5065) ## Summary `devtools gate patterns` is **red on master**, blocking every PR opened since, including ones that touch neither implicated file. This restores it and makes the baselines honest. ## Problem Two PRs, each green on its own, red once both had landed: - **#5056** (error paths) added `logger = logging.getLogger(__name__)` to `polylogue/sources/retained_acquisition.py` for the ZIP-member-skip warning. - **#5059** (structured logging) recorded the `legacy-stdlib-logger` ratchet baseline at 23 entries. Neither PR's CI ever saw the other's change. After both merged, master scanned 24 matches against a 23-entry baseline, so the gate reported a new match and set `blocking: true`. PRs #5061, #5062, #5063 and #5064 all failed for this inherited reason. Separately, the baselines carried **22 stale entries** whose sites no longer exist — several naming `polylogue/storage/repair.py`, a file deleted some time ago. ## Solution Convert the one blocking site to a structured event, `source.zip.members_refused`. No new allowlist field was needed: `path` and `skipped` are already registered, and the refused-member list rides in `error_detail`, the single existing quarantined field. Prune the 22 stale entries. Pruning **shrinks** the ratchet, which is the permitted direction; adding an entry to silence the gate is the forbidden one. ## Verification ``` devtools gate patterns -> blocking: false, new_matches: 0, stale_matches: 0 ``` Baselines now match the scan exactly in both directions. Before this change the same command reported 1 new match and 22 stale entries. No test asserts on the old warning text, so no test changes were required. ## Note for the ratchet's owner — not addressed here A structural gap surfaced while fixing this. `legacy-stdlib-logger` matches `logging.getLogger(...)`, but the form most of the tree actually uses is the `polylogue.logging.get_logger` wrapper, which the rule does not match. A concurrent conversion of 90 prose sites across `daemon/cli.py` and `daemon/http.py` therefore eliminated **zero** baseline entries — the gate meant to enforce "no legacy logging" is blind to the dominant legacy form. Widening the existing rule would grow its baseline by roughly 140 modules, which the ratchet forbids. The coherent route is a second rule with its own baseline at the true remaining count: a new ratchet may start wherever reality is, while an existing one may only shrink. That is a deliberate decision and belongs in its own change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
event_bus, intake and supervisor were the only daemon modules the rule matched (it matches logger acquisition, not each call site), so the baseline drops from 23 entries to 20. The gate was already failing before this branch: #5056 added an unbaselined logging.getLogger in sources/retained_acquisition.py. Fixed forward by converting that one site rather than growing the ratchet. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
…ion (#5129) ## Summary The last open arm of `polylogue-163ku`: one selector member that no longer parses still fenced an entire source generation, through a different code path than the one #5056 fixed. ## Problem `polylogue/storage/ingest_governance.py::_session_for_key` raised a bare `RuntimeError(f"membership {raw_id}:{logical_source_key} no longer parses uniquely")` whenever a selector member did not yield exactly one session for the key. `prepare_ingest_cohort` calls it once per selector member, and `_selector_raw_ids` admits `archive.raw_revision_head_raw_id(logical_source_key)` **unconditionally** — no `revision_kind` / `source_index` / census filter, unlike its sibling `raw_membership_raw_ids`, which admits only byte-proven members. Concrete input, executed as the new regression test: a published cohort over two Codex raws, then a re-prepare where the now-accepted head raw raises (exactly the production shape — `parse_retained_raw_sessions` is typed `-> list[ParsedSession]` and raises rather than returning `None`). Wrong observable outcome at the reviewed head: the exception escapes `prepare_ingest_cohort`, out of `IngestExecution.materialize`, to `execute_ingest_operation`'s `except Exception: await execution.fence("refused"); raise` (`polylogue/operations/daemon_ingest.py`). Every *other* logical key in that generation — all of them still preparable — is lost with it. This is the repo's own doctrine violated in the stated terms: an escaped exception fencing a generation is neither explicit-and-retryable nor a typed permanent refusal. Secondary, same site: the zero-match case never established "no longer parses uniquely". A head that is an append fragment was never expected to parse standalone, so the message named a cause the code had not proven. ## Solution 1. **Typed, per-key refusal.** New `CohortMembershipRefusalError(logical_source_key, raw_id, reason)` in `ingest_governance`. `_session_for_key` raises it for a parse exception, for zero matches, and for multiple matches, each with the reason actually established. Transient SQLite contention is re-raised rather than converted, mirroring `prepare_raw_census` — contention is not a parse verdict. 2. **Recover per key, not per generation.** `IngestExecution.materialize` catches it around `prepare_cohort`, emits `ingest.membership.refused`, records it, and `continue`s to the next key. The remaining keys publish normally. 3. **The skip is counted.** This is the part that matters: a per-item skip nothing reports would trade a loud failure for a silent one. `IngestTerminalSummaryHistorical` gains `refused_membership_count: int` and a bounded `refused_memberships: list[IngestRefusedMembershipHistorical]` (key, raw id, reason), populated in `historical_receipt`. Two new `IngestHistoricalReceipt` validators make dishonest receipts unconstructable: the count may not fall below its own enumeration, and a receipt may not be `source_complete` while any membership was refused. The refused keys additionally remain visible as incomplete in the `SourceGenerationReceipt` blockers projection, which is computed from durable state and unchanged here. Deliberately **not** changed: `_selector_raw_ids` still admits the revision head unconditionally. Filtering it would silently drop the current accepted head from classification — a silent degradation traded for the loud one. Refusing the key, counted, is the conservative reading. ## Verification ``` devtools test tests/unit/storage/test_ingest_governance.py tests/unit/operations/test_machine_receipts.py tests/unit/daemon/test_daemon_http_contracts.py tests/unit/daemon/test_daemon_status.py devtools test: PASSED exit=0 diagnosis=pytest_passed devtools verify --quick # EXIT=0 ``` Anti-vacuity **verified by reverting**, not asserted. With `_session_for_key` restored to the bare `RuntimeError` and the two receipt validators deleted: ``` E ValueError: synthetic unparseable retained payload E Failed: DID NOT RAISE ValueError E Failed: DID NOT RAISE ValueError FAILED tests/unit/storage/test_ingest_governance.py::test_unparseable_selector_member_is_a_typed_per_key_refusal FAILED tests/unit/operations/test_machine_receipts.py::test_refusal_count_may_not_understate_its_own_enumeration FAILED tests/unit/operations/test_machine_receipts.py::test_refused_memberships_cannot_coexist_with_a_source_complete_claim devtools test: FAILED exit=1 diagnosis=pytest_failed ``` The first line is the defect itself: the raw `ValueError` propagating out of `prepare_ingest_cohort`, which is what reached the generation fence. ## Schema closure `devtools schema closure` on every touched file: ``` out polylogue/storage/ingest_governance.py out polylogue/operations/daemon_ingest.py IN polylogue/operations/machine_receipts.py out tests/unit/storage/test_ingest_governance.py out tests/unit/operations/test_machine_receipts.py ``` **`machine_receipts.py` is IN the closure.** This moves the derived schema identity: it must land **before** the from-scratch rebuild starts, never during one, and it invalidates the seeded fixture cache. ## Residuals - The per-key `continue` in `materialize` is covered only indirectly — by the typed exception it catches and the receipt contract it feeds. There is no end-to-end test driving `execute_ingest_operation` through a refusal to a terminal receipt; the existing suite has no harness for that path. - `prepare_ingest_cohort`'s `convertible` branch still raises two bare `RuntimeError`s with the same fence-the-generation shape. Different route (full-revision retirement), left untouched and unreported by this change. - `refused_memberships` is capped at 256 entries while `refused_membership_count` is uncapped, so a pathological generation reports an honest total with a truncated enumeration. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Summary
Three error-path defects on the route the from-scratch rebuild will run, where a single bad item cost every other input.
Problem and solution
1. An unreachable
FAILEDarm fenced a whole source generation (polylogue-163ku).prepare_raw_censusmodelled parse failure asparsed is None, but the only production callable raises. With aparse_retained_rawthat raisesValueError, the exception escaped tooperations/daemon_ingest.py:662, marking the checkpoint unknown and fencing the generation asrefused.The branch was dead twice over, and the second was only visible once the first was made reachable:
publish_raw_censusforwardedprojections=()alongsidesessions=None, which tripsreplace_raw_membership_census's alignment check — so had the arm ever been entered, it would have raised at publication. Every pre-existing test used a_parse_fromdouble that can only return, so the arm was vacuously "covered". Both are fixed. Transient SQLite contention is re-raised rather than quarantined, so a lock is never recorded as a permanent parse verdict.2. One refused ZIP member aborted its whole input (
polylogue-bwu75).Reproduced with a 4 MiB repetitive
.jsonlmember at deflate ratio 1027.8. The consequence is worse than filed:enumerate_itemonly writescomplete_source_item_enumerationon normal exhaustion, so the trailing raise left the source item permanently unclosed, and every retry re-enumerated to the same raise — terminal, retried forever. Refused members are now skipped and logged; admitted members keep their ordinals.3. Four SQLite lock predicates classified by message text.
convergence_standing_queriestested bare"locked"/"busy"substrings, sono such table: busy_cursorsread as contention — and withfalse_means_pending=Truethe stage deferred a permanent schema error forever.daemon.httpreturned 500 instead of 503 for extendedSQLITE_LOCKED_SHAREDCACHE, stopping client retries. All four now delegate to the existing correct result-code predicate.Verification
plus the focused suite for each touched file, all green.
gate layeringaccepted the changes.Residuals
sources/live/watcher.pycarries a fifth copy of the text-based lock predicate and is deliberately not routed here: it is IN the derived-schema-identity closure, so changing it costs a full reconvergence. That belongs to a change that can pay for it; noted in the commit and onpolylogue-ebjar.Three further findings are filed as design calls rather than fixed, including
polylogue-qoa75(P0):_write_sessionomitsmanage_transaction, so the per-sessionwith conn:commits the batch'sBEGIN IMMEDIATE. Verified directly against sqlite — after the innerwith,in_transactionis False and a second connection sees both rows.🤖 Generated with Claude Code
https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK