Skip to content

Feat/dead code#178

Merged
HardMax71 merged 7 commits intomainfrom
feat/dead-code
Feb 13, 2026
Merged

Feat/dead code#178
HardMax71 merged 7 commits intomainfrom
feat/dead-code

Conversation

@HardMax71
Copy link
Owner

@HardMax71 HardMax71 commented Feb 13, 2026


Summary by cubic

Added Vulture dead code checks to CI and pre-commit and removed unused backend code and tests to reduce maintenance and stabilize builds. Simplified Kubernetes pod cleanup by setting ConfigMap ownerReferences to pods so K8s garbage-collects them automatically; updated README and docs (DLQ now persists to MongoDB, added dead-code badge, CI docs include Vulture).

  • New Features

    • CI workflow and pre-commit run Vulture via uv; configured in pyproject (min_confidence 80; paths app; exclude tests) with dev dep and vulture_whitelist.py.
  • Refactors

    • Pruned unused code across DLQ and producer paths, consumer group monitor, k8s resource cleaner, repositories/models, and related tests (including the producer roundtrip e2e); minor DI tweaks.
    • K8s worker: delete command now only deletes the pod; ConfigMaps are GC’d via ownerReference; removed unused NetworkingV1 client; _create_pod returns the created pod to set ownership.

Written for commit 153392e. Summary will update on new commits.

Summary by CodeRabbit

  • Chores
    • Added automated dead‑code detection to CI and local pre‑commit hooks.
    • Updated project tooling/configuration to support static analysis with explicit whitelist exclusions for framework patterns.
    • Removed a number of deprecated public APIs, related behaviors, and their associated tests to simplify the codebase.

@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

📝 Walkthrough

Walkthrough

Adds Vulture dead-code detection (CI workflow, pre-commit hook, pyproject config and whitelist) and removes numerous backend public APIs, DLQ-related flows and tests, native consumer-group monitoring, ResourceCleaner orchestration and providers, various repo/service methods, domain models/schemas, and related tests.

Changes

Cohort / File(s) Summary
Vulture CI & tooling
/.github/workflows/vulture.yml, /.pre-commit-config.yaml, backend/pyproject.toml, backend/vulture_whitelist.py
Adds GitHub Actions workflow and pre-commit hook to run Vulture; adds vulture dev dependency and config; provides whitelist entries and excludes.
Kafka mappings & consumer monitoring
backend/app/infrastructure/kafka/mappings.py, backend/app/events/consumer_group_monitor.py, backend/tests/e2e/events/test_consumer_group_monitor.py, backend/tests/e2e/events/test_consumer_group_monitor_real.py
Removes get_event_types_for_topic and deletes NativeConsumerGroupMonitor and its e2e tests.
DLQ & producer flows + tests
backend/app/events/core/producer.py, backend/app/dlq/manager.py, backend/app/db/repositories/dlq_repository.py, backend/tests/e2e/dlq/*, backend/tests/e2e/events/test_producer_roundtrip.py
Removes DLQ send/management paths and repository state-transition methods; deletes DLQ e2e test modules and DLQ-related test assertions.
ResourceCleaner & Kubernetes worker / pod monitoring
backend/app/services/result_processor/resource_cleaner.py, backend/tests/e2e/test_resource_cleaner.py, backend/app/services/k8s_worker/worker.py, backend/app/services/pod_monitor/event_mapper.py, backend/app/core/providers.py, backend/app/core/container.py, backend/app/services/result_processor/__init__.py
Deletes ResourceCleaner orchestration and public APIs, removes ResourceCleaner DI provider/export, alters Kubernetes worker to use ownerReferences (removes ExecutionStarted event), removes PodEventMapper.clear_cache, and deletes related e2e tests.
Repository & service API removals
backend/app/db/repositories/..., backend/app/services/..., backend/tests/e2e/..., backend/tests/unit/...
Removes many public methods across repositories and services (execution update, replay session create/get, DLQ mark methods, idempotency delete/health_check, user settings reset/count, advanced event query and helper, etc.) and corresponding test expectations.
Domain models & Pydantic schemas
backend/app/domain/..., backend/app/schemas_pydantic/*.py
Removes several domain models/exceptions/fields (CollectionNames, SagaStatistics, SagaCompensationError, DomainSettingChange, CachedSettings.is_expired, UserUpdate.has_updates, etc.) and deletes/reshapes multiple Pydantic schema classes (execution create/update, notification batch/stats, replay throughput, SavedScript DB model → API models, UserInDB, settings events).
Tests: unit & e2e adjustments
backend/tests/unit/..., backend/tests/e2e/...
Deletes or simplifies unit and e2e tests tied to removed APIs/features (saga context serialization tests, notification batch validation, DLQ e2e suites, consumer-group monitor e2e tests, resource cleaner e2e tests, idempotency/delete/health tests, user settings reset test, producer DLQ assertions).

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I hopped through lines both old and new,
Nibbling unused code where cobwebs grew.
Vulture peeks, I hold a carrot high,
Whitelisted ghosts wave their good-bye.
Clean paths ahead — a joyful rabbit sighs.

🚥 Pre-merge checks | ✅ 2 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 53.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Feat/dead code' is vague and generic, using non-descriptive phrasing that doesn't clearly convey the specific nature or scope of the changes to someone scanning commit history. Consider revising the title to be more specific and descriptive, such as 'Add Vulture dead-code detection and remove unused backend code' or 'feat: integrate Vulture for dead-code detection and prune unused utilities'.
✅ Passed checks (2 passed)
Check name Status Explanation
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/dead-code

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 and usage tips.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 7 files

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
backend/app/services/result_processor/resource_cleaner.py (2)

23-107: ⚠️ Potential issue | 🟠 Major

All remaining private methods are unreachable dead code.

The ResourceCleaner class is instantiated via the dependency injection container, but with all public methods removed (cleanup_pod_resources, cleanup_orphaned_resources, get_resource_usage), there are no entry points to invoke any of the remaining private methods. The search confirms:

  • _cleanup_orphaned_pods and _cleanup_orphaned_configmaps have zero callers anywhere in the codebase
  • _delete_configmaps and _delete_pvcs have zero callers
  • _delete_pod is only called internally by _cleanup_orphaned_pods, which itself is unreachable
  • The class instance is created but never used

The entire class should be removed along with its provider and DI registration, or these private methods need to be re-exposed via new public methods if they're intended to be used elsewhere.


18-21: ⚠️ Potential issue | 🟡 Minor

self.networking_v1 is unused and should be removed.

This attribute is initialized on line 20 but never referenced in any method within the class. Removing it will also eliminate the unnecessary NetworkingV1Api instantiation.

🧹 Proposed fix
     def __init__(self, api_client: k8s_client.ApiClient, logger: structlog.stdlib.BoundLogger) -> None:
         self.v1 = k8s_client.CoreV1Api(api_client)
-        self.networking_v1 = k8s_client.NetworkingV1Api(api_client)
         self.logger = logger
🧹 Nitpick comments (1)
backend/tests/e2e/events/test_producer_roundtrip.py (1)

12-19: Test has no assertions — consider adding at least a basic one.

After the DLQ path removal, this test only calls produce with no explicit assertion. It relies solely on the absence of an exception, which is a very weak guarantee for an e2e test. Consider asserting on the return value of produce (e.g., delivery metadata) or renaming/removing this test if it no longer serves a meaningful purpose.

Also, the filename test_producer_roundtrip.py no longer reflects the content — there's no "roundtrip" being tested anymore.

…es the ConfigMap with an ownerReference pointing to the pod's UID. K8s garbage collector auto-deletes the ConfigMap when the pod is deleted (by anyone — saga

  compensation, manual kubectl delete, namespace cleanup, etc.)
  2. Simplified handle_delete_pod_command — only deletes the pod now; ConfigMap cleanup is handled by K8s GC
  3. Removed networking_v1 — unused client (PR review comment)
  4. _create_pod returns the created pod — needed to get the pod UID for the ownerReference
… zero assertions after the DLQ path was removed. No roundtrip, no verification, no value.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@backend/app/services/k8s_worker/worker.py`:
- Around line 128-135: _created_pod can be None when _create_pod hit a 409 (pod
already exists), leaving a newly-created ConfigMap orphaned; update the control
flow after calling _create_pod so that if created_pod is falsy you read the
existing pod (e.g. add a call like self._read_pod/_get_pod using
pod.metadata.name and pod.metadata.namespace), check the returned
pod.metadata.uid, and then call _set_configmap_owner(config_map, existing_pod)
just like in the created case; keep the subsequent await
self._publish_pod_created(command, pod) behavior unchanged and ensure you guard
against missing metadata/uid before calling _set_configmap_owner.

@sonarqubecloud
Copy link

@HardMax71 HardMax71 merged commit 1ff4858 into main Feb 13, 2026
18 checks passed
@HardMax71 HardMax71 deleted the feat/dead-code branch February 13, 2026 23:00
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