Environment Variables
All Crewship configuration can be set via environment variables. These override values from the YAML config file. The mapping is defined inapplyEnvOverrides in internal/config/config.go.
Server
Native Craft edit lease
See the native Craft lease contract for admission and handoff.
Mooring session profile
See the session transport contract for the
current HTTP boundary and acceptance limitations.
IPC
Container
Runtime image pinning
Before starting a crew container, Crewship resolves the runtime image tag to an OCI manifest digest (a registryHEAD) and then pulls that digest, not the
tag. A tag can be repointed between the check and the fetch; a digest cannot.
The digest is recorded on the crew’s provisioning.step journal entry
(payload.digest, plus payload.pinned), stamped with the run’s trace_id,
so the audit trail can answer which image produced this run.
Read it back with:
provisioning.step payload, which crewship journal already returns.
Offline and air-gapped installs are unaffected. When the registry cannot be
reached at all, the digest lookup returns nothing and Crewship keeps using the
local copy exactly as before — it just logs the local digest alongside, so even
an offline run is attributable.
When the local image is provably stale. This is the case that changed.
Two different failures land a host in the same state — the registry answered
the digest check, and the tag the container will start from resolves to a
different manifest. That is provable drift, not a guess, so Crewship
refuses to start the container rather than silently running the wrong image.
CREWSHIP_ALLOW_STALE_RUNTIME_IMAGE=1 is the single host-wide opt-out for
both routes.
Route 1 — the pull failed. Reaching a pull with a local copy present means the
digest check succeeded and the local copy did not match it:
HEAD
generously and throttles blob pulls).
Route 2 — the pull succeeded but the tag could not be moved. A digest-pinned
pull leaves the image on disk unnamed, so Crewship re-creates the repo:tag
alias itself. If the daemon refuses that and an older copy of the tag is still
there, the tag keeps pointing at the old manifest and every downstream lookup —
ContainerCreate included — addresses the image by tag. Crewship re-reads the
tag before deciding, and refuses on the same terms:
docker tag that fixes it properly. Digests are abbreviated (sha256:aaaa…)
in the examples above for width — the real error prints them in full, and the
docker tag line it gives you is runnable as printed.
What the opt-out does and does not relax. With
CREWSHIP_ALLOW_STALE_RUNTIME_IMAGE=1 both routes proceed, log a warning naming
both digests, and journal the local digest — what actually ran — with
payload.pinned: false. The escape hatch relaxes execution only. It never
relaxes the audit record: a provisioning.step row never claims a digest that
did not run, opt-out or not.
One case is deliberately left alone: if the re-tag fails and the daemon answers
404 for the tag afterward, there is no stale image to run and no digest to
record. The provisioning.step row is still written — it just carries no
digest and pinned: false — and the daemon’s own error surfaces at container
create, which is where it is most legible.
A read-back that fails rather than answering 404 is not the same thing and is
not treated as one: a timeout or a busy daemon says nothing about what the tag
resolves to, so Crewship falls back on what it proved before the pull. If a
local copy was present then (which is what sent it to the pull in the first
place), the tag is still the stale one and the start is refused.
Locally built devcontainer cache images (crewship-cache:*) exist in no
registry and therefore have no digest. Their provisioning.step rows omit the
digest key entirely; their provenance is the base image recorded on the
build’s own steps.
Set by Crewship inside the container
These are not configuration — Crewship sets them on the crew container itself, and an agent (or apostCreateCommand) can read them.
Experimental fixed-operation broker launch environment
The isolatedbrokered-http-v1 prototype supplies these variables to the agent
process through its trusted private bootstrap. They are generated for each
attempt; operators do not configure them or create tokens themselves. Setting
these variables in the server environment does not enable the profile. The
prototype supports bounded, fixed HTTPS operations and remains separate from
production dispatch and general provider/model streaming.
Read by the sidecar inside the container
These are read by the sidecar process in the crew container, not bycrewshipd. They only take effect when they are present in the crew container’s environment (set by whatever launches the container — nothing inside the container can change them), and none of them is set by a normal deployment.
CREWSHIP_CONTAINER_PREFIX is essential for multi-instance deployments. Without it, multiple Crewship instances will create containers with colliding names like crewship-team-engineering.Storage
State
Public-facing URL
Origin enforcement (CORS / EnforceOrigin)
Rate limiting & proxy trust
Metrics
Webhooks / hooks (SSRF guard)
Profiling & observability
These are off by default and intended for operators debugging performance.Crash reporting (Sentry)
Email (password recovery)
Google sign-in compatibility settings (disabled)
The retained Google sign-in status endpoint always reports
enabled: false,
regardless of these settings. Credential-provider OAuth connections and the
Gemini grant-refresh settings below are separate features, not switches for
Crewship user sign-in.
Imported Gemini grant refresh
These live server-side settings configure refresh of imported Gemini CLI grants. They are separate from the disabled Crewship Google sign-in settings.Logging
CLI and runtime context
These names are used by CLI commands, test harnesses, or the agent runtime rather than by the server’s main YAML configuration. They are listed here so a deployment or script can distinguish an intentional context variable from a typo.Authentication
As of PR #446 (
internal/secrets), the three persisted secrets — ENCRYPTION_KEY, NEXTAUTH_SECRET, and CREWSHIP_ADMIN_TOKEN_HMAC_KEY (the managed list in internal/secrets/bootstrap.go) — are bootstrapped on first start: missing values are generated with crypto/rand, persisted atomically to <dataDir>/secrets.env at mode 0600, and re-exported into the process environment so existing os.Getenv call sites see them unchanged. Explicit env vars override the file; partial persistence is handled (one missing key is filled, the other valid keys are preserved). CREWSHIP_INTERNAL_TOKEN is handled separately — the config loader generates it per boot when unset and does not persist it, so it rotates on each restart. For clustered deployments, set all four explicitly via your secret manager.Auto-Derived Values
CREWSHIP_NEXTJS_URL: If not explicitly set, defaults tohttp://localhost:{CREWSHIP_PORT}. In single-binary mode, the internal resolver calls itself on the same port.CREWSHIP_INTERNAL_TOKEN: Generated fresh per boot by the config loader when unset; not persisted, so it rotates on restart. Pin it explicitly only for multi-instance IPC bus sharing.
Encryption
Composio integrations
Keeper (AI Security Gatekeeper)
Local models (coding agents)
LLM Proxy
Paymaster (Billing Modes)
These variables tag every cost-ledger row written from inside an agent run. The orchestrator sets them on the agent’s environment from the credential type before exec; the sidecar reads them once at startup and includes them on everyPOST /api/v1/internal/cost/record call.
Operators do not set these manually for normal use. They are propagated automatically based on the credential’s auth type (API key →
metered, OAuth/subscription → flat_rate). They are listed here only for sidecar-image authors and tooling that intercepts the orchestrator handoff.Ollama (Episodic Memory + Keeper)
Feature toggles & runtime tuning
Backup webhooks
Operational skip flags (dev / CI)
These bypass safety or convenience behaviours. Never set them in production.License
Seed Data
These variables are used by the./dev.sh seed command:
Container Runtime
The Docker provider checks
DOCKER_HOST first, then auto-detects from candidate socket paths.
Idle runtime retention and cache eviction
Both are off by default. They reclaim disk held by crews nobody is using; neither removes volumes or host data. Idle cache eviction keeps images selected by live crews in this installation; stopped runtimes are recreated when needed. Seedocs/specs/container-cleanup.md (section “Idle retention”) in the repository
for the exact rules.
Images are shared through the Docker daemon. On a host where several
installations share one daemon, eviction enabled on one of them can make
another lose a selected artifact: its database references are not visible.
Coordinate retention across those installations. Historical revision records
are not a backup of image bytes.
Devcontainer Cache GC
Crewship runs a background sweeper every 30 minutes that detects three kinds of leaks: temporary provisioning containers orphaned by acrewshipd crash
(matched by the crewship-provision-* name and the
crewship.temp=provision label — see
Devcontainers → Background GC
for why the name is the one that authorises deletion), unreferenced
crewship-cache:* images left behind when the process is killed between
docker commit and the database write that links the image to a crew, and
intermediate crewship-feat:* BuildKit feature images (per-feature layers
that are regenerable and never directly referenced by a crew row).
Temp containers older than one hour are always removed. Cache and feature
images are logged only by default; deletion must be explicitly enabled.
A 5-minute age floor protects images that were committed in the last few
minutes (closing the race between
docker commit and the DB update inside
Provision()), so enabling auto-delete is safe even on busy systems.
Leave
CREWSHIP_CACHE_GC_AUTODELETE unset on developer machines. Enable
it on long-running production hosts where reclaiming disk matters more
than preserving incidental cached images. Inspect the orphan list in the
logs first to verify nothing important would be removed.CLI client
These configure thecrewship CLI on a developer/operator machine (not the server). They override values in ~/.crewship/cli-config.yaml. Resolution order and parsing live in internal/cli/config.go.
Installer
Read byscripts/install.sh (the curl … | bash install path), not by the running server.
Complete Example
Validation
The config is validated at startup (Config.Validate). These constraints are enforced:
Private document engine
The document foundation is disabled by default.CREWSHIP_DOCUMENTS_ENABLED
enables its private Go persistence authority. Set
CREWSHIP_DOCUMENTS_AUTHORITY_SOCKET to the private authority socket path,
CREWSHIP_DOCUMENTS_SERVICE_SOCKET to the engine socket path, and
CREWSHIP_DOCUMENTS_SERVICE_TOKEN_FILE to the service credential file path.
Use distinct, clean absolute paths of at most 100 bytes. The credential file
must be a regular file with mode 0600; configure its path rather
than putting its contents into an environment variable. Invalid enabled
configuration or an authority startup failure prevents server startup.
CREWSHIP_DOCUMENTS_MAX_DOCUMENTS_PER_WORKSPACE limits stored documents per
workspace; zero selects the default of 128.
CREWSHIP_DOCUMENTS_MAX_OPERATIONS_PER_WINDOW limits new operations per document;
zero selects 10,000. CREWSHIP_DOCUMENTS_OPERATION_WINDOW_SECONDS selects the
rolling admission window; zero selects 600 seconds and the maximum is 86,400.
These limits preserve confirmed receipts and history. Exact retries retain their
original operation identity; a temporary admission refusal does not erase them.
Experimental offline workbook engine
CREWSHIP_GRIDCRAFT_ENABLED enables the experimental personal workbook API and
agent tools; default false. Only true or 1 enables it. Activation requires
independent qualification of a persistent operator-pinned worker. Set
CREWSHIP_GRIDCRAFT_SERVICE_SOCKET to its clean absolute private Unix socket
path and CREWSHIP_GRIDCRAFT_SERVICE_TOKEN_FILE to its regular mode-0600 secret
file. These paths must differ and fit within 100 bytes. The application never
launches containers or falls back to an unsandboxed executable.
CREWSHIP_GRIDCRAFT_EDITOR_ENABLED enables live workbook editing (editor
sessions, cell edits and the commits feed); default false, only true or 1
enables it, and it requires CREWSHIP_GRIDCRAFT_ENABLED. Each workspace must
also turn on the feature flag gridcraft_editor, which is off by default and
can be switched off again without a restart.
See workbook commands for scope and request contracts.
The worker process (crewship-gridcraft-worker, inside its own container)
reads its own limits; out-of-range values stop it at startup:
CREWSHIP_GRIDCRAFT_TEST_BARRIER_DIR and CREWSHIP_GRIDCRAFT_TEST_BARRIER_SLOT
exist only in test builds (build tag crewship_testbarrier): the private
directory for the commit barrier’s park/release files and the development slot
it is limited to. Release builds ignore both, and the release pipeline refuses
a binary that contains the barrier.
Embedded workbook editor origin
The browser workbook editor is third-party code. It runs only in a sandboxed iframe with an opaque origin, holds no Crewship credential and is served only from operator-pinned bundles. All of it is off by default. Zero-config default. With the editor enabled and noCREWSHIP_EDITOR_RUNTIME_ORIGIN, Crewship serves the editor on the Studio
origin under /_editor/b/<digest>/ (see Same-host mode).
No origin has to be configured: the editor follows the origin each browser
request reaches. No DNS record, certificate or extra proxy route is needed. A
dedicated origin is optional hardening on top.
At startup each allowlisted bundle is read once:
manifest.json must hash to
the pin and every file must match its manifest digest. The manifest is decoded
strictly: only the exact, case-sensitive keys files, source_commit and
toolchain, no duplicate keys at any level, string digests and nothing after
the object. A symlink as a bundle
file and paths that leave the bundle directory are refused; content is checked
by hash either way. A bundle that references the WebRTC API
(RTCPeerConnection, RTCDataChannel and the other RTC* transport
interfaces) in a script, wasm, HTML, JSON or SVG file is refused as well: see
the webrtc note below. A bundle that fails is not served and the error is logged.
Files are served from memory at /b/<digest>/<path>.
The editor document runs sandboxed: its policy ends in
sandbox allow-scripts, so it has an opaque origin. Even on a sibling
subdomain of Studio it cannot read or set cookies, use storage, navigate the top
window, open popups or submit forms. Because of the opaque origin, sources name
the editor origin explicitly rather than 'self'. Every request from that
document is cross-origin, so assets are sent with
Access-Control-Allow-Origin: * for CORS loads and
Cross-Origin-Resource-Policy: cross-origin for no-cors loads such as a
stylesheet <link>, an <img> or a classic <script src>; never with
credentials (the bundle is public, constant code). Inline scripts in index.html, such as a Trunk module
bootstrap, are allowed only by their SHA-256 hash, computed from the verified
file; there is no 'unsafe-inline' script. Every response carries:
connect-src does not govern, and the iframe
sandbox does not block RTCPeerConnection. The policy carries
webrtc 'block', but Chromium does not enforce that directive yet, so a
qualified bundle must not use WebRTC; bundles that name its API are refused at
load. This is a qualification check against a supplier bundle that uses
WebRTC, not a boundary against deliberately obfuscated code.
Keep Cross-Origin-Resource-Policy: same-origin on the document: under
Studio’s Cross-Origin-Embedder-Policy: credentialless it means the editor can
be framed only through a credentialless iframe.
The host iframe must be exactly
<iframe sandbox="allow-scripts" credentialless referrerpolicy="no-referrer" …>,
never with allow-same-origin. The server’s sandbox applies to the editor
document only; if the frame navigates itself to another URL, only the iframe
attribute applies. When Studio’s frame-src includes Studio’s own origin
(for example a same-origin Page runtime), allow-same-origin would let such a
navigation land in the Studio origin and read the host page. 'wasm-unsafe-eval' is granted
only on the editor origin. The editor never sets cookies; a dedicated host
never reads them, and in same-host mode only their names are read.
While the editor is enabled, Studio adds the editor origin to frame-src of
every UI document. The UI routes on the client, so a policy scoped to one route
would not follow navigation. Only this one origin is added, and frame-src
controls what Studio frames, not who may frame Studio.
Same-host mode
WithoutCREWSHIP_EDITOR_RUNTIME_ORIGIN, an enabled editor is served at
<Studio origin>/_editor/b/<digest>/<path> with the headers above, where every
<editor origin> source is the bundle path <Studio origin>/_editor/b/, never
the bare Studio origin. Studio’s frame-src likewise names only that path.
The host page frames the editor by that path (/_editor/b/<digest>/index.html),
resolved against its own origin.
Which Studio origin. Nothing needs to be configured. The <Studio origin>
of each response is the one the request reached: its Host header, and
https when the connection is TLS or a trusted proxy
(CREWSHIP_TRUSTED_PROXY_CIDRS, loopback by default) sends
X-Forwarded-Proto: https, otherwise http. A CSP source with http also
matches the https URL of the same host, so a proxy that ends TLS without
being trusted still gets a working policy. A Host that a CSP source cannot
name (no valid DNS name or IPv4 address, an IPv6 literal, a bad port) gets
400 on the editor path and no editor in frame-src; requests on the Page
runtime origin get 421. Studio documents whose policy names the request’s
origin are sent with private added to their Cache-Control (HTML keeps its
no-cache, must-revalidate), so no shared cache serves one host’s policy to
another; the editor’s own responses are no-store or private already.
When CREWSHIP_PAGE_STUDIO_ORIGIN is set, it is the only origin the editor
answers on: a request that reaches Crewship under another Host gets 421 on
the editor path and no editor in frame-src (fail closed). Set it only if the
proxy forwards the original Host; CREWSHIP_NEXTJS_URL plays no part.
Isolation then rests on:
- The opaque origin. The server’s
sandbox allow-scriptsapplies whatever the iframe says, so the editor cannot read or set Studio cookies, use storage or service workers, open popups or navigate the top window. - Path-scoped sources. The editor cannot fetch, connect to or load
anything on the Studio origin outside
/_editor/b/, so the Studio API is unreachable. Because Studio frames only that path, a frame that navigates itself cannot land on a Studio document, even if the host page drops thesandboxattribute or addsallow-same-origin, provided nothing in front of Crewship redirects or rewrites/_editor/(see the proxy requirements below). The mandatory iframe attributes keep the frame opaque either way. - One route for the prefix. Every request whose path starts with
/_editor(any case, percent-encoded or with dot segments) is answered by the editor handler and never reaches the API or the UI. Nothing under it redirects, because a browser drops the path of a CSP source after a redirect. - Requests only a credentialless, sandboxed frame makes. The editor
answers
403to any request that carries one of Crewship’s own cookies (authjs.*andnext-auth.*session, refresh and CSRF cookies, with or without the__Secure-/__Host-prefix, and the UI’ssidebar_state), because an iframe withoutcredentiallesssends them. This holds even where Studio’sCross-Origin-Embedder-Policyis missing. Other cookies are ignored: a load balancer or CDN may set its ownSameSite=Nonecookie (stickiness, bot management) on editor responses, and the credentialless frame’s temporary cookie jar, which the whole Studio tab shares, sends it back when the editor is reopened.index.htmlis served only withSec-Fetch-Dest: iframe. Other files are served only withSec-Fetch-Site: cross-site, which is what the opaque-origin document sends, and never as a document. A Studio page therefore cannot load the third-party code into the Studio origin. Responses carryVary: Cookie, Sec-Fetch-Site, Sec-Fetch-Dest, and assets areCache-Control: private, so a shared cache that ignoresVarycannot replay a frame’s response to a Studio page. Every editor response sends Studio’s own HSTS value, so loading the editor never weakens the host’s stored HSTS policy.
CREWSHIP_PAGE_STUDIO_ORIGIN must be one of those. Same-host mode is refused
at startup when the configured Studio origin is the Page runtime origin,
because Studio would then frame its own whole origin, and when
CREWSHIP_ALLOWED_ORIGINS contains null; without a configured origin the
Page runtime host is refused per request. The Page runtime origin
(CREWSHIP_PAGE_RUNTIME_ORIGIN) must be a host that serves only the Page
runtime, never the Studio UI: Studio lists that whole origin in frame-src,
so if it also served Studio documents, a frame that navigates itself could
land on one. The configuration compares origins, not what a host serves; this
is on the operator.
Proxy requirements. The path-scoped sources and frame-src hold only
while the browser receives /_editor/ responses from Crewship directly. A
browser drops the path of a CSP source after a redirect, and a proxy that
decodes %2F and resolves .. can route a path under the prefix to the API
or the UI. A reverse proxy, CDN or load balancer in front of Crewship must
therefore:
- pass
/_editor/to Crewship with the path unchanged: no percent-decoding, no dot-segment or slash normalisation (nginx:proxy_pass http://upstream;without a URI part, notproxy_pass http://upstream/;); - never redirect under
/_editor/(no trailing-slash or canonical-host rules, no HTTP-to-HTTPS redirect for that prefix on an HTTPS listener); - put no SSO or authentication gate on
/_editor/. The editor frame is credentialless and always unauthenticated; the bundle is public, constant code; - forward the original
Hostheader (Caddy and Traefik do by default; nginx:proxy_set_header Host $host;, Apache:ProxyPreserveHost On), as the rest of Crewship already needs for its same-origin check of sign-in and other state-changing requests; - forward the
CookieandSec-Fetch-*request headers and pass theX-Crewship-Routeresponse header through. Setting its own cookies on these responses is harmless but unnecessary; - not let a shared cache override
Cache-Controlfor/_editor/(“cache everything” rules).
CREWSHIP_PAGE_STUDIO_ORIGIN when set,
and otherwise learns the public Studio origin from signed-in browser requests:
the Origin or Referer of a same-origin request that a sign-in session
authenticated (never an anonymous request or a CLI token). Those are plain
headers to a script holding a session, so learning is bounded:
- only
httpsorigins are learned; plainhttponly forlocalhostand loopback addresses, and those only while the server itself listens on loopback (CREWSHIP_HOST=127.0.0.1, development). IP literals that are link-local (including cloud metadata169.254.169.254), unspecified, multicast or broadcast are never learned, and the self-check refuses to connect to such addresses whatever name resolved to them; - each user teaches at most one origin, at most four are checked, and an origin no signed-in request has used for 24 hours is forgotten. When all four are taken, an instance administrator’s origin still gets in, replacing the least recently used origin no administrator used, so other users can never push out the origin administrators use;
- a browser origin whose host differs from the
HostCrewship received (a proxy that rewritesHost) is reported, never checked, and takes no slot; - a learned origin’s state applies to that exact origin only (scheme, host
and port). The one exception fails closed: a request Crewship sees as
httpbecause TLS ended at a proxy it does not trust also takes the state ofhttpson the same host.
pending, never passed. Then the server requests
/_editor/ variants through that public URL: soon after an origin is learned,
hourly while it passes and every five minutes while it does not. Browsers
resolve .., %2e%2e and .%2e segments before sending a request, so only
spellings that reach a server unchanged are probed (..%2f, ..%5c). Every
Crewship response in same-host mode carries X-Crewship-Route (editor or
app), so a path under the prefix that ends up elsewhere in Crewship is
recognised positively; a refusal in front of Crewship, whatever its headers,
reached nothing and is fine. If a probe is redirected, Crewship answers a
traversal outside the editor, or the proxy strips X-Crewship-Route (then the
check cannot tell where a traversal ends up), and a repeat 30 seconds later
confirms it, the server disables the editor on that origin: bundle files
answer 503, the UI and API are unaffected, and the log names the problem
and the user whose request taught the origin. After three consecutive passing
checks (about 15 minutes after the proxy is fixed or a maintenance redirect
ends) the editor is enabled again by itself. The check also reports, without
disabling anything, a prefix that does not reach the editor and a proxy that
rewrites Host (the browser’s origin and the Host Crewship sees differ).
Many deployments cannot reach their own public name from inside; then the
self-check decides nothing.
The public /healthz reports only a coarse workbook_editor state: ok,
pending, failed or disabled. It counts only the configured origin and
origins an instance administrator’s session used, so other users cannot
change it; until an administrator has used Studio it stays pending.
Origins, causes, the problems found and who taught each origin are in the
log and, for instance administrators, in
crewship admin instance workbook-editor.
crewship doctor runs the same check from
the machine it runs on, through the proxy a browser uses. Run it from outside
after any proxy change.
To check a deployment by hand:
/_editor/* is
proxied to the backend like /api/*. That dev server sends Studio pages
without Crewship’s security headers (no CSP, no COEP), so neither the
path-scoped frame-src nor the browser’s COEP check applies there. It is not a
valid target for accepting the editor isolation; use the UI served by the
Crewship server.
A dedicated origin adds a second, independent boundary: a real origin, which
on a different site also means a separate browser process. Configure one where
the deployment can provide it. A sibling subdomain needs
CREWSHIP_EDITOR_RUNTIME_DEVELOPMENT_SAME_SITE. Crewship does not derive an
editor subdomain on its own, because it cannot tell whether DNS, the
certificate and the proxy cover that name.
Diff preview computation
These limits apply to routine-version and consolidation previews in one server process. Environment overrides YAML; restart to apply changes. Zero selects the defaults below. Negative, nonnumeric or out-of-range values fail configuration validation. Raising limits permits more computation; these are not hard CPU timeouts or an RSS ceiling.
The byte budget covers both raw version definitions together and both
pretty-printed matcher inputs together. Consolidation reads are individually
bounded before checking the pair and the proposed merged result. The existing
absolute 8 MiB per-file ceiling remains in force. The line budget counts exactly
the matcher’s newline-separated elements, including a final empty element after
a newline. Output is additionally capped at four times the input-byte budget
plus 128 KiB. An identical version hash returns its existing cheap response.
Above budget, previews return 413 with an explicit too-large message. If both
slots are occupied, they immediately return 429 and
Retry-After: 1; there is no
waiting queue. A canceled caller does not release a slot while synchronous
computation is still running. Limits are per process, not shared across replicas.