Hosted deployment
Running Turntable on a platform with no shell (Railway), connecting GitHub installations per org, and shadowing a repo's CI.
This page is for running one Turntable instance for several orgs on a platform that gives you environment variables and a volume, and no shell. It covers configuration from the environment alone, the installation claim flow, webhooks, and a shadow run.
Everything from the environment
Every serve option has a variable (a flag, when given, wins):
| Variable | Option |
|---|---|
PORT, TURNTABLE_HOST, TURNTABLE_DATA_DIR | --port, --host, --data-dir |
TURNTABLE_WORKER=1 | --worker |
TURNTABLE_PROVIDER, TURNTABLE_PROVIDER_CONFIG, TURNTABLE_PROVIDER_CONFIG_JSON | --provider, --provider-config |
TURNTABLE_POLL, TURNTABLE_POLL_JSON | --poll |
TURNTABLE_IMAGE, TURNTABLE_GLOBAL_CAP, TURNTABLE_ORG_CAP, TURNTABLE_LEASE_SECONDS | --image, --global-cap, --org-cap, --lease-seconds |
TURNTABLE_HOSTED=1, TURNTABLE_ISOLATION_OVERRIDE | --hosted, --isolation-override |
TURNTABLE_GITHUB_APP_SETUP_TOKEN_SHA256 | Turns on creating the GitHub App from the instance. Not a serve option. |
With no files, the two configs can be JSON in a variable (TURNTABLE_PROVIDER_CONFIG_JSON, TURNTABLE_POLL_JSON). A config never carries a secret. The Daytona provider names the variable that holds its API key ("apiKeyEnv": "DAYTONA_API_KEY", the default), and the poll config names the variable that holds the poll token ("tokenEnv": "GITHUB_POLL_TOKEN") instead of a file. A token pasted into the config is refused.
Example for a Daytona-backed worker that shadows one repo:
TURNTABLE_WORKER=1
TURNTABLE_PROVIDER=daytona
TURNTABLE_PROVIDER_CONFIG_JSON={"apiKeyEnv":"DAYTONA_API_KEY","maxLive":3}
TURNTABLE_POLL_JSON={"tokenEnv":"GITHUB_POLL_TOKEN","provider":"daytona","repos":[{"repo":"acme/web","org":"acme","project":"web","workflow":".github/workflows/ci.yml","defaultBranch":"main","prMode":"approval"}]}
TURNTABLE_HOSTED=1
TURNTABLE_MASTER_KEY_FILE=/data/master.key
DAYTONA_API_KEY=...
GITHUB_POLL_TOKEN=...
The master key on a host with no shell
turntable keys init needs a shell, and Railway has none. Set TURNTABLE_MASTER_KEY_FILE to a path on the volume (for example /data/master.key) and TURNTABLE_MASTER_KEY_AUTOINIT=1 (or start with --init-master-key). If the file is absent at start, Turntable creates it once with 32 random bytes and mode 0600, and records master_key_created in the system org’s audit chain. The log names the path and never the key.
- It never overwrites. If the file exists it is used as it is, even if it is the wrong size (the server then refuses to start, as it always does).
- Two replicas starting together are safe: the file is written whole to a private temporary file and linked into place, so exactly one creates it and the other reads a complete file.
- It is refused when the key’s directory or the data dir can be read or written by other users and is not owned by the server process. A directory the process owns is tightened to remove the access, and the log says so.
- Without the opt-in an absent file is an error, as before.
The volume now holds the key, so a volume backup is also a copy of the key. (Use TURNTABLE_MASTER_KEY instead to keep it off the volume.) Anyone who can read a backup of the volume can read every stored secret in it. Back the key up on its own, somewhere else (a secrets manager), and keep volume backups under the same access rules. Losing the file loses every secret sealed with it. Turn the opt-in off once the key exists if you want a missing file to be an error again.
The master key from a variable, and rotating it
Prefer this on a hosted instance. With a key file on the volume, every volume backup holds the key next to what it unseals: the GitHub App private key, the webhook secret, the vault and the audit state. Anyone with backup or restore access to the hosting project can unseal all of it. Put the key in your platform’s secret variable instead, and nothing on the volume can open the store.
Set TURNTABLE_MASTER_KEY to 32 random bytes as base64 (openssl rand -base64 32) or 64 hex characters. Then:
- It is read once at boot and deleted from the process environment before any child process, provider or plugin starts. Children are also spawned with an allowlisted environment that never carries it.
- Setting it together with
TURNTABLE_MASTER_KEY_FILEis an error, and the server does not start.TURNTABLE_MASTER_KEY_AUTOINITcreates a key file and is not used with the variable: remove it. - A host with a separate secrets mount can keep using
TURNTABLE_MASTER_KEY_FILE;doctorwarns when that file sits inside the data directory. - With a variable there is no key file to sit next to, so the audit anchor state lives in
<data dir>/audit-stateunlessTURNTABLE_AUDIT_STATE_DIRnames another directory. In the data directory it is on the volume, so a restored volume restores it too: mount a separate volume forTURNTABLE_AUDIT_STATE_DIR, and setaudit_anchor_sink_url(TURNTABLE_AUDIT_ANCHOR_SINK_URL) so each org’s latest signed anchor also leaves the instance.turntable doctorwarns until the state is outside the data directory. See Security. - The offline commands (
secret,oidc,github-app,audit) read the variable the same way.
Rotating the master key with no shell
Rotation re-encrypts every sealed row at boot, so it needs only variables and a deploy.
- Generate a new key:
openssl rand -base64 32. - Set
TURNTABLE_MASTER_KEYto the new key andTURNTABLE_MASTER_KEY_PREVIOUSto the key in use now. To move off a key file, set the file’s contents as the previous key (TURNTABLE_MASTER_KEY_PREVIOUS_FILE=/data/master.keyworks too) and removeTURNTABLE_MASTER_KEY_FILEandTURNTABLE_MASTER_KEY_AUTOINIT. - Deploy. At boot, every sealed row is re-encrypted under the new key in one transaction: the secrets table (GitHub App credentials, audit signing keys, OIDC keys), vault versions and outbound webhook secrets. Each is opened again under the new key and compared before the commit, and the audit anchor state files are re-sealed with it. The system org’s audit chain records
master_key_rewrapwith a count per table. If any row opens under neither key, nothing is changed and the server does not start; the log names the table and row, never a value. Fix the variables and deploy again. - Take a new backup. It is the first one that holds nothing the old key opens.
- Keep
TURNTABLE_MASTER_KEY_PREVIOUSset until a clean boot is confirmed (turntable doctorgreen, orinstance_doctorwith no shell, noAnchorCorrupt, no “audit anchor … previous master key” line in the log), and only then remove it. Removing it earlier on a host that has not finished the re-wrap leaves rows the new key cannot open. If the old key was a file on the volume, retire it (see below). Leaving the previous key set is harmless (rows already under the new key are skipped), but it keeps the old key in the environment.
If you boot on a new key without the previous one, an audit anchor that does not open is reported at boot and by doctor as “not sealed under the current master key (most likely the previous one)”, with the fix: set TURNTABLE_MASTER_KEY_PREVIOUS and restart.
6. Rotate the secrets themselves. The old key and every backup taken before step 4 still open the values inside those backups. Rotate the GitHub App private key and the webhook secret (turntable github-app rotate-webhook-secret, or create the App again), and every vault secret, so what the old backups hold is dead. Deleting the old backups is your decision; the rotation is what makes them safe.
7. Retire the old key file (no shell). If the old key was a file on the volume (/data/master.key), it still sits there and in every later backup. Set TURNTABLE_MASTER_KEY_RETIRE_FILE=/data/master.key together with TURNTABLE_MASTER_KEY and the previous key (TURNTABLE_MASTER_KEY_PREVIOUS_FILE=/data/master.key, or the same bytes in TURNTABLE_MASTER_KEY_PREVIOUS), and deploy. After the re-wrap, the boot deletes the file only if the process runs on TURNTABLE_MASTER_KEY, every sealed row opens under it (a read-only check), the file equals the previous key you gave, and the path is a regular file (not a symlink) inside the data directory. Otherwise one log line names the condition that failed and the file stays. A deletion is audited as master_key_file_retired with the path, never a key. A file that is already gone is logged once and is not an error. Then remove TURNTABLE_MASTER_KEY_RETIRE_FILE and TURNTABLE_MASTER_KEY_PREVIOUS[_FILE]. Backups taken before the rotation still hold the old file’s key: step 6 is what makes them safe.
Cache blobs are not re-wrapped: a cache entry sealed under the old key stops opening and is a miss. The release lane has its own key and is not touched by this; see below.
The release lane’s key
On a host where the lane runs in the same service, a key file on the data volume puts the signing key wrapper in every backup. Set TURNTABLE_RELEASE_MASTER_KEY (base64 or hex, 32 bytes) instead of TURNTABLE_RELEASE_MASTER_KEY_FILE; both set is an error. The lane reads it once and removes it from its environment; the main process removes it too and never uses it. doctor warns when the release key file is inside the data directory or the release data directory.
To rotate it, set the new key and TURNTABLE_RELEASE_MASTER_KEY_PREVIOUS on the lane. At boot the lane re-wraps its publish credentials (release-class vault rows) and its signing key files under the new key, verified before the commit, and audits it as release_key_rewrap. Keep TURNTABLE_RELEASE_MASTER_KEY_PREVIOUS set until a clean boot is confirmed, then remove it. A vault row that opens under neither release key is left alone and named in the log: it is sealed under the main key.
When the lane runs in the same process as the main service, give that process both pairs. The main re-wrap tries every key it holds (main previous and new, release previous and new) and re-seals each row under the new key of the family it opened under, all in one transaction. A release-class vault row that opens under none of the held keys fails the boot, naming the row (table and id, never a value): provide the release master key (TURNTABLE_RELEASE_MASTER_KEY and _PREVIOUS) too. The one exception is a main process that does not hold the release keys while a release lane is configured for the instance (TURNTABLE_RELEASE_MASTER_KEY_FILE or the worker’s publish channel is set): such a row is counted and logged as left for the release service.
Keep the new key in your secrets manager as well as in the platform variable. Losing it loses every stored secret.
Instance administrator access on a host with no shell
To call the instance operations on a hosted instance, generate a tti_ token on your own machine with turntable token generate --instance and set only its hash as TURNTABLE_INSTANCE_BOOTSTRAP_TOKEN_SHA256. On boot it becomes an instance token if none is active, expiring in 30 days at most. Call POST /api/v1/instance/tokens/rotate once to swap it for a token only you have seen, then remove the variable. The steps and the rules are in Instance administrator.
The first approver on a host with no shell
turntable approvals bootstrap needs a shell on the server, which a hosted instance does not have. Instead, the instance administrator calls POST /api/v1/instance/approvers/bootstrap (the bootstrap_approver op) with a tti_ token, once per org. Generate the key pair on the approver’s own machine with turntable approvals keygen --out alice.key, which prints the public key, and send only that:
curl -sS -X POST "$TURNTABLE_URL/api/v1/instance/approvers/bootstrap" \
-H "Authorization: Bearer $TURNTABLE_INSTANCE_TOKEN" -H "content-type: application/json" \
-d '{"target_org":"acme","person":"Alice","forge_login":"alice-gh","public_key":"<alice.pub text>"}'It works only while the org has no active approver, and it never adds to an existing set. If every approver of an org was revoked, it is refused until a delay has passed since the last revocation (24 hours by default, the approver_rebootstrap_delay_hours setting, at least 1; see Settings registry), so a stolen instance token cannot revoke all approvers and enrol its own key at once. The refusal says when it becomes possible. An org that never had an approver has no delay, and the host’s CLI is not delayed. The setting is an org setting whose default is the instance-wide 24 hours; only the instance administrator changes it (instance_set_setting with target_org), never over MCP, and TURNTABLE_APPROVER_REBOOTSTRAP_DELAY_HOURS or turntable.toml locks it. Revoking an org’s last approver emits an approvers.depleted event and each bootstrap an approver.bootstrapped event; both reach the org’s outbound webhooks (subscribe by type), and both are audited in the org’s chain and the system chain. Enrol a passkey next as a second key, signed by the bootstrap key as usual. The op is REST only: an org token of any role is refused, and instance tokens are not MCP credentials. See Human approvals.
Webhooks wake the poller
A signed push or pull_request webhook for a repo the poller is configured for polls that repo now instead of at the next interval. The payload contributes only the repo name, to choose which configured repo to poll: the poll re-fetches every fact from the GitHub API and applies the trust decision exactly as for any run (class from re-fetched facts, an untrusted pull request held for approval). A repo not in the poll config is ignored, polls of one repo never overlap, two wakes are at least 5 seconds apart, and a repo that is backing off after errors or a rate limit is not woken early. Without webhooks the poller still polls on its interval.
Check runs post as shadow / <job>, always neutral, while the project’s checks mode is shadow.
The API budget of the poller
GitHub counts requests per credential. Polling with no token shares 60 requests an hour per address with every other unauthenticated call, including action resolution. The poll token has its own 5,000 an hour, shared by every repo that uses it.
A repo bound through the GitHub App is polled with a token minted for that one repo instead, with contents, metadata and pull_requests read and nothing else. Each installation has its own 5,000 an hour, so the repos of one instance do not draw on each other’s budget or on the fallback. The token is short-lived, held in memory only (the App’s token cache, which an incident freeze clears), never logged and never returned by an operation. The ETag cache is kept across token renewals, and a 304 is not counted against the limit.
The binding must be in the same org and project the repo is polled into. A repo with no installation, and any repo whose token cannot be minted, uses the poll token, or no token. A failed mint is logged once per poll interval and the poll goes ahead on the fallback.
ingest_status shows the auth mode of each repo (anonymous, token or installation) and its budget, plus rate_limit_by_mode: the last seen budget of each mode, as anonymous, poll_token and installation (for installation, the repo with the least left).
Creating the GitHub App on an instance with no shell
turntable github-app create serves a page on the machine that holds the data directory, which a platform with no shell cannot do. The instance can run the same manifest flow itself.
-
On your own machine, make a setup token and keep it:
turntable token generateprints a token and its sha256. Set only the hash on the instance, together with its public URL, and redeploy:TURNTABLE_GITHUB_APP_SETUP_TOKEN_SHA256=<the sha256> TURNTABLE_PUBLIC_URL=https://ci.example.com TURNTABLE_MASTER_KEY_FILE=/data/master.keyWithout the hash the routes do not exist.
-
Open
<public url>/api/v1/instance/github-app/manifest, enter the token, the slug of the Turntable org that will own the App, and a name (and a GitHub organization, to create it there instead of under your account). You can alsoPOSTthe same fields (org,name,gh_org,rotate) withAuthorization: Bearer <token>. -
The reply is a page that sends the manifest to GitHub. Approve it there. GitHub sends the browser back to
<public url>/api/v1/github/app-callback, which exchanges the one-time code and seals the App’s id, private key, webhook secret and client secret in the encrypted store. They are never printed, logged or shown, and the page says only the App’s name and where to install it. -
Install the App on your repositories, then remove
TURNTABLE_GITHUB_APP_SETUP_TOKEN_SHA256from the variables.
The manifest asks for the least it needs: checks write; contents, metadata and pull_requests read; events push, pull_request and check_run. Merge queue runs are found by the poller, and a merge_group webhook is not subscribed to, because GitHub requires another permission for it. With TURNTABLE_CLAIM_INSTALLATIONS=1 the manifest also carries the setup URL and asks for user authorization on install, which the claim flow needs. In that mode the App is also created public, because a private App can be installed only by the account that owns it, and the claim flow exists for other accounts to install it. That is safe: an installation nobody has claimed is ignored (it maps to no org and nothing runs), and a claim needs proof that the installer owns the installation. Without claim mode the App is private. An App created before this change is private: open its settings on GitHub, go to Advanced, and choose Make public.
How it is protected:
-
The setup token is the only credential. Only its hash is configured and it is compared in constant time. It is checked first: a correct token is never throttled, so noise from elsewhere cannot lock you out. Failed attempts are audited and capped at 10 a minute per client address (the real client when you name your proxies in
TURNTABLE_TRUSTED_PROXIES, otherwise the socket peer). -
The state is signed and single use. It is an HMAC over the org, a nonce, an expiry and the replace flag, under a key sealed in the owning org’s store. The nonce is stored and consumed before the code is exchanged, so a link works once, and it expires after 15 minutes.
-
Only the starting browser can finish. The page sets a
HttpOnly,SameSite=Laxcookie holding a random secret that never appears in a URL; the signed state carries only a MAC of it. Someone who sees the state (browser history, a referer, GitHub’s redirect) does not have the secret and cannot complete the flow with their own App’s code. A link opened in another browser, or a forged callback, creates nothing. -
The App must be the one asked for. The signed state carries the requested name and GitHub organization. After the code is exchanged and before anything is stored, the instance checks that the App has that name (without regard to case) and owner, that its page is on
github.com, and, reading it back with its own credentials, that its permissions and events are no broader than the manifest’s and that its webhook points at this instance. Otherwise nothing is sealed and the attempt is audited aserror:app_mismatchwith a reason class. Because the name is checked, do not edit it on GitHub’s page; if you do, start again. Error text from GitHub is never logged or audited. -
Storing is atomic and serialised. The four secrets, the App row, and the removal of a replaced App are written in one transaction, and “an App already exists” is checked again inside it. Starts and callbacks run one at a time, and a start is refused while another flow is unexpired and unfinished, so concurrent attempts can never mix one App’s key with another’s id.
-
A second create is refused. Once an App exists, starting again is refused (and audited) unless the request asks to replace it, and a replace must name the same owning org. A replace swaps the App and its credentials, drops cached installation tokens, and is audited as
github_app_replace. The old App’s installations are marked deleted and the repository bindings they granted are removed (the count is audited and shown on the result page); install the new App again. -
Everything is audited in the owning org’s chain (
github_app_manifest_start,github_app_createorgithub_app_replace, and each refusal). Attempts with a wrong token go to the system chain. -
The route closes itself. It closes after the first success until the instance restarts, and 6 hours after the instance starts. The owning org must be the bootstrap org (
TURNTABLE_BOOTSTRAP_ORG, defaultlocal) or the system org, never a customer org, because the App’s owner holds every installation of it. Request bodies are capped at 4 KiB before they are parsed.
This is gated by the setup token until the instance admin role exists.
Checking the GitHub App
After the manifest flow, confirm the result without a shell:
- The instance administrator calls
instance_github_app_status(GET /api/v1/instance/github-app, atti_token, REST only). It returns the App’s id, slug, owner login, the Turntable org that owns it and when it was created,sealed(true when the app id, private key and webhook secret are all stored; the material itself is never returned), installation counts by status (active,suspended,deleted) and the ids of installations that webhooks named but no org has claimed (up to 100, newest first). - An org’s own token (
release_operatoror admin, org-level) callsgithub_app_status(GET /api/v1/github/app, also an MCP tool). It returns whether the org owns the App, and only the installations that org has claimed, each with its account, status, repository selection and bound repos. Another org’s installations never appear.
One instance, several orgs: claiming an installation
By default every installation of the App maps to the org that owns the App. On a hosted instance, set TURNTABLE_CLAIM_INSTALLATIONS=1 and each org claims its own installation:
- A signed-in principal of the org calls
start_installation_claim. It needs an org-level token withrelease_operatoror admin; a project-scoped token is refused. It returns a link to this Turntable instance carrying astate: an HMAC over the org, who started it, a nonce and an expiry (15 minutes), with the nonce stored and single use. Optionally passgithub_loginto restrict the claim to one GitHub user. - Opening the link shows a confirmation page that names the Turntable org that will receive the installation. The page sets a random token in a
Strictcookie and puts an HMAC of it (with the claim’s nonce) in the form. The confirming POST is accepted only if the browser says it came from this instance (Sec-Fetch-Site: same-origin, or anOriginequal to the instance origin; with neither header it is refused) and the cookie and form value match. It then sets a short-livedHttpOnly,Secure,SameSite=Laxcookie holding the nonce and sends the browser to GitHub (Lax, notStrict, because the callback is a navigation that starts on github.com and aStrictcookie would not be sent). The callback needs that cookie, and clears both cookies once it has used it, so a link forwarded to another browser, or a flow another site’s page tries to start, cannot be completed. - The person installs the App, and GitHub sends the browser to the App’s setup URL,
<public url>/api/v1/github/setup, withinstallation_id,stateand an authorizationcode. The App must have Request user authorization (OAuth) during installation enabled and that setup URL set. The manifest flow sets both (request_oauth_on_installand the setup URL) when claim mode is on. An App created without claim mode needs both set by hand in its settings. - The state names the org but does not prove the installation id, which is only a query parameter, and access is not ownership (every member of an organization can see its installations). So the callback exchanges the code for the user’s token and requires that the user can reach the installation and owns it: for an organization account,
GET /user/memberships/orgs/{org}with the user’s token must sayrole: adminandstate: active; for a personal account, the account must be the user. Ifgithub_loginwas given, it must match. It then re-fetches the installation with the App’s own credentials (it must be our App) and only then maps it, and its repositories as projects, to the org in the state, consuming the nonce. A failed attempt does not burn the link. Every outcome is written to the org’s audit chain asclaim_installation, with the GitHub user id and login who claimed it. - An installation another org already holds is never taken (the callback refuses it with a 409 before it spends the claim). An installation nobody has claimed is ignored by the webhook handler (stored as ignored), not mapped to the App’s org.
Claiming an installation made without the claim link
An install made from the App’s public page, or before claim mode was on, is ignored as unclaimed. Claim it from its configure page instead of reinstalling:
- Call
start_installation_claimwithinstallation_idset to the installation’s id (the number in its settings URL, or an id frominstance_github_app_status). The link is the same Turntable confirmation page. - Confirming sends the browser to the installation’s configure page on GitHub (
https://github.com/organizations/<org>/settings/installations/<id>, orhttps://github.com/settings/installations/<id>for a personal account; Turntable reads the account type from the App’s own view of the installation). It refuses an id the App does not have. - The App must have Redirect on update enabled (
setup_on_update). The claim-mode manifest turns it on. An App created before this change needs it set by hand: in the App’s settings on GitHub, under Post installation, tick Redirect on update, and check that the setup URL is<public url>/api/v1/github/setup. - The person opens the configure page and saves (for example Save on the repository access section). GitHub redirects to the setup URL with
setup_action=update,installation_idand an authorizationcode. GitHub sends nostateon this redirect, so the callback finds the claim by the nonce in the browser-binding cookie that the confirmation page set. Every other proof is the same as for an install: the cookie, a claim that is unused and under 15 minutes old, a user token that reaches the installation and owns it, an optionalgithub_loginmatch, and a re-fetch with the App’s credentials. Aninstallredirect still needs the signedstate. The browser-binding cookie isSameSite=Lax, so it also rides on a link someone else sends. The claim is therefore pinned to theinstallation_idit was started with: anupdateredirect for any other installation is refused with a uniform error before the owner check, the token exchange or the claim spend, and a claim started without aninstallation_idcannot finish through anupdateredirect at all. - An installation held by another org is refused and never moved. For an unclaimed one the installation and its repositories are mapped as in a normal claim, and the adoption of same-org bindings applies.
Ingesting a bound repo without a poll entry
An installation binds its repositories to a project, but binding alone ingests nothing. A project is ingested from its binding only after an operator gives it ingest settings, locally and audited, because the settings decide who is trusted:
turntable policy set --ingest on --org acme --project web \
--workflow .github/workflows/ci.yml --pr-mode allowlist --authors octocat --merge-queue
turntable policy set --ingest off --org acme --project webThe settings are the poll knobs that belong to a repo: --workflow, --default-branch (fixed when ingest is turned on: given, or asked from GitHub once for the bound repository, and stored; the poller never asks again to decide it, so a repo admin changing GitHub’s default branch cannot move what counts as protected. If GitHub later reports another branch, that is logged and audited as ingest_default_branch_drift and the stored one stays in use), --pr-mode, --authors, --merge-queue, and --var NAME=value (repeatable). Vars are non-secret variables for ${{ vars.NAME }} in a workflow’s if: and expressions, as GitHub’s repository variables are: they are stored in the clear, shown by policy show, written to the audit chain, and replaced as a set each time ingest is turned on (a name may not start with GITHUB_; at most 50, values up to 1024 bytes). --splits-json takes rules that run a job as several shards, see Compatibility; a poll-config repo takes splits too. A poll-config repo takes the same as vars. Turntable’s own project sets TURNTABLE_CI=true, which is how the repository’s CI workflow turns off the jobs that need a docker daemon or service containers when Turntable runs it, and turns on the PGlite stand-in for its Postgres job. The poller reads the bindings at start, every minute, and when a signed webhook names a repo it does not know (it looks once, then polls). A repo in the static poll config wins over its binding. A repo bound to several projects is ingested into the first only. The poll config still needs at least one repo entry to run the poller at all, plus the token (tokenEnv) and limits, which the bound repos share.
Adding a second tenant to a running instance
The env bootstrap handles one org. For another, the instance administrator makes the org and its first token over REST, with no redeploy (see Instance administrator):
curl -sS -X POST "$TURNTABLE_URL/api/v1/instance/orgs" \
-H "authorization: Bearer $(cat "$TOKEN_FILE")" -H 'content-type: application/json' \
-d '{"slug":"acme","name":"Acme"}'
# the first token only: refused once the org has any active token. The secret is in the response once.
curl -sS -X POST "$TURNTABLE_URL/api/v1/instance/orgs/tokens" \
-H "authorization: Bearer $(cat "$TOKEN_FILE")" -H 'content-type: application/json' \
-d '{"target_org":"acme","name":"acme operator","role":"operator","expires_days":90}'Then add its projects as below. This is how a tenant is moved out of the bootstrap org before its GitHub App installation is claimed; the repo’s binding moves with move_repo_binding.
Moving a polled repo to another org
A repo is bound to one project on the whole instance, so a repo polled in one org (the bootstrap org, say) cannot simply be pointed at a project in another. Pointing the poll entry at the new project alone is not enough: the repo stays bound to the old one. The instance administrator moves the binding with move_repo_binding:
-
Create the target org, its project and its first token (
create_org,create_project,create_org_token), as above. -
Move the binding. The response names the poll entries that still point at the old project:
bash curl -sS -X POST "$TURNTABLE_URL/api/v1/instance/repo-bindings/move" \ -H "Authorization: Bearer $TURNTABLE_INSTANCE_TOKEN" -H "Content-Type: application/json" \ -d '{"owner":"acme","repo":"web","to_org":"acme","to_project":"web"}' -
Change the poll entry’s
organdproject(TURNTABLE_POLL_JSON) to the new ones and restart. Until then the poller skips that repo and logs one warning per interval: it makes no GitHub call and tries no bind. The poller’s record of seen shas follows the repo, so the first poll at the new project does not run the same head again, and a new sha creates exactly one run. -
Claim the installation into the new org (see claiming an installation). The installation sync adopts the moved binding, so checks are posted from then on. If the binding already has an installation, the move is refused unless that installation is mapped to the target org.
-
Pause the old project (
set_project_settingswithmax_concurrent0) once its queue has drained, or when it is no longer wanted.
Run history stays with the old project and is readable only in the old org. Attempts queued or running there when the binding moves are not touched: they finish in the old project. Only runs ingested after the move land in the new one. The move is audited in the system org’s chain and in both orgs’ chains, with the old and new org and project ids.
Moving a polled repo to the GitHub App
A repo ingested by polling before the App is installed gets checks as soon as the App is installed on it: the installation sync adopts its existing binding (same org, no installation yet) and keeps its project. A binding in another org, from another installation, or with a different GitHub repo id is a conflict and is not touched. See Moving a polled repo to the App.
Adding a second repo to a running instance
A repo is ingested into a project, and the poll config names that project, so the project must exist first. On an instance with no shell, the instance administrator makes it over REST (an instance token, see Instance administrator):
# 1. the project, in an existing org (a slug already used in the org is a conflict)
curl -sS -X POST "$TURNTABLE_URL/api/v1/instance/projects" \
-H "authorization: Bearer $(cat "$TOKEN_FILE")" -H 'content-type: application/json' \
-d '{"target_org":"local","slug":"dogfood","name":"Dogfood"}'
# 2. its sandbox snapshot and concurrency cap (both optional; null removes one)
curl -sS -X POST "$TURNTABLE_URL/api/v1/instance/project-settings" \
-H "authorization: Bearer $(cat "$TOKEN_FILE")" -H 'content-type: application/json' \
-d '{"target_org":"local","target_project":"dogfood","sandbox_snapshot":"daytona-large","max_concurrent":4}'- Add the repo to the poll config, into that project, with the non-secret
varsits workflow reads:
{
"repo": "owner/name",
"org": "local",
"project": "dogfood",
"workflow": ".github/workflows/ci.yml",
"defaultBranch": "main",
"prMode": "allowlist",
"authors": ["octocat"],
"vars": { "TURNTABLE_CI": "true" }
}The cap divides the instance’s sandboxes between projects: with a global cap of 10 and max_concurrent 4 on this project, the other projects of the org always have 6. A project cap can only lower the per-org cap (--org-cap, TURNTABLE_ORG_CAP), so that must be at least as high as the largest cap you set. The snapshot only changes where this project’s sandboxes start, and it is used for every trust class in the project, untrusted pull requests included, so never bake credentials or private code into it. max_concurrent: 0 pauses the project. See Providers for the order against size classes and the provider default.
A low-priority project
When the instance runs its own CI next to a customer’s, mark its project yield so its jobs wait for, and give way to, the customer’s. With the instance token:
curl -sS -X POST "$TURNTABLE_URL/api/v1/instance/settings" \
-H "authorization: Bearer $(cat "$TOKEN_FILE")" -H 'content-type: application/json' \
-d '{"key":"scheduling_class","value":"yield","target_org":"local","target_project":"dogfood"}'A normal job that waits at the global or org cap preempts the newest running yield job, which is requeued under a new attempt and starts over. Under the global cap this is cross-org, because yield is instance-wide: a yield project in org A can be preempted by normal work in org B. See Providers. There is no preemption limit by default. An operator can set preempt_max_per_job (with preempt_window_minutes, both instance settings) so that a job preempted that often is left alone until it finishes. That bounds wasted yield minutes but can make normal work wait for a capped yield job, so on a shared hosted instance enable it only with the affected tenants’ agreement. Also, and sandbox_usage with group_by: "project" reports each project’s preemptions and the minutes they wasted apart from useful minutes.
Sandbox sizes: set untrustedClass explicitly
If you map runs-on labels to sandbox sizes (see Sandbox size per job), set untrustedClass on any hosted or multi-tenant instance, and make it a small class. A run classified untrusted_pr (a fork or any other untrusted pull request) ignores the labels its workflow asks for and gets untrustedClass. When untrustedClass is unset it falls back to default, so on an instance whose default is large, a stranger’s code gets large sandboxes.
{
"classes": {
"small": { "cpus": 2, "memoryMb": 4096 },
"large": { "cpus": 4, "memoryMb": 8192, "snapshot": "daytona-large" }
},
"labels": { "ubuntu-latest-4-cores": "large" },
"default": "large",
"untrustedClass": "small"
}Here trusted jobs that name no mapped label get large, while every untrusted run gets small, whatever its labels say. Set it through TURNTABLE_SANDBOX_SIZES_JSON or TURNTABLE_SANDBOX_SIZES_FILE.
Trusted proxies
The webhook failure rate limit is keyed on the real client address. Name the proxies in front of the server, as addresses and CIDR ranges, in TURNTABLE_TRUSTED_PROXIES (for example 10.0.0.0/8,fd00::/8). The client is the right-most X-Forwarded-For hop that is not one of them, and the header is read only when the socket peer is itself trusted. With none configured the limiter keys on the socket peer, so a spoofed header gains nothing. A correctly signed delivery is never rate limited. TURNTABLE_TRUST_FORWARDED_FOR is no longer read.
Live verification runbook
Run this once, by hand, against live GitHub. The automated tests use a fake GitHub, so each step below checks what they cannot. Use a throwaway GitHub organization you own and a test Turntable org. Do not use a production App.
Before you start: an instance on a public https URL with TURNTABLE_MASTER_KEY_FILE set, TURNTABLE_CLAIM_INSTALLATIONS=1, TURNTABLE_TRUSTED_PROXIES naming your platform’s proxy range, and an org-level token with release_operator or admin.
1. Manifest flow
- Run
turntable github-app create --url <public url> --org <github org>, and open the printed loopback address. - Press the button and approve on GitHub. Expect a redirect back to the loopback page that reports success.
- Run
turntable github-app status. Expect the App listed with no secret in the output. - On GitHub, open the App settings. Check these: the permissions are the four in GitHub App, the events are
push,pull_requestandcheck_run, the webhook URL is<public url>/api/v1/webhooks/github, and the setup URL is<public url>/api/v1/github/setup. - With claim mode on, the manifest already turned on Request user authorization (OAuth) during installation. Check that it is on. Turn it on by hand only for an App created without claim mode.
- The loopback command always creates a private App. If other accounts will install it, choose Make public under Advanced.
2. Webhook delivery
- In the App’s Advanced tab, redeliver the
pingdelivery. Expect202in GitHub’s delivery log. - Send one delivery with a wrong signature, for example with
curland a made-upX-Hub-Signature-256. Expect401. - Repeat the bad delivery until you get
429. Then redeliver a real one from GitHub. Expect202: a correctly signed delivery is never rate limited.
3. Claim callback
Use two GitHub accounts: an admin of the test organization (A), and a member who is not an admin (B).
- Call
start_installation_claimwith the test org’s token and open the link as A, in a fresh browser profile. Expect a confirmation page naming the Turntable org. - Confirm. Install the App on the test organization. Expect a redirect back to the setup URL and a success page.
- Check that the installation and its repositories now appear as projects of that org, and that the org’s audit chain has a
claim_installationentry with A’s GitHub id and login. - Start a second claim for another Turntable org and open it as A. Complete it for the same installation. Expect a refusal: a held installation is never taken.
- Start a claim as org X, but open the link as B and install or configure the App. Expect a refusal (B is not an admin) and an audited failed attempt. The link must still work afterwards for A.
- Open a claim link, then paste it into a different browser profile and confirm there. Expect a refusal (no cookie).
- Trigger a push on a bound repository. Expect a delivery that is stored as processed, not ignored. Trigger one on a repository of an unclaimed installation. Expect it stored as ignored.
4. Secret rotation
- Run
turntable github-app rotate-webhook-secret. Expect success. - On GitHub, look at the App’s webhook settings. The secret there changed (GitHub shows it as set).
- Redeliver a recent delivery signed before the rotation. Expect
202: the old secret stays valid for 24 hours. - Push to a bound repository. Expect
202and a stored delivery. - Wait out the 24 hours and redeliver the old one. Expect
401. - Run the rotation once with GitHub unreachable or the App’s key revoked. Expect an error and no local change: the next real delivery still verifies.
Report back
Record the date, the App id, and the pass or fail of each numbered step in the tracking issue, without secrets or installation ids. Then remove the “Known gaps” entry below.
Known gaps
- The manifest flow (the local one and the hosted one), the claim flow’s OAuth exchange and secret rotation have been exercised against a fake GitHub only. Each needs one run against live GitHub.