Skip to content

chore(channels): remove confirmed dead code in the messaging channels - #6876

Merged
NicholasRBowers merged 1 commit into
mainfrom
chore/dead-code-channels
Aug 30, 2026
Merged

chore(channels): remove confirmed dead code in the messaging channels#6876
NicholasRBowers merged 1 commit into
mainfrom
chore/dead-code-channels

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

What

Removes five symbols from the messaging-channels group that have zero references anywhere in the repository. 122 deleted lines, 0 added, no behaviour change.

Scope was src/kiro_crew/{slack,discord,telegram,teams,webex,wecom,weixin,whatsapp,imessage,feishu,messaging}/ plus channel.py, channels.py, channel_history.py, channel_transcript_migration.py. Nothing outside that group is touched.

How the candidates were found

Three independent passes, because one scanner is not enough here:

pass method result
1 vulture --min-confidence 60 120 function/class/method findings
2 AST: defined names − (Name-Load ∪ Attribute-attr ∪ str-const ∪ import ∪ kwarg) repo-wide 1714 defs scanned → 23 zero-ref
3 tokenize real NAME tokens repo-wide, def sites subtracted (docstrings/comments cannot register as references) 21 zero-ref

Intersection: 18. Each survivor then went through a five-step confirmation: repo-wide word-boundary sweep across .py .ts .tsx .js .md .json .yml .yaml .toml .sh .ps1 including test/, docs/, system-specs/, builtin_skills/, error-code-baseline.json, config-baseline.json, .github/ and website/src; dynamic-reference sweep (getattr / setattr / globals() / importlib / __all__ / string-form names); action-id routing-table check against slack/interactions.py; public-surface check; and a 30-day introduction gate.

The cross-channel copy-paste risk was real and it caught things. Vulture's largest block — fetch_history / configured_targets / may_send_to across nine transport.py files — is Protocol implementation dispatched through messaging.transport.MessageTransport, not duplicated dead code. Rejected wholesale. The six WhatsApp _on_qr / _on_pair / _on_connected / _on_disconnected / _on_logged_out / _on_ban functions are @client.event(QREv)-registered whatsmeow handlers — the exact event-dispatch trap. Also rejected.

Deleted

symbol location why it is dead, specifically
config_panel slack/blocks.py:94 Unroutable. Emits inline action_id=mc_config_{key} toggles. The router has no == "mc_config_*" branch and no startswith("mc_config") branch. The live config path is the modal view handler register_view_handler("mc_config_panel", ...) reading values["channels_block"]["mc_config_channels"] (interactions.py:220,262) — a different mechanism entirely. First-add 2026-07-16.
agent_buttons slack/blocks.py:203 Unroutable. Emits mc_agent_select_{name} / mc_agent_select_off, but the router matches action_id == "mc_agent_select" by exact equality (interactions.py:859) and the live producer is the static_select at events.py:334. Superseded pre-select-menu implementation. First-add 2026-07-16.
_receipt_finish_cancelled_locked discord/transport_dispatch.py:881 Orphaned member of a live family. The sibling _receipt_flip_locked is called (transport_dispatch.py:808), and teams/webex call self._queue.finish_cancelled_locked(...) directly instead of wrapping it. No dispatch pairing. First-add 2026-07-21.
_history_dashboard_key discord/session_resume.py:123 Superseded by the shared messaging/session_resume.py::history_dashboard_key, which is used (session_resume.py:236) and tested (test/test_teams_sessions.py:858-862). Private copy left behind when the helper was hoisted to messaging/. First-add 2026-07-30.
_options discord/renderer.py:1306 Orphaned by #5716 "give the [OPTIONS:] trailer parse one owner". The 6 grep hits for the name are unrelated _options parameters in website/vite.config.ts, website/electron/test/windows-port.test.js and test/test_platform_compat_coverage.py. _extract_options itself stays — still used at renderer.py:675,831,833. First-add 2026-07-21.

No test companions were deleted — all five have zero references under test/ as well, so nothing had to be rewritten.

Deliberately NOT deleted

Six symbols the scanners flagged and I am holding. Four of them are not cleanup questions at all — they are unwired features whose deadness is itself the defect, and the right fix is wiring, not deletion.

symbol location why held
prompt_allowlist slack/allowlist.py:95 Unwired access control. Zero Python callers, yet docs/system-specs/modules/slack-gateway.md:12,28,231 documents it as live behaviour: "When a user joins a monitored channel, prompt_allowlist() sends Allow/Deny to the owner". Its sibling prompt_track_channel is wired (events.py:62,1429). This is an authorization gate that never fires. Needs a maintainer decision.
confirmation_dialog slack/blocks.py:153 Sole producer of mc_stop_confirm / mc_stop_cancel, both of which have live handlers (interactions.py:724,727). Zero callers ⇒ that confirm flow is currently unreachable. Deleting the builder is behaviour-neutral today but removes the only path to a shipped handler. Wire-or-remove is a product call.
build_subagent_ack_block slack/format.py:315 Byte-identical to build_cron_ack_block, which is called (gateway.py:4633), with the prefix swapped. Sole producer of SUBAGENT_ACK_ACTION_PREFIX, whose handler _handle_subagent_ack is live (interactions.py:687,2077) but therefore unreachable — subagent notifications lost their Acknowledge button. Same wire-or-remove call.
send_message_draft telegram/client.py:876 Complete, working Bot API 9.3+ ephemeral-draft streaming with no production caller. Its only reference is the protocol-conformance stub in test/test_telegram.py:125, so removal is a refactor (rewrite the test double), not a deletion — and dropping a shipped streaming feature is a product decision.
MessageContext slack/handler.py:1351 Design-uncalled facade: handler.py:2607 actively advertises it ("New callers can use MessageContext to group the service parameters"). Deleting it would also mean editing a docstring in slack/handler.py, a hot conflict file.
CallableReactionSink messaging/status_reactions.py:186 Named in docs/system-specs/modules/messaging.md:397, and first-add 2026-08-23 — inside the 30-day new-code gate.

Also held under the 30-day gate: _display (discord/session_resume.py:226, first-add 2026-08-18), and ResumeSurface / post_picker / settle_picker (messaging/session_resume.py, first-add 2026-08-23) which are a Protocol declaration and its method stubs, implemented structurally per channel.

Verification


No linked issue: this is a self-directed cleanup pass over one file group; the #NNNN references above are provenance citations for when a symbol was orphaned, not issues this PR closes.

Five symbols with zero references anywhere in the repository, each confirmed
superseded or orphaned rather than merely un-called by a static scan.

- slack/blocks.py `config_panel` — emits inline `mc_config_{key}` toggles. The
  router has no `== "mc_config_*"` branch and no `startswith("mc_config")`
  branch; the live config path is the modal view handler
  `register_view_handler("mc_config_panel", ...)` reading
  `values["channels_block"]["mc_config_channels"]`. Unroutable.
- slack/blocks.py `agent_buttons` — emits `mc_agent_select_{name}` /
  `mc_agent_select_off`, but the router matches `action_id == "mc_agent_select"`
  by exact equality (interactions.py:859) and the live producer is the
  static_select at events.py:334. Unroutable.
- discord/transport_dispatch.py `_receipt_finish_cancelled_locked` — orphaned
  member of a live family: the sibling `_receipt_flip_locked` IS called
  (transport_dispatch.py:808), while teams/webex call
  `self._queue.finish_cancelled_locked(...)` directly rather than wrapping it.
- discord/session_resume.py `_history_dashboard_key` — superseded by the shared
  `messaging/session_resume.py::history_dashboard_key`, which is used at
  session_resume.py:236 and tested in test/test_teams_sessions.py.
- discord/renderer.py `_options` — orphaned by #5716, which gave the
  `[OPTIONS:]` trailer parse one owner. `_extract_options` remains used at
  renderer.py:675, 831, 833.

No test companions to delete: all five have zero references under test/ too.
No behaviour change — none of the deleted code was reachable.

Held back deliberately (reported in the PR body): prompt_allowlist,
confirmation_dialog, build_subagent_ack_block, send_message_draft,
MessageContext, CallableReactionSink.
@iamwhatever
iamwhatever requested a review from a team as a code owner August 29, 2026 23:23
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Aug 29, 2026
@github-actions

github-actions Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 3c9bb917f7b887d8e8de8c30dd82b445323ca887 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 3c9bb91

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 3c9bb917f7b887d8e8de8c30dd82b445323ca887: <one-sentence reason>

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of 3c9bb917f7b887d8e8de8c30dd82b445323ca887 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

All verified: the four deleted names have zero references repo-wide, _extract_options retains its live callers, and the router's mc_agent_select exact-match / mc_config_panel view-handler claims check out against interactions.py. The diff is exactly the five described deletions (122 lines, no additions), all internal symbols with no public surface, trivially revertible.

Design-Verdict: PASS

Verified pure dead-code removal — every zero-reference claim checks out against the repo, and the held-back unwired features are correctly left for a product decision.

[DESIGN-REVIEWED] 3c9bb91

@github-actions

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed 3c9bb917f7b887d8e8de8c30dd82b445323ca887 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 3c9bb91

Verdict parsed from the review's SHA-scoped output markers for commit 3c9bb917f7b887d8e8de8c30dd82b445323ca887.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 3c9bb917f7b887d8e8de8c30dd82b445323ca887: <one-sentence reason>

@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of 3c9bb917f7b887d8e8de8c30dd82b445323ca887 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

All verification complete — every claimed zero-reference deletion checked out under my own greps, deleted symbols' callees retain live callers, and the shared replacement for the deleted duplicate exists and is tested. Final review:

First-Principles-Verdict: PASS

Pure subtraction: five symbols with independently verified zero references removed, nothing added, no capability a user or component could reach is lost.

What this change ships

Intent: shrink the messaging-channels code surface by deleting confirmed-dead symbols — a FIX (of accumulated dead surface), 122 lines deleted, 0 added.

  1. Unroutable Slack config-toggle builder removed (config_panel) — justified; only greps for the name are the distinct mc_config_panel modal string, and no router branch matches its mc_config_{key} ids.
  2. Superseded Slack agent-select button builder removed (agent_buttons) — justified; 0 references; router at interactions.py:859 matches mc_agent_select by exact equality, so its suffixed ids never routed.
  3. Discord cancelled-receipt wrapper removed (_receipt_finish_cancelled_locked) — justified; 0 references; the wrapped finish_cancelled_locked keeps 3 live callers (teams, webex, messaging/commands.py:130).
  4. Discord private copy of the dashboard-key helper removed (_history_dashboard_key) — justified; 0 references; the shared messaging/session_resume.py:159 version is live (:236) and tested.
  5. Discord _options helper removed — justified; 0 references (self._options matches only webex's unrelated _options_card); its callee _extract_options keeps 3 discord callers.

All counts above are greps I ran, not the author's. The description's held-back list (unwired features like prompt_allowlist, confirmation_dialog) is correctly deferred: their deadness is a wiring defect, out of scope for a deletion pass, and the author enumerated them rather than deleting silently.

[FIRST-PRINCIPLES-REVIEWED] 3c9bb91

@bolichen97
bolichen97 enabled auto-merge August 29, 2026 23:43
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Aug 29, 2026

@chenmingwei23 chenmingwei23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tier 1 auto-approve: chore/refactor (4 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean (Semgrep+CodeQL success, 0 annotations, 0 open alerts), security checklist all-NO, AI reviewers green. Category: removes confirmed dead helper functions (_options, _history_dashboard_key, _receipt_finish_cancelled_locked, config_panel, agent_buttons) in the messaging channels, pure deletion with no behavior change.

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tier 1 auto-approve: refactor (4 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: dead-code removal only (pure deletions, -122 lines); all four deleted symbols (config_panel, agent_buttons, _history_dashboard_key, _receipt_finish_cancelled_locked) verified unreferenced on current main — remaining config_panel search hits are the unrelated mc_config_panel callback-id string.

@NicholasRBowers
NicholasRBowers merged commit 900615d into main Aug 30, 2026
74 of 76 checks passed
@NicholasRBowers
NicholasRBowers deleted the chore/dead-code-channels branch August 30, 2026 00:27
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Aug 30, 2026

@NicholasRBowers NicholasRBowers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tier 1 auto-approve: chore (4 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: deletion-only dead-code removal (unused Discord renderer/_options helper, unused history-key and cancelled-receipt helpers, unused Slack config_panel/agent_buttons block builders); no remaining references verified by full-tree grep (mc_config_panel string matches are an unrelated callback id), no runtime impact; already human-APPROVED.

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.

4 participants