Files
mnote/bugs/05-editor-mainline/done/5-22-documents-content-strips-editor-document-before-page-aggregate-v1.md
T

63 lines
2.0 KiB
Markdown
Raw Normal View History

2026-05-19 08:11:58 +08:00
# 5-22 [done][bug] documents.content.get 在 Page Aggregate 前剥离原生块文档字段 v1
> 发现时间:2026-05-18
>
> 状态:`[done]`
>
> 关联主线:`05-editor-mainline`
## 1. 问题定义
`page.aggregate.get` 已支持按 `editorDocument -> blockDocument -> documents.content` 的顺序构建正文真相,但 `/api/page-aggregate/:id` 主链会先通过 `documents.content.get` 读取内容。
旧的 `DocumentContentResult` 只保留:
- `content`
- `revision`
- `conflictDetectionKey`
- `title`
- `pageSubtree`
上游返回的 `editorDocument / blockDocument / tiptapDocument` 被提前剥离,导致 Page Aggregate route 真实运行时仍回落到 `documents.content`
## 2. 根因
`bridge-runtime``build_document_content_result` 没有把原生块文档字段带入 `DocumentContentResult`
这使 5-19 的 Page Aggregate 优先级修复只在合成输入测试里成立,真实 `mnote-web` route 入口仍拿不到原生字段。
## 3. 修复
- `core-protocol::DocumentContentResult` 新增可选字段:
- `editorDocument`
- `tiptapDocument`
- `blockDocument`
- `blockProjectionVersion`
- `build_document_content_result` 保留这些上游字段。
- `mnote-web` Page Aggregate route 回归测试加入含 `editorDocument``documents:getContent` fixture,并断言:
- `body.projectionSource=editorDocument`
- `body.blockDocument.rootBlockIds[0]=editor_1`
- `body.blockDocument.blocks[0].text` 来自 `editorDocument`
## 4. 验证
RED
```bash
cargo test --manifest-path rust/Cargo.toml -p mnote-web page_aggregate_endpoint_returns_snapshot_contract -- --nocapture
```
旧实现失败,`projectionSource` 仍为 `documents.content`
GREEN
```bash
cargo test --manifest-path rust/Cargo.toml -p mnote-web page_aggregate_endpoint_returns_snapshot_contract -- --nocapture
```
结果:`1 passed`
## 5. 剩余边界
这修复的是 Rust route 读取链字段保留;底层 Convex schema/mutation 是否已完整原生落库仍按后续持久层迁移继续跟进。