Repository navigation
test(pipeline): regress the message_type combined-text drift shape - #3629
Conversation
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).
|
Warning Review limit reached
Next review available in: 7 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 (1)
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 |
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]>
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.dbfound 1,919 rows still persisted asmessage_type='message'that the current classifier would flip tocontext/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_typematches most markers with an anchoredstr.startswithcheck, 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
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: amessage_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 toprotocolfrom the TEXT block content alone -- proving the existingmessage_type_backfillmachinery (storage/message_type_backfill.py, unchanged by this PR) correctly converges this class of drifted row regardless of other block types on the message.count_unclassified_message_type_syncfunction (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)./realm/db/polylogue/index.db) using the existing, unmodified_backfill_pass/count_messages_by_type_syncfunctions, opened via the productionopen_connectionhelper (the same code pathpolylogue doctor --repair --target message_type_backfillexercises). This only touches themessages.message_typecolumn on theindex.dbtier, which is the rebuildable-by-design tier in the five-tier durability model -- no durable-tier or DDL change involved.message=1,230,456, context=19,600, protocol=40,245(1,901 candidates)message=1,228,555, context=19,603, protocol=42,143(0 candidates)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.polylogueddaemon 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 incode_parser.pyhas 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.