Skip to content

scan --prune's vendored GC reverts entries by hand instead of through VendoredBackend::revert, and drops each revert's error and still-wired orphans #1910

Open

Description

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

Kind: refactor. Register ID: T37 (child of T16/#1861).

Problem

VendoredBackend::revert (vendored_backend/mod.rs L137-L200,`` plus revert_vendor_entry at L360-L391)``` is the shared vendored undo. remove, rollback and `vendor --revert` call it.

run_vendor_gc L4964-L5132, which scan --prune uses, does not. It calls dispatch_revert_one directly at L4978 and L5047 and redoes the classification, the advisories and the ledger write by hand. Its leg (a) reverts the same manifest_dropped_purls set that reconcile_dropped reverts through the backend.

The hand copy has drifted:

  • It drops the revert error. It never reads outcome.error: on failure it only does out.failed.push(purl). Neither run_vendor_gc nor dispatch_revert_one_opts prints anything. Yet scan/gc.rs L529-L531 says "the backend's own error was printed as it happened". revert_vendor_entry keeps the error (VendorRevertStep::Failed(outcome.error…), L374).
  • It saves the ledger once at the end (L5077), not per entry the way revert_vendor_entry does.
  • It drops KeepCause::Reference. A keep caused by a residual reference is reported as a drift ("undo the drift", scan/gc.rs L517-L527).
  • It drops the orphan sweep's still_wired set (L5125-L5131). remove, rollback and vendor --revert each report it.
  • It runs no go_undo_warnings.

I read all of this from the code and executed none of it.

Proposed change

  • run_vendor_gc legs (a) and (b) call VendoredBackend::revert and fold the returned RevertedEntry steps into VendorGcSummary, keeping each failure's detail.
  • Report still_wired the way vendor --revert does.
  • Delete the GC's own classification. gc_note loses its unused _code parameter.
  • Make scan/gc.rs print the carried failure detail, and fix the comment.

Size

vendor.rs, scan/gc.rs. About −60 / +30 lines.

Acceptance criteria

Activity

  1. added
    arch-audit
    refactor
    on Nov 1, 2026
  2. mikolalysenko commented on Nov 1, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Triaged: priority:p3 (cross-cutting vendored GC refactor). Related to #1861 (remove/rollback render VendorRevertStep) but a different code path (run_vendor_gc bypassing VendoredBackend::revert), so tracked separately. No open PR covers it.


    Generated by Claude Code

  3. mikolalysenko commented on Nov 25, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Claiming this for the architecture refactor routine. Branch: arch-refactor/1910-prune-gc-keep-cause.

    Ran two of this issue's claims on main at 332b3e8 with a unit test in scan/gc.rs; both hold:

    • A keep that is not a drift is reported as one. A requirements project whose patch left the manifest, with a second requirements file that still installs from the vendored wheel: the pass restores requirements.txt, keeps the wheel and the ledger entry, and prints GC: kept 1 drifted vendored entry: lock entries were re-resolved since vendoring, so their artifacts and manifest/ledger entries were retained; undo the drift and re-run vendor --revert to finish. Nothing drifted, the recorded wiring was restored, and the file that still installs from the wheel is never named (its vendor_revert_residual_reference warning is dropped). remove and rollback report this keep correctly since remove and rollback call a vendored PyPI residual-reference keep "lockfile wiring drifted", and their "re-run scan --mode vendored to normalize, then remove" remedy loops (Pipenv pipenv requirements export) #1184.
    • A failed revert loses its reason. With requirements.txt a symlink the revert refuses, and the pass prints only GC: failed to revert 1 vendored entry: pkg:pypi/six@1.16.0.

    Scope of the PR: those two (the keep cause and the failure reason), in run_vendor_gc and scan/gc.rs. Moving the pass onto VendoredBackend::revert wholesale, the orphan sweep's still-wired set and the Go undo warnings stay open here.


    Generated by Claude Code

  4. added a commit that references this issue on Nov 25, 2026
  5. mikolalysenko commented on Nov 25, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Architecture refactor routine: the still_wired bullet is now run, not just read. It holds on main at 9a2a946.

    Project. requirements.txt installs from .socket/vendor/pypi/<uuid>/six-1.16.0-py2.py3-none-any.whl, and .socket/vendor/state.json is a valid ledger with no entry for that uuid (what a git merge that kept one side of state.json leaves).

    Command Exit What it says
    vendor --revert --dry-run --json 0 a skipped event, vendor_orphan_still_wired: "a project lockfile still points at .socket/vendor/pypi/, which no ledger entry owns; the artifacts were kept (restore the missing entries …)"
    rollback --dry-run --json --offline 1 vendor_ledger_missing, with the same remedy
    scan --prune --json --dry-run 0 status: "success", no warnings, a gc of zeros
    scan --prune (human, wet) 0 nothing about the directory

    The wheel is kept in every case, so nothing breaks: the defect is only that the prune pass computes the still-wired set (sweep_orphan_vendor_dirs) and drops it, where the three other callers of the same sweep report it.

    It is a small fix in run_vendor_gc, the function #2253 has to change to report a ledger it could not read. The two fit in one PR; I have noted that in the register. The Go undo warning (the last bullet) is still unverified: the sandbox has no Go toolchain.


    Generated by Claude Code

  6. mikolalysenko commented on Nov 25, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Architecture refactor routine: the still_wired bullet is fixed in #2261, with #2253. scan --prune now reports vendor_orphan_still_wired for a vendored directory that no ledger entry owns and a project file still installs from, also when the ledger holds no entry at all.

    What remains here after #2246 and #2261:

    • the Go undo warning after the pass reverts a vendored Go module (not verified: the routine's sandbox has no Go toolchain);
    • the per-entry ledger save and the move onto VendoredBackend::revert, which have no demonstrated defect.

    Generated by Claude Code

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-auditpriority:p3refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions