Skip to content

[6234] 假附件缓存标注供应商并在ready前确认落盘 - #4767

Merged
PinkMagicFly merged 2 commits into
mainfrom
pigmagicfly/6234/attachment-fake-cache-supplier
Oct 27, 2026
Merged

PinkMagicFly merged 2 commits into
mainfrom
pigmagicfly/6234/attachment-fake-cache-supplier

Conversation

@PinkMagicFly

@PinkMagicFly PinkMagicFly commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

概要

Mogan 内置假附件插件完成两件事(配套任务文档见 LiiiLabs/dev-agent devel/6234.stem):

  • 新生成的抽取缓存 result.json 在载荷 [1] 中写入 supplier=fake,明确数据来自假插件;命中刷新保留缓存原文 [1](不重造 content、不丢原 supplier)。
  • 返回 ready 前独立回读当月 extract/<yyyymm>/<sha256>/result.json,确认 [0].id 等于本次 sha256 且 [1] 与本次应保存的完整载荷一致;首次写入与命中刷新共用同一条确认路径,任一失败返回带原 taskId 的 error 事件(附件缓存写入失败,请重试),不得 ready。

实现要点

  • attachment-fresh-entry 成为新缓存 [1] 的唯一构造点;attachment-cache-put! 三参签名不变,写盘后返回本次应保存的 [1](expected-payload,只是预期值,不代替落盘确认)。
  • 新增 attachment-cache-payload-stored?:只读当月目标文件,比较解析后的 JSON 结构(非文本);文件缺失、非法 JSON、非二元 vector、id 不符、payload 不符均返回 #f;只读不写、不删坏缓存、不重试。
  • fake-attachment-ready-event:put → 回读确认 → ready/error;写入抛异常仍由 fake-attachment-ingest 既有 catch 兜底为同款 error。
  • tm-llm.scm 仅更新契约注释。

不变项

  • ready 六键、%attachment 请求协议不变。
  • 假 LLM 仍只读取 content,不读取、不回显 supplier。
  • 旧缓存不迁移、不补字段、不加版本号。

测试

实际执行的命令与结果(macOS arm64,releasedbg):

gf fix TeXmacs/plugins/attachment/goldfish/tm-attachment.scm
gf fmt --changed-since=main
gf fmt --check          # OK: all files formatted
xmake b stem            # build ok
xmake r chat-protocol-test   # 120 correct, 0 failed(测试脚手架归并后复验仍 120/0)
git diff --check        # 通过

新增/扩展用例(chat-protocol-test.scm):

  • 新缓存 supplier:直读当月 result.json 断言 [1].supplier=="fake"、[0].id 正确、content 为假提取文本。
  • 回读确认助手逐场景:一致 #t;文件不存在 / 非法 JSON / 非二元 vector / id 不符 / content 不符 / supplier 不符或缺失 / 只有上月文件均 #f。
  • put no-op(最关键):attachment-cache-put! 替换为正常返回但不写文件,ingest 必须 error、不得 ready——证明实现不是只检查 put 返回值。
  • 非法或不一致缓存:写入非法 JSON / 错误 id / 篡改 content,均 error。
  • 命中刷新:上月有效缓存 + 当月无文件 + 刷新 no-op 时,即使上月文件存在也 error;正常命中刷新当月回读一致(content/supplier 保留、ts 刷新)后才 ready。
  • put 抛异常(disk-full 注入):error + 原 taskId,dynamic-wind 保证断言失败也恢复全局函数。
  • 假 LLM 回归:supplier 不影响 content 注入、不出现在回显正文;未知 sha 无注入行。

GUI 手动验收步骤见 dev-agent devel/6234.stem 3.1 节,待人工执行。

范围边界

  • 真实 liii 插件链路属于配套任务 2118,本 PR 未验证真实 kimi/local。
  • 未修改 2115 相关文件,未混入 2118 的 liii 代码与手动驱动。

🤖 Generated with Claude Code

@MoonL79 MoonL79 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@PinkMagicFly
PinkMagicFly merged commit 474a2f3 into main Oct 27, 2026
3 checks passed
@PinkMagicFly
PinkMagicFly deleted the pigmagicfly/6234/attachment-fake-cache-supplier branch October 27, 2026 08:43
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.

2 participants