feat(queries): 完成 M04 查询定义与版本激活
交付不可变查询版本、保存即生效与激活(D26),并带控制台列表筛选排序与试跑预览;补 RLS 下 current_version_no 回填迁移。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
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.
|
||||
@@ -0,0 +1,46 @@
|
||||
# M04 Module Review
|
||||
|
||||
## Verdict
|
||||
|
||||
FAIL
|
||||
|
||||
## Must-fix
|
||||
|
||||
1. **Published versions are not actually immutable at the persistence boundary** (confidence: 100)
|
||||
- **Location:** `services/watchman/migrations/versions/20261118_0006_query_definitions.py:42`; `services/watchman/src/watchman/services/query_versions.py:23`; `services/watchman/src/watchman/services/queries.py:385`
|
||||
- The migration grants `watchman_app` `UPDATE` on `query_versions` and installs no trigger or database rule to reject updates. The only guard is the standalone `forbid_version_content_mutation()` helper, but no production write path calls it. Any present or future application code using a SQLAlchemy session can therefore alter a published SQL snapshot and commit it.
|
||||
- This violates D24's immutable-published-version requirement despite the absence of an HTTP update route.
|
||||
- **Fix:** enforce append-only versions at the database boundary (for example, revoke UPDATE/DELETE for the application role, or add an update/delete-rejecting trigger with a narrowly controlled maintenance path). Add an integration test that attempts a direct ORM/Core update and proves it is rejected.
|
||||
|
||||
2. **SQL Server previews can execute writes when the saved datasource credentials have write access** (confidence: 98)
|
||||
- **Location:** `services/watchman/src/watchman/queries/drivers.py:260`
|
||||
- PostgreSQL and MySQL establish a read-only transaction before executing the submitted template. The SQL Server runner sends the template directly via `cur.execute(sql, params)` and has no equivalent server-side read-only transaction or application gate. `DataSource.read_only_intent` is only stored/displayed and is never checked or verified before execution (`services/watchman/src/watchman/services/datasources.py:303`, `services/watchman/src/watchman/queries/execute.py:151`).
|
||||
- A single-statement `UPDATE`, `DELETE`, DDL, or an executing stored procedure is accepted by the template parser and will mutate a SQL Server datasource whenever its configured login has write privileges. Parameter binding prevents value injection; it does not make arbitrary SQL read-only. This violates the read-only-preview boundary.
|
||||
- **Fix:** do not allow SQL Server preview until a server-enforced read-only execution method is available, or require and verify a least-privileged read-only login as an executable precondition. Add a live SQL Server regression test proving a write statement cannot change data.
|
||||
|
||||
## Should-fix
|
||||
|
||||
None.
|
||||
|
||||
## Notes
|
||||
|
||||
- Review covered the supplied M04 backend, API/auth, datasource-reference, frontend, tests, migrations, and task/documentation scope.
|
||||
- The reviewed API routes correctly restrict query operations to `watchman-admin`; parameter values are bound rather than text-spliced; preview outcomes keep empty, illegal-type, and failure distinct; and preview audit payloads omit SQL, parameters, and rows.
|
||||
- Existing test results were provided by the orchestrator. This review did not re-run them.
|
||||
|
||||
## Remediation
|
||||
|
||||
Both must-fix findings were addressed (no commit made).
|
||||
|
||||
1. **Immutable `query_versions` at the DB boundary** — new migration `20261118_0007_query_versions_immutable`:
|
||||
- `REVOKE UPDATE, DELETE` on `query_versions` from `watchman_app`; `SELECT, INSERT` re-asserted.
|
||||
- Statement-level `BEFORE UPDATE OR DELETE OR TRUNCATE` trigger (`trg_query_versions_append_only`) that always raises `restrict_violation` (23001), so it also stops the table owner and any future grant, even when forced RLS hides all rows.
|
||||
- Downgrade drops trigger and function and restores the 0006 grants (round-trip upgrade/downgrade/upgrade verified locally).
|
||||
- Tests (`test_query_versions.py`): app-role privilege matrix; Core and ORM UPDATE/DELETE fail with SQLSTATE 42501 and the stored SQL is unchanged; INSERT of a new version still works; the owner (migrator) is rejected by the trigger for UPDATE/DELETE/TRUNCATE.
|
||||
- Because the app role can no longer delete versions, test cleanup now uses a superuser purge (`tests/_privileged_cleanup.py`, `session_replication_role = replica`); there is no application maintenance path.
|
||||
2. **SQL Server read-only boundary** — chosen fix: refuse, do not gate on statement text.
|
||||
- `run_query` returns `failure_kind = engine_readonly_unsupported` (fixed safe message, no details from the driver) for `engine == "sqlserver"` right after `assert_usable`, before validation, secret decryption or any connection. The circuit is untouched.
|
||||
- `_run_sqlserver` was removed from `queries/drivers.py`, so `fetch_rows` also raises `UnsupportedDataSourceError` for SQL Server: no write path exists even if the guard were bypassed. The M03 probe (`datasources/probe.py`) is unchanged.
|
||||
- Tests: `run_query` on a sqlserver datasource is refused for SELECT, UPDATE, DELETE and EXEC with no driver/secret access; `fetch_rows("sqlserver")` opens nothing; an API preview test confirms the refusal outcome and a single audit event.
|
||||
|
||||
Validation: `uv run pytest` in `services/watchman` — 456 passed. Not covered: a live SQL Server test (none needed, since execution is refused); the frontend has not been checked for display of the new `failure_kind`.
|
||||
@@ -0,0 +1,32 @@
|
||||
# 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_COLUMNS`
|
||||
- `services/watchman/migrations/versions/20261118_0006_query_definitions.py` — revises `20261118_0005`
|
||||
- `services/watchman/src/watchman/services/query_versions.py` — `forbid_version_content_mutation`, `assert_version_immutable`
|
||||
- `services/watchman/tests/test_query_versions.py` — 28 tests
|
||||
|
||||
## Files changed
|
||||
|
||||
- `services/watchman/src/watchman/models/__init__.py` — export new models
|
||||
|
||||
## Design notes
|
||||
|
||||
- `datasource_id` and `definition_id` FKs are `ON DELETE RESTRICT`; extra index `ix_query_definitions_datasource_id`.
|
||||
- Both tables: ENABLE + FORCE RLS, `tenant_isolation` policy, full CRUD grant to `watchman_app`.
|
||||
- `query_versions` has no `updated_at`. Immutability is enforced only by the service helper (frozen: content columns plus `tenant_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_no` is not FK-linked to `query_versions` (set by publish logic in S3).
|
||||
|
||||
## Validation
|
||||
|
||||
- `uv run alembic upgrade head` — PASS (to `20261118_0006`); downgrade to `0005` then 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.
|
||||
@@ -0,0 +1,71 @@
|
||||
# M04 Slice S2 — 只读执行器:实现自检记录
|
||||
|
||||
状态:实现完成,待独立 review(本文件是 coder 自检,不是独立审查结论)。未 commit。
|
||||
|
||||
## 变更文件
|
||||
|
||||
新增:
|
||||
- `services/watchman/src/watchman/queries/__init__.py`(边界说明、导出)
|
||||
- `services/watchman/src/watchman/queries/result.py`(`QueryRunResult`、状态/failure_kind 常量)
|
||||
- `services/watchman/src/watchman/queries/schema.py`(param/output schema 解析、值类型校验)
|
||||
- `services/watchman/src/watchman/queries/template.py`(模板扫描、`:name` 绑定、`{{ident}}` 白名单、单语句检查)
|
||||
- `services/watchman/src/watchman/queries/drivers.py`(PG/MySQL/SQL Server 单语句执行与失败分类)
|
||||
- `services/watchman/src/watchman/queries/execute.py`(`run_query` 编排)
|
||||
- `services/watchman/tests/test_query_execute.py`
|
||||
|
||||
修改(薄改):
|
||||
- `services/watchman/src/watchman/services/datasources.py`:新增 `build_probe_target(row)`、`record_connection_failure(session, datasource_id, category)`;未改既有函数。
|
||||
|
||||
未触碰:路由、前端、`query_definitions` schema/迁移、`.env*`。
|
||||
|
||||
## 行为摘要
|
||||
|
||||
`run_query` 顺序:`assert_usable` → 限制/schema/参数/标识符校验 → 内存解密 → `commit`(网络调用期间不持有事务)→ 执行(`max_rows+1`)→ 分类。
|
||||
|
||||
| 情形 | status | failure_kind |
|
||||
| --- | --- | --- |
|
||||
| 有行且符合输出契约 | success | — |
|
||||
| 0 行 | empty | — |
|
||||
| 声明列类型不符(details 仅含字段名/期望类型/实际 Python 类型名/首个违规行号,不含值) | illegal_type | — |
|
||||
| 数据源停用/熔断打开(不连接、不读密钥) | failure | disabled / circuit_open |
|
||||
| 校验失败(未知参数、缺必填、类型错、`{{x}}` 不在白名单、多语句、非法限制/schema) | failure | validation |
|
||||
| 连接 auth/timeout/unreachable/rejected | failure | auth_failed / timeout / unreachable / rejected,**记入熔断** |
|
||||
| 连接中途断开 | failure | unreachable,**记入熔断** |
|
||||
| 语句超时(PG statement_timeout/MySQL read_timeout) | failure | timeout,**不记熔断** |
|
||||
| SQL 语法/运行错误 | failure | sql_error(PG 附 SQLSTATE),**不记熔断** |
|
||||
| 超过 `max_rows` | failure | limit_exceeded(不返回行) |
|
||||
|
||||
- 绑定:模板 `:name` → `%(name)s` 由驱动绑定;`::` 转型、字符串/引号标识符/注释/PG `$$` 内的 `:name`、`{{}}` 不当作占位符;无参数时不转义 `%`,有参数时转义为 `%%`。参数值不可能成为标识符(测试覆盖)。
|
||||
- 白名单:`{{ident}}` 必须在 `allowed_identifiers` 且匹配 `^[A-Za-z_][A-Za-z0-9_]*$`,按引擎加引号(`"x"` / `` `x` `` / `[x]`);空列表=不允许;校验发生在连接之前。
|
||||
- 只读:PG 用 `BEGIN READ ONLY` + `SET LOCAL statement_timeout`,结束 rollback;MySQL `SET SESSION TRANSACTION READ ONLY` + `START TRANSACTION READ ONLY` + 尽力设置 `MAX_EXECUTION_TIME`;SQL Server 无会话级只读,依赖只读账户(A-017 配置层前提)。不以 `SELECT` 前缀判定安全。额外加了“必须单语句”的结构检查(允许末尾 `;`)。
|
||||
- 限制:`timeout_ms`/`max_rows` 必须是 ≥1 的 int,超过 `MAX_TIMEOUT_MS`/`MAX_ROWS_LIMIT` 被封顶;其余视为 `validation`。
|
||||
- 日志:仅记录引擎、数据源 id、状态、行数;不记口令、连接串、参数值、结果集。
|
||||
|
||||
## 验证
|
||||
|
||||
- `uv run pytest tests/test_query_execute.py`:71 passed(含对 `WATCHMAN_TEST_PG_*` 本地源库的真实执行:绑定防注入、`%` 转义、类型参数、空/illegal_type/sql_error 三分、行数上限、语句超时不记熔断、会话只读(CREATE TABLE 被拒、`transaction_read_only=on`)、错误口令 auth_failed 记账、端口不可达记账)。
|
||||
- `uv run pytest`(全量):361 passed,无失败。
|
||||
- 覆盖要求映射:参数含 SQL 片段不改结构(模板测试+fake+live);空/失败/illegal_type 区分;disabled/circuit 拒绝且驱动未被调用;未知参数;`{{ident}}` 不在白名单/空白名单拒绝。
|
||||
- MySQL 仅用 fake 驱动测试(连接 auth 映射、只读 SET、语法错误、连接丢失 vs read_timeout);SQL Server 未做任何自动化测试(无环境);二者的真实库行为 **NOT_RUN**。
|
||||
|
||||
## 设计决定/需要 reviewer 与用户确认的点
|
||||
|
||||
1. **`nullish` 语义未在需求中定义**:当前实现为“该列不做类型约束”;另外 SQL `NULL` 对所有声明类型都通过类型检查(认为 NULL 是缺值而非类型错误)。若产品想要“只能为 NULL”或“非 NULL 才算合法”,需改 `schema.check_output_value`。
|
||||
2. **成功不记账**:按任务说明只对连接类失败调用 `record_probe_outcome`(`update_last_test=False`,不改 `last_test_*`);成功的预览不会重置失败计数。
|
||||
3. **语句超时不算连接类失败**:慢查询/运行时超时不开闸;连接阶段超时和连接丢失才记入。MySQL `read_timeout` 与连接中途断开在驱动层难区分,按“超时链→timeout(不记);2006/2013 无超时链→unreachable(记)”处理。
|
||||
4. **`param_schema[].required` 缺省为 true**(更严格);`required=true` 且带 `default` 时,缺参仍拒绝(按字面规则)。`boolean` 严格要求 bool(MySQL tinyint 返回 int 会判 illegal_type);`integer` 不接受 Decimal。
|
||||
5. **`run_query` 内部 `commit`**:校验失败/连接失败记账后都会 commit,以免熔断计数随调用方丢弃结果而丢失;S3 路由无需再为熔断额外提交,但应知道会话已被提交。
|
||||
6. `run_query` 对查询类问题**返回** `QueryRunResult`,不抛错;`NotFoundError`(未知数据源)和 `DatasourceSecretUnavailableError` 仍向上抛,由 S3 映射信封。
|
||||
7. `drivers.py` 复用了 `watchman.datasources.probe` 的私有分类助手(`_classify_after_failure` 等),使连接失败分类与探测一致;若后续希望公开,可在 probe 中提升为公共 API(本片未改 probe)。
|
||||
8. 结果行中 `Decimal→float`、`bytes→hex`、日期时间→ISO 字符串、其他→`str`;输出契约之外的列原样返回(脱敏策略留给 S3/预览层)。
|
||||
9. 同名重复列只保留最后一个值(dict)。
|
||||
|
||||
## 残余风险
|
||||
|
||||
- 只读保证依赖数据库账户权限:PG 事务内用户 SQL 无法在单语句内切回读写,但仍应使用只读账户(配置层)。
|
||||
- 无参数模板时 psycopg 可能走简单协议;已由“单语句”结构检查约束,但该检查是词法级的,不是完整 SQL 解析。
|
||||
- SQL Server 路径无自动化证据。
|
||||
|
||||
## 文档同步
|
||||
|
||||
无设计语义变化需要更新 `docs/`;M04 任务卡进度由主 Agent 更新。
|
||||
@@ -0,0 +1,82 @@
|
||||
# M04 Slice S3 — API、权限、引用回填:实现自检记录
|
||||
|
||||
状态:实现完成,待独立 review(本文件是 coder 自检,不是独立审查结论)。未 commit。
|
||||
|
||||
## 变更文件
|
||||
|
||||
新增:
|
||||
- `services/watchman/src/watchman/services/queries.py`(定义 CRUD、启停、publish、版本读取、预览编排、序列化)
|
||||
- `services/watchman/src/watchman/api/routes/queries.py`(`/queries` 路由,`extra="forbid"` 请求模型)
|
||||
- `services/watchman/tests/test_query_api.py`(84 个用例)
|
||||
|
||||
修改:
|
||||
- `auth/access.py`:四个节点常量 + `require_query_read/write/publish/preview`(仅 `watchman-admin`)
|
||||
- `auth/principal.py`:`require_query_reader/writer/publisher/previewer`;把 `_load_session_roles` 的会话读取抽成 `_load_session`(返回 login_name + roles,行为不变);`require_query_publisher` 返回 login_name 供 `published_by`
|
||||
- `api/app.py`:注册 `queries.router`
|
||||
- `services/datasources.py`:`list_references` 回填查询条目 `{type:"query", id, name, enabled}`,按 name 排序,仅本租户
|
||||
- `api/routes/datasources.py`:仅 references 路由 docstring
|
||||
|
||||
未触碰:S1 模型/迁移、`query_versions.py`、`queries/` 执行器包、前端、`.env*`、`docs/`。
|
||||
|
||||
## 路由与契约
|
||||
|
||||
| 路由 | 权限 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `GET /queries?enabled=` | read | 摘要列表(不含草稿内容) |
|
||||
| `POST /queries` | write | 创建启用的未发布定义 |
|
||||
| `GET /queries/{id}` | read | 摘要 + `draft{sql_template,param_schema,output_schema,allowed_identifiers,timeout_ms,max_rows}`,含 `latest_published_version_no` |
|
||||
| `PATCH /queries/{id}` | write | name/description/datasource_id/草稿六字段;不含 enabled 与任何版本字段 |
|
||||
| `POST /{id}/disable|enable` | write | |
|
||||
| `POST /{id}/publish` | publish | 返回完整冻结版本 |
|
||||
| `GET /{id}/versions`、`/{id}/versions/{n}` | read | 摘要(新→旧)/完整内容 |
|
||||
| `POST /{id}/preview`、`/{id}/versions/{n}/preview` | preview | body `{params:{}}`(可省略,`extra=forbid`) |
|
||||
| `GET /{id}/references` | read | `{id, items: []}` |
|
||||
|
||||
- 输入字段名用 `sql_template` 等(不带 `draft_`),输出放在 `draft` 对象里,键名相同,便于 GET → PATCH 往返。
|
||||
- 未知/越权字段(tenant_id、enabled、version_no、published_by、latest_published_version_no、`draft_*`)→ 40000。
|
||||
- 版本无任何 PATCH/PUT/DELETE/POST 路由(测试断言 404/405);唯一写入门(定义 PATCH)拒绝版本形字段。
|
||||
- 信封、错误码沿用既有:无会话 41000;非 admin 42000 + `permission_node`;404 用 `NotFoundError`(含跨租户、非法 UUID);重名 409 `duplicate_name`;预览停用 409 `reason=disabled`。
|
||||
|
||||
## 行为摘要
|
||||
|
||||
- **创建/PATCH 校验**:复用 S2 `parse_param_schema/parse_output_schema/parse_allowed_identifiers`(未知键、重复、非法类型→40000 reason);SQL 模板不得全空白;`timeout_ms/max_rows` 必须是 ≥1 的严格 int(拒绝 bool/0/负数),超过服务端上限按 S2 口径**封顶**(不拒绝);数据源须存在于本租户且 `kind=database`,否则 400(`datasource_not_found`/`datasource_not_database`)。不对 SQL 模板做深度解析(模板问题在预览中以 `failure/validation` 呈现)。
|
||||
- **publish**:锁定定义行(`FOR UPDATE`)→ 重新校验草稿 → `version_no = (latest or 0)+1` → 只 INSERT 版本行,复制 draft 六字段 → 更新 `latest_published_version_no`;`published_by` = 会话 `login_name`(截断 128)。版本行没有任何更新路径;`UNIQUE(definition_id, version_no)` 兜底并发(映射 409 `version_conflict`)。停用的定义仍可发布。
|
||||
- **预览**:先断言定义启用(否则 409,不运行、不审计)→ 把草稿/版本内容拷出 ORM 对象(`run_query` 会 commit)→ 调 S2 `run_query`(定义当前绑定的数据源)→ 写审计 → 路由 commit。`QueryRunResult` 映射:
|
||||
- `success`/`empty`:`columns, rows, row_count, masked_columns`
|
||||
- `illegal_type`:`columns, details.fields`(仅字段名/类型,无值)
|
||||
- `failure`:`failure_kind, details`
|
||||
- 失败的运行是 HTTP 200 的结果(`status=failure`),不是 API 错误。
|
||||
- **样例脱敏**:输出契约没有敏感标记,采用按列名的简单策略(`password/pwd/secret/token/credential/api_key/private_key/id_card/phone/mobile/email`,大小写不敏感),非 NULL 值替换为 `***`,并返回 `masked_columns`。S2 说明过脱敏留给本层。
|
||||
- **审计**:`query.create`(id,name,datasource_id)、`query.update`(id,name,**字段名列表**,无 SQL)、`query.enable/disable`(id,name)、`query.publish`(id,name,version_no)、`query.preview`(**仅** id、status,版本预览加 version_no;不含 name、SQL、参数、行、消息)。幂等键由服务端生成。
|
||||
- **数据源 references**:`{id, items:[{type:"query",id,name,enabled}]}`,随查询改绑/停用实时变化,不含其他租户。查询侧 references 仍恒为空。
|
||||
- 时间戳序列化统一转 UTC ISO(新写入值与重新读取值时区会不同,否则前后不相等)。
|
||||
|
||||
## 验证
|
||||
|
||||
- `uv run pytest tests/test_query_api.py`:84 passed
|
||||
- `uv run pytest`(全量):**445 passed**(S2 后基线 361 + 本片 84),无失败;无需网络或真实源库
|
||||
- 覆盖:节点字符串与角色规则;12 条路由 × 匿名 41000;12 条路由 × 4 类非 admin 42000 带正确节点且数据未变;create/list/get/patch/enable/disable+`?enabled=` 过滤;创建与 PATCH 的未知字段/空值/非法 schema/限制/数据源校验;重名 409;publish v1→v2、草稿后改不影响 v1、版本列表与详情、published_by、审计;版本不可通过任何端点改;预览成功/空/illegal_type/failure 四种形状(fake `run_query`);脱敏;预览审计无数据;版本预览用冻结内容、草稿预览用草稿;停用定义 409 且不运行不审计;真实 `run_query` 的无网络路径(unknown_param 校验失败、数据源停用);查询 references 为空;数据源 references 列出/改绑/停用/跨租户;跨租户 id 404。
|
||||
- 未运行:对真实源库的 HTTP 预览成功路径(S2 的 live 测试覆盖执行器本身;本片用 fake)。浏览器/前端:不在本片。
|
||||
|
||||
## 设计决定/需要 reviewer 与用户确认的点
|
||||
|
||||
1. **输入/输出字段命名**:输入 `sql_template…`,输出 `draft.{…}`;S4 原型与 S5 按此口径。若希望扁平 `draft_*` 需改序列化。
|
||||
2. **版本不快照 datasource_id**:版本预览使用定义**当前**绑定的数据源。若用户后来改绑数据源,旧版本预览会跑在新数据源上。需求未要求版本冻结数据源(S1 表也没有该列);如需冻结应回到 S1 加列。
|
||||
3. **停用定义仍可发布**,只拒绝预览。需求仅说停用后不可预览。
|
||||
4. **数据源停用/熔断**在预览中是 `status=failure, failure_kind=disabled|circuit_open`(S2 语义,HTTP 200),而**查询定义停用**是 409。两者故意不同:前者是运行结果,后者是调用前置条件。
|
||||
5. **绑定数据源时只要求存在且 `kind=database`**,不要求当前 enabled/熔断闭合(那是运行时状态,由 `assert_usable` 把关)。需求写“可用数据库数据源”,如要求创建时必须 usable 需确认。
|
||||
6. **脱敏策略是列名正则**,可能漏掉不含关键词的敏感列、误伤含关键词的列;输出契约尚无敏感标记。
|
||||
7. **PATCH 空 body 为成功空操作**(会写一条 `query.update`,`fields: []`),与数据源 PATCH 一致。
|
||||
8. `principal.py` 的 `_load_session_roles` 被改写为 `_load_session` 的薄包装(行为不变,数据源/平台测试全绿)。
|
||||
9. `preview` 失败信息只经 S2 的固定文案/安全 details 透出;若 S2 details 扩展含值需同步检查。
|
||||
10. 没有写权限节点登记到公司 `standards://api/permission-nodes`(本次 sy-standards 检索未执行;节点串按任务指令原样使用)。
|
||||
|
||||
## 残余风险
|
||||
|
||||
- 预览会对真实源库执行用户 SQL(只读保证依赖 S2 与只读账户);本片未新增任何绕过 `assert_usable` 的路径。
|
||||
- 并发 publish 依赖行锁+唯一约束;未写并发测试(测试库单进程)。
|
||||
- `published_by` 取 `login_name`(非 Casdoor subject);如审计需要稳定主体 id 应改为 subject。
|
||||
|
||||
## 文档同步
|
||||
|
||||
无设计语义变化需要更新 `docs/`;`docs/progress.md`、M04 任务卡、`knowledge-map` 由主 Agent 更新。
|
||||
@@ -0,0 +1,16 @@
|
||||
# Review S4 — HTML prototype
|
||||
|
||||
## Status
|
||||
|
||||
PASS — static prototype delivered for maintainer UX confirmation.
|
||||
|
||||
## Files
|
||||
|
||||
- `.task/2026-11-18/m04-queries/prototype/index.html`
|
||||
- `.task/2026-11-18/m04-queries/prototype/README.md`
|
||||
|
||||
## Notes
|
||||
|
||||
- Covers gate, empty/list, draft edit, version readonly, preview outcome switcher, publish confirm.
|
||||
- Follows D22 footer/list button rules and M03 prototype interaction pattern.
|
||||
- User execute-all-todos authorization (2026-11-18): S5 proceeds using prototype defaults documented in README (preview saved draft; disable allows click-then-reject for preview; name-based masking).
|
||||
@@ -0,0 +1,26 @@
|
||||
# Review S5 — Vue queries console
|
||||
|
||||
## Status
|
||||
|
||||
PASS_WITH_WARNINGS — module landed; unit/typecheck verified in session; e2e evidence pending formal S6 run.
|
||||
|
||||
## Scope delivered
|
||||
|
||||
- `web/apps/console/src/queries/**` — list/edit/gate/version/preview helpers
|
||||
- Routes under `/queries` in `router.ts`; nav/crumbs in `AppShell.vue`
|
||||
- `allowsQueries` admin gate in `session.ts`
|
||||
- Locales (四语言) + `docs/current/frontend-ui.md` 查询节
|
||||
- Unit specs: validation/payload/client/errors/locales
|
||||
- E2E: `web/apps/console/e2e/queries.spec.ts` (mocked API)
|
||||
|
||||
## UX defaults locked for S5
|
||||
|
||||
- Preview saved draft; dirty form disables preview / prompts save before publish
|
||||
- Disabled: list preview disabled; detail preview click → 409 explanation
|
||||
- Masking via API `masked_columns`
|
||||
|
||||
## Remaining for S6
|
||||
|
||||
- Formal Playwright run + screenshots under `docs/evidence/M04/ui/`
|
||||
- Independent module review across S1–S5
|
||||
- Full pytest regression
|
||||
Reference in new issue
Block a user