Repository navigation
docs(sandbox): lease mode is an experimental operator opt-in in v0.11.0 - #920
Conversation
install.md: level 1 (lease) is experimental and off by default; an operator may opt in with SBX_MODES_ALLOWED=per-exec,lease. It becomes supported after the live smoke (runbook §13 step 8) and the security review's lease section. Adds what to check before opting in (snapshots with lease-v1 and balloon-fpr-v1, upgraded workers, the janitor's wait) and the known limits from the lease-mode measurement: memory stays near the ceiling, cancelling a running command ends the lease, workspaces at most 2048 MiB (rossoctl#907). Level 2 stays off as before. lease-mode.md: an experimental note, how a lease ends (idle, the agent gone 2 min, the maximum duration, memory reclaim, reset or downgrade, a worker restart), what survives, and the known limits for users. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Review — docs(sandbox): lease mode is an experimental operator opt-in in v0.11.0
Every timer and every limit in the new text matches the code, and the install page's opt-in path is consistent with what setup.sh actually enforces. #915 is already in main, so the dependency note is satisfied.
Install page (docs/operate/sandbox-service/install.md)
- The janitor rule:
setup.sh:261requires the wait to exceed the token lifetime + 30 s, and:281addsSBX_IDLE_CEILING_Swhen a lease mode is allowed. Defaults are 60 min against 45 s / 1845 s, so "the defaults pass" is right, and "the janitor's wait, below" does have a target (:218). - Snapshots:
lease-v1alone is lease-capable with a start-up warning; the warning is exactly about the missingballoon-fpr-v1and the never-returned memory (remote-worker/cmd/microvm-worker/main_test.go:721-740). - Workers: "re-run
install-host.shwheneverSBX_IDLE_CEILING_Schanges" matches both the table row and the worker's old-ceiling behaviour. - Known limits: page cache kept / charge near guest RAM is the E17b finding and is consistent with the reclaim model; the 2048 MiB workspace limit is #915's rule.
Lease how-to (docs/sandbox/how-to/lease-mode.md)
- Idle 300 s default, counted from the end of the last command (
DefaultLeaseIdle,config.go:65). - Agent gone after 2 min:
DefaultLeaseKeepaliveLoss = 120 * time.Second(config.go:72) with a 30 s keepalive cadence (mcpKeepalivePeriod,config.go:83); onlymocactl sbx mcpsetskeepalive(mcp.ts:114). - 8 h / 4 h and the 30 min grace:
DefaultLeaseMaxDuration,DefaultLeaseMaxDurationProcesses,DefaultLeaseGraceLimit(config.go:68-70). "Commands still run, each with a warning" is real: every result while expiring carries anexpiringlease event, rendered as[sandbox] guest restarts within N min (max_duration)(sandbox-client/src/lease.ts:199-207). - Memory reclaim:
reclaimLeasesLockedtakesidleLeaseRunsLocked(idle-longest first) and skips any lease whose gate is held — the comment is explicit that a lease with an Exec in flight is never reclaimed (vmpool/lease.go:1227-1254). - reset / mode change / worker restart /
agent_deadare allLeaseEndReasonvalues (lease_mode.go:97-107); at most 4 tracked processes isDefaultLeaseMaxProcesses = 4(config.go:78), bounded by the image's 4 tracked uids.
Checks: make check-links → 236 files, 0 broken (in-page #known-limits included); check-docs-publish.sh → 83 files, clean. CI at review time: 12 green, 4 pending.
One suggestion inline about the sandbox/v1 client sentence.
Author: pdettori (MEMBER — maintainer). Agent/IDE config: none. Commits: 1, signed off.
| - **The agent went away.** While your agent runs, `mocactl sbx mcp` tells the sandbox every 30 s | ||
| that it is still there. If 2 minutes pass without that signal (the agent exited, the laptop went | ||
| to sleep, the network dropped), the lease ends without waiting for the idle timeout. A lease | ||
| started from `mocactl sbx exec`, `run`, `shell` or your own `sandbox/v1` code has no such signal |
There was a problem hiding this comment.
suggestion: a sandbox/v1 client can opt into the keepalive rule — Exec.keepalive is a client-set field (proto/sandbox/v1/sandbox.proto:90, "opts the lease into the keepalive-loss rule"), and mocactl's own exec path simply leaves it false (sbx/exec.ts:280 only forwards what the caller passes). So "your own sandbox/v1 code has no such signal" would mislead someone writing a client: the accurate form is that a lease with no client keepalive — exec, run, shell, or a client that leaves keepalive false — ends by the idle timeout only, and a client that sets keepalive gets the 2-minute rule too.
There was a problem hiding this comment.
Fixed in the latest commit. The sentence now reads: a lease with no client keepalive (from mocactl sbx exec, run or shell, or a sandbox/v1 client that leaves Exec.keepalive false) ends by the idle timeout only. A client that sets it, and calls LeaseKeepalive every 30 s, gets the 2-minute rule too. It links to the API guide's Lease mode section, which already describes Exec.keepalive (direct-api.md lines 221–225).
Assisted-By: Claude Code
…ule (rossoctl#920 review) Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Summary
Documents lease mode as an experimental operator opt-in for v0.11.0, in the refactored docs: the Deploy-and-operate install page and the sandbox how-to. Until now the install page said lease mode "stays off" until the live smoke and the security-review sign-off.
docs/operate/sandbox-service/install.mdlease) is experimental and off by default. An operator may opt in withSBX_MODES_ALLOWED=per-exec,leaseand asetup.shre-run. It becomes supported, and a candidate for the default, after its live smoke (runbook §13, step 8) and the security review's lease section.lease-v1andballoon-fpr-v1;install-host.shre-run whenSBX_IDLE_CEILING_Schanges;SBX_MODES_ALLOWEDtable row now points to this paragraph. Level 2 (lease+processes) stays off; that paragraph is unchanged.docs/sandbox/how-to/lease-mode.mdAn "Experimental" note under the Preview banner.
When a lease ends:
mocactl sbx mcpkeepalive, which applies only to MCP-started leases);Also what survives an end.
Known limits for users:
Every timer and limit is taken from the code at main:
remote-worker/internal/vmpool/config.goandlease_mode.go, andmocactl sbxhelp. The published pages name no internal deployment (scripts/check-docs-publish.shpasses).Depends on #915 for the sentence "
setup.shandinstall-host.shrefuse a largerSBX_WORKSPACE_IMAGE_MB". Merge #915 first.Tests
scripts/check-docs-publish.sh: 83 published files, none matches the denylist.python3 scripts/check-doc-links.py: 236 files, 0 broken links.--checkis clean on both files.Assisted-By: Claude Code