Skip to content

Latest commit

 

History

History
770 lines (633 loc) · 44.3 KB

README.md

File metadata and controls

770 lines (633 loc) · 44.3 KB

runner/ — sandboxed execution

Takes one paper's generated coder/output/<paper>/ directory and executes it inside a Docker container, escalating through cheap gates until something fails or the requested depth is reached. Captures the logs, reads the metrics back out, and — only when a run genuinely fails — spends one Claude Haiku call classifying the failure.

This stage never imports torch and never runs a training script on the host. Everything executes inside the image; on the host it shells out to the docker CLI, so its own dependencies are just anthropic + python-dotenv.

The interface is reproduce.sh, not CLI flags

This is the central design decision of the stage.

The only command ever sent into a container is:

bash reproduce.sh <mode>          # mode ∈ probe | smoke | capped | full | seed2 | seed3

The Runner never constructs a python command, never passes a --flag, and never needs to know what arguments a generated script accepts. That is what keeps it paper-agnostic: a future paper whose script takes entirely different arguments changes only its own reproduce.sh, and nothing in this folder. The contract narrows from "eight CLI flags spelled exactly right" to "four mode names".

Mode semantics come from the script's own header (see coder/README.md):

Mode What it costs What it proves
probe a couple of optimizer steps, seconds data → model → loss → step works at all; catches shape/dtype errors
smoke one full epoch over a small slice execution reaches the eval path and the metrics write
capped 5 epochs / 512 samples, minutes training actually learns — train_metric moving well past a trivial baseline (CIFAR-10's 10% chance accuracy; predicting the mean for a regression)
full the paper's real setup, hours the only numbers comparable to the paper's claim; needs a GPU
seed2, seed3 full again with --seed 2 / --seed 3 run-to-run spread, when the Critic cannot judge one run; the Orchestrator asks for them only when a full run took ≤ 30 min

Each mode writes its own metrics.<mode>.json, so a cheap stage's numbers can never be mistaken for a real run's.

The seed modes (added 2026-09-14 for the Critic) are not in the escalation ladder. STAGE_ORDER is still the four stages, and SEED_MODES sits beside it (ALL_MODES is both). They take full's 24 h timeout and all six check-up rules, and has_seed_modes(paper_dir) tells a caller whether a script generated before them can run them at all.

One sharp edge worth knowing: reproduce.sh with no argument defaults to full. The Runner always passes an explicit mode, and the image's default CMD passes probe, so neither can start a multi-hour run by accident.

Escalating gates

      probe ──ok──► smoke ──ok──► capped ──(only if asked)──► full
        │             │             │
      exit≠0        exit≠0        exit≠0
        ▼             ▼             ▼
             stop, triage, record

Stages run in order and stop at the first non-zero exit — a shape error costs seconds instead of hours. full is never reached by escalation; the default --max-stage is capped, and full has to be named explicitly.

A stage also stops early when a live check-up halts it (next section). For a classical estimator (model_family: "classical" in coder_output.json), capped scales data instead of epochs — 5,000 training / 2,000 evaluation rows — because an SVM or a forest has no epochs, and the old epoch-based capped gave numbers identical to smoke.

Live check-ups — is it actually learning?

An exit code says a script finished, never that it learned. Twice in phase 3 a full run exited normally with a broken model (Tang 2013's collapse; a soft decision tree whose sign-flipped loss drove accuracy to 0.15%), and both were caught by a person reading docker logs. checkups.py makes the Runner read the run itself.

The channel. Every generated script appends one JSON record per epoch (or per repetition/fold/fit for a classical estimator) to metrics.<mode>.history.jsonl in the bind mount, and prints the same record after the REPROBOT_PROGRESS marker. The record carries the losses, the claim's metric on both splits, and three fields the rules need: chance_metric (a trivial predictor's score on the eval split, fitted on the training split), target_value (the claim) and loss_lower_bound. coder/pipeline.py rejects a script that does not write it.

The mechanism. run_stage keeps its blocking subprocess.run; a watcher thread beside it reads new history lines every --checkup-interval seconds (default 5), logs them (at most ~20 lines per stage), and evaluates the rules on every tick, whether or not a record arrived — the tick that sees nothing is exactly the one no_first_record has to decide. When a rule fires, the watcher kills the container by name — the timeout path's own docker kill — and the stage ends with status halted and the evidence. The rules run once more after exit, because a short stage can finish between two polls; that final pass is given no wall clock, so silence can only halt a stage that is still running. No triage call is made: the rule's evidence is the diagnosis. A finished script that wrote no history is judged on its exit code alone, with a warning. --no-live-checkups turns all of it off.

The rules — pure functions, conservative, because a false halt kills a run that would have reproduced a paper:

Rule Fires when Stages
non_finite a loss or metric is NaN/inf all
loss_below_lower_bound a loss falls below its declared lower bound all
worse_than_chance an accuracy-like metric is >3 binomial SEs below chance for 3 records running (from step 3) capped, full
no_progress the loss is flat (<0.1% range) over the opening window and the metric is not meaningfully better than chance full
stuck_at_chance after warmup (max(3, 10% of the run)), the metric is not meaningfully past chance for 3 records running — skipped when the claim itself sits near chance full
diverged the loss is >1.5x its best and the metric has kept <50% of its best gain over chance, for 3 records running full
no_first_record the stage has been silent — no record written, no dataset arriving — for longer than its per-stage deadline capped, full
hang (check_hang, live only) records had been arriving, then none for longer than max(1800 s, 10x the longest wait so far) full, seed2, seed3

"Meaningfully past chance" is max(3 SEs, 10% of the distance from chance to a perfect score). no_progress was first allowed in capped too, and end-to-end testing showed why it cannot be: a correctly generated soft tree, whose leaves start uniform, held its loss at ln 10 = 2.303 for all five capped epochs while accuracy was already 30% — three times chance.

no_first_record — the rule that judges silence

Every rule above needs at least one record, so a script stuck inside its first fit was invisible to all six of them. That is not hypothetical. On 2026-09-20 the Coder targeted Fashion-MNIST's RBF SVC claim (c21, 0.897); one LIBSVM fit on 60,000 × 784 rows is tens of minutes single-threaded, and the paper's protocol repeats it five times. Fifteen minutes in, metrics.full.history.jsonl was still empty, every rule had nothing to judge, the stage had ~86,000 s of budget left — and a person killed the container by hand. no_first_record is that person.

Stage Deadline Why that number
probe, smoke never armed probe is the stage that absorbs a cold dataset fetch, whose worst case belongs to the network rather than the script, and both stages can legitimately end without a record (a probe is a couple of optimizer steps). Their 2700 s / 900 s budgets already bound them, and a timeout stops the loop for a human instead of asking the Coder to rewrite a script that was never at fault.
capped 900 s 1.7× the slowest measured capped stage (~525 s), 8× its slowest real first epoch (~105 s), half its own 1800 s budget. Below the 1707 s cold fetch — which is safe only because the clock measures silence, not elapsed time (next paragraph).
full, seed2, seed3 5400 s 3.2× the longest wait ever measured before a first record (the 1707 s cold CIFAR-10 fetch) and ~50× the slowest real first epoch, while still bounding the SVC incident's remaining hours at 90 minutes.

The deadlines are defaults, not constants: DEFAULT_FIRST_RECORD_SECONDS in checkups.py, overridable per stage with --first-record-deadline MODE=SECONDS (same shape as --timeout) for a paper whose first unit of work is honestly huge.

Four properties keep it from killing a slow-but-honest run:

  1. The first record disarms it for the rest of the stage. It is a rule about never starting, never about slowing down — the Fashion-MNIST forest's five sparse repetition records, or a single fit, switch it off for good.
  2. It only ever sees a stage that is still running. evaluate() takes the clock as an argument and the watcher is the only caller that passes it; the post-exit pass does not, so a stage that has already finished is judged on its exit code as before — including a probe that legitimately exits before its first epoch.
  3. It counts silence, not elapsed time (below).
  4. Its deadline is sized against the slowest first unit of work ever measured here, not against the compute a paper might need.
  5. It is armed only for a script that can report. Before launching, the Runner checks the generated train.py for the REPROBOT_PROGRESS marker; a script from before the progress contract (the Trainer-era NIN and WRN, Tang's and Wijaya's current scripts) never writes a record however healthy it is, so the rule is disarmed for it with a warning and only the stage budget bounds that run.

A dataset download is not silence — SilenceClock, and the reason the capped deadline can sit below the measured 1707 s CIFAR-10 fetch. The clock restarts whenever the shared dataset mount (runner/cache/datasets) changes in file count or total bytes, so the deadline is measured from the moment the data stopped arriving, not from container start. Without it, bash reproduce.sh capped on a cold cache — a documented single-stage run, with no probe in front of it to warm the mount — would be halted mid-download, and the Orchestrator would hand the Coder a complaint about a script that was never at fault. With it, that run stays untouched while the fetch proceeds and is bounded by capped's own 1800 s budget instead.

That mount is the only live signal there is. The obvious alternative — watch the script's log, since a downloading script does print — is not available: run_stage captures both streams through a blocking subprocess.run(capture_output=True), so not one line is readable until the process exits. Making the log a liveness signal would mean replacing that capture with pipe readers and re-proving the timeout path around them, which is a large change to the most delicate code in this stage for a signal the cache already gives. Two honest limits of the cheaper choice, both documented in checkups.py: a download the script buffers entirely in memory (pandas.read_csv(url) writes no file) still looks like silence, and a script re-downloading in a loop keeps resetting the clock until the stage's own timeout ends it. The walk is bounded at 20,000 entries and runs only while a stage is still silent, so the check cannot become the slow part of the run.

check_hang — silence after records have started

no_first_record disarms at the first record; check_hang takes over from there and fires when the records stop arriving. It halts a full/seed2/seed3 stage when no new record has arrived for longer than max(1800 s, 10 x the longest wait so far), and only after records have arrived at least twice. Three choices keep it conservative:

  • The watcher's clock, not the script's. elapsed_seconds is unusable: WRN's history omits it, and the SVM guide's script restarted it for its second grid.
  • The longest wait, not the typical one, plus a floor. In the SVM guide's real full run the slowest fold took 5.33 s against a median of 0.15 s - 35x. The wait before the first record (dataset download, model setup) counts as a wait too.
  • Silence after the final step is left to the stage timeout. A final evaluation or a refit on all the data has no cadence to compare against.

It needs the time, so only the live watcher asks it; it is never judged after exit. The cheaper stages do not get it because their timeouts are no longer than its floor. A WRN-28-10 epoch on the dev machine's CPU (~2.6 h) puts the limit past the 24 h stage timeout, so a run that slow is never hang-halted.

Verified (tests/test_checkups.py, 33 replays of real curves and real timings; plus Docker):

Curve Result
Tang ablation, as generated (mom 0.9, C=1.0) halted at epoch 12, diverged
Tang ablation, whitened PCA halted at epoch 6, diverged
Tang ablation, 4 stable configs; Tang C=0.1; Wijaya; soft tree (fixed, 40 epochs); random forest; SVM never halted
Fashion-MNIST SVC, 2026-09-20: empty history in full, warm cache untouched at 900 s (where the human gave up), halted at 5400 s, no_first_record
The same silence in probe/smoke, and a 1707 s cold fetch in full never halted
The measured cold CIFAR-10 fetch replayed chunk by chunk under --mode capped never halted while the mount grows; counts only afterwards
Any stage after it has exited, with no record never halted — exit code decides
A pre-contract (Trainer-era) script, silent for 24 h never halted — the rule is not armed for it
Soft tree, sign-flipped loss, live full run in Docker halted at epoch 1 of 40, container killed 0.3 s after the record — ~70 min saved
Same fault through the Orchestrator halted in probe after 5 s → evidence fed to the Coder → regenerated script passed to capped, success
SVM guide's real full cadence (192 records) through check_hang never halted
WRN-28-10 at its real GPU pace (61 s/epoch), then silence halted 1801 s after the last record, hang
Stand-in process (no Docker) that writes 4 records and then sleeps, through run_stage's real watcher, floor lowered to 3 s full: halted, hang, process killed; capped: left to the timeout; a process that exits normally: success
The same stand-in, now four test_watcher_* tests: records-then-silence, never reports, healthy exit, silent capped hang, no_first_record, success, timeout — both silence checks through one watcher loop

Class architecture

runner/triage.py
┌──────────────────────────────────────────────┐
│  triage_failure(exit_code, failed_stage,        │
│                 log_excerpt, client)              │
│    -> TriageResult(category, reasoning,            │
│                    suggested_fix)                   │
│  A plain function. One fixed step, one call site,    │
│  so an ABC would be abstraction nobody uses.          │
└──────────────────────────────────────────────┘

runner/docker_runner.py
┌──────────────────────────────────────────────┐
│  DockerRunner(image, cache_dir, stage_timeouts, │
│               memory, cpus, network, run_triage) │
│    check_daemon() / ensure_image(build)           │
│    run_stage(paper_dir, logs_dir, mode) -> StageRun │
│    run_paper(...) -> RunnerOutput                    │
│  Everything that touches the docker CLI lives here.   │
└──────────────────────────────────────────────┘

runner/pipeline.py
┌──────────────────────────────────────────────┐
│  discover_paper_dirs / run_dataset / main       │
│  Argument parsing, skip-if-done, per-paper       │
│  try/except, output writing. The only entry point. │
└──────────────────────────────────────────────┘

Same split as coder/: the pipeline owns I/O and the CLI, the worker module owns the mechanics, and neither reaches into the other's job.

The timeout trap

The single easiest thing to get wrong in this stage, so it is handled explicitly:

subprocess.run(timeout=...) kills the docker run client, not the container. The container is a child of dockerd, not of the Python process. Kill the client and the container keeps running — burning CPU, holding the bind mounts, and writing into the paper directory — indefinitely.

So every run:

  1. gets an explicit --name, chosen before launch (container_name_for()), because after the client dies the name is the only handle left on it;
  2. on TimeoutExpired, issues docker kill <name>, treating "No such container" as success (with --rm the daemon may already have reaped it) and falling back to docker rm --force;
  3. carries a per-stage budget, enforced independently, so a hung probe cannot eat the budget of the capped run behind it.

Defaults, overridable with a repeatable --timeout MODE=SECONDS:

Budgets are calibrated against a measured run, not estimated (see Status):

Stage Budget Measured / reasoning
probe 2700 s ~67 s of compute, but a cold cache adds the ~170 MB CIFAR-10 fetch — measured at 1707 s on a slow connection. An earlier 1200 s guess would have timed out on the very first run, which looks exactly like a hung script.
smoke 900 s ~134 s equivalent at the measured 5.256 samples/s, warm cache
capped 1800 s ~525 s equivalent, warm cache
full 86400 s Not a real ceiling — a marker that this mode is GPU-only. At the measured CPU throughput it would take ~22 days.

For reference, the containerised probe with a warm cache completed in 166 s, comfortably inside its budget.

A second, subtler trap is handled too: on the timeout path TimeoutExpired carries whatever partial output it had collected as raw bytes even in text mode. decode_stream() normalizes it, so a timeout cannot crash the handler that is trying to report the timeout.

The mounts — and how results get out

coder/output/<paper>/  ──►  /workspace        (rw)   ← metrics.<mode>.json written here
runner/cache/datasets  ──►  /workspace/data   (rw)   ← shared datasets, nested on purpose
runner/cache/home      ──►  /cache            (rw)   ← HOME/HF_HOME/TORCH_HOME

The dataset mount is not CIFAR-specific: coder/'s prompt requires every download — a torchvision dataset, an OpenML table fetched with fetch_openml(data_home=args.data_dir), a file from a direct URL — to land under --data-dir, so each one is fetched once and shared from then on.

There is no docker cp. The paper directory mount is the host directory, so when the script writes metrics.<mode>.json the file is already on the host. Read-write is not optional for that mount — it is the entire results channel.

The CIFAR-10 cache is the interesting one. The generated scripts default --data-dir to ./data relative to the script, and reproduce.sh never overrides it, so a naive setup downloads 170 MB per paper. Mounting a shared host directory at /workspace/data — nested inside the /workspace mount, which Docker allows because it orders mounts by path depth — turns that into one shared copy across all eight papers.

That nesting depends on the script defaulting --data-dir to ./data. This README used to call that "a convention, not a contract" — and then the convention broke, exactly as predicted.

Under orchestrator/'s retry loop, a regenerated script defaulted its data directory to ./<output-dir>/data instead, missed the mount, and re-downloaded 170 MB: the same probe stage took 2000 s instead of 169 s. Nothing failed, which is what makes it nasty — it just silently costs twelve minutes, and a retry loop re-rolls that dice on every regeneration while these stage budgets assume a warm cache.

So --data-dir is now in coder/'s REQUIRED_CLI_FLAGS, with the prompt requiring exactly "./data", enforced by the same literal check as every other flag. It is a contract now.

runner/cache/ and runner/output/ are both gitignored.

Resource limits — the decision, and why

--memory and --cpus are exposed as flags but unset by default, and that is deliberate rather than an oversight.

A CPU-only CIFAR-10 run's memory is dominated by the dataset plus activations, and it varies with the paper's batch size — a number this stage does not know, because it deliberately never reads the script's arguments. An arbitrary cap would produce an exit code 137 (OOM-killed), which looks exactly like a crash in the generated script and would be triaged as one, sending the Coder off to fix a bug that does not exist. Costing a false recoverable_error is worse than an uncapped container on a developer machine that is running one paper at a time.

The flags exist for the cases where the trade-off flips — a shared CI box, or several papers in parallel — and triage.py's prompt names exit 137 explicitly as an environment_error so a deliberate cap is still classified correctly.

--network stays on bridge by default because a script downloads its dataset (CIFAR-10 via torchvision, a table via OpenML) on the first run. Once the cache is warm, --network none makes the sandbox fully offline.

Known limitation: the container runs as root, so on a Linux host the files it writes into the bind mounts (metrics.*.json, the CIFAR-10 cache) come out root-owned. On macOS, Docker Desktop's filesystem mapping hides this and the files are owned by the host user. Adding --user $(id -u):$(id -g) would fix it but needs a writable HOME inside the container and cannot be verified here without a daemon, so it was deliberately not added blind.

Log capture and truncation

Both streams are captured separately and the full, untruncated logs always go to disk:

runner/output/<paper>/logs/<mode>.stdout.log
runner/output/<paper>/logs/<mode>.stderr.log

Separately, a log_excerpt of roughly 8000 characters is built for the triage/Critic prompt — head-and-tail, with an explicit ...[N chars truncated]... marker carrying the exact count:

Stream Head Tail
stdout 800 2400
stderr 1200 3600

The 1:3 head:tail ratio is the point. The head catches an import or setup failure that aborts before anything else prints; the tail catches the traceback; the middle — epoch after epoch of progress lines — is the part nothing is learned from.

Each stream is truncated before combining, which matters more than it looks. Concatenate first and a chatty stdout (one progress line per epoch) can push stderr's traceback entirely out of the window — exactly the thing the excerpt exists to preserve. This is verified against a 150k-char stdout in the checks below.

error_trace is the last traceback in stderr (a raise ... from chain prints the original first; the final one is what actually ended the process). If there is no traceback at all — an OOM kill, a signal, a shell error before Python started — the tail of stderr is returned instead, since it is still the best evidence available.

Reading the metrics back

After each stage, metrics.<mode>.json is read out of the bind mount and parsed against the contract documented in coder/README.md — claim_id, metric, unit, value are copied verbatim by the generated script and are never normalized here either.

Two contract shapes exist on disk, and both are read. The current one is task-agnostic (task_type, higher_is_better, train_metric, eval_metric); the legacy one, written by the Trainer-era Network In Network and Wide Residual Networks scripts, carries train_accuracy/eval_accuracy instead. Nothing here reads either set strictly. summarize_split_metrics() builds the per-stage log line from whichever keys are present — the current ones when either train_metric or eval_metric exists, the legacy accuracy pair otherwise, and a plain "no per-split metrics reported" when neither is. The first line below is from the real plain-loop NIN regression probe; the second is the helper's output for the Trainer-era NIN metrics.probe.json still on disk:

[probe] metrics (file): claim_id=c1 Test Error=89.84375 % (task_type=classification, higher_is_better=False, train_metric=90.625, eval_metric=89.84375, epochs_completed=1)
[probe] metrics (file): claim_id=c1 Test Error=85.9375 % (train_accuracy=13.671875, eval_accuracy=14.0625, legacy accuracy-shaped metrics, epochs_completed=1)

If the file is missing, there is a fallback: the generated script also prints the identical object as its final line of stdout, so parse_metrics_from_stdout() scans upward for it. The scan requires a contract key (claim_id / metric / value, shared by both shapes) before accepting a line, so a legacy script's HuggingFace Trainer progress lines ({'loss': 2.30, 'epoch': 1.0} — Python reprs with single quotes, not valid JSON) cannot be mistaken for the metrics.

A stage that exits 0 without producing metrics is not an error: probe may exit before reaching the write. It is logged as a warning and recorded with metrics: null.

Triage — one Haiku call, only when it earns itself

stage exit 0        ─► success   ─► NO API call
stage timed out     ─► timeout   ─► NO API call
stage exit non-zero ─► error     ─► one claude-haiku-4-5 call

Success and timeout are decided mechanically. That is deliberate: a zero-exit run needs no explanation, and a timeout's cause is already "it did not finish in N seconds", which no model can improve on. The common path — everything passes — costs nothing.

On a genuine failure, triage_failure() sends only the three things that carry signal: the exit code, which stage failed, and the truncated log excerpt. The generated script's source is not sent — the traceback already names the failing line, and shipping several hundred lines of code would cost far more than the classification is worth.

It returns one of two categories, which is the routing decision the future Orchestrator needs:

  • recoverable_error — the fault is in the generated script; a rewrite could fix it. suggested_fix is written to be handed verbatim to CodeWriter.write(feedback=...).
  • environment_error — the fault is in the container or its inputs; regenerating the script would change nothing.

A failed download is decided by whether a different script could succeed. If the network works but one specific source refused — HTTP 403/404/410/5xx from a particular URL — that is recoverable_error, because a rewritten script can fetch the same data elsewhere. Only a container with no network at all is an environment_error. This rule exists because the old prompt listed "a network/download failure" under environment_error without qualification, and the first tabular run hit exactly that: a dead Boston Housing URL was triaged environment_error, so the Orchestrator stopped immediately with zero retries — on a failure one regeneration would have fixed. Re-triaging the same real log with the corrected prompt returns recoverable_error.

Four rules constrain suggested_fix, since it is handed verbatim to the model that rewrites the script:

  1. Never change what is being reproduced. Same dataset, model, task and metric. The first corrected triage run suggested, among its options, switching to "a standard alternative regression dataset" — a fix that makes the run pass while silently measuring a different experiment.
  2. One fix, not a menu — the rewriter may pick the wrong item.
  3. No API or source it is unsure still exists — the same run also suggested sklearn.datasets.load_boston(), which was removed in scikit-learn 1.2.
  4. No specific identifier (dataset id, version, URL, checksum) unless it appears in the log. Describe the mechanism and let the Coder choose the value. Before this rule, triage recommended Boston Housing as OpenML data_id=506, which is a different dataset entirely (531 is Boston) — and a wrong data_id does not fail, it quietly trains on the wrong data.

The prompt calls out the genuinely ambiguous case explicitly: a missing import is an environment_error if the image lacks the package, but a recoverable_error if the script imports a name that does not exist inside an installed one.

The category is re-validated on parse even though the tool schema declares an enum — the schema is a strong hint to the model, not an SDK-enforced guarantee, and a silently mislabelled category would misroute the entire retry decision.

The Dockerfile

python:3.11-slim, not pytorch/pytorch: the official PyTorch images are CUDA-based and carry the CUDA runtime, cuDNN and NCCL layers — several GB that a CPU-only CIFAR-10 gate run never touches. CPU-only wheels come from --index-url https://download.pytorch.org/whl/cpu (--index-url, not --extra-index-url, so a CUDA build from PyPI can never be resolved instead).

This stage is the platform trap's solution, not another instance of it. CLAUDE.md and ocr/README.md document the host constraint: Intel Mac + Python 3.13, and no PyTorch release ships Intel-macOS wheels and 3.13 support at the same time. None of that applies inside the container, which runs its own Linux CPython 3.11 against Linux wheels. The host's OS, interpreter and lockfile are irrelevant to it — which is exactly why the generated scripts can finally be run.

Nothing generated is copied in. There is no COPY train.py; the paper directory is bind-mounted at docker run time. The image stays completely static, so the Coder can regenerate every script in the repo without rebuilding it or invalidating a single layer.

Versions are pinned so a rebuild months from now reproduces the sandbox a recorded run used — an unpinned image would silently change what "the script failed" means. torch is pinned as 2.5.1, not 2.5.1+cpu: the CPU index tags the x86_64 wheel with the +cpu local version but the aarch64 one without it, so the bare pin resolves on both the Intel dev machine and an Apple Silicon collaborator's.

What is in the image, and why each piece is there

Package Pin Why
torch, torchvision 2.5.1, 0.20.1 (CPU index) Every generated script's model and training loop; torchvision for image datasets and transforms.
numpy 2.1.3 Universal.
pandas, scikit-learn, scipy 2.2.3, 1.5.2, 1.14.1 Generalization beyond image classification. A tabular paper has no torchvision loader: its script fetches data from OpenML via sklearn.datasets.fetch_openml (which returns a pandas frame) and fits its split/scaling/PCA with scikit-learn. Never the model — that is always torch. scipy is scikit-learn's own requirement, pinned explicitly because it is numerical code a result can depend on.
transformers, accelerate 4.46.3, 1.1.1 Legacy. coder/ no longer generates Trainer scripts, but the NIN/WRN scripts already on disk and every archived attempt under orchestrator/output/ still import it. Dropping the pair would turn those into ImportErrors.
pillow 11.0.0 torchvision's image backend.

There is deliberately no TensorFlow/Keras. coder/ always reimplements in PyTorch, even for a paper written in Keras, and discloses the framework-default differences that implies (Adam epsilon, layer initialization, ...) instead — see coder/README.md. A second framework would add a second large dependency tree to the image and give every script two ways to be subtly wrong.

The three new packages are all from the same release window as the torch/numpy pins, all accept numpy==2.1.3, and all ship cp311 wheels for both x86_64 and aarch64. They are installed in the same pip install command as numpy==2.1.3, not a later step: a separate pip install scikit-learn is free to upgrade an installed numpy to satisfy itself, silently. One command makes the resolver honour every pin jointly or fail the build.

Logging

Detailed by design, via loguru (not print) — the daemon version, the build, the exact docker run argv for every stage, the container name, the budget, the captured byte counts and where the full logs went, the parsed metrics field by field, each stage's verdict and elapsed time, the escalation stop, and the triage category, reasoning and suggested fix. A run that fails should be diagnosable from console output alone.

Setup

uv sync --extra runner --group dev
cp .env.example .env   # ANTHROPIC_API_KEY — only needed if a run fails

Docker Desktop (macOS) or the docker engine (Linux) must be running. There is no Python docker SDK dependency — this stage shells out to the CLI.

# one paper, escalating probe -> smoke -> capped, building the image first
uv run python -m runner.pipeline --input "coder/output/2016-05 - Wide Residual Networks"

# every generated paper, reusing an already-built image
uv run python -m runner.pipeline --input coder/output --no-build

# just the cheapest gate
uv run python -m runner.pipeline --mode probe

# tighter budgets, capped resources, offline (warm cache), no API call at all
uv run python -m runner.pipeline --timeout probe=300 --timeout smoke=900 \
    --memory 8g --cpus 4 --network none --no-triage

# a paper whose first fit is honestly enormous: wait 3 h of silence, not 90 min
uv run python -m runner.pipeline --mode full --first-record-deadline full=10800

# the paper's real setup — needs a GPU and hours; never reached by default
uv run python -m runner.pipeline --input coder/output/<paper> --max-stage full

--max-stage and --mode are mutually exclusive: the first escalates up to a stage, the second runs exactly one. Papers with an existing runner_output.json are skipped unless --force is given.

Output per paper (gitignored):

runner/output/<paper>/
├── runner_output.json         # status, stages, metrics, excerpt, triage
└── logs/
    ├── probe.stdout.log       # FULL, untruncated
    ├── probe.stderr.log
    └── ...

runner_output.json carries the top-level verdict (status, stage_reached, failed_stage, exit_code, wall_clock_seconds, reproduced_metrics, logs_path, log_excerpt, error_trace, triage) plus a stages list with the same detail per stage — so the Critic can compare against the claim while the Orchestrator sees exactly how far the escalation got.

Dependency choice

runner is its own pyproject.toml extra (anthropic + python-dotenv), identical in shape to reader's and coder's and, importantly, torch-free on the host. torch exists only inside the image. That is what lets this stage stay in the managed uv.lock on the Intel-macOS dev machine while being the thing that finally executes torch code.

Status

Image rebuilt for generalization (pandas / scikit-learn / scipy)

  • docker build -t reprobot-runner:latest runner/ succeeded in 3 min 52 s (Docker server 29.7.2, x86_64). No layer came from cache: the floating python:3.11-slim tag resolved to a new base digest (sha256:9534e5a8…), so apt and the torch step rebuilt too — and the torch step's unpinned transitive dependencies (sympy, networkx, jinja2, fsspec, …) resolved to whatever is current. The pins above are honoured, but this image is not byte-identical to the one the earlier runs used. That gap predates this change; pinning the base by digest and adding a constraints file would close it.
  • Inside the built image, import pandas, sklearn, torch, torchvision (plus numpy, scipy, transformers, accelerate, and from sklearn.datasets import fetch_openml) all succeed, reporting torch 2.5.1+cpu, torchvision 0.20.1+cpu, numpy 2.1.3, pandas 2.2.3, scikit-learn 1.5.2, scipy 1.14.1, transformers 4.46.3, accelerate 1.1.1. pip check: no broken requirements.
  • numpy stays at 2.1.3. The build log shows the torch step pulls numpy 2.4.6 from the CPU index as an unpinned dependency, and the joint pin step then replaces it with 2.1.3. That happened before this change too; it is why the pins share one pip install.
  • Regression probe, new plain-PyTorch NIN script: runner.pipeline --mode probe → PASSED, exit 0, 76.3 s, triage: null, metrics read from the file in the new task-agnostic shape (see coder/README.md's Status for the full run).
  • Not verified: fetch_openml against the live OpenML service from inside the container. OpenML's API host now answers api.openml.org with a 301 to www.openml.org, which urllib follows, and the file_id download route is still listed in its metadata — so it is expected to work, but no dataset has been fetched through it yet. The first tabular paper's probe is that test.

Earlier verification (HuggingFace Trainer era)

Verified end to end in Docker. The image builds and a real container runs a real generated script to completion:

[docker] built reprobot-runner:latest in 224.2s
  [probe] budget: 2700s
  [probe] captured 1124 chars stdout, 2218 chars stderr (full, untruncated)
  [probe] metrics (file): claim_id=c34 test error=92.1875 % (train_accuracy=14.45)
  [probe] PASSED in 166.4s (exit 0)
[done] 1 paper(s) passed, 0 failed their stages, 0 could not be run at all

runner_output.json came back status: success with triage: null — no API call is spent on the success path, as designed.

The shared dataset cache is worth what it costs. The same probe took 1774 s natively with a cold cache and 166 s in the container with a warm one. Nearly all of that difference is the one-time ~170 MB CIFAR-10 download, which every one of the 8 papers would otherwise repeat.

Verified

  • The generated script genuinely runs, and the stage budgets below are calibrated against that run rather than estimated. reproduce.sh probe was executed natively on the dev machine (outside Docker, in a throwaway Python 3.11 venv — see CLAUDE.md's Tooling section for the narrow legacy pin-set that makes that possible on an Intel Mac). It completed with exit 0 and wrote a metrics.probe.json matching the documented contract exactly, all twelve keys:

    train_runtime             48.7 s   (256 samples, 1 epoch, 2 optimizer steps)
    train_samples_per_second   5.256
    eval passes               ~6.4 s (128 eval) + ~12.2 s (256-sample train-acc)
    total compute             ~67 s
    total wall clock          1774 s   <- the other ~1707 s was the CIFAR-10 download
    

    Two things follow, and both changed the code. First, the cold dataset fetch dominates everything else, so probe's budget has to tolerate it (the earlier 1200 s guess would have timed out on the very first run, looking exactly like a hung script) and the shared cache mount is load-bearing, not an optimisation. Second, extrapolating 5.256 samples/s to full — 50,000 samples × 200 epochs — gives roughly 22 days on this CPU, which settles any ambiguity about whether full is GPU-only.

    What it does not verify: any of this happening inside a container. The script ran on the host — the containerised run above is the one that proves the Docker path itself.

  • ruff check, ruff format --check, mypy --strict runner/, and pre-commit run --all-files all pass.

  • 110 assertions over every daemon-free function, against synthetic input: log truncation (boundary cases, exact dropped-char accounting, the chatty-stdout property proved against a 150k-char stdout), traceback extraction (last-of-a-chain, the no-traceback fallback), metrics parsing (contract object recovered; HF Trainer's single-quoted repr and unrelated JSON both correctly rejected; invalid/array/missing files), stage escalation, --timeout parsing and all four of its rejection paths, container-name legality against Docker's name grammar, docker run argv assembly, byte/str stream decoding, paper discovery, and triage payload parsing.

  • run_stage and run_paper end-to-end with subprocess.run monkeypatched, which needs no daemon and covers: exit-0 success with metrics read from the mount, full untruncated logs written to disk, the timeout path issuing docker kill against the exact --name it launched with, partial raw-bytes output surviving decode, escalation stopping before capped when smoke fails, triage firing on failure with suggested_fix captured, no API call on either success or timeout, --no-triage suppressing it, and runner_output.json round-tripping through asdict/json.

  • The reproduce.sh interface, against the real generated file for Wide Residual Networks: bash -n syntax check passes; its four case arms are probe/smoke/capped/full, matching STAGE_ORDER exactly; an unknown mode exits 2 with a usage message without reaching python.

  • The Dockerfile structurally: all 9 logical instructions parse and use valid keywords, base is python:3.11-slim, no COPY/ADD of generated code, torch from the CPU-only index, everything pinned.

  • Every pinned version exists as a real artifact (checked over HTTP, since it could not be checked by building): torch-2.5.1+cpu-cp311-cp311-linux_x86_64.whl (HTTP 200, 174.7 MB), torchvision-0.20.1+cpu-cp311-cp311-linux_x86_64.whl (HTTP 200), both aarch64 counterparts (HTTP 200), and transformers==4.46.3, accelerate==1.1.1, numpy==2.1.3, pillow==11.0.0 on PyPI (HTTP 200).

Exercised for real since

Everything this section once listed as written-but-unrun has now run:

  • docker build — many times, most recently with pandas/scikit-learn/scipy added for tabular papers (3 min 52 s).
  • docker run — real training in real containers across four papers, through every stage including the first full run (Tang 2013, MNIST).
  • metrics.<mode>.json — written by real containers in both the old accuracy-keyed shape and the current train_metric/eval_metric shape, and parsed back by summarize_split_metrics().
  • Live triage — real Haiku calls on real failures, including a dead-URL download that exposed a misclassification now fixed (see "Triage" above).
  • Stage budgets — calibrated against a measured run (see the timeout table).
  • The Coder↔Runner retry loop — built as orchestrator/, and proven to repair a real runtime bug on its first retry.

Still open

  • Check-ups judge health, not fidelity. A run that learns healthily but lands far from the paper's number (Wijaya: RMSE 4.48 vs 3.02) passes every check-up; comparing a result with its claim is critic/'s job (added 2026-09-14), which runs after the Runner inside the Orchestrator.
  • Check-ups only see what the script records. A script from before the progress contract (NIN, WRN, Tang, Wijaya's current scripts) writes no history and is judged on its exit code alone until regenerated — and no_first_record is deliberately disarmed for it, so a legacy script that hangs is still bounded only by its stage budget.
  • Thresholds are calibrated on nine papers' worth of curves. Every halt logs its evidence, so a false positive is visible; tune the constants in checkups.py.
  • The image is not reproducible byte-for-byte. python:3.11-slim is a moving tag and torch's own transitive dependencies are unpinned, so a rebuild can differ from the image an earlier run used. Pinning the base by digest would fix it.

Worth knowing about the class of failure this stage exists to catch: a real AttributeError (_NoOpScheduler.get_last_lr() reading a self.optimizer the class never assigns) passed ast.parse, because a script can be perfectly valid Python and still die on its first step. That is the reason probe exists at all: a syntax gate proves a script parses, never that it runs.