Skip to content

docs(sbx): the template onboarding guide and its governance - #793

Merged
pdettori merged 8 commits into
rossoctl:mainfrom
webchang:pr/i31a-onboarding-guide
Nov 15, 2026
Merged

pdettori merged 8 commits into
rossoctl:mainfrom
webchang:pr/i31a-onboarding-guide

Conversation

@webchang

@webchang webchang commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Part of #753. On main (e921272). Documents the units in #756–#792; merge after them. A second PR (the operations docs) closes #753.

What it does: the template onboarding guide and the governance docs. Three signed-off commits:

  1. deploy/sbx/template-onboarding/GUIDE.md, ONBOARDING.md (the step list) and the folder's README.md.
  2. governance/README.md and PROCESS.md: the process, and how its rules are owned.
  3. A pointer in deploy/microvm/P4-ON-P6.md, and a "Start here" row in docs/index.md.

Notes for review:

  • Each unit's own RUNBOOK, configuration and spec sections went with that unit's PR; this one carries the rest.
  • Files that exist only in the unit PRs are named in code spans, not linked, so main's link check passes.
  • The worked examples use public images and public SWE-bench ids only.

Checks: scripts/check-doc-links.py finds 0 broken links, and prettier passes.

7 files, +1,387 / -22.

Assisted-By: Claude Code

…r's index

Add deploy/sbx/template-onboarding/GUIDE.md, ONBOARDING.md and README.md: how a
container image becomes a Moca sandbox template, end to end, and how clients and
agent sessions use it.

- GUIDE.md: the mental model (what a snapshot holds, where things run, names), the
  flow on one page, the template spec, a worked example on Moca's public sandbox
  image, self-serve from an OCI image (the profiles, the Moca minimum layer, path A
  on python:3.12-slim, path B with the user's own gate record, what Moca records,
  the refusals users meet), a worked SWE-bench instance (django__django-11133),
  two templates side by side, update and retire, templates in Moca Pi sessions
  (a session pinned to a build), capacity, and troubleshooting.
- ONBOARDING.md: the short reference (steps, the spec's fields, the tools' options).
- README.md: what is in the folder and where the related files live.

The guide describes the units proposed with rossoctl#730 to rossoctl#752. Files that only those
units add (the tools, the samples, the specs) are named in code spans, not
linked, so every link resolves on main. Measured figures state their conditions;
the worked examples name public SWE-bench instance ids and public images only.

Refs rossoctl#753

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
Add deploy/sbx/template-onboarding/governance/README.md and PROCESS.md.

- README.md: what governs the onboarding tools, who owns each document, how a
  gating rule changes (a pull request to the rules with the code that enforces
  them) and how a deployment's own choices change instead (an admin's
  PUT /v1/policy, a policy provenance record).
- PROCESS.md: the template process step by step (set the policy, gate the image,
  write the spec, create, build, follow, register, activate, use, age out,
  retire, change, verify offline), each with who does it, the tool, the rules it
  applies and the record it leaves, and what the units proposed with rossoctl#730 to
  rossoctl#752 implement.

The gating rules themselves (GATING-RULES.md) come with the self-serve create
(rossoctl#737); they are named here, not linked.

Refs rossoctl#753

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
…uide

- deploy/microvm/P4-ON-P6.md: the hand-built snapshot steps say that turning a
  container image into a sandbox template is the onboarding guide's flow.
- docs/index.md: a "Start here" row for turning an image into a sandbox
  template, with the onboarding folder and its governance.

Refs rossoctl#753

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>

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

Summary

Docs only: the template onboarding guide (GUIDE.md), its short reference (ONBOARDING.md), the folder README.md, the governance README.md/PROCESS.md, a pointer in P4-ON-P6.md and a "Start here" row in docs/index.md. I checked the claims against main 6f9a736 (template-policy.ts, setup.sh defaults, the example specs and gate record, GATING-RULES.md) and against #794 for RUNBOOK §14 / SBX_CHECK_PROBE_<ID>. They hold, with two exceptions in §4b.4's base walk-through, where the sample is out of step with the policy on main (inline). Files that land with the unit PRs are named in code spans, as the body says, so the link check passes now. They still need to merge first, as the body says.

Author: webchang (MEMBER — maintainer)
Areas reviewed: Docs
Agent/IDE config (.claude/.vscode): none
Commits: 3 commits, all signed-off: yes
CI status: passing (all 18 checks)

AI-assisted review, approved by a maintainer before posting.

"vcpus": 2,
"egress": false,
"seed": "",
"skip_git_identity_check": true,

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: Copied as written, this base create is refused on main: template-policy.ts applies X12 under every profile, so skip_git_identity_check: true with no gateRecord answers 422 policy_refused, rule X12 ("skip_git_identity_check needs a gate record showing commits refused"). And build-snapshot.sh on main already passes a git-less image ("the guest has no git: no commit to fail"). So the run this records is no longer reproducible. Suggest dropping the field from the sample and rewording the bullet below it to say that base refuses an unbacked skip (X12).

Comment thread deploy/sbx/template-onboarding/GUIDE.md Outdated
host's snapshot check then failed a git-less image. With the build tooling's check for git-less
images (an image with no git has no commit to fail), it passes by itself: leave the field out.
An image that has git should never set it on `base`.
- The policy also reads the guest size as `guest_mb`; write `guest_ram_mb`, the name the build's

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: This looks stale. On main, normalizeSpec (template-policy.ts) rewrites an alias-only guest_mb to guest_ram_mb before the spec is stored, so the build's spec step never sees guest_mb. Only a spec with both keys is refused (M7.guest). The spec_refused (guest_mb, above) example in step 4 (line 405) has the same problem. Suggest saying the alias is accepted and normalized but never sent alongside guest_ram_mb, and picking another spec_refused example.

@clawgenti clawgenti 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.

  1. must-fix — GUIDE §4.5's worked example runs mocactl sbx run -- python3 ... right after mocactl sbx create. But sbx create does not bind the sandbox (no .sbx/sandbox.json is written), so outside a bound repository that run fails with sbx: run needs --sandbox ID (or a .sbx/sandbox.json in this repository). Inside a repository bound to another sandbox, it silently runs in that other sandbox instead. Details are inline.

Everything else I checked holds against the code in the PR stack (#759, #761, #771-#792): the scripts' flags, the spec fields, env vars, error codes and the templates/retire/tag/transfer commands. No suggestions or nits.

  • Author: webchang (MEMBER — maintainer)
  • Areas reviewed: Docs (deploy/sbx/template-onboarding/{GUIDE,ONBOARDING,README}.md, governance/{README,PROCESS}.md, deploy/microvm/P4-ON-P6.md, docs/index.md)
  • Agent/IDE config (.claude/.vscode): none
  • Commits: 3 commits, all signed-off: yes
  • CI status: passing (all 16 checks, including docs, shellcheck and DCO)

Verified by:

  • gh pr view --json commits (3/3 Signed-off-by), gh pr checks 793, and gh api .../pulls/793 (author_association: MEMBER).
  • Ran python scripts/check-doc-links.py at the PR head: 0 broken links. On a local merge of main with #758-#794, the one broken anchor (P4-ON-P6.md#a-templated-p4-worker-session-templates) comes from the forced resolution of the #759/#793 conflict, not from this PR.
  • Checked the commands and flags the guide cites against the units' heads:
    • template-build.sh (--kernel/--agent/--registry/--egress-ca/--gate-record, min_budget_mb = (guest+32)×3+1024, SBX_MIN_FREE_GB) and template-register.sh (--env-file/--retire/--remove/--apply) in #771.
    • setup.sh --env-file, SBX_MAX_PER_SUBJECT/TOTAL/INFLIGHT defaults 3/40/2, SBX_PROFILE=combined (#789), SBX_START_CONCURRENCY (#784), SBX_READ_AHEAD_KB (#782), SH_TURN_PATCH_MAX_BYTES (#790), MOCACTL_SBX_BUSY_RETRIES (#761).
    • unknown_template / no such template, template_exists and template_not_active in control-plane.
  • Read packages/mocactl/src/sbx/cli.ts/commands.ts: cmdCreate writes no binding, and run resolves its id from --sandbox or .sbx/sandbox.json.

Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).

```bash
mocactl sbx templates
mocactl sbx create --template default --name try-default
mocactl sbx run -- python3 -c 'print(6*7)'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

must-fix — this sbx run has no sandbox to run in. mocactl sbx create only prints the new id and writes no .sbx/sandbox.json; run takes its id from --sandbox or the nearest binding (cli.ts, the TAKES_SANDBOX_FLAG branch). Copied as written, it fails with sbx: run needs --sandbox ID (or a .sbx/sandbox.json in this repository). Worse, run from a repository bound to another sandbox, it silently runs in that one. §5.3 and §6 already do this correctly. Suggested fix:

mocactl sbx templates
id=$(mocactl sbx create --template default --name try-default --json | jq -r .id)
mocactl sbx run --sandbox "$id" -- python3 -c 'print(6*7)'

Conflicts:
- deploy/microvm/P4-ON-P6.md: both sides added a paragraph after the
  golden snapshot's introduction. Kept main's manifest hash (version 2)
  and verify cache paragraph as main has it, then this branch's pointer
  to the template onboarding guide, right before step 1.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
…transferred until its record is trusted

The transfer paragraph in §7 now states the subject-trust rule: a
template with a self-attested build answers 409 self_attested to a
transfer until an admin trusts its gate record.

Refs rossoctl#753

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
…ress and session behavior

The guide and the step list now say what upstream main does:

- an operator still installs each registered build's worker (the host
  agent installs none), on create and on update;
- the guest_mb alias is gone from the text (the control plane stores it
  as guest_ram_mb), mocactl's --spec takes a flat spec with --profile,
  and a refused create on a new id leaves an audit line, not a check;
- the egress CA is baked only by an operator's --egress-ca build;
  egress events ship, with the 600 s seal and a later state: egress
  record;
- the refusal table gains rule envelope, the owned quota, the private
  template's 404, no_active_slot and template_unavailable; the profile
  table gains the default envelopes;
- trusting a gate record needs an admin named in the settings;
- retire waits out the 600 s egress window (--wait 900 s);
- sbx create --seed is the client's seed on a store deployment, lease
  modes are named, and mocactl run sends sandboxTemplate=ID@build as
  given;
- smaller fixes: the build's last output line, SBX_PROFILE in setup.sh's
  env file, enrollment, probe_status, --vmm, one snapshot-size figure,
  and links instead of "proposed with" wording.

Refs rossoctl#753

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
… files and name both kinds of admin

The README links the tools, samples and tests now on main, and lists
redact-provenance.py and verify-provenance.py's --egress. The governance
pages link GATING-RULES.md, drop the "proposed with" wording, label the
non-host-agent registration path, let mocactl run name ID@build, and
say that admins granted through /v1/subjects may narrow the policy or
change quotas while only a settings admin widens it or changes access.

Refs rossoctl#753

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
@webchang

Copy link
Copy Markdown
Member Author

Updated to follow main (e921272), at 9025212. An accuracy pass of the guide against main found 28 points, and all are fixed. The main ones:

  • The --spec form: templates create --spec F reads F as the spec itself, so the example now saves a flat spec and passes --profile.
  • The operator's worker install: an operator still installs each build's worker (SBX_WORKERS, setup.sh, install-host.sh), so "no operator step" is gone.
  • The template pin: mocactl run --option sandboxTemplate=ID@sha256:… now works on a control plane with a template store.
  • The widening rule: trusting a gate record, adding a registry or repository, or loosening a profile needs an admin named in the settings; API-granted admins may narrow the policy and change quotas.
  • The removal window: a retired build is removed 600 s after its last sandbox ended, and retire --wait defaults to 900 s.
  • create --seed is the client path for seeding a sandbox from a template build.
  • The refusal table: it adds 409 no_active_slot and 409 template_unavailable, and names the envelope rule and the owned quota.

This PR still merges last. Its quota and reject lines are checked again after #786 lands.

Assisted-By: Claude Code

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

Summary

Follow-up at 9025212 (269209a..9025212): one merge of main e921272 plus two docs commits. The merge e49343a is clean (git show --remerge-diff is empty). 6e112fb brings GUIDE/ONBOARDING in line with main. I fact-checked about 70 claims against e921272 (worker install, guest_ram_mb, flat --spec, --egress-ca, the 600 s egress seal and retire --wait 900, profile envelopes, the owned quota, no_active_slot/template_unavailable, the private template's 404, trust needing a settings admin, ID@build, the admin-power split). Nearly all of them hold, and every added link and anchor resolves. It also fixes our guest_mb thread. What's left: two documented admin actions don't exist on main (build reject, quota set by subject), and a few smaller wording points inline.

Still open from 14a22ca: clawgenti's must-fix on GUIDE §4.5 (line 260, sbx run with no --sandbox after sbx create) is unchanged at this head. The §4b.2 sample still carries skip_git_identity_check: true (line 365), but the bullet now says to leave it out, so that thread is mostly addressed. Dropping the field from the sample would close it. §4b.7 still has no 409 self_attested row (our earlier nit).

Author: webchang (MEMBER — maintainer)
Areas reviewed: Docs (GUIDE.md, ONBOARDING.md, README.md, governance/PROCESS.md, governance/README.md; merge e49343a)
Agent/IDE config (.claude/.vscode): none
Commits: 2 own commits + 1 merge since 269209a, all signed-off; DCO pass
CI status: all checks pass

AI-assisted review, approved by a maintainer before posting.

removes its worker and snapshot, once the 600 s after its last sandbox ended have passed (the window
in which that sandbox's last egress events still ship; `retire --wait` waits 900 s by default).
Every step is a record naming who did it. The owner also changes the description and visibility
(`templates edit`); an admin rejects a build after the fact (`POST

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: Main (e921272) has no POST /v1/templates/{id}/builds/{build}/reject. routes.ts lists the template routes, and the only build actions are cancel and DELETE (retire). reject exists only as a provenance kind (provenance.ts:45). There is no templates quota subcommand either: TEMPLATE_ADMIN_SUBS in mocactl/src/sbx/cli.ts:455 is tag/untag/edit/transfer, and quotas live in the policy (PUT /v1/policy, quota). An admin who follows this gets a 404 or an unknown-command error. Suggest marking reject as (planned) and pointing quotas at PUT /v1/policy.

| ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------- |
| `422 policy_refused`, rule `registry` | the image's registry isn't in `allowedRegistries` | use an allowed registry; never another host name for the same registry |
| `422 policy_refused`, rule `registry.repository` | that registry allows only listed repositories | ask an admin to list yours |
| `422 policy_refused`, rule `envelope` | the spec is outside the profile's envelope | fit the spec to the profile (`GET /v1/policy`) |

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: On the three 4096 MiB / 2 vCPU profiles (general-self, benchmark-self, benchmark), a spec that is too small isn't refused by envelope. That rule only checks maximums (template-policy.ts:487-497). It is refused by X15 ("a benchmark template is 4096 MiB, 2 vCPUs", template-policy.ts:621-627), which all three profiles require. Suggest adding an X15 row, or writing "rule envelope or X15".

policy allows. Read it first: `GET /v1/policy` lists `allowedRegistries` and, per registry,
`allowedRepositories` (§3). Docker Hub is written with its host: `docker.io/library/python@sha256:…`.
- **A Moca login** (`mocactl sbx login`) as an enrolled subject (in the deployment's
`SBX_ALLOWED_SUBJECTS`, or enrolled by an admin with `mocactl sbx admin subjects enroll`), and

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: Only an admin named in the settings can enroll. An API-granted admin gets refused (member-handlers.ts:29-30, and cli.ts:150-153 says "an admin named in the settings only"). Suggest "enrolled by an admin named in the settings (SBX_ADMIN_SUBJECTS)", the wording §4b.5 already uses for trust.

| 8 | Use: sessions name the template | a client | `POST /v1/sessions {sandbox:{template}}`, `mocactl run --option sandboxTemplate=ID` (also `ID:tag` or `ID@build`, resolved by the template store); SBX0 `sbx create --template` | — | the session's template and build; a `sandbox` record, or for a Moca Pi session a `session` record, at create (its lease's `activate` record) and at end | implemented: sandboxes and sessions on `id@buildId`; the `sandbox` record; a session seeded from its build, its patch returned with the turn, and the `session` record |
| 9 | Age out: leases run out; never an eviction | the control plane | leases (`leaseSeconds`, renewed by the client) | — (no eviction) | `deactivate` | implemented: leases age out |
| 10 | Deactivate, retire or remove | the owner, or an admin | `POST /v1/templates/{id}/deactivate`; `POST /v1/templates/{id}/retire` or `DELETE …/builds/{build}` (`mocactl sbx templates retire`), then the host agent removes the worker and snapshot; an admin rejects after the fact (`POST …/builds/{build}/reject`). The operator path stays `template-register.sh --retire/--remove`, `install-host.sh --uninstall` | — | `deactivate`, `retire`, `reject`; the host's removal as a `retire` by `host:<id>` | implemented: retire and the host's own removal |
| 10a | Change: move tags, edit description and visibility, transfer the owner, set quotas | the owner; an admin for the owner and quotas | `POST/DELETE …/tags`, `PATCH /v1/templates/{id}`, `PUT …/owner`, `PUT /v1/quota/{subject}` (`mocactl sbx templates tag/untag/edit/transfer/quota`); each a record naming who | — | `tag`, `visibility`, `owner`, `policy` | implemented |

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: Row 10a is marked implemented, and this commit now says the last column "is what is implemented". But PUT /v1/quota/{subject} and mocactl sbx templates … quota don't exist on main. The only quota route is GET /v1/quota (routes.ts:591). Quotas are policy.quota, set through PUT /v1/policy (as row 0 says). Suggest pointing the quota part there.

| 7 | Activate: attach the build's worker | the client (within its quota) | `POST /v1/templates/{id}/activate` (a lease, renewed); the host agent starts the installed worker; today `install-host.sh` by an operator | M14, M15, M16 | `activate` (the client's and the host's report) | implemented: by lease, and on first use; workers pre-installed by an operator |
| 8 | Use: sessions name the template | a client | `POST /v1/sessions {sandbox:{template}}`, `mocactl run --option sandboxTemplate=ID` (also `ID:tag` or `ID@build`, resolved by the template store); SBX0 `sbx create --template` | — | the session's template and build; a `sandbox` record, or for a Moca Pi session a `session` record, at create (its lease's `activate` record) and at end | implemented: sandboxes and sessions on `id@buildId`; the `sandbox` record; a session seeded from its build, its patch returned with the turn, and the `session` record |
| 9 | Age out: leases run out; never an eviction | the control plane | leases (`leaseSeconds`, renewed by the client) | — (no eviction) | `deactivate` | implemented: leases age out |
| 10 | Deactivate, retire or remove | the owner, or an admin | `POST /v1/templates/{id}/deactivate`; `POST /v1/templates/{id}/retire` or `DELETE …/builds/{build}` (`mocactl sbx templates retire`), then the host agent removes the worker and snapshot; an admin rejects after the fact (`POST …/builds/{build}/reject`). The operator path stays `template-register.sh --retire/--remove`, `install-host.sh --uninstall` | — | `deactivate`, `retire`, `reject`; the host's removal as a `retire` by `host:<id>` | implemented: retire and the host's own removal |

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: Same as GUIDE §7: POST …/builds/{build}/reject isn't a route on main, and nothing writes a reject record. The last column correctly limits "implemented" to retire and the host's removal, but the Tool and Records columns present reject as available. Suggest marking it (planned).

changes: an admin sets them in the stored policy (`PUT /v1/policy`), and each change is a `policy`
provenance record naming who made it ([`PROCESS.md`](PROCESS.md), step 0). A change that widens
the policy (a trusted gate record, a registry or repository, a profile added or loosened) needs an
admin named in the settings (`SBX_ADMIN_SUBJECTS`); an admin granted through the API may only narrow

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: The check is on SH_ADMIN_SUBJECTS (sandbox-handlers.ts:2376-2379, and the 403 text names it). SBX_ADMIN_SUBJECTS is only SBX0's setup.sh input that feeds it (setup.sh:759). PROCESS.md:33, a few lines away, says SH_ADMIN_SUBJECTS. Suggest "SH_ADMIN_SUBJECTS (SBX_ADMIN_SUBJECTS on SBX0)" on both pages, GUIDE §4b.5 included.

@pdettori
pdettori merged commit 2f992db into rossoctl:main Nov 15, 2026
17 checks passed
@pdettori pdettori added this to the v0.11.0 milestone Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document sandbox template onboarding and the template lifecycle

4 participants