fix(git): delete stale artifacts when their target leaves the definition's target group
Merged
FA
4mo ago+77+77+01234567890123456789-2-2-0123456789
Summary
Removing a device from an artifact definition's target group (e.g. via a merged proposed change) left its generated artifact on main indefinitely โ a stale, Ready-looking artifact for a target the definition no longer selects. Artifact generation now cleans these up, so the artifact set on a branch always reflects the definition's current targets.
Fixes #9790
Key Changes
- A full artifact-generation pass over a definition (post-merge trigger, definition create/update, or the generate endpoint without a node filter) now deletes artifacts whose target is no longer a member of the target group.
- Limited runs (an explicit list of artifacts to regenerate, e.g. the per-artifact re-generate button) are unchanged: they only regenerate what was requested and never delete.
- Regression coverage reuses the existing
objects/test_artifact_definition.pye2e spec instead of adding a new one: before generating,atl1-core1is added to theedge_routertarget group (the pass must produce its artifact); it is then removed and a second Generate pass must delete the artifact. The original proposed-change-merge reproduction was validated separately during development (commit cea3e246e, later folded into this spec) โ both paths funnel into the same generation flow.
Documentation Updates
docs/docs/artifacts/overview.mdx: the "When artifacts regenerate" section now documents that a target leaving the group deletes its artifact on the next generation pass.
Test Plan
INFRAHUB_TESTING_IMAGE_VER=local INFRAHUB_TESTING_DOCKER_PULL=false uv run pytest -c tests/e2e/pytest.ini tests/e2e/objects/test_artifact_definition.pyโ verified locally: passes on an image built from this branch (3m07s), fails at the deletion deadline on an image built without the fix.- CI:
E2E-testing-pytest-playwrightshardshard_branches_reporuns the extended spec.
๐ค Generated with Claude Code