Skip to content

Deepen code Grader execution into one owned lifecycle #1285

Closed

Description

@JacobStephens2

What to build

Give code Graders one owned execution lifecycle. Experiment scoring should ask for the configured checks and receive their private Check records; the code Grader module should own the neutral packet, repository snapshot, report copies, sandbox launch, memory supervision and startup classification until every check has ended.

Preserve today's Scores, Trial outcomes, retries, private evidence and CLI/Console output. This consolidates the implementation obligations that several recent Grader fixes had to change in different modules.

Acceptance criteria

  • Experiment scoring calls one code Grader operation with the Trial repository, report references, ordered checks, per-check timeout and current memory caps. It receives completed Check records or an operational error. No command, memory scope, launcher-status handle or later startup-check operation crosses this seam.
  • The code Grader owns one neutral packet and repository snapshot for the whole check list. Checks run sequentially against that same snapshot, keep their own deadlines and memory scopes, and can share build artifacts. Packet cleanup happens after process cleanup on success, timeout, interruption and error.
  • Snapshotting preserves ordinary files, directories and symlinks, skips special files, and leaves the Trial repository untouched. Report copies remain blinded, absent reports have empty environment values, raw Trial logs remain hidden, and the local-origin rewrite remains confined to a real Git directory/config inside the snapshot.
  • The existing distinction between an ordinary failed check, an unavailable sandbox, a memory-cap failure and interruption is preserved. A timeout or nonzero check produces a failed Check; sandbox startup failure still makes the Trial void through the worker's existing handling; a code Grader memory-cap failure still pauses the Experiment. Interrupted work finishes cleanup and returns interruption before grading continues.
  • Both code and model Graders use the existing Trial Reports type's shared read-and-blind operation, with the current redaction behavior. Check and Reports serialization, Score combination and saved Experiment compatibility remain unchanged.
  • Existing Experiment regressions for startup evidence, misleading check diagnostics, Arm metadata, report/repository confinement, real memory caps and private check output continue to pass. Snapshot special-file and Git-rewrite confinement coverage exercises the new execution interface or the Experiment command instead of a copy helper or a launch constructor alone.
  • Focused command tests cover a code Grader timeout and interruption during a check: descendants finish before cleanup, timeout remains a failed Check, interruption publishes no incomplete Trial Score, and the Experiment remains resumable under its existing rules. Cover ordered checks sharing snapshot artifacts and continuing after an ordinary failed check.
  • The domain-to-code index names the new ownership. Run focused Experiment and Trial checks, then the repository's affected-test selector against the implementation's Base branch. Preserve meaningful environment gates for real sandbox and memory-cap checks, and report any skips.

Blocked by

None (can start immediately).

Decisions

The design tree is settled in four rounds. Each round depends only on decisions settled earlier; there are no outstanding design questions.

Round 1 — responsibility

  1. Own the full code-check lifecycle; keep Score composition in Experiment scoring. Packet preparation, launch, supervision and operational classification must have locality in one deep module. The two initial checks (Trial succeeded; a report exists), model Score combination, Verdict and rechecks remain grading policy. Merely moving process execution would leave the privacy and lifetime protocol spread across the seam.

Round 2 — placement and interface, from decision 1

  1. Make code Grader execution a child module of the sandbox module. It can reuse that parent's private bind, environment and launch primitives without exposing more sandbox implementation through a crate-wide interface. Move the existing code-specific launcher and startup-status implementation into it; remove the old caller-facing command/scope and separate startup-check operations.
  2. Use one operation with explicit inputs and completed Check records. Accept the repository, Trial Reports, ordered command arguments, per-check timeout and current Caps. Move the Check record definition into the code Grader child module; return those records and let scoring import the same type to construct its two initial checks. Preserve its existing fields and serialization. Callers need grading intent, not process machinery; no Arm identity, entire Eval task, Bar or Trace context is required.
  3. Keep the current skip and configuration rules in scoring. A Void Trial or empty check list does not invoke code-check execution. Otherwise load live machine caps once at the current point and pass them in. This preserves behavior and makes configuration an explicit dependency. The worker still translates the existing typed sandbox-unavailable error into a Void Trial, and retains its existing pause/retry accounting.
  4. Move shared report reading and blinding onto Trial Reports. Both code and model Graders need the same operation, so neither should depend on the other's implementation to blind reports. Preserve the exact existing text filtering, optional-report behavior and read timing at each grading stage; add no report cache or new redaction policy. This is shared implementation, not a new adapter.

Round 3 — implementation obligations, from decisions 2–5

  1. Keep the packet and its snapshot alive for the entire ordered list. Use one temporary neutral directory outside Trial/Arm storage, copy the repository once, and write the blinded report texts there. Retain the existing special-file skipping, symlink behavior and confined origin rewrite. Reusing the snapshot preserves build artifacts between checks and avoids changing what checks can observe.
  2. Keep the existing sandbox and pass-through adapters behind the same seam. The explicit sandbox opt-out continues to select pass-through execution; production execution continues to require caps. Both use the existing process and scope modules. These are two real adapters already exercised by the fixtures, so no new trait or general execution framework is needed.
  3. Preserve classification order inside execution. After a process ends or is stopped, check interruption first; for an unsuccessful execution, check scope-owned OOM evidence next; then use launcher-owned startup evidence; finally turn ordinary output or execution failure, including timeout, into a Check. Check stderr cannot assert sandbox startup failure. A missing check executable after the sandbox starts remains an ordinary failed check. Keep the unlinked launcher-status descriptor outside the packet and alive through the child process.
  4. Finish process cleanup before releasing packet, scope or status ownership. Reuse the existing supervised process operation, deadline, scope sampling and SIGTERM/SIGKILL cleanup. Every check gets its own scope and timeout, and an ordinary failed check does not stop later checks. An operational error returns no partially completed Check list, matching current Score publication.
  5. Preserve all retained formats and existing Trace placement. Check fields, command order, diagnostic construction, the two initial checks, Reports path fields and Score serialization stay the same. The existing surrounding Grader span remains in the worker. This is an ownership change that can land without migrating saved Experiments or changing the pending Bar/recheck work in Spec: a Bar a release that changes nothing can pass #1252.

Round 4 — verification, documentation and size, from decisions 6–10

  1. Use the existing Experiment command as the primary test surface. Its fixtures already provide pass-through systemd executables and sandbox opt-out, while the sandbox regressions exercise real bwrap and the gated cap test uses the real user manager. Keep those tests; replace helper-only/constructor-only coverage with observable execution behavior. Add focused timeout, interruption and ordered-check coverage there, because those verify the lifecycle without coupling tests to its implementation. Reuse the model Grader's report-blinding regressions and run the Trial checks because Reports is shared. No new test-only execution interface is needed.
  2. Update navigation; require no new domain term or ADR. Grader and Trial already name this responsibility. This reversible consolidation changes neither the trust policy nor the scoring/sandbox contract, so it does not warrant a new domain definition or architectural decision; the code index does need the new ownership for locality.
  3. Publish one standalone Ticket. This is one complete mechanical extraction and caller migration with existing behavioral coverage, sized for one fresh context window. It needs no parent Spec or blocking edges.

Architecture review

Strength: Strong · Dependencies: local-substitutable

Files: src/evals/experiment/grading.rs, src/sandbox.rs, src/sandbox/code_grader.rs (new), src/trial.rs, src/trial/reports.rs (new), src/evals/experiment/model_grader.rs, tests/experiments.rs, tests/experiments/sandbox.rs, tests/experiments/model_graders.rs, docs/code-navigation.md

Before

flowchart LR
  Scoring[Experiment scoring] --> Packet[Grader packet]
  Scoring --> Launch[Code Grader launch]
  Scoring -. deadline, memory, startup .-> Execution[Check execution]
  Execution --> Launch
  Launch --> Sandbox[Sandbox adapter]
  Launch --> Direct[Pass-through adapter]
  classDef leak stroke:#dc2626,stroke-width:2px;
  class Scoring,Execution leak
Loading

After

flowchart LR
  Scoring[Experiment scoring] --> Grader
  subgraph Grader[Code Grader module]
    Packet[Grader packet] --> Execution[Check execution]
    Execution --> Launch[Code Grader launch]
    Launch --> Sandbox[Sandbox adapter]
    Launch --> Direct[Pass-through adapter]
  end
  classDef deep stroke-width:3px;
  class Grader deep
Loading

Problem: the code Grader module is shallow because its interface makes scoring coordinate private packet preparation with command, memory and startup implementation across the seam, repeatedly repaired in 780d0cdb, 18058a1b, 4a714600, ab24591f, 9349fe1e, e698c21d and be8f17a5.

Solution: deepen code Grader execution into one owned lifecycle whose interface returns completed checks while its implementation retains packet, process and classification knowledge.

Wins

  • locality: snapshot through failure classification
  • leverage: one interface, both adapters
  • depth: callers supply grading intent
  • Tests cross the production seam

Deletion test: deleting the deep module would redistribute packet privacy, process lifetime and classification knowledge into scoring and sandbox callers.

Coverage: all 118 open issue titles and bodies were checked and rechecked before publication; no open issue proposes this deepening. #1252 changes the Bar and rechecks, not this module's ownership.

Review basis: main at f298420d30f7535cd04fd1af5031751514f8271d (the captured origin/main head). No source changes were needed for the review; the affected-test selector against that head reported no changed files and no affected tests.

Activity

  1. added
    needs-triage
    ready-for-agent
    architect-plan
    in-progress
    and removed
    needs-triage
    ready-for-agent
    on Oct 24, 2026
  2. removed
    in-progress
    on Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    architect-plan

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions