Skip to content

Managed runtime: task-scoped artifact retention and safe Registry garbage collection #167

Open

Description

@rcyw

Problem

Managed BuildKit outputs used by one-off data synthesis jobs accumulate in the internal Registry after their tasks finish. Stopping a builder or sandbox does not reclaim these remote images. Without an explicit retention contract, repeated trials and retries can eventually fill the Registry disk.

A private deployment encountered this capacity issue. Expanding its disk restored service, and a fresh build → push → sandbox creation → execution/content verification passed. Existing images and authentication were preserved. This issue tracks the missing lifecycle mechanism, not an ongoing service outage. No existing images should be deleted as part of opening this issue.

Here, Harbor means the agent evaluation/task harness, not the Harbor container-registry product.

Source observations

Inspected AKernel develop: 753b5861.

  • Managed publication pushes native Nydus OCI outputs under generated build tags and records immutable digest references.
  • build_image() cleans up its temporary builder. Its returned BuiltImage has no task retention/release contract.
  • The managed-runtime contract explicitly excludes automatic Registry artifact GC. Sandboxd's node-local live/checkpoint leases protect managed collections; they do not authorize remote Registry deletion.
  • The pinned ADX checkpoint deletion guard checks checkpoint references and input holds. OCI image dependencies need an explicit connection to that lifecycle.
  • The inspected Harbor checkout (5d5e58a2a5d65c6f46edbd47008b38a5f5f4c1c0) retries the entire trial, with backoff between attempts. An individual environment's stop is therefore not the logical task's final completion. No built-in AKernel environment adapter was found in that checkout; integration must use the actual adapter/extension point.

These are source observations, not evidence that the proposed cleanup already exists.

Proposed minimal design

Keep the internal Registry as the temporary publication store; moving ephemeral outputs to ACR is not required.

  1. Task ownership: the harness/adapter assigns a stable logical task owner across attempts. Final success, exhausted retries, or cancellation releases this owner after required results/logs have been persisted. Per-attempt sandbox cleanup must not release the whole retry group.
  2. Durable artifact receipt: AKernel records the owner, publication identity, exact repository/digest, and retention state. Register ownership before publication and reconcile committed outputs, including partial pushes and lost responses. Keep authoritative state outside the SDK process and temporary builder. Reuse existing durable control-plane storage where appropriate rather than introducing a separate artifact platform.
  3. Reference protection: running, queued/preparing, paused, and restoring consumers, retained checkpoints/Snapshots, and reusable templates where applicable retain all required image dependencies, including managed Compose service images. Reuse local leases for local cleanup, but do not treat them alone as a complete remote reference inventory.
  4. Grace period: start a configurable grace period only after final task release and the last protected reference disappears. A suggested initial default for explicitly ephemeral tasks is 24 hours, subject to measured workloads. Explicit debug retention/pinning overrides expiry. Do not expire images merely because their build timestamp is old.
  5. Safe reclamation: a small periodic reconciler produces candidates and deletes eligible manifests through a narrowly scoped operator identity. Reference acquisition must be fenced against deletion; a new valid consumer cancels pending expiry. Unknown references or an unreachable owner/control plane defer deletion. A crashed client or heartbeat timeout alone is insufficient authority to delete.
  6. Physical space recovery: manifest deletion and Registry blob GC are separate operations. Use a supported no-writer/read-only maintenance procedure for GC, account for OCI/Nydus dependency graphs and shared blobs, and report actual reclaimed bytes. BuildKit and Dragonfly cache eviction remain separate mechanisms.

Provide a small explicit release/extend-retention API, with SDK/adapter wrappers. Exact API names and storage layout remain implementation choices. Do not hand Registry deletion credentials to task sandboxes.

Delivery stages

  • Add durable task/publication ownership and reference inventory; expose read-only candidates, retention reasons, and unknown/protected states.
  • Add idempotent task-finalization and explicit retention/release operations in the actual harness integration.
  • Qualify reference/deletion concurrency and operator manifest deletion + Registry GC in isolation.
  • Enable automatic short retention only for newly opted-in ephemeral publications, initially in dry-run mode. Preserve existing behavior for other callers and keep legacy/unowned images protected until separately reviewed.

Acceptance criteria

  • Finalized, unreferenced ephemeral outputs become reclaimable after the configured grace period; deletion and physical reclamation are observable separately.
  • No deletion during execution, retry backoff, preparation, pause/restore, or retained checkpoint/Snapshot/template use.
  • Cover concurrent acquire versus delete, client/harness crash, control-plane restart, failed/partial publication, lost completion responses, and idempotent reconciliation.
  • Two tasks sharing an image or blobs remain independent: finishing one cannot break the other.
  • Retained managed checkpoints still restore and required Nydus blobs remain available; no cross-node portability claim is implied.
  • Legacy images, unrelated repositories, operator-owned images, and pinned debug artifacts remain untouched.
  • Validate actual disk reclamation under the supported GC procedure, preserving auth and surviving manifests; publish operational guidance and capacity metrics.

This issue requests a lifecycle enhancement. It does not authorize deleting current images, enabling age-only pruning, or changing the current Registry/ACR deployment.

Activity

  1. rcyw commented on Nov 17, 2026

    @rcyw
    CollaboratorAuthor

    Two linked draft PRs were opened for the initial implementation.

    • Explicit retention policies, durable publication and independent lease APIs, registration before building, Compose dependency tracking, and a separate manifest reclamation tool. AKernel #169
    • An authoritative ledger in the existing Coordinator and Redis, durable dependencies before scheduling, dependency inheritance on Snapshot restore, and exclusion between new consumers and deletion. The administrative deletion API is disabled by default. agent-dx #332

    The scope is a general AKernel SDK and Registry lifecycle. Existing calls retain their behavior and enrollment requires an explicit opt-in. Caller holds survive SDK exit and sandbox deletion. Lost contact and partial publication keep the artifact protected. Operators can observe candidates and run a dry run while deletion is disabled. A separate operator process handles Registry requests, with separate procedures for manifest deletion and physical garbage collection.

    The initial validation passed 547 SDK unit tests, 35 benchmark driver tests, 64 runtime adapter tests, Ruff, and mypy. The backend passed 43 core tests, 45 Coordinator library tests, a real Redis AOF restart, three mTLS RPC regressions, and workspace Clippy. A dedicated Redis instance and a fresh Distribution Registry verified concurrent reference protection, recovery after partial manifest deletion, denial of deletion by ordinary callers, and garbage collection with writers stopped. GC reclaimed 2,109,440 bytes, while shared blobs and an unenrolled fixture image remained readable. The isolated test containers and child processes were cleaned up.

    At this stage, the remaining work was to qualify the native Nydus and sandboxd build, checkpoint, publisher release, source deletion, and restore path, then consume the matching formal ADX release and tools. Production activation and Registry maintenance require their own review. Both PRs were drafts when this update was posted, and the issue remained open.

    All validation ran in isolation. Existing clusters, authentication, runtimes, images, and historical data were preserved.

  2. rcyw commented on Nov 17, 2026

    @rcyw
    CollaboratorAuthor

    The native qualification passed on AKernel commit 959ae6c20d112efc1f13be327bda48f7c20c7f80 in a dedicated Linux/amd64 runsc environment.

    • Both a Nydus image and a two-service managed Compose project completed build, execution, Snapshot capture, publisher release, source deletion, restore, consumer removal, grace, manifest deletion, and garbage collection with writers stopped. Two samples after restore showed the original PID, in-memory nonce, and single launch count, with the counter still advancing. Files written to the source after capture were absent on restore. The run also covered hidden Compose dependencies and a control plane restart.
    • The final runtime-6 run deleted 3 manifests. Physical allocation fell from 229,208,064 to 226,779,136 bytes, reclaiming 2,428,928 bytes. The surviving manifests and 6 blobs passed verification, and a fresh consumer started from the retained image. Independent checks confirmed that the test containers, network, mount, and loop device were cleaned up. Backing files and evidence were retained.
    • The SDK fixes bind existing handles to their original API endpoint, credentials, and TLS settings. Implicit builds share one connection configuration and preserve the separate gateway, default ports, and WSS behavior. Managed Compose verifies the API identity before startup. All 557 SDK tests, 35 benchmark driver tests, Ruff, and mypy passed.
    • All 11 checks passed for the exact AKernel commit, including Python 3.10–3.14, package and contract checks, and Standalone E2E. Docker Hub publication was skipped as configured. AKernel CI
    • The backend PR was marked Ready for review. Static analysis, compliance, and CLA checks passed on acdecb0eb9077cfce5c054f23cb4ae06451a1206. The real Redis restart and three mTLS RPC regressions are now wired into the standard CI gate. The remote CodeCheck reported unit tests, system tests, and packaging as N/A. The local Rust checks and integration regressions passed. agent-dx #332

    Formal release integration remains pending. The native test used a complete local ADX candidate with matching static Execd and rootfs. A maintainer needs to merge the backend PR, and the CI repository's master must contain the merged change. The next integration step is to verify matching Platform and Execd archives from the same formal build, update both AKernel Dockerfiles and the ADX gitlink together, and qualify the rebuilt combination. The AKernel PR remains a draft with its current release pins. AKernel #169

    The coordination record contains the source provenance, failed attempts, operating tradeoffs, and handoff steps. All validation ran in isolation and preserved existing clusters, authentication, images, and historical data. Production activation and garbage collection across the production storage domain require separate review.

  3. rcyw commented on Nov 18, 2026

    @rcyw
    CollaboratorAuthor

    The follow-up fixes are on agent-dx #332 at 6b148869 and AKernel #169 at 45fe40f. The implementation supports the direct AKernel SDK and Registry workflow.

    • Environment and Snapshot admissions now share a durable Redis fence with deletion claims. Lost executions retain their own image dependencies until the original host or session is reconciled.
    • Publication plans are bound to an approved Registry namespace and builder generation. The operator checks live tag digests before deletion. A fenced partial publication can be reconciled against its actual outputs.
    • Inventory uses paged summaries. An explicit administrator observation checks current references within a bounded budget.

    The new candidate passed the Redis/mTLS regressions and isolated Registry tests, including partial publication recovery and interrupted deletion. Both ordinary Nydus and two-service Compose resumed the original checkpointed processes. Privately scoped test GC released 2,428,928 bytes in the native run, and the retained image and shared blobs were verified. All 11 current AKernel CI checks passed, including Standalone E2E. CI run

    The ADX PR is Ready for review. The AKernel PR remains a draft pending the upstream merge and integration of verified Platform and Execd release archives. Existing clusters, images, and historical data were preserved.

  4. rcyw commented on Nov 18, 2026

    @rcyw
    CollaboratorAuthor

    CodeCheck passed for agent-dx #332 at 6b148869d0f995027bd1189c8b2c21562f3d30fc. The report shows successful static analysis, blacklist scanning, anti-poisoning, open-source compliance, and Ruff checks. CodeCheck report

    The upstream PR is still open. AKernel #169 remains a draft pending the merge and verification of the matching official Platform and Execd archives. The release integration will be validated in a fresh isolated environment. Upstream PR · AKernel PR

  5. rcyw commented on Nov 20, 2026

    @rcyw
    CollaboratorAuthor

    The Agent DX review is complete in agent-dx #332. The Coordinator owns the Redis admission fence for execution dependencies, including native snapshot preparation. AKernel owns the builder, Registry layout, and reconciliation of interrupted writes. Completed reclamation returns active capacity while preserving the original request identity.

    • Agent DX f7f373d350d91c2588da19b6dfd38c65678f3a5e passed the focused Redis/mTLS regressions, workspace Clippy, and exact-head CodeCheck. GitCode !256 has the same head, and #332 is ready for upstream review.
    • The same-source local release-format candidate and AKernel 71fb53220f813e1b05683537c17e01e68cb7eb87 passed the isolated Nydus and two-service Compose checkpoint loop. Both restored the original processes. The Nydus case also passed after a control-plane restart. The public API refused a scheme-prefixed reference to a reclaimed repository before scheduling. Three scoped manifest deletions were followed by physical GC that released 2,478,080 bytes. Six retained blobs and a fresh survivor were verified.
    • The separate Registry fixture exercised an independent publisher, fenced partial publication, resumable deletion, and shared OCI content. GC released 3,170,304 bytes while preserving the shared blob and unmanaged manifest.

    AKernel #169 remains a draft pending the upstream merge and integration of the matching official Platform and Execd archives. All 11 checks in the current-head AKernel CI passed, including Standalone E2E with the existing release pins. The official-archive combination will have its own isolated and CI verification. Existing clusters, images, and historical data were preserved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions