Conversation
Allocate a private directory for each prepare batch and return its run id. Target commit, resource verification, and explicit discard by that id. Keep failed backend commits retryable and remove successful runs completely. Document the CLI migration, executor ownership, and backend conflict boundary. BREAKING CHANGE: memorize commit and verify-resources require a run id. Co-authored-by: Codex <codex@openai.com> AI-Model: gpt-6-astra
Co-authored-by: Codex <codex@openai.com> AI-Model: gpt-6-astra
Report successful backend submission when snapshot refresh or working-file cleanup fails, so callers can discard the stopped run instead of resubmitting. Cover snapshot, job, and directory cleanup failures in regression tests. Co-authored-by: Codex <codex@openai.com> AI-Model: gpt-6-astra
|
补充当前实现的 run 创建、返回和清理流程,便于直接核对生命周期。 1. run 如何创建执行: memu memorize prepare session-1.json session-2.json --json顺序如下:
一次 prepare 对应一个 run。 同一次 prepare 的多个 session 共用该 run;不同 prepare 分配不同目录。 2. run-id 在哪里返回使用 {
"run_id": "run-a1b2c3d4",
"workspace": "/home/alice/.memu/developer/runs/run-a1b2c3d4",
"next_command": "memu memorize commit run-a1b2c3d4"
}完整响应还包含 应用应在启动 executor 前保存这些返回值。生成的 resource job 内部使用 3. 什么时候删除 run 目录
两个关键点:
4. 已做的简单实测使用两个真实 CLI 子进程,共享一个已初始化的临时 SQLite 数据库,同时 prepare 得到两个独立目录。对第一个执行 no-op commit 后,其整个目录及额外临时文件被删除,第二个 run 的全部文件逐字节保持不变;再 discard 第二个, 另外,25 项 run 专项测试通过,覆盖失败保留与重试、prepare 失败清理、提交成功后的清理错误,以及路径边界。 |
|
已建立供分层评审的 upstream stack,由 MrXnneHang 创建,使用与原 PR 相同的提交:
评审可在该 stack 中进行;最终合入仍由 xnne-bot 的 #698 / #699 承接。已核对两层 head 与原 PR 完全一致。后续评审修改需要同步回相应合入 PR。 |
📝 Pull Request Summary
为 developer CLI 的每次
memu memorize prepare自动分配独立 run workspace,解决多个应用调用共用固定目录、无法独立定位和清理失败运行的问题。一次 prepare 的 1–10 个 canonical session 仍属于同一个 run,由一个 executor 串行执行,再通过返回的 run-id 提交。Host adapters 的 prepare–commit 流程保持现有行为。
✅ What does this PR do?
tempfile.mkdtemp在~/.memu/developer/runs/下原子分配私有目录,返回run_id、workspace 和带 id 的next_command。commit <run-id>、生成指令中的verify-resources <run-id>定位同一个 run;拒绝路径穿越、未知 id 和重定向目录的链接。discard <run-id> [--json],用于 executor 停止后的显式清理,不调用 backend;也可清理进程中断留下的不完整 run。2N + 1个有序 jobs;底层接受显式 workspace 的 Python 函数保持原有目录生命周期。🤔 Why is this change needed?
主动 memorize 需要可独立跟踪、重试和结束的执行单元。每次调用拥有自己的目录后,待执行或失败的 run 不会占用其他调用的工作区。
在已合入的 #695 基础上,run 边界是一次 prepare 的整个 batch。