Skip to content

test(pipeline): regress the message_type combined-text drift shape - #3629

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/message-type-classification-restamp
Aug 3, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/message-type-classification-restamp

Conversation

@Sinity

@Sinity Sinity commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

Regresses bd polylogue-c831's classification-drift bug shape with a fixture, and completes the bead's remaining operational scope by running the actual production backfill against the live archive.

Problem

polylogue-c831's original evidence: a read-only scan against the live index.db found 1,919 rows still persisted as message_type='message' that the current classifier would flip to context/protocol -- a divergence between ingest-time classification and the backfill's own re-derivation.

The root cause was found and fixed in PR #3525 (merged): classify_text_message_type matches most markers with an anchored str.startswith check, but pre-#3525 Claude Code ingest classified from a combined THINKING+TOOL_RESULT+TEXT string. A marker that starts a message's own TEXT block does not start the combined string once non-empty THINKING/TOOL_RESULT segments are concatenated ahead of it, so the anchored check silently misses it at ingest time. That PR stopped new drift from accumulating but explicitly left two things open: a regression test for the backfill side of the divergence, and the operational backfill run over the already-materialized drifted rows.

Solution

  • Added test_backfill_reclassifies_drifted_row_ignoring_other_block_types (tests/unit/pipeline/test_message_type_backfill.py) with a new fixture (_make_db_with_drifted_mixed_block_message) that reproduces the exact drift shape directly: a message_type='message' row whose persisted TEXT block alone starts with a protocol marker (<bash-input>), alongside marker-free THINKING/TOOL_RESULT blocks, asserting the backfill flips it to protocol from the TEXT block content alone -- proving the existing message_type_backfill machinery (storage/message_type_backfill.py, unchanged by this PR) correctly converges this class of drifted row regardless of other block types on the message.
  • Confirmed the live candidate count with the production count_unclassified_message_type_sync function (not a reimplementation): 1,901 candidates as of 2026-08-03 (down slightly from the bead's original 1,919, consistent with fix(sources): classify Claude Code message_type from TEXT blocks only #3525 having stopped new accumulation and ordinary archive churn since).
  • Ran the actual production backfill against the live archive (/realm/db/polylogue/index.db) using the existing, unmodified _backfill_pass/count_messages_by_type_sync functions, opened via the production open_connection helper (the same code path polylogue doctor --repair --target message_type_backfill exercises). This only touches the messages.message_type column on the index.db tier, which is the rebuildable-by-design tier in the five-tier durability model -- no durable-tier or DDL change involved.
    • Before: message=1,230,456, context=19,600, protocol=40,245 (1,901 candidates)
    • Updated: 1,901 rows
    • After: message=1,228,555, context=19,603, protocol=42,143 (0 candidates)
    • Re-confirmed 0 candidates in a fresh read-only pass after the write.
  • No change to polylogue/ production code in this PR -- the classifier/backfill logic was already correct (delivered by fix(sources): classify Claude Code message_type from TEXT blocks only #3525); this PR is the test-coverage + operational-convergence half of the bead's remaining scope.

Verification

  • devtools test tests/unit/pipeline/test_message_type_backfill.py -- 8 passed (7 pre-existing + 1 new).
  • devtools verify --quick -- exit 0, 23/23 steps green, on the rebased branch.
  • Live production backfill apply + before/after/re-confirm counts as above (polylogued daemon remained healthy throughout; its pre-existing, unrelated schema-version health warning -- source.db:20!=18, index.db:46!=56, part of the separate in-flight differential-reindex program -- was unchanged before and after this write).

Scope notes

Ref polylogue-c831. Not addressed here (out of scope, no evidence of drift found): classify_material_origin's combined-text argument in code_parser.py has the same latent divergence shape for OPERATOR_COMMAND/GENERATED_*_PACK markers, per PR #3525's own notes -- a follow-up would need its own drift measurement first.

Problem: bd polylogue-c831's live production scan found 1,901 candidate
rows still sitting as message_type='message' that the current
classifier would flip to context/protocol. The root cause (found while
fixing this bead, PR #3525) is that classify_text_message_type matches
markers with an anchored str.startswith check, and pre-#3525 Claude Code
ingest classified from a combined THINKING+TOOL_RESULT+TEXT string --
so a marker that starts the message's own TEXT block can fail to start
the combined string once non-empty THINKING/TOOL_RESULT segments are
concatenated ahead of it, leaving the row unclassified at ingest time.

What changed: added a fixture + test
(test_backfill_reclassifies_drifted_row_ignoring_other_block_types)
that reproduces this exact drift shape directly -- a message_type='message'
row whose persisted TEXT block alone starts with a protocol marker,
alongside marker-free THINKING/TOOL_RESULT blocks -- and asserts the
backfill flips it to 'protocol' from the TEXT block content alone.

Verification: devtools test tests/unit/pipeline/test_message_type_backfill.py
(8 passed).
@coderabbitai

coderabbitai Bot commented Aug 3, 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: 7 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: aa83bbec-deda-473d-a206-43baab6bdd01

📥 Commits

Reviewing files that changed from the base of the PR and between 2643c77 and d56eb2a.

📒 Files selected for processing (1)
  • tests/unit/pipeline/test_message_type_backfill.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 merged commit 6678455 into master Aug 3, 2026
2 of 3 checks passed
@Sinity
Sinity deleted the feature/fix/message-type-classification-restamp branch August 3, 2026 10:08
Sinity added a commit that referenced this pull request Aug 3, 2026
6753s (byte-dup supersession, PR #3624), c831 (message_type restamp,
PR #3629, live backfill verified 0 remaining), qhk8z (duplicate-chain
baseline tie-break, PR #3616), ct3r2 + t6iga (merge-gate enforcement,
PR #3607, duplicate beads for the same fix).

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