Bind container deletion and exit callbacks to instances - #2201
Open
sturdy4days wants to merge 5 commits into
Open
Bind container deletion and exit callbacks to instances#2201sturdy4days wants to merge 5 commits into
sturdy4days wants to merge 5 commits into
Conversation
Return the server-generated ID and instance token from container creation, expose safe JSON CLI output with mixed-version fail-closed negotiation, and reject start/bootstrap after force-deletion reservation. Add deterministic ownership, compatibility, integration, and command-reference coverage.
Keep ContainerClient.create source-compatible as async throws -> Void while discarding the optional server reply internally. Expose create results only through createWithResult and compile-check both exact function types.
sturdy4days
force-pushed
the
codex/force-removal-instance-token-20260827
branch
from
September 2, 2026 19:24
5a1500c to
69d6094
Compare
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.
Type of Change
Motivation and Context
Addresses #2116.
Container IDs can be explicitly reused. A delayed delete or exit callback that only carries an ID can therefore act on a replacement container after the original instance has gone away. Force deletion makes the ownership boundary especially important because stopping and cleanup span asynchronous work.
This change:
container create --format jsonfor orchestrators that need to retain that exact ownership token without a later inspect;container delete --if-instance-token TOKEN IDand validates the token while holding the container lifecycle lock;Backward compatibility is preserved. The legacy create route and ordinary create output remain supported. The public Swift
ContainerClient.create(...)API retains its exact legacyasync throws -> Voidsignature;createWithResult(...)is the distinct result-returning API. The exact legacyContainerClient.delete(id:force:)andContainersService.delete(id:force:)entry points also remain present, whiledeleteIfInstance(id:force:expectedInstanceToken:)provides the distinct required-token path.An older client can ignore the optional result returned by a newer server. Result-capable create and conditional delete check server capabilities and use distinct routes, so a newer client fails before an unsafe operation when connected to an older server. Typed
ContainerizationError, including.unsupported, is preserved rather than being reclassified as an internal error.Credit and overlap: @nassersala documented the reusable-ID race and an earlier local token-precondition proof of concept in this #2116 comment. This PR does not claim origin of that model. The comment describes an unpublished 9-file local patch; no public branch or PR is linked. This implementation covers the same ownership concern while also handling force-delete ID reservation/revalidation, mixed-version capability negotiation, atomic machine-readable create results, cleanup-failure identity retention, start/bootstrap reservation checks, and stale exit-callback generation ownership.
This is a source proposal only. It is not merged, released, or active in a shipped runtime.
Current Revision
apple/containermain atb8ffd38c734448af49cab87c537075f0a803222b.69d609498bce690a04346d48b34379b9ed33edb0.Testing
Validation on exact head
69d609498bce690a04346d48b34379b9ed33edb0:make swift-fmt-checkmake buildmake build-testsmake test: 799 non-integration tests in 89 suites passedTestCLICreateCommand: 6/6TestCLIRmRaceCondition: 3/3.unsupportedpreservation and unknown-error conversion to.internalErrorgit diff --check, signed-history verification, andgit fsck --full --no-danglingAn independent exact-object source review of this head completed with
P0=0,P1=0,P2=0, andP3=0. That review is local source evidence only; it is not maintainer approval, CI, merge, release, or runtime activation.The isolated integration service and disposable test root were removed after validation. No Docker or NanoClaw runtime was selected or activated.