Skip to content

fix: compile every build tag, so a tagged file cannot rot unobserved - #351

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/tagged-file-rot-197-240
Aug 4, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/tagged-file-rot-197-240

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #197. Closes #240.

The gap, measured

A file behind a build tag is excluded from the default build. Injecting a type error into tests/e2e_test.go on this branch:

command exit
go build ./... 0
go vet ./... 0
go test ./tests/ 0 (ok)
go vet -tags=e2e ./... 1

Not "untested" — unbuilt. Four tags had rotted through that gap.

Repaired

  • tests/aws_s3_test.go — ten PutObject call sites still passing three arguments after the method grew a fourth map[string]string parameter. Passing nil, which the interface documents as valid; this suite asserts nothing about user metadata.
  • test/benchmarks/cache_test.go — fmt.Itoa → strconv.Itoa. fmt.Itoa has never existed in any release of Go, so that file has not compiled since it was written.

Deleted

  • tests/posix_test.go (tests: posix_test.go has never compiled — MockBackend redeclared under -tags=posix #197's question (2), answered "superseded"). Repair was tried and abandoned on evidence: removing the duplicate MockBackend yields unknown field files, fixing that yields undefined: vfs, adding the import yields metrics.NewCollector wanting *metrics.Config. Three API generations. Its own MockBackend copy had been half-edited by a later sweep — it takes meta and carries a rename-preserves-metadata comment — which is the clearest available evidence someone updated this file without ever compiling it.

    Its eight suite methods (mount, file CRUD, mkdir/readdir/rmdir, permissions, seek, concurrent reads, stats) are covered by internal/fuse's 13 test files against a real in-process S3 endpoint, by internal/difftest differentially against the local OS filesystem, and by internal/fuse/kernel_options_live_test.go for what genuinely needs a kernel. Its assert.NoError on manager.Mount also meant it would fail rather than skip on a runner without /dev/fuse, so it could not have been added to CI as written — which is what tests: posix_test.go has never compiled — MockBackend redeclared under -tags=posix #197's verification asks for.

  • tests/integration/ — a LocalStack suite. CLAUDE.md, CONTRIBUTING.md and DEVELOPMENT.md all rule LocalStack out, and nothing in the repo set the AWS_ENDPOINT_URL it required, so it never ran even when it compiled.

  • pkg/optimization — those two files were its only importers in the entire tree (verified). A 284-line interface set whose sole consumer was a test of its own self-consistency.

  • Two pieces of broken wiring: the integration-ready-check pre-commit hook, which inferred LocalStack from an environment variable, and make test-integration, which ran go test -tags=integration ./test/integration/... — a directory that has never existed, so the target failed with lstat: no such file or directory for as long as git records it.

The integration tag survives: it marks real-AWS tests in internal/awsrates and internal/storage/s3, which make test-aws and CONTRIBUTING.md run.

The gate

A build-tags job, one go vet -tags=<tag> ./... cell per tag: aws_s3, benchmark, distributed, e2e, integration, fuse_mount. Vet rather than test, deliberately — several of these need credentials, a bucket, or /dev/fuse and correctly refuse to run without one, but compiling them needs nothing, and compiling is what was missing. The bespoke Compile the fuse_mount tag step folds in; it was the one tag already handled correctly and there's no reason for it to be special.

The tag list is checked against the tree, not maintained by hand — a stale hand-kept list is precisely the defect this fixes. TestEveryBuildTagIsGated walks every //go:build line, strips the boolean operators, discards toolchain-selected tags (GOOS/GOARCH/cgo/race), and fails naming the file. TestGatedTagsStillExist is the converse and is not symmetric: a cell for a deleted tag passes, because go vet -tags=gone ./... selects no files and reports success — a green cell named after a deleted suite is worse than a red one.

Verification

Five mutations, each producing the intended failure:

mutation result
drop e2e from the matrix TestEveryBuildTagIsGated fails, naming tests/e2e_test.go
add a cell for the deleted posix TestGatedTagsStillExist fails
add //go:build sekrit to a new file TestEveryBuildTagIsGated fails, naming it
restore the fmt.Itoa defect benchmark cell fails
type error in tests/e2e_test.go e2e cell exits 1; default build exits 0 (table above)

Also: go vet -tags=<tag> ./... clean for all six tags · go build ./... · full go test -race -timeout 20m ./... green · golangci-lint --new-from-merge-base=origin/main 0 issues · gofmt clean · markdownlint CHANGELOG.md held at its 361 baseline (I introduced one duplicate [#240] reference and removed the redundant one), README 24, design doc 28.

One doc correction fell out: docs/design/conditional-writes-vs-raft.md cited five PutObject test doubles including tests/posix_test.go:443. Now four.

Note

build-tags cells are not in main's required status checks. cross-build lists its cells individually, so the precedent is per-cell — worth adding the six once this run confirms the exact names.

A file behind a build tag is excluded from the default build. `go build ./...`,
`go vet ./...`, and `go test ./...` all pass without type-checking it — not
"untested", unbuilt. Four of this repo's tags had rotted through that gap.

Measured on this commit: a type error injected into tests/e2e_test.go passes
`go build ./...` (exit 0), `go vet ./...` (exit 0), and `go test ./tests/`
(exit 0, "ok") while `go vet -tags=e2e ./...` exits 1. That gap is the issue.

Repaired:
- tests/aws_s3_test.go — ten PutObject call sites still passing three
  arguments after the method grew a fourth map[string]string parameter.
- test/benchmarks/cache_test.go — fmt.Itoa, which has never existed in any
  release of Go, so that file has not compiled since it was written.

Deleted, because repair was the wrong answer:
- tests/posix_test.go — three successive API generations stale (removing the
  duplicate MockBackend yields `unknown field files`, then `undefined: vfs`,
  then metrics.NewCollector wanting *metrics.Config). Its eight suite methods
  are covered by internal/fuse's 13 test files against a real in-process S3
  endpoint, by internal/difftest against the local OS filesystem, and by
  internal/fuse/kernel_options_live_test.go for what needs a kernel. Its
  assert.NoError on Mount also meant it would fail rather than skip without
  /dev/fuse, so it could not have joined CI as written.
- tests/integration/ — a LocalStack suite, which CLAUDE.md, CONTRIBUTING.md,
  and DEVELOPMENT.md all rule out; nothing set the AWS_ENDPOINT_URL it needed,
  so it never ran even when it compiled.
- pkg/optimization — those two files were its only importers in the tree. A
  284-line interface set whose sole consumer tested its own self-consistency.
- the integration-ready-check pre-commit hook, which inferred LocalStack from
  an environment variable, and `make test-integration`, which pointed at
  ./test/integration/... — a directory that has never existed.

The gate: a build-tags job with one `go vet -tags=<tag> ./...` cell per tag.
Vet rather than test, because several suites need credentials, a bucket, or
/dev/fuse and correctly refuse to run without one — but compiling them needs
nothing, and compiling is what was missing. The bespoke fuse_mount step folds
into the matrix; it was the one tag already handled right.

The tag list is checked against the tree, not maintained by hand — a stale
hand-kept list is the defect this fixes. TestEveryBuildTagIsGated walks every
//go:build line, strips the boolean operators, discards toolchain-selected
tags, and fails naming the file. TestGatedTagsStillExist is the converse and
is not symmetric: a cell for a deleted tag passes, because `go vet -tags=gone`
selects nothing and reports success, and a green cell named after a deleted
suite is worse than a red one.

Verified by mutation five ways: dropping e2e from the matrix, adding a cell
for the now-deleted posix, adding a new //go:build sekrit file, restoring the
fmt.Itoa defect, and the injected e2e type error above.

Closes #197
Closes #240
@scttfrdmn
scttfrdmn merged commit 4d10da0 into main Aug 4, 2026
31 checks passed
@scttfrdmn
scttfrdmn deleted the fix/tagged-file-rot-197-240 branch August 4, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant