Repository navigation
fix: retain managed Daytona cleanup after uncertain creation - #1579
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 28, 2026, 4:30 PM ET / 20:30 UTC. ClawSweeper reviewWhat this changesThe PR persists exact Daytona resource identity and original provider context during brokered creation, adds native sandbox TTL checks, and retains unresolved cleanup state after a lost create response. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open: the branch addresses the open Daytona cleanup bug and has substantial real-provider evidence, but its intentional fail-closed treatment of legacy unscoped lease records needs an explicit maintainer rollout decision before merge. Priority: P1 Review scores
Verification
How this fits togetherThe Worker coordinator creates brokered leases, persists their lifecycle state, and later releases or expires them. Its Daytona provider adapter allocates sandboxes and performs identity-checked cleanup, while the coordinator schedules retries and exposes lease status. flowchart LR
A[Brokered lease request] --> B[Coordinator reservation]
B --> C[Daytona sandbox allocation]
C --> D[Persist exact UUID and scope]
D --> E[Readiness and SSH access]
D --> F[Scoped cleanup]
F --> G[Observed deletion or unresolved record]
Decision needed
Why: This is a deliberate tradeoff between preserving a working legacy workflow and preventing a new credential or endpoint context from gaining deletion authority; source alone cannot choose that policy. Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the exact-ID and scope fencing only after maintainers explicitly accept the legacy-record cutover or provide a safe, operator-approved upgrade path that does not silently adopt resources under current credentials. Do we have a high-confidence way to reproduce the issue? Yes: the linked open issue provides a concrete lost-create fault scenario, and the added Worker regressions cover release, restart, retained-resource, and context-loss paths. This review did not execute the tests because the checkout is read-only. Is this the best way to solve the issue? Unclear: durable UUID publication and adapter-scoped ownership checks fit the provider-neutral architecture, but the intentionally incompatible legacy-record handling requires maintainer policy approval before it is the best release path. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d024b182260d. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Record exact resource identity before readiness, preserve unresolved cleanup across lifecycle transitions, and bind destructive operations to the original provider context. Request native TTL and verify a fixed remaining deadline without assuming atomic creation timestamps.
21bc20c to
029b4c2
Compare
Maintainer decision and land-ready proofApproved: use the documented fail-closed cutover for legacy unscoped Daytona leases and changed credentials, including same-organization key rotation. This decision was explicitly accepted in the task before implementation. It resolves the remaining P1 policy question and rank-up move in the latest review; it is not a request to invent an automatic migration or adopt resources under current credentials. Operator path: finish outstanding cleanup in the original context before upgrading/rotating when possible. Inspect unresolved records with The legacy transition is now additionally verified with real workerd and persistent SQLite Durable Objects: byte-verified stable Final head: The separate real-provider proof completed managed create, real SSH use, unauthorized caller/context rejection before provider I/O, original-context managed GET → DELETE → 404 cleanup, lost-response persistence through release/restart, and native expiry without any coordinator provider calls after the lost create. All three authorized task sandboxes are confirmed gone; the successful retry used no emergency deletion. The final Worker tree is identical to the live-tested implementation. No further allocation, tagged release, or package publication is authorized or needed. |
Fixes #1575 — managed Daytona loses cleanup after an unacknowledged create.
The real managed lifecycle and lost-response/native-expiry proof now pass. Final head
029b4c28a46c3d5a1d26eeec6efb9630bbe6caabadds the release note and rebases ontod024b182260d671973f0eb979e966ea6a7054332; its entireworker/tree is byte-identical to the live-tested21bc20c6e6ff72496d0b83263e2473642f1474b8. All 20 relevant checks on the exact final head passed, including the non-bypassable Release Check. Merging triggers the normal production coordinator deployment; no tag or package release is requested.Additional instructions
Keep Allow edits from maintainers enabled where applicable. This branch is in the upstream repository and is takeover-ready.
What Problem This Solves
Resolves a problem where a managed Daytona allocation could succeed upstream but become invisible to coordinator cleanup after its response was lost and an immediate inventory lookup returned nothing. Failure, release, restart, and expiry could then discard uncertainty without establishing that the sandbox was gone.
The original composed secretless reproduction failed in six cases across fixed-ID PUT and ordinary POST with no release, release during creation, and release after failure. The inventory response shape is valid: this is a lifecycle-ownership bug, not list decoding.
Why This Change Was Made
The provider requests native creation-relative wall-clock TTL in the original allocation. The coordinator records a returned exact UUID and original request-context fingerprint before readiness can race release or restart, and preserves explicit unresolved responsibility when it receives no UUID. Cleanup requires the original API, configured organization, and credential context, checks exact ownership, then observes terminal provider state or exact-resource absence. DELETE acknowledgment alone is not completion.
Immediate name/label adoption and provider-local readiness rollback are removed in favor of the existing coordinator lifecycle owner. Provider-authoritative recovery cannot fall through to generic label discovery. Fixed PUT retains its public replay/cancellation contract. There is no new datastore, schema version, configuration option, dependency, or direct-Go change.
The first live control caught an error in this patch's original deadline check: Daytona's creation and TTL timestamps differed by the requested five minutes plus 1 ms. Readiness now pins a maximum remaining native deadline once when observation begins, rejects missing/expired/excess deadlines, and never extends the bound while polling. It adds no arbitrary clock tolerance.
User Impact
Operators get a visible unresolved outcome rather than false cleanup success after an ambiguous create. Native TTL applies to kept and explicitly retained managed sandboxes, starts at provider creation, and is not extended by heartbeats. API versions that silently ignore TTL are not accepted as ready.
Legacy records without scope and changes to the API endpoint, organization, or API key deliberately fail closed for cleanup and access refresh. This includes same-organization key rotation. Finish cleanup before rotating credentials, or restore the original context and repeat explicit stop. Missing historical scope requires operator resolution, never backfilling from current configuration. These rollout tradeoffs were explicitly approved. Empty inventory and elapsed TTL never become deletion proof.
Evidence
Real managed lifecycle and authority boundary
Completed August 28, 2026, 20:11 UTC using the official signed 0.46.0 CLI, the actual candidate Worker under local workerd with persistent Durable Objects, and the real Daytona API. The original failed control was already cleaned up; the separately authorized retry enforced a cumulative maximum of three task sandboxes, five-minute requested native TTL each, and a $1 total ceiling. All three are confirmed terminal. The successful retry required no emergency DELETE, and the outbound safety guard blocked zero requests.
The known-ID case completed managed
warmup, then the documentedcrabbox ssh --show-secrethandoff executed a fixedprintfover real noninteractive SSH, exit 0. The token-bearing handoff was captured only in memory and redacted before evidence storage. A task-only SSH wrapper excluded host SSH profiles, pre-existing identity files, and agent access; host-key verification used task-onlyknown_hosts. No repository sync or run-history claim is made.While the same sandbox existed, real Worker restarts changed the non-admin caller, provider credential context, API URL, and organization. The different caller received HTTP 404. Each provider-context mismatch accepted release intent but retained the exact UUID and original scope with visible cleanup/failure diagnostics. Every negative case produced zero provider I/O, not a request blocked by the harness. Replacement key/URL/organization values were synthetic changes to the isolated Worker's trusted configuration; no new credential was minted and no other provider account was contacted. After restoring the original context, ordinary managed
stopexited 0; the Worker trace shows exact-resource GET 200 → DELETE 200 → GET 404. Independent exact-ID observation also returned 404.Real lost-response and native expiry
The observer captured a real create HTTP 200 and withheld its UUID by returning HTTP 502 to the Worker. The CLI visibly failed; its fixed-PUT replay returned 409 without another provider create. Explicit release and a real Worker restart preserved empty
cloudID, the original scope/dispatch evidence, and both unresolved diagnostics.The native deadline was 20:10:51.951 UTC. Exact-resource HTTP 404 was observed at 20:11:17.204 UTC, about 25.3 seconds later. The Worker made zero provider requests after the lost create: no inventory adoption, SSH access, or DELETE. The coordinator still correctly reported unresolved after observer-known native termination, because it never received the UUID. This observed timing is not a provider teardown SLA.
The nine-request Worker/control trace was: inventory GET; known create POST; exact readiness GET; SSH-access POST; exact ownership GET; DELETE; exact GET 404; independent known-completion GET 404; lost create POST with provider 200 / delivered 502. The observer's native-expiry polling used only the separately retained exact UUID. No database rows were manually edited.
Regression, compatibility, and review
The missing-scope upgrade also passed a supplementary real-runtime/persistent-store check. Byte-verified stable
v0.47.0source (0a55378990265271f5830a465aa643605d7d41f3) naturally created a managed, known-ID, unscoped lease through authenticated public POST. The current Worker reopened the same native SQLite Durable Object store, accepted release intent, and its native alarm persisted explicit unresolved cleanup with the UUID intact and zero provider calls. A second reopen retained that outcome. SQLite inspection was read-only; no row was manufactured or backfilled. Both source versions used the installed workerd engine, and the old provider's three responses were synthetic: this proves the runtime/store upgrade, not an observed historical Cloudflare deployment or another real-cloud allocation.Maintainer rollout decision: the maintainer explicitly approved fail-closed cleanup/access refresh for legacy unscoped leases and changed credentials, including same-organization rotation, before implementation. Existing unscoped leases require manual resolution in their original provider account; they must not be silently adopted or backfilled from current configuration. New native TTL is not retroactive. This is the accepted cutover policy requested by the latest ClawSweeper review, not an unapproved migration gap.
Commands:
Dependency contracts inspected: public Daytona clients at
dbf05b3f7a1b79caa0bf7cc77593fb5851811f0c(CreateSandbox.ttlMinutes,Sandbox.autoDestroyAt, eventually consistent inventory); historical public server v0.190.0 at01c502bb1f1ff8f2885d0cd490e043736083dca8; and the live API schema. Historical source is not claimed to identify the current hosted server revision or guarantee teardown latency.Scope/size: 8 files; production +404/-175, net +229; tests +1,057/-4, net +1,053; docs/changelog +59/-8, net +51. Production growth owns early durable identity publication, original-context fencing, and unresolved lifecycle responsibility. Immediate label recovery and adapter-local rollback were removed; sibling provider/cancellation/cleanup paths are covered by the full Worker suite.
Review follow-through: the real managed lifecycle, unauthorized caller/context rejection, matching-context deletion, restart/release persistence, native expiry, and zero-residue requests in the ClawSweeper review are now demonstrated. The legacy cutover decision and the distinction between real-store upgrade and synthetic provider transport are recorded above. Tagged releases and package publication remain out of scope; production deployment uses the normal main-triggered workflow.