Skip to content

阶段1: 底层写闸门(核心锁) - #281

Merged
taekchef merged 8 commits into
mainfrom
codex/filemodel-phase1-write-gate
Aug 21, 2026
Merged

taekchef merged 8 commits into
mainfrom
codex/filemodel-phase1-write-gate

Conversation

@taekchef

Copy link
Copy Markdown
Collaborator

实际改动

  • 新增 writeNotebookMarkdownThroughGate:全仓唯一笔记写盘闸门。文件在场时写前重读磁盘 digest:
    • 重读失败或调用方无基线 ⇒ .writeRefusedKeepContent 拒写,待写内容保留草稿
    • 摘要不符 ⇒ 待写内容先入备份环(副本先行)再抛 .diskChangedAdoptDisk,调用方采用磁盘并刷新编辑器(adoptExternalDiskNote)
    • 一致 ⇒ 原子写,写后刷新 noteBacking/lastSelfWritten 双 digest
  • writeNoteMarkdownTriple 改为闸门薄封装;P0 模板守卫此阶段并存
  • rename 标题改写直写点改走闸门(身份偷换回滚与写后校验保留,digest 簿记快照恢复防泄漏)
  • repair restoreDraft 直写点改走闸门(备份先行保留)
  • retryRestoredPendingNoteWrites / persistAgentActionNote / persistCourseOwnedNote 经 persistNote→triple 自动覆盖
  • SelfCheck 新增 SAFETY 断言:notebookMarkdownWriter 直接调用全仓白名单唯一 + 闸门语义存在

未做内容

  • swift test 本机无法执行,由 CI 执行 WriteGateSafetyTests + 全量回归

共享核心面占用

  • WorkspaceStore.swift(loadedCourseNoteTextByItemID 去 private)
  • WeiBeiSelfCheck/main.swift(新断言块)
  • 合并即释放

验证命令

  • swift build ✅ / WeiBeiSelfCheck ✅ / check_file_growth ✅ 零增长
  • swift test → CI

回退自查表(六条)

  1. 可见性:采用磁盘时条内状态刷新,无静默丢失,通过
  2. 数据安全:新增备份先行+拒写通道,只升不降,通过
  3. 编辑:光标下内容被换可能性降低(比对在唯一写点),dirty 守卫未动,通过
  4. 性能:比对仅在低频写回时点发生,无逐键开销,通过
  5. 功能:多机搬运/搜索索引/Agent 授权/崩溃恢复未动,通过
  6. 可逆:独立提交可整体回滚,模板守卫并存期行为兼容,通过

- writeNotebookMarkdownThroughGate: 写前重读磁盘digest比对基线; 无基线或重读失败拒写留草稿; 不符先备份待写内容再采用磁盘
- writeNoteMarkdownTriple 改为薄封装接入闸门(模板守卫并存); rename改写与repair restoreDraft改走闸门
- retry/agent写路径经persistNote自动覆盖; 新增adoptExternalDiskNote采用磁盘并刷新编辑器
- SelfCheck新增SAFETY断言: notebookMarkdownWriter直接调用白名单唯一+闸门语义存在
@taekchef
taekchef marked this pull request as ready for review August 21, 2026 20:54
@taekchef
taekchef merged commit c7018f0 into main Aug 21, 2026
6 of 10 checks passed
taekchef added a commit that referenced this pull request Aug 22, 2026
…gence

revert: 回退文件模型收敛与库迁移方案全部已合并 PR(#277 #280 #281 #286)
@taekchef
taekchef deleted the codex/filemodel-phase1-write-gate branch August 22, 2026 01:19
wang-kaopu pushed a commit to wang-kaopu/weibei that referenced this pull request Aug 22, 2026
…model-phase1-write-gate"

This reverts commit c7018f0, reversing
changes made to 47e1da8.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant