refactor(backend): remove dead modules and the 14 vulture hits (#2493) - #2500
Merged
Conversation
…-move schema shims, scripts/poc, and 14 vulture hits (#2493) Every item re-verified before removal; two of the fourteen vulture hits turned out NOT to be dead and were fixed by making the liveness visible instead of deleting it: - utils/errors.py (126 lines, zero importers for eight months) deleted; grep for utils.errors/SafeHTTPException/log_and_raise is empty. - client_portal/schema.py + shared_sessions/schema.py deleted. Their callers were seven TEST sites — replaced by ONE test-side applier, tests/conftest.py::ensure_schema_tables(*names), over the canonical db/schema.py DDL (Invariant #3; index statements matched by table name, the shims' own drift rationale). ent#443's helper-owns-no-DDL guard repoints at the conftest helper so the drift rule survives the shim it was written about. (Placed in tests/conftest.py, not tests/unit/conftest.py — 'from conftest import' resolves to the parent, the stubbed_modules precedent.) - scripts/poc/ (3 files) deleted outright; git history is the archive. - vulture ≥80% now reports ZERO with no suppressions: * 5 genuinely unused imports dropped (pop_frames, get_portal_identity, SlackOAuthInitResponse, PageBreak, and event_bus's RedisResponseError try/except pair — the name was never read after binding). * exc_type/tb in three __exit__/__aexit__ signatures are PROTOCOL parameters, not sys.exc_info() unpacking as the issue guessed — renamed to _-prefixed (idiomatic unused-arg, not a linter directive). * Coroutine in task_execution_service was NOT dead: it is read by a string annotation vulture cannot see. Unquoted the annotation. * settings_service's NON_ROW_RETENTION_OPS_KEYS re-export was NOT dead either — two tests imported it there. Repointed them at config (the true home) and dropped the re-export. * _perform_auto_switch's old_subscription_id parameter removed with its one production call site and six test call sites (all keyword). 497 tests across every touched suite pass; full unit run in CI. Closes #2493 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NLfHNPtB5UCMk4LonZiJux
The residual grep that cleared the shim removal was piped through head -3 and truncated past the conftest lines — the exhaustive rerun found tests/unit/test_ent220_chain_shield_and_residuals.py (14 tests, all erroring at collection in CI's regression diff). Rewired to the shared conftest applier like its six sibling files. Related to #2493 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NLfHNPtB5UCMk4LonZiJux
obasilakis
approved these changes
Sep 2, 2026
obasilakis
left a comment
Contributor
There was a problem hiding this comment.
/validate-pr: APPROVE
Deletions map 1:1 to the issue's five ACs, and the two "not dead" items were correctly reclassified rather than deleted.
Dead-code verification — the failure mode that actually matters here — is clean. Greps run against the PR head ref:
utils.errors/SafeHTTPException/log_and_raise/safe_error_message/init_client_portal_schema/init_shared_sessions_schema/client_portal.schema/shared_sessions.schema/PageBreak/RedisResponseError— 0 hits repo-wide.- Enterprise submodule checked too (public CI cannot see it): its references are to
enterprise.backend.{client_portal,shared_sessions}.schema, which are distinct files undersrc/backend/enterprise/backend/…/schema.pyand untouched. No cross-repo break. pop_frames— the live copy stays invoip_audio.py:39;twilio_media_stream.pyhas 0 call sites, so that import is genuinely unused.old_subscription_id— removed from the signature plus 1 prod call site and 6 test sites, 0 residual hits.Coroutineunquoting is runtime-safe: imported at module scope fromcollections.abc(task_execution_service.py:23), subscriptable on 3.13.
I also chased the one subtle risk: the new conftest.ensure_schema_tables narrows the old shim's index matcher from "enterprise_portal" in stmt to table(. Safe — every live INDEX statement in db/schema.py:1893-1910 uses the no-space table( form, so no index is silently dropped, and the ent#443 no-DDL guard plus a new idempotency test are repointed at the helper.
Warnings
pytest (base, seed 99999)is red from a 45-minute job timeout on the BASE (dev) side, not a test failure and not head. All three head seeds are green (8–10 min) andregression diffpasses. Needs a re-run, not a code change — but it keeps the merge gate blocked.docs/security/OWASP_COMPLIANCE_REPORT.md:243,264,294still names the deletedutils/errors.pyas the A10 remediation, marked "DONE". The control was never actually wired (error_handlers.pyowns the 422/500 shape), so the report was already inaccurate — this deletion just exposes it. One line noting the live owner would close it.
Suggestions
get_portal_identity(client_portal/portal_auth.py:156) now has zero call sites in OSS and in the enterprise submodule — only docstrings and docs reference it. Vulture's <80% confidence threshold missed it; candidate for the next sweep, not this PR.tests/unit/test_1073_voip_media_stream_ticket.py:127patchesaudio_mod.pop_framesfor a pathtwilio_media_streamnever calls — leftover scaffolding.
Findings produced by /validate-pr (Claude Code).
vybe
pushed a commit
that referenced
this pull request
Sep 3, 2026
Brings the branch onto dev at 36e6e1a: #2509 (main reconcile), #2479 (zod 4), #2513 (pull: scheduled work reaches the durable queue), plus #2500/#2480. The only shared file with #2513 is task_execution_service.py; git merged the import block cleanly and the four scrub blocks in _write_terminal_and_gate / apply_result are untouched (#2513 adds build_pull_queue_payload above them and widens _admission_gate, which the ent#279 allowlist already names).
Merged
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #2493 — the four pieces of backend dead weight removed, with
vulture --min-confidence 80now reporting zero findings and no suppressions added. Two of the fourteen vulture hits turned out not to be dead; per the issue's own rule ("a behaviour change anywhere means the item was not dead"), those were fixed by making the liveness visible to vulture rather than by deleting live code.The four items
utils/errors.py— deleted.grep -rn "utils.errors\|SafeHTTPException\|log_and_raise" src/ tests/is empty (AC 1).src/, but seven test call sites across six files used them, which is the AC 2 carve-out: the tests now call one shared applier,tests/conftest.py::ensure_schema_tables(*names), over the canonicaldb/schema.pyDDL (Invariant Feature/vector log retention #3 — index statements matched by table name, preserving the shims' own drift rationale). ent#443'stest_the_bootstrap_helper_owns_no_ddlrepoints at the conftest helper, so the no-second-copy-of-DDL guard survives the shim it was written about. Placement note: the helper lives intests/conftest.py, nottests/unit/conftest.py—from conftest import …resolves to the parent (thestubbed_modulesprecedent), which a first attempt found the loud way.scripts/poc/— deleted outright (the issue offered archiving the Nevermined demo; git history is the archive, and nothing references the directory).pop_frames(twilio_media_stream — the live copy is invoip_audio),get_portal_identity(router.py referenced it only in docstrings),SlackOAuthInitResponse,PageBreak, andevent_bus'sRedisResponseErrortry/except pair (bound, never read).exc_type/tb×3 are protocol parameters, not thesys.exc_info()unpacking the issue's technical note guessed — they sit in__exit__/__aexit__signatures and cannot be dropped. Renamed to_-prefixed (idiomatic unused-argument marking, not a linter directive).Coroutinewas NOT dead — read by the string annotation"Coroutine[Any, Any, None]"on_spawn_bg, which vulture cannot see. Unquoted the annotation (evaluates fine at runtime;collections.abcgenerics are subscriptable).NON_ROW_RETENTION_OPS_KEYS's re-export was NOT dead — two tests imported it fromsettings_service. Repointed them atconfig(the true home; the sibling re-exports stay, they have production readers) and dropped the one line.old_subscription_id— a dead parameter of_perform_auto_switch; removed from the signature, its one production call site, and six test call sites (all keyword, so the removal is mechanical and total — zero residualgrephits).Verification
vulture src/backend --min-confidence 80 --exclude '*/venv/*,*/__pycache__/*,*/tests/*,*/enterprise/*,*/migrations/versions/*'→ zero findings, exit 0 (AC 4).tests/unitrun in flight locally and authoritative in CI (AC 5).🤖 Generated with Claude Code
https://claude.ai/code/session_01NLfHNPtB5UCMk4LonZiJux