Skip to content

fix(test): stop two gates passing against stale artifacts (#792, #795) - #801

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/792-795-stale-artifact-gates
Oct 11, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/792-795-stale-artifact-gates

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Closes #792
Closes #795

The same defect twice: a check that validates a generated artifact rather than
re-deriving it from source passes when the artifact is merely stale or
orphaned.

#792 — Tier 0 tested whatever bin/spawn contained

tier0SpawnBin preferred an existing bin/spawn unconditionally. bin/ is
gitignored, so it is precisely the artifact that accumulates locally. It misled
this repo three times in one day, in both directions:

stale binary is symptom
older than a feature added a test passes that should fail
older than a feature removed a test fails naming something that is gone

The first is the dangerous one — a failing test prompts investigation, a passing
one does not. A nine-hour-old binary with no alerts create refusal in it made
TestTier0_AlertsRoundTrip pass vacuously.

Now it always builds from source, once per process, and prints which binary it
built
. The old behaviour printed nothing, so a run's output could not say what
produced a result:

tier0: built /var/folders/.../spawn-tier0-782987456/spawn from /Users/.../spawn

Proven rather than asserted: planting a bin/spawn that is a shell script
echoing I am a stale binary no longer affects the suite.

An mtime freshness heuristic was considered and rejected. The second failure
mode is why: what goes stale is not only behaviour but the command inventory —
the coverage gate enumerates commands from the binary — so the comparison
would have to be right every time, whereas go build is right by construction.

Built once rather than per test because there are 72 call sites and
t.TempDir() is per-test, which is what made the shortcut tempting originally.

The tier 0 TestMain is safe alongside reaper.go's: that one is tagged
e2e_tier1 || e2e_tier2 || e2e_tier3, and no target combines tags — I checked
the Makefile and ci.yml, each passes exactly one. A combined build would be a
duplicate-TestMain compile error, which is loud rather than silent.

#795 — check-docs shipped docs for a deleted command

The drift check is git diff --exit-code docs-gen/. It catches a fragment whose
content changed, never one whose command is gone — nothing rewrote or removed
the file, so there was no diff:

wrote 53 reference fragments to docs-gen    # was 54
echo $?  -> 0                               # passed
git ls-files docs-gen/ | grep alerts -> docs-gen/alerts.md

Published docs would have gone on describing spawn alerts create|list|delete|history after the command was deleted, with the gate whose
job is "docs match the CLI" reporting success.

gen-docs now prunes orphaned fragments and names each removal — a silent
deletion is indistinguishable from a file that was never there:

pruned ghost.md (no such command)
wrote 53 reference fragments to docs-gen (pruned 1 stale)

But pruning only fixes this instance, so the gate asserts set equality in both
directions
. The second direction — a command with no committed fragment — was
previously caught only incidentally, by git diff noticing an untracked file,
which says nothing if the file was never generated.

Pruning refuses when the generated set is implausibly small (<10). Without
the floor, a broken tree walk or an i18n failure leaving every Short empty
would delete the entire published reference, and git diff would then report it
faithfully but far too late. Same rule as scripts/nested-modules.sh refusing to
pass on an empty discovery.

Gates verified against reverts

revert diagnostic
orphaned fragment (#795 verbatim) contains 1 fragment(s) for commands that do not exist: ghost.md — and gen-docs pruned it
removed fragment 1 command(s) have no committed fragment: version.md
stale bin/spawn planted ignored; built from source

Verification

make check (all 10 nested modules), check-docs, changelog, semgrep
(0 findings). Full Tier 0 suite with -count=1, 67.8s.

The same defect twice: a check that validates a GENERATED ARTIFACT rather
than re-deriving it from source passes when the artifact is merely stale
or orphaned.

## #792 — Tier 0 tested whatever bin/spawn contained

tier0SpawnBin preferred an existing bin/spawn unconditionally. bin/ is
gitignored, so it is exactly the artifact that accumulates locally. It
misled this repo three times in one day, in both directions:

  older than a feature ADDED    -> a test PASSES that should fail
  older than a feature REMOVED  -> a test FAILS naming something gone

The first is the dangerous one: a failing test prompts investigation, a
passing one does not. A nine-hour-old binary with no `alerts create`
refusal in it made TestTier0_AlertsRoundTrip pass vacuously.

Now always builds from source, once per process, and PRINTS which binary
it built — the old behaviour printed nothing, so a run's output could not
say what produced a result.

Proven rather than asserted: planting a bin/spawn that is a shell script
echoing "I am a stale binary" no longer affects the suite.

An mtime freshness heuristic was considered and rejected. The second
failure mode shows why: what goes stale is not only behaviour but the
command INVENTORY — the coverage gate enumerates commands FROM the binary
— so the comparison has to be right every time, whereas `go build` is
right by construction.

Built once rather than per test because there are 72 call sites and
t.TempDir() is per-test, which is what made the shortcut tempting.

The tier 0 TestMain is safe alongside reaper.go's: that one is tagged
e2e_tier1||e2e_tier2||e2e_tier3 and no target combines tags — checked the
Makefile and ci.yml, each passes exactly one. A combined build would be a
duplicate-TestMain COMPILE error, which is loud.

## #795 — check-docs shipped docs for a deleted command

The drift check is `git diff --exit-code docs-gen/`. It catches a fragment
whose CONTENT changed, never one whose COMMAND is gone: nothing rewrote or
removed the file, so there was no diff.

  wrote 53 reference fragments to docs-gen    # was 54
  echo $?  -> 0                               # passed
  git ls-files docs-gen/ | grep alerts -> docs-gen/alerts.md

Published docs would have gone on describing `spawn alerts
create|list|delete|history` after the command was deleted, with the gate
whose job is "docs match the CLI" reporting success.

gen-docs now prunes orphaned fragments and names each removal — a silent
deletion is indistinguishable from a file that was never there.

But pruning only fixes this instance, so the gate asserts SET EQUALITY in
both directions. The second direction (a command with no committed
fragment) was previously caught only incidentally, by git diff noticing an
untracked file, which says nothing if the file was never generated.

Pruning refuses when the generated set is implausibly small (<10). Without
the floor, a broken tree walk or an i18n failure leaving every Short empty
would delete the whole published reference, and git diff would then report
it faithfully but far too late. Same rule as nested-modules.sh refusing to
pass on an empty discovery.

## Gates verified against reverts

  orphaned fragment (the #795 scenario) -> "contains 1 fragment(s) for
      commands that do not exist: ghost.md", and gen-docs pruned it
  missing fragment                      -> "1 command(s) have no committed
      fragment: version.md"
  stale bin/spawn planted               -> ignored; built from source

## Verification

make check (all 10 nested modules), check-docs, changelog, semgrep
(0 findings). Full Tier 0 suite with -count=1, 67.8s.
@codecov

codecov Bot commented Oct 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 20 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/gendocs.go 0.00% 20 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit fc19b2d into main Oct 11, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/792-795-stale-artifact-gates branch October 11, 2026 03:31
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