fix(validation): stale_artifacts --delete removed fresh rebuilds along with the stale ones - #876
Open
WesIngwersen wants to merge 1 commit into
Open
fix(validation): stale_artifacts --delete removed fresh rebuilds along with the stale ones#876WesIngwersen wants to merge 1 commit into
WesIngwersen wants to merge 1 commit into
Conversation
…d alike
`--delete` matched `f"{name}_v"` against the bare `name_data`, so it took
every version of an artifact. That is wrong exactly when it matters most:
a rebuild sits beside the stale artifact it replaces and shares its name.
The rebuild is not in `problems` -- it is current, which is the point of
having rebuilt it -- but its filename starts with the same name, so the
sweep removed the fix and kept nothing.
Caught on a real sweep. 60 superseded UMD_GHGIA artifacts were flagged
after regenerating 2022 and 2024; the dry run added last week listed 60
bare names, none carrying the stale git hash, and `--delete --yes` would
have taken the 60 fresh builds with them -- the FBAs the GHG FBS series
was mid-build on.
find_stale now carries the versioned stem on every row (it had it and
threw it away by iterating .values()), and delete_stale matches that stem
exactly. A row without a stem deletes nothing: "I cannot tell which
build" must not mean "all of them". After the fix the same sweep listed
60 stems all carrying the stale hash, ran, and left all 124 fresh files
in place.
Four tests, since the failure mode is silent and expensive. Also stops
the progress line raising on a scope outside the repo, which is what
made the function untestable.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Follow-up to #867 / #874. Found by using the dry run that review asked for.
The bug
delete_stalematchedf"{name}_v"against the barename_data, so it deleted every version of an artifact. That is wrong exactly when it matters most: a rebuild sits beside the stale artifact it replaces and shares itsname_data. The rebuild is not inproblems— it is current, which is the point of having rebuilt it — but its filename starts with the same name, so the sweep removed the fix and kept nothing.Net effect of a sweep in that state: you lose the good build and keep none, and the next run silently rebuilds from whatever is left.
Caught on a real sweep, not hypothetically
Regenerating
UMD_GHGIAfor 2022 and 2024 left 60 superseded artifacts flagged. The dry run listed 60 bare names — not one carrying the staledcf7077hash:--delete --yesat that point would have taken the 60 fresh99655e9builds with them — the FBAs the Cornerstone GHG FBS series was mid-build on.The fix
find_stalehad the versioned stem and threw it away by iterating.values(). It now iterates.items()and carriesstemon every problem row;delete_stalematches that stem exactly.A row without a stem deletes nothing — "I cannot tell which build" must not mean "all of them".
After the fix, the same sweep listed 60 stems all carrying the stale hash, ran, and left all 124 fresh files in place:
Testing
Four tests in a new
test_stale_artifacts.py, since the failure mode is silent and expensive:find_stalerow carries a stem, so the contract holds at the producing endAlso stops the progress line raising
ValueErroron a scope outside the repo, which is what made the function untestable at all.🤖 Generated with Claude Code