Repository navigation
fix(backends): retain retry owners for refused launch cleanup - #3964
Merged
Merged
Conversation
This was referenced Nov 11, 2026
schlessera
marked this pull request as draft
November 11, 2026 02:35
schlessera
marked this pull request as ready for review
November 11, 2026 02:35
This was referenced Nov 11, 2026
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.
Closes #3821
Closes #3489
Refs #3813
What changed
A failed Claude launch now hands its original retryable cleanup and retained runtime-state/turn-temp reservation to the shared SDK reconciler. Pi does the same when a post-launch callback refuses. Required native output and checkpoint deletion must confirm before the failed launch releases its reservation; rejected deletion promises can be retried without reopening publication or admitting new consumers. The original launch error remains the outcome.
Why this shape
This implements #3489's selected owner and reuses #3815's reconciler unchanged: indefinite retries, capped backoff, unreferenced timers, existing Activity notices, and shutdown that releases nothing. The SDK close retains the exact failed-launch broker instead of reconstructing cleanup authority. The native deletion memo changes are necessary so a retry can reach the real deletion operation after a refusal. The launcher/error path remains internal; supported API signatures, CLI/MCP/HTTP shapes and provider history are unchanged. The review follow-up records one shared diagnostic helper name in the existing internal export inventory. A patch changeset covers the three affected packages.
Collision review found draft #3464 also touching
packages/ui-sdk/src/server/worker-launcher.ts; this diff is confined to the failed-launch cleanup branch. Both issues and this PR target milestone 0.45.0.Proof
Current base:
067d1904bafccf0503a1e3effd6bd260ebf34769. Current head:4c707a691d38c322f841c6eb648a978f32f9200f.The full-suite proof for the review follow-up is recorded in Review follow-up below. The original implementation receipts in this table were collected on
4082835e75cd76a27e5b0b94a13c9bdb2cf15536, starting from60d7967f16665846fe4655b251fa19543847fbd5, with a later preflight/typecheck refresh atbcc5ac40008eb05e54297a532a9c135b48c58222. They retain those actual identities; they are not relabelled as proof of the follow-up.bun test --timeout 30000 ./testsbun run test packages/ui-sdk packages/ui-backend-claude packages/ui-backend-pibun run test packages/ui-server/tests/no-console.test.ts packages/ui-server/tests/maintenance-temp-boundary-diagnostics.test.tsbun run lintNODE_OPTIONS=--max-old-space-size=16384 bun run typecheckbun run api-report --write;bun run api-reportbun scripts/check-changeset-packages.ts;bunx --no-install changeset statusbun run check:pr --base origin/mainbun scripts/prove-worker-identity.tsFailing-first tests before implementation: Claude exited 1 on
FAILED_LAUNCH_EXPOSES_OWNED_CLOSE; Pi exited 1 onPI_POST_LAUNCH_REFUSAL_HAS_RETRY_OWNERand the required-output reservation assertion. The restored focused run passed all 46 tests; the later complete package run includes the final test versions.Acceptance criteria
Mutation receipts
Each mutation was baseline pass (exit 0), expected assertion failure (exit 1), then restored pass (exit 0). The failure output was inspected, including the actual reservation count for the Claude handoff.
FAILED_LAUNCH_CONFIRMED_RETRY_RELEASES_RESERVATIONPI_POST_LAUNCH_REFUSAL_HAS_RETRY_OWNERNATIVE_STAGE_REFUSED_DELETE_CAN_RETRYCHECKPOINT_DELETE_RETRIES_AFTER_REFUSALProportionate containment
{ "version": 1, "kind": "brain-check-pr-receipt", "head": "3d12b32096617f52383361b2c1d5dbaf788b18db", "base": "origin/main", "mode": "focused", "startedAt": "2026-11-11T02:33:12.275Z", "finishedAt": "2026-11-11T02:34:33.322Z", "checks": [ { "name": "all lint and leakage gates", "categories": [ "changeset" ], "outcome": "passed", "elapsedMs": 14051.830699999999 }, { "name": "environment documentation", "categories": [ "changeset" ], "outcome": "passed", "elapsedMs": 118.78857900000003 }, { "name": "pending changeset package names", "categories": [ "changeset" ], "outcome": "passed", "elapsedMs": 76.63833700000032 }, { "name": "contribution changeset", "categories": [ "changeset" ], "outcome": "passed", "elapsedMs": 23.98508799999763 }, { "name": "affected fast invariants", "categories": [ "verify", "unit" ], "outcome": "passed", "elapsedMs": 66666.353645 } ] }Review follow-up
Independent review of
bcc5ac400identified F1 and F2 proof gaps and N1's inconsistent missing-close behavior. Current main was merged first (merge commit3e8ec581b); this follow-up is4c707a691d38c322f841c6eb648a978f32f9200f.worker_cleanup_strandedstderr diagnostic with backend,missing_retryable_close, runtime-state/turn-temp bytes and cause, and schedule no retry. Both backend tests assert the original error, retained charge, zero scheduled tasks and exactly one diagnostic. A shared internal helper keeps the diagnostic shape consistent. The internal export inventory and patch changeset are updated; no supported API or wire shape is added.STRICT_FAILED_LAUNCH_RESOURCE_REFUSAL_RETAINS_RESERVATION, expected 1 retained reservation, got 0; fails for both prepared-output and startup-only variantsSTRICT_FAILED_LAUNCH_OUTPUT_NOT_DELETED_BY_OUTER_CATCH, expected an existing stage, got deletedCLAUDE_STRANDED_CHARGE_HAS_ONE_DIAGNOSTIC, expected one line, got zeroNO_FUTILE_PI_CLEANUP_RETRY, expected zero scheduled retries, got oneAll failure outputs were inspected at the named assertions, and source was restored after every mutation.
Full local proof after restoring all mutations (every command's real exit code was read):
bun test --timeout 30000 ./testsbun run test packages/ui-sdk packages/ui-backend-claude packages/ui-backend-pibun run test packages/ui-server/tests/no-console.test.ts packages/ui-server/tests/maintenance-temp-boundary-diagnostics.test.tsNODE_OPTIONS=--max-old-space-size=16384 bun run typecheckbun run lintbun run api-reportbun run check:pr --base origin/mainAll four mutations above have independently recorded baseline, mutated and restored exit codes. No candidate confirmation or merge was run.
Checklist
Anything left open
The full native command initially exited 1 in the existing prepared-consumer cleanup-failure mode: the resumed turn failed during startup before its second request. The task's real broker cleanup qualification passed in that run. One original-checkpoint control and one candidate diagnostic run with extra fixture logging passed the full native identity composition, including both prepared-consumer modes. These passes do not attribute or repair the intermittent failure. Evidence and recurrence capture are recorded in #2744.
The root suite's initial ambient-environment run reproduced the two sandbox-note failures tracked in #2769; the environment-controlled full result is listed above. The package suite's one expected skip is the existing delegated-cgroup fork/OOM test: no systemd user manager can delegate a cgroup subtree here. No cgroup behavior is changed or newly qualified by this PR.
No candidate confirmation or merge was requested by this implementation worker. The coordinator owns those steps and the final hosted proof review.