# Learner submission contract

This is an open-book traceability exercise. The checker validates the format, immutable bindings, evidence pointers, exact quotations and internal consistency of learner declarations. It does not assess whether the declared interpretation or proposed prose is semantically correct. A traceable submission can contain unsupported claims. No teacher answer, keyword list or exact answer oracle is consulted.

Every CLI result explicitly reports `semantic_correctness: not_automatically_assessed`, `actual_human_review_status: pending_human`, `identity_verification: not_performed` and `release_authorized: false`. A self-reported `learner_declaration` establishes neither identity nor actual learner attainment. Teaching examples retain `teaching_example`; a prepared blank retains `blank_template` until its author completes it. None of these artifacts represents independent human reviews.

## Commands and exit codes

Use Python 3.10+ with the existing `jsonschema` dependency. The verified delivery runtime is Python 3.12. No provider, API key, network request or package installation is required when the dependency is already available.

```sh
python -B exercise.py list
python -B exercise.py inspect --case case-a
python -B exercise.py prepare --case case-a --out /absolute/outside/package/submission.json
python -B exercise.py check --case case-a --submission /absolute/outside/package/submission.json
python -B -m unittest discover -s . -p 'test_*.py'
```

`prepare` exclusively creates a fresh file in an existing directory outside this package. It refuses overwrites, package destinations and every symlink component. Relative paths such as `../learner-work/submission.json` are supported; each original path component is traversed without following symlinks, including before `..`. Use canonical directories; macOS aliases such as `/tmp` and `/var` can be symlinks. `list`, `inspect` and `check` write no files. `-B` also suppresses Python bytecode creation, allowing the package and working directory to be read-only after relocation.

Exit 0 means successful list/inspect/prepare, or a complete traceable submission. Complete declared failure and escalation also exit 0. Exit 1 means incomplete or inconsistent declarations, including blank forms, stale bindings or invalid traces. Exit 2 means invalid CLI/input, unreadable or malformed submission JSON, or source integrity failure. Duplicate JSON keys and nonfinite numbers are rejected as invalid input.

## Exact JSON fields

`SUBMISSION_SCHEMA` in `exercise.py` is the executable schema. Objects reject extra fields. Prepared blanks deliberately do not satisfy completed-submission constraints.

| Object | Required fields |
| --- | --- |
| Submission | `submission_version`, `exercise_id`, `origin`, `binding`, `initial_assessment`, `disposition`, `revision`, `revised_assessment`, `next_step` |
| Binding | `exercise_id`, `packet_sha256`, `rubric_sha256` |
| Assessment | `binding`, `dimensions`, `findings`, `overall_verdict` |
| Dimension | `criterion_id`, `verdict`, `severity`, `quote`, `omission`, `candidate_pointer`, `evidence_pointers`, `rationale` |
| Finding | `id`, `criterion_ids`, `severity`, `quote`, `omission`, `candidate_pointer`, `evidence_pointers`, `rationale` |
| Revision | `parent_candidate_sha256`, `answer`, `rationale` |

`submission_version` is `learner-review-submission-v1`. `exercise_id` is `case-a`, `case-b` or `case-c`. `origin` is `blank_template`, `learner_declaration` or `teaching_example`. Completed declarations require a nonblank `next_step`; `blank_template` never qualifies as completed work. `disposition` is `accept_assessment`, `revise_prose` or `escalate`.

SHA256 fingerprints use sorted-key UTF-8 compact JSON with `ensure_ascii=False`, separators `(',', ':')`, and `allow_nan=False`. Packet binding covers the entire delivered packet, including candidate, context, boundaries, original candidate and source references. Rubric binding covers the entire rubric. Teacher materials are excluded. `parent_candidate_sha256` fingerprints the entire original `packet.candidate` object, including its structured proof.

Each assessment contains exactly one dimension for each of S1–S7. Dimension verdicts are `pass`, `fail` or `needs_evidence`; severities are `none`, `minor`, `major` or `critical`. Every trace supplies exactly one nonblank `quote` or nonblank `omission`, setting the other to null. `candidate_pointer` must select a string below `/candidate`; a quote must be an exact contiguous substring there. An omission describes missing content as the author's judgment. Evidence pointers are a nonempty unique list resolving within this packet using strict RFC6901 syntax. RFC6901 root pointer `""` is allowed for evidence. Invalid escapes, missing fields and noncanonical array indexes are rejected. Rationale is nonblank.

Findings have nonblank unique IDs, a nonempty unique list of S1–S7 IDs, and severity `minor`, `major` or `critical`. Every failing or major/critical dimension requires a linked major/critical finding. A failing dimension requires major/critical severity; a passing dimension cannot have major/critical severity. Any major/critical finding vetoes declared overall pass. Overall verdict is `fail` if any dimension fails or any finding is material; otherwise `needs_evidence` if any dimension is uncertain; otherwise `pass`. These rules validate the author's consistency; they cannot establish that the author chose the correct verdicts or evidence.

## Proposed revision and mechanical boundary

`accept_assessment` requires a declared initial overall pass. `escalate` can retain a complete declared failure or uncertainty. Both require `revision` and `revised_assessment` to be null.

`revise_prose` requires a nonblank answer differing from the original, a rationale, the original candidate fingerprint, and a new seven-criterion assessment. `revised_packet(case, revision)` deepcopies the original packet and changes only `candidate.answer`. Context, structured claims, atoms, rules, original candidate and boundaries remain intact. `revised_assessment.binding` must match the complete revised packet and current rubric; original bindings are stale. Its quotations and evidence are validated against the revised packet. A revised assessment can consistently declare failure or uncertainty; this still documents an exercise rather than readiness.

`mechanical` always records the frozen source task against the original delivered case. A proposed answer is a learner artifact, never a rewritten provider response. Its semantic declarations neither rerun a historical request nor change historical/current authority. Historical MCP remains `externally_unverified`, with current verification still required. Mechanical failure or pending external verification does not prevent a learner from submitting a traceable analysis, and a traceable analysis never grants release authority.

## API and output

`prepare_submission(case) -> dict` returns a bound blank. `revised_packet(case, revision) -> dict` returns only the revised packet and raises on an invalid revision. `check_submission(case, submission) -> dict` checks the original sources before invoking frozen grading, then validates the submission. Imports never depend on teacher files. `packets.binding_for(dict(case, packet=revised_packet(case, revision)))` computes a revised binding.

The checker separates `format_issues`, `binding_issues`, `trace_issues`, `declaration_issues` and `input_issues`. `submission_traceable` is true only when format, bindings, traces and declaration consistency all pass. `recorded_declarations` summarizes the author's original/revised verdict, disposition, origin and next step without claiming correctness. `mechanical` records the original task status separately. A format error prevents deeper validation; unvisited checks remain false. Frozen source and packet pin failures are input errors before any grader import. `inspect` also presents explicit recorded/authored origin and complete edit provenance.

Generic synthetic tests demonstrate that two different arbitrary revisions can both be traceable and an unsupported declaration remains explicitly unassessed. They contain no completed answers or expected semantic verdicts for the delivered cases. Teacher examples belong in a separate download and are not dependencies of this checker.
