Skip to content

refactor: delete confirmed-dead code sweep (8 beads) + correct CLAUDE.md drift - #3594

Merged
Sinity merged 1 commit into
masterfrom
chore/dead-code-sweep-2026-08-03
Aug 2, 2026
Merged

refactor: delete confirmed-dead code sweep (8 beads) + correct CLAUDE.md drift#3594
Sinity merged 1 commit into
masterfrom
chore/dead-code-sweep-2026-08-03

Conversation

@Sinity

@Sinity Sinity commented Aug 2, 2026

Copy link
Copy Markdown
Owner

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 rg whole-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_typed claimed "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 referenced polylogue-ktwa in its docstring. Checked ktwa's close reason: its real fix landed as different functions in raw_retention.py. This trio is genuinely superseded — confirmed safe to delete.
  • fts_lifecycle.py's restore_fts_triggers_async was flagged as a possible real bug (its sibling suspend_fts_triggers_async "IS called live" per the audit). Re-checked: suspend_fts_triggers_async has 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_image cascaded: it left archive_context_image_summary/dedupe_archive_context_image_rows/archive_context_image_filters/ArchiveContextImageFilters with 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_session as the session_links resolver, but it 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 incremental ingest and full reindex). Left the actual async function undeleted — tests/property/test_write_path_state_machine.py also exercises it, 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 — 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 each git diff against 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

    • Clarified session-link resolution behavior and distinguished production functionality from test support.
  • Refactor

    • Simplified archive, search, rendering, schema, storage, repair, and UI components by removing obsolete functionality.
    • Streamlined prompt session retrieval with paginated archive reads, ISO timestamps, and a 4,000-character message limit.
    • Consolidated existing data-processing and token-usage paths without changing supported workflows.
    • Removed several unused public utilities and internal helpers to reduce maintenance overhead.

….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>
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The 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.

Changes

Archive reads and helper cleanup

Layer / File(s) Summary
Archive query and prompt read paths
CLAUDE.md, polylogue/archive/provider/semantics.py, polylogue/cli/archive_query.py, polylogue/context/selection.py, polylogue/mcp/server_prompts.py
Removed unused archive query and context-image helpers. Archive prompt sessions now read summaries and bounded messages, limit text to 4000 characters, and convert timestamps to ISO format.
CLI and runtime helper cleanup
polylogue/cli/click_option_groups.py, polylogue/cli/commands/check.py, polylogue/cli/shared/check_support.py, polylogue/cli/shared/types.py, polylogue/daemon/status.py, polylogue/ui/theme.py
Removed unused loaders, check-command wrappers, metric formatting, lazy UI construction, status formatting, and WebUI theme token helpers.
Storage and repair helper cleanup
polylogue/storage/repair.py, polylogue/storage/sqlite/archive_tiers/*, polylogue/storage/artifacts/inspection.py, polylogue/storage/blob_integrity.py, polylogue/storage/blob_repair.py, polylogue/storage/fts/fts_lifecycle.py, polylogue/storage/derived/insights.py, polylogue/storage/insights/*
Removed obsolete repair, archive-tier, blob, inspection, FTS, derived-status, feedback, and session-storage helpers.
Domain and pipeline helper cleanup
polylogue/archive/semantic/pricing.py, polylogue/insights/transforms.py, polylogue/pipeline/ids.py, polylogue/schemas/generation/*, polylogue/schemas/operator/workflow.py, polylogue/sinex/material_adapter.py
Removed unused pricing, message-fragment, event-ID, schema-generation, annotation-summary, and block-fidelity helpers.

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

Possibly related PRs

Suggested labels: type:refactor, area:storage

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the dead-code deletion sweep and the CLAUDE.md documentation correction.
Description check ✅ Passed The description covers the summary, problem, solution, verification, affected scope, and rationale; omitted changelog and risk sections are acceptable for this refactor.
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 chore/dead-code-sweep-2026-08-03

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.

@coderabbitai coderabbitai 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1570354 and 7b072f4.

📒 Files selected for processing (31)
  • CLAUDE.md
  • polylogue/archive/provider/semantics.py
  • polylogue/archive/semantic/pricing.py
  • polylogue/cli/archive_query.py
  • polylogue/cli/click_option_groups.py
  • polylogue/cli/commands/check.py
  • polylogue/cli/shared/check_support.py
  • polylogue/cli/shared/types.py
  • polylogue/context/selection.py
  • polylogue/core/dates.py
  • polylogue/daemon/backup.py
  • polylogue/daemon/status.py
  • polylogue/insights/transforms.py
  • polylogue/mcp/server_prompts.py
  • polylogue/pipeline/ids.py
  • polylogue/rendering/core_markdown.py
  • polylogue/schemas/generation/archive_workload_profile.py
  • polylogue/schemas/generation/packages.py
  • polylogue/schemas/operator/workflow.py
  • polylogue/sinex/material_adapter.py
  • polylogue/storage/artifacts/inspection.py
  • polylogue/storage/blob_integrity.py
  • polylogue/storage/blob_repair.py
  • polylogue/storage/derived/insights.py
  • polylogue/storage/fts/fts_lifecycle.py
  • polylogue/storage/insights/feedback/__init__.py
  • polylogue/storage/insights/session/storage.py
  • polylogue/storage/repair.py
  • polylogue/storage/sqlite/archive_tiers/archive.py
  • polylogue/storage/sqlite/archive_tiers/user_write.py
  • polylogue/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

Comment on lines +13 to +15
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 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

@Sinity
Sinity merged commit 64b2d83 into master Aug 2, 2026
3 checks passed
@Sinity
Sinity deleted the chore/dead-code-sweep-2026-08-03 branch August 2, 2026 23:37
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