fix(git): delete stale artifacts when their target leaves the definition's target group

Merged
FA
4mo ago
+77-2

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.py e2e spec instead of adding a new one: before generating, atl1-core1 is added to the edge_router target 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-playwright shard shard_branches_repo runs the extended spec.

๐Ÿค– Generated with Claude Code