Skip to content

feat(devtools): add capture-time raw-authority safeguards - #3586

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/raw-authority-capture-time-safeguards
Aug 2, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/raw-authority-capture-time-safeguards

Conversation

@Sinity

@Sinity Sinity commented Aug 2, 2026

Copy link
Copy Markdown
Owner

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:

  1. Prove raw authority at capture time instead of deferring to the async reconciler, at least for the common case.
  2. Generalize the u19l fix (Codex append captures used to splice a synthetic session_meta header 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.
  3. Add a schema-lint rule flagging position-derived synthetic identity in parser code, checking existing parsers for a concrete instance first.

Solution

Item 1 -- already implemented, now locked in by a test. 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 (archive.classify_raw_revision_cohort / apply_raw_revision_replay) -- there is no code path where a normal single-predecessor append is left quarantined for RawAuthorityReconciler to 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 is revision_authority='byte_proven' immediately, its content is already in index.db, and the heavy raw_authority_censuses/raw_authority_blockers tables (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 into devtools lab policy raw-payload-hash-purity and devtools 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) 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, 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 of polylogue/sources/parsers/ flagging new position-derived provider_message_id construction (inline or via a local variable, following the dominant msg_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 into devtools lab policy position-derived-identity and devtools 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

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 \
  -k "not (test_full_ingest_skips_durably_excised_content_without_aborting_batch or test_append_multi_session_payload_is_rejected_before_index_write or test_full_ingest_writes_archive_with_route_observability)"
# 91 passed

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.

devtools verify --quick
# exit 0 -- format, lint, mypy --strict, render all --check, all lab policy
# checks including the two new ones (raw-payload-hash-purity,
# position-derived-identity)

Ref polylogue-ds4b4, polylogue-lb39z, polylogue-u19l, polylogue-hith

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 48 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: cebb55ca-cdb4-4993-afd6-30f4504bd069

📥 Commits

Reviewing files that changed from the base of the PR and between b4db9eb and 8c4233e.

📒 Files selected for processing (9)
  • devtools/command_catalog.py
  • devtools/verify.py
  • devtools/verify_position_derived_identity.py
  • devtools/verify_raw_payload_hash_purity.py
  • docs/devtools.md
  • docs/plans/position-derived-identity-acks.json
  • 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

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 force-pushed the feature/fix/raw-authority-capture-time-safeguards branch from dddd49c to f5adc66 Compare August 2, 2026 20:05
…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]>
@Sinity
Sinity force-pushed the feature/fix/raw-authority-capture-time-safeguards branch from f5adc66 to 8c4233e Compare August 2, 2026 20:45
@Sinity
Sinity merged commit 1644247 into master Aug 2, 2026
3 checks passed
@Sinity
Sinity deleted the feature/fix/raw-authority-capture-time-safeguards branch August 2, 2026 20:50
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