Files
mnote/bugs/07-ai/done/7-26-resource-block-normalized-to-paragraph-ai-projection-v1.md
T
lix-2026 a2cb1338c8 chore: 保存当前架构收口与 bug 修复快照
归档本轮 P0/P1 bug 修复、设计审查迁移、AI selection scope 收口与 stream contract 调整,并保留当前 05 主线迁移起点。
2026-05-18 17:01:35 +08:00

2.1 KiB
Raw Blame History

7-26 [done] Resource 块保存后在 AI block projection 中被降级为 paragraph

状态

  • Owner07-ai / Page Block AI projection 写入前置合同
  • 优先级:P0,影响 AI 精确块编辑安全边界
  • 状态:已修复并验证

现象

真实 3000 smoke 扩展复杂块后,mnote.page.save 写入 type:"resource" 的块,再经 Page Aggregate / AI block projection 回读时,resource_1 被显示为:

  • type="paragraph"
  • editable=true
  • unsupportedReason=null

这会让 AI 工具把资源占位误判为普通可编辑文本块,违反复杂块不得伪装完全可编辑的合同。

根因

core-protocolEditorBlockType 没有 Resource 变体,bridge-runtimenormalize_editor_block_type_for_save() 因此把未知 resource 类型落入默认 Paragraph。后续 legacy_content_from_editor_document()project_legacy_content_to_block_document() 只能看到 paragraph,导致 AI projection 误报可编辑。

修复

  • rust/crates/core-protocol/src/editor/model.rs 增加 EditorBlockType::Resource
  • 在 Tiptap bridge 中用 mnoteBlockType=resource 保留 resource 类型往返。
  • bridge-runtime 中让 resource/resource_block 规范化为 EditorBlockType::Resourcelegacy 回写继续输出 type:"resource"
  • 保留 resource props 到 resourcePropslegacy 回写时恢复。
  • editor_actor block 类型摘要中补 resource
  • 扩展 scripts/task-page-block-ai-tools-smoke.js,覆盖 resource 在真实 3000 的投影和 move 阻断。

验证

  • cargo test --manifest-path rust/Cargo.toml -p bridge-runtime editor_document_roundtrip_preserves_resource_block_type -- --nocapture
  • cargo test --manifest-path rust/Cargo.toml -p mnote-web hermes_tools_block_move_after_blocks_complex_and_nested_blocks -- --nocapture
  • PLAYWRIGHT_CHROME_EXECUTABLE=/snap/bin/chromium MNOTE_UI_BASE_URL=http://127.0.0.1:3000 MNOTE_AUTH_BASE_URL=http://127.0.0.1:3000 node scripts/task-page-block-ai-tools-smoke.js

最新真实 smoke 证据:tmp/page-block-ai-tools-smoke/mpag4966.json,截图:tmp/page-block-ai-tools-smoke/mpag4966-page.png