Repository navigation
fix: Count a refused membership cohort instead of fencing its generation - #5129
Conversation
`_session_for_key` raised an untyped `RuntimeError("... no longer parses
uniquely")` for any selector member it could not resolve. That escaped
`prepare_ingest_cohort` into `execute_ingest_operation`'s
`except Exception: fence("refused")`, so one unparseable selector member --
notably the unconditionally-admitted `raw_revision_head_raw_id`, which
carries no revision_kind filter -- cost every other logical key in the
source generation. The message also named a cause the zero-match case never
established.
Every failure there is now a typed `CohortMembershipRefusalError` carrying
the logical key, raw id, and the reason actually established. `materialize`
records it and continues with the remaining keys; transient SQLite
contention still propagates so the cohort is re-prepared rather than
quarantined.
The skip is counted, not silent: `IngestTerminalSummaryHistorical` gains
`refused_membership_count` plus a bounded `refused_memberships` list, and
`IngestHistoricalReceipt` refuses to be `source_complete` while any
membership was refused or to carry a count below its own enumeration.
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 47 seconds. 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 (5)
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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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_keyraised a bareRuntimeError(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_cohortcalls it once per selector member, and_selector_raw_idsadmitsarchive.raw_revision_head_raw_id(logical_source_key)unconditionally — norevision_kind/source_index/ census filter, unlike its siblingraw_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_sessionsis typed-> list[ParsedSession]and raises rather than returningNone).Wrong observable outcome at the reviewed head: the exception escapes
prepare_ingest_cohort, out ofIngestExecution.materialize, toexecute_ingest_operation'sexcept 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
CohortMembershipRefusalError(logical_source_key, raw_id, reason)iningest_governance._session_for_keyraises 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, mirroringprepare_raw_census— contention is not a parse verdict.IngestExecution.materializecatches it aroundprepare_cohort, emitsingest.membership.refused, records it, andcontinues to the next key. The remaining keys publish normally.IngestTerminalSummaryHistoricalgainsrefused_membership_count: intand a boundedrefused_memberships: list[IngestRefusedMembershipHistorical](key, raw id, reason), populated inhistorical_receipt. Two newIngestHistoricalReceiptvalidators make dishonest receipts unconstructable: the count may not fall below its own enumeration, and a receipt may not besource_completewhile any membership was refused. The refused keys additionally remain visible as incomplete in theSourceGenerationReceiptblockers projection, which is computed from durable state and unchanged here.Deliberately not changed:
_selector_raw_idsstill 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
Anti-vacuity verified by reverting, not asserted. With
_session_for_keyrestored to the bareRuntimeErrorand the two receipt validators deleted:The first line is the defect itself: the raw
ValueErrorpropagating out ofprepare_ingest_cohort, which is what reached the generation fence.Schema closure
devtools schema closureon every touched file:machine_receipts.pyis 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
continueinmaterializeis covered only indirectly — by the typed exception it catches and the receipt contract it feeds. There is no end-to-end test drivingexecute_ingest_operationthrough a refusal to a terminal receipt; the existing suite has no harness for that path.prepare_ingest_cohort'sconvertiblebranch still raises two bareRuntimeErrors with the same fence-the-generation shape. Different route (full-revision retirement), left untouched and unreported by this change.refused_membershipsis capped at 256 entries whilerefused_membership_countis uncapped, so a pathological generation reports an honest total with a truncated enumeration.🤖 Generated with Claude Code
https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK