Skip to content

Extract prompt CRUD out of the crud/__init__.py monolith - #2590

Merged
akwasigroch merged 1 commit into
mainfrom
refactor/extract-prompt-crud
Aug 25, 2026
Merged

Extract prompt CRUD out of the crud/__init__.py monolith#2590
akwasigroch merged 1 commit into
mainfrom
refactor/extract-prompt-crud

Conversation

@akwasigroch

Copy link
Copy Markdown
Collaborator

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, as apps/backend/AGENTS.md's crud-layout rule asks for.

What Changed

New apps/backend/src/rhesis/backend/app/crud/prompt.py holds get_prompt, get_prompts, create_prompt, update_prompt, delete_prompt, get_prompt_template, get_prompt_templates, create_prompt_template, update_prompt_template and delete_prompt_template. Both entities share the one module because a prompt template is a prompt with placeholders left in — same domain.

crud/__init__.py loses those 116 lines. Callers now use the house pattern from rhesis.backend.app.crud import prompt as prompt_crud: routers/prompt.py, routers/prompt_template.py, services/test_run.py and tests/backend/security/test_organization_filtering.py. The two routers used the bare crud name only for prompt functions, so crud is dropped from their from 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__.py is 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 -q from apps/backend — 1456 passed, 13 skipped. Ruff check and format on every touched file report only the three pre-existing errors that are already on main (two unused fastapi.APIRouter imports and an unused test local in services/test_run.py).

@akwasigroch
akwasigroch merged commit 5a57204 into main Aug 25, 2026
15 of 17 checks passed
@akwasigroch
akwasigroch deleted the refactor/extract-prompt-crud branch August 25, 2026 11:52
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