Repository navigation
Delete go_sum_edit's oracle-only free functions and move the go.sum codec to formats #631
Description
[agent] Filed by the scheduled architecture audit routine (ecosystems and formats). Register: discussion #560 register.
Kind: refactor. Source: new finding (register E52). It is an instance of review 3.7 #9 / E35 (refactor oracles kept in production) and of 4.7 J / E20 (pure codecs outside formats/).
Problem
vendor/go_sum_edit.rs carries two implementations of the same three go.sum edits. Verified on 045d7ec:
| Edit | Free pub fn (no production caller) |
GoSumEditor method (used by hosted rewrite_golang) |
|---|---|---|
upsert zip + /go.mod lines |
upsert_module_lines |
GoSumEditor::upsert_module_lines |
| presence check | has_module_version |
GoSumEditor::has_module_version |
| exact prune | remove_exact_module_version_lines |
GoSumEditor::remove_exact_module_version_lines |
- No production callers.
grep -rnover the workspace, includingsocket-patch-node, finds the free functions only in this file's tests. The only production user isGoSumEditor(redirect/mod.rs#L6714,#L6874,#L6932,#L6950). - A test oracle in production code. The free functions survive as the oracle for
editor_matches_the_text_transforms_step_by_step(L686): ~90 production lines kept in sync by hand, with the key-matching rule ("{module} {version} "/"{module} {version}/go.mod ") spelled six times. - A codec in the wrong module. The file is a pure hosted codec ("Pure
go.sumline edits for the hosted Go redirect"), but it lives invendor/.patch/redirect(mod.rs,upstream/golang.rs,upstream/client.rs),vex::discover::golangandlock_inventory::golangall import it from there.
Symptoms and impact
I found no open bugs. Today any change to the upsert rule, such as #509's /go.mod-only line question, has to be made twice and kept equal through the oracle test. The risk is low.
Proposed change
- Move the file to
formats/golang/sum.rs(mechanical, its own commit):GoSumEditor,go_sum_lines,is_h1_dirhash,reinsert_lines,remove_lines,remove_module_prefix_lines,go_sum_line_cmp. Re-export it fromvendor::go_sum_editfor one release only if that's needed. - Delete the free
upsert_module_lines,has_module_versionandremove_exact_module_version_lines. Retarget their unit tests atGoSumEditor(feednew(text), then compareinto_string()), and replace the step-by-step oracle test with fixed expected outputs. - Name the key rule once:
fn is_version_line(line, module, version) -> bool.
Size and scope
About 100 production lines deleted, plus about 750 moved. It touches vendor/go_sum_edit.rs (moved), vendor/mod.rs, formats/mod.rs and five import sites. Out of scope: go_mod_edit.rs (E19) and the hosted Go rewriter's logic.
Acceptance criteria
-
go.sumediting has one implementation (GoSumEditor) underformats/. Nothing inpatch/,vex/orlock_inventory/importsvendor::go_sum_edit. - The upsert, idempotence, stale-line, sort-order, CRLF and bare-
\rcases from the current tests pass against the editor. - The hosted Go redirect tests (
cargo test -p socket-patch-core --lib golang) and the e2e Go suites stay green.
Dependencies
None. It is related to E20 (codecs into formats/), and this is that row's first go child.
Backlog review — 2026-10-08
Priority: P2 → P3. Dead oracle-only functions and a codec file move; no production behavior change. Keep its active PR #1103.
Activity
mikolalysenko commentedon Oct 3, 2026
[agent] Triaged as
priority:p2(Go modules refactor). Not a duplicate, and no open PR covers it.Generated by Claude Code
mikolalysenko commentedon Oct 8, 2026
[agent] Claiming this issue for the architecture refactor routine (highest leverage: the only backlog item whose files no open PR touches; deletes the oracle-only go.sum copies). Branch: arch-refactor/631-go-sum-one-editor. Claim-ID: 2026-10-08T01:56:03Z-081a10
Slice taken: steps 2 and 3 (delete the free
upsert_module_lines,has_module_versionandremove_exact_module_version_lines, retarget their tests atGoSumEditor, name the key rule once). Step 1 (move the file toformats/golang/sum.rs) stays open: it touchespatch/redirect/mod.rs,vendor/mod.rsandformats/mod.rs, which 13 open PRs change.Generated by Claude Code
mikolalysenko commentedon Oct 8, 2026
[agent] PR: #1103 deletes the three oracle-only free functions and names the key rule once (
is_version_line). Remaining for this issue: step 1, moving the file toformats/golang/sum.rsand retargeting the five import sites, once the open PRs that changepatch/redirect/mod.rs,vendor/mod.rsandformats/mod.rsland.Generated by Claude Code
Refactor run: #1103 for #631 (E52)