Relationships
#5074 Support enrollment-bound worker execution ceilings
Opened by kneel · 11/25/2026
Deployment context
An operator running a shared worker fleet needs to bound what each worker is allowed to execute. The motivating case is multi-tenant hosting, but it generalizes to any fleet mixing trust levels: CI runners of differing privilege, or workers spanning production and non-production, all enrolled against one serve.
Current behavior (verified against 20261124.230941.0-sha.6a630211)
A worker's execution is not constrained to any allow-set:
- The serve-side dispatch gate checks only pool membership, connection, protocol
version, capacity, and worker status (
src/serve/worker_gateway.ts; refusal reasons are pool/capacity/protocol/status, e.g.not_in_pool, andstatusis one of idle/busy/unverified/draining). It does not check the dispatched behaviour type or method against anything bound to the worker. - The worker-side handler refuses only on draining/capacity/auth-gate/closed/
protocol, then runs whatever method it is handed (
src/worker/dispatch_handler.ts). - The enrollment-token and worker schemas carry no allow-set field:
EnrollmentTokenSchema(src/domain/models/worker/enrollment_token_model.ts) has name/expiry/vault/secret/bindings and no allowedTypes/allowedMethods/scope; likewisesrc/domain/models/worker/worker_model.ts. - Placement labels are self-asserted at the worker and taken verbatim by the serve, and an unsatisfiable placement queues rather than denies - so placement and labels are a scheduling hint, not an authorization control.
Consequence: a serve cannot restrict which behaviour types or methods a given worker may be dispatched or will accept.
Why the serve/workspace boundary is not sufficient here
Serve-per-workspace (swamp serve host, #4835) is the right isolation wall between tenants. But within a single workspace an operator still runs workers of differing privilege - a job that may touch secrets versus a sandboxed build, a trusted deploy runner versus an untrusted PR runner. Standing up a separate serve plus datastore per privilege tier inside one tenant is disproportionate. A per-enrollment execution ceiling is the proportionate control at the granularity where the serve boundary is too coarse.
Desired behavior
An enrollment token (or the worker definition it binds) can declare an execution ceiling - an allow-set of behaviour types and/or methods - enforced fail-closed at BOTH the serve dispatch gate and the worker accept gate. A dispatch outside a worker's ceiling is refused server-side before dispatch; a ceiling-bound worker also refuses out-of-ceiling methods as defense in depth. Absent a declared ceiling, behavior is unchanged (unrestricted), preserving backward compatibility.
Suggested implementation (non-prescriptive)
Add an optional allow-set to the enrollment-token definition; evaluate it at the dispatch gate and again at the worker accept gate. The exact schema (type globs, method lists, a CEL predicate) is the maintainers' to choose; the request is the capability and the two-sided enforcement.
Acceptance criteria
- An enrollment token can declare the behaviour type(s) and/or method(s) a worker bound to it may execute.
- A dispatch outside that set to such a worker is refused server-side, before dispatch, fail-closed.
- A ceiling-bound worker refuses an out-of-ceiling method even if dispatched.
- A token with no declared ceiling preserves current unrestricted behavior.
- A refusal is observable and distinguishable from a capacity or protocol refusal.
Evidence status
Dispatch-gate and schema facts were confirmed by reading the source at the version above; no behavior was experimentally executed. Placement/label self-assertion is covered by existing worker-connect and scheduler tests.
Related
- #2196 (workload identity for enrollment) - complementary: it authenticates the worker's identity; it does not bound what the worker may execute.
- #3679 (preserve active worker execution across restarts) - unrelated.
Open
No activity in this phase yet.
Sign in to post a ripple.