Providers
The provider plugin model and the detached exec contract.
A provider creates and destroys sandboxes and runs commands in them. Turntable runs one job per sandbox.
Plugin model
- First-party providers (Docker, Daytona) are compiled into the binary.
- Third-party providers run out of process and talk JSON-RPC over stdio. Any language works, and a crashing plugin cannot take down the server.
Capability handshake
On start, the core and the provider exchange a handshake. The provider declares which capabilities it supports, and the core refuses to schedule work that needs a capability the provider lacks.
Detached exec
Correctness never depends on a long-lived stream. A command runs detached, and the core reads its progress by polling:
| Call | Purpose |
|---|---|
exec.start | Start a command and return a handle. |
exec.status | Report whether the command is running and, when done, its exit code. |
exec.logs | Return output from a byte offset, so the core resumes where it left off. |
A dropped connection loses nothing, and a silent stream is not mistaken for a finished job. Live streaming is an optimization on top of this contract.
No env in the sandbox spec
The sandbox spec has no environment variable field. Providers never receive secrets or other job environment through the spec. This keeps secrets out of provider APIs and logs. See Secrets and security.
Conformance suite
A provider conformance suite will exercise the contract: detached exec, offset logs, exit code recovery and cleanup. First-party and third-party providers must pass it.
Isolation levels
Every provider declares an isolation class in its info, weakest first:
| Class | Meaning |
|---|---|
container | Processes share the host kernel. |
gvisor | A user-space kernel intercepts system calls. |
microvm | The sandbox has its own kernel in a lightweight VM. |
vm | A full virtual machine. |
A provider declares only what it has verified. Docker declares container, or gvisor when it runs with the runsc runtime ("runtime": "runsc" in its provider config). Daytona declares container: its sandboxes report the container class, and the linux-vm class has not been exercised.
The scheduler enforces a minimum before a job starts:
- A job from an untrusted author needs
gvisoror stronger. A job is untrusted when it needed the untrusted-author approval, or its run’s plan says"trust": "untrusted". - On a hosted instance (
serve --hosted, orTURNTABLE_HOSTED=1), every job needsmicrovmorvm. - Otherwise any provider will do.
A job on a provider that is too weak ends as infra_error with a reason naming both classes, and never starts. To run anyway, start the server with --isolation-override "<reason>". The override is explicit and audited: each affected job writes an audit entry (run, job, attempt, provider, required and actual class, reason) and starts its log with a line saying so.
Daytona
The Daytona provider (packages/provider-daytona) runs jobs in Daytona sandboxes through its REST API with plain fetch. It supports detached exec through the shared wrapper, file upload and download, listing by label, and TTL backstops.
Configuration
The API key is read when it is first needed, from a file path, an environment variable name, or a function, and is never stored in config, logged or included in an error:
new DaytonaProvider({ apiKey: { file: "/run/secrets/daytona" } });
new DaytonaProvider({ apiKey: { env: "DAYTONA_API_KEY" } });Other options: baseUrl, runId, maxLive, target, snapshot (the name of an existing snapshot), maxFileBytes, capacityWaitMs, ownerCiPreflight, ownerCiLabels and ownerCiLabelWaitAt.
Account rules, enforced in code
The provider is built for a shared account where it must not disturb other work. Each rule is checked in the provider, with tests, and cannot be switched off by configuration:
-
Every sandbox is named
<fleet>-*and labelled<fleet>=1plusturntable-run=<run id>. The fleet is thefleetoption of the provider config and defaults tolongshore-dev, so an existing config is unchanged. -
Fleets. Two Turntable instances in one Daytona account (a developer’s machine and a hosted shadow, say) must not count against each other’s own-fleet budget or touch each other’s sandboxes. Give each its own
fleet, for example"fleet": "longshore-shadow"for the hosted one: its sandboxes are namedlongshore-shadow-*and labelledlongshore-shadow=1. A fleet name is lower case, starts withturntable-(orlongshore-, the name before the rename), uses letters, digits and single hyphens, and has at most 30 characters; anything else stops the server at start. A sandbox is a fleet’s own only with both its label and its name prefix, and everything that counts, lists, verifies or deletes goes through that test, so an instance can never see, count or delete another fleet’s sandboxes, including a fleet whose name extends its own (longshore-dev-2next tolongshore-dev). Each fleet has its ownmaxLive. The org CPU check still sees every sandbox in the account, whatever its fleet. -
Our own fleet is counted from recorded sandbox ids, never from a listing. Daytona’s listings cannot be trusted: a label-filtered list returned nothing for new sandboxes even a minute later, and the unfiltered list showed deleted sandboxes as started (measured). Only a get by id is accurate. So the provider keeps the ids it created and has not confirmed gone, confirms each with a get whenever it counts (a 404 or
destroyedmeans gone), and countsmaxLivefrom that. On boot (and with every reconcile) the server hands it the sandboxes recorded in the database with no confirmed destroy (adopt), so a restart does not forget them. Cleanup anddestroyByLabelswork from the same ids. The label-filtered listing is only a best-effort extra for finding strays; whatever it finds is confirmed by a get first, it can never lower a count, and an empty or failing listing means nothing. A finished attempt whose sandbox was never confirmed destroyed is swept: destroyed by id and its destroy recorded, retried until it works.capacityStatus()reportscounting: { mode: "recorded-ids", tracked }. -
At most 2 sandboxes of ours are live.
maxLivecan lower this, or raise it up to a ceiling of 10 that is fixed in code; the default stays 2, so a deployment opts in to more. -
The hard TTL, auto-stop and auto-delete are at most 30 minutes. A spec asking for more is refused. Auto-delete is 0, so a stopped sandbox is deleted at once.
-
Label count (optional, off by default). If you give
ownerCiLabels({ "key": "project", "values": ["acme-ci", "acme-release"] }: the account owner’s CI sandboxes are those whose labelkeyis exactly one of the values, or that started from a snapshot with one of those names) andownerCiLabelWaitAt(a number), the provider waits before creating a sandbox while that many of them hold quota. They are only counted, never listed back, changed or deleted. With noownerCiLabelWaitAt, or noownerCiLabels, there is no label gate and no request is made for it. -
It also reads the org’s usage (
GET /organizations/{id}/usage) and waits while the CPU in use in regionus, classcontainer, plus the new sandbox’s vCPU, is above 200 of the 250 quota. Other users of the same org run sandboxes with labels we cannot know, and a label count cannot see them; this check needs to know nobody’s labels, so it is the gate to rely on when the owner’s CI legitimately runs many sandboxes. In the provider config file,ownerCiPreflightistrue(or absent) for these defaults,{ "cpuLimit": 150, "region": "us", "sandboxClass": "container" }to change them, orfalseto turn this org check off.allowDomainListConfinement(boolean, default false) is for the proxy path, see the secrets proxy page. The same check covers disk and memory: it waits while disk (or memory) in use plus the new sandbox’s (itsresources, else Daytona’s default of 1 GiB memory and 3 GiB disk) is above the limit. The limit isdiskLimitGiB/memLimitGiBfrom the config when set, else the total quota the usage reply reports for the region and class; a reading or quota the reply does not carry is skipped, never taken for room.capacityStatus()reports the limits in use and where each came from. A create that Daytona refuses with a 400 saying a quota is exceeded (“Total disk limit exceeded. Maximum allowed: 2000GiB”) is capacity too: it is logged once, waited out and retried withincapacityWaitSeconds, and fails as an infrastructure fault only when the wait ends. Any other 400 is still a spec error and fails at once. The org id comes from any sandbox in the account, and from the first one we create. With no sandbox to learn it from, the check is skipped for that create and a line is logged (nobody else is running). A usage endpoint that answers 404, or a reply that cannot be read, fails the create instead of being taken for room: setownerCiPreflight: falseto run without the check.A key that may create and delete sandboxes but not read the org’s usage gets a 403 on that read. Only that status falls back, to an own-fleet budget: Turntable counts its own live sandboxes by its label and waits while that is
maxLiveor more, logsorg usage forbidden (403); own-fleet budget mode, maxLive Nonce, and reports the mode incapacityStatus(). The org’s CPU is then not checked, so other users of the account can push it past the quota;maxLiveis the only gate. SetquotaMode: "own-fleet"to choose this mode without asking Daytona first. A 401 (bad key), 404, 5xx, a network error or an unreadable reply still refuses the create. -
A sandbox counts as live, for that wait and for our own cap, in every state except
stopped,archived,destroyedanderror. Transitional states such ascreating,starting,pending_build,building_snapshot,restoringanddestroyinghold quota and count. -
Listing, counting and deleting only ever touch sandboxes carrying our fleet’s label and name prefix.
destroy,execandfilesfirst check that the target is ours and refuse anything else. -
No snapshots are created. A named existing snapshot (
snapshotin the config) is used when there is one. With none configured, animagethe scheduler names is ignored and the create call names no snapshot, so Daytona starts from the account default snapshot.allowImageBuildis the only way to build an image, because a build makes a snapshot in the account. -
withSandboxcreates, runs and always deletes in afinally.destroyreturns only once the sandbox is gone from the API and from listings, so counts and the cap are true. -
Every response body the provider reads is capped and streamed: file downloads stop at the caller’s
maxByteshowever large or mislabelled the response, and API replies are capped at 16 MiB.
Verified against the real service
These were checked by running the conformance suite and a short capability test on a real account (packages/provider-daytona/scripts/live-check.ts):
- Egress
noneblocks outbound connections (networkBlockAll), and egressopenallows them. These are the two policies the provider declares. - Sandboxes are Linux x86_64 containers (
sandboxClass: container) running as userdaytona, with 1 vCPU, 1 GB memory and 3 GB disk by default. - Exit codes, signal deaths, offset logs across silent gaps, output caps, binary file round trips and the absence of controller environment variables all pass the shared conformance suite.
Per-project snapshot and concurrency cap
Three settings belong to the instance operator, one project at a time (--untrusted-run-approval <human|no_agents|any> sets the third, who may approve a held run; see Secrets and security). A tenant must not choose its own image or lift its own cap, so they are set with turntable policy set --org <slug> --project <slug> --sandbox-snapshot <name|none> --max-concurrent <n|none> on the host, or with set_project_settings over REST with an instance token (not an MCP tool, audited in the system chain and the org’s). get_project_settings (reader, project-scoped) and turntable policy show read them.
sandboxSnapshotnames an existing provider snapshot (Daytona) that the project’s sandboxes start from. Order: the project’s snapshot, then a size class’s snapshot, then the provider config’ssnapshot, then the provider’s default. The project’s wins because it carries that project’s tools; an instance-wide size class must not replace it. A size class’s cpus, memory and disk still apply on top, for a provider that honours them. The project’s snapshot is used for every trust class in that project, untrusted pull requests included, so never bake credentials or private code into a snapshot (a job holds untrusted code or usable credentials, never both).maxConcurrentcaps the project’s running attempts. Like an org quota it can only lower the instance’s per-org cap (--org-cap), never lift it: with the default per-org cap of 2 a project cap of 4 does nothing, so raise--org-capand--global-capfirst. The org’s own cap still applies. A project at its cap holds new work (running attempts finish) while the org’s other projects keep running.max_concurrent: 0pauses the project: nothing of it is claimed until the cap is raised or cleared (attempts already running finish).
Scheduling class: yield to other projects
Projects share one fleet (the global cap, the org’s cap and the provider’s live sandboxes), and the claim is first come first served inside an org. A low-priority project, such as an instance running its own CI next to a customer’s, can set scheduling_class to yield so that it never delays the others. The default is normal.
- Claim. A
yieldattempt is claimed only when nonormalattempt can be claimed at that moment. A normal attempt that waits for something else (aneedsdependency, an approval, its project’s cap, a held quota) does not hold yield work back. Inside the yield class the usual order applies. While the fleet has room and no normal work can run, yield work runs: it is held back by waiting normal work, never starved on an idle fleet. - Preemption. When a normal attempt could run but the global cap, or its org’s cap, is full, the scheduler preempts the newest running
yieldattempt (in the same org when the org’s cap is what is full). It does this in the same transaction as the claim, so there is no moment where the slot is free but unclaimed. One call preempts at most one attempt, and the scheduler claims again until nothing waits, so a fan-out of ten normal jobs preempts four running yield jobs in four passes. Anormalattempt is never preempted. Preemption under the global cap is cross-org, because yield is instance-wide: a yield project in org A can be preempted by normal work in org B when the global cap is full. Nothing is preempted while both caps have room. - Stop path. A preempted attempt stops through the same path as a cancel-in-progress supersession: its worker is aborted and its sandbox destroyed (a worker in another process finds its lease gone at the next heartbeat).
- Requeue, never failure. The attempt ends
cancelledwith the error classpreempted, and its job goes back toqueuedwith a new attempt (the next attempt number, norerun_reason, so no rerun is used). The old attempt keeps its log, steps and sandbox record and stays readable under its own id. It is no failed attempt, retry or quota failure, and the run’s conclusion comes from the final attempt of each job. The change is audited (scheduler.preempt, in the org’s chain) and appears in the event feed as ajob.state_changedevent withreason: "preempted". The partial run’s work is lost: a preempted job starts over. - Reporting.
sandbox_usagewithgroup_by: "project"returns each project’sscheduling_classand aclassestotal, so yield usage is reported apart. Minutes of a preempted attempt count to the yield project. - Anti-thrash (off by default).
preempt_max_per_jobis 0, which means no limit: normal work waits only for a teardown, however often a yield job was preempted. An operator can set it to 1 or more. A job preempted that many times withinpreempt_window_minutes(default 60, used only when the cap is on) is then no longer preempted: normal work waits for it, and it runs to its end. The count is the job’s attempts that ended with the error classpreemptedand finished inside the window, so it needs no new storage, and once the window has passed the job can be preempted again. Both are instance settings (TURNTABLE_PREEMPT_MAX_PER_JOB,TURNTABLE_PREEMPT_WINDOW_MINUTES, orscheduler.preempt_max_per_jobandscheduler.preempt_window_minutesinturntable.toml). Only the instance administrator changes them, never an agent, and a value in the environment or the file locks it. Trade-off: enabling the cap bounds wasted yield minutes, but normal work can then wait for a capped yield job to finish. - Counts and cost.
get_rungives each job apreemptionscount (the run view shows “Preempted N times”). Withgroup_by: "project",sandbox_usagegives each project and each classpreemptions,preempted_minutes(sandbox time of attempts that were preempted, which is lost work) anduseful_minutes(the rest), and a project’s most preempted jobs underpreempted_jobs. The preempted minutes stay insidetotal_minutesand still count against quotas, because the sandbox ran.
The setting belongs to the instance administrator and is never an MCP tool, because it decides whose work the fleet serves first. Set it for a project with instance_set_setting (see Hosted setup).
Not declared, and why
allowlistegress: the API hasdomainAllowListandnetworkAllowList, but they have not been exercised, so the provider does not claim them.- Proxy reachability and ingress: a sandbox has no route to a controller on a private machine without a tunnel.
- Isolation: the sandboxes observed are containers sharing a host kernel, which is weaker than a VM. Daytona has a
linux-vmclass that has not been tested. The provider interface has no isolation field yet, so nothing is claimed.
Known limits
nprocand/proc/meminfoshow the host, not the sandbox. Read limits from the sandbox’s cgroup instead.- Listings are eventually consistent and deletion is asynchronous. The provider waits for both, which adds a few seconds to create and destroy.
Sandbox size per job
By default every sandbox gets the provider’s own default size (Docker: no limits; Daytona: the snapshot’s). To give some jobs more, the operator maps runs-on labels to a size class. It is server configuration, not stored in the database and not a migration: set TURNTABLE_SANDBOX_SIZES_JSON (or TURNTABLE_SANDBOX_SIZES_FILE) to a document like this.
{
"classes": {
"small": { "cpus": 2, "memoryMb": 4096 },
"large": { "cpus": 4, "memoryMb": 8192, "diskGb": 40, "snapshot": "daytona-large" }
},
"labels": { "ubuntu-latest-4-cores": "large" },
"default": "small",
"untrustedClass": "small",
"maxCpus": 8,
"maxMemoryMb": 16384,
"maxDiskGb": 100
}- A job’s
runs-onlabels are read at plan time (a string, a list, orlabels:; a matrix expression is resolved per leg). The first label with a mapping picks the class. A job with no mapped label getsdefault; with nodefaulteither, it gets the provider’s own size. - A class sets
cpus,memoryMb,diskGband, for a provider that picks the size by image, asnapshot(Daytona: one snapshot per class, for exampledaytona-large). The scheduler puts these in the sandbox spec; a provider that cannot honour a field says so in its capabilities. - Daytona’s capacity wait already counts the class’s
cpus, so a 4-vCPU job waits until 4 are free in the account. maxCpus,maxMemoryMbandmaxDiskGbare ceilings across every class: a class past one is clamped to it. They are instance-wide. There is no per-org CPU quota; the org’s concurrency and sandbox-minute quotas still apply.- A workflow file chooses its own labels, so a stranger’s pull request could ask for the biggest class. A job that runs as
untrusted_prignores its labels and getsuntrustedClass(elsedefault). The class is the job’s own, as recorded on its attempt (after the demotion rule), not its run’s; a missing or unrecognised class counts as untrusted, and only a local run is exempt. - Lookups use own keys only: a label such as
constructoror__proto__is not a mapping and gets the default, and a class named like an inherited key does not exist. A failed lookup falls back todefault, never to the provider’s size, while a map is configured. - A bad document stops the server at start, naming the problem: an unknown class in
labels,defaultoruntrustedClass, a non-integer or non-positive number, or an unknown key.
Provider trust model
A provider runs the job’s untrusted code, so it is a trust boundary. This is exactly what one can see and do.
What a provider sees. The sandbox spec (image or snapshot, resources, labels, TTL, egress policy), the files the scheduler uploads (the repository tarball and the plan), and every command and environment variable it is asked to run, which means the job’s code and any secret value placed in its environment. Secrets that Turntable holds for a job are not placed in its sandbox when the secrets proxy is in use: the sandbox gets a placeholder and the proxy adds the real value on the way out. A provider also sees the job log bytes as they pass.
What a provider can do. Create, list, exec in, read and write files of, and destroy sandboxes, through the Provider interface in provider-sdk, and nothing else. It is given only the credentials its own config names (an API key read from a file or an environment variable it is told about), and nothing from the vault, the database, the signing keys or the data directory.
Built-in providers (docker, daytona) are code in the Turntable binary, so they are covered by the release’s signatures and reviewed with it. They run in the server process. The server still checks them: at registration the declared capabilities must satisfy the contract (detached exec with offset logs, labels, listing by label, a TTL, and enforceable egress none) and must not exceed the provider’s ceiling (Docker may declare up to gvisor, with the runsc runtime; Daytona only container; neither may declare egress policies beyond what was verified: Docker none, open and deny-all-except-proxy; Daytona those plus proxy-domain-filtered when the operator opts in, and never allowlist). A provider that fails is refused at startup, naming the reason.
External plugins are not built in, and today there is no loader for them. The gate is in place: an unknown provider name is refused unless TURNTABLE_PROVIDER_PLUGINS (a JSON array of {name, path, sha256}) names it and the file at path has exactly that sha256, and it is refused in every case in hosted mode (--hosted), where third-party plugins are disabled. A plugin whose digest matches is reported as verified, then refused with a message that this build has no external loader. When a loader exists it must run the plugin as a separate process with an allowlisted environment (pluginEnv: PATH, LANG, LC_ALL, TZ, TMPDIR and the names the operator lists for that plugin, so never the master key, database settings or tokens of the server), no access to the data directory, and caps, timeouts and schema validation on its JSON-RPC messages. None of that is claimed to exist yet.
Assurance tiers. The isolation class a provider declares (container, gvisor, microvm, vm) is its tier. The scheduler already requires a minimum tier per trust class (see isolation levels), so a weaker provider is refused for classes that need more, rather than trusted more.