Automate clean-up of Attestations

Open
#1,134 0 comments 1 reaction 2 assignees View on GitHub

Maintainers usually reply within 1 day

@rjaegers is already working on this.

Since Mar 13, 2026.

  • #1200 by @copilot-swe-agent — closed without merging

Assessment

This issue has not been assessed yet.

Description

Goal and agreed policy

Extend image cleanup to remove obsolete GitHub artifact attestations without breaking verification of supported images.

The retention policy is:

Subject Policy
Images belonging to a published GitHub release, including prereleases Preserve their attestations indefinitely
Images for an open pull request Preserve while the PR is open
Current default-branch edge image Preserve
Other, obsolete builds Eligible only after a seven-day grace period

This replaces the ambiguous original reference to "release branches". A release tag or draft release alone does not confer indefinite retention. Published-release protection takes precedence even if the image later disappears from the registry. Never delete or modify published release assets.

Current implementation and starting points

Inspected at af840070c907d71ce06334ea65eded00dc3946a4; recheck the implementation before starting.

  • .github/workflows/image-cleanup.yml: weekly/manual cleanup using dataaxiom/ghcr-cleanup-action, deleting untagged and orphaned images.
  • .github/workflows/pr-image-cleanup.yml: closed-PR pr-<number> image cleanup and separate cache cleanup.
  • .github/workflows/wc-build-push.yml: creates index-level GitHub provenance and pushes it to the registry; BuildKit also generates SBOM material.
  • Package scope: amp-devcontainer, amp-devcontainer-base, amp-devcontainer-cpp, amp-devcontainer-docs, amp-devcontainer-embedded-cpp, amp-devcontainer-embedded-rust, amp-devcontainer-rust.

GitHub attestation records, OCI registry attestations/referrers, and release assets are different storage surfaces. Removing one does not prove that the others were removed.

Implementation requirements

  1. Establish a supported, repository-scoped inventory and authentication path first. Document how existing attestations and their subjects are discovered, including historical orphans whose images have already disappeared. Digest lookup alone cannot discover unknown digests. Check pagination, API availability, and the actual minimum token permissions with a disposable fixture before enabling deletion. If historical discovery is incomplete, report that explicitly rather than claiming a complete cleanup.
  2. Resolve a protected set from published releases, open PRs, and current edge, across all packages. Use immutable digests, not tag-name matching alone. Walk multi-platform indexes to include child manifests and associated evidence. Preserve shared digests if any protected reference reaches them.
  3. Keep a durable, auditable release-to-digest mapping at publication if existing metadata cannot reconstruct it reliably. Bootstrap older published releases conservatively; unresolved mappings block affected deletions. A short-lived workflow artifact is not an indefinite-retention record.
  4. Require at least seven days since a candidate was first confirmed obsolete/unprotected, and at least seven days since its attestation was created. Closing a PR or advancing edge starts the grace period; it must not trigger immediate deletion. Treat in-flight builds as protected and recheck protection immediately before deleting.
  5. Reconcile with existing image cleanup so the order does not destroy the information needed to classify attestations. A missing image is not sufficient justification to delete published-release evidence. Unknown tags, malformed metadata, incomplete pagination, authentication failures, rate limits, registry errors, or ambiguous ownership must result in retention and a diagnostic, not inferred absence.
  6. Apply the same policy to provenance and SBOM predicates, including the attestations introduced by philips-software/amp-devcontainer#1135. If an attestation covers multiple subjects, preserve the entire record when any subject is protected.
  7. Prefer deletion by validated attestation ID over organization-wide digest deletion. Verify repository ownership explicitly; identical digests may occur in other repositories. Preserve registry referrers needed by protected images and identify which registry-side cleanup is already handled by the existing action.
  8. Provide a dry-run mode reporting keep/delete/unknown decisions, subject digest, attestation ID, reason, and grace-period status. Roll out with a reviewed dry run before enabling scheduled deletion. Export candidate bundles and a deletion manifest before applying changes; document their retention and the limits of recovery.
  9. Keep cleanup bounded, idempotent, and safe to rerun after partial failures. Use least privilege, pinned actions, existing workflow conventions, and safe handling of event/API data. Do not execute code from a closed PR with elevated credentials. A scheduled sweep must handle cases where a fork PR's close event cannot obtain deletion permissions.

Do not silently expand this into organization-wide cleanup, deletion of valid release evidence, or changing the image retention policy.

Required tests

Use fixtures and a disposable integration target, not production release deletions:

  • Published release survives indefinitely, including a missing registry image and shared release/PR/edge digest.
  • Open PR and current edge survive; closed PR and superseded edge survive until the full grace period expires.
  • Old draft/tag-only build has no indefinite exemption, but an active build is not deleted.
  • Boundary times, publication/reopening/edge changes between planning and deletion, multi-platform children, referrers, multiple subjects, and multiple predicates.
  • Unrelated repository with the same digest is untouched.
  • Missing/ambiguous release mappings, paginated results, 403/404 ambiguity, 429/5xx, registry failures, and interrupted/repeated runs fail safely.
  • Dry run performs zero deletions; apply deletes only approved eligible fixtures; protected image verification still succeeds afterward.

Acceptance criteria

  • The agreed policy and grace-period semantics are documented and automated for every in-scope package.
  • Discovery coverage and minimum permissions are demonstrated; historical gaps are resolved or explicitly block unsafe deletion.
  • Published-release evidence is protected independently of moving tags and registry availability.
  • GitHub and registry cleanup responsibilities are explicit; both provenance and SBOM evidence follow one policy.
  • Automated positive/negative tests pass, and a reviewed dry-run report precedes scheduled apply.
  • Logs/exported manifests support auditing; partial failures are visible and do not widen deletion scope.

Dependencies and references

No dependency on philips-software/amp-devcontainer#1135: implement predicate-independent retention now; that issue integrates its new SBOM records with this policy.

Dominant language
Shell
Stars
136
Forks
8
Avg merge
17h 19m
Merged PRs (30d)
53

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from philips-software/amp-devcontainer

All issues in philips-software/amp-devcontainer

Similar issues

More Shell/Bash issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.