Repository navigation
Description
Problem
With templates in a store (#736) and self-serve creates (#737), what changes after create can only be
changed by editing the store: an owner cannot move default (or stable, v2) to a new build, nor
change a template's description or visibility; an admin cannot hand a template to another user. A
template the deployment declared (imported once from SH_SANDBOX_TEMPLATES) has no owner, so its id
blocks every self-serve create under it (409 template_exists) and nobody can ever build a new version
of it without a store edit.
Proposal
Each change is an API call and a provenance record (#730) naming the new value and the one before.
POST /v1/templates/{id}/tags {tags, build}(the owner): moves tags onto a registered build;
DELETE /v1/templates/{id}/tags/{tag}removes one (neverdefault; the build stays). Atagrecord
{tag, buildId (null when removed), before}. Sandboxes and sessions created earlier keep the build
they were given.PATCH /v1/templates/{id} {description?, visibility?}(the owner): avisibilityrecord{field, value, before}. A self-attested template cannot becomedeployment-visible (Trust a subject's own gate record for its own templates; allow repositories per registry #738).PUT /v1/templates/{id}/owner {owner}(admins): anownerrecord{owner, before}. A declared
template (owner: null) can be handed to an enrolled subject, recorded withbefore: null; the
subject then builds, tags and retires it like any of theirs, and a restart does not undo it (the env
list is not re-imported).ownertakes the subject grammar of Enroll subjects and grant the admin role through the API, recorded and effective per request #739:github:<id>oroidc:<sub>
(feat: generic OIDC identity provider (w3id) behind the login seam #701), nevertest:<n>.- Every owner action is also open to admins, on any template.
- mocactl (the client part, filed here):
sbx templates tag ID TAG… --build B,untag ID TAG,
edit ID [--visibility private|deployment] [--description TEXT],transfer ID SUBJECT(admins).
What the PR will contain
One PR, about 1,150 added lines with tests (client included).
- control-plane:
src/sandbox-handlers.ts(ownTemplate,moveTemplateTags,removeTemplateTag,
updateTemplate,transferTemplateOwner),src/routes.ts;test/activation.test.ts(tags, edit,
owner transfer including a declared template; anoidc:owner passes the subject grammar),test/routes.test.ts,
test/openapi-contract.test.ts. - mocactl:
src/sbx/api.ts,src/sbx/commands.ts,src/sbx/cli.ts;test/sbx-cli.test.ts,
test/contract.test.ts,test/helpers/sbx.ts. - docs:
docs/api/openapi.yaml(a minor API version bump), CHANGELOG; the template lifecycle design §5.1-§5.2.
Depends on
#736, #730, #737. The subject grammar (MEMBER_SUBJECT_RE in src/identity.ts, after #701) is shared with
#739 and #748: whichever lands first carries it.
How to verify
pnpm -C packages/control-plane test -- activation routes openapi-contractpnpm -C packages/mocactl test -- sbx-cli contract- On a deployment with a store: an admin transfers a declared template to a user; the user's
templates createunder that id is a new build of it (not409);tag ID stable --build Bmoves
stable, and a sandbox created withID:stableis served by B; the template's stream holds the
owner(before: null) andtagrecords.
Limits / out of scope
- A transfer needs an admin; a deployment with none cannot transfer.
- Whether a declared id should be claimable without an admin, and whether a retired id should become
free for others, are left open (today: neither). - No per-template roles (a maintainer who may tag but not transfer).
Assisted-By: Claude Code
Activity
test(control-plane): the template admin tests send the guest size once
fix(control-plane): a tag is looked up as the template's own, and a r…
fix(control-plane): a template change is stored only once its records…
fix(control-plane): the owner's check is made again under the templat…
test(control-plane): a create retried after an owner transfer is chec…
docs(reference): change-policy names the control plane's API 1.8.0
feat(control-plane): the member subject grammar, MEMBER_SUBJECT_RE
feat(control-plane): template tags, edits and owner transfer through …
feat(mocactl): sbx templates tag, untag, edit and transfer