Skip to content

docs(sandbox): lease mode is an experimental operator opt-in in v0.11.0 - #920

Merged
pdettori merged 2 commits into
rossoctl:mainfrom
pdettori:docs/lease-mode-experimental
Nov 19, 2026
Merged

pdettori merged 2 commits into
rossoctl:mainfrom
pdettori:docs/lease-mode-experimental

Conversation

@pdettori

Copy link
Copy Markdown
Member

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.md

  • Level 1 (lease) is experimental and off by default. An operator may opt in with SBX_MODES_ALLOWED=per-exec,lease and a setup.sh re-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.
  • Before you opt in:
    • snapshots that advertise lease-v1 and balloon-fpr-v1;
    • workers upgraded, with install-host.sh re-run when SBX_IDLE_CEILING_S changes;
    • the janitor's wait rule.
  • Known limits (from the lease-mode measurement, E17b):
  • The SBX_MODES_ALLOWED table row now points to this paragraph. Level 2 (lease+processes) stays off; that paragraph is unchanged.

docs/sandbox/how-to/lease-mode.md

  • An "Experimental" note under the Preview banner.

  • When a lease ends:

    • idle timeout;
    • the agent gone for 2 minutes (the mocactl sbx mcp keepalive, which applies only to MCP-started leases);
    • the 8 h / 4 h maximum duration with its 30-minute grace;
    • memory reclaim;
    • reset or downgrade;
    • a worker restart.

    Also what survives an end.

  • Known limits for users:

    • Ctrl-C ends the lease;
    • a lease holds its guest's memory;
    • at most 4 tracked processes.

Every timer and limit is taken from the code at main: remote-worker/internal/vmpool/config.go and lease_mode.go, and mocactl sbx help. The published pages name no internal deployment (scripts/check-docs-publish.sh passes).

Depends on #915 for the sentence "setup.sh and install-host.sh refuse a larger SBX_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.
  • Prettier 3.10.1 --check is clean on both files.

Assisted-By: Claude Code

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]>
@pdettori pdettori added this to the v0.11.0 milestone Nov 19, 2026

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:261 requires the wait to exceed the token lifetime + 30 s, and :281 adds SBX_IDLE_CEILING_S when 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-v1 alone is lease-capable with a start-up warning; the warning is exactly about the missing balloon-fpr-v1 and the never-returned memory (remote-worker/cmd/microvm-worker/main_test.go:721-740).
  • Workers: "re-run install-host.sh whenever SBX_IDLE_CEILING_S changes" 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); only mocactl sbx mcp sets keepalive (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 an expiring lease event, rendered as [sandbox] guest restarts within N min (max_duration) (sandbox-client/src/lease.ts:199-207).
  • Memory reclaim: reclaimLeasesLocked takes idleLeaseRunsLocked (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_dead are all LeaseEndReason values (lease_mode.go:97-107); at most 4 tracked processes is DefaultLeaseMaxProcesses = 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.

Comment thread docs/sandbox/how-to/lease-mode.md Outdated
- **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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@pdettori
pdettori merged commit aa911e6 into rossoctl:main Nov 19, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants