Skip to content

Tracking: one agent-mode patch engine for apply and rollback #771

Description

[agent] Filed by the scheduled architecture audit routine (CLI and core). Register: discussion #560 register.

Kind: tracking. Source: review 7.4 and 7.6 #4; register C24.

Problem

Verified on main @ 045d7ec. Agent-mode apply (patch/apply.rs, 3,665 lines) and rollback (patch/rollback.rs, 2,585 lines) implement one transformation in two directions, written twice:

Concern apply rollback Drift
Verify types VerifyStatus/VerifyResult VerifyRollbackStatus/VerifyRollbackResult identical fields; rollback adds MissingBlob
Per-file verify verify_file_patch verify_file_rollback same guard, hash, and before/after comparison with the roles swapped; exact == in both (#707)
pnpm/vlt store-copy fan-out apply_package_patch rollback_package_patch copy-pasted loop
Copy result fold fold_copy_result fold_copy_result drifted: apply carries only the ownership advisory, rollback any advisory; both drop the copy's per-file records (#756)
Sidecar boundary dispatch_fixup dispatch_rollback_fixup same best-effort wrapper

Symptoms

Target design

One engine in patch/engine.rs, parameterized by Direction { Apply { sources, policy }, Rollback { blobs } }:

  • one FileVerify { file, status, message, current_hash, expected_hash, target_hash } with one FileStatus (Ready, AlreadyDone, HashMismatch, NotFound, MissingSource);
  • one PackageOutcome with files_changed (today's files_patched and files_rolled_back);
  • one store-copy fan-out and fold, and one sidecar boundary.

apply_package_patch/rollback_package_patch stay as thin public wrappers, so the CLI does not change.

Checklist (ordered; each one is a PR)

Acceptance criteria

  • Every child has landed, and patch/rollback.rs holds only the rollback-specific source logic (before-blob probe, new-file delete).
  • The core apply/rollback unit tests and the CLI apply, rollback, remove and repair integration tests stay green throughout.

Dependencies

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent:triagedarch-auditFiled by a scheduled architecture audit routine (see the architecture review discussion)priority:p3refactorStructural change: duplicated code or logic, missing abstraction, layering, dead code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions