Visitar URL original
Edit go.sum through GoSumEditor only and delete the oracle copies (#631) by mikolalysenko · Pull Request #1103 · SocketDev/socket-patch · GitHub
Skip to content

Edit go.sum through GoSumEditor only and delete the oracle copies (#631) - #1103

Merged
Mikola Lysenko (mikolalysenko) merged 3 commits into
mainfrom
arch-refactor/631-go-sum-one-editor
Oct 8, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 3 commits into
mainfrom
arch-refactor/631-go-sum-one-editor

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code:claude-opus-5-5

Fixes #631 (slice: steps 2 and 3; step 1, the move to formats/golang/sum.rs, stays open on the issue)

Summary

vendor/go_sum_edit.rs had two implementations of the same three go.sum edits: free upsert_module_lines, has_module_version and remove_exact_module_version_lines, and the GoSumEditor methods the hosted Go redirect actually uses. The free copies had no production caller and survived only as the oracle for one test. This PR deletes them, so GoSumEditor is the one implementation, and names the version-line key rule once.

Why (leverage)

What changed

  • New is_version_line(line, module, version): the "{module} {version} " / "{module} {version}/go.mod " rule, previously spelled six times with two format! allocations per call, now in one place and allocation-free.
  • New GoSumEditor::current_lines(): one iterator over the content in either state, replacing three match &self.state copies.
  • The editor methods carry the doc comments of the deleted free functions.
  • Tests: the existing cases now run through the editor (small test-only adapters keep their bodies unchanged). odd_line_endings_give_the_recorded_outputs pins mixed CRLF/LF, bare-\r, missing-final-newline and blank-line inputs to the exact outputs the deleted functions produced (captured on this branch before deleting them). version_line_key_rule covers the near misses. The 3000-seed random test now checks the editor's lines form against a fresh text-form editor at every step, instead of against the deleted oracle.

The first commit refactors the editor while keeping the free functions, and the old oracle test passed on it, so the refactored editor is proven equal to the old text transforms before they are deleted.

Deleted

git diff --stat origin/main: 1 file, +194 / −173. Production: 485 → 398 lines (−87). Tests: 264 → 372 lines (+108).

Behavior

None. Hosted go.sum rewrites are byte-identical; no public API changes (GoSumEditor is pub(crate); the deleted functions had no caller in the workspace).

Test evidence

  • cargo clippy --workspace --all-features -- -D warnings: clean.
  • cargo test -p socket-patch-core --lib: 5663 passed, 4 failed. The 4 are the known root-sandbox failures that also fail on main (copy_tree::relax_loop_must_not_traverse_symlinked_root, vlt_heal::an_unremovable_hidden_lock_keeps_every_store_entry, pypi_poetry::wire_write_failure_maps_error_and_leaves_lock_untouched, pypi_requirements::wire_failure_rolls_back_already_written_files).
  • cargo test -p socket-patch-core --lib go_sum_edit: 13 passed (the old oracle test passed on the first code commit too).
  • cargo test -p socket-patch-core --test redirect_golden --test upstream_restore_golden: 49 passed.
  • cargo test -p socket-patch-cli --all-features --test e2e_golang_hosted_state: 28 passed.
  • cargo test -p socket-patch-cli --all-features --test e2e_golang_hosted_build -- --include-ignored with a real go toolchain: 21 passed.

Risk

Low. One file, pub(crate) surface only, equivalence proven against the deleted code before deletion.

🤖 Generated with Claude Code


Generated by Claude Code

Assisted-by: Claude Code:claude-opus-5-5
GoSumEditor spelled the "{module} {version} " / "/go.mod " key rule
in three methods, each allocating two format! keys per call. One
is_version_line helper now carries the rule without allocating, and
the editor reads its lines through one current_lines iterator instead
of matching on its state in every method. No behavior change: the
step-by-step oracle test still compares the editor with the text
transforms over 3000 random go.sum files.

Assisted-by: Claude Code:claude-opus-5-5
vendor/go_sum_edit.rs kept two implementations of the same three
go.sum edits: free upsert_module_lines, has_module_version and
remove_exact_module_version_lines, which no production code called,
and the GoSumEditor methods the hosted Go redirect uses. The free
copies survived only as a test oracle, so every rule change had to
be made twice. They are gone; their tests now run through the
editor, the odd line-ending cases are pinned to the outputs the old
functions gave, and the random step-by-step test now checks the
editor's lines form against its text form instead of an oracle.

No user-visible change: hosted go.sum rewrites are byte-identical.

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko Mikola Lysenko (mikolalysenko) added arch-refactor PR opened by the scheduled architecture refactor routine refactor Structural change: duplicated code or logic, missing abstraction, layering, dead code labels Oct 8, 2026
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review October 8, 2026 02:17
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

Mikola Lysenko (mikolalysenko) pushed a commit that referenced this pull request Oct 8, 2026
Assisted-by: Claude Code:claude-opus-5-5

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 084cd9e. Configure here.

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Oct 8, 2026
@mikolalysenko

Mikola Lysenko (mikolalysenko) commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator Author

Ready for review (burn-down agent).

  • Head: 084cd9ee917793b3dc87c267cd7bd132faf26900
  • CI: all checks green on this head; one lock-diff job was cancelled by a superseded run, and the same job succeeded on this head (run 37717185035).
  • Bugbot: reviewed this head (Cursor Bugbot check: success), no unresolved review threads.
  • Changelog: untouched.

Nothing specific flagged for the reviewer beyond the PR description.


Generated by Claude Code

@mikolalysenko
Mikola Lysenko (mikolalysenko) added this pull request to the merge queue Oct 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 8, 2026
@mikolalysenko
Mikola Lysenko (mikolalysenko) added this pull request to the merge queue Oct 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 8, 2026
@mikolalysenko
Mikola Lysenko (mikolalysenko) added this pull request to the merge queue Oct 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 8, 2026
@mikolalysenko
Mikola Lysenko (mikolalysenko) added this pull request to the merge queue Oct 8, 2026
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[final reviewer] Re-enqueued (auto-merge on, squash) at head 084cd9ee. Merge-group run 37843887676 evicted it at 21:14 UTC: the only failed job was e2e (ubuntu-latest, e2e_redirect_maven_build, maven, 3.9.3) (step Run e2e tests), and fail-fast cancelled the rest. This PR only changes crates/socket-patch-core/src/vendor/go_sum_edit.rs, which the Maven redirect e2e doesn't touch, so this isn't this PR's failure. This is the one re-queue. If it's evicted again, the janitor should look at the Maven 3.9.3 leg.


Generated by Claude Code

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 8, 2026
@mikolalysenko
Mikola Lysenko (mikolalysenko) added this pull request to the merge queue Oct 8, 2026
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[final reviewer] Re-enqueued (auto-merge on, squash) at head 084cd9ee. The queue dropped it at 22:55 UTC: in merge-group run 37853387102 the only failed job was e2e (ubuntu-latest, e2e_vendor_maven_build, maven, 3.6.3) in its Install Maven 3.6.3 step (download failure, before any test ran); fail-fast then cancelled the rest. Not caused by this PR (#1166 adds recovery for these Maven downloads). Still approved at this head, ci-ok/clippy green, mergeable with current main (checked locally: clean merge), no open threads.


Generated by Claude Code

@mikolalysenko Mikola Lysenko (mikolalysenko) added Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review and removed Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review labels Oct 8, 2026
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[ci-janitor] The merge queue evicted this PR a second time at 22:38 UTC (run 37853387102). The failing job was e2e_vendor_maven_build (maven 3.6.3): its install Maven step got six HTTP 429s from repo.maven.apache.org. The 21:14 eviction was the same class of failure, a Maven Central miss during the e2e fixture warm-up. Neither one is caused by this PR's go_sum_edit.rs change.

Fixes:

I have not re-queued this PR. The final reviewer can re-add it whenever it decides to.


Generated by Claude Code

Merged via the queue into main with commit 568214e Oct 8, 2026
429 of 430 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the arch-refactor/631-go-sum-one-editor branch October 8, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-refactor PR opened by the scheduled architecture refactor routine Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review refactor Structural change: duplicated code or logic, missing abstraction, layering, dead code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete go_sum_edit's oracle-only free functions and move the go.sum codec to formats

3 participants