Extract tool and type lookup crud modules - #2600
Merged
Merged
Conversation
Continues the incremental split of the crud monolith. Tool and TypeLookup move to their own modules; callers switch to direct submodule imports. Pure move -- no logic changes.
akwasigroch
force-pushed
the
refactor/extract-tool-type-lookup-crud
branch
from
August 25, 2026 15:13
77d7376 to
cdcd6c5
Compare
This was referenced Aug 25, 2026
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.
Purpose
app/crud/__init__.pyis the crud monolith thatapps/backend/AGENTS.mdsays should only shrink from here. This continues the incremental split started in #2588, #2590, #2591 and #2592, taking the Tool and TypeLookup blocks off the tail of the file.What Changed
crud/tool.py(_TOOL_RELATED_FIELDS,get_tool,get_tools,create_tool,update_tool,delete_tool) andcrud/type_lookup.py(get_type_lookup,get_type_lookups,create_type_lookup,update_type_lookup,delete_type_lookup,get_type_lookup_by_name_and_value), moved verbatim fromcrud/__init__.py.crud/__init__.py, 998 → 857. No re-exports left behind — the old names are gone from the monolith.routers/tools.py,routers/type_lookup.py,services/source.py,services/task_notification.py,services/tool/actions.py,services/tool/mcp/config.py,services/tool/rest/config.py,services/tool/rest/health.pyandservices/tool/rest/jira.py. All but two of those only used the monolith for these entities, so thefrom rhesis.backend.app import crudimport is dropped where it became unused.tests/backend/services/test_mcp_service.py,test_rest_health.py,test_rest_config.pyandtest_jira_rest.py— these patch the module attribute by string, so the targets move from...config.crudto...config.tool_crud/.type_lookup_cruddepending on which entity the block exercises.This is a pure move: the two new module bodies were diffed byte-for-byte against the removed blocks.
Additional Context
routers/tools.py,services/tool/*); splitting them into two PRs would make the two fight over the same lines.services/task_notification.pywas reached through a direct name import (from rhesis.backend.app.crud import get_status, get_type_lookup) rather than attribute access, so it does not show up in acrud.get_type_lookupgrep. It keepsget_statuson the monolith for now.get_or_create_type_lookuplives inutils/crud_utils.pyand is left alone.task_notification.pyimport line.ruff formatalso tidied a few pre-existing over-long dict literals and hand-wrapped@patchdecorators intest_mcp_service.pyandtest_rest_config.pyas a side effect of formatting those files.Testing
uv run pytest tests/backend/services/→ 1976 passed, 14 skipped, 1 xfailed.uv run pytest tests/backend/routes/test_type_lookup.py tests/backend/routes/test_tools_*.py tests/backend/routes/test_source.py→ 148 passed, 4 skipped.Ruff check and format on all 16 touched files are at the pre-change baseline.