Configuration reference¶
Every environment variable a host reads, by host. Each host reads its settings
once, when it starts, and refuses to start on invalid, incoherent or retired
configuration with a message naming the variable. Nothing loads .env files:
set variables in the service definition (Compose environment:) or the process
environment. tests/unit/test_settings_contract.py fails when code reads a
variable missing from this page, or this page lists one that code does not read.
Sandbox pools, the host sandbox budget and the host maximum sandbox lifetime
(general.running_timeout) are not environment variables: they live in the
YAML file named by SANDBOX_CONFIG_FILE
(see Sandbox ownership
and Sandbox lifetime). Each host
validates that file when it starts: running_timeout must be an integer of at
least 92 s (one 30 s process), and the API also refuses a value below 100 s, the
lifetime deliberate execution needs. Definitions whose
execution budget exceeds it are
refused at validation and acceptance (EXECUTION_BUDGET_EXCEEDED).
Optional providers stay lazy: the fixture store and the AI provider are first
contacted by the first grading that needs them
(Host capabilities).
Check a configuration without starting the service, exactly as startup validates it (no database, Docker or network access):
docker compose run --rm --no-deps api python -m web.main --check
API service¶
web.core.config.Settings plus the execution providers it composes. Variables
marked required have no working default for a deployment.
| Variable | Default | Meaning |
|---|---|---|
DATABASE_URL |
local development URL | Required. SQLAlchemy async URL of the PostgreSQL database, also used by alembic and python -m web.database.schema. |
DATABASE_ECHO |
false |
Log every SQL statement (true/false). |
DATABASE_POOL_SIZE |
10 |
Connections kept per API process. |
DATABASE_MAX_OVERFLOW |
20 |
Extra connections beyond the pool (may be 0). |
DATABASE_POOL_TIMEOUT |
30 |
Seconds to wait for a pooled connection. |
DATABASE_POOL_RECYCLE |
3600 |
Seconds before a connection is replaced. |
AUTOGRADER_INTEGRATION_TOKEN |
empty | Required. Bearer token of the integration principal. Unset, protected routes answer 503 and /ready reports not ready (AUTH.md). |
AUTOGRADER_ATTESTATION_TOKENS |
empty | name=token,... producer credentials limited to publishing external results. |
WEB_OUTCOME_RECEIPT_DIR |
data/unpublished-outcomes |
Persistent. Directory of finalized outcomes not yet published to the database; relative to the working directory (/app in the image). Mount it on a volume (Durable jobs). |
WEB_WORKER_COUNT |
2 |
Grading workers per API process. |
WEB_LEASE_SECONDS |
60 |
Lease of a claimed job; renewed every third. |
WEB_MAX_ATTEMPTS |
3 |
Attempts per submission, interrupted or ended by a retryable failure; then the last failure (or RECOVERY_EXHAUSTED) is published (execution retry). |
WEB_RETRY_SECONDS |
30 |
Backoff before the attempt after a retryable failure; doubles with each attempt, at most one hour. |
WEB_POLL_SECONDS |
1 |
Idle worker polling interval. |
SANDBOX_MODE |
local |
local: the API process owns its sandboxes through the Docker socket (development and tests). remote: sandboxes come from the private sandbox manager (the supported deployment, see Deployment). |
SANDBOX_API_URL |
http://localhost:8001 |
Sandbox manager URL (remote). |
SANDBOX_API_TOKEN |
empty | Sandbox manager bearer token (remote); the same value as the manager's. |
SANDBOX_CONFIG_FILE |
sandbox_config.yml |
Sandbox runtime (general.runtime), budget, pools, runtime images and host maximum lifetime; relative paths resolve from the project root. Validated at startup in both modes for general.running_timeout (in remote mode keep it identical to the sandbox manager's). In local mode the API also starts its sandbox manager at startup, which fails when Docker does not offer the runtime (environments). Missing, budgets are checked only at acquisition. |
EXTERNAL_ASSETS_BUCKET_NAME |
unset | S3 bucket holding definition fixtures. Unset, the host has no fixture store and fixture assignments fail with the non-retryable FIXTURE_PROVIDER_UNAVAILABLE, as they do when the store answers that the bucket is missing or access is denied. |
S3_ENDPOINT_URL |
AWS | S3-compatible endpoint. Setting it without a bucket stops startup. |
AWS_REGION |
us-east-1 |
Region of the fixture bucket and of the AI secret. |
AWS_ACCESS_KEY_ID |
SDK default chain | Fixture store credential; set together with the secret key or neither. |
AWS_SECRET_ACCESS_KEY |
SDK default chain | Fixture store credential. |
OPENAI_API_KEY |
unset | Key of the AI assessment provider. |
AUTOGRADER_AI_MODEL |
o4-mini-2025-04-16 |
AI assessment model. |
ENVIRONMENT |
unset | production reads the AI key from AWS Secrets Manager when OPENAI_API_KEY is unset. |
AUTOGRADER_AI_SECRET_NAME |
AUTOGRADER_OPENAI_KEY |
Secrets Manager entry (ENVIRONMENT=production). |
JSON_LOGS |
false |
JSON log lines (true in production). |
LOG_LEVEL |
INFO |
DEBUG, INFO, WARNING, ERROR or CRITICAL. |
SERVICE_NAME |
autograder-api |
service field of log lines. |
APP_ENV |
local |
env field of log lines. |
OTEL_EXPORTER_OTLP_ENDPOINT |
unset | OTLP/HTTP collector base URL (http://alloy:4318). Unset, nothing is traced (traces). |
Booleans accept true/false, 1/0 and yes/no; anything else stops
startup, as do non-numeric numbers and out-of-range values.
Sandbox manager¶
The private control API (sandbox_manager.api.ControlSettings), one per Docker
host (Sandbox ownership).
| Variable | Default | Meaning |
|---|---|---|
SANDBOX_API_TOKEN |
unset | Required. Bearer token every client must send. |
SANDBOX_API_ALLOW_UNAUTHENTICATED |
false |
Run without a token. Local development only. |
SANDBOX_CONFIG_FILE |
sandbox_config.yml |
Sandbox runtime (general.runtime), budget, pools and runtime images; startup fails when Docker does not offer the runtime (environments). |
SANDBOX_HANDLE_TTL_SECONDS |
600 |
Idle time before a handle expires. |
SANDBOX_HANDLE_TOMBSTONE_SECONDS |
3600 |
How long closed handles are remembered. |
WEB_CONCURRENCY |
1 |
Must be 1: handles live in process memory (Uvicorn also reads it). |
SANDBOX_HOST |
127.0.0.1 |
Bind address of python -m sandbox_manager. The image's command binds 0.0.0.0:8001. |
SANDBOX_PORT |
8001 |
Port of python -m sandbox_manager. |
JSON_LOGS |
false |
JSON log lines (true in production). |
LOG_LEVEL |
INFO |
DEBUG, INFO, WARNING, ERROR or CRITICAL. |
SERVICE_NAME |
autograder-sandbox-manager |
service field of log lines. |
APP_ENV |
local |
env field of log lines. |
OTEL_EXPORTER_OTLP_ENDPOINT |
unset | OTLP/HTTP collector base URL (http://alloy:4318). Unset, nothing is traced (traces). |
Logs and traces¶
Both services, the API and the sandbox manager, log and trace the same way.
Log lines¶
Both services write one log line per record to stdout, in the same format. With
JSON_LOGS=true each line is a JSON object with timestamp, level, logger,
message, service, env and request_id (- outside a request), plus
exception when one was raised. trace_id and span_id appear on lines
written while a span context is active (the text format shows trace_id after
the request id); a trace backend holds the trace only when its span was
sampled. attempt_id appears on the API's lines of a grading attempt. Each
HTTP request gets one http_request_completed (or http_request_failed) line
with method, path, status and duration_ms. path is the matched route
template (/sandboxes/{sandbox_id}/process), or <unmatched> when no route
matched; the raw path, the query string, headers and the client address are
never logged, and Uvicorn's own access line is turned off. A /metrics
response below 400 (a Prometheus scrape, every few seconds) logs its line at
DEBUG; any other status, and a raised error, stay at INFO or above. A
request keeps a well-formed incoming X-Request-ID ([A-Za-z0-9._:-], at most
128 characters) or gets a new one, and the response echoes it. The API forwards
it to the sandbox manager.
Grading attempts. The API records the id of the request that accepted a
submission, and its grading worker uses that id as the request id of every
attempt, in both services. So request_id groups a submission's acceptance
and all of its attempts, retries included. To isolate one attempt, use
attempt_id (API lines) or trace_id (both services; each attempt is its own
trace, different from the accepting request's). A submission accepted before
the id was recorded (migration 012) uses its attempt id as the request id.
Traces¶
Setting OTEL_EXPORTER_OTLP_ENDPOINT turns on OpenTelemetry tracing in that
service: spans are batched in the background and sent over OTLP/HTTP
(protobuf) to <endpoint>/v1/traces; a slow or unreachable collector drops
spans and never delays a request. Unset, no instrumentation is installed. The
standard SDK variables apply as well, among them OTEL_RESOURCE_ATTRIBUTES
(for example deployment.environment.name=production; a service.name set
there, like OTEL_SERVICE_NAME, replaces SERVICE_NAME), OTEL_TRACES_SAMPLER
(default parentbased_always_on: everything is traced, and an incoming
traceparent's sampling decision is kept) and OTEL_EXPORTER_OTLP_HEADERS.
- Both services continue an incoming W3C
traceparent, and the API sends its own to the sandbox manager, so one request is one trace across both. Only W3C trace context is propagated: incomingbaggageis ignored. The API trusts its callers'traceparent, like the rest of its private interface. /health,/readyand/metricsare never traced.- The API traces database statements (with placeholders, never the bound values) and AI provider calls (without bodies), only inside a request or a grading attempt: the idle worker's polling produces no traces.
- Each grading attempt is its own trace, rooted at a
grading.attemptspan; its sandbox calls continue the attempt's trace. When the request that accepted the submission was sampled, the API stored its span'straceparent(migration012) and the attempt's span links to it; the storedrequest_idjoins the attempt's log lines to that request. - No span carries a raw path, query string, full URL, client address, or
exception message or stack trace: server spans keep the route template
(
/sandboxes/{sandbox_id}/process), and errors keep their type only. The log line with the sametrace_idhas the details.
GitHub Action¶
The Action is configured through its inputs
(configuration). The runner provides the
GITHUB_*/RUNNER_* variables; the others reach the Action only through a
workflow's env:.
The Action has no SANDBOX_* settings: it runs each execution in one sandbox
on the runner's own Docker, under runc, from the runtime images its
sandbox_config.yml pins (Requirements).
| Variable | Default | Meaning |
|---|---|---|
GITHUB_WORKSPACE |
. |
Base of relative input paths. |
GITHUB_OUTPUT |
unset | Step outputs file. |
GITHUB_STEP_SUMMARY |
unset | Job summary file. |
GITHUB_ACTIONS |
unset | Must be true to publish. |
GITHUB_EVENT_NAME |
unset | Trusted-event check and provenance. |
GITHUB_EVENT_PATH |
unset | Event payload, for provenance. |
GITHUB_REPOSITORY |
unset | Default submitter name and provenance. |
GITHUB_REPOSITORY_ID |
unset | Default submitter ID and provenance. |
GITHUB_REF |
unset | Provenance. |
GITHUB_SHA |
unset | Provenance. |
GITHUB_RUN_ID |
unset | Provenance. |
GITHUB_RUN_ATTEMPT |
unset | Provenance. |
GITHUB_WORKFLOW_REF |
unset | Provenance. |
GITHUB_ACTOR |
unset | Provenance (never the submitter). |
GITHUB_TRIGGERING_ACTOR |
unset | Provenance. |
RUNNER_ENVIRONMENT |
unset | github-hosted unless trusted-self-hosted-runner is set (trust). |
EXTERNAL_ASSETS_BUCKET_NAME |
unset | As for the API. |
S3_ENDPOINT_URL |
AWS | As for the API. |
AWS_REGION |
us-east-1 |
As for the API. |
AWS_ACCESS_KEY_ID |
SDK default chain | As for the API. |
AWS_SECRET_ACCESS_KEY |
SDK default chain | As for the API. |
OPENAI_API_KEY |
unset | As for the API. |
AUTOGRADER_AI_MODEL |
o4-mini-2025-04-16 |
As for the API. |
ENVIRONMENT |
unset | As for the API. |
AUTOGRADER_AI_SECRET_NAME |
AUTOGRADER_OPENAI_KEY |
As for the API. |
Retired variables¶
A host refuses to start while one of these is set to a non-empty value, and names its replacement. Remove them from service definitions.
| Variable | Host | Replacement |
|---|---|---|
SANDBOX_POOL_SIZE |
API | general.max_sandboxes (budget) and general.pool_size (warm containers) in sandbox_config.yml. |
API_HOST |
API | Never read: the image serves on 0.0.0.0:8000; choose the published address in Compose ports. |
API_PORT |
API | As API_HOST. |
API_WORKERS |
API | One API process per container; scale grading with WEB_WORKER_COUNT. |
UPSTASH_REDIS_URL |
API | None: outcomes are stored in PostgreSQL. |
UPSTASH_REDIS_TOKEN |
API | None. |
CRITERIA_ASSETS_BUCKET_NAME |
API | EXTERNAL_ASSETS_BUCKET_NAME. |
AWS_ACCESS_ID |
API | AWS_ACCESS_KEY_ID. |
SANDBOX_MAX_HANDLES |
Sandbox manager | general.max_sandboxes bounds open handles. |