Repository navigation
feat(control-plane,sbx,deploy): one control plane for sessions and sandboxes; sessions pinned to a template build - #789
Conversation
A Moca Pi session picks its hands by tier only. Sandbox-service clients can pick a template, a worker serving one snapshot, but a session cannot, so a session that needs one environment may land on a worker of any snapshot in its tier and starts in an empty workspace. The design follows P6.3's tier path: - workers advertise a second presence label, moca.dev/template, from SANDBOX_TEMPLATE; - a session names a template at creation, validated against SH_SANDBOX_TEMPLATES (the list the sandbox profile reads, with an optional seed); - the exchange carries the template and seed to the data plane, and the harness keeps the session on workers with that label. A session with no template runs only on untemplated workers. The harness seeds a templated workspace once, on its first use. Refs rossoctl#731 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
SANDBOX_TEMPLATE, set and non-blank, adds the Hello label moca.dev/template (session.TemplateLabels, merged with the tier by session.Labels) in both cmd/worker and cmd/microvm-worker. Unset or blank sends no label; there is no default, because a session with no template must never land on a templated worker. The relay passes the label through like any other, and removes it from a worker attached with a workload binding: workload sandboxes are not templated, and the binding does not sign a template. The harness exports the label's name as TEMPLATE_LABEL. Refs rossoctl#731 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
The harness profile now reads SH_SANDBOX_TEMPLATES too, the same JSON list the sandbox profile reads, with an optional seed per entry (worker is ignored here: selection is by label). - POST /v1/sessions takes sandbox.template. A non-string is 400 invalid_request; an id not declared is a 400 listing the declared ids; with none declared, any template is a 400. - SessionRecord.sandboxTemplate stores it, and the session views show it. GET /v1/discovery gains sandboxTemplates, without the seeds. - The exchange returns sandboxTemplate and sandboxSeed, both omitted for a session that named none, so a deployment without templates answers byte-identically. It fails closed: a template later dropped from the list is still sent, without a seed, so the turn finds no worker and is refused rather than run on an untemplated worker on an empty workspace. The control-plane API goes to 1.4.0, with its changelog entry. Refs rossoctl#731 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…emplate
TurnAuth carries the exchange's sandboxTemplate and sandboxSeed,
refusing a present template that is not a non-empty string and a
non-string seed. executeTurn passes them to acquireTurnSandbox.
- selectPoolSandbox, after the tier filter, keeps only records whose
moca.dev/template equals the session's, or for a session with none
only records without the label. SandboxPoolEmptyError names the
template and the fix (SANDBOX_TEMPLATE=<id>).
- An affine sandbox that now serves another template, or none, is
reset at once with the existing retiered reason, so the
workspace_reset frame is unchanged on the wire.
- The seed runs on the first turn that uses the workspace, in it:
under flock .moca-seed.lock, [ -e .moca-seeded ] || { <seed>
>.moca-seed.log 2>&1 && touch .moca-seeded; }. The marker lives in
the workspace, so a reset workspace is seeded again; the output goes
to the log, never into the turn; the lease is renewed while it runs.
A failure is SandboxSeedError (500, not retryable) naming the
template, the exit code and the log, and returns the lease.
Leaves and unauthenticated turns pass no template. The relay's
integration test runs templated and untemplated workers through a
real relay and Redis. The harness API document goes to 1.1.0.
Refs rossoctl#731
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
- --option sandboxTemplate=<id>, its choices from discovery's sandboxTemplates, with "none" first and preselected so a deployment declaring one template does not have it picked for every session. A value not among the choices is sent as given (id@build, id:tag), for a control plane that resolves such references; its refusals are shown as worded. - A create answered 409 template_not_active is retried after its Retry-After, for up to 10 minutes; mocactl run says it is waiting. - The sessions list shows a session's template beside its tier, and the workspace_reset notice says "another tier or template". - mocactl run refuses an empty --session rather than starting a new session, gives the server's reason when it waits on "no capacity", and stops waiting after 15 minutes. Refs rossoctl#731 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…rker setup-microvm.sh --template ID --snapshot DIR [--budget-mb N] [--egress] installs a second P4 worker beside the untemplated main one, serving the snapshot DIR as sandbox template ID: instance tpl_<id> of a template unit [email protected], in its own slice (a worker sweeps its parent cgroup at start, so two never share one), with its own relay token, env file, and workspace and jail roots on the snapshot's filesystem under a short key, so the VMs' API socket path fits. Its guest RAM is the manifest's; the budget defaults to one session's worth. A re-run changes nothing and keeps the token, budget and egress; another snapshot under the same id is refused (a new snapshot is a new template worker). --egress is refused while another worker on the host uses moca-egress, which keys VM listeners by an id every worker reuses. --uninstall-template ID removes exactly what --template wrote and keeps workspace data. P4-ON-P6.md documents the templated worker, and mock-anthropic.mjs gains TPL-SMOKE-LOOK, a scripted prompt that reports what a turn's workspace holds, for a check without model cost. Refs rossoctl#731 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
… reference - docs/concepts/sandboxes-and-tiers.md: a Templates section, covering what a template is, how a session picks one, the seed, the fail closed rule and affinity moves. - docs/reference/configuration.md: SH_SANDBOX_TEMPLATES on the control plane's harness profile, and the worker's SANDBOX_TEMPLATE. Refs rossoctl#731 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
On a template whose seed puts a repository at the workspace root, the seed's marker, log and lock (.moca-seeded, .moca-seed.log, .moca-seed.lock) showed as untracked files, so a patch taken with `git add -A` or `git status --porcelain`, or an agent that commits everything, picked them up. After a successful seed, when the workspace is a git repository, the three are added to its info/exclude (each once; best-effort, so a workspace without git seeds as before). SEED_LOCK is now a named constant beside SEED_MARKER and SEED_LOG. The seed log's comment and the design say what holds: it is never in the turn's output, but it is in the agent's own workspace, so a seed must not print a secret. Tests (real bash and git): a seeded repository's status shows only the seed's own file, and each exclude line appears once across a re-seed; a workspace without a repository seeds as before. Refs rossoctl#731 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…015) Two checks in the `--template` code used `a && b || die`, which shellcheck flags (SC2015: the die also runs if b's own command fails for another reason), and the setup test's "shellcheck clean" step fails on it: the derived unit's Slice= and SH_PARENT_CGROUP= lines, and the budget's lower bound. Both are now `if …; then die; fi`, with the same messages and the same refusals. The test's count of the main worker's kept files is a plain loop rather than `ls | wc -l` (SC2012). Tests: shellcheck 0.11.0 clean on both files; setup-microvm.test.sh PASS on bash 5 and 3.2. Refs rossoctl#731 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
… too "both env files are 0600" tried BSD `stat -f '%Lp'` first. On Linux GNU `stat -f` is filesystem status, so it succeeded with a listing, the `||` never ran, and the check failed on CI while passing on macOS. It now uses the file's own `mode()` helper, which tries GNU `stat -c %a` first. Tests: setup-microvm.test.sh PASS on macOS with bash 5 and 3.2; shellcheck clean. (The CI log showed the Linux failure; the helper is what the rest of the file already uses there.) Refs rossoctl#731 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
One conflict, docs/reference/configuration.md's control-plane table: main's rows kept (its LEAF_RESULT_TTL_SECONDS wording), with this PR's SH_SANDBOX_TEMPLATES row. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Conflicts and their resolutions, keeping both sides: - docs/api/CHANGELOG.md: both added a 1.4.0 entry. The activation line's 1.4.0-1.7.0 entries are kept as they are; the session templates entry follows them as 1.8.0. - docs/api/openapi.yaml: info.version 1.7.0 against 1.4.0; set to 1.8.0, the version that carries both sides' additions. - docs/api/harness-openapi.yaml: the 503 description keeps the session-templates wording (none of the session's tier or template) and the cause named in sandbox_unavailable's message. - docs/reference/configuration.md: both added an SH_SANDBOX_TEMPLATES row; one row now says either profile reads it, with the optional seed and the template store import on the sandbox profile. - packages/control-plane/src/handlers.ts: the union of the imports (SandboxTemplate, and the provenance, catalog and policy types). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…settings SH_ROUTE_PROFILE=combined serves sessions and sandboxes from one control plane (combined control plane spec §3.1-§3.5). harness and sandbox are unchanged; combined is opt-in. - Routes: mountsOn mounts a route on combined when its profiles name harness or sandbox; no route lists combined. The egress gate applies on combined only to the sandbox-only route, so the credential routes stay mounted for harness users. - /v1/discovery on combined answers the harness fields plus execEndpoint and execCa, with profile "combined". mocactl sbx login accepts a combined control plane. - Who may call what: login stays open as on harness; enrollment moves to the routes. isEnrolled stays the login gate, isEnrolledForSandbox (requireEnrolledPrincipal) gates every sandbox route and template write, and requireReader opens the template, policy and quota reads to any logged-in subject on harness and combined (enrolled-only on sandbox). A test user is refused on the sandbox routes. - Tokens: API tokens on combined use the harness issuer, so a sandbox stack sharing the key accepts none; the sandbox token is unchanged. - Settings: combinedProfileConfig requires both profiles' settings and refuses to start naming a missing one; the one template list backs sessions and sandboxes; template host bearers must differ from the exchange, janitor and egress tokens. depsFromEnv builds the sandbox store on combined too. Egress follows SH_EGRESS_HOSTS alone there. Tests: route-profile (the union, no route names combined), combined-enrollment (open login, enrolled-only sandbox routes and template writes, token separation), sandbox-config (the combined settings and their refusals), discovery, and mocactl's sbx login. Refs rossoctl#750 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…e, pinned to a build Combined control plane spec §3.4. With a template store (SH_PROVENANCE_DIR), POST /v1/sessions resolves sandbox.template as a sandbox create does (resolveForUse): `id`, `id:tag` or `id@sha256:...`, a registered build the caller may see, else 400 unknown_template. The build is recorded on the session as sandboxBuildId and kept for its life. Activation on first use applies (requireActive): on a deployment with host agents, a template that is not active answers 409 template_not_active with Retry-After and takes the caller's lease; `sandbox.activate: false` starts nothing. Without a store, the static SH_SANDBOX_TEMPLATES list, as before. The Session view adds sandboxBuildId and templateManifestHash (null for an imported build) beside sandboxTemplate. mocactl's CreateSessionRequest carries `sandbox.activate`; SessionManager.create already waits out a 409 template_not_active. openapi documents the body field, the view's fields and the 409s; activation.test covers a self-serve template backing a session, the refusal with and without activation, the pin by id@build and the malformed `activate`. Refs rossoctl#750 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Combined control plane spec §3.4, turns by build. - microvm-worker adds the presence label moca.dev/build, the manifest hash of the snapshot it verified at start (session.WithBuild), beside moca.dev/tier and moca.dev/template. - The credential exchange returns sandboxBuildId for a session whose template resolved to a manifest-hash build; never for an `imported:` build, which names no snapshot, so that response is unchanged. - The data plane carries it (turn-auth refuses a malformed one rather than drop it, buildConfig, run-turn's TurnConfig and acquireTurnSandbox) to selectPoolSandbox, which keeps only records labelled with that build and refuses the turn when none is attached: a pinned session never runs on another build. - A worker without the label still serves unpinned sessions and every sandbox (sandboxes route by worker id), so workers are upgraded first and nothing else depends on the order. openapi documents sandboxBuildId on POST /internal/credentials; harness-openapi (1.2.0) says a pinned session runs only on its build's workers. Tests: the selection filter (pinned, unpinned, none attached), the exchange body check, the exchange answer for a pinned session, and WithBuild. Refs rossoctl#750 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Combined control plane spec §3.3, §3.6. - deploy/k8s/overlays/ocp-combined: ocp-single's harness control plane and supervisor with SH_ROUTE_PROFILE=combined and SBX0's settings from sbx-settings, the template store, the relay with both Routes (attach and exec) and both Exec callers (the harness exec token and the sandbox keyset), and the janitor. One namespace, one Redis, one signing key, one API Route. The harness's credentials are files on their own volume (SH_CREDENTIAL_STORE=file), so the credentials Role and the service account token go: no Kubernetes API access, and no cluster-scoped object. - deploy/sbx/setup.sh SBX_PROFILE=combined (default sandbox, which is unchanged) renders it: the harness's keys added to moca-mu1 (public keyset, KEK, exchange token, each generated once and kept), the harness exec token kept in moca-relay and mirrored attach token, the template store on, the supervisor Route (SBX_MOCA_HOST, its TLS Secret, moca-ca.crt when self-signed), the in-cluster addresses for the run's namespace, and every image pinned by digest (SBX_SANDBOX_IMAGE, SBX_IMAGE). It writes to .generated-<namespace>, so an SBX0 namespace's generated files from the same checkout stay as they are. Egress credentials are refused with it for now (both would mount a KEK). Tests (no cluster): overlay-combined.test.sh renders the overlay; setup.test.sh covers the combined run, its re-run and its refusals. Refs rossoctl#750 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…othing else does Two lookups that ignored the login on this machine: - `mocactl credentials add` (and every other top-level command) right after `mocactl login --control-plane-url URL` still asked for SH_CONTROL_PLANE_URL or the flag: login writes the URL into auth.json but not config.json, and resolveEndpoints read only the flag, the environment and config.json. The login's own controlPlaneUrl is now the last fallback (http or https only); a URL named any other way still wins, and a login is still sent only to its own control plane. - `mocactl sbx` likewise falls back last to sbx-auth.json's controlPlaneUrl, after --control-plane-url, MOCACTL_SBX_URL and the URL `sbx login` remembered, so a login file present without config.json (copied from another machine, say) needs no MOCACTL_SBX_URL. Such a URL is not "explicit": SBX_TOKEN_CMD lines name no flag for it. Tests: resolveEndpoints' precedence and the scheme check, a runtime built after a login with no URL, and `sbx ls` on a login file alone. Refs rossoctl#750 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…eploy - docs/specs/2026-11-05-combined-control-plane-design.md: the design (a third route profile, who may call what, tokens, one template store for sessions and sandboxes, turns by build and the upgrade order, settings, the deployment), its decisions and limits; listed in docs/specs/README.md. - openapi 1.9.0 and its CHANGELOG entry: the combined profile, its discovery and enrollment rules, sessions through the template store with first use, the Session view's build fields, the exchange's sandboxBuildId; harness-openapi 1.2.0 for the build filter. - docs/reference/configuration.md: SH_ROUTE_PROFILE, the store path for a session's template, mocactl's login URL fallback. - deploy/sbx/README.md: SBX_PROFILE=combined, its inputs, logging in to it (NODE_EXTRA_CA_CERTS for a self-signed or untrusted Route certificate). Refs rossoctl#750 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
clawgenti
left a comment
There was a problem hiding this comment.
Summary
The PR body says this stacks on #775 and #759, so this review covers its own six commits (5f04a36..16ee7f0). Those add the combined route profile, session templates resolved through the store and pinned to a build, the moca.dev/build worker filter, the ocp-combined overlay with setup.sh SBX_PROFILE=combined, the mocactl login fallback, and the docs. The route union, the login/enrollment split, token separation and the build propagation (exchange → turn-auth → run-turn → selectPoolSandbox → worker label) look right. The ocp-combined overlay renders with kubectl kustomize: one API Route, no Role, automountServiceAccountToken: false, and limits on every container. setup.sh's combined path showed no defects. One authz gap: on combined, createSession lets a non-enrolled user activate a template (take a lease and start a worker), which the activate route itself refuses. Smaller gaps: affinity with the build filter, two isEnrolled call sites that went stale on combined, a test that does not reach the authz it claims, and doc wording.
Author: webchang (MEMBER — maintainer)
Areas reviewed: route profiles and mounting (routes.ts), enrollment (sandbox-config.ts, handler-util.ts, sandbox-handlers.ts), createSession template resolution and activation, build propagation (exchange, turn-auth, knative-server, harness run-turn/select-sandbox, Go session labels, microvm-worker), egress/credential handlers on combined, mocactl login fallbacks, ocp-combined overlay, setup.sh combined path, openapi/CHANGELOG/design doc, commits/DCO, CI, agent-config gate
Agent/IDE config (.claude/.vscode): none
Commits: 64 commits (6 of them this PR's own), all signed-off: yes
CI status: passing (all 17 checks green)
1 must-fix, 4 suggestions, 1 nit.
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
| let resolved: { id: string; buildId: string } | undefined; | ||
| if (requestedTemplate !== undefined && deps.templates && deps.provenance) { | ||
| const t = await resolveForUse(deps, p, requestedTemplate); | ||
| await requireActive(deps, p, t, activateField !== false); |
There was a problem hiding this comment.
must-fix: On combined, this lets an unenrolled user activate a template. createSession takes only requirePrincipal (combined login admits any GitHub account and test users). With activate absent or true, requireActive (sandbox-handlers.ts:959-979) calls takeLease(deps, p, …, 'first_use'), which writes a lease under p.sub and makes the host agent start the build's worker. The explicit POST /v1/templates/{id}/activate is requireEnrolled (sandbox-handlers.ts), and design §3.2 and CHANGELOG 1.9.0 call activate/deactivate enrolled-only. So POST /v1/sessions {"sandbox":{"template":"t"}} gets around that gate. It uses host slots and KVM capacity, limited only by quota.active per subject, and every new GitHub account is a new subject.\n\nSuggested fix: only take a lease here when isEnrolledForSandbox(p.sub, p.roles, deps.config) holds. Otherwise call requireActive(..., false), which answers 409 template_not_active and starts nothing, or refuse with not_enrolled. Add a combined-enrollment test that an outsider's createSession on an inactive template takes no lease.
| // The build filter: only with a template and a pinned build; a worker reporting no | ||
| // build label never serves a pinned session. | ||
| const build = template && opts.build ? opts.build : ''; | ||
| if (build) grpcRecs = grpcRecs.filter((r) => r.labels?.[BUILD_LABEL] === build); |
There was a problem hiding this comment.
suggestion: The build filter drops an affine worker that now serves another build of the same template, but the affinity "retiered" check (line 873: inOtherDeclaredTier(r) || !inScope(r) || !ofTemplate(r)) does not know about builds. So a pinned session whose affine worker was re-labelled takes the detached-grace path and waits out SandboxAffinityPendingError, which can never succeed, before it resets. Suggested fix: add || (build && r.labels?.[BUILD_LABEL] !== build) to that predicate, with a test.
| * (combined control plane spec §3.2: login stays open, enrollment moves to the routes). | ||
| */ | ||
| export function isEnrolled(subject: string, roles: string[], config: CpConfig): boolean { | ||
| if (config.routeProfile !== 'sandbox') return true; |
There was a problem hiding this comment.
suggestion: isEnrolled is now always true on combined, but egress-handlers.ts:62 (lookupEgressCredential) still uses it to gate the sandbox owner. So that check silently does nothing on combined. In the same way, putCredential/listCredentials/deleteCredential branch on routeProfile === 'sandbox', so the destination_conflict check for sandbox-egress credentials is skipped on combined, although design §3.1 says the egress kind is accepted "as on sandbox". Today setup.sh refuses egress on combined, but combinedProfileConfig and the route table allow it. Suggested fix: use isEnrolledForSandbox there and key the conflict check on consumer === 'sandbox-egress'. Or refuse SH_EGRESS_HOSTS in combinedProfileConfig until this is designed.
| () => HANDLERS.listTemplates!(ctx({ principal: tester }), d), | ||
| () => HANDLERS.getTemplate!(ctx({ principal: tester, params: { id: 'default' } }), d), | ||
| ]) { | ||
| expect(await outcome(r)).not.toBe('not_enrolled'); |
There was a problem hiding this comment.
suggestion: not.toBe('not_enrolled') passes for any other failure. As the comment notes, these deps have no template store, so the reads probably fail with invalid_request/unknown_template before any authz runs. The test does not show that an unenrolled subject can actually read. Suggested fix: use a deps fixture with a store (as activation.test.ts does) and assert 200 for listTemplates, getTemplate, getPolicy and getQuota as the outsider and the tester.
| template store (combined control plane spec §3.4), kept for the session's life; a | ||
| manifest-hash build's turns run only on workers labelled moca.dev/build with it. Null | ||
| without a template store | ||
| templateManifestHash: |
There was a problem hiding this comment.
suggestion: sessionView emits sandboxBuildId/templateManifestHash only when sessionTemplates || rec.sandboxTemplate. On combined, sessionTemplates is [] (truthy) when SH_SANDBOX_TEMPLATES is empty, so the fields always appear. On harness without a static list they are absent for an untemplated session. "Null without a template store" (sandboxBuildId) is therefore not what happens: the field is absent. Suggest stating when the fields are present, and saying "absent" rather than null.
| # token, from the base, AND per-sandbox tokens (SBX0 §3), from sbx-token-keys. The relay classifies | ||
| # each call, the harness's token first (sandbox-relay/src/main.ts execCaller). Its exec listener | ||
| # stays on all interfaces for the in-cluster exec Service the supervisor uses; the base's | ||
| # NetworkPolicy admits only the supervisor to it, and the exec Route reaches it through the |
There was a problem hiding this comment.
nit: On combined this listener takes two kinds of caller. The harness exec token (MOCA_RELAY_EXEC_TOKEN) is checked first in execCaller and allows Exec into any attached worker, including the SBX0 sandboxes of enrolled users, with no per-sandbox scope. That is by design, but a supervisor compromise now reaches stock-agent sandboxes in the same namespace. Worth saying here and in design §3.6/Limits, so operators know the isolation boundary changed from a separate SBX0 namespace.
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
clawgenti reviewed this head first (23:32Z) with the same must-fix (createSession activating templates for unenrolled subjects on combined, handlers.ts:964) and the same isEnrolled/egress suggestion (sandbox-config.ts:204). +1 to both; we concur that the first is blocking, which is why this review requests changes. I have not repeated them inline. Our inline comments cover only what theirs does not: pinned sessions losing their worker after the first-use lease (handlers.ts:984) and the unenforced namespace rule in setup.sh.
Summary
Adds a combined route profile that runs sessions and sandboxes in one control plane, resolves session templates through the template store (id, id:tag, id@build) with activation on first use and a recorded sandboxBuildId, filters workers by a new moca.dev/build label, and ships an ocp-combined overlay plus SBX_PROFILE=combined in setup.sh. The route mounting and the enrollment gate on sandbox routes and template writes look right, and it is no weaker than the sbx profile on the routes themselves. The build-label filter fails closed when the label is missing. This PR also adds the server side of 409 template_not_active and id:tag that mocactl already handled (#759 review). The blocker: createSession now takes activation leases for any logged-in subject, which gets round the enrolled-only activate gate. Pinned sessions also lose their worker once the first-use lease runs out (async turns and /runs still drop the template and build here; #790 closes that).
Author: webchang (MEMBER, maintainer)
Agent/IDE config (.claude/.vscode): none
Commits: own range all signed off: yes
CI status: CI 17/17 green; mergeable_state blocked (needs approval)
Review range: 5f04a36..16ee7f0 (stacked PR; earlier commits reviewed on their own PRs)
Notes outside the diff
- The async-turn and /runs gap from our #759 review (turn-claim.ts:110-124 and run-leaf.ts's selectPoolSandbox drop the template and build) is still open in this range. #790, which stacks on this PR, closes it. If #789 merges without #790, async turns of a pinned session can run on other workers.
- Done since #759: createSession now resolves
id,id:tagandid@buildthrough the store and answers409 template_not_activewith Retry-After, which matches what mocactl's SessionManager retry expected. - createSession takes the first-use lease (handlers.ts:964) before the configRef existence check and the session write. A request that then fails (unknown configRef) still holds a lease. Moving resolve and activation after the other validation would avoid leases nobody uses.
- Checked and fine:
mountsOn/matchRouteon combined mount exactly the union (route-profile.test.ts). Janitor, host and egress routes keep their static-bearer auth./metricsstays harness-only and admin-gated. Sandbox routes go throughassertSandboxOwner, so enrollment is checked on every request.resolveForUseappliescanSeeand needsstatus === 'registered', so nobody can pin another user's private template or a retired or draft build. The build filter compares for equality, so a worker with no label never serves a pinned session. The exchange returns onlysha256:builds, and turn-auth refuses a malformed one. - Worker label trust:
moca.dev/buildcomes from the worker's own Hello. The relay does not check it against the attach token, so a compromised worker can claim any build. This matches the existing trust inmoca.dev/template, so no new exposure, but worth stating in the spec. - mocactl fallback:
resolveEndpointsfalls back toauth.json'scontrolPlaneUrl, andloadAuthsends the token only to that same control plane (sameControlPlane). So the token cannot go to another host. The regex acceptshttp://, as the flag does.
| } | ||
| const sandboxTemplate = resolved?.id ?? requestedTemplate ?? ''; | ||
| // The build the reference resolved to, kept for the session's life; none without a store. | ||
| const sandboxBuildId = resolved?.buildId ?? ''; |
There was a problem hiding this comment.
suggestion: the session pins sandboxBuildId for its whole life, but nothing keeps that build's worker running. If the build is already active, requireActive takes no lease for this subject. Otherwise the first-use lease ages out (default idleLimitSeconds or 3600 s). After that hostWanted (host-handlers.ts:215-225) puts the worker in stop, because busy counts only live sandbox records, not sessions. Later turns then fail with SandboxPoolEmpty, and a subject who is not enrolled cannot re-activate. Either renew or take a lease on exchange for a pinned session, or count sessions with recent turns as busy. At minimum, document the failure mode and how to recover.
| # It turns the template store on, keeps the harness's exec token in moca-relay, | ||
| # and adds the harness's keys to moca-mu1 (SH_SESSION_TOKEN_PUBLIC_KEYS, | ||
| # SH_CREDENTIAL_KEK, SH_EXCHANGE_TOKEN). Egress credentials are refused with it | ||
| # (both would mount a KEK). Its namespace must be another than a sandbox one's |
There was a problem hiding this comment.
nit: "Its namespace must be another than a sandbox one's" is not enforced. SBX_PROFILE=combined pointed at an existing SBX0 namespace passes the foreign check in ensure_signing_key, because that Secret carries the sbx setup label. It then adds the KEK and exchange token to that namespace's moca-mu1 and switches its overlay. Refuse when moca-mu1 lacks SH_EXCHANGE_TOKEN but already holds SH_JANITOR_TOKEN, or when sbx-api exists, unless the operator passes an explicit override.
Signed-off-by: Rong Chang <[email protected]>
Upstream main's rossoctl#788 (a queued turn pinned to its submission's model and tier, via rossoctl#775 → rossoctl#789) meets this branch's templated queued turns. Conflicts, both kept: - turn-exchange.ts: the tier and the model are read from the turn record (rossoctl#788); the session's template, seed and build are still read from the session, which writes them once at creation. - turn-exchange.test.ts: both describe blocks. - openapi.yaml: rossoctl#788's record-pinned sandboxTier text, and this branch's sandboxTemplate, sandboxSeed, sandboxSeedSource and sandboxBuildId. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
|
Merged the stack's reviewed fixes into this branch, including upstream #788.
Assisted-By: Claude Code |
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Follow-up at 538d36f. Every item from our c507f85 review and from clawgenti's review is fixed and verified against the code:
- must-fix (handlers.ts:964):
createSessionpassesisEnrolledForSandboxtorequireActive, so only an enrolled subject takes a first-use lease. Another subject waits (409) on a build that isactivatingand gets403 not_enrolledotherwise. Activation is now the create's last check, so a create refused for another reason holds no lease. Tested. - pinned worker stops once the lease ages out (handlers.ts:984): each credential exchange (interactive and dequeue) holds the build's worker for the hosts' idle limit through
busyWorkers. As of 538d36f only an enrolled owner's turns hold it. The failure mode and recovery are documented in §3.4/§6. Tested both ways. - setup.sh:55:
check_combined_namespacerefuses an SBX0 namespace (janitor token without an exchange token, or thesbx-apiRoute) before applying anything, unlessSBX_CONVERT_TO_COMBINED=1. Case 17 covers it. - clawgenti's items: the affinity
!ofBuild(r)retier (tested), the egress lookup usingisEnrolledForSandbox,destination_conflictkeyed onsandbox-egresson combined, the combined read test asserting 200 with a store, the openapi present/absent wording, and the exec-token isolation note.
One nit inline. The author's #762 note also applies: whichever of #762 and this PR merges second must switch both enrollment sites to the members store.
Author: webchang (MEMBER — maintainer)
Agent/IDE config (.claude/.vscode): none
Commits: 9 new, all signed off
CI status: pending at 538d36f (check, lint, proto, deploy-scripts, k8s-kind-e2e); the rest pass.
AI-assisted review, approved by a maintainer before posting.
| // A caller that already holds a live lease on the build (a retry of its own first use, say) is | ||
| // only told to wait: no renewal and no new `activate` record on every retry. | ||
| const leased = liveLeases(t.build, facts.nowS).some((l) => l.subject === p.sub); | ||
| if (activate && !mayActivate && !leased && readiness !== 'activating') { |
There was a problem hiding this comment.
nit: a worker kept only by a session hold (no live lease) reads as deactivating in readinessOf (activation.ts:127). That happens after the first-use lease lapses while an enrolled subject's turns keep it up. So a new session by a subject who isn't enrolled gets 403 not_enrolled here even though the worker is attached and serving. The template list also shows it as deactivating while it stays up. This may be intended (only leases make a build active), but a sentence in §3.4 would help, or readinessOf could treat a held worker as active.
clawgenti
left a comment
There was a problem hiding this comment.
Re-review at 538d36f. Since our last review (c507f85) this PR adds 9 commits of its own, and each one answers a finding from our review or from @ingpaolodettori-dev's:
createSessionnow activates a template only for a subject enrolled for sandboxes, and only after every other check.- Pinned sessions hold their build's worker between turns, and only for enrolled subjects.
- The egress lookup and the destination check now hold on
combined. - The affinity reset now covers builds.
setup.shrefuses an SBX0 namespace.- The relay boundary and the build label's trust are written down.
- The read test now uses a store and asserts 200.
- The Session view docs now say "absent" where they used to say null.
I checked each one against the code, and the new tests cover them. No must-fixes remain. One suggestion is inline: when the relay's presence list can't be read, an unenrolled caller gets a terminal 403 for a transient outage.
The other 52 new commits are base commits that came in from #771 and #785 and are reviewed on those PRs. The async-turn//runs template gap is still closed only by #790, as noted last time.
- Author: webchang (MEMBER — maintainer)
- Areas reviewed: TypeScript (control-plane handlers.ts createSession, sandbox-handlers.ts requireActive, host-handlers.ts busyWorkers/holdPinnedWorker, exchange.ts/turn-exchange.ts, egress-handlers.ts; harness select-sandbox.ts), shell (deploy/sbx/setup.sh and its test), openapi, CHANGELOG and the design doc
- Agent/IDE config (.claude/.vscode): none
- Commits: 94 in the branch (9 new of this PR's own since the last review), all signed-off: yes
- CI status: passing (17/17)
Verified by:
- control-plane
vitest runon head, with a local Redis: 1423 pass, 3 skipped, 0 fail. The Lua-backed stores were exercised this time. - harness
vitest run: 393 pass, 1 skipped. - A throwaway probe in activation.test.ts on
combined: withpresence.listthrowing, an outsider's create gave{"code":"not_enrolled","readiness":"unknown"}. The probe is deleted.
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
| // A caller that already holds a live lease on the build (a retry of its own first use, say) is | ||
| // only told to wait: no renewal and no new `activate` record on every retry. | ||
| const leased = liveLeases(t.build, facts.nowS).some((l) => l.subject === p.sub); | ||
| if (activate && !mayActivate && !leased && readiness !== 'activating') { |
There was a problem hiding this comment.
suggestion: this check also fires when readiness is unknown, which happens when presence.list() throws (readinessFacts, L289). In that case an unenrolled caller gets a terminal 403 not_enrolled ("an enrolled user must activate it first") for what is a transient relay outage, maybe on a build that is in fact active. An enrolled caller in the same state gets the retryable 409 template_not_active. Probe on combined with presence.list throwing: the outsider got {"code":"not_enrolled","readiness":"unknown"}. The same happens for unavailable, where another subject's lease is waiting for a slot.
Suggested fix: refuse with not_enrolled only when readiness is inactive or deactivating. Let unknown, unavailable and activating fall through to the 409 with Retry-After. Add an unknown case to the combined outsider test.
Brings rossoctl#766's quota changes (the templates quota for a template holding no slot, and the owned quota) through pr/i19-activation. Conflicts: none. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
pr/i19-activation now carries upstream/main (sbx templates create, build, follow, cancel, quota and policy). Conflicts and resolutions: - packages/mocactl/src/sbx/cli.ts (the usage's closing lines): this branch's sentence on where the control plane comes from (the login's own, a login minted by an operator) is kept, with upstream's exit line (5 a wait timed out, 130 interrupted). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
|
Merged main (d4babb8). CI is the full check: local tests ran on the existing node_modules during the hono pin's release-age window. Assisted-By: Claude Code |
Brings in upstream main (lease modes, API 1.6.0) through pr/i19-activation. Conflicts: - deploy/sbx/README.md: main's settings table (SBX_REDIS_IMAGE) with this branch's SBX_PROFILE row, then main's lease mode settings. - deploy/sbx/setup.sh: ensure_settings declares main's relay and this branch's moca_crt; the image overrides keep this branch's container sandbox image and main's SBX_REDIS_IMAGE. - deploy/sbx/tests/setup.test.sh: this branch's cases 16 and 17 (the combined profile), then main's SBX_REDIS_IMAGE case, numbered 18. - docs/api/CHANGELOG.md: this branch's sections, renumbered 1.10.0 (sessions and sandboxes from one combined control plane) and 1.9.0 (sandbox templates for agent sessions), above pr/i19-activation's 1.8.0, pr/i18-host-agent's 1.7.0 and main's 1.6.0. - docs/api/openapi.yaml: info.version 1.10.0. - docs/specs/README.md: main's table, with this branch's combined control plane row added. API version: this branch's two sections move from 1.8.0 and 1.9.0 to 1.9.0 and 1.10.0. The data plane's harness-openapi.yaml keeps its own numbering. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Brings in upstream main through f60db30 (turn grants, API 1.7.0) by pr/i19-activation. Conflicts: - docs/api/CHANGELOG.md: this branch's sections, renumbered 1.11.0 (the combined control plane) and 1.10.0 (sandbox templates for agent sessions), above pr/i19-activation's 1.9.0, pr/i18-host-agent's 1.8.0 and main's 1.7.0 and 1.6.0. - docs/api/openapi.yaml: info.version 1.11.0. - docs/reference/configuration.md: main's table (the grant settings), with this branch's SH_ROUTE_PROFILE row and its SH_SANDBOX_TEMPLATES note (either profile). API version: this branch's two sections move from 1.9.0 and 1.10.0 to 1.10.0 and 1.11.0. The data plane's harness-openapi.yaml keeps its own numbering. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Refs rossoctl#731, rossoctl#750 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…ession at once The affinity check that resets at once when the affine worker is re-tiered or re-templated did not know about builds: a session pinned to a build whose affine worker now serves another build of the same template waited out the affinity grace, which could never succeed, before it reset. That worker is now the same "retiered" case, with no grace. select-sandbox-templates.test.ts: the pinned session moves at once, with no grace read (fails with the fix reverted). (cherry picked from commit b91a756) Ports rossoctl#789 review fixes Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…nly, and its last check On the combined profile any login may create a session, but createSession took a first-use activation lease for any caller, which got round the enrolled-only activate route. Now only a subject enrolled for sandboxes (the fork's per-request membership: roles and the store's enrolled flag) takes one: another subject waits (409 template_not_active) on a build another lease is starting, and is refused (403 not_enrolled) on one nobody is starting; activate: false answers 409 as for anyone. The activation also moves after the configRef, credential and model checks, so a create refused for another reason holds no lease. activation.test.ts: an outsider's session create on combined takes no lease, waits on an enrolled user's activation and creates once active; a create refused for an unknown configRef takes no lease. Both fail with the fix reverted. Combined spec §3.2/§3.4, the API changelog and openapi (a 403 on POST /v1/sessions) say so. (cherry picked from commit 8ef8627) Ports rossoctl#789 review fixes Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…k hold on combined The egress credential lookup gated the sandbox owner with the login gate, which is open on the combined profile, so that check did nothing there; it now uses the sandbox route gate (with the fork's per-request membership). The destination_conflict check for sandbox-egress credentials ran only on the sandbox profile; it now keys on the credential's consumer on both profiles that serve sandboxes. Tests for both on combined (fail with the fix reverted); combined spec §3.1 and the API changelog say so. (cherry picked from commit 85f85fb) Ports rossoctl#789 review fixes Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…nrolled, with a store The test of the reads on the combined profile asserted only "not not_enrolled", which any other failure passes; its deps had no template store, so the reads failed before any authorization ran. It now builds a store and asserts 200 from listTemplates, getTemplate, getPolicy and getQuota for a subject not enrolled, a test user and an enrolled one. Test only. (cherry picked from commit b52c87e) Ports rossoctl#789 review fixes Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…ild label's trust On combined the relay's one exec listener takes the harness's exec token, which is not scoped to a sandbox, beside the per-sandbox tokens; so a compromised supervisor reaches the sandboxes of enrolled users too, which a separate SBX0 namespace kept out of its reach. The overlay's relay patch and design §3.6 now say so (the fork's design has no Limits section, so that hunk is not ported). Design §3.4 also states that moca.dev/build is the worker's own claim, with the same trust as moca.dev/template. Comments and docs only; overlay-combined.test.sh passes. (cherry picked from commit fc90275) Ports rossoctl#789 review fixes Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…ess told to convert it "Its namespace must be another than a sandbox one's" was not enforced: a combined run pointed at an SBX0 namespace passed the foreign-key check (that moca-mu1 carries setup.sh's own label), then added the harness's keys to it and switched its overlay. The run now refuses, before anything is applied, a namespace whose moca-mu1 holds SH_JANITOR_TOKEN but no SH_EXCHANGE_TOKEN, or that has the sbx-api Route, unless SBX_CONVERT_TO_COMBINED=1. Only key names are read. setup.test.sh (bash and /bin/bash): both refusals change nothing, a failing Route read stops the run, a bad override value is refused, and the override converts. README says so (its table re-wrapped by prettier). Deploy-side. (cherry picked from commit 9a4be4c) Ports rossoctl#789 review fixes Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…running A session pins its build for life, but nothing kept that build's worker: an active build takes no lease for a later session, and the first-use lease runs out after the hosts' idle limit. The host agent was then told to stop the worker, since only live sandbox records counted as busy, and later turns found no worker. Each credential exchange of a session pinned to a host-managed build now holds that build's worker for the default lease length from the turn, and busyWorkers counts held workers as it counts live sandboxes: not stopped, slot kept. A hold never starts a worker and is not a lease. Only the turns of a subject enrolled for sandboxes hold (read with the fork's per-request membership), so a subject not enrolled cannot keep an active build's worker running after every lease on it has gone. The fork's queued-turn exchange carries no template, so that upstream hunk is not ported. Combined spec §3.4, the API changelog and the wanted route's description say so, with the failure mode and its recovery. activation.test.ts: turns keep the worker past the first-use lease and renew the hold, and with no turn for the hold it stops (fails with the fix reverted); a subject not enrolled holds nothing (fails with the enrollment check removed). (cherry picked from commit 56a1701) (cherry picked from commit 538d36f) Ports rossoctl#789 review fixes Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Brings in upstream main through c812554 (API 1.14.0: template tags, edits and owner transfer, subject trust for gate records, the host agents, activation, memory placement, cold-start pacing and the egress records; lease mode in setup.sh). Conflicts: - deploy/sbx/README.md: main's optional inputs (with SBX_REDIS_IMAGE) and main's lease mode settings, plus this branch's SBX_PROFILE row. - docs/api/CHANGELOG.md: this branch's sections, renumbered 1.16.0 (the combined control plane) and 1.15.0 (sandbox templates for sessions), above main's 1.14.0 and below. - docs/api/openapi.yaml: info.version 1.16.0; the wanted state's description is main's, with this branch's note on a worker a pinned session's turn holds. - docs/reference/change-policy.md: control plane 1.16.0, harness 1.2.0; main's list, then sandbox templates for sessions and the combined control plane. - packages/control-plane/src/host-handlers.ts: main's imports with this branch's isEnrolledForSandbox. - packages/control-plane/src/main.ts: the sandbox and egress stores on every profile that serves sandboxes (`sandbox` and `combined`). - packages/control-plane/src/sandbox-handlers.ts: readinessFacts returns main's queue, hosts and trusted set, with no sandbox use only on `harness`. - packages/mocactl/src/sbx/cli.ts: main's SandboxModeName import with this branch's storedLoginUrl. Fitted to main: - sandbox-handlers.ts: an owner transfer's new owner must be enrolled for the template writes (isEnrolledForSandbox), which on `combined` is the allow list, as on `sandbox`; isEnrolled admits any subject there, the login's rule. - packages/mocactl/test/run-record.test.ts: `mocactl run --record` now records two discovery reads before the session's create (the sandbox tier's, then this branch's sandbox template's), so the later records' places and seq move by one. API version: the combined control plane moves from 1.11.0 to 1.16.0 and sandbox templates for sessions from 1.10.0 to 1.15.0 (openapi info.version, the changelog and change-policy); the harness document stays 1.2.0. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
|
Main (c812554) merged in. Besides resolving the conflicts, the merge makes two changes that this PR's own diff doesn't show:
Also, The openapi versions move to 1.15.0 (session templates) and 1.16.0 (the combined plane), with harness-openapi 1.2.0. Assisted-By: Claude Code |
Brings rossoctl#789 (sandbox templates for sessions, the combined control plane; API 1.15.0 and 1.16.0) and rossoctl#790 (a session's seed, patch and records; 1.17.0). This branch's retire section moves to 1.18.0. Conflicts: - docs/api/CHANGELOG.md: ## 1.18.0 retire, above main's ## 1.17.0 to 1.15.0 and below, which are unchanged. - docs/api/openapi.yaml: info.version 1.18.0. The wanted-state description is main's (with a pinned session's hold), plus the retired builds in stop and the imported-build rule. - docs/reference/change-policy.md: main's list, then "template retire"; control plane 1.18.0, harness 1.3.0 (main's). - packages/control-plane/src/sandbox-handlers.ts readinessFacts: this branch's fields (holders, shared) on the no-sandbox return, under main's condition (no sandbox use on the harness profile only). - packages/control-plane/test/activation.test.ts: registered() takes this branch's options (another, vcpus, sourceDigest, status) plus main's spec, as opts.spec; main's one caller passes { spec }. Also moved to 1.18.0: http-api.md's Retire row and "Retire came with API" line. A worker kept by a pinned session's hold counts as busy, as a live sandbox does, so a retired build's worker drains until the hold ends before it is stopped. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Brings pr/i26-retire at upstream main d227d41 (through rossoctl#790, with rossoctl#789's combined plane and pinned-session holds, rossoctl#791/rossoctl#792 egress, rossoctl#784 pacing, rossoctl#776 memory placement and rossoctl#808), and i26's retire at API 1.18.0. This branch's quotas and reject section moves to 1.19.0. Conflicts: - docs/api/CHANGELOG.md: ## 1.19.0 quotas and reject above i26's ## 1.18.0 and main's sections, which are unchanged. - docs/api/openapi.yaml: info.version 1.19.0. The wanted-state description is main's (memory, idle grace, pinned-session hold, start order) with this branch's admin-rejected builds in `stop`. - docs/reference/change-policy.md: main's list, then "template retire", then "admin quotas and build reject"; control plane 1.19.0, harness 1.3.0. - docs/reference/http-api.md: main's rows (egress records, Retire at 1.18.0), then the Admin row at 1.19.0. - docs/specs/2026-11-03-template-lifecycle-and-provenance-design.md: the status line names both main's §6.2/§6.5 parts and this branch's quotas and reject. - packages/control-plane/src/activation.ts: main's buildOfWorker and running-worker maps, with endedWithWorker (retired or admin-rejected) where main tests for a retired build with a worker. - packages/control-plane/src/host-handlers.ts: main's file (wantedAnswer, egress, start limit, grace), with this branch's rejectedByAdmin in the wanted state's ended branch, liveSnapshots skipping rejected builds, and `detached` taken for an admin-rejected build. - packages/control-plane/src/sandbox-handlers.ts: activationLock is main's import from activation-lock.ts (its local copy dropped, so no duplicate); this branch's templateUseLock stays. Imports carry both rejectedByAdmin and main's readinessReasonOf, startQueue, startRetryAfterS; identity.js is imported once. - packages/control-plane/test/activation.test.ts: both new placement cases. - packages/control-plane/test/openapi-contract.test.ts: 31 enrollable routes (28 + this branch's 2 + main's 1). - packages/mocactl/src/sbx/api.ts, commands.ts, cli.ts: both sides' types, imports, usage, flags and dispatch (quota and --stop-now). - packages/mocactl/test/contract.test.ts: 28 replies (25 + 1 + 2), with main's reply shape. Also: activation-lock.ts's comment says, as this branch's code does, that a reject takes the activation lock and a sandbox create takes only its template's use lock; http-api.md's "admin routes came with API 1.19.0"; the reject test reads main's wanted answer (starting, egressSids). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Brings pr/i26-retire at upstream main d227d41 (through rossoctl#790, with rossoctl#789's combined plane and pinned-session holds, rossoctl#791/rossoctl#792 egress, rossoctl#784 pacing, rossoctl#776 memory placement and rossoctl#808), and i26's retire at API 1.18.0. This branch's removal section moves to 1.19.0. Conflicts: - docs/api/CHANGELOG.md: ## 1.19.0 removal above i26's ## 1.18.0 and main's sections, which are unchanged. The `remove` bullet names a pinned session's hold beside a live sandbox. - docs/api/openapi.yaml: info.version 1.19.0. The wanted-state description is main's (memory, idle grace, pinned-session hold, start order), with "in no list", `remove` (since 1.19.0; not under a live sandbox or a session's hold) and the shared-build rule; the response keeps main's `starting`, `graced` and `egressSids` and adds `remove`. - docs/reference/change-policy.md: main's list, then "template retire", then "retired build removal"; control plane 1.19.0, harness 1.3.0. - packages/control-plane/src/host-handlers.ts: main moved the wanted state into wantedAnswer; `remove` is built there, in the retired branch, under main's busyWorkers (a live sandbox or a pinned session's hold), and returned beside main's run, stop, starting and graced; hostWanted adds egressSids as main does. hostWorkerReport takes `removed` on main's version of it (st.running and refused kept); the host's holds drop the build on st. The header, liveSnapshots and T.unique texts are this branch's. - packages/control-plane/test/activation.test.ts: the wanted answers carry both `remove` and main's `starting`/`egressSids`. - packages/mocactl/src/sbx/cli.ts: main's usage (sbx hosts, create --mode/--idle-timeout) with this branch's retire --wait text. - deploy/sbx/host-agent.sh: main's header and run loop (run.tsv, start limit, grace), then this branch's removal() before the lock is let go; REMOVED beside main's counters; summary keeps "removed" before "errors" and main's egress, memory, start and grace fields after it. - deploy/sbx/tests/host-agent.test.sh: both mocks (install-host, journalctl) and both settings; main's sections 13-26, then this branch's removal section as 27, on a clean srv with well-formed snapshots (snapfiles), so main's memory report raises no error. - deploy/sbx/RUNBOOK.md: main's summary text with "removed". - docs/specs/2026-11-03-template-lifecycle-and-provenance-design.md: main's records table with this branch's `event: removed`; step 7 names a pinned session's hold. Also moved to 1.19.0: http-api.md's "Since API 1.19.0" and host-agent.sh's "older than API 1.19.0" comment. activation.test.ts's live-sandbox removal case reads the answer with toMatchObject: the wanted state now also carries egressSids, which list the sandbox. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…te lifecycle stack Upstream main 0dc3d01 (API 1.21.0) carries the reviewed, final form of the features this branch held in early, integrated versions, through the PRs filed from this fork (rossoctl#755-rossoctl#776, rossoctl#781, rossoctl#782, rossoctl#784-rossoctl#786, rossoctl#789-rossoctl#794, rossoctl#798-rossoctl#800) and the maintainer's lease mode, grants and lease clients (rossoctl#763, rossoctl#802, rossoctl#807, rossoctl#808, rossoctl#810, rossoctl#812, rossoctl#814). Where upstream has a feature, upstream's version wins: its code, tests, openapi, CHANGELOG (byte identical), docs and specs. The fork was 736 commits behind and 390 ahead (merge base dd0ce71). Conflict resolution (148 files, 82 both-modified, 66 both-added): every conflicted file is upstream's side as is (byte identical to 0dc3d01). No conflicted file differs from 0dc3d01 in this commit. One file merged without a conflict and was set back to upstream's: - packages/mocactl/src/sbx/push.ts: the auto-merge added the fork's baselineAtHead a second time beside upstream's own (fb28e06's function, already upstream); upstream's file as is. With that, this commit's tree is 0dc3d01's plus the 18 files only the fork has (below). Every other file the fork changed is upstream's. Conflicted files, all resolved to upstream's side (0dc3d01): - deploy/k8s/overlays/ocp-combined/kustomization.yaml (AA) - deploy/k8s/overlays/ocp-combined/patch-addressing.yaml (AA) - deploy/k8s/overlays/ocp-combined/patch-relay.yaml (AA) - deploy/microvm/P4-ON-P6.md (UU) - deploy/microvm/build-rootfs.sh (UU) - deploy/microvm/build-snapshot.sh (UU) - deploy/microvm/setup-microvm.sh (UU) - deploy/microvm/tests/build-rootfs.test.sh (UU) - deploy/microvm/tests/build-snapshot.test.sh (UU) - deploy/microvm/tests/setup-microvm.test.sh (UU) - deploy/sbx/README.md (UU) - deploy/sbx/RUNBOOK.md (UU) - deploy/sbx/host-agent.sh (AA) - deploy/sbx/install-host.sh (UU) - deploy/sbx/sbx-host-agent-wanted.service (AA) - deploy/sbx/sbx-host-agent-wanted.timer (AA) - deploy/sbx/sbx-host-agent.service (AA) - deploy/sbx/[email protected] (UU) - deploy/sbx/setup.sh (UU) - deploy/sbx/template-onboarding/GUIDE.md (AA) - deploy/sbx/template-onboarding/ONBOARDING.md (AA) - deploy/sbx/template-onboarding/README.md (AA) - deploy/sbx/template-onboarding/examples/django__django-11133.gate-record.json (AA) - deploy/sbx/template-onboarding/examples/django__django-11133.json (AA) - deploy/sbx/template-onboarding/governance/GATING-RULES.md (AA) - deploy/sbx/template-onboarding/governance/PROCESS.md (AA) - deploy/sbx/template-onboarding/governance/README.md (AA) - deploy/sbx/template-onboarding/template-build.sh (AA) - deploy/sbx/template-onboarding/template-register.sh (AA) - deploy/sbx/template-onboarding/tests/examples.test.sh (AA) - deploy/sbx/template-onboarding/tests/template-build.test.sh (AA) - deploy/sbx/template-onboarding/tests/template-register.test.sh (AA) - deploy/sbx/template-onboarding/verify-provenance.py (AA) - deploy/sbx/templates-check.sh (AA) - deploy/sbx/tests/host-agent.test.sh (AA) - deploy/sbx/tests/install-host.test.sh (UU) - deploy/sbx/tests/overlay-combined.test.sh (AA) - deploy/sbx/tests/setup.test.sh (UU) - deploy/sbx/tests/templates-check.test.sh (AA) - deploy/vm/tests/setup-vm.test.sh (UU) - docs/api/CHANGELOG.md (UU) - docs/api/harness-openapi.yaml (UU) - docs/api/openapi.yaml (UU) - docs/concepts/sandboxes-and-tiers.md (UU) - docs/reference/change-policy.md (UU) - docs/reference/cli-mocactl.md (UU) - docs/reference/configuration.md (UU) - docs/reference/http-api.md (UU) - docs/sbx/user-guide.md (UU) - docs/specs/2026-10-15-sbx0-internal-sandbox-service-design.md (UU) - docs/specs/2026-10-30-session-sandbox-templates-design.md (AA) - docs/specs/2026-11-03-template-lifecycle-and-provenance-design.md (AA) - docs/specs/2026-11-05-combined-control-plane-design.md (AA) - docs/specs/2026-11-08-enrollment-and-roles-api-design.md (AA) - docs/specs/2026-11-08-sandbox-egress-records-design.md (AA) - docs/specs/2026-11-08-subject-trust-gate-records-design.md (AA) - docs/specs/README.md (UU) - harness/src/run-turn.ts (UU) - harness/src/sandbox-affinity.ts (UU) - harness/src/select-sandbox.ts (UU) - harness/test/select-sandbox-templates.test.ts (AA) - harness/test/turn-seed.test.ts (AA) - harness/test/turn-stream.test.ts (UU) - packages/control-plane/src/activation-lock.ts (AA) - packages/control-plane/src/activation.ts (AA) - packages/control-plane/src/egress-handlers.ts (UU) - packages/control-plane/src/egress-log.ts (AA) - packages/control-plane/src/errors.ts (UU) - packages/control-plane/src/exchange.ts (UU) - packages/control-plane/src/handler-util.ts (UU) - packages/control-plane/src/handlers.ts (UU) - packages/control-plane/src/host-handlers.ts (AA) - packages/control-plane/src/identity.ts (UU) - packages/control-plane/src/index.ts (UU) - packages/control-plane/src/main.ts (UU) - packages/control-plane/src/member-handlers.ts (AA) - packages/control-plane/src/members.ts (AA) - packages/control-plane/src/ownership.ts (UU) - packages/control-plane/src/provenance.ts (AA) - packages/control-plane/src/routes.ts (UU) - packages/control-plane/src/sandbox-config.ts (UU) - packages/control-plane/src/sandbox-handlers.ts (UU) - packages/control-plane/src/server.ts (UU) - packages/control-plane/src/template-catalog.ts (AA) - packages/control-plane/src/template-policy.ts (AA) - packages/control-plane/src/token.ts (UU) - packages/control-plane/test/activation.test.ts (AA) - packages/control-plane/test/egress-redis.test.ts (AA) - packages/control-plane/test/errors.test.ts (UU) - packages/control-plane/test/host-flow.test.ts (AA) - packages/control-plane/test/members.test.ts (AA) - packages/control-plane/test/openapi-contract.test.ts (UU) - packages/control-plane/test/provenance.test.ts (AA) - packages/control-plane/test/repository-allowlist.test.ts (AA) - packages/control-plane/test/route-authz-enumeration.test.ts (UU) - packages/control-plane/test/route-profile.test.ts (UU) - packages/control-plane/test/routes.test.ts (UU) - packages/control-plane/test/sandbox-egress.test.ts (AA) - packages/control-plane/test/sandbox-handlers.test.ts (UU) - packages/control-plane/test/session-templates.test.ts (AA) - packages/control-plane/test/subject-trust.test.ts (AA) - packages/control-plane/test/template-admin.test.ts (AA) - packages/control-plane/test/template-catalog.test.ts (AA) - packages/control-plane/test/template-create.test.ts (AA) - packages/knative-server/src/server.ts (UU) - packages/knative-server/src/turn-auth.ts (UU) - packages/knative-server/test/turn-auth.test.ts (UU) - packages/mocactl/src/api/errors.ts (UU) - packages/mocactl/src/api/frames.ts (UU) - packages/mocactl/src/cli.ts (UU) - packages/mocactl/src/core/session-manager.ts (UU) - packages/mocactl/src/core/session-options.ts (UU) - packages/mocactl/src/headless.ts (UU) - packages/mocactl/src/sbx/api.ts (UU) - packages/mocactl/src/sbx/call-record.ts (AA) - packages/mocactl/src/sbx/cli.ts (UU) - packages/mocactl/src/sbx/commands.ts (UU) - packages/mocactl/src/sbx/dry-run.ts (AA) - packages/mocactl/src/sbx/exec.ts (UU) - packages/mocactl/src/sbx/run.ts (UU) - packages/mocactl/src/sbx/templates.ts (AA) - packages/mocactl/test/contract.test.ts (UU) - packages/mocactl/test/harness.test.ts (UU) - packages/mocactl/test/headless.test.ts (UU) - packages/mocactl/test/helpers/sbx.ts (UU) - packages/mocactl/test/run-record.test.ts (AA) - packages/mocactl/test/sbx-admin-subjects.test.ts (AA) - packages/mocactl/test/sbx-cli.test.ts (UU) - packages/mocactl/test/sbx-egress.test.ts (AA) - packages/mocactl/test/sbx-exec.test.ts (UU) - packages/mocactl/test/sbx-templates.test.ts (AA) - packages/mocactl/test/session-manager.test.ts (UU) - packages/mocactl/test/session-options.test.ts (UU) - remote-worker/cmd/microvm-worker/main.go (UU) - remote-worker/cmd/microvm-worker/template_record.go (AA) - remote-worker/cmd/microvm-worker/template_record_test.go (AA) - remote-worker/cmd/microvm-worker/verify_cache.go (AA) - remote-worker/cmd/microvm-worker/verify_cache_test.go (AA) - remote-worker/internal/egress/audit_test.go (UU) - remote-worker/internal/session/labels.go (UU) - remote-worker/internal/vmpool/errors.go (UU) - remote-worker/internal/vmpool/guestconn.go (UU) - remote-worker/internal/vmpool/guestconn_test.go (UU) - remote-worker/internal/vmpool/launcher_firecracker.go (UU) - remote-worker/internal/vmpool/launcher_firecracker_egress_unix_test.go (UU) - remote-worker/internal/vmpool/snapshot.go (UU) - remote-worker/internal/vmpool/snapshot_test.go (UU) - remote-worker/internal/vmpool/verifycache.go (AA) Fork-only files, kept as they are (upstream has no such file): - deploy/sbx/mint-login.sh, deploy/sbx/tests/mint-login.test.sh: a test login minted with the deployment's signing key. Checked against upstream: makeSigner/mint, SANDBOX_API_ISSUER, the moca-mu1 Secret and its label, the env keys it reads and mocactl's sbx-auth.json shape are all still upstream's. - deploy/sbx/template-onboarding/deck/ (README, requirements, the two generators, deck_kit.py, the two PDFs, .gitignore): the fork's decks. - deploy/sbx/template-onboarding/GUIDE.pdf: regenerated from upstream's GUIDE.md in a later commit. - deploy/sbx/template-onboarding/governance/GAPS-AND-ASSUMPTIONS.md and INVENTORY-2026-11-02.md: the fork's register and inventory. - docs/specs/2026-11-09-cold-start-pacing-design.md, 2026-11-09-memory-aware-placement-design.md and 2026-11-10-mocactl-template-commands-design.md: the fork's design notes; upstream folded their content into its lifecycle spec (§6.4 memory, §6.5 pacing) and the user guide (mocactl). - docs/tools/gen_pdf.py, docs/tools/gen_toc.py: the PDF and TOC tools. Fork-only behaviour, decided one by one (from git log 0dc3d01..f125c02 --no-merges, checked against 0dc3d01): Ported onto upstream's code, each in its own commit after this one: - The pinned-session retire guard (c571226): a retire is refused (409 build_in_use) while an active Moca Pi session is pinned to the build. Upstream's buildsInUse checks live sandboxes only and its comment says pinned sessions are still to be checked. - Reuse only while a host holds the snapshot (G29, 521efe5): upstream reuses any registered build with the same inputs; its own lifecycle spec (§4, Reuse) says a registered build is reused only while a host reports holding its snapshot. - install-host.sh --uninstall-shared and the mounted legacy jail guard (5e66397): upstream has neither. - GUIDE §4b.4's base example without skip_git_identity_check (f125c02): upstream applies X12 under every profile, so its example create would be refused. - Links from upstream's READMEs to the fork-only files above. Dropped, because upstream's design replaces them on purpose: - Removal of admin-rejected builds: upstream stops them and never removes them (the user's decision in rossoctl#786). - The harness-profile catalog's fallback to SH_SESSION_TEMPLATES (902255b): upstream serves the harness profile the store's templates only (its test was renamed so); a combined plane is unaffected. - The fork's register ids (G-numbers), window dates and results pointers inside the documents upstream now has (RUNBOOK, README, GUIDE, ONBOARDING, PROCESS, GATING-RULES, P4-ON-P6, the specs): upstream's text wins; the fork's own documents above keep them. - The fork's image-builder-specific wording in GATING-RULES.md: upstream's generic wording (the image builder) is taken as is. Dropped, could be re-proposed (no upstream equivalent, but the port is an API change or its intent upstream is unclear): - TurnPlacement.template, a turn result naming the session's sandbox template (9d6004d): a harness API field; upstream's CHANGELOG is kept byte identical. - An imported build's catalog entry and create record carrying the declared seed (20d0995): sessions are seeded the same (upstream falls back to the declared seed); only the field in the catalog API goes. - mocactl: sbx create --seed checking the seeded HEAD against the spec's baseline_commit; activate --wait stopping at once on not_held or memfile_mismatch; ApiError's readiness, readinessReason and queuePosition in refusals; an admin write refused when the control plane URL came only from the login; the admin-write issuer check for the combined profile; the dry run's X1.offline check and its guest_mb and git-less advice; the quota, policy and build lines' extra fields (quotaSource, selfAttest, allowedRepositories, heldBy, attestation). Upstream's reviewed client (rossoctl#767, rossoctl#768) left them out; the server still enforces every rule. Already upstream (not lost): build reuse (G21), the verify cache, the host agent's --keep-shared removals, read-ahead, the hash_version 2 check in the microVM worker, M7, G39, G42, G43, G48, G49, G50, mocactl --record, --version, the minted login's own control plane, activate --wait sizing, and every other fork feature listed in the task. The relay's per-client tokens: not on this branch (the fork's sandbox-relay main.ts is older upstream code), so nothing to resolve. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Closes #750. On main (c812554), and stacked on #759 (a Moca Pi session can choose a sandbox template): #775, which this branch also stacked on, is merged. This branch contains #759's code commits, so merging it also lands #759's change. Its own change is 6 commits (review range
5f04a36a..16ee7f02), plus merges of #759 and of main.What it does: one control plane serves sessions and sandboxes (the
combinedprofile), and a session's template resolves through the store, pinned to a build. Six signed-off commits:combinedroute profile: enrollment applies to the sandbox routes and to template writes;combinedProfileConfig;mocactl sbx loginworks against a combined control plane.id,id:tagorid@build, pinned to that build. First use answers409 template_not_active.moca.dev/build, and turns filtered by build.ocp-combinedoverlay andsetup.sh SBX_PROFILE=combined.Limits:
membershipNow.combined, template, policy and quota reads are open to any logged-in subject. With the harness profile admitting any GitHub account, any such user can list deployment-visible templates and read the policy.400 unknown_template; the static list keeps400 invalid_request.Tests on the tip:
go testpasses forinternal/sessionand microvm-worker;setupandoverlay-combinedpass on bash 5 and 3.2, and prettier passes.50 files, +1,471 / -90, counted over the review range.
Assisted-By: Claude Code