交付不可变查询版本、保存即生效与激活(D26),并带控制台列表筛选排序与试跑预览;补 RLS 下 current_version_no 回填迁移。 Co-authored-by: Cursor <cursoragent@cursor.com>
1.9 KiB
1.9 KiB
M04 Slice S1 Review Note (coder self-check)
Status: implemented; awaiting independent review (not a review verdict).
Files created
services/watchman/src/watchman/models/query.py—QueryDefinition,QueryVersion,VERSION_CONTENT_COLUMNSservices/watchman/migrations/versions/20261118_0006_query_definitions.py— revises20261118_0005services/watchman/src/watchman/services/query_versions.py—forbid_version_content_mutation,assert_version_immutableservices/watchman/tests/test_query_versions.py— 28 tests
Files changed
services/watchman/src/watchman/models/__init__.py— export new models
Design notes
datasource_idanddefinition_idFKs areON DELETE RESTRICT; extra indexix_query_definitions_datasource_id.- Both tables: ENABLE + FORCE RLS,
tenant_isolationpolicy, full CRUD grant towatchman_app. query_versionshas noupdated_at. Immutability is enforced only by the service helper (frozen: content columns plustenant_id,definition_id,version_no,published_at,published_by). It is NOT enforced at DB level because UPDATE is granted per the slice spec; direct SQL/ORM writes bypass the helper. Later slices must route all version writes through the service layer. A DB trigger is a possible hardening for the reviewer to consider.latest_published_version_nois not FK-linked toquery_versions(set by publish logic in S3).
Validation
uv run alembic upgrade head— PASS (to20261118_0006); downgrade to0005then upgrade again — PASS.uv run pytest tests/test_query_versions.py— 28 passed.uv run pytest(full) — 290 passed, 1 pre-existing deprecation warning.- No real passwords; datasource rows use a placeholder ciphertext and synthetic host/user.
Scope check
- Only
models/,migrations/,services/query_versions.py(explicitly requested),tests/touched. No API routes, executor, frontend, M03 circuit changes, or git commits.