Skip to content

feat(control-plane,harness): a templated session seeds from its build and returns its workspace patch; session records - #790

Merged
webchang merged 55 commits into
rossoctl:mainfrom
webchang:pr/i28-seed-patch
Nov 14, 2026
Merged

webchang merged 55 commits into
rossoctl:mainfrom
webchang:pr/i28-seed-patch

Conversation

@webchang

@webchang webchang commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Closes #751. On main (11f814b): #789 (the combined control plane, #750), which this branch stacked on, is merged. Its own change is 5 commits (review range 16ee7f02..0f2a77e8), plus merges of main.

What it does: a session on a template runs on that template's build, seeded from the build's own spec, and returns its workspace patch; a session's span on its build is recorded. Five signed-off commits:

  1. A pinned session's seed is its build's own spec.seed, reported as sandboxSeedSource (build or declared).
  2. The harness: a templated turn returns its workspace patch (captureTurnPatch, SH_TURN_PATCH_MAX_BYTES) and the seed's origin on its done and error frames; .moca-baseline goes in info/exclude.
  3. session provenance records: created, then terminated or deleted.
  4. A queued turn of a templated session runs on its template's build, seeded, and returns its patch.
  5. The docs: openapi 1.17.0 and harness-openapi 1.3.0.

Limits:

  • Sync /v1/runs prompt runs under a templated session's token now also run on its template, seeded, returning the workspace and seed (they share runPromptLeaf).
  • A failed or aborted queued turn returns no patch.
  • A queued turn's workspace is keyed by the leaf's session, so it's seeded separately from the interactive one.
  • A shared template's seed runs in each session's workspace, so trust it as you trust the image.

Tests on the tip:

  • typecheck passes;
  • the control-plane, harness, knative-server, sandbox-relay and mocactl suites pass;
  • prettier passes.

31 files, +1,339 / -79, counted over the review range.

Assisted-By: Claude Code

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]>
The exchange read a session's seed from SH_SANDBOX_TEMPLATES only, so a
session on a self-serve template (in no env list) started in an empty
workspace even though its build's spec carries a seed. With a template
store, a session pinned to a sha256: build now gets that build's own
spec.seed (the build's, never the newest); a build with no seed sends
none. Otherwise the declared seed, as before.

The exchange sends sandboxSeedSource (build | declared) with the seed;
knative-server validates it and passes it to the harness's TurnConfig.

Refs rossoctl#751

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

A session's client has no exec on its workspace (the relay's exec route
takes sandbox tokens only), and tool results are clipped, so it could not
read back what the agent changed. After every turn of a templated session
that leased its sandbox, before the lease is returned, the harness now runs
one capture in the workspace: git diff --cached --binary from the seed's
baseline commit to everything now, in a throwaway index (.moca-* and
.sh-config left out), so the agent's own commits do not hide its work.
Right after the seed, the harness writes git rev-parse HEAD to
.moca-baseline (best effort), and adds it to the repository's info/exclude
beside the seed's other files.

TurnResult.workspace = {baseline, patch | patchBase64, patchSha256,
patchBytes}; over SH_TURN_PATCH_MAX_BYTES (default 4 MiB, at most the
transport's output cap less 4 KiB) the patch is left out, never cut
(patchRefused: too_large, with its sha256 and size); a failed capture is
{error} and never fails the turn. TurnResult.sandbox.seed = {source,
buildId?}. Both ride on the terminal done and error frames, so mocactl
run --json prints them; mocactl's sync fallback keeps them too.
k8s-sandbox exports DEFAULT_OUTPUT_CAP for the cap.

Session templates spec §5, §5.1; harness-openapi TurnPlacement,
TurnWorkspace, FrameDone, FrameError; configuration reference.

Refs rossoctl#751

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

As the sandbox kind does for a sandbox: a session created against a build
resolved through the template store writes, on template/<id>, {sessionId,
buildId, templateManifestHash, lease, state: created}, its lease the
caller's live lease's activate record digest (null with none); its delete
writes {sessionId, buildId, state: terminated, reason: deleted, endedAt}.
A composer then joins a session to its lease and span exactly, with no
time inference. A session never deleted has no end record.

Lifecycle spec §7.1.

Refs rossoctl#751

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
…ed, with its patch

The dequeue-time exchange (POST /internal/turn-credentials) returned the
session's tier but none of its template, seed or build, so when a worker
drained a templated session's queued turn it ran on an untemplated worker,
unseeded, with no patch.

- control-plane: the dequeue exchange returns sandboxTemplate, sandboxSeed,
  sandboxSeedSource and sandboxBuildId exactly as the session exchange does
  (sessionTemplate, sessionSeed). They are read from the session, and that
  is a pin all the same: a session's template and build are written once,
  at creation, and no route changes them. A template no longer declared is
  still sent, without a seed, so the turn is refused, not run untemplated.
- knative-server: the claim validates them with the session exchange's own
  rules and carries them into the leaf's TurnConfig (templateAuth, shared
  with resolveTurnAuth).
- harness: a prompt leaf of a templated session selects only the template's
  workers, pinned to its build, seeds the leased workspace before the turn
  (a failed seed fails the leaf and returns the lease), and after a
  responded turn takes the workspace patch with the same capture as an
  interactive turn. The responded result, and so the turn's result record,
  carries workspace and, with a seed, seed {source, buildId?}. Verdict and
  solve leaves are unchanged.

openapi: /internal/turn-credentials' new fields, TurnStatus.result's seed
and workspace; harness-openapi: RunResult's responded seed and workspace;
session templates spec §3.4, §4, §5.2.

Refs rossoctl#751

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
The changelog entry for a session's seed from its pinned build, its
workspace's patch, its session records and its queued turns on its
template; /internal/credentials documents the build seed and
sandboxSeedSource. Both documents take a minor bump: every change is
additive.

Refs rossoctl#751

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 12, 2026

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

This PR runs a templated session on its build, seeded from the build's own spec.seed. It also has templated turns return their workspace patch, and records each session's span on its build. The patch capture is careful:

  • A throwaway index leaves the agent's own index alone.
  • The base is the seed's commit, so an agent committing its work doesn't hide it.
  • An oversized patch is refused whole, never truncated.
  • Seed files are excluded from the patch.

Queued and sync turns now share one templateAuth path, and the tests run real git and bash, not just mocks. I reviewed this PR's own commits, 16ee7f0..0f2a77e.

Must-fixes:

  1. An imported-build session gets a wrong created record and no end record (handlers.ts:1051 and :1199). resolveForUse only returns registered builds, so templateManifestHash is always the build id, including imported:<hex>, where §7.1 says it must be null. The delete path, meanwhile, is gated on sha256:. A probe created and deleted a session on a declared template. The chain then held only {"buildId":"imported:2dc079cabe4d","state":"created","templateManifestHash":"imported:2dc079cabe4d"}, with no terminated record.
  2. A templated session's workload run never finds a sandbox (run-leaf.ts:547). template is now passed to selectPoolSandbox for workload runs too. Workload sandboxes carry no moca.dev/template label, so a sync /v1/runs with workloadId under a templated token gets a retryable 503 workload_sandbox_unavailable. Clients retry it forever. A probe with one workload record returned wl-0 without a template, and WorkloadSandboxUnavailableError with template:'example-repo'.

The rest are suggestions and nits, inline:

  • a store error quietly drops a pinned self-serve build's seed;

  • the patch capture follows the workspace's git config;

  • a session record can be lost or duplicated around the state change.

  • Author: webchang (MEMBER — maintainer)

  • Areas reviewed: TypeScript (control-plane handlers/exchange/sandbox-handlers, harness run-leaf/run-turn, knative-server turn auth), openapi 1.10.0 and harness-openapi 1.3.0, docs

  • Agent/IDE config (.claude/.vscode): none

  • Commits: 70 in the branch (5 of them this PR's own), all signed-off: yes

  • CI status: pending (DCO, Trivy and check pass; the rest are still running)

Verified by:

  • harness turn-seed, run-leaf, turn-stream and leaf-result-store: 147/147 pass.
  • control-plane: 1322 pass, 9 fail. All 9 failures are ECONNREFUSED 6379 because no Redis was available.
  • knative-server turn-auth, turn-claim and server-process: 120/120 pass.
  • mocactl: 1753 pass, 1 fail, in sbx-up, which this range doesn't touch.
  • Throwaway probes for imported-build records, workload selection, the seed on a store error, and git apply --check under color.ui=always and diff.noprefix. They are deleted.

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

Comment thread packages/control-plane/src/handlers.ts Outdated
body: {
sessionId,
buildId: resolved.buildId,
templateManifestHash: resolved.build.status === 'registered' ? resolved.buildId : null,

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: resolveForUse only returns registered builds, so this is always resolved.buildId, including imported:<12hex> for an env-imported template. §7.1 and the sandbox record (sandbox-handlers.ts L118/L176) say the hash is null for an imported build. The delete path at L1199 is also gated on sha256:, so such a session gets created and never terminated. A probe on a declared t9 (create, then delete) left exactly one record: {"buildId":"imported:2dc079cabe4d","state":"created","templateManifestHash":"imported:2dc079cabe4d","lease":null}.

Suggested fix: templateManifestHash: resolved.buildId.startsWith('sha256:') ? resolved.buildId : null, and write the end record whenever rec.sandboxBuildId is set (see L1199). Add an imported-template case to activation.test.ts.

Comment thread packages/control-plane/src/handlers.ts Outdated
deps.provenance &&
deps.templates &&
rec.sandboxTemplate &&
rec.sandboxBuildId?.startsWith('sha256:')

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 (the same issue as L1051): this gate doesn't match the create side, which writes created for any build the store resolves, imported: included. The comment above promises that a created record precedes this one, and the spec table promises the pair. Gate on rec.sandboxBuildId being set, not on sha256:.

Comment thread harness/src/run-leaf.ts
tier: config?.sandboxTier,
// A templated session's leaf runs on its template's workers, pinned to its build, as its
// interactive turns do (session-templates spec §4): a queued turn of it included.
...(template ? { template } : {}),

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: template now reaches selectPoolSandbox for workload runs too. Workload sandboxes from the provisioner carry no moca.dev/template label (only SANDBOX_TIER), so a sync /v1/runs with workloadId under a templated session's token never matches. It gets a retryable 503 workload_sandbox_unavailable with Retry-After, and clients retry forever. Probe: one workload record returned wl-0 without a template, and WorkloadSandboxUnavailableError ... no sandbox of this workload is attached with template:'example-repo'.

Suggested fix: don't apply template, build or seed when workload is set, or refuse up front with a terminal error. Add a test.

Comment thread packages/control-plane/src/exchange.ts Outdated
if (!rec.sandboxTemplate) return undefined;
const build = rec.sandboxBuildId;
if (build?.startsWith('sha256:') && deps.templates) {
const doc = await deps.templates.get(rec.sandboxTemplate).catch(() => null);

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 (close to must-fix): for a session pinned to a sha256: build, a store read error falls back to the declared seed. A self-serve template has none, so the turn runs on an unseeded workspace with no error. That goes against the fail-closed rule sessionTemplate states just above ("rather than quietly moving a benchmark session to … an empty workspace"), and this function also serves the dequeue exchange. Probe: with templates.get throwing EIO, a self-serve template gave seed undefined, and a declared entry gave {"seed":"echo ENV-SEED","source":"declared"}.

Suggested fix: on a sha256: build, throw a retryable CpError when the store throws, and keep the fallback only for a missing doc or build.

Comment thread harness/src/run-turn.ts Outdated
`BASE=$(cat ${SEED_BASELINE} 2>/dev/null || git rev-parse --verify -q HEAD) && [ -n "$BASE" ] || exit 91`,
`D=$(mktemp -d) || exit 92`,
`export GIT_INDEX_FILE="$D/index"`,
`git read-tree "$BASE" && git add -A -- . ':(exclude).moca-*' ':(exclude).sh-config' && printf '%s\\n' "$BASE" && git diff --cached --binary "$BASE"`,

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 git diff reads the workspace's .git/config and the image's /etc/gitconfig, both of which the template or the agent controls. Probe (seed, capture, then git apply --check):

  • default config: applies;
  • color.ui=always: the patch starts \u001b[1mdiff --git and gives "No valid patches in input";
  • diff.noprefix=true: "git diff header lacks filename information".

The doc comment promises a patch that applies like a stock agent's.

Suggested fix: git -c color.ui=never -c diff.noprefix=false -c diff.mnemonicPrefix=false diff --cached --binary --no-color --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ "$BASE", and consider --no-renames for determinism.

Comment thread packages/control-plane/src/handlers.ts Outdated
};
resolveAuditLog(deps)({ event: 'audit', ...deletedEntry });
await deps.index.audit(deletedEntry);
// Its end on the build's chain (§7.1): with a store and provenance, a session's build was

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 session record is appended after the state change, after cascadeDelete here and after index.create at create. A provenance append that throws then turns an applied delete or create into a 500. Two concurrent DELETEs can also both pass assertOwner before the tombstone and write two terminated records. Suggested fix: log and swallow append failures as the audit mirroring does, or append first. This is fine as a follow-up.

Takes the combined plane's reviewed fixes: enrolled-only first-use
activation as createSession's last check, the pinned-worker hold on
each turn's exchange, the egress lookup on the sandbox enrollment
check, and the setup guard. Conflicts and their resolutions:

- packages/control-plane/src/handlers.ts (createSession): the template
  resolves first (resolveForUse) and the resolved build is kept for the
  session record; activation on first use (enrolled-only) stays the
  last check, after configRef, credential and model; the best-effort
  `created` record stays after the session is stored. So a create
  refused by any check, activation included, takes no lease and writes
  no `created` record. A successful activation check takes no lease
  (it returns only when the build is active), so the build read at
  resolution still names the caller's live lease for the record.
- packages/control-plane/src/exchange.ts: the template and seed resolve
  before the credential audit, so a store that cannot answer refuses
  the exchange before any credential is recorded; holdPinnedWorker runs
  where the other side placed it, after the audit and every refusal, so
  a refused exchange holds nothing (it is best effort and never refuses
  one itself).
- packages/control-plane/src/turn-exchange.ts: the same for a queued
  turn: template and seed before the audit, the hold after it; tier and
  model still come from the turn record.
- packages/control-plane/test/activation.test.ts: both sides' tests,
  the seed and session-record tests and the enrolled-only lease and
  worker-hold tests.

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

Copy link
Copy Markdown
Member Author

Merged #789's reviewed fixes into this branch: first-use leases and worker holds are now for enrolled subjects only. A refused session create takes no lease and writes no created record, and a refused exchange (interactive or queued) holds no worker. New head: 17f383a.

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.

Follow-up at 17f383a. This head is only a merge of #789 @538d36f (pr/i27-combined-plane) into 8e0809f. I checked the conflict resolutions with git show --remerge-diff and they keep both sides:

  • handlers.ts createSession: resolveForUse runs first, and resolved keeps build for the session record. requireActive(..., isEnrolledForSandbox(...)) (#789's enrolled-only first use) stays the last check, after configRef, credential and model. The created record is appended after index.create, so a refused create writes no record and takes no lease. A successful requireActive takes no lease (it returns only when the build is active), so the build read at resolution still names the caller's live lease correctly.
  • exchange.ts / turn-exchange.ts: sessionTemplate and sessionSeed are resolved before the audit, as at 8e0809f, so the fail-closed seed still refuses before any credential is recorded. holdPinnedWorker runs after the audit and every refusal, as on #789. On the queued-turn path, tier and model still come from the turn record (#788).
  • activation.test.ts: both sides' tests are kept (seed/session-record tests, the enrolled-only lease test, the worker-hold tests).

Apart from these resolutions and their comments, the merge brings in exactly #789's delta. Every item from our 26c19b1 review and clawgenti's review stays fixed, as verified at 8e0809f (imported-build terminated gating, untemplated workload runs, fail-closed seed read, .sh-config* patch excludes + diff overrides, validated BASE).

Still a follow-up, as agreed: two concurrent DELETEs can each write a terminated record.

Author: webchang (MEMBER — maintainer)
Agent/IDE config (.claude/.vscode): none
Commits: 1 new (merge), signed off
CI status: green so far; check (one job), deploy-scripts-bash32 and k8s-kind-e2e pending at draft time.

Assisted-By: Claude Code

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

Re-review at 17f383a. Since our last review (26c19b1) this PR adds 4 commits of its own, and they close both must-fixes and two of the suggestions:

  • Imported-build records: templateManifestHash is now null for an imported: build. The end record uses the same gate as created, and both are written best effort (184513d).
  • Workload runs: a templated session's workload run now selects only by its workload, with no seed, no patch capture and no template fields (6623052).
  • Seed on a store error: it now fails closed, and both exchanges resolve the seed before the credential audit, so a refused exchange records nothing as issued (2912d71).
  • Patch capture: the diff is pinned against git config (color, noprefix, mnemonicPrefix, renames). It excludes the promoted config's cache, lock and link, and refuses a baseline that is not a full commit id (8e0809f).

I checked each one against the code, and the new tests (real git and bash) cover them. No must-fixes remain.

One nit from last time is still open, and it's fine as a follow-up: two concurrent DELETEs can both pass assertOwner before the tombstone, so each writes a terminated record.

This PR stacks on #789, so it also carries #789's open suggestion: on combined, an unenrolled create gets a terminal 403 when readiness is unknown. See the #789 review. The other new commits are #789's own or base commits from #771 and #785, and are reviewed there.

  • Author: webchang (MEMBER — maintainer)
  • Areas reviewed: TypeScript (control-plane handlers.ts session records, exchange.ts/turn-exchange.ts seed and audit order; harness run-leaf.ts workload path, run-turn.ts patch capture), the design doc and harness API
  • Agent/IDE config (.claude/.vscode): none
  • Commits: 103 in the branch (4 new of this PR's own since the last review), all signed-off: yes
  • CI status: passing (17/17)

Verified by:

  • control-plane vitest run on head, with a local Redis: 1435 pass, 3 skipped, 0 fail.
  • harness vitest run: 396 pass, 1 skipped.
  • knative-server: 148 pass, 4 fail, all in server-process.test.ts. These fail the same way on main in this sandbox, because the harness dist/ isn't built here, so they are not from this PR. CI passes them.

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

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]>
Brings rossoctl#766's quota changes (the templates quota for a template holding
no slot, and the owned quota) through pr/i27-combined-plane.

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]>
pr/i27-combined-plane now carries upstream/main (sbx templates create,
build, follow, cancel, quota and policy).

Conflicts: none.

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

Copy link
Copy Markdown
Member Author

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 (lease modes, API 1.6.0) through pr/i27-combined-plane.

Conflicts:
- docs/api/CHANGELOG.md: this branch's seed and patch section, renumbered 1.11.0, above
  pr/i27-combined-plane's 1.10.0 and 1.9.0 and the lower sections.

API version: this branch's section moves from 1.10.0 to 1.11.0 (openapi info.version and the
changelog). 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]>
Brings in upstream main through f60db30 (turn grants, API 1.7.0) by pr/i27-combined-plane.

Conflicts:
- docs/api/CHANGELOG.md: this branch's seed and patch section, renumbered 1.12.0, above
  pr/i27-combined-plane's 1.11.0 and 1.10.0 and the lower sections.

API version: this branch's section moves from 1.11.0 to 1.12.0 (openapi info.version and the
changelog). 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]>
webchang added a commit to webchang/moca that referenced this pull request Nov 13, 2026
…dbox's, best effort

A session on a template imported from SH_SANDBOX_TEMPLATES got a
`created` record whose templateManifestHash was its `imported:` build
id, and no `terminated` record at delete: the create side wrote for any
build the store resolved, the delete side only for a `sha256:` one.
templateManifestHash is now the build id only for a `sha256:` build;
the end record is written whenever the session has a build id (the
same gate as `created`); both are written best effort, after the
change they record, so a failed append is logged and the create or
delete stands instead of a 500. The spec paragraph is not ported (the
fork's spec has none); the API changelog says so.

activation.test.ts: an imported build's session gets a null hash and
both records; a session record that cannot be written is logged and the
create and delete still succeed (both fail with the fix reverted); a
session with no lease cites none.

(cherry picked from commit 184513d)

Ports rossoctl#790 review fixes

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
webchang added a commit to webchang/moca that referenced this pull request Nov 13, 2026
…plate store cannot answer

For a session pinned to a `sha256:` build, a template store read that
threw fell back to the declared seed. A self-serve template declares
none, so the turn ran on an unseeded workspace with no error, against
the fail-closed rule sessionTemplate states. sessionSeed now refuses
the exchange on a store error (a store CpError as is, else
internal_error); only a template or build the store does not hold falls
back to the declared seed. The exchange resolves the template and seed
before the credential audit, so a refused exchange records no
credential as issued. The fork's queued-turn exchange sends no
template or seed, so that upstream hunk is not ported.

session-templates.test.ts: a store that throws refuses the exchange
with no credential_issued audit entry (fails with the fix reverted); a
store that holds no such build falls back to the declared seed.

(cherry picked from commit 2912d71)

Ports rossoctl#790 review fixes

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
webchang added a commit to webchang/moca that referenced this pull request Nov 13, 2026
…t config, checks its baseline

Three points on the patch capture after a templated turn:

- A promoted config's files reached the patch: the exclude matched only
  the top-level `.sh-config`, not its lock nor the session's link
  `leaves/<sid>/.sh-config`. The capture now excludes `.sh-config*`
  and `leaves/*/.sh-config` (glob).
- The diff followed the workspace's and the image's git config: under
  `color.ui=always` or `diff.noprefix=true` the patch did not apply. The
  diff now fixes its output: no color, no external diff or textconv,
  `a/` and `b/` prefixes, no renames.
- The baseline comes from a file the agent can write, and was passed to
  git as is. It must now be a full commit id (40 or 64 hex); anything
  else is reported as `{ error: 'the baseline is not a commit id' }`.

turn-seed.test.ts (real git and bash): a promoted config's cache, lock
and link stay out of the patch; under color, noprefix and
mnemonicPrefix config the patch has a/ b/ headers, no escapes, no
renames, and applies; an option, a rev name, a short or a two-line
baseline is refused. They fail with the fix reverted. The upstream
run-leaf test hunks (templated prompt leaves, which the fork lacks) are
not ported. The harness API and the design say so.

(cherry picked from commit 8e0809f)

Ports rossoctl#790 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]>
Brings in upstream main through c812554 (API 1.14.0) and the sandbox templates for sessions at
1.15.0 and the combined control plane at 1.16.0, by pr/i27-combined-plane.

Conflicts:
- docs/api/CHANGELOG.md: this branch's seed and patch section, renumbered 1.17.0, above the
  combined control plane's 1.16.0 and below.
- docs/api/openapi.yaml: info.version 1.17.0.
- docs/reference/change-policy.md: control plane 1.17.0, harness 1.3.0; main's list, then
  sandbox templates for sessions, the combined control plane, and a session's seed, patch and
  records.

API version: this branch's section moves from 1.12.0 to 1.17.0 (openapi info.version, the
changelog and change-policy); the harness document stays 1.3.0.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
@webchang
webchang merged commit d227d41 into rossoctl:main Nov 14, 2026
19 checks passed
webchang added a commit to webchang/moca that referenced this pull request Nov 14, 2026
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]>
webchang added a commit to webchang/moca that referenced this pull request Nov 14, 2026
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]>
webchang added a commit to webchang/moca that referenced this pull request Nov 14, 2026
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]>
@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.

Seed a pinned session from its build, return the workspace's patch, and carry templates on async turns

4 participants