Files
romm/backend/Backend.practice.md
Georges-Antoine Assi 4564c9c5e6 chore(coherence): give each worktree its own test database automatically (#5680)
* chore(coherence): give each worktree its own test database automatically

The rootdir conftest now sets ROMM_TEST_DB_TAG to the linked worktree's
folder name when it is unset, so a worktree never runs against the shared
romm_test. With the rule enforced, the "worktree test database" practice
no longer fires on every `uv run pytest`: each firing reopened an owed
enactment at Stop, and sessions committed one identical record per run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: load the rootdir conftest by path

Under a full run, `from conftest import` resolves to whichever conftest
pytest imported first, so the worktree_tag tests failed to collect.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(tests): hash the worktree path into its test database tag

Addresses the Greptile review on #5680: worktree folders that sanitize or
truncate to the same name no longer share a temporary test database.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 07:04:27 -05:00

17 lines
1.4 KiB
Markdown

- worktree test database: A backend test run in a git worktree uses its own temporary database, never the shared romm_test.
when: explicit
step: set ROMM_TEST_DB_TAG to a tag unique to the worktree before running pytest
step: select the tests affected by the change; never run the whole suite locally
step: leave the shared romm_test alone: never stamp or downgrade it
pitfall: a worktree on another branch migrated the shared romm_test to a revision the current branch lacked, and every test errored in setup with "Can't locate revision" (503c9b290)
learned: 503c9b290
because: every checkout shares romm_test, so one branch's migrations break every other branch's test run
- regenerate frontend types: A change to a backend response schema or route ships with the frontend types regenerated from the OpenAPI schema.
when: edit backend/endpoints/responses/**/*.py | edit backend/endpoints/**/*.py adding protected_route
step: run npm run generate in frontend with the backend running
leaves: the changed files under frontend/src/__generated__
step: run npm run typecheck in frontend
pitfall: a new API field reached the UI only once the generated models were updated in the same change (212caf1a2)
learned: 212caf1a2
because: the backend owns the API contract; stale generated types let the frontend typecheck against a shape the API no longer returns