Route `get <uuid>` agent mode through download_and_apply_patches_into instead of a second copy of the engine

未关闭
#1,835 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
cli

调研方向

Start in crates/socket-patch-cli/src/commands/get.rs at the UUID agent-mode path and compare it with download_and_apply_patches_into in crates/socket-patch-cli/src/commands/agent_download.rs. Read the existing UUID tests in get.rs and tests/get/, then route the fetched patch through the shared engine and remove the duplicate helpers. Done when the listed output, save-only, dry-run, and nested-apply behaviors meet the acceptance criteria and the UUID tests pass.

由索引模型根据 Issue 内容生成。

描述

agent:triaged arch-audit priority:p3 refactor

[agent] Filed by the scheduled architecture audit (audit-cli-tests). Register: register comment.

Kind: refactor. Register ID: T01.

Problem

get <uuid> in agent mode does not use the shared download engine. Instead, save_patch_record plus save_and_apply_patch (get.rs L1931-L2172, about 240 lines) repeat, for a single patch, every step of download_and_apply_patches_into (agent_download.rs L1700-L1886):``

  • the lock acquire;
  • the fail-closed manifest read-modify-write;
  • the files_for_manifest guard;
  • decide_patch_action;
  • write_all_patch_blobs and the unwind on failure;
  • the uuid-drift and gitignore warnings;
  • the lock hand-off and the nested apply;
  • record_apply_outcome.

The copies have already drifted:

  • No-files message: "Patch X has no applicable files; nothing to apply" in get.rs L1951, against "patch has no applicable files" in the engine.```
  • Blob failure: get prints its own "Error: Blob decode or write failed for patch" line and builds a different envelope (L1976-L1995).
  • Unchanged record: the uuid path re-applies a record that hasn't changed (L2064-L2068). The engine applies only added or updated records.
  • persist_blobs: the uuid path ignores DownloadParams.persist_blobs.

The engine already supports a pre-fetched patch: fetch_selected_patches takes a prefetched map, and the vendored arm of the uuid path already goes through download_patch_records_preflighted with it.

Proposed change

  • Build the one-element prefetched map from the PatchResponse that get <uuid> fetched, and call download_and_apply_patches_into, as the vendored arm does.
  • Delete save_patch_record and save_and_apply_patch.
  • If the re-apply of an unchanged record (#454) is still wanted, make it an engine rule for every caller, not a get-only branch.

Size

get.rs and possibly agent_download.rs. About −230 / +30 lines.

Acceptance criteria

  • get <uuid> human and --json output stay the same, except the no-files and blob-failure wording, which takes the engine's form.
  • The existing get uuid tests in get.rs mod tests and tests/get/ stay green, and they are updated only where they pinned the drifted wording.
  • --save-only, --dry-run and the nested-apply exit codes are unchanged.
主要语言
Rust
星标
8
派生
2
平均合并
18 小时 47 分钟
30 天内合并 PR
637

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

SocketDev/socket-patch 的其他 Issue

查看 SocketDev/socket-patch 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。