Physical completion and logical ACK: independent source review

Reviewed 2026-10-23 against SDK base bb1e51680ba5e06dde5d897e8e273f17460cb064. This is a source review, not PocketIC measurement or a claim about a particular deployed replica revision. Only this note is owned by the source-review lane. The adapter implementation and qualification belong to their separately assigned lanes.

The original SDK callback path erased its transport result into Option<Acknowledgement>. Showtime then used ack.is_some() to settle its physical-start reservation. Consequently a genuine response with malformed Wire, an oversized reply, a definite rejection, and an uncertain timeout were indistinguishable to the host. A succession of otherwise terminal failures could exhaust the application's retained physical debt.

Accounting boundary

For the application's 2R + 2D bound, a physical reservation accounts for an original transmission that could still cause a counted later request/response delivery. Caller callback completion alone does not settle that reservation. Logical custody/ACK processing is independent: malformed response bytes or a definite reject do not acknowledge the retained batch.

The IC guarantees at-most-once original request delivery and one caller-visible response. A bounded-wait SYS_UNKNOWN can nevertheless precede successful callee processing, and the real response can then be discarded. Thus the one-response property is insufficient to establish absence of later counted work. (Official message-execution properties 6–9)

The abstract expiry rule preserves the original message or active callee context, marks its deadline expired, and separately produces a SYS_UNKNOWN response. Spontaneous rejection instead replaces the original queued call with its reject response. These transitions directly distinguish possible late delivery from a terminal original exchange. (Official abstract behavior, call expiry and rejection)

Result classification

The table applies to genuine call outcomes, with the cleanup provenance caveat below. It does not claim that the callee made no earlier state changes, or that unrelated downstream work is finished.

Outcome Physical reservation Logical ACK
Actual reply with valid ACK Release Pass decoded ACK to existing Reactor validation
Actual reply with invalid Wire/envelope/ACK Release Absent; preserve retry/custody behavior
CallFailed::ResponseLimitExceeded Release: reply callback observed response bytes Absent
InsufficientLiquidCycleBalance Release: no dispatch occurred Absent
CallPerformFailed Release: no dispatch occurred Absent
Genuine IC rejection codes 1–5 Release: definite original exchange result Absent
SYS_UNKNOWN (6) Retain uncertainty Absent
Unrecognized/future reject code Retain uncertainty Absent
Guard abandonment, cancellation, callback trap/cleanup without preserved provenance Retain uncertainty Absent

The SDK's pinned call API supplies the local evidence: its liquid-cycle check returns before perform; nonzero call_perform returns CallPerformFailed; and ResponseLimitExceeded is created only in the msg_reject_code() == 0 reply branch. Wire decoding occurs after a Response already exists. The baseline call-file SHA-256 is b48dfbcfb288b1a5c9e443000f2ee1caf4b8cb5157818ad64de5139ad6cc0f1e.

The System API specifies that failed call_perform does not dispatch or invoke callbacks. A zero return queues the call subject to the current execution committing. Starts already charged by the application should therefore remain in its rolling start window even when the unused physical reservation releases. (Official System API, inter-canister calls)

Codes 1–5 are the known definite reject classes; code 6 is the explicit unknown outcome class. The raw code must remain available so new values default to uncertainty. (Official reject-code definitions) The SDK's existing CallErrorExt::is_clean_reject() is a different property: it whitelists only 1–3 to assert no callee state changes. It cannot replace the physical-completion classifier; 4 and 5 can finish the original exchange despite prior committed callee effects.

Callback ownership, drop and cleanup

The baseline system wrapper documents callback-environment ownership, expressly separating memory safety from semantics. On successful dispatch, either the normal callback or cleanup owns the raw Arc after rollback; nonzero call_perform releases it immediately. The SDK counts pending callbacks even after their awaiting task is cancelled. Normal CallFuture drop does not cancel a dispatched IC request. Recovery drop marks the future trapped; cleanup cancels tasks in the originating method/task context. None of those local ownership facts discharges possible late delivery.

The baseline cleanup path fabricates CallRejected(4, "cleanup") for callers outside the default executor while discarding the original response class. It must not become evidence of a genuine CANISTER_REJECT: the trapped callback could have carried SYS_UNKNOWN. A reusable public classifier needs explicit cleanup provenance or conservative treatment; matching an error-message string is not a reliable semantic contract. The default executor instead cancels the task, so its ExchangeGuard::drop must report uncertainty.

Current official System API documentation permits msg_reject_code in cleanup, contrary to the older comment preserved in the local cleanup implementation. Cleanup runs after callback rollback; a cleanup trap also rolls back its own changes and triggers no further recovery. This review does not infer behavior of an older measured replica from the current specification. (Official System API, arguments and cleanup)

The SDK fork records upstream ic-cdk 0.20.3 at commit 624606f7fd1ecd6668e9608594946486aec29167 in UPSTREAM.json. The inherited ownership and cleanup structure is independently inspectable in the pinned primary upstream source. The authoritative baseline for this application is the local SDK source above, including its Wire response cap and task-context changes.

Commit rationale draft

Expose physical disposition independently from Reactor ACK validity. A returned reply, local predispatch failure, or genuine definite IC reject releases the original transmission's physical reservation while the existing ACK path keeps batch custody and retries intact. Preserve physical uncertainty for SYS_UNKNOWN, unknown future reject codes, abandoned guards and cleanup without response provenance. Keep rolling start charges unchanged. Do not substitute single-callback ownership for proof that no counted late delivery remains.

Validation performed by this reviewer: read the pinned SDK call/callback/cleanup and host paths; independently checked primary IC specification and upstream source. No Cargo/build/actual-network experiment was run in this lane. Adapter diff review is recorded below; the implementation owner's concrete test receipt is separate.

Implementation diff review

The subsequent RRT and RRts adapter diffs were independently reviewed before qualification. Both carry PhysicalDisposition alongside the unchanged Option<Acknowledgement>, classify failures before they lose provenance, use a positive whitelist for debt retirement, and report UnknownOrAbandoned from guard drop. All in-repository Host implementations accept the added argument. The core CallRejected now carries private cleanup provenance exposed through is_cleanup(), so a synthetic code 4 cannot pass the definite-reject whitelist. The raw-Arc ownership path, callback count, executor wake/cancellation paths, and actor-frame placement remain unchanged. No source-level blocker was found.

The new component tests cover the known/unknown reject classes, cleanup origin, predispatch errors, oversized replies, valid ACK variants, malformed Wire, wrong-method envelopes and debt-retirement classification. The callback probe also asserts the disposition during normal completion and trap cleanup. Reading those tests establishes intended coverage; it does not establish that they ran.

Pre-first-poll task cancellation remains an existing unqualified edge: the guard is constructed inside the async body, after prepare reserved the exchange. A future cancelled before its first poll has no guard-driven host completion. Its reservation remains conservative, but this change does not claim recovery or exact-once callback accounting for that case. Moving guard construction across the actor/executor boundary requires its own frame and rollback evidence.