Extract prompt CRUD out of the crud/__init__.py monolith - #2590
Merged
Conversation
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
Continues the incremental split of
crud/__init__.py(#2410 through #2458, and #2588 for Test Result) by moving the Prompt and Prompt Template CRUD functions into their own per-entity module, asapps/backend/AGENTS.md's crud-layout rule asks for.What Changed
New
apps/backend/src/rhesis/backend/app/crud/prompt.pyholdsget_prompt,get_prompts,create_prompt,update_prompt,delete_prompt,get_prompt_template,get_prompt_templates,create_prompt_template,update_prompt_templateanddelete_prompt_template. Both entities share the one module because a prompt template is a prompt with placeholders left in — same domain.crud/__init__.pyloses those 116 lines. Callers now use the house patternfrom rhesis.backend.app.crud import prompt as prompt_crud:routers/prompt.py,routers/prompt_template.py,services/test_run.pyandtests/backend/security/test_organization_filtering.py. The two routers used the barecrudname only for prompt functions, socrudis dropped from theirfrom rhesis.backend.app import ...line.Additional Context
Pure refactor. Function bodies moved verbatim — no signature, query or behaviour change, so the generated SQL is identical. The import block at the top of
crud/__init__.pyis untouched: every symbol the moved code used (get_item,get_items,get_items_detail,create_item,update_item,delete_item) still has other callers in the monolith.Testing
uv run pytest ../../tests/backend/routes/test_prompt.py ../../tests/backend/routes/test_prompt_template.py ../../tests/backend/security ../../tests/backend/services/test_rescore.py -qfromapps/backend— 1456 passed, 13 skipped. Ruff check and format on every touched file report only the three pre-existing errors that are already onmain(two unusedfastapi.APIRouterimports and an unusedtestlocal inservices/test_run.py).