Terminal outcomes v1¶
autograder.models.contracts.outcome defines the shared HTTP, Python, and Action
artifact contract. Its JSON Schema is generated by outcome_json_schema();
validate_outcome() enforces the additional arithmetic and semantic invariants.
Validation is required before external ingestion and persistence. One terminal
snapshot can be serialized and delivered repeatedly without evaluating again.
The version (schema_version: "1.0") and discriminator (status) are required
on the wire. Timestamps require RFC3339 text with offsets; numeric Unix epochs
and date-only strings are rejected. The discriminator is status: completed requires a finite numeric score in
[0, 100], a typed tree, and a null error; failed requires null score and
tree and a structured error. Booleans and numeric strings are not scores.
Feedback and comparison independently carry disabled, completed, or failed
status. Completed enrichment has content and no error; failed enrichment has an
error and no content. Disabled enrichment has neither. A grading failure cannot
claim completed enrichment.
Every outcome identifies its execution and exact normalized definition through
execution_id and provenance. Error correlation IDs equal execution_id.
started_at and finished_at have explicit UTC offsets and serialize as UTC;
duration_ms is a nonnegative integer measured using a monotonic clock, frozen at
finalization, including engine resource cleanup. It excludes adapter queueing,
persistence, and publication. Internal
pipeline diagnostics are not public result fields.
Error codes are one closed vocabulary, OUTCOME_ERROR_CODES in
autograder.models.contracts.outcome; the terminal-outcome schema and OpenAPI
publish it as an enum, and every code below appears in it. Engine codes
(ENGINE_ERROR_CODES) are the only ones an evaluator or provider may raise as
EvaluationError; an unpublished code is a programming error reported as
EXECUTION_ERROR. Host-only codes (HOST_ERROR_CODES) are recorded by an adapter
for work the engine never finalized. EXECUTION_ERROR is the single code for an
unexpected failure in the engine and in every host.
| Trigger | Grading outcome | Error category / code |
|---|---|---|
| An assessed criterion genuinely scores zero | Completed, score 0 | No top-level error |
| Student compilation/runtime failure or student execution timeout reported by an I/O evaluator | Completed, criterion scores 0 | No top-level error |
Submission exhausts the sandbox's memory or process limit (SandboxExhausted) |
Completed; that criterion and every later one in the sandbox score 0, the same under gVisor and runc | No top-level error |
Workspace program (./a.out) missing or not executable |
Completed, criterion scores 0 | No top-level error |
| Expected artifact missing, or a symbolic link (or reached through one) | Completed, criterion scores 0 | No top-level error |
| Required preparation or assessment file missing | Failed, no score | submission / REQUIRED_FILE_MISSING |
| Preparation command fails because the submission does not satisfy it | Failed, no score | submission / PREPARATION_FAILED |
| Language omitted for a multilingual definition or disallowed language selected | Failed, no score | submission / LANGUAGE_REQUIRED or LANGUAGE_NOT_ALLOWED |
| Criterion file parameters conflict with its targets, or a target is outside the evaluation scope | Failed, no score | submission / FILE_TARGET_CONFLICT |
| A criterion target has a file type its evaluator does not accept | Failed, no score | submission / UNSUPPORTED_FILE_TYPE |
| A single-file evaluator matches several files without an explicit target | Failed, no score | submission / AMBIGUOUS_FILE_TARGET |
| AI criterion identities are not unique | Failed, no score | definition / INVALID_DEFINITION |
| Program command is malformed (reached only outside a compiled plan) | Failed, no score | definition / INVALID_COMMAND |
| No program command is defined for the selected language | Failed, no score | submission / MISSING_LANGUAGE_COMMAND |
| Required sandbox cannot be provisioned (Docker or the sandbox service unreachable or failing), or no sandbox budget slot frees up within the grading wait (retryable) | Failed, no score | capability / CAPABILITY_UNAVAILABLE |
| The host has no runtime for the selected language, or the sandbox service refuses the host's token (not retryable: an operator must act) | Failed, no score | capability / CAPABILITY_UNAVAILABLE |
| Host cannot start and reach an assessed server | Failed, no score | capability / SERVER_CAPABILITY_UNAVAILABLE |
Sandbox system/transport or artifact extraction failure, or a host/operator that stopped or removed the sandbox (its lifetime passed, docker kill/rm) |
Failed, no score, retryable | capability / SANDBOX_ERROR |
The definition's execution budget (its declared process deadlines) needs a longer session than the host grants (running_timeout); refused before any code runs, and by HTTP hosts at validation and acceptance (422) |
Failed, no score | capability / EXECUTION_BUDGET_EXCEEDED |
Runtime command (python3) cannot be started |
Failed, no score | capability / PROCESS_START_FAILED |
| Fixture preparation fails (missing reference: not retryable; transport or other store failure: retryable) | Failed, no score | capability / PREPARATION_ERROR |
| Required fixture provider is not supplied by the host, or its store refuses the bucket or the credentials (missing bucket, access denied; not retryable) | Failed, no score | capability / FIXTURE_PROVIDER_UNAVAILABLE |
| Required structural analysis unavailable | Failed, no score | capability / CAPABILITY_UNAVAILABLE |
| Provider initialization fails (not cached; the next grading tries again), no provider is supplied, or the provider refuses the credential, the access or the model (HTTP 401/403/404; not retryable) | Failed, no score | provider / PROVIDER_UNAVAILABLE |
| Provider request fails (one request): transport failure, deadline expiring, HTTP 408/409/429 or 5xx (retryable); any other 4xx answer, such as an input over the model's context (not retryable) | Failed, no score | provider / PROVIDER_ERROR |
| Missing required AI assessment | Failed, no score | provider / MISSING_EVALUATOR_RESULT |
| Duplicate, unknown, or invalid provider assessment | Failed, no score | provider / INVALID_EVALUATOR_RESULT |
| Evaluator returns an invalid numeric grade | Failed, no score | internal / INVALID_EVALUATOR_RESULT |
| Unexpected exception in the engine or a host's grading call | Failed, no score | internal / EXECUTION_ERROR |
| Optional focus or feedback fails | Completed, original grade preserved | feedback.error / FEEDBACK_ERROR |
| Owned execution session cannot be closed | Outcome unchanged | Diagnostic observation only / CLEANUP_ERROR |
| HTTP: interrupted work exhausts its recovery attempts (host-only) | Failed, no score | internal / RECOVERY_EXHAUSTED |
| HTTP: an attempt passes its deadline (session lifetime from the grant + provider deadline per AI call + margin, see JOBS.md); its lease is not renewed (host-only) | Failed, no score, retryable | capability / ATTEMPT_DEADLINE_EXCEEDED |
| HTTP: unfinished historical submission lacks replayable input (host-only projection) | Failed, no score | internal / RECOVERY_INPUT_UNAVAILABLE |
| HTTP: historical failure predates the verified outcome contract (host-only projection) | Failed, no score | internal / LEGACY_UNVERIFIED |
| Feedback disabled (even if feedback services would fail) | Completed; no focus or report work | feedback.status = disabled |
| Externally attested comparison enrichment fails | Completed, original grade preserved | host-attested comparison.error (published codes only) |
| On-demand baseline comparison cannot be computed | Stored outcomes unchanged | HTTP 409/422 response only (see below) |
| Persistence/publication fails after finalization | Original artifact remains completed or failed | Adapter delivery failure, outside the grading outcome |
There is no partial grading policy: every configured evaluator is required,
including zero-weight criteria. A required evaluator failure makes the entire
numeric grade unauthoritative. Student timeout is determined by a sandbox's
explicit TIMEOUT assessment response; an exception while communicating with
the sandbox is an infrastructure failure. Who ended a sandbox is decided from
host-side evidence, never from an exit code (PROCESSES.md),
and the submission cannot signal or starve the control processes, so it cannot
turn an assessed result into a retryable failure. API evaluators assess returned HTTP
status/content; inability to obtain a response is a capability failure. These
conservative classifications avoid claiming that unavailable infrastructure
proved student code incorrect.
retryable: true means the cause can pass without an operator acting (an
outage, a restart, saturation, a deadline, nondeterministic provider output), so
grading the same input again may succeed. A deterministic misconfiguration (a
missing bucket, a refused credential, a runtime the host does not have) is never
retryable. The HTTP host consumes the flag: a retryable failure of accepted work
is graded again within its attempt budget and published only on the last attempt
(execution retry); the engine itself never retries.
A published HTTP outcome with retryable: true therefore means the host's retries
are exhausted: an integrator should not resubmit it in a loop.
Public errors expose stable codes, messages, categories
(definition, submission, capability, provider, internal), retryability,
and correlation IDs. capability, provider, internal and definition errors
carry fixed safe engine messages; raw exceptions, provider responses and internal
step names remain in host-controlled diagnostics/logs. submission errors
explain themselves to the student instead (see Explained submission
failures). Authenticated external hosts may
attest their own safe messages using the published codes; that attestation does
not prove the local server executed the grade.
Explained submission failures¶
A submission the engine cannot grade because of the submission itself stays a
failed grading: the categories, codes, retryable, null score and tree and
the matrix rows above are unchanged. Its error message is an actionable
explanation in the submission's locale (en or pt-br), built from catalog
keys preflight.error.* in autograder/translations:
| Code | The message names |
|---|---|
REQUIRED_FILE_MISSING |
the missing required files, or the criterion and its missing target, or how many assessable files a criterion needs and found |
PREPARATION_FAILED |
the failing setup step's name and its exit code, its 30 s deadline, or that it exhausted the sandbox |
LANGUAGE_REQUIRED / LANGUAGE_NOT_ALLOWED |
the definition's allowed languages (and the rejected one) |
FILE_TARGET_CONFLICT |
the criterion and the target outside the evaluation scope (or its conflicting file parameter) |
UNSUPPORTED_FILE_TYPE |
the criterion and the target it cannot assess |
AMBIGUOUS_FILE_TARGET |
the criterion, how many files it assesses and how many submitted files match |
A submission error an evaluator raises without an explanation (only reachable
outside a compiled plan, such as MISSING_LANGUAGE_COMMAND) keeps its fixed
message. Messages contain only definition-authored names (files, steps, criteria,
languages) and counts, never submitted file names or contents, so their size is
a function of the definition. The setup command itself is not shown.
A failed setup step also returns an excerpt of its output (standard output, then
standard error) as error.output:
{"code": "PREPARATION_FAILED", "category": "submission", "retryable": false,
"message": "The setup step 'compile' failed with exit code 1, so the submission could not be graded.",
"output": "Main.java:3: error: ';' expected\n int x = 1\n ^\n1 error\n",
"correlation_id": "..."}
output uses the report bound and excerpt of Size bounds
(MAX_REPORT_BYTES, head and tail around the omitted-bytes marker); an attested
output above it is rejected with text_too_large. Only submission errors may
carry output, and it is absent from the wire, not null, when there is none,
so every other error serializes exactly as before. A step that exhausted the
sandbox has no output.
Setup output can contain author-private content, for example compiler messages
quoting a hidden test harness staged as a fixture. By default a failing step's
output is shown; a setup command with "private_output": true
(DEFINITIONS.md) still names the step and exit code but never
returns its output. The flag is validated at compilation (a strict boolean) and
is omitted from the snapshot while false, so definitions written before it
keep their hash.
Hosts: HTTP compact polling and history keep error.message but omit
error.output; authenticated details return the full outcome with it. The
Action writes the outcome to .autograder/outcome.json and the message and
fenced output to the job summary. Hosts that validate the language at
acceptance (HTTP 422, Action configuration) report LANGUAGE_REQUIRED and
LANGUAGE_NOT_ALLOWED before grading, naming the allowed languages.
The tree has one root representation. Categories retain the base/bonus/penalty
score semantics; holder scores must equal the weighted average of their children
and the root must equal the capped combination of its categories. A category's
weight is the points it moves: 100 for base, the definition's max_points for
bonus and penalty. provenance.schema_version is the format of the bound
definition: "2.0", or "1.0" for an outcome graded before format 2.0. Tests identify their evaluator and globally unique criterion id; display
names and grouping are presentation. Serialization rounds scores to two decimal
places, and validation allows only the resulting small arithmetic rounding
error. outcome_score_vector(completed) derives an ID-to-score projection from
the authoritative tree.
Scoring arithmetic has one implementation (autograder/models/contracts/scoring.py)
and one description, Scores. On the wire, effective
weights are the normalized sibling ratios (summing to 100 within a group),
holder scores are the weighted mean of unrounded child scores, every reported
score is rounded to two decimals and effective weights are not rounded. The
canonical criterion order is base, bonus, penalty and, inside a holder, nested
subjects before direct tests.
Every completed tree, locally produced or externally attested, passes the same
structural check, verify_outcome_tree(criteria, tree): categories, holder names
and order, criterion IDs, evaluator types, labels and file targets must match the
definition, and effective weights must equal its ratios (tolerance 1e-5).
Reported parameters are optional on the wire; when present they must equal the
canonical parameters. Arithmetic is validated separately, from the reported
values, by the outcome model itself; neither check trusts the producer. No independently mutable vector is present on the wire.
The embedded comparison enrichment's path field carries a criterion ID, never
a display path. Tree parameters contain only normalized authoring parameters, never
pipeline-injected resources or prompts. Trusted detail may contain private tests;
student-facing visibility policy belongs to the hosting adapter.
Python terminal models are frozen, including nested JSON maps/lists. Their
model_dump(mode="json") output is an independent JSON-compatible delivery
payload. Modifying a payload does not modify the finalized grading snapshot.
The frozen PipelineExecution return envelope holds only outcome; intermediate
assessment data remains local to the coordinator. Optional diagnostic events
are separate from the grading artifact. Cleanup failures reach host logging and
an optional observer without replacing the completed or failed grading outcome.
Size bounds¶
Student-controlled text cannot size an outcome. Each criterion report is at
most MAX_REPORT_BYTES (8 KiB) and feedback content at most
MAX_FEEDBACK_BYTES (256 KiB) of UTF-8, both in
autograder/models/contracts/outcome.py. The engine bounds locally produced
text in one place: grade excerpts every evaluator and AI report, and
render_feedback excerpts feedback. Text that fits is kept (lone surrogates
become U+FFFD). Longer text becomes a deterministic, valid UTF-8 excerpt that
keeps the head and the tail around a marker with the full byte count:
FAILURE: Output Mismatch.
Expected: '5'
Actual: 'ooo...
[... 1040478 of 1048626 bytes omitted ...]
...ooo'
Excerpting never changes a score. Process output is still read with its 1 MiB
per-stream bound (PROCESSES.md), and evaluators assess the whole
stream. Only the retained text is shorter. Validation rejects an attested report
or feedback above its bound with the typed error text_too_large and never
truncates it.
The worst-case outcome is a function of the definition, never of a submission.
CompiledDefinition.max_outcome_bytes is the largest size of any of its
outcomes serialized with json.dumps defaults. That encoding uses ASCII escaping
and spaced separators, so it is never smaller than a compact or raw-UTF-8
encoding:
max_outcome_bytes = S + 6 * (N * 8 KiB + 256 KiB) + 1 KiB * nodes + 16 KiB
Here S is the measured tree with empty reports: IDs, labels, targets, weights
and canonical parameters. N is the number of criteria, and nodes counts
criteria, groups, categories and the root. The factor 6 is the largest JSON
escaping of one UTF-8 byte (\u0001). The per-node allowance covers score digits
and one attested comparison delta for each criterion of this definition. Deltas
for criteria removed since the baseline name criteria that are not nodes of
this definition and have no allowance. An attestation whose comparison lists
enough of them to exceed the bound is rejected with OUTCOME_TOO_LARGE. The
16 KiB covers identifiers, provenance, timestamps, statuses and a structured
error. A failed outcome has no tree and no feedback, so its bounded output
(at most 6 * 8 KiB escaped) is always inside the same bound.
An attestation carries the definition snapshot and the outcome. Compilation
(compile_definition and compile_snapshot) therefore rejects with
DEFINITION_TOO_LARGE any definition whose snapshot plus max_outcome_bytes
exceeds MAX_ATTESTATION_BYTES (24 MiB, verification.py). The hosts' 32 MiB
request limit (SUBMISSIONS.md) leaves 8 MiB for identity and
audit metadata, so every valid definition's maximal attestation is accepted.
With short parameters this allows about 465 criteria, and long
definition-authored text lowers the number. The HTTP host also rejects an
attested outcome larger than its snapshot's max_outcome_bytes (for example
because of oversized metadata) with 422 OUTCOME_TOO_LARGE. Storage and UI can
size for these bounds.
Outcomes this host stored before the bounds existed are upgraded, never
rejected when they are read. Alembic revision 009_bound_outcome_text rewrites
every stored submission_results.outcome with the same excerpt
(bound_outcome_text). Scores, identities and text within a bound are
unchanged, and the upgrade is idempotent. Publication receipts written before
the deployment are excerpted the same way when they are read, so their delivery
retry still completes and still equals the migrated row. Neither path applies to
incoming attestations.
Publication receipts¶
The HTTP host writes each finalized outcome to a private, fsynced, atomically
renamed receipt before database publication. Set WEB_OUTCOME_RECEIPT_DIR to a
persistent writable directory (default data/unpublished-outcomes). Files have
mode 0600. A database failure retains the receipt and leaves the original grade
unchanged. Polling can remain processing until delivery succeeds.
Replay one receipt with the same database configuration:
python -m web.service.outcome_delivery /path/to/submission-receipt.json
Replay validates its bound submission provenance, publishes the existing outcome, and removes the receipt only after success. Ambiguous commit recovery verifies an identical persisted outcome; it never runs the pipeline. These receipts preserve finished grading and do not provide a durable submission scheduler.
Baseline comparison¶
Comparison is a separate, read-only use of two completed outcomes, never part
of grading. compare_outcomes(baseline, head, baseline_definition, head_definition)
is pure; the HTTP host exposes it as authenticated
GET /api/v1/submissions/{submission_id}/comparison?baseline_submission_id={id}
over two stored submissions of the same grading configuration. Nothing is
stored or regraded; a retry is another call. The grading outcome's comparison
enrichment stays disabled for normal grading and is never rewritten.
Each definition must hash to its outcome's provenance. Criteria join only by ID.
Same hash gives same_definition with an overall delta. Different hashes give
cross_revision with a null overall delta; per criterion, identical evaluator
type, normalized parameters, file target and effective weight/category compare
normally, changed effective weight/category is reweighted (with criterion
delta), changed type/parameters/target is redefined (no delta), and one-sided
criteria are introduced/removed. Failed or pending outcomes are
OUTCOME_NOT_COMPLETED; history without a bound snapshot or canonical outcome is
LEGACY_UNVERIFIED; different configuration resources are NOT_COMPARABLE.
Attested and executed outcomes follow identical rules and are labelled by
source. See baseline comparison for the
complete table and example.