Hyeonsang Cho aa978d1b32
fix(sandbox): release the E2B ownership lease when acquire finds the VM gone (#7277)
* fix(sandbox): release the E2B ownership lease when acquire finds the VM gone

The in-process reuse path (dead or unreachable cached client) and the
warm-pool reclaim path (reconnect reports "sandbox not found") dropped
their local bookkeeping but kept the VM's ownership lease. Nothing later
sees that ID: the warm sweep only walks the warm pool, reconciliation
only walks the remote inventory, and the lease renewer keeps renewing
(and re-claims a lapsed lease) until shutdown. Every reaped VM left one
entry in _owned_sandbox_ids and one renewed ownership key behind.

Call _release_ownership in both branches. Both act only on E2B's trusted
not-found signal, the store's release is a no-op for a peer's lease, and
a backend error still drops the local ID so the shared lease expires on
its TTL.

* docs(changelog): reference #7277 for the E2B dead-VM lease fix

* test(sandbox): pin that transient E2B errors keep the ownership lease

The dead-VM release is only safe because the gone signatures match
narrowly. Pin the other side: a non-gone ping error keeps reusing the
cached VM, and a non-gone warm reconnect error leaves the lease to
eviction.

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-10-23 08:08:35 +08:00
..