feat(queries): 完成 M04 查询定义与版本激活

交付不可变查询版本、保存即生效与激活(D26),并带控制台列表筛选排序与试跑预览;补 RLS 下 current_version_no 回填迁移。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
unknownandCursor committed 2026-11-18 18:32:24 +08:00
1 parent 8c0335040f
commit 21cc721fcc
97 files changed
+13354 -153

No files matched your search

@@ -0,0 +1,30 @@
# M04 MUST-FIX Recheck
## Verdict
PASS
## Scope
Bounded recheck of the two MUST-FIX findings in `review-module-m04.md`; this is not a new module-wide review.
## Findings Closed
1. **Immutable query versions — closed.**
- Migration `20261118_0007` revokes `UPDATE`/`DELETE` from `watchman_app` and installs a statement-level `BEFORE UPDATE OR DELETE OR TRUNCATE` rejection trigger.
- The trigger also rejects mutations attempted by the migrator/table-owner, so a later privilege grant cannot bypass the append-only boundary.
- Regression coverage verifies app-role Core and ORM mutation failures, unchanged stored SQL, allowed inserts, and owner-side update/delete/truncate rejection.
2. **SQL Server preview write risk — closed.**
- `run_query` refuses SQL Server immediately after datasource usability checks, before template validation, secret decryption, or any source connection, with `engine_readonly_unsupported`.
- `queries/drivers.py` has no SQL Server runner, so direct `fetch_rows` calls also fail without opening a connection. The M03 connectivity probe remains separate and unchanged.
- Regression coverage exercises SELECT, UPDATE, DELETE, and `EXEC` refusal plus the API outcome and no-connection path.
## Validation
- `uv run pytest tests/test_query_versions.py tests/test_query_execute.py tests/test_query_api.py -q`
- Result: **194 passed**; one pre-existing dependency deprecation warning from Starlette `TestClient`.
## Notes
No new high-severity issue was found in these remediations.