Research-1338: Go fix clean-tree gate¶
Tool contract¶
The repository currently declares Go 1.27.1 in go.mod, and the local toolchain reports go version go1.27.1-X:nodwarf5 linux/amd64. Its installed go help fix documents -diff as a non-mutating mode that prints a unified diff and exits nonzero when the diff is not empty. go tool fix help lists the modernization analyzers used by the default command.
Before this change, neither .github/workflows/go-ci.yml nor the Makefile ran go fix. The first low-priority probe was therefore red and proposed current standard-library and language rewrites, including maps.Copy, slices.Contains, errors.AsType, integer ranges, and sequence iterators.
Applying the sweep¶
go fix ./... was run repeatedly as directed by the tool. Two details needed review rather than blind acceptance:
- In
cmd/vmafx-mcp,stringsseqandslicescontainsproposed overlapping rewrites for the same path-component loop. Applyinggo fix -stringsseq ./cmd/vmafx-mcpfirst selected the allocation-free iterator form; the full fixer then completed without an exclusion. errorsastypemodernized a test that matches theexitCoderinterface.errors.AsTypeconstrains its type parameter toerror, while the old interface declared onlyExitCode(). Embeddingerrordocuments the actual contract and preserves the test's important negative control:*exec.ExitErrorstill satisfies the interface, while the CLI accepts only its ownexitCodeErrortype.
The hand-maintained api/vmafx/v1/zz_generated_deepcopy.go was included. Its local AGENTS.md explicitly says the generated-style file is hand-maintained until controller-gen becomes authoritative, so applying maps.Copy does not violate a generated-source owner.
Gate placement and validation¶
The check does not need libvmaf to be linked, so it belongs immediately after actions/setup-go and before package installation, ONNX Runtime setup, and the native build. This makes a source-only failure cheap while retaining ADR-1238's existing impact routing and required check name.
Focused validation:
go fix -diff ./...
python3 scripts/ci/test_go_workflow_contract.py
actionlint .github/workflows/go-ci.yml
go test ./...
go vet ./...
The first command must produce no output and exit zero. The contract test also proves the workflow step precedes native setup and that the local write/check targets cannot silently drift from CI.