refactor: delete confirmed-dead code sweep (8 beads) + correct CLAUDE.md drift - #3594
Conversation
….md drift Deletes 34 functions across 30 files, each independently re-verified (fresh rg whole-word grep, not just trusting the audit that flagged them) to have zero production or test callers before removal. Cascading orphans created by earlier deletions (e.g. removing query_archive_context_image left archive_context_image_summary/dedupe_archive_context_image_rows/ archive_context_image_filters/ArchiveContextImageFilters with no callers) were traced and removed in the same pass, along with the imports they stranded. Two candidates were investigated and NOT deleted after re-verification: - storage/repair.py's stale-supersession-receipt trio initially looked scaffolded for polylogue-ktwa, but ktwa's close reason confirms its real fix landed as different functions (raw_retention.py's plan_stale_supersession_reissue/reissue_stale_supersession_receipts) -- this trio is genuinely superseded, safe to delete. - fts_lifecycle.py's restore_fts_triggers_async was flagged as a possible bug (its sibling suspend_fts_triggers_async "IS called live"). Re-checked: suspend_fts_triggers_async has ZERO callers too -- the audit's claim was wrong. Only the SYNC variants (suspend_fts_triggers_sync + rebuild_fts_index_sync) are used in production. Both async functions deleted; no bug, just an unused duplicate of the sync path. CLAUDE.md correction (polylogue-enium): its Lineage normalization paragraph named resolve_session_links_for_session as THE session_links resolver, but that function has no production caller -- only two unit tests exercise it. The real resolver is _resolve_session_graph/_resolve_outbound_session_links in storage/sqlite/archive_tiers/write.py (confirmed by a separate audit this session: single choke point, used identically by live ingest and reindex). Left the actual async function undeleted -- it's also exercised by tests/property/test_write_path_state_machine.py, which needs more care than a mechanical sweep; the doc fix is enium's core deliverable regardless. Verification: devtools test across every affected test directory (storage, mcp, schemas, cli, daemon, insights, rendering, ui, core, sinex, archive, pipeline, context) -- 4354 passed, 11 pre-existing failures confirmed unrelated (each touched file's diff is a pure deletion of a function with zero callers; none of the 11 failing tests exercise anything in this diff). devtools verify --quick exit 0. Ref polylogue-aedgk, polylogue-ply88, polylogue-6pnmt, polylogue-soejd, polylogue-xi3bs, polylogue-44dzt, polylogue-f4ygq, polylogue-nlojm, polylogue-enium Co-Authored-By: Claude <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe change removes unused helpers and imports across archive, CLI, storage, schema, pipeline, and UI modules. Archive prompt construction now uses bounded reads. Session-link documentation identifies the production resolution path. ChangesArchive reads and helper cleanup
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@polylogue/context/selection.py`:
- Around line 13-15: Remove the Any-based typing from
select_context_image_sessions and keep its query result strongly typed using the
existing session type, or define a narrow Protocol containing the fields
consumed by this module. Update the callback/result annotation and related
imports so mypy --strict validates the boundary without broad Sequence[Any] or
other type-checking bypasses.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: f58b1718-715d-4adc-90e6-5f38070c0258
📒 Files selected for processing (31)
CLAUDE.mdpolylogue/archive/provider/semantics.pypolylogue/archive/semantic/pricing.pypolylogue/cli/archive_query.pypolylogue/cli/click_option_groups.pypolylogue/cli/commands/check.pypolylogue/cli/shared/check_support.pypolylogue/cli/shared/types.pypolylogue/context/selection.pypolylogue/core/dates.pypolylogue/daemon/backup.pypolylogue/daemon/status.pypolylogue/insights/transforms.pypolylogue/mcp/server_prompts.pypolylogue/pipeline/ids.pypolylogue/rendering/core_markdown.pypolylogue/schemas/generation/archive_workload_profile.pypolylogue/schemas/generation/packages.pypolylogue/schemas/operator/workflow.pypolylogue/sinex/material_adapter.pypolylogue/storage/artifacts/inspection.pypolylogue/storage/blob_integrity.pypolylogue/storage/blob_repair.pypolylogue/storage/derived/insights.pypolylogue/storage/fts/fts_lifecycle.pypolylogue/storage/insights/feedback/__init__.pypolylogue/storage/insights/session/storage.pypolylogue/storage/repair.pypolylogue/storage/sqlite/archive_tiers/archive.pypolylogue/storage/sqlite/archive_tiers/user_write.pypolylogue/ui/theme.py
💤 Files with no reviewable changes (28)
- polylogue/storage/insights/session/storage.py
- polylogue/archive/provider/semantics.py
- polylogue/schemas/generation/packages.py
- polylogue/insights/transforms.py
- polylogue/storage/derived/insights.py
- polylogue/storage/blob_repair.py
- polylogue/storage/blob_integrity.py
- polylogue/core/dates.py
- polylogue/daemon/backup.py
- polylogue/storage/artifacts/inspection.py
- polylogue/storage/insights/feedback/init.py
- polylogue/archive/semantic/pricing.py
- polylogue/cli/commands/check.py
- polylogue/sinex/material_adapter.py
- polylogue/storage/fts/fts_lifecycle.py
- polylogue/cli/shared/types.py
- polylogue/mcp/server_prompts.py
- polylogue/daemon/status.py
- polylogue/storage/sqlite/archive_tiers/user_write.py
- polylogue/cli/archive_query.py
- polylogue/cli/click_option_groups.py
- polylogue/storage/sqlite/archive_tiers/archive.py
- polylogue/rendering/core_markdown.py
- polylogue/storage/repair.py
- polylogue/cli/shared/check_support.py
- polylogue/schemas/generation/archive_workload_profile.py
- polylogue/ui/theme.py
- polylogue/schemas/operator/workflow.py
| from typing import TYPE_CHECKING, Any | ||
|
|
||
| from polylogue.core.timestamps import parse_archive_datetime | ||
| from polylogue.mcp.archive_support import archive_index_active_paths, archive_query_filters | ||
| from polylogue.storage.sqlite.archive_tiers.archive import ( | ||
| ArchiveSessionSearchHit, | ||
| ArchiveSessionSummary, | ||
| ArchiveStore, | ||
| ) | ||
| from polylogue.mcp.archive_support import archive_index_active_paths |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Keep the query result boundary strongly typed.
This change introduces Any, which makes the retained select_context_image_sessions query result untyped. Use the existing session type or define a small protocol for the fields consumed by this module instead of widening the callback to Sequence[Any].
As per coding guidelines, **/*.py must use strict typing with mypy --strict; do not bypass type and identifier checks.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@polylogue/context/selection.py` around lines 13 - 15, Remove the Any-based
typing from select_context_image_sessions and keep its query result strongly
typed using the existing session type, or define a narrow Protocol containing
the fields consumed by this module. Update the callback/result annotation and
related imports so mypy --strict validates the boundary without broad
Sequence[Any] or other type-checking bypasses.
Source: Coding guidelines
Summary
Mechanical dead-code deletion sweep covering 8 beads filed by a read-only audit earlier this session, plus a CLAUDE.md correction (polylogue-enium).
Problem
A broad dead-code audit found 34 functions across the repo with zero production or test callers (fresh
rgwhole-word grep, one occurrence = the def line itself). Left in place, they're maintenance burden and misleading (several docstrings claim usage that doesn't hold, e.g._list_corrections_sequence_typedclaimed "type-only helper used in tests" with zero test references).Solution
For each candidate, re-verified the dead-code claim fresh (the audit ran a few hours before this PR — code may have shifted) before deleting. Two candidates were investigated and not deleted after re-verification found the audit's premise didn't hold:
storage/repair.py's stale-supersession-receipt trio referencedpolylogue-ktwain its docstring. Checked ktwa's close reason: its real fix landed as different functions inraw_retention.py. This trio is genuinely superseded — confirmed safe to delete.fts_lifecycle.py'srestore_fts_triggers_asyncwas flagged as a possible real bug (its siblingsuspend_fts_triggers_async"IS called live" per the audit). Re-checked:suspend_fts_triggers_asynchas zero callers too — the audit's claim was wrong. Only the sync variants are used in production. No bug; deleted both async functions as an unused duplicate pair.Deleting
query_archive_context_imagecascaded: it leftarchive_context_image_summary/dedupe_archive_context_image_rows/archive_context_image_filters/ArchiveContextImageFilterswith no remaining callers. Traced and removed all four in the same pass, along with the imports they stranded.CLAUDE.md correction (polylogue-enium): the "Lineage normalization" paragraph named
resolve_session_links_for_sessionas thesession_linksresolver, but it has no production caller — only two unit tests exercise it. The real resolver is_resolve_session_graph/_resolve_outbound_session_linksinstorage/sqlite/archive_tiers/write.py(confirmed by a separate audit this session: single choke point, used identically by live incremental ingest and full reindex). Left the actual async function undeleted —tests/property/test_write_path_state_machine.pyalso exercises it, which needs more care than a mechanical sweep; the doc fix is enium's core deliverable regardless.Verification
devtools testacross every affected test directory (storage, mcp, schemas, cli, daemon, insights, rendering, ui, core, sinex, archive, pipeline, context): 4354 passed, 11 pre-existing failures confirmed unrelated — every touched file's diff is a pure deletion of a function with zero callers, and none of the 11 failing tests exercise anything in this diff (checked eachgit diffagainst the failing test's actual assertion).devtools verify --quick: exit 0.Ref polylogue-aedgk, polylogue-ply88, polylogue-6pnmt, polylogue-soejd, polylogue-xi3bs, polylogue-44dzt, polylogue-f4ygq, polylogue-nlojm, polylogue-enium
Summary by CodeRabbit
Documentation
Refactor