Skip to content

Build every tests/apply fixture through apply_fixture: 9 suites in the apply binary re-write the manifest, blob, package and event-lookup helpers it already has #1941

Closed

Description

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

Kind: refactor. Register ID: T51. Follows the closed tracking issue #824 (shared CLI test helpers), scoped to one test binary.

Problem

tests/apply/apply_fixture.rs (L28-L94) has run_apply, patch_record, one_file, write_manifest, stage_blob, install_npm_pkg, write_root_package_json, install_gem and write_gem_patch. Other modules of the same apply test binary write their own:

  • manifest + blob writers: apply_network.rs L22-L94,`` apply_invariants.rs L29-L66 (+ L156-L210, L540-L595), bun_global_store.rs L90-L120,```` pnpm_global_virtual_store.rs L93-L114,````` cargo_lock_source.rs L25-L46,`````` check_verifies_installed_tree.rs L31-L68``````` (+ L215-L247), lockfile_only_skip.rs L22-L72 (same names as apply_fixture's);
  • the rack@3.1.0 gem patch three more times: gem_stale_bundler_plugin.rs L40-L69,````````` in_process_gem_config_warning.rs L38-L76,`````````` in_process_gem_fallback_home.rs L32-L91,``````````` plus a fourth fallback-home fixture in apply_render.rs L304-L403;````````````
  • the event-by-purl lookup, identical, in bun_global_store.rs L124-L131,````````````` pnpm_global_virtual_store.rs L116-L123,`````````````` lockfile_only_skip.rs L150-L157,``````````````` cargo_lock_source.rs L137-L144 (common/envelope.rs has no by-purl finder);
  • link_dir identical in bun_global_store.rs L22-L37 and pnpm_global_virtual_store.rs L23-L38;
  • 13 explicit ("SOCKET_TELEMETRY_DISABLED","1") env pairs that hermetic::command already forces (hermetic.rs L72-L76).

Drift: exportedAt 2024 vs common::write_minimal_manifest's 2026; index.js vs package/index.js; three gem copies hand-format the JSON; gem_stale_bundler_plugin.rs L75-L90```````````````` spawns without the Extra::Bundle scrub every other gem runner applies, so an ambient `BUNDLE_*` reaches that child. `apply_fixture::write_manifest` and `common::write_minimal_manifest` (common/mod.rs L320-L386) are themselves two writers for one shape.

Proposed change

  1. Make apply_fixture the only fixture module of the apply binary: delete the local copies above and call its helpers; move the fallback-home human test from apply_render into in_process_gem_fallback_home.
  2. Add event_for(&Value, purl) -> &Value to common/envelope.rs and link_dir to apply_fixture.
  3. Implement apply_fixture::write_manifest/stage_blob on top of common::write_minimal_manifest/write_blob (add a records parameter there) so there is one manifest writer.
  4. Drop the redundant telemetry env pairs.

Size

~11 files in tests/apply/ plus common/envelope.rs; roughly −450/+60 lines. No product code.

Acceptance criteria

  • cargo test -p socket-patch-cli --test apply passes with the same test count.
  • No fn write_manifest, fn stage_blob, fn event( or fn link_dir outside apply_fixture.rs / common/ in tests/apply/.
  • gem_stale_bundler_plugin's child gets the Extra::Bundle scrub.

Activity

  1. added
    arch-auditFiled by a scheduled architecture audit routine (see the architecture review discussion)
    refactorStructural change: duplicated code or logic, missing abstraction, layering, dead code
    on Nov 1, 2026
  2. mikolalysenko commented on Nov 1, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Triage: priority:p3 (test-only refactor inside the apply test binary). No open PR covers it; follows the closed tracking issue #824.


    Generated by Claude Code

  3. mikolalysenko commented on Nov 1, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Claiming this for the architecture refactor routine (highest-scoring structural item with free files: ~9 duplicated fixture writers in one test binary, risk L). Branch: arch-refactor/1941-apply-fixture. Claim-ID: 2026-11-01T16:56:10Z-384c6e


    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-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