Repository navigation
feat(devtools): add capture-time raw-authority safeguards - #3586
Conversation
|
Warning Review limit reached
Next review available in: 48 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus 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 |
dddd49c to
f5adc66
Compare
…ds4b4)
Problem
polylogue-ds4b4 (raw-authority redesign Phase 3) asked for three things:
proving raw authority at capture time instead of deferring to the async
reconciler, a generalized regression guard against the u19l Codex-header
byte-mutation bug, and a preventive lint against position-derived synthetic
identity in parsers.
Investigation found item 1 already implemented: append_ingest.py's
_ingest_append_plans_archive resolves the byte-contiguous predecessor via
raw_append_revision_parent and, once found, classifies+applies the revision
synchronously in the same ingest call -- there is no code path where a
normal single-predecessor append is left quarantined for the async
RawAuthorityReconciler. A regression test locks this in.
Investigating item 3's "position-derived identity" pattern surfaced a live,
unfixed sibling of the already-fixed polylogue-hith/qkuq attachment-id bug:
message_identity_hash (polylogue/pipeline/ids.py) hashes provider_message_id
directly, and multiple parsers construct that id as f"msg-{index}" when no
provider-native id exists -- unstable across export vintages that reorder
entries, same hazard class as the fixed attachment bug. Filed as
polylogue-gysk3 (fixing it is a separate, higher-risk change; out of scope
here per the bead's own conservative-scope instruction).
What changed
- tests/unit/sources/test_live_batch_support.py: new regression test
proving a normal append gets revision_authority='byte_proven' and is
materialized into index.db in the same ingest call, with zero rows
written to the batch-oriented raw_authority_censuses/_blockers tables
(item 1).
- devtools/verify_raw_payload_hash_purity.py (+ CommandSpec, wired into
devtools verify --quick/--lab): AST lint over the raw-capture write-path
modules forbidding the exact byte-mutation-before-hashing shape that
produced u19l's bug (a synthesized literal concatenated onto captured
bytes before they reach the content hasher). No ack mechanism -- there is
no legitimate exception on this write path (item 2).
- devtools/verify_position_derived_identity.py (+ CommandSpec, wired into
devtools verify --quick/--lab): AST lint over polylogue/sources/parsers/
flagging new position-derived provider_message_id construction (inline or
via a local variable), with an ack-manifest
(docs/plans/position-derived-identity-acks.json) recording the 22
currently-known instances against polylogue-gysk3 (item 3).
Verification
devtools test tests/unit/devtools/test_verify_position_derived_identity.py
tests/unit/devtools/test_verify_raw_payload_hash_purity.py
tests/unit/sources/test_live_batch_support.py -- 91 passed (3 pre-existing
order/parallelism-dependent flakes excluded by -k, confirmed to reproduce
identically on unmodified master via git stash).
devtools verify --quick -- exit 0 (format, lint, mypy --strict, render all
--check, all lab policy checks including the two new ones).
Ref polylogue-ds4b4, polylogue-lb39z, polylogue-u19l, polylogue-hith
Co-Authored-By: Claude <[email protected]>
f5adc66 to
8c4233e
Compare
Summary
Delivers polylogue-ds4b4 (raw-authority redesign Phase 3): a regression test proving raw authority is already proven at capture time for the common append case, a lab-policy lint generalizing the u19l Codex-header byte-mutation fix into a standing guard, and a preventive lint against position-derived synthetic identity in parsers.
Problem
polylogue-ds4b4 asked for three things:
session_metaheader onto captured bytes before hashing, permanently defeating live-source byte-identity verification for ~59GB of raw rows) into a standing regression guard, not just a one-off fix.Solution
Item 1 -- already implemented, now locked in by a test.
append_ingest.py's_ingest_append_plans_archiveresolves the byte-contiguous predecessor viaraw_append_revision_parentand, once found, classifies+applies the revision synchronously in the same ingest call (archive.classify_raw_revision_cohort/apply_raw_revision_replay) -- there is no code path where a normal single-predecessor append is leftquarantinedforRawAuthorityReconcilerto pick up later.test_append_ingest_proves_byte_authority_at_capture_without_reconciler(tests/unit/sources/test_live_batch_support.py) proves: the append raw isrevision_authority='byte_proven'immediately, its content is already inindex.db, and the heavyraw_authority_censuses/raw_authority_blockerstables (owned by the async reconciler) have zero rows.Item 2 --
devtools/verify_raw_payload_hash_purity.py. An AST lint over the raw-capture write-path modules (sources/live/batch.py,batch_support.py,append_ingest.py, the pipeline ingest/acquisition modules,archive_tiers/{archive,revision_governance}.py) forbidding the exact shape that produced u19l's bug: a synthesized literal (bytes/str constant, f-string,json.dumps()/.encode()result) concatenated onto a bare reference before it reaches the content hasher. Confirmed it flags a fixture reproducing the historical bug and passes clean against the current (fixed) code. No ack mechanism -- there is no legitimate exception on this write path. Wired intodevtools lab policy raw-payload-hash-purityanddevtools verify --quick/--lab.Item 3 --
devtools/verify_position_derived_identity.py. Investigated existing parsers first (per the bead's instruction) and found a live, unfixed sibling of the already-fixed polylogue-hith/qkuq attachment-id bug:message_identity_hash(polylogue/pipeline/ids.py) hashesprovider_message_iddirectly, and multiple parsers construct that id asf"msg-{index}"when no provider-native id exists -- unstable across export vintages that reorder entries, the identical hazard class hith/qkuq already fixed for attachments. Filed as polylogue-gysk3 (fixing every existing instance reworks a core identity function used archive-wide -- separate, higher-risk follow-on, not rushed into this PR per the bead's own conservative-scope instruction). Shipped the preventive lint: an AST scan ofpolylogue/sources/parsers/flagging new position-derivedprovider_message_idconstruction (inline or via a local variable, following the dominantmsg_id = ... or f"msg-{idx}"shape), with an ack-manifest (docs/plans/position-derived-identity-acks.json) recording the 22 currently-known instances against polylogue-gysk3. Wired intodevtools lab policy position-derived-identityanddevtools verify --quick/--lab.Item 4 (blob-GC invariant verification against Phase 2's verdict vocabulary) is explicitly blocked on polylogue-w6hql (Phase 2, not yet started) and is not attempted here.
Verification
The 3 excluded tests are pre-existing order/parallelism-dependent flakes, confirmed to reproduce identically against this branch's base with the new files removed (
git stash) -- unrelated to this change, and the exact set PR #3539 already documented as pre-existing.Ref polylogue-ds4b4, polylogue-lb39z, polylogue-u19l, polylogue-hith
🤖 Generated with Claude Code