Skip to content

chore(protocols): prune zero-consumer protocols, fix dangling cursor mapping - #2906

Merged
Sinity merged 1 commit into
masterfrom
feature/chore/prune-zero-consumer-protocols
Jul 14, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/chore/prune-zero-consumer-protocols

Conversation

@Sinity

@Sinity Sinity commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

Re-verified polylogue-a7xr.11's 2026-07-06 claim against current code (a lot has landed since, including PRs #2879/#2882). The protocol-pruning half held up; the kwarg-wrapper/TypedDict-deletion half did not.

  • Deleted 6 protocols from core/protocols.py confirmed to have zero consumers anywhere in the tree: SessionReader, SearchStore, ArchiveMessageQueryStore, SemanticArchiveQueryStore, SessionSemanticStatsStore, SessionArchiveReadStore. Methods that surviving protocols (SessionQueryRuntimeStore, SessionOutputStore, SessionArchiveStatsStore) actually needed are inlined directly instead of inherited from a now-deleted shared base — Protocol conformance is structural, so this changes nothing for real implementers.
  • Not deleted (bead's claim was wrong as of today): RepositoryArchiveQueryMixin.list()/.list_summaries()/.count() and SessionListQueryKwargs/SessionCountQueryKwargs are all alive, with real callers in tests/integration/test_workflows.py, tests/unit/storage/test_query_security.py, and tests/benchmarks/*. Two now-orphaned local commits independently corroborate this — another agent tried the same deletion and reverted it 13 minutes later after mypy caught real **-unpacking breakage.
  • Fixed the cursor field-spec bug the bead named: archive/query/fields.py mapped record_attr="cursor" onto a SessionRecordQuery field that doesn't exist — a latent TypeError waiting for any plan to ever carry a non-None cursor. Dropped the record_attr mapping (cursor still exists at the spec/plan layer) rather than inventing pagination machinery to justify keeping it.

Verification

  • mypy --strict clean across polylogue/ (992 files)
  • devtools test sweep across CLI query/session modules — 1 failure + 22 errors, all independently confirmed present identically on unmodified origin/master (sqlite trigger-already-exists collision, ref-operand-cycle test), zero new failures
  • devtools verify --quick (pre-push gate): exit 0, all 16 steps green

Ref polylogue-a7xr.11

Co-Authored-By: Claude Sonnet 5 [email protected]

…mapping

Ref polylogue-a7xr.11

Re-verified the bead's 2026-07-06 claim against current code (a lot has
landed since, including PRs #2879/#2882). The protocol half held up; the
kwarg-wrapper/TypedDict-deletion half did not.

Deleted 6 protocols from core/protocols.py confirmed to have zero
consumers anywhere in the tree: SessionReader, SearchStore,
ArchiveMessageQueryStore, SemanticArchiveQueryStore,
SessionSemanticStatsStore, SessionArchiveReadStore. Methods that surviving
protocols (SessionQueryRuntimeStore, SessionOutputStore,
SessionArchiveStatsStore) actually needed are inlined directly instead of
inherited from a now-deleted shared base -- Protocol conformance is
structural, so this changes nothing for real implementers, just removes
unused base classes.

NOT deleted (bead's claim was wrong as of today): RepositoryArchiveQueryMixin
.list()/.list_summaries()/.count() and SessionListQueryKwargs/
SessionCountQueryKwargs are all alive, with real callers in
tests/integration/test_workflows.py, tests/unit/storage/test_query_security.py,
and tests/benchmarks/*. Two now-orphaned local commits independently
corroborate this: another agent tried the same deletion and reverted it
13 minutes later after mypy caught real **-unpacking breakage.

Also fixed the cursor field-spec bug the bead named: archive/query/fields.py
mapped record_attr="cursor" onto a SessionRecordQuery field that doesn't
exist, a latent TypeError waiting for any plan to ever carry a non-None
cursor. Dropped the record_attr mapping (cursor still exists at the
spec/plan layer, where it currently has meaning) rather than inventing
pagination machinery to justify keeping it.

Verification: mypy --strict clean across polylogue/ (992 files). devtools
test sweep across CLI query/session modules -- 1 failure + 22 errors, all
independently confirmed present identically on unmodified origin/master
(sqlite trigger-already-exists collision, ref-operand-cycle test), zero
new failures.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GjyDHiwc5QfXGgDMGuFEB8
@coderabbitai

coderabbitai Bot commented Jul 14, 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: 6 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

Run ID: a20feb9f-21ee-4934-a983-9bdd4c420731

📥 Commits

Reviewing files that changed from the base of the PR and between 9461741 and da95b30.

📒 Files selected for processing (2)
  • polylogue/archive/query/fields.py
  • polylogue/core/protocols.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/chore/prune-zero-consumer-protocols

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 b6d851a into master Jul 14, 2026
2 checks passed
@Sinity
Sinity deleted the feature/chore/prune-zero-consumer-protocols branch July 14, 2026 22:16
Sinity added a commit that referenced this pull request Jul 27, 2026
## Summary

Executes polylogue-k7m7: independently re-verify and delete the
~30-symbol dead-code kill-list produced by polylogue-9e5.15's 2026-07-09
vulture+coverage+affordance-usage audit. Every symbol was re-checked
against the current tree (not blindly trusted from a ~2.5-week-old
audit) before deletion.

## Problem

polylogue-9e5.15 intersected three signals (vulture static analysis,
coverage.py 0%-function data, CLI/MCP affordance-usage telemetry) and
manually call-site-verified a ~30-symbol kill-list, documented in
`.agent/handoffs/polylogue-deep-research-2026-07-09/2026-07-09-codebase-structure-audit.md`
section 2. That audit was explicitly split into an audit half (closed)
and an execution half (this PR, polylogue-k7m7) because a lot can land
between finding dead code and deleting it.

## Solution

For every symbol on the list: fresh `rg` call-site search across
`polylogue/`, `tests/`, `docs/`; check for
test/CLI-registration/MCP-registration/generated-doc references; and for
one ambiguous case (a Protocol-declared method), a full-repo `mypy
--strict` run with the symbol removed to empirically confirm no
structural-typing consumer exists.

**Deleted (still genuinely dead):**
- `polylogue/cli/commands/agents.py`: `self_command`, `current_command`,
`conflicts_command`, `overlap_command`, `handoff_command` — 5 untested,
uncalled CLI subcommand wrappers. `agents status`/`agents work-item`
remain; the underlying `CoordinationView` substrate and MCP surface are
untouched, only these CLI aliasing wrappers are gone.
- `polylogue/archive/semantic/models.py`: `to_evidence_input` on all 6
semantic-facts dataclasses (zero call sites anywhere) + the now-unused
`JSONDocument`/`json_document` import.
- `polylogue/archive/query/plan.py`: 8 one-line `SessionQueryPlan`
wrapper methods (`_matches_referenced_path`, `_matches_action_terms`,
`_matches_tool_terms`, `_matches_action_sequence`,
`_matches_action_text_terms`, `_sort_generic`,
`_candidate_record_query_for`, `_search_limit`) that only forwarded to
free functions already called directly by their real callers, plus the
resulting unused imports (`candidate_record_query_for`, `search_limit`,
the `matches_*` family, `sort_generic`, `SortKey`).
- `polylogue/archive/query/expression.py`: `_merge_tuples`,
`_canonicalize_with_units`, `_source_where_unit` (zero callers) + the
unused `terminal_query_unit` import.
- `polylogue/archive/artifact_taxonomy/support.py`: `path_only_sidecars`
(one-line dict-returning wrapper, zero callers;
`path_only_sidecar_reason`, which reads the same dict directly, stays).
- `polylogue/storage/repository/archive/sessions.py`: `get_eager`.

**Skipped — found to have changed since the 2026-07-09 audit (not
deleted):**
- The 3 `cli/query_verbs.py` mark-candidate commands
(`reject`/`defer`/`supersede_mark_candidate_command`) **no longer exist
at all** — already deleted by PR #3138 (2026-07-19), which consolidated
the `mark candidates` subcommand group into the root `judge` command. No
action needed; this half of the audit's finding is stale in a "already
resolved" direction.
- The `polylogue/api/archive.py` half of the audit's "`get_eager` pair"
is also already gone — removed by the #2900 control-center
decomposition. Only the `storage/repository/archive/sessions.py` half
still existed and was deleted above.
- `get_eager` is now declared as a required method on two
`@runtime_checkable` Protocols (`SessionQueryRuntimeStore`,
`SessionOutputStore` in `polylogue/core/protocols.py`), added by PR
#2906 (2026-07-15, after the audit) when those protocols' methods were
inlined from a deleted shared base. This looked exactly like the "grew a
new reference since the audit" case the bead warned about, so I verified
it empirically rather than assuming either way: a full-repo `mypy
--strict` run with the concrete `sessions.py` method removed reports
zero errors, and grepping for `.get_eager(` call sites and
getattr/dynamic-dispatch patterns found none — the two Protocol
declarations themselves are never structurally checked against a real
`SessionRepository` instance anywhere in production code today. I
deleted the concrete method (documented above) but left the two Protocol
declarations untouched (out of this sweep's scope). This leaves the
Protocols describing a method their only real implementer no longer
provides — worth revisiting if `plan_execution.py`/`query_actions.py`
(themselves apparently production-unreferenced, test-only-exercised
query scaffolding using these exact Protocols) are ever wired into a
live call path.

## Verification

- `python -m mypy --strict polylogue` → `Success: no issues found in
1082 source files` (run after every deletion step, including a throwaway
pre-deletion probe specifically for the `get_eager` question).
- `ruff check polylogue` → `All checks passed!`; `ruff format --check
polylogue` → `1082 files already formatted`.
- `devtools test` against the ~40 test files that import the touched
modules: **11 failed, 291 passed**. Confirmed via `git stash` + re-run
against `origin/master` with the identical test-file set that all 11
failures are **pre-existing and unrelated** (same test names, same
assertion messages, same line numbers, with or without this diff).
- `devtools render all --check` → exit 0, no `out of sync` entries
(grepped per the repo's own gotcha about the tail line lying).
- `devtools verify --quick` (pre-push hook) → all 16 steps green (ruff
format/check, mypy, render all, topology, layering, closure-matrix,
schema roundtrip, manifests, ci-workflows, doc-commands, docs-coverage,
test-infra-currency, test-clock-hygiene, pytest-timeout-overrides,
degrade-loudly).

Ref polylogue-k7m7

---------

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