Repository navigation
Description
[agent] Found by the architecture refactor routine (lead L136, raised while #2431 was written). Run on main at d718b07 with go 1.24.7.
The problem
The contract says the go.work in effect "is resolved as go resolves it: GOWORK naming an absolute file". go keeps a workspace's checksums in the work file's name with .sum appended: go.work.sum for go.work, ci.work.sum for GOWORK=/repo/ci.work. The workspace loader reads go.work.sum beside the work file whatever the file is called (core vendor/go_workspace.rs, load_file, line 328). VEX discovery takes its sums from there for a workspace that is not the project's own go.work (core vex/discover/golang.rs, line 676).
So under a GOWORK that names another file, vex decides a hosted Go pin from a file go does not read, and never reads the one go does. It is wrong both ways:
- it refuses to attest a patched build that go accepts (exit 1, no document);
- it attests from a zip pin in a file go never reads, and over a sum file go refuses to build with.
Who it hurts: a repository that keeps a second work file for CI (GOWORK=/repo/ci.work), beside or instead of go.work.
Evidence
What go does (go 1.24.7, a module served from a file proxy, one member a):
/repo/a$ GOWORK=/repo/ci.work go run . # no sum file anywhere yet
upstream v0.9.1
/repo/a$ ls ..
a ci.work ci.work.sum go.work # go wrote ci.work.sum; a/go.sum does not exist
/repo/a$ printf 'github.com/x/y v1.0.0\n' > ../go.work.sum
/repo/a$ GOWORK=/repo/ci.work go run . # a go.work.sum go cannot parse: not read
upstream v0.9.1
/repo/a$ go run . # the same file with GOWORK unset
malformed go.sum:
/repo/go.work.sum:1: wrong number of fields 2
/repo/a$ rm ../go.work.sum; printf 'github.com/x/y v1.0.0\n' >> ../ci.work.sum
/repo/a$ GOWORK=/repo/ci.work go run .
malformed go.sum:
/repo/ci.work.sum:3: wrong number of fields 2
What vex does. A project with a hosted replace in go.mod, its record in the ledger, ci.work (use .) in the project root and GOWORK=<root>/ci.work; the binary built from main, vex --offline:
| Sum files | go | vex on main |
|---|---|---|
both lines of the Socket module in go.sum |
builds | attests, exit 0 |
the same, and a go.work.sum go cannot parse |
builds: go does not read it (run above) | exit 1, the pin skipped, no document |
the same, and a ci.work.sum go cannot parse |
refuses to build (run above) | attests, exit 0 |
go.sum holds the /go.mod line, ci.work.sum the zip line |
the zip pin is in the file go reads, and go wrote it there | exit 1, the pin skipped, no document |
go.sum holds the /go.mod line, go.work.sum the zip line |
no file go reads holds a zip pin | attests, exit 0 |
Each row gives the same answer with GOWORK unset and the work file named go.work (ran both): the file read is go.work.sum. The last row is an attestation the contract rules out ("a /go.mod-only pin is never the lockfile basis in a workspace").
The go column of the last two rows is go's rule, not a run: a Socket module cannot be fetched here.
A unit test that fails on main, for core vex/discover/golang.rs, over the work file in the project root and one directory above it:
test vex::discover::golang::tests::a_named_gowork_reads_its_own_sum_file ... FAILED
[
"a go.work.sum go cannot parse, GOWORK=ci.work: pinned false, go says true",
"a go.work.sum go cannot parse, GOWORK=../ci.work: pinned false, go says true",
"a ci.work.sum go cannot parse, GOWORK=ci.work: pinned true, go says false",
"a ci.work.sum go cannot parse, GOWORK=../ci.work: pinned true, go says false",
"the zip line in ci.work.sum, GOWORK=ci.work: pinned false, go says true",
"the zip line in ci.work.sum, GOWORK=../ci.work: pinned false, go says true",
"the zip line in go.work.sum, GOWORK=ci.work: pinned true, go says false",
"the zip line in go.work.sum, GOWORK=../ci.work: pinned true, go says false",
]
The test
/// Under a `GOWORK` that names `ci.work` the workspace's sum file is
/// `ci.work.sum`, as for go: it decides the pin, and a `go.work.sum`
/// beside it is not read.
#[tokio::test]
async fn a_named_gowork_reads_its_own_sum_file() {
let m = gopatch(UUID_A);
let sver = "v1.4.2-socketpatch.1";
let broken = "github.com/x/y v1.0.0\n";
let zip_line = format!("{m} {sver} {ZIP_H1}\n");
let mod_line = format!("{m} {sver}/go.mod {MOD_H1}\n");
let both = go_sum_for(UUID_A, sver);
let mut wrong = Vec::new();
// (case, go.sum, go.work.sum, ci.work.sum, pinned)
for (case, sum, work_sum, ci_sum, pinned) in [
("both lines in go.sum", &both, None, None, true),
(
"a go.work.sum go cannot parse",
&both,
Some(broken),
None,
true,
),
(
"a ci.work.sum go cannot parse",
&both,
None,
Some(broken),
false,
),
(
"the zip line in ci.work.sum",
&mod_line,
None,
Some(zip_line.as_str()),
true,
),
(
"the zip line in go.work.sum",
&mod_line,
Some(zip_line.as_str()),
None,
false,
),
] {
for (work, use_dir, dir) in [("ci.work", ".", ""), ("../ci.work", "./app", "../")] {
let p = project_in_repo();
p.write(
"go.mod",
format!("{BASE_GO_MOD}\nreplace {MODULE} {VERSION} => {m} {sver}\n"),
)
.write("go.sum", sum)
.write(work, format!("go 1.21\n\nuse {use_dir}\n"));
if let Some(text) = work_sum {
p.write(&format!("{dir}go.work.sum"), text);
}
if let Some(text) = ci_sum {
p.write(&format!("{dir}ci.work.sum"), text);
}
let gowork = p.root().join(work).to_string_lossy().into_owned();
let ctx = p.ctx();
let mut out = Discovery::default();
super::extract_gowork(&ctx, &mut out, Some(&gowork)).await;
assert_eq!(out.refs.len(), 1, "{case}, GOWORK={work}");
let got = out.refs[0].locked_integrity.is_some();
if got != pinned {
wrong.push(format!(
"{case}, GOWORK={work}: pinned {got}, go says {pinned}"
));
}
}
}
assert!(wrong.is_empty(), "{wrong:#?}");
}Planned fix
load_file reads the work file's name with .sum appended. Tried, not pushed: with these lines the test above passes, and so do the 64 other unit tests of vex::discover::golang and vendor::go_workspace.
// go's rule: the work file's name with `.sum` appended.
let mut sum_file = work_file.clone().into_os_string();
sum_file.push(".sum");
let work_sum = read_regular_to_string(Path::new(&sum_file)).await.ok();Plus the unit test, and one CLI test of the table. No behavior changes for a work file named go.work.
After #2431. That PR changes go_workspace.rs, and its crawler has its own copy of the rule (the work file's name plus .sum). Once it merges there are two readers of one rule that disagree on this input; the fix should leave one helper for both.
Not run
- Windows and macOS; go releases other than 1.24.7.
- The hosted and vendored writers under such a
GOWORK: read, not run. They writego.work.sumonly for the project's owngo.work(rooted_at), which a named work file is not, so they writego.modandgo.sumthere. - The in-memory hosted engine (
read_memory, line 1308): it has noGOWORKand reads the view'sgo.work.sum.
Generated by Claude Code
Activity
refactor: L135 on #2429; L136 filed as #2439
mikolalysenko commentedon Dec 2, 2026
[agent] Claiming this for the architecture refactor routine. Branch: arch-refactor/2439-gowork-sum-file.
Confirmed again on
mainat 7beca2f: the unit test in the issue fails with the same eight rows, and go 1.24.7 reads and writesci.work.sum(nevergo.work.sum) underGOWORK=/repo/ci.work. #2431 has merged, so the crawler's copy of the rule (the work file's name plus.sum) and the workspace loader's (go.work.sumbeside the work file) now disagree on this input.Generated by Claude Code
Read the sum file of the work file GOWORK names
Name every wrong row of the named-GOWORK vex test
Take the review's wording points on the sum file
refactor: #2458 opened for #2439, ready with CI green; L146 to verify