GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||
GeezerVison is showing github.com — Fix Go replace for unselected versions (#391, #392, #509) by mikolalysenko · Pull Request #1403 · SocketDev/socket-patch Conversation
|
| Path | Before | After |
|---|---|---|
agent apply (#392) |
no gate: wrote the inert replace and exited 0 | refuses (nothing written) |
vendor (#392, vendored variant in a comment) |
same | refuses vendor_go_version_not_selected |
apply --check (#392, go 1.16) |
"absent from require" counted as harmless | ResolvedVersionMismatch |
vex (#391) |
attested not_affected from the intact copy |
omits with go_version_not_selected (agent, vendored and hosted replaces) |
| hosted gate (#509) | a go.sum /go.mod-only line counted as "in the graph" |
only a zip line counts; warns redirect_golang_version_mismatch |
There was no shared answer to "does the build list select M@v?". The new
vendor::go_build_list answers it offline from go.mod and go.sum, and every
call site above uses it:
require is authoritative. If the modulego directive): require holds only lower bounds/go.modgo mod tidyDocs: CLI_CONTRACT.md (golang agent section and the hosted rule) and
docs/ecosystems.md (Go).
main, green here)Each new regression test was applied to unmodified origin/main and failed
there:
golang_local::tests::test_apply_refuses_a_version_the_build_does_not_select: go 1.16 graph, go 1.21 require bump, and a module the project doesn't use. FAILED on main.golang_local::tests::test_verify_flags_go116_transitive_version_mismatch: apply --check in a go 1.16 graph. FAILED on main.vendor::golang::tests::test_vendor_refuses_a_version_the_build_does_not_select. Added with the vendor gate./go.mod-only line as "in the graph", so on a go 1.16 module it writes an inert replace for an unselected version and VEX attests not_affected #509 redirect::tests::golang_go116_go_mod_only_line_is_not_the_selected_version. FAILED on main.go get upgrades the patched module, although the go-patches replace no longer applies and the build links the unpatched code #391 covgap_commands_vex::go_patches_replace_for_an_unselected_version_is_not_attested: go 1.21 go get bump and the go 1.16 graph are omitted; the selected and unknown controls still attest. FAILED on main.test_apply_go116_selected_version_still_applies, where the selected version applies and stays in sync after tidy. Passes on both.go_build_list::tests).Commands run locally (Linux, go 1.24.7):
cargo fmt --all -- --check: cleancargo clippy --locked --workspace --all-features -- -D warnings: cleancargo test -p socket-patch-core --all-features --lib -- go: 848 passedcargo test -p socket-patch-cli --all-features --lib: 913 passedcovgap_commands_vex, covgap_commands_rollback, e2e_golang, e2e_vex_vendor, in_process_vendor, e2e_golang_build, e2e_golang_hosted_build, e2e_golang_hosted_state, e2e_golang_workspace_build and e2e_vendor_golang_build (with --include-ignored, real go): all passThe full cargo test --workspace couldn't finish locally because the session
ran out of disk, so CI's full matrix is the check for the rest.
tests/equivalence/golang_rewrite.golden was re-blessed. To show only the
warning wording changed, I restored the old not-in-graph message and checked
that the old golden still matched.
/code-review high findings not fixedgo mod tidy): this reads as "the build selects the higher version". Itvex omits, and hosted drops its owngo mod tidy clears it.apply --check names the drift. Removing go.mod lines from aproject_selection re-reads go.mod/go.sum per replace entry inapply --check and vex: there are a handful of entries per project, soread_required_versions is no longer used outside tests: left in place🤖 Generated with Claude Code
https://claude.ai/code/session_01DH6BEwGj8nVAeveDy6x5fc
Note
Medium Risk
Changes fail-closed behavior across apply, vendor, hosted redirect, and VEX for Go patches—users with stale version-pinned replaces may see new refusals or omitted attestations until they re-scan for the selected version.
Overview
Go replace directives are keyed by module and version, so a pin for a version the build list does not select is ignored and the unpatched module is linked. This PR adds shared offline logic in go_build_list (from go.mod / go.sum) and uses it everywhere that used to guess from partial heuristics.
Agent apply / vendor now refuse before writing copies or replace lines when the patched version is not selected (including go 1.16 graphs where selection comes from go.sum zip lines, not /go.mod-only entries). apply --check flags ResolvedVersionMismatch on the same basis instead of treating “missing from require” as harmless.
Hosted redirect applies the same selection rules: version mismatches warn redirect_golang_version_mismatch; “in graph” checks ignore /go.mod-only lines (#509). vex drops attestation for socket-owned replaces with go_version_not_selected when go.mod/go.sum show another version is built.
CLI and ecosystem docs describe the behavior; regression tests and updated golang rewrite golden cover apply, vendor, hosted, vex, and the helper.
Reviewed by Cursor Bugbot for commit 598055a. Configure here.
Generated by Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
A Go replace names an exact module version. When the build list selects another version (a later go get, or a go 1.16 graph where a transitive dependency asks for a newer one), the replace is ignored and the build links the unpatched module. Agent apply wrote such a replace and reported it applied, apply --check passed it in go 1.16 graphs, vex attested not_affected, and the hosted gate took a go.sum /go.mod-only line as proof the version was built. All four now ask one helper that reads go.mod and go.sum: require for go 1.17+, and for older graphs the highest of require and the go.sum zip-line versions. apply refuses, apply --check flags, vex omits with go_version_not_selected, and hosted warns and skips. Fixes #391, #392, #509. Assisted-by: Claude Code:claude-opus-5-5
The not-in-graph warning now says go.sum has no zip line for the version, since a /go.mod-only line no longer counts. Checked that the old golden still matches with the old wording, so only the message changed. The +incompatible reconcile test now requires the version it applies. Assisted-by: Claude Code:claude-opus-5-5
A go 1.16 go.sum zip line below the patched version now shows that lower version is built, so apply and apply --check catch it again. Vendored mode gets the same build-list gate before it fetches or wires a module. The hosted not-in-graph warning no longer claims go.mod lacks a require it may have, and the zip-line rule lives in one place. Assisted-by: Claude Code:claude-opus-5-5
The download plan has to name exactly the modules vendor asks the service for, so it now skips a version the build doesn't select, as vendor itself does. Adds a regression test for vendoring an unselected version in a go 1.16 graph. Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Stale Bugbot comment from a previous run.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The vendor suite pinned apply exiting 0 when go.mod requires a newer version than the patch, though the replace it wrote was ignored. It now expects the refusal that names the selected version (#392); apply --check still reports the drift. Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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 598055a. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ready for review (burn-down agent)
Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Hosted Go scans got about a third slower in #1403. For each patched dependency the rewriter asks go.sum which versions the build loads, and that tokenized every go.sum line every time. On a project with 1200 modules and 30 patches this was about 30% of the scan's work. Lines that can't belong to the module are now skipped with one prefix check before tokenizing, so the answer stays the same. Tests pin the edge cases: shared path prefixes, /go.mod lines, odd whitespace and short lines. Fixes #1424 Assisted-by: Claude Code:claude-opus-5-5
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Hosted Go redirect's not_in_module_graph gate counts a go.sum/go.mod-only line as "in the graph", so on a go 1.16 module it writes an inert replace for an unselected version and VEX attests not_affected
Agent-mode Go apply writes a go-patches replace for a module version the build graph doesn't select, reports it applied, and on a go 1.16 go.mod apply --check and vex also report it as patched
Agent-mode Go vex attests not_affected after go get upgrades the patched module, although the go-patches replace no longer applies and the build links the unpatched code
There was an error while loading. Please reload this page.