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

Aperta
#1,835 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
cli

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
Rust
Stelle
8
Fork
2
Merge medio
19h 24m
PR unite (30g)
669

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di SocketDev/socket-patch

Tutte le issue di SocketDev/socket-patch

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.