Skip to content

fix(storage): keep equivalents quarantined-ambiguous when no head is accepted#3255

Merged
Sinity merged 1 commit into
masterfrom
fix/storage/headless-cohort-authority-mislabel
Jul 21, 2026
Merged

fix(storage): keep equivalents quarantined-ambiguous when no head is accepted#3255
Sinity merged 1 commit into
masterfrom
fix/storage/headless-cohort-authority-mislabel

Conversation

@Sinity

@Sinity Sinity commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Summary

When classify_membership_revisions refuses to pick a head (accepted_raw_ids=()), the membership write-back no longer labels equivalent_raw_ids as superseded_equivalent/byte_proven — they collapse back into the unresolved cohort as ambiguous/quarantined.

Problem

Live-archive forensics (Ref polylogue-yla8; report .agent/reports/byte-headless-914-investigation-2026-07-21.md) found 914 logical sources (155,816 max messages) whose memberships read byte_proven/superseded_equivalent yet have no raw_revision_heads row, no application receipt, and no session — supersession authority fabricated for a head that was never written. Introduced by 6a579d0 (#2684, 2026-07-11); the 2026-07-20 rebuild walk amplified it (93% of the cohort decided in one hour).

Solution

One-line gate in apply_raw_membership_classification's decisions construction: equivalents map to superseded_equivalent only when accepted_raw_ids is non-empty. The authority ternary then keeps them quarantined automatically. Comment documents the incident.

Verification

  • devtools test tests/unit/storage/test_revision_replay.py → 23 passed.
  • New test_headless_cohort_keeps_equivalents_quarantined_ambiguous: all-ambiguous cohort with duplicate content → no head row, every member ('ambiguous','quarantined'). Anti-vacuity: with the fix stashed, the test fails (pre-fix labeling) — verified.
  • devtools test tests/unit/storage/test_no_string_interpolated_sql.py (archive.py self-audit) → pass.
  • devtools verify --quick → exit 0.

Note: repairing the existing mislabeled rows on the live archive is a separate coordinator-owned step (re-census after this merges).

Ref polylogue-yla8

🤖 Generated with Claude Code

https://claude.ai/code/session_01QUsH3Rhq6oAZpYPWcsZqnZ

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of conflicting revision branches when no accepted version exists.
    • Keeps affected records marked as ambiguous and quarantined instead of incorrectly treating them as superseded.
  • Tests

    • Added coverage to verify that headless revision groups retain their ambiguous status and do not produce an accepted revision.

…accepted

Problem: apply_raw_membership_classification labels equivalent_raw_ids
superseded_equivalent and promotes them to byte_proven even when
classification.accepted_raw_ids is empty — i.e. when the head/session/
application-receipt write never ran. That fabricates supersession
authority for a head that does not exist. On the 2026-07-20 rebuild walk
this produced 914 logical sources (155,816 max messages) that read as
byte_proven/superseded in raw_session_memberships yet have zero
raw_revision_heads row, zero application receipt, and zero session row
(investigation: .agent/reports/byte-headless-914-investigation-2026-07-21.md).
Introduced by 6a579d0 (#2684).

What changed: with no accepted head, equivalence collapses back into the
unresolved cohort — equivalent members are recorded decision='ambiguous'
and stay revision_authority='quarantined'. Regression test proves an
all-ambiguous cohort with duplicate content writes no head and keeps
every member quarantined-ambiguous; the pre-fix labeling fails it
(verified via stash).

Note: this fix restores honest debt visibility only; re-resolving the
existing mislabeled 914 sources on the live archive is a separate
coordinator repair.

Ref polylogue-yla8

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QUsH3Rhq6oAZpYPWcsZqnZ
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: f933e23e-b00e-405c-aa9c-51b8973ed94c

📥 Commits

Reviewing files that changed from the base of the PR and between 2f3aa34 and f5e31cb.

📒 Files selected for processing (2)
  • polylogue/storage/sqlite/archive_tiers/archive.py
  • tests/unit/storage/test_revision_replay.py

📝 Walkthrough

Walkthrough

The archive now labels equivalent raw memberships as ambiguous when classification produces no accepted raw head. A regression test verifies that headless cohorts persist without an accepted head and retain ambiguous, quarantined membership authority.

Changes

Headless membership classification

Layer / File(s) Summary
Conditional equivalent decision and regression coverage
polylogue/storage/sqlite/archive_tiers/archive.py, tests/unit/storage/test_revision_replay.py
Equivalent raws receive superseded_equivalent only when an accepted head exists; otherwise they remain ambiguous. The test verifies no accepted head is stored and memberships remain ambiguous with quarantined authority.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the PR’s main behavior change.
Description check ✅ Passed The description covers Summary, Problem, Solution, and Verification clearly, with only non-critical sections omitted or folded into notes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/storage/headless-cohort-authority-mislabel

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f5e31cb0f5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

decisions.update(
dict.fromkeys(
classification.equivalent_raw_ids,
"superseded_equivalent" if classification.accepted_raw_ids else "ambiguous",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Count equivalent members in quarantine totals

When a headless cohort contains duplicate content, this branch now quarantines every equivalent_raw_id, but backfill_historical_revision_evidence still increments its quarantine total using only len(classification.ambiguous_raw_ids) at polylogue/sources/revision_backfill.py:863-864. For the new three-member fixture, all three membership rows are quarantined while the result reports only two, so raw_materialization_quarantined_count and the operator-facing repair detail understate the unresolved evidence; include the equivalent IDs in that count when no head is accepted.

Useful? React with 👍 / 👎.

@Sinity

Sinity commented Jul 21, 2026

Copy link
Copy Markdown
Owner Author

Coordinator review: read the full diff. One-line semantic gate at the decisions construction (equivalents map to superseded_equivalent only when an accepted head exists) + incident comment; regression test asserts no-head cohorts stay ('ambiguous','quarantined') for every member, anti-vacuity verified via stash (pre-fix labeling fails it). archive.py self-audit test run explicitly per repo gotcha. Live-archive re-resolution of the 914 mislabeled rows is named as a coordinator follow-up, not claimed. Merging on green quick-gate.

@Sinity
Sinity merged commit adf4ba9 into master Jul 21, 2026
3 checks passed
@Sinity
Sinity deleted the fix/storage/headless-cohort-authority-mislabel branch July 21, 2026 21:57
Sinity added a commit that referenced this pull request Jul 21, 2026
… deploy, blocker critical path)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QUsH3Rhq6oAZpYPWcsZqnZ
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