Skip to content

feat(maintenance): write back decided membership verdicts to raw_sessions - #3577

Merged
Sinity merged 2 commits into
masterfrom
feature/feat/raw-membership-writeback-actuator
Aug 2, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/feat/raw-membership-writeback-actuator

Conversation

@Sinity

@Sinity Sinity commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Summary

Adds the "write-back" actuator identified as item 2 of 5 in the 2026-08-02 raw-authority-redesign Phase 1 plan (polylogue-lb39z): propagates already-decided raw_session_memberships verdicts onto raw_sessions.revision_authority, the column the rest of the archive actually reads authority from.

Problem

The membership pipeline (session_revision_membership.classify_membership_revisions) already decides most raw revisions correctly and records the verdict in raw_session_memberships.decision, but nothing propagates that verdict onto raw_sessions.revision_authority. A live, read-only audit measured 15,737 quarantined raw_sessions rows (42.95GB) whose membership row already says applied / superseded_equivalent / superseded_prefix with membership revision_authority='byte_proven' — a decided fact sitting one column away from where the rest of the archive reads authority. This is pure fact transfer, not new judgment: the system already decided.

Solution

A new actuator (polylogue/maintenance/raw_membership_writeback_apply.py) follows the identical safety pattern as the already-merged raw_live_source_reconciliation_apply (polylogue-u19l):

  • Dry-run by default.
  • --apply requires a verified backup manifest for the source tier, validated with the same gate durable-tier schema migrations use.
  • Classification re-runs live inside the same write transaction the promotion runs in, never trusting a stale plan.
  • Every promoted row gets an immutable receipt (new raw_membership_writeback_receipts table, migration 019, source schema v18 -> v19).

The read-only classifier (polylogue/storage/raw_membership_writeback.py) only ever selects a membership row whose decision is in {applied, superseded_equivalent, superseded_prefix} and whose own revision_authority is already 'byte_proven' — never a raw's own unresolved/ambiguous membership row, and never a decision whose membership authority itself is unproven (a real fixture case this PR's tests cover explicitly).

The actuator deliberately never touches predecessor_raw_id / baseline_raw_id / acquisition_generation (owned by classify_raw_revision_cohort) or revision_authority_evidence (a closed vocabulary scoped to live-source-verification promotions) — this is a distinct, independently-verifiable evidence mechanism with its own receipt row.

Registered as devtools workspace raw-membership-writeback-apply.

Explicitly out of scope

Running this actuator against the live archive. That is a separate, later, operator-supervised step requiring a verified backup, exactly like the u19l actuator's own live application. This PR only builds and tests the actuator against synthetic fixtures.

Verification

  • devtools test tests/unit/maintenance/test_raw_membership_writeback_apply.py — 4 passed: dry-run makes zero mutations; apply promotes only decided byte_proven-membership rows while leaving ambiguous / deferred / no-membership-row / membership-itself-unproven rows untouched and revision-graph linkage columns unchanged; refuses without a backup manifest; refuses on an invalid manifest.
  • devtools test tests/unit/storage/test_durable_migrations.py — 40 passed; updated 7 pre-existing hardcoded schema-version-chain assertions to include the new v19 migration.
  • devtools test -k "raw_membership_writeback or raw_revision or revision_governance or migration or schema_versioning" — 80 passed.
  • mypy polylogue devtools (strict) — no issues.
  • devtools lab policy schema-versioning — intact.
  • devtools render all --check — sync OK across all generated surfaces (including docs/devtools.md and docs/plans/topology-target.yaml for the two new modules).
  • ruff check + ruff format --check — clean.
  • Pre-push devtools verify --quick gate — passed.

Ref polylogue-lb39z

@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: 33 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: 58cf6c55-a6ab-4108-ab6e-5e7388e4ffae

📥 Commits

Reviewing files that changed from the base of the PR and between 3161466 and b6cbef5.

📒 Files selected for processing (11)
  • .beads/issues.jsonl
  • devtools/command_catalog.py
  • devtools/raw_membership_writeback_apply.py
  • docs/devtools.md
  • docs/plans/topology-target.yaml
  • polylogue/maintenance/raw_membership_writeback_apply.py
  • polylogue/storage/raw_membership_writeback.py
  • polylogue/storage/sqlite/archive_tiers/source.py
  • polylogue/storage/sqlite/migrations/source/019_raw_membership_writeback_receipts.sql
  • tests/unit/maintenance/test_raw_membership_writeback_apply.py
  • tests/unit/storage/test_durable_migrations.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 and others added 2 commits August 2, 2026 18:58
…ions

Problem: the membership pipeline (session_revision_membership.classify_
membership_revisions) already decides most raw revisions correctly and
records the verdict in raw_session_memberships.decision, but nothing
propagates that verdict onto raw_sessions.revision_authority. A live,
read-only audit (polylogue-lb39z) measured 15,737 quarantined raw_sessions
rows (42.95GB) whose membership row already says applied /
superseded_equivalent / superseded_prefix with membership
revision_authority='byte_proven' -- a decided fact sitting one column
away from where the rest of the archive reads authority from. This is
pure fact transfer, not new judgment.

What changed: a new actuator (polylogue/maintenance/raw_membership_
writeback_apply.py) follows the identical safety pattern as the already-
merged raw_live_source_reconciliation_apply (polylogue-u19l): dry-run by
default; --apply requires a verified backup manifest for the source
tier, validated with the same gate durable-tier schema migrations use;
classification re-runs live inside the same write transaction the
promotion runs in, never trusting a stale plan; every promoted row gets
an immutable receipt (new raw_membership_writeback_receipts table,
migration 019, source schema v18->v19). The read-only classifier
(polylogue/storage/raw_membership_writeback.py) only ever selects a
membership row whose decision is in {applied, superseded_equivalent,
superseded_prefix} AND whose own revision_authority is already
'byte_proven' -- never a raw's own unresolved/ambiguous membership row,
never a decision whose membership authority is itself unproven. The
actuator deliberately never touches predecessor_raw_id / baseline_raw_id
/ acquisition_generation (owned by classify_raw_revision_cohort) or
revision_authority_evidence (a closed vocabulary scoped to
live-source-verification promotions) -- this is a distinct,
independently-verifiable evidence mechanism with its own receipt row.

Registered as `devtools workspace raw-membership-writeback-apply`
(devtools/raw_membership_writeback_apply.py + command_catalog.py entry).

Not done here (explicitly out of scope, per polylogue-lb39z): running
this actuator against the live archive. That is a separate, later,
operator-supervised step requiring a verified backup, exactly like the
u19l actuator's own live application.

Verification: devtools test tests/unit/maintenance/test_raw_membership_writeback_apply.py
(4 passed: dry-run zero-mutation, apply promotes only decided
byte_proven-membership rows while leaving ambiguous/deferred/no-membership/
membership-itself-unproven rows untouched and revision-graph linkage
columns unchanged, refuses without a backup manifest, refuses on an
invalid manifest); devtools test tests/unit/storage/test_durable_migrations.py
(40 passed, updated 7 hardcoded schema-version-chain assertions for the
new v19 migration); devtools test -k "raw_membership_writeback or
raw_revision or revision_governance or migration or schema_versioning"
(80 passed); mypy polylogue devtools --strict (no issues); devtools lab
policy schema-versioning (intact); devtools render all --check (sync OK
across all generated surfaces, including docs/devtools.md and
docs/plans/topology-target.yaml for the two new modules); ruff check +
format (clean).

Ref polylogue-lb39z (Phase 1, item 2 of 5).

Co-Authored-By: Claude <[email protected]>
@Sinity
Sinity force-pushed the feature/feat/raw-membership-writeback-actuator branch from 29c0a17 to b6cbef5 Compare August 2, 2026 17:00
@Sinity
Sinity merged commit f189747 into master Aug 2, 2026
3 checks passed
@Sinity
Sinity deleted the feature/feat/raw-membership-writeback-actuator branch August 2, 2026 17:01
Sinity added a commit that referenced this pull request Aug 2, 2026
…y lint (#3588)

## Summary

Lands items 3 and 4 of polylogue-lb39z's five-item raw-authority Phase 1
program (items 1-2 already merged via PR #3574 and #3577). Both items
are low-risk (read-only classifier + dry-run actuator; static AST lint)
and share the same investigation session, so they land in one PR with
two focused commits rather than two separate PRs.

## Problem

**Item 3**: 2,712 `raw_sessions` rows are `revision_kind='append'`,
`revision_authority='quarantined'`, and have zero
`raw_session_memberships` rows at all -- a genuine fixed point. The only
mechanism that ever promotes an append raw
(`_promote_contiguous_append_evidence`) requires its byte-contiguous
predecessor to already be `byte_proven`; when the predecessor is itself
stuck quarantined, no amount of re-running that cascade reaches the
child.

**Item 4**: polylogue-w32w found
`RawAuthorityFrontierState.UNRESOLVED_PROVENANCE` paired with the
dispatched `RawAuthorityActuator.REFINE_QUARANTINE` -- an actuator no
path (daemon or operator) could ever select. 4,174 blockers accumulated
behind this for weeks undetected. PR #3466 added a runtime constructor
guard (`RawAuthorityFrontierItem.__post_init__`) for the exact shape,
but a constructor guard only fires when something actually constructs
the bad pairing -- w32w's own close note explicitly left this bead's
broader ask (a static lab-policy check) open.

## Solution

**Item 3** (`polylogue/storage/raw_append_chain_backfill.py` +
`polylogue/maintenance/raw_append_chain_backfill_apply.py`): a new
read-only classifier proves each membershipless append row's own claimed
`[append_start_offset:append_end_offset)` byte range directly against
its live source file's current bytes, reusing the exact byte-window
comparison polylogue-u19l's `live_source_reconciliation` module already
validated -- a proof independent of any ancestor's authority. The
actuator follows the identical dry-run-default /
verified-backup-required-to-apply / immutable-receipt pattern as the
merged u19l and lb39z-item-2 actuators, promoting exact matches to
`byte_proven` (reusing the existing `live_source_verification_v1`
evidence value -- the mechanism is identical, only the target population
differs). It deliberately never touches
`predecessor_raw_id`/`baseline_raw_id`/`acquisition_generation`; once a
row is proven, the existing cascade picks it up for free on the next
convergence pass. Adds migration 020 (source schema v19->v20, new
`raw_append_chain_backfill_receipts` table) and `devtools workspace
raw-append-chain-backfill-apply`.

**Item 4** (`devtools/verify_raw_authority_frontier_executability.py`):
statically parses `polylogue/storage/raw_reconciler.py` and enumerates
every literal `(state, actuator)` pair constructible via `_item(...)`
and `_StrategyOverride(...)` call sites (17 pairs on current source; 1
dynamic forwarding site correctly reported informational-only, since its
literal source is separately covered). Each pair is re-checked against
the real `_EXECUTABLE_STATES`/`_APPLY_DISPATCHED_ACTUATORS` imported
directly from `raw_reconciler.py`, so this lint can never drift out of
sync with the actual gate. Wired as `devtools lab policy
raw-authority-frontier-executability`.

## Not in scope / explicitly deferred

Item 5 of polylogue-lb39z (re-classify the ambiguous cohort + wire
`_maximal_evidence_fallback`) is intentionally NOT in this PR -- flagged
in the bead as the highest-risk item, directly touching the
never-retire-an-accepted-head invariant. See the bead notes for a
detailed account of what's needed and why it needs its own dedicated,
unhurried session.

No live archive mutation was performed or attempted. Both actuators are
proven only against synthetic fixtures; live application is a separate,
later, operator-supervised step.

## Verification

- `devtools test tests/unit/storage/test_raw_append_chain_backfill.py
tests/unit/maintenance/test_raw_append_chain_backfill_apply.py` -- 5
passed
- `devtools test tests/unit/storage/test_durable_migrations.py` -- 40
passed (hardcoded v19->v20 migration-chain assertions updated)
- `devtools test
tests/unit/devtools/test_verify_raw_authority_frontier_executability.py`
-- 6 passed, including an anti-vacuity test reproducing the exact
pre-#3466 defect shape in a synthetic fixture and proving the lint
catches it
- `devtools test -k raw_authority` -- 90 passed, 6 failed (confirmed
pre-existing/unrelated: `test_raw_authority_scale_proof.py` /
`test_raw_authority_daemon_health_proof.py`, identical to the prior
lb39z session's findings)
- `devtools test -k raw_materialization` -- 118 passed
- `devtools verify --quick` -- clean (format, lint, mypy --strict,
render all --check, topology projection regenerated)

Ref polylogue-lb39z (Phase 1, items 3 and 4) / polylogue-w32w

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
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