Skip to content

feat(core): #1662 第二轮 Agent 附件保留(AGT-06) - #1765

Merged
1lck merged 2 commits into
previewfrom
feat/issue-1662-r2-agent-attachments
Nov 5, 2026
Merged

1lck merged 2 commits into
previewfrom
feat/issue-1662-r2-agent-attachments

Conversation

@1lck

@1lck 1lck commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Issue #1662 第二轮【Agent 附件】车道,条目 AGT-06。

改了什么

  • 新增 Core 命令 agent.attachments.retentionPlan(纯函数,在 lithe-agent-host::attachment_retention,由 lithe-core 分发):输入缓存清单、已接受引用集合、当前时间,输出 delete / keep,每项带原因。规则:被引用则保留(即使被标记放弃);放弃或失败的粘贴删除;未引用且超过 7 天删除;修改时间未知不过期。路径比较统一分隔符,Windows 另外不分大小写。
  • 契约与 fixture:shared/fixtures/agent/attachment-retention-v1.json,shared/contracts/rust-core-api.md 补充说明。
  • 已接受引用的存放位置:两端各自平台缓存目录里与图片目录并列的账本文件(macOS Caches/AgentAcceptedAttachments.json,Windows appCacheDir/agent/pasted-images-accepted.json),发送被接受后追加(只记缓存目录内的文件,同时丢掉已不存在的文件)。不在 app bundle、安装目录,不跨 worktree。

两端行为变化

  • macOS:删除“每次粘贴清理 7 天前图片”的规则,改为列目录后调用 Core 计划再删除;历史会话引用的图片不再被删。发送成功后记录引用(AgentConversationView -> recordAcceptedAgentAttachments)。
  • Windows:以前不做过期清理;现在首次使用缓存目录时按同一计划清理过期且无引用的图片,放弃或失败的批次也改走 Core 计划(标记为 abandoned)。发送后记录引用(recordAcceptedPastedImages)。
  • 没有新增用户可见文案,未改 i18n。

新增 Core API

agent.attachments.retentionPlan

撤出的条目

无。

验证

  • cargo test -p lithe-core --lib agent 通过;cargo test -p lithe-agent-host -- --test-threads=2 通过(首轮曾有 1 个偶发失败,重跑 270 通过)。
  • Windows:bun run typecheck 通过;tests/agent-pasted-images.test.ts(6 项,含 fixture 驱动的启动清理和账本)与 agent-composer.escape.test.tsx 通过。
  • macOS:swift build --build-tests 通过;test-macos.sh --filter AgentAttachmentRetention(链接真实 Core,对照共享 fixture)通过。
  • 脚本:verify-rust-core-comments、verify-core、verify-shared-contracts、verify-service-boundaries、verify-windows-boundaries、verify-platform-feature-matrix、generate-i18n.mjs --check 通过。

未执行

  • 真实 GUI 粘贴/清理的人工验收;Windows 真机;verify-runtime-bundle-immutability.sh(本改动只写 Caches,未跑);cargo check --bin lithe-windows(未改 Windows Rust 代码)。

关联 #1662

🤖 Generated with Claude Code

新增 agent.attachments.retentionPlan:被会话接受的引用永不删除,放弃或失败的粘贴立即删除,未引用且超过 7 天的删除。macOS 和 Windows 删除各自的清理规则,只列目录、记录已接受引用的账本并执行 Core 返回的删除。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ghfind-review ghfind-review Bot added the review: high ghfind author score; see https://ghfind.com label Nov 5, 2026
Core 计划新增 ledgerPresent 输入和 seed 输出:只看账本文件是否存在,缺失时把现有的非放弃图片全部作为已接受引用并返回 seed,两端在删除前原子写入账本(临时文件加 rename)。账本存在但为空不再触发迁移。fixture 补两端共用的用例,Windows 补 fs rename 权限。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@1lck

1lck commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

本地集成验证(#1662 第二轮)

本 PR 与 #1765、#1768、#1767、#1766、#1769 一起,在本地集成分支 feat/issue-1662-r2-integration(基于 preview c1c7015)上验证。结果如下:

Rust

  • cargo test -p lithe-core:2130 个测试通过。
  • cargo test -p lithe-agent-host -- --test-threads=2:270 个测试通过。
  • cargo fmt --check -p lithe-core 通过。
  • cargo check --bin lithe-windows 在 macOS 上只有 2 个已知的 std::os::windows 错误,没有新增。

校验脚本
以下脚本全部通过:rust-core-comments、verify-core、shared-contracts、service-boundaries、windows-boundaries、platform-feature-matrix、两个 i18n 检查、runtime-bundle-immutability。

macOS

  • swift build --build-tests 通过。
  • test-macos.sh 跑了相关的 701 个测试,没有本次引入的失败:
    • cancellingSaveAllDuringRemoteDrainDoesNotWrite 在 preview 上同样失败,是既有问题。
    • 另外 3 个失败是高负载下的时序抖动,单独重跑能通过。

Windows 前端(在 Mac 上用 bun 跑)

  • bun run typecheck 通过。
  • 逐文件跑了 259 个测试文件,只有 3 个失败(git-status-display-order、matcher 的 IME 用例、agent-hooks-settings),在 preview 上同样失败,都是既有问题。

未执行
Windows 真机上的编译和测试没跑,因为 lithe-dev 服务器暂时连不上。

验证通过后用 --admin squash 合并,没有触发云端 macOS/Windows CI。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: high ghfind author score; see https://ghfind.com

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant