diff --git a/rfc/0030-kubernetes-sandbox-resources/README.md b/rfc/0030-kubernetes-sandbox-resources/README.md new file mode 100644 index 0000000000..17a634229d --- /dev/null +++ b/rfc/0030-kubernetes-sandbox-resources/README.md @@ -0,0 +1,592 @@ +--- +authors: + - "@JimBugwadia" +state: review +links: + - https://github.com/ai-openshell/openshell/issues/6073 + - https://github.com/ai-openshell/openshell/issues/5062 + - https://github.com/ai-openshell/openshell/issues/1719 + - https://github.com/ai-openshell/openshell/issues/5847 + - https://github.com/ai-openshell/openshell/issues/3362 + - https://github.com/ai-openshell/openshell/pull/5518 + - https://github.com/ai-openshell/openshell/pull/6149 +--- + +# RFC 0030 - Kubernetes Resources for Sandboxes, Templates, and Providers + + + +## Summary + +This RFC adds an optional Kubernetes controller and three custom resources in +the API group `openshell.ai/v1alpha1`: + +- `OpenShellSandbox` +- `OpenShellSandboxTemplate` +- `OpenShellProvider` + +You declare long-lived agents in Git, deploy them with Argo CD or Flux, +control them with Kubernetes RBAC and admission policy, and wait for them with +`kubectl wait`. The controller calls the gateway's public gRPC API, the same +API that the CLI and SDKs use. It doesn't create pods or other compute +resources. + +Each namespace that opts in maps to one gateway workspace. A new gateway +setting, `workspace_managers`, lets only the controller create or change the +sandboxes, templates, and providers in that workspace. Other users can still +read them, connect to sandboxes, and run commands in them. Workspaces without +the setting, and gateways without the controller, work as they do today. + +## Motivation + +Teams that run agents on Kubernetes deploy everything else from Git. Argo CD +and Flux can install the OpenShell gateway with its Helm chart, but not the +agents that run in OpenShell sandboxes. You can create sandboxes, templates, +and providers only through the gateway, with the CLI, an SDK, or gRPC, so +teams write CI scripts that call the CLI. + +Those scripts miss what Kubernetes provides for other workloads: + +- **Access control.** Permissions live in the gateway, not in namespace RBAC, + so platform teams manage two access models. +- **Drift detection.** A CLI call runs once. Nothing notices when the gateway + no longer matches Git. +- **Health.** `kubectl wait` and GitOps health checks can't see a sandbox. +- **Policy and audit.** Admission policy engines such as Kyverno, Gatekeeper, + and ValidatingAdmissionPolicy don't run, and Kubernetes audit logs don't + record changes. + +The Kubernetes compute driver creates `agents.x-k8s.io/Sandbox` objects, but +those describe pods and the driver owns them. They don't include policy, +providers, or templates. + + proposed serving +sandboxes from an aggregated API server in the gateway. Reviewers preferred +custom resources and a controller that calls the gateway API. A controller +supports more than one gateway per cluster, needs no change to gateway +storage, and works with `kubectl wait`, admission policy, and GitOps health +checks. This RFC describes that design. It adds a public Kubernetes API, a +gateway authorization model for workspaces, and a component that operators +install and run. + +## Non-goals + +- **Installing or upgrading the gateway.** + proposes an operator + for that. The controller works with a gateway installed by the Helm chart, + the operator, or any other way. +- **Sandboxes created on demand.** Sandboxes created per user, session, or + conversation stay on the gateway API and never become Kubernetes resources, + so etcd grows with the number of declared agents, not with traffic. +- **Mirroring gateway objects into Kubernetes.** Sandboxes created through the + gateway API in other workspaces don't get resources. +- **Mixed managers in one workspace.** A workspace is managed either by + Kubernetes or through the gateway API. +- **Declarative apply in the CLI and SDKs.** An `openshell apply -f` command is + possible later work. +- **Rollout strategies.** No canaries, session migration, or zero-downtime + replacement. Delivery tools handle those. +- **A policy resource, templates shared across namespaces, and sandbox sets.** + These can be added later without changing the fields defined here. + +## Proposal + +### Architecture + +The controller watches the three resources in each namespace that opts in and +applies them to that namespace's gateway workspace. Kubernetes stores the +declared spec and the controller's progress. The gateway database stores each +object's configuration and state. + +```mermaid +graph LR + Git --> GitOps[Argo CD or Flux] + GitOps --> API[Kubernetes API server] + API -->|watch| Ctrl[OpenShell controller] + Ctrl -->|status| API + Ctrl -->|gRPC, own identity| GW[Gateway] + CLI[CLI and SDKs] -->|gRPC| GW + GW --> DB[(Gateway database)] + GW --> Drivers[Compute drivers] +``` + +- **The controller is optional.** The gateway doesn't depend on it, and a + gateway outside Kubernetes works unchanged. +- **It uses only the public API.** It calls the same gRPC methods as the CLI + and has no access to the gateway database or the compute driver. +- **It has its own identity.** It authenticates to the gateway with its own + mTLS client certificate, `CN=openshell-k8s-controller`. Its Kubernetes + ServiceAccount is used only for the Kubernetes API. +- **It runs separately from the gateway.** It's a Rust Deployment with + Lease-based leader election, in its own Helm chart. It can run in the + gateway's cluster or another one, and you upgrade it separately. It uses the + gateway's policy parser to validate policy. + +### Resources + +All three resources are namespaced, in API group `openshell.ai`, version +`v1alpha1`. + +| Resource | Short name | Gateway object | +|---|---|---| +| `OpenShellSandbox` | `ossbx` | A sandbox. | +| `OpenShellSandboxTemplate` | `ossbxt` | A template. Each spec change publishes a new revision. | +| `OpenShellProvider` | `osprov` | A provider. Credentials come from Kubernetes Secrets in the same namespace. | + +```yaml +apiVersion: openshell.ai/v1alpha1 +kind: OpenShellSandboxTemplate +metadata: + name: support-agent + namespace: agents +spec: + image: registry.example.com/support-agent@sha256:9f2c... + resources: + cpu: "2" + memory: 4Gi +--- +apiVersion: openshell.ai/v1alpha1 +kind: OpenShellProvider +metadata: + name: nvidia + namespace: agents +spec: + type: nvidia + credentials: + - name: NVIDIA_API_KEY + secretKeyRef: + name: nvidia-credentials + key: api-key +--- +apiVersion: openshell.ai/v1alpha1 +kind: OpenShellSandbox +metadata: + name: support-agent + namespace: agents +spec: + templateRef: + name: support-agent + providers: [nvidia] + command: ["/app/agent", "--serve"] + restartPolicy: Always + stopped: false +``` + +**`OpenShellSandbox`** has the same inputs as a gateway sandbox: a +`templateRef` or an inline `workload`, but not both; `providers`; `command`; +`restartPolicy`; `serviceExposures`; and an inline `policy`. It adds +`stopped`. + +- You can change `providers`, `policy`, and `stopped`. The controller attaches + or detaches providers, applies the policy, and stops or starts the sandbox. + The sandbox keeps its ID. +- You can't change `templateRef`, `workload`, `command`, `restartPolicy`, or + `serviceExposures`, because they apply only when the sandbox starts. A CEL + rule in the CRD rejects changes to them, so `kubectl apply` fails instead of + being ignored. To run a different workload, create a new resource. + +**`OpenShellSandboxTemplate`** holds the image and workload settings, so Git +has the reviewed workload, not only its name. Gateway templates can't be +changed, so the controller publishes each spec change as a new revision, +`-r`. New sandboxes use the latest revision, and running sandboxes +keep theirs. `status.currentRevision` shows the latest. A `templateRef` can +also name a gateway template that has no resource. + +Templates don't support warm pools in `v1alpha1`. The gateway creates a warm +pool from a template's startup settings, `ready_within` and `max_burst` +(), and a pool serves +only its own template. Templates without these settings have no pool, so old +revisions cost nothing. If a later `spec.startup` field adds them: + +- Only the latest revision has startup settings. When the controller + publishes a revision, it removes the settings from the previous one, and the + gateway drains that pool. Running sandboxes aren't affected. +- The controller deletes old revisions that no sandbox uses. +- A new revision starts with an empty pool, so frequent template changes + reduce the benefit of warm pools. + +**`OpenShellProvider`** declares a provider whose credentials and refresh +material come from Kubernetes Secrets. The resource never holds a value, and +its `type` can't change. + +### Namespaces and workspaces + +A namespace opts in with a label whose value is its gateway workspace: + +```shell +kubectl label namespace agents openshell.ai/workspace=agents +``` + +- **One controller serves every labeled namespace.** It watches namespaces, so + a new label takes effect within seconds. An optional label selector lets + several controllers, one per gateway, share a cluster. +- **Each workspace has one namespace.** If two namespaces use the same + workspace, the one created first keeps it, and resources in the other + report `WorkspaceConflict`. Resource names are unique only within a + namespace, so two namespaces in one workspace could overwrite each other's + objects. +- **The controller creates missing workspaces.** If the gateway lists the + controller in `workspace_provisioners`, the controller becomes the manager + of each workspace it creates. Adding a team then needs only a label, not a + gateway configuration change. +- **An admission policy enforces opt-in.** The chart includes a + ValidatingAdmissionPolicy that rejects OpenShell resources in namespaces + without a valid label. +- **Labeling a namespace is privileged.** The label decides which workspace a + namespace's resources reach. If tenants can label their own namespaces, + restrict who can set `openshell.ai/workspace`. + +### Workspace managers + +Two gateway settings control who can change a workspace's objects: + +```toml +[openshell.gateway] +# Identities that become the manager of each workspace they create. +workspace_provisioners = ["mtls:openshell-k8s-controller"] + +[openshell.gateway.workspace_managers] +# Per workspace, the identities allowed to change its sandboxes, templates, +# and providers. +agents = ["mtls:openshell-k8s-controller"] +``` + +Each identity has the form `:`, which the gateway's +authentication already uses. The subject is the client certificate CN for +`mtls` and the token's `sub` claim for `oidc`. So +`mtls:openshell-k8s-controller` is a caller with a client certificate, issued +by the gateway's CA, whose CN is `openshell-k8s-controller`. It isn't a +Kubernetes ServiceAccount; see [Open questions](#open-questions). + +In a managed workspace, only its managers can `create`, `delete`, `stop`, +`start`, `suspend`, `resume`, or `update` sandboxes; `attach` or `detach` +providers; expose services; `approve` or `edit` policy drafts; `create` or +`delete` templates; and `create`, `update`, or `delete` providers. Other users +can still list and inspect these objects, read logs, and run commands with +`sandbox exec`. Operators and users with the admin role can still stop or +delete a sandbox in an emergency. The controller then reports the sandbox as +missing and doesn't recreate it. + +- The gateway checks the caller's identity on every API, regardless of client. +- The setting is a list, so several controllers, for example one per cluster, + can manage one workspace, and mixed managers can be added later without a + data migration. +- When the controller creates a workspace, the gateway records the manager in + the `internal.openshell.ai/workspace-managers` annotation. A + `workspace_managers` entry overrides it. `openshell workspace get` shows the + managers, from a new `managers` field on `Workspace`. +- A workspace without managers works as it does today. +- Roles still apply. The controller needs the workspace admin role to manage + templates and providers. + +Approving a policy advisor draft changes a running sandbox's policy, so it's +blocked in a managed workspace. To allow a rule for a declared sandbox, add it +to the sandbox's policy in Git. + +### Reconciliation, status, and deletion + +The controller records its progress in each resource's status, so a crash, +restart, or leader change doesn't duplicate or lose work. + +```mermaid +sequenceDiagram + participant K as Kubernetes + participant C as Controller + participant G as Gateway + C->>K: Add finalizer + C->>K: Record create attempt and request ID in status.journal + C->>G: CreateSandbox (request ID) + G-->>C: Sandbox ID + C->>K: Record sandbox ID, Ready=True + Note over K,C: Resource deleted + C->>G: DeleteSandbox (expected sandbox ID) + G-->>C: Accepted + C->>G: Confirm the sandbox is gone + C->>K: Remove finalizer +``` + +- **Finalizers.** The controller adds its finalizer before calling the + gateway, and removes it only after the gateway object is gone. This also + applies when you delete the namespace. +- **Retries.** The controller records each request in `status.journal` before + sending it, and retries with the same request ID after a lost response or a + restart, so the gateway doesn't create a second object. +- **Safe deletes.** A new optional field, `expected_sandbox_id` on + `DeleteSandboxRequest`, makes the gateway delete the sandbox only if its ID + matches, so the controller never deletes a sandbox that replaced its own. +- **The `Ready` condition.** Each resource has a `Ready` condition, + `observedGeneration`, `phase`, and `reason`. A sandbox also reports + `sandboxId`, `templateRevision`, and `gatewayPhase`. `Ready` means the + gateway accepted the spec. It stays `True` while the sandbox is stopped, + suspended, or completed, so stopping a sandbox doesn't change GitOps health. + Error and unknown phases set it to `False`. Whether the agent is running is + a separate condition; see [Sandbox availability](#sandbox-availability). +- **Errors.** Resources report reasons such as `TemplateNotFound`, + `PolicyInvalid`, `SecretNotFound`, `SecretsForbidden`, `WorkspaceConflict`, + `WorkspaceUnavailable`, `NamespaceNotEnabled`, and `CreateRejected`. The + controller's `/readyz` endpoint reports problems an administrator must fix. +- **Load.** While a sandbox starts or stops, the controller follows the + gateway's `WatchSandbox` stream, so `gatewayPhase` updates within seconds. + It checks other sandboxes every 2 minutes, writes status only when it + changes, and reconciles at most 16 resources at a time. A flag turns off + `gatewayPhase`, so stopping and starting sandboxes causes no status writes. + +### Sandbox availability + +`Ready` doesn't show that the agent is running: a process can crash and +restart, or run without the policy or credentials it needs. Each +`OpenShellSandbox` has a second condition, `Available`, like a Deployment's. +GitOps health checks read `Available` instead of `Ready`. + +The controller sets `Available` from the `WatchSandbox` stream it already +follows, so it adds no gateway calls. `Available` is `True` when: + +- The sandbox phase is `READY`. +- `current_policy_version` matches the policy the controller applied. +- Every attached provider is ready. +- Every endpoint in `endpoint_statuses` last succeeded. The gateway checks + these passively for tool servers, such as MCP over HTTP. +- `restart_count` hasn't increased for `spec.minReadySeconds`, 30 seconds by + default. + +Otherwise it's `False`, with a reason such as `CrashLooping`, +`PolicyNotLoaded`, `ProviderNotReady`, or `EndpointUnreachable`. A stopped, +suspended, or completed sandbox reports `True` with reason `Stopped`, +`Suspended`, or `Completed`, so stopping a sandbox doesn't change application +health. + +`OpenShellSandboxTemplate` status reports how many sandboxes run the latest +revision and how many of them are `Available`, so a GitOps tool can wait for +a template change to roll out. + +Health checks should read `Available` only when `observedGeneration` matches +the resource's generation: a Lua health check in Argo CD, or a CEL expression +in `healthCheckExprs` in Flux 2.5 and later. To test the agent with a real +request, such as a test prompt, run a hook once per application, for example +an Argo CD PostSync Job or a Flux post-deployment test that calls +`openshell sandbox exec`. + +### Secrets + +Kubernetes Secrets hold credential values, often synced from a secret manager +by the External Secrets Operator. + +1. You store or rotate a value in a Secret in the team's namespace. +2. The controller reads it for each `OpenShellProvider` that references it. +3. The controller sends it to the gateway when it creates or updates the + provider. The gateway stores it with its configured credential driver: the + database, Kubernetes Secrets, or Vault. +4. The sandbox gets a placeholder. The sandbox proxy adds the real value only + to requests that its policy allows, so the agent never sees it. + +- **Access is granted per namespace.** The chart includes a ClusterRole for + reading Secrets, with no ClusterRoleBinding. An administrator grants it in + each namespace with a RoleBinding, through the chart's `secretsNamespaces` + value or other tooling. A label alone never grants Secret access, and a + namespace whose providers reference no Secrets needs no RoleBinding. +- **Rotation takes seconds.** The controller watches Secret metadata in + namespaces whose providers reference Secrets, and updates only the providers + that use a changed Secret. Provider status records each Secret's resource + version, never its value. +- **Values stay private.** Status, events, and errors never include values, + and the controller never calls `RevealSecret`. +- **Access to OpenShell resources is cluster-wide.** Deleting a namespace + deletes its RoleBindings in no particular order. If the controller's access + to its own resources were namespaced, it could lose it before removing its + finalizers, and the namespace would never finish deleting. The cluster-wide + grant covers only `openshell.ai` resources and namespaces. Deleting + resources doesn't need Secrets. + +Refresh material that many providers share, such as one OAuth client secret, +belongs in workspace secrets from +[RFC 0024](../0024-workspace-secrets/README.md). A resource for them can +follow once that RFC lands. + +### Packaging and operations + +The controller ships as a container image and a Helm chart. The chart installs +the CRDs, which it keeps on uninstall, the controller's RBAC, optional +ClusterRoles for platform engineers and developers, the admission policy, and +a Deployment with leader election and a readiness probe. The controller +reloads rotated gateway credentials without a restart. + +```shell +helm install openshell-controller deploy/helm/openshell-k8s-controller \ + --namespace openshell-controller --create-namespace \ + --set gateway.url=https://openshell.openshell.svc:8080 \ + --set gateway.tls.secretName=openshell-controller-tls \ + --set "secretsNamespaces={agents}" +kubectl label namespace agents openshell.ai/workspace=agents +kubectl apply -f support-agent.yaml +kubectl wait ossbx/support-agent -n agents --for=condition=Available +``` + +## Implementation plan + +The gateway changes and the controller are opt-in, so they can land in steps +without changing behavior for existing users. A working implementation, with +tests and docs, is on +[`feat/6073-k8s-sandbox-crd/JimBugwadia`](https://github.com/JimBugwadia/OpenShell/tree/feat/6073-k8s-sandbox-crd/JimBugwadia). + +1. **Gateway.** Add `workspace_managers`, `workspace_provisioners`, the + `managers` field on `Workspace`, and `expected_sandbox_id` on + `DeleteSandboxRequest`. Enforce managers for sandboxes, templates, and + providers. Document the settings in the gateway configuration reference as + experimental. Test that only managers can change a managed workspace and + that other workspaces are unaffected. +2. **Controller.** Add `crates/openshell-k8s-controller` with the three + resources, the request journal, namespace opt-in, Secret handling, status + streams, the `Available` condition, template rollout status, leader + election, and credential reload. Test reconciliation against a mock + gateway, including lost responses, restarts, rejected changes, and + deletion. +3. **Packaging.** Add the controller image and the + `deploy/helm/openshell-k8s-controller` chart, with Helm tests for install, + leader failover, credential rotation, namespace opt-in, and readiness. +4. **Docs.** Add a Kubernetes sandbox resources page, image requirements, a + walkthrough under `examples/`, the chart README, and rows in the + `debug-openshell-cluster` skill. +5. **End-to-end tests.** Run the full stack in a kind cluster with a network + plugin that enforces NetworkPolicy, such as Cilium. Check that the + sandbox's workload pod can't connect out directly, that deleting a + namespace removes its gateway objects, and that Argo CD reports sync, + health, self-heal, and prune correctly. + +Possible follow-ups after the first release: + +- **Warm pools.** Template startup settings, with the revision rules in + [Resources](#resources). +- **A read-only runtime view.** A `SandboxRuntime` resource in its own API + group, such as `runtime.openshell.ai`, served by an aggregated API server + that reads live state from the gateway, like metrics-server serves + `PodMetrics`. It would show phase, restarts, endpoints, and sandboxes that + the controller doesn't manage, such as session sandboxes, without etcd + writes. It would replace `gatewayPhase`. + + It's deferred because an aggregated API server is in the cluster's + discovery path. While it's down, discovery for its API group fails, clients + that list all API groups report errors, and namespace deletion stops with + `NamespaceDeletionDiscoveryFailure`. CRDs don't have this problem, because + kube-apiserver serves them. The server would need: + + - At least two replicas, a PodDisruptionBudget, and anti-affinity. + - To keep serving when the gateway is down, returning stale or empty data + with a condition instead of an error. + - Read-only access, which avoids admission and writes. + - Delegated authentication, SubjectAccessReview authorization, and an + exclusion for its API group in GitOps tools. + + The first release doesn't need it: `Available` and `gatewayPhase` cover + status. + +The API starts at `v1alpha1`, so fields can change before `v1beta1` without +conversion webhooks. Moving to `v1beta1` needs a load test that confirms the +numbers in [Risks](#risks). + +## Risks + +- **Two copies of the spec.** Kubernetes stores the declared spec, and the + gateway stores what it applied. In a managed workspace only the controller + writes, and status reports the revision the gateway accepted. An + administrator's emergency stop or delete still makes them differ; the + controller reports the difference instead of undoing it. +- **Deletion depends on the controller.** Finalizers block deletion until the + controller removes the gateway object, so a controller outage blocks + namespace deletion. A create that the gateway rejected or never received + releases its finalizer without a gateway call, and the controller README + documents manual recovery. Removing a finalizer by hand leaves the gateway + object behind. +- **The namespace label grants a workspace.** Anyone who can label namespaces + chooses which workspace their resources reach. The one-namespace-per- + workspace rule, the label selector, and admission control on namespace + labels limit this. Secret access needs a separate RoleBinding. +- **etcd and gateway load.** The implementation stores about 2.8 KB per + sandbox resource and makes 7 Kubernetes writes from creation to `Ready`, + then none. 10,000 declared sandboxes would use about 28 MB of etcd and about + 83 gateway checks a second. Each sandbox on the Kubernetes driver already + has a Pod and an `agents.x-k8s.io/Sandbox` object, so this adds little. + On-demand sandboxes stay out of Kubernetes. A load test must confirm these + numbers. +- **Some errors appear after apply.** Errors that only the gateway detects, + such as an invalid policy, appear as conditions rather than `kubectl apply` + failures. The CRD schema and CEL rules catch structural errors at + admission. +- **More to maintain.** The project takes on a controller, a chart, and a + Kubernetes API with compatibility commitments once it leaves alpha. + +## Alternatives + +### An aggregated API server in the gateway + +Proposed in . It stores +nothing in etcd and has one source of truth. But a cluster can register only +one server per API group and version, so it can't serve several gateways. If +the gateway is down, discovery and namespace deletion stop, and watch, +server-side apply, and admission need custom work. An aggregated server suits +a read-only runtime view, not the declared spec; see the follow-ups in +[Implementation plan](#implementation-plan). + +### The driver's `agents.x-k8s.io/Sandbox` objects + +The Kubernetes driver already creates these objects, but they describe pods, +the driver owns them, and they exist only on the Kubernetes driver. They can't +hold policy, providers, or templates, and editing them would bypass the +gateway. + +### Running the CLI from CI, or doing nothing + +Teams can keep calling the CLI from pipelines. This needs no new code, but +gives no drift detection, self-heal, health, or admission policy, and keeps +access control in the gateway instead of namespace RBAC. + +### Declarative apply in the gateway first + +`openshell apply -f`, with the gateway handling retries, would also serve +users outside Kubernetes. It needs the gateway database to store declared +specs and revisions. Current demand is Kubernetes GitOps, so this RFC keeps +that work in the controller. If the gateway adds declarative apply later, it +can take over retries from the controller without changing the resources. + +## Prior art + +- **Kubernetes operators**, such as cert-manager and Crossplane providers, + declare external resources as custom resources and reconcile them through + the external system's API, with finalizers that guard cleanup. This RFC + follows the same pattern and uses status conditions that GitOps tools read. +- **metrics-server** serves `PodMetrics` through API aggregation alongside the + Pods that etcd stores. It's the model for the runtime view follow-up, which + keeps live state separate from the declared spec. +- **Argo CD and Flux health checks** read conditions and + `observedGeneration`, so sync, health, self-heal, and prune need only a + short health check. +- **Deployments** separate a rollout in progress from `Available` Pods that + stayed ready for `minReadySeconds`. `Available` on a sandbox works the same + way. +- **[RFC 0024](../0024-workspace-secrets/README.md)** adds workspace secrets + for shared refresh material. This RFC leaves shared refresh material to it. + +## Open questions + +- Should the controller authenticate with its Kubernetes ServiceAccount + instead of a client certificate? The gateway would verify the token with the + TokenReview API and accept identities such as + `k8s:system:serviceaccount:openshell-controller:openshell-k8s-controller` in + `workspace_managers`. This works only when the gateway runs in the same + cluster. +- Should a session service and the controller be able to manage the same + workspace? Which use cases justify the per-object ownership rules this + needs? +- When should policy get its own resource, and should teams share policies + across namespaces? +- Should templates be shareable across namespaces, so platform teams can + publish them from a namespace they control? Only templates from listed + namespaces would be allowed to set placement. +- Do agents need a readiness probe that the supervisor runs inside the + sandbox? It would test the agent itself, but needs a template field, + supervisor support, and a gateway condition. +- Should a sandbox set with a replica count be added for identical workers, + and how would a new template revision reach existing members?