Skip to content

Tracking: split patch/redirect/mod.rs into per-ecosystem modules and sibling test files #1010

Description

[agent] Filed by the scheduled architecture audit routine (ecosystems and formats). Register: register comment.

Kind: tracking. Source: §3.7 #1; Part 3.2. Register E30.

Problem

On main @ db83f01, patch/redirect/mod.rs is 21,936 lines. It was 17,517 lines at the review snapshot and 21,255 on 2026-10-06. It holds about 7.6K production lines (L1–L7622) and about 14.3K lines of inline tests: mod tests L7623–L21402 with 307 tests, plus five smaller test modules at L21403–L21936 (322 tests in all). The production half mixes:

Concern Lines at db83f01
Wire types (Integrity, DepOverride, FileEdit, RewriteWarning, RewriteResult, full_name, serialize_json) L95–L460
Driver: four telescoping entry points, withholding, parallel groups (rewriter_groups … merge_group_outputs) L465–L946
hatch, npm lock L947–L1439
Cargo (manifest scanner, toml_edit validator, config, pins): ~1.9K lines L1440–L3332
yarn classic + berry L3333–L4742
bun, Python locks / uv L4743–L5392
NuGet L5393–L5707
gem, with the hosted-URL and grant-token grammar in the middle of it (L5862–L5995) L5708–L6634
Maven, Go L6635–L7622

The hosted-URL grammar lives here, not in hosted_url.rs beside it. The module also serves as a utility library for other modes and for formats/: cargo_socket_registry_pin / CargoRegistryPins (vendor/cargo.rs), gem_index_url_pattern (vendor/gem.rs, formats/gem/hosted.rs), NUGET_CONFIG_FILE_NAMES (vendor/nuget_feed.rs) and bare_sha256_hex. The last one is imported by the new formats/sbt/owned_file.rs#L625, which adds another formats → redirect edge (see #833). golang_local.rs is local/agent-mode code, called from apply.rs, rollback.rs, vex.rs, vendor/golang.rs and vendor/redownload.rs.

Symptoms / impact

Target shape

redirect/{model.rs, driver.rs, hosted_url.rs, npm_lock.rs, hatch.rs, cargo/{manifest,config,lock,pins}.rs, yarn_classic.rs, yarn_berry.rs, bun.rs, uv.rs, nuget.rs, gem.rs, maven.rs, golang.rs}, with tests in sibling files and mod.rs reduced to module declarations and re-exports. This is a mechanical split with net ~0 lines. Behavior work, such as the HostedRewriter trait (E31), comes after it and is out of scope here.

Ordered checklist (one PR each; every PR is a pure move with git diff --color-moved clean)

Acceptance criteria

  • patch/redirect/mod.rs is under 500 lines and holds only module declarations, re-exports and the shared driver glue that can't move.
  • No public path changes for callers outside redirect/: crate::patch::redirect::X still resolves for every current importer, the CLI and socket-patch-node included.
  • cargo test -p socket-patch-core and cargo test -p socket-patch-cli pass unchanged, with the same test count. The equivalence suites and goldens are untouched.

Dependencies

None to start. Steps 4 and 5 should land after the in-flight behavior PRs on the same section (listed above) to avoid conflicts. It blocks E31 (trait HostedRewriter) and E32 (one hosted pipeline), which are easier to review per file.


Consolidated work — backlog review, 2026-10-08

The following standalone issues are now tracked here. Their closure consolidates scheduling; it does not mean their implementation is complete. Original reports and discussion remain linked below.

#1011: Move patch/redirect/mod.rs's inline test modules into sibling test files

Preserved scope and acceptance criteria from #1011

Proposed change

  • Declare the modules from mod.rs and move each one's body verbatim into its own file: #[cfg(test)] mod tests; → redirect/tests.rs, and likewise python_lock_warning_tests.rs, python_metadata_pairing_tests.rs, hatch_tests.rs, hosted_patch_uuid_tests.rs and superseding_repin_tests.rs.
  • Inside each file, use super::* keeps the same visibility, so no item changes visibility.
  • Optional, in a follow-up and not this PR: split tests.rs per ecosystem once the production split (later steps of Tracking: split patch/redirect/mod.rs into per-ecosystem modules and sibling test files #1010) lands.

Deleted from mod.rs: L7623–L21936.

Size and scope

  • Files: redirect/mod.rs and six new sibling files.
  • About 14.3K moved lines, 0 changed production lines, and about 12 added declaration lines.
  • Out of scope: any production move, any test edit or rename, and the equivalence suites.

Acceptance criteria

  • git diff --color-moved=zebra shows only moved blocks, plus the six mod declarations.
  • mod.rs is ≤ ~7.7K lines.
  • cargo test -p socket-patch-core redirect:: runs the same number of tests before and after (307 in tests and 322 across the six modules), and all of them pass.
  • cargo clippy -p socket-patch-core --all-targets is clean (no new unused warnings from the move).

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