[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)
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.
VendorSource has one variant, and its predicates are constant.
- 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.
- 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
Dependencies
[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)PatchSources::mem_blobsis neverSomein production.mem_blobs: None:commands/vendor.rs(6 sites),vendored_backend/mod.rs:71,repair.rs:413,fetch_stage.rs:39andvendor/npm_flavor.rs:546,763.vendor/test_support/service_fixture.rs:167.VendorSourcehas one variant, and its predicates are constant.enum VendorSource { Service }:may_use_service()andrequires_service()both returntrue, andas_tag()always returns"service".VendorServiceConfig.sourcecarries no information.LEDGERSincludes.socket/vendor/redirect-state.json.save_redirect_state(patch/redirect/state.rs:147-156) is#[doc(hidden)]and test-only.retire_legacy_redirect_ledgerinrollback.rs/remove.rs, runs outside anyGroupCommit, whose only production scope is thevendorloop.switched_off("group_commit")oracle keeps the pre-group-commit path alive.vendor.rs:2273-2275skipsGroupCommit::beginunderSOCKET_PATCH_SWITCH_OFF=group_commit, a debug-only env var.tests/vendor_group_commit_e2e.rs(304 lines) uses it, as an equivalence oracle for a change that has already landed. It is the onlyswitched_offcall site.Not dead (ruled out): the
Pypi/LauncherCacheupdate channels inupdate/channel.rs. They detect pre-v5 pip/gem installs so that--updaterefuses 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:
mem_blobsfield, its branch inapply.rs, its ~25mem_blobs: Noneinitializers and the fixture read;VendorSource::{may_use_service, requires_service}and the always-true condition atvendor.rs:141. KeepVendorSource::parseand the--vendor-sourceflag, because acceptingservice/autoand rejectingbuildis contract (CLI_CONTRACT "Prebuilt vendor artifacts"). Removing the flag is out of scope (decision C35);redirect-state.jsonentry fromgroup_commit::LEDGERS, along with its doc line and its test row (group_commit.rs:1071);switched_off("group_commit")guard,failpoint::switched_offif it is then unused, and the oracle test (or turn it into a golden check of the group-commit output).Size and scope
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.--vendor-sourceremoval, the update channels, the pre-v5 redirect ledger readers (migration).Acceptance criteria
grep -rn mem_blobs cratesreturns nothing.VendorSourcehas no always-true predicate, and--vendor-source service|autostill parses whilebuildis still rejected (theargs.rstests stay green).group_commit::LEDGERSlists only.socket/vendor/state.json; the group-commit crash and replay tests stay green.SOCKET_PATCH_SWITCH_OFFreference remains (or one documented user, if a maintainer wants to keep the mechanism).cargo test -p socket-patch-core --libandcargo test -p socket-patch-clistay green;cargo clippy --workspace --all-features -- -D warningsstays clean.Dependencies
patch/apply.rsis touched by open PRs Fix agent mode patching linked first-party source (#626) #634, Full Gradle support in agent, hosted and vendored modes #646 and sbt, Mill and scala-cli support in agent, hosted and vendored modes #690; land after them, or keep theapply.rshunk to the two lines.