Repository navigation
fix(storage): widen empty-session repair to catch content-empty phantoms - #3583
Conversation
|
Warning Review limit reached
Next review available in: 19 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 (4)
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 |
3829a55 to
05257a0
Compare
Problem: polylogue-21qj found 6 non-transcript files under watched ~/.claude/projects trees (a sinex analysis-index, a tool-result spill file x3, a workflow journal, a derived duplicate-messages index) had been ingested as claude-code-session rows. Investigation found 5 of the 6 shapes are already refused at detection time by prior work (#3426, #3428, c6190d7, and the pre-existing workflow_journal OriginArtifactRule) -- verified live by rerunning each real file's exact byte content (read from source.db + the blob store, since 2 of 3 sinex files no longer exist on disk) through classify_artifact/detect_provider_evidence. For cleanup, polylogue-ne6k had already built the classifier+dry-run-gated maintenance-repair pattern this bead asked for (repair.py's `empty_sessions` target, wired through `polylogue maintenance repair --target empty_sessions`) -- but scoped to literally message-less sessions (`NOT EXISTS messages`). claude-code-session:conversation_relationships has 96,748 MESSAGE ROWS, every one carrying zero blocks/words, so it fell outside that predicate entirely and was never even a repair candidate. Solution: widen `_empty_session_candidate_ids` (renamed from `_empty_session_message_less_candidates`) to also propose sessions where `sessions.word_count = 0` regardless of message_count. The existing positive-classification gate (`_raw_artifact_positively_fails_classification`) remains the sole deletion authority, so a legitimate all-tool-use session with no text turns is still retained (its raw artifact still carries real Claude Code envelope markers and passes classification). Also added the one missing regression pin: analysis/signal/high_value_ messages.jsonl (the 6th named shape) was already refused via the analysis/ directory heuristic but had no dedicated test using its real field shape (file/timestamp/type/content). That session is deliberately excluded from the empty_sessions purge (word_count=827,894, real content) -- investigation found its real source session is stuck revision_authority='quarantined' and never parsed, so it is currently the archive's only queryable copy of that conversation; deferred to polylogue-6bebe rather than deciding blanket deletion here. Verification: - devtools test tests/unit/storage/test_empty_session_repair_provenance.py tests/unit/sources/test_artifact_taxonomy.py -- 15 passed. New tests pin both the widened-predicate debris case and its "legit all-tool-use" sibling that must NOT be swept in, plus the high_value_messages shape. - devtools verify --quick -- exit 0, all 19 steps green. - Read-only measurement against the live archive (/realm/db/polylogue): before this change, conversation_relationships was absent from `_empty_session_debris_session_ids`'s output; after, it is flagged alongside problems_index/journal/3x toolu_*. Total flagged debris across the archive went from 5023 to 5076 rows (+53, this generalization also catches other same-shaped phantoms, not only the 5 named here). - Pre-existing, unrelated failure noted and NOT fixed here: tests/unit/ maintenance/test_planner_contract.py and test_planner_filter_narrowing.py fail with a TypeError (row_factory not set on a test fixture's index connection) on master (120cf6f) before this change too (confirmed via git stash) -- filed as polylogue-9rdky. Ref polylogue-21qj, polylogue-gvgi (closed as duplicate), polylogue-6bebe, polylogue-9rdky Co-Authored-By: Claude <[email protected]>
05257a0 to
757d5d3
Compare
Summary
Widens
polylogue/storage/repair.py'sempty_sessionsmaintenance-repair target so it also catches sessions that have message rows but zero real content (all-zero-word messages), not only literally message-less sessions. Adds the one missing regression test among 6 named phantom-artifact shapes.Problem
polylogue-21qj found 6 non-transcript files under watched
~/.claude/projectstrees had been ingested asclaude-code-sessionrows in the live archive: a sinex analysis-index (conversation_relationships.jsonl, 96,748 empty messages), a derived duplicate-messages index (high_value_messages.jsonl, 8,763 real duplicate messages), an empty problem-index (problems_index.jsonl), 3x oversized-tool-output spill files (tool-results/toolu_*.json), and a workflow journal (journal.jsonl).Investigating against the live archive (read-only,
/realm/db/polylogue) and the current checkout found 5 of the 6 shapes are already refused at detection time by prior merged work (#3426 self-generatedanalysis/dir guard, #3428looks_like_codeenvelope-marker requirement, c6190d7 letting record content override theanalysis/guard, and the pre-existingworkflow_journalOriginArtifactRule). Verified live: reran each real file's exact byte content (read fromsource.db+ the blob store, since 2 of 3 sinex files no longer exist on disk) throughclassify_artifact/detect_provider_evidence— all returnparse_as_session=False.For cleanup,
polylogue-ne6khad already built exactly the classifier + dry-run-gated actuator pattern this bead asked for (repair.py'sempty_sessionstarget, wired throughpolylogue maintenance repair --target empty_sessions, dry-run by default) — but scoped to literally message-less sessions (NOT EXISTS messages).conversation_relationshipshas 96,748 message rows (every one carrying zero blocks/words), so it fell outside that predicate and was never even a repair candidate.Solution
_empty_session_candidate_ids(renamed from_empty_session_message_less_candidates) to also propose sessions wheresessions.word_count = 0regardless ofmessage_count. The existing positive-classification gate (_raw_artifact_positively_fails_classification) remains the sole deletion authority — a legitimate all-tool-use session with no text turns still passes classification and is retained (pinned bytest_all_empty_content_session_with_legit_raw_is_retained).test_all_empty_content_session_with_phantom_raw_counts_as_debris, pinning that aconversation_relationships-shaped session (many zero-word message rows, relationship-index-shaped raw artifact underanalysis/) is now flagged.test_analysis_signal_duplicate_messages_are_not_a_sessiontotest_artifact_taxonomy.py, the missing regression pin for the 6th named shape (high_value_messages.jsonl's real field shape:file/timestamp/type/content).empty_sessionsmaintenance-target description to reflect the broader predicate.high_value_messages.jsonl(8,763 non-empty messages, 827,894 words) is deliberately excluded from the purge — its content is real duplicated conversation text, and investigation found the real source session (bad69218-...) is stuckrevision_authority='quarantined'and never parsed, so this phantom is currently the archive's only queryable copy of that content. Blanket deletion would be real data loss, not garbage collection. Deferred to polylogue-6bebe.Verification
devtools test tests/unit/storage/test_empty_session_repair_provenance.py tests/unit/sources/test_artifact_taxonomy.py— 15 passed.devtools verify --quick— exit 0, all 19 steps green (also ran again automatically via the pre-push hook).conversation_relationshipswas absent from_empty_session_debris_session_ids's output; after, it is flagged alongside the already-flaggedproblems_index/journal/3xtoolu_*. Total flagged debris across the archive went from 5023 to 5076 rows (+53 — this generalization also catches other same-shaped phantoms archive-wide, not only the 5 named in this bead).tests/unit/maintenance/test_planner_contract.pyandtest_planner_filter_narrowing.pyfail with aTypeError(row_factory not set on a test fixture's index connection) on master (120cf6f) too, confirmed viagit stashbefore this change. Filed as polylogue-9rdky.Ref polylogue-21qj, polylogue-gvgi (closed as duplicate), polylogue-6bebe, polylogue-9rdky