Skip to content

Tier 0 e2e silently runs a stale bin/spawn, so a passing suite can prove nothing #792

Closed

Description

@scttfrdmn

Found while verifying #790's alerts fix: the Tier 0 suite reported PASS for a
change the binary under test did not contain.

The mechanism

test/e2e/substrate_cli.go:99:

func tier0SpawnBin(t *testing.T) string {
	...
	if p := filepath.Join(root, "bin", "spawn"); fileExists(p) {
		return p          // <- used as-is, no freshness check
	}
	// Build once into the test binary's temp dir.
	...
}

If bin/spawn exists it is used unconditionally. bin/ is gitignored, so it
is exactly the kind of artifact that accumulates locally — mine was from 08:07
while the source had changed at 17:15.

What it cost

I added a new Tier 0 case asserting that spawn alerts create refuses when the
alert consumer is not deployed. Against the stale binary:

  • the new negative test failed with "exited 0" — correct, but for the wrong
    reason, and I spent a round trip looking for the bug in my own code;
  • worse, TestTier0_AlertsRoundTrip PASSED — because the stale binary had no
    refusal at all, so the round-trip succeeded vacuously. A green round-trip was
    evidence of nothing.

The second half is the real hazard: a failing test prompts investigation, a
passing one does not. Anyone who has ever run make build and later runs
go test -tags e2e_tier0 is testing whatever that build produced.

CI is unaffected — it starts from a clean checkout where bin/spawn does not
exist — which is precisely why this can persist unnoticed: it only misleads
locally, and only the person doing the verifying.

Suggested

Prefer the explicit build, or make reuse conditional on freshness:

  1. Simplest and safest: drop the bin/spawn shortcut and always go build
    into t.TempDir(). It costs one build per go test invocation, and the
    existing comment already says "Build once into the test binary's temp dir."
  2. If the shortcut is kept for speed, compare bin/spawn's mtime against the
    newest .go file under the module root and rebuild when it is older — and
    fail rather than silently reuse if the comparison cannot be made.
  3. Either way, have the harness log which binary it is testing and its mtime.
    The current run prints nothing, so there is no way to tell from the output
    which binary produced a result.

Option 1 is the one consistent with the gate convention in CLAUDE.md: a check
that can pass against code it did not run is not a check.

Activity

  1. added
    bug
    on Oct 11, 2026
  2. scttfrdmn commented on Oct 11, 2026

    @scttfrdmn
    ContributorAuthor

    It bit a second time, in the same session, with a different symptom — worth
    recording because the second failure mode is the opposite of the first.

    Removing the alerts command for #783 and running the suite:

    --- FAIL: TestTier0_CommandCoverageGate
        tier0_coverage_test.go:94: commands with no Tier 0 coverage decision: [alerts]
    

    cmd/alerts.go had been deleted. The command no longer exists in the source —
    but bin/spawn was from 40 minutes earlier, so the gate enumerated the command
    list from a binary that still had it and demanded a coverage decision for a
    command that is gone. go build -o bin/spawn . and it passes.

    So the hazard runs both ways:

    stale binary is symptom
    older than a feature being added a test passes that should fail (the first case: a green round-trip against a binary with no refusal in it)
    older than a feature being removed a test fails that should pass, naming an entity that no longer exists

    The second is merely annoying — you investigate and find nothing. The first is
    the dangerous one. But both argue the same way, and together they rule out the
    "compare mtimes" option in my original suggestion 2: the coverage gate derives
    the command list from the binary, so it is not only prices or behaviour that go
    stale, it is the inventory. Any freshness heuristic has to be right every
    time, and go build into t.TempDir() is right by construction.

    Recommending option 1 (always build) more strongly than before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions