Files

75 lines
2.8 KiB
Markdown
Raw Permalink Normal View History

# 4-41 [done][bug] tree.node.purge commandProtocol 泄漏到 Convex validator v1
> 更新时间:2026-05-16
>
> 分类归属:
> - `04-tree-domain/done`
>
> 关联文档:
> - `/mnt/Data1T/mnote/design/10-review/process/08-kernel-architecture-next-priority-review-and-checklist.md`
> - `/mnt/Data1T/mnote/design/03-rust-web/process/3-3-rust-web-tree-realtime-event-stream-v1.md`
## 1. 问题定义
`tree.node.purge` / `documents.purge` 的 Rust execution plan 会携带 `commandProtocol` 审计字段,用于标记正式 tree command 与 compat alias 的关系。但发往 Convex legacy mutation `documents:purge` 时,这个字段不应进入 mutation args。
实际运行中,`task432-filetree-trash-page-dual-browser-no-refresh-smoke.js` 在 purge 阶段触发 Convex validator 502
```text
ArgumentValidationError: Object contains extra field `commandProtocol` that is not in the validator.
Object: {commandProtocol: {...}, id: "..."}
Validator: v.object({id: v.string()})
```
这会阻断双浏览器 File Tree / Trash no-refresh 验收中的彻底删除阶段。
## 2. 根因
`rust/crates/bridge-runtime/src/lib.rs``documents.purge | tree.node.purge` plan 会生成:
```json
{
"id": "...",
"commandProtocol": {
"family": "tree",
"owner": "rust-runtime-kernel",
"preferredCommandName": "tree.node.purge",
"compatCommandName": "documents.purge"
}
}
```
`rust/crates/mnote-web/src/transport/convex.rs``convex_command_args_for_plan` 只对 create / rename / archive / restore / move 等命令调用 `strip_tree_artifact_fields`,漏掉了 `tree.node.purge``documents.purge`
## 3. 修复
`rust/crates/mnote-web/src/transport/convex.rs` 已将以下命令加入 legacy mutation artifact 剥离名单:
- `tree.node.purge`
- `documents.purge`
新增回归测试:
- `convex_command_args_strips_tree_purge_artifacts_for_legacy_mutation`
## 4. 验证
已通过:
```bash
cargo test --manifest-path rust/Cargo.toml -p mnote-web convex_command_args_strips_tree_purge_artifacts_for_legacy_mutation -- --nocapture
cargo test --manifest-path rust/Cargo.toml -p mnote-web convex_command_args_strips_tree_archive_artifacts_for_legacy_mutation -- --nocapture
MNOTE_UI_BASE_URL=http://127.0.0.1:3000 MNOTE_AUTH_BASE_URL=http://127.0.0.1:3000 node scripts/task432-filetree-trash-page-dual-browser-no-refresh-smoke.js
```
真实 smoke 证据:
- 修复前失败:`tmp/task432-filetree-trash-page-dual-browser-no-refresh-smoke/result.json` 曾记录 `documents:purge``commandProtocol` 额外字段返回 502。
- 修复后通过:`tmp/tree-live-cache-smoke/20260516-task432/result.json``ok=true`,覆盖 create / archive / restore / purge / empty trash 在 B 端 File Tree 与 Trash 无刷新同步。
## 5. 状态
当前状态:`done`
该缺陷已在真实代码中修复,并通过单测与真实 3000 双浏览器 smoke 验证。