Repository navigation
fix(test): stop two gates passing against stale artifacts (#792, #795) - #801
Merged
Merged
Conversation
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 Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/spawncontainedtier0SpawnBinpreferred an existingbin/spawnunconditionally.bin/isgitignored, so it is precisely the artifact that accumulates locally. It misled
this repo three times in one day, in both directions:
The first is the dangerous one — a failing test prompts investigation, a passing
one does not. A nine-hour-old binary with no
alerts createrefusal in it madeTestTier0_AlertsRoundTrippass 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:
Proven rather than asserted: planting a
bin/spawnthat is a shell scriptechoing
I am a stale binaryno 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 buildis 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
TestMainis safe alongsidereaper.go's: that one is taggede2e_tier1 || e2e_tier2 || e2e_tier3, and no target combines tags — I checkedthe Makefile and
ci.yml, each passes exactly one. A combined build would be aduplicate-
TestMaincompile error, which is loud rather than silent.#795 —
check-docsshipped docs for a deleted commandThe drift check is
git diff --exit-code docs-gen/. It catches a fragment whosecontent changed, never one whose command is gone — nothing rewrote or removed
the file, so there was no diff:
Published docs would have gone on describing
spawn alerts create|list|delete|historyafter the command was deleted, with the gate whosejob is "docs match the CLI" reporting success.
gen-docsnow prunes orphaned fragments and names each removal — a silentdeletion 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 diffnoticing 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
Shortemptywould delete the entire published reference, and
git diffwould then report itfaithfully but far too late. Same rule as
scripts/nested-modules.shrefusing topass on an empty discovery.
Gates verified against reverts
contains 1 fragment(s) for commands that do not exist: ghost.md— andgen-docspruned it1 command(s) have no committed fragment: version.mdbin/spawnplantedVerification
make check(all 10 nested modules),check-docs, changelog,semgrep(0 findings). Full Tier 0 suite with
-count=1, 67.8s.