Add a defense task over a student's mycpu checkout

Merged
JS
17h ago
+13576-98

This supersedes #821, which was merged by mistake and then removed from main; it carries that series, reworked after its review, with the review fixes and the tests its mutation run asked for.

A course that grades a student's own RISC-V core in Chisel (ca2026-mycpu) needs to know the student wrote it and understands it. This adds an opt-in defense set to task mode: codetrial web --task-mode --workspace <path-to-checkout> examines the student's own checkout. Lines the student added, chosen with the package's own salt, are explained to Jim; a stated change is typed and its failing specs predicted before a real sbt testOnly run; and the student's core, built with a mutant drawn per attempt, is run beside the clean build (retire log, waveform, obs-trace window) until the student states the cycle, signal, rule and exercise of the bug. Edits and builds happen in a private git worktree, so the student's tree and index are never written, and the page never learns the mutant or what a claim is checked against.

Jim examines without saying right or wrong and is told the panel's events once neither he nor the learner is speaking. A package may allow up to three hints (hints, default 0); each is recorded against its item and caps that item's suggested marks at 2. The result gains a defense section of suggested marks, labelled as suggestions generated on the student's machine. Item code is colored from a vendored tree-sitter-scala grammar, a defense set's setup advances by itself and remembers its PIN per set version, and scripts/task-package.py gains pin new and pin check. docs/mycpu-defense.md is the contract; non-defense task mode is unchanged.

Verified with ./scripts/test.sh on the branch, rebased on main: every gate passes except the browser test "a formatter that cannot load changes nothing, and the next press loads it", which fails on main as well. Each of the series' commits builds with clippy and passes its own tests. Every mutant that survived #821's mutation run is either killed by a test, checked by applying it by hand, or gone because the line now says what it computes in one step. A rehearsal against a public ca2026-mycpu checkout and a live Gemini room exercised the panel, hints and the bug item end to end.

Left out, as open questions: defense packages keep packageVersion, taskContract and rubricProfile at 1 under task-mode's draft clause; the defense prompt is not pinned in tests/golden/task-prompts.json; a replacement connection is told how many hints each item had but not their wording; and when the student's bootcamp gate stamp is stale, the course's Makefile reruns that gate in the student's bootcamp clone, which the contract names as the one write outside the worktree.


Summary by cubic

Task mode previously only posed tasks from a packaged bank; it can now pose a defense set that examines a student's own ca2026-mycpu checkout, so a course can grade whether the student understands the RISC-V core they wrote. Start it with codetrial web --task-mode --workspace <checkout>; edits and builds run in a private git worktree, so the student's checkout is never modified.

New Features

  • Jim asks about lines the student added, then the student types a stated change and predicts which specs fail before the real sbt testOnly run.
  • A bug item builds the student's core with a per-attempt mutant and compares it with the clean build until the student states the cycle, signal, rule and exercise; the page never shows the mutant or the check.
  • Every spec, model and simulation run is bounded: each command runs in its own process group, is killed past its package time limit, and keeps a 64 KiB tail of output, so nothing the checkout's tools print or leave behind can stall the attempt.
  • Defense packages can allow up to three hints; each hint is recorded and caps that item's suggested marks at 2.
  • Results gain a defense section with suggested marks, and task-package.py gains pin new and pin check.
  • Chisel lines in the defense panel are colored with a vendored tree-sitter-scala grammar.
  • A defense submission is one ZIP holding the code, the conversation transcript, the result, and a manifest of hashes and the recording link.

Migration

  • A defense set is a task-mode package with a defense object in place of a bank; docs/mycpu-defense.md is the contract.
  • --workspace is accepted only with --task-mode, and non-defense task mode is unchanged.
  • The checkout must sit on a clean HEAD with a committed STUDENT_ID and an upstream remote; the asked-about lines are those the student added since the merge base.