Remove a cancelled `SpritesSandbox` command's stderr capture file over a slow exec
- Part of #8933
When a Sprites command is cancelled, the backend reads back and removes its stderr capture in /tmp with a fresh exec under stop_shielded, which got the default 2 s grace. A live exec takes about 2 s, so the read-back was often cut off and the file stayed in the Sprite. With the fake transport and a slow read-back handshake, the capture file is still there after the cancel.
This passes grace=_INTERNAL_EXEC_TIMEOUT, the bound _read_capture already gives that same exec, as other backends pass their own stop bound (e2b, render, docker_container). The grace was the cause: _read_capture's own bound is already 30 s, and _close_command runs before the shield under its own bound. In the worst case (an unreachable Sprite), a cancelled or failed command now waits up to about 30 s instead of 2 s, since _abandon_command runs for any exception. The timeout path already does this read-back unshielded under the same 30 s bound.
Left out:
- Removing stale capture files and capping the capture size. Both need decisions (age threshold, cap size and how a capped capture reports), so they stay on the issue.
- A second cancel arriving during
_close_commandskips the cleanup, and with a caller-supplied client a cancelled read-back can open a client nothing closes. Both predate this PR.
The new test moves the loop clock 25 s during the read-back's handshake (no real waits). It fails on main and passes here. No Sprites key was available, so this is proven with the repo's fake Sprites transport only.
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
- PR title is fit for the release changelog.
Summary by cubic
Fixes cancelled Sprites commands leaving their stderr capture file in /tmp when the cleanup read-back exec runs longer than the default 2 s stop-shield grace.
- The read-back now runs under
_INTERNAL_EXEC_TIMEOUT, matching its own exec bound, so the capture file is removed even over a slow read-back; cancelling an unreachable Sprite now waits up to about 30 s instead of 2 s. - Adds a test that moves the loop clock during the read-back handshake, keeping it within the exec handshake timeout, with the readiness poll as a real wait; it fails on
mainand passes here. - Removing stale capture files and capping capture size stay on #8933; both need a decision (age threshold, cap size, and how a capped capture reports).