Skip to content

feat(eval): add resumable batch runner and verifier-env forwarding - #6977

Closed
Colafornia wants to merge 3 commits into
apache:rust-previewfrom
Colafornia:feat/eval-batch-runner
Closed

Colafornia wants to merge 3 commits into
apache:rust-previewfrom
Colafornia:feat/eval-batch-runner

Conversation

@Colafornia

@Colafornia Colafornia commented Nov 17, 2026 •

Copy link
Copy Markdown
Member
English

Summary

#6938 and #6849 wired up single-task Harbor execution (maka-eval run) and per-request Host usage pricing, but running multi-task or multi-subject comparisons still required external shell loops with no crash recovery, per-run lock protection, or native verifier.env forwarding.

This PR adds maka-eval batch and native --verifier-env support. maka-eval batch expands a tasks × repetitions × subjects JSON spec, freezes normalized canonical paths in experiment.json, records two-phase started/settled events in an OS-locked append-only results.jsonl, resumes interrupted runs without repeating settled work, isolates per-cell failures, and writes summary.json.

Refs #6667.

Changes

  • Resumable batch runner (src/batch.rs):
    • Validates and normalizes BatchSpec into canonical paths, freezing it in experiment.json so resumed runs against the same --out reject mismatched specs (bundleDir, harborBin, forceBuild, verifierEnv, repetitions, maxSteps, timeoutMs, subjects, tasks).
    • Expands tasks × repetitions × subjects in deterministic order (cellId = "${task}::${rep}::${subject.id}") under isolated per-cell directories (trials/cell-{idx}), preventing case-colliding subject IDs or path-separator issues on disk.
    • Guards results.jsonl with an exclusive non-blocking File::try_lock, fails fast on truncated trailing lines or out-of-order journal records, and skips already-settled cells on resume.
    • Records started before launching a cell and settled after completion; if a previous run was killed mid-cell (leaving started without settled), resuming auto-settles that cell as failed (durationMs: null, summaryPath: null) while preserving trials/cell-{idx} artifacts untouched, then continues remaining cells. Unstarted non-empty directories still fail loudly with the cell_id in the error.
    • Isolates per-cell Harbor/trial failures without aborting remaining cells, writes atomic summary.json (completed, subjectFailed, failed, cells), and exits non-zero when failed > 0.
  • Three-state trial settlement & native verifier.env (src/harbor.rs, src/guest.rs, src/main.rs):
    • Classifies each trial into completed, subject_failed (retaining valid verifier scores including 0.0 when Host usage settled cleanly), or failed (infra, Harbor, or evidence errors).
    • Forwards --verifier-env KEY=VALUE / verifierEnv directly into Harbor's verifier.env, rejects duplicate keys and invalid entries (NUL / =), shares HarborRunOptions and run_and_settle between run and batch, scopes the Tokio runtime to guest-run, rejects empty/whitespace stopReason and infraError in guest.rs, and adds no new workspace dependencies (Cargo.toml / Cargo.lock unchanged).
  • Public CLI integration tests (tests/eval_runner.rs) & docs (README.md, README.zh-CN.md):
    • Replaces internal white-box unit tests with 7 end-to-end public CLI integration tests (maka-eval run and maka-eval batch against real maka Host processes, 0 unit tests).

Verification

Verified on commit 8c03461e3 (rebased onto 82b262826; 7 files changed, 1534 insertions(+), 318 deletions(-)):

  • Public CLI integration suite: cargo test -p maka-eval passed (7/7 integration tests in 16.23s, 0 unit tests), covering:
    • Existing guest-run and run contracts (subagent delegation, 429 retry, priced/unpriced/missing-cache settlement, maxSteps retirement, missing-usage rejection, and infraFailed root-cause reporting).
    • --verifier-env forwarding into Harbor job config and duplicate-key rejection.
    • Live maka-eval batch matrix execution, dual-process results.jsonl lock contention, crash recovery after process termination (auto-settling the interrupted started cell as failed while preserving orphan artifacts), experiment.json freeze enforcement, and idempotent resume.
    • Case-colliding subject directory isolation (same vs Same), per-cell failure isolation without aborting remaining cells, and refusing unexpected unstarted non-empty cell directories with cell_id.
  • Live Docker Harbor 0.26.0 batch runs: Rebuilt the Linux aarch64 bundle (maka-eval BuildID 7bad70928ed3bba99a352f891582a89b70bde08e) and executed real containerized trials (alexgshaw/*:20251031, forceBuild: false, native verifierEnv):
    • Three-dimension matrix (1 task × 2 reps × 2 subjects): log-summary-date-ranges × deepseek-native / deepseek-openai-compat settled {completed: 4, subjectFailed: 0, failed: 0}; native cells recorded costUsd: 0.003235938 (score: 0.0) and 0.00249432 (score: 1.0), while openai-compatible cells recorded metering: complete, costUsd: null, and score: 1.0.
    • kill -9 crash recovery: Killed mid-cell-0 (leaving started without settled); resuming the same --out auto-settled cell-0 as failed (durationMs: null, summaryPath: null, preserving trials/cell-0), executed cell-1 to completed (score: 1.0, costUsd: 0.002993376, 56315 ms), wrote summary.json ({completed: 1, subjectFailed: 0, failed: 1}), and exited non-zero (error: batch finished with 1 failed cell(s)).
    • Mixed failure isolation: 2-task batch with the 2nd task pointing to a missing Docker image tag settled cell-0 as completed (score: 1.0) and cell-1 as failed with the full Docker compose error without aborting the batch ({completed: 1, failed: 1}, exit code 1).
    • docker ps -a was empty after every run.
  • Static & license checks: cargo fmt -p maka-eval --check, cargo clippy -p maka-eval --all-targets --no-deps -- -D warnings, RUSTDOCFLAGS="-D warnings" cargo doc --locked -p maka-eval --no-deps, and node scripts/asf-license-headers.mjs check all passed.

Did not run the full-repo just check locally.

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Google Antigravity implemented maka-eval batch, the harbor/guest/main boundary refinements, README updates, and the eval_runner integration tests. Commits fdb21abd8, 1a0128b1b, and 8c03461e3 carry the Generated-by trailer.

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No
简体中文

概述

#6938 和 #6849 打通了单题容器评测(maka-eval run)与 Host 用量计费,但跑多题或多模型对比仍需依赖外部脚本循环,缺乏文件锁保护、崩溃恢复和原生 verifier.env 透传。

本 PR 新增 maka-eval batch 子命令与原生 --verifier-env 支持:maka-eval batch 按 JSON 配置展开 tasks × repetitions × subjects 矩阵,将归一化后的规范路径冻结写入 experiment.json,在文件锁保护的只追加 results.jsonl 中记录 started/settled 两阶段事件,支持断点续跑、单格失败隔离并最终输出 summary.json。

关联 #6667。

主要改动

  • 支持断点续跑的批量执行器(src/batch.rs):
    • 校验并归一化 BatchSpec 路径后冻结写入 experiment.json,针对同一 --out 续跑时会校验冻结配置一致性(bundleDir、harborBin、forceBuild、verifierEnv、repetitions、maxSteps、timeoutMs、subjects、tasks)。
    • 按固定顺序展开 tasks × repetitions × subjects(cellId = "${task}::${rep}::${subject.id}"),在独立目录 trials/cell-{idx} 下落盘,避免被测名称大小写冲突或路径分隔符问题。
    • 通过非阻塞独占锁(File::try_lock)保护 results.jsonl,遇到截断残行或乱序事件直接报错退出,续跑时跳过已结算单元。
    • 执行单元前先落盘 started、结束后写 settled;若上次进程在中途被强杀(存在未结算的 started),续跑时会自动将其结算为 failed(durationMs: null、summaryPath: null)同时完整保留 trials/cell-{idx} 现场目录,并继续执行剩余单元;而未记 started 的意外非空目录仍会明确拒绝覆盖并在报错中给出对应 cell_id。
    • 单格 Harbor/试验失败只记录该格为 failed 而不会中断后续单元,最终原子写入 summary.json(completed、subjectFailed、failed、cells),若存在失败单元则返回非零退出码。
  • 三态试验结算与原生 verifier.env 透传(src/harbor.rs、src/guest.rs、src/main.rs):
    • 试验结果统一收口为 completed、subject_failed(Host 用量已正常结算时保留包括 0.0 在内的合法 verifier 分数)和 failed(基础设施、Harbor 或证据缺失故障)。
    • 支持 --verifier-env KEY=VALUE / verifierEnv 直接写入 Harbor 的 verifier.env 并拦截重复键及非法键值;run 与 batch 复用同一套 HarborRunOptions 与 run_and_settle,Tokio runtime 仅限于 guest-run 使用,guest.rs 拒绝空白 stopReason / infraError,且不引入新的工作区依赖(Cargo.toml / Cargo.lock 无改动)。
  • 公共 CLI 端到端测试(tests/eval_runner.rs)与文档(README.md、README.zh-CN.md):
    • 删除内部白盒单元测试,改为 7 个纯经由 maka-eval run / maka-eval batch 驱动真实 maka Host 进程的集成测试(0 个单元测试)。

验证

基于提交 8c03461e3(已 rebase 到 82b262826,总变更 7 files changed, 1534 insertions(+), 318 deletions(-))完成如下验证:

  • 公共 CLI 集成测试:cargo test -p maka-eval 通过(7/7 集成测试通过,耗时 16.23s,0 单元测试),覆盖:
    • 原有 guest-run 与 run 链路(子会话委托、429 重试、有价/无价/缺缓存拆分结算、maxSteps 截断退役、缺 token 计数拦截、infraFailed 根因透出)。
    • --verifier-env 透传至 Harbor 任务配置及重复键校验拦截。
    • maka-eval batch 实时矩阵执行、双进程 results.jsonl 文件锁互斥、强杀中断后续跑自动将未结算格标为 failed 并保留现场目录、experiment.json 配置冻结校验、幂等空跑续跑。
    • 大小写冲突 subject 目录隔离(same vs Same)、单格失败隔离不中断批量执行、未记 started 非空脏目录拒绝覆盖并附带 cell_id。
  • Docker Harbor 0.26.0 真容器批量实跑:重编 Linux aarch64 运行包(maka-eval BuildID 7bad70928ed3bba99a352f891582a89b70bde08e),在 alexgshaw/*:20251031 预打镜像上实跑(forceBuild: false + 原生 verifierEnv):
    • 三维矩阵(1 题 × 2 reps × 2 subjects):log-summary-date-ranges 对 deepseek-native 与 deepseek-openai-compat 均完成,{completed: 4, subjectFailed: 0, failed: 0};原生两格分别记录 costUsd: 0.003235938(score: 0.0)与 0.00249432(score: 1.0),openai-compatible 两格均为 metering: complete、costUsd: null、score: 1.0。
    • kill -9 强杀续跑:在 cell-0 执行中途强杀留下未结算的 started 记录;同一 --out 续跑后自动将 cell-0 结算为 failed(durationMs: null、summaryPath: null、保留 trials/cell-0),继续跑完 cell-1 为 completed(score: 1.0、costUsd: 0.002993376、56315 ms),产出 summary.json({completed: 1, subjectFailed: 0, failed: 1})并以非零码退出(error: batch finished with 1 failed cell(s))。
    • 混合失败隔离:2 题批量中第 2 题指向本地不存在的镜像 tag,cell-0 正常 completed(score: 1.0),cell-1 捕获完整 Docker compose 报错落盘为 failed 且未中断批量({completed: 1, failed: 1},退出码 1)。
    • 每次运行结束后 docker ps -a 均为空。
  • 静态与许可证检查:cargo fmt -p maka-eval --check、cargo clippy -p maka-eval --all-targets --no-deps -- -D warnings、RUSTDOCFLAGS="-D warnings" cargo doc --locked -p maka-eval --no-deps、node scripts/asf-license-headers.mjs check 全部通过。

本地未跑全仓 just check。

AI 使用

单选:

  • 没有生成式工具作出实质性贡献
  • 生成式工具作出了实质性贡献

工具与范围:Google Antigravity 实现了 maka-eval batch、harbor/guest/main 边界收拢、中英文 README 更新以及 eval_runner 端到端集成测试;提交 fdb21abd8、1a0128b1b 与 8c03461e3 均附带 Generated-by trailer。

审查清单

  • 测试覆盖本次变更且无修复前会失败
  • 格式、类型检查与受影响测试集已在本地通过

本 PR 是否带来行为变更?

  • 是 — 如上文概述所述
  • 否

@Colafornia
Colafornia force-pushed the feat/eval-batch-runner branch from 494caa3 to 0183c56 Compare November 17, 2026 16:08
@github-actions github-actions Bot added the effort/XL Under 2500 readable lines label Nov 18, 2026
Add `maka-eval batch` (`products/eval/src/batch.rs`) to expand
`tasks × repetitions × subjects` specs, guard append-only `attempts.jsonl`
under an exclusive file lock, resume interrupted runs without re-running
settled cells, and write `summary.json`.

- Adjudicate `HarborRunOutcome` into closed 4-state trial outcomes
  (`completed`, `subject_failed`, `infra_failed`, `indeterminate`),
  blocking automatic retries on `AgentTimeoutError` or broken evidence
  invariants while bounding `infra_failed` retries to `maxRetries`.
- Forward optional `--verifier-env` / `verifierEnv` to Harbor's native
  `verifier.env` job config, share input validation via borrowed
  `TrialSpec`, and run `run`/`batch` synchronously while keeping the
  Tokio runtime scoped to `guest-run`.
- Exercise `maka-eval run` and `maka-eval batch` end-to-end through the
  public CLI against live Host processes and verify cell expansion and
  selection parity against the frozen TypeScript reference (`85a1031c`).

Refs apache#6667.

Generated-by: Google Antigravity
On Linux, `std::env::current_exe()` reads `/proc/self/exe`, which
dereferences symlinks back to `target/` and escapes `IsolatedEnv.bundle`
during `run_cli_persists_summary_and_surfaces_guest_root_cause_on_infra_failure`.
Stage bundle binaries with `std::fs::hard_link` (falling back to
`std::fs::copy` across filesystems) so the kernel `exe_file` dentry
remains inside the isolated bundle directory on all platforms.

Refs apache#6667.

Generated-by: Google Antigravity
@Colafornia
Colafornia force-pushed the feat/eval-batch-runner branch from 4dbcba2 to 1a0128b Compare November 18, 2026 14:42
…t/settle recovery

Replace the 4-state retry adjudicator and content-hashing freeze layer
with a minimal resumable batch runner:
- Collapse trial settlement to completed, subject_failed, and failed
- Record started/settled events in results.jsonl so interrupted cells
  auto-settle as failed on resume while preserving artifacts, while
  unstarted non-empty cell directories still fail loudly
- Drop sha2/hex dependencies and keep path-level experiment.json freeze
- Replace internal white-box tests with public CLI integration tests

Refs apache#6667.

Generated-by: Google Antigravity
@Colafornia Colafornia changed the title feat(eval): add resumable batch runner and 4-state trial retry feat(eval): add resumable batch runner and verifier-env forwarding Nov 20, 2026
@M4n5ter
M4n5ter deleted the branch apache:rust-preview November 23, 2026 00:07
@M4n5ter M4n5ter closed this Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/XL Under 2500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants