Skip to content

Delete PatchSources::mem_blobs, the single-variant VendorSource predicates, the redirect-state group-commit capture and the group_commit switch-off oracle #746

Description

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

Kind: refactor (dead code; no behavior change). Source: review 7.4, 7.6 #3, 5.6; register C23.

Problem (verified on 045d7ec)

  1. PatchSources::mem_blobs is never Some in production.
    • The field says vendor flows "stage their patch content here". Every production constructor passes mem_blobs: None: commands/vendor.rs (6 sites), vendored_backend/mod.rs:71, repair.rs:413, fetch_stage.rs:39 and vendor/npm_flavor.rs:546,763.
    • Its only readers are the apply branch and vendor/test_support/service_fixture.rs:167.
  2. VendorSource has one variant, and its predicates are constant.
  3. Group commit captures a ledger that nothing in its scope writes.
    • LEDGERS includes .socket/vendor/redirect-state.json.
    • v5 never writes that file. save_redirect_state (patch/redirect/state.rs:147-156) is #[doc(hidden)] and test-only.
    • The only deleter, retire_legacy_redirect_ledger in rollback.rs/remove.rs, runs outside any GroupCommit, whose only production scope is the vendor loop.
  4. The switched_off("group_commit") oracle keeps the pre-group-commit path alive.
    • vendor.rs:2273-2275 skips GroupCommit::begin under SOCKET_PATCH_SWITCH_OFF=group_commit, a debug-only env var.
    • Only tests/vendor_group_commit_e2e.rs (304 lines) uses it, as an equivalence oracle for a change that has already landed. It is the only switched_off call site.

Not dead (ruled out): the Pypi/LauncherCache update channels in update/channel.rs. They detect pre-v5 pip/gem installs so that --update refuses to swap a package-manager-owned binary and prints a migration hint. That is a live safety refusal, so they stay.

Symptoms / impact

There are no user-visible bugs. The cost falls on readers: two documented mechanisms that do nothing, an unconditional branch dressed as a policy, and a debug env var (SOCKET_PATCH_SWITCH_OFF) that keeps a second code path compiled into debug builds.

Proposed change

Delete:

  • the mem_blobs field, its branch in apply.rs, its ~25 mem_blobs: None initializers and the fixture read;
  • VendorSource::{may_use_service, requires_service} and the always-true condition at vendor.rs:141. Keep VendorSource::parse and the --vendor-source flag, because accepting service/auto and rejecting build is contract (CLI_CONTRACT "Prebuilt vendor artifacts"). Removing the flag is out of scope (decision C35);
  • the redirect-state.json entry from group_commit::LEDGERS, along with its doc line and its test row (group_commit.rs:1071);
  • the switched_off("group_commit") guard, failpoint::switched_off if it is then unused, and the oracle test (or turn it into a golden check of the group-commit output).

Size and scope

  • Production: about −60 lines. Tests: about −350 lines.
  • Files: patch/apply.rs, vendor/{mod,npm_flavor}.rs, vendor/test_support/service_fixture.rs, utils/{group_commit,failpoint}.rs, commands/{vendor,repair,fetch_stage}.rs, commands/vendored_backend/mod.rs, tests/vendor_group_commit_e2e.rs.
  • Out of scope: --vendor-source removal, the update channels, the pre-v5 redirect ledger readers (migration).

Acceptance criteria

  • grep -rn mem_blobs crates returns nothing.
  • VendorSource has no always-true predicate, and --vendor-source service|auto still parses while build is still rejected (the args.rs tests stay green).
  • group_commit::LEDGERS lists only .socket/vendor/state.json; the group-commit crash and replay tests stay green.
  • No SOCKET_PATCH_SWITCH_OFF reference remains (or one documented user, if a maintainer wants to keep the mechanism).
  • cargo test -p socket-patch-core --lib and cargo test -p socket-patch-cli stay green; cargo clippy --workspace --all-features -- -D warnings stays clean.

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