[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:
- No production callers.
grep -rn over the workspace, including socket-patch-node, finds the free functions only in this file's tests. The only production user is GoSumEditor (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.sum line edits for the hosted Go redirect"), but it lives in vendor/. patch/redirect (mod.rs, upstream/golang.rs, upstream/client.rs), vex::discover::golang and lock_inventory::golang all 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 from vendor::go_sum_edit for one release only if that's needed.
- Delete the free
upsert_module_lines, has_module_version and remove_exact_module_version_lines. Retarget their unit tests at GoSumEditor (feed new(text), then compare into_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
Dependencies
None. It is related to E20 (codecs into formats/), and this is that row's first go child.
[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.rscarries two implementations of the same threego.sumedits. Verified on045d7ec:pub fn(no production caller)GoSumEditormethod (used by hostedrewrite_golang)/go.modlinesupsert_module_linesGoSumEditor::upsert_module_lineshas_module_versionGoSumEditor::has_module_versionremove_exact_module_version_linesGoSumEditor::remove_exact_module_version_linesgrep -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).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.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
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.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.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.rsand 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.\rcases from the current tests pass against the editor.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.