Replay the deps flow's upstream stage in bin/eval

What does this MR do and why?

Part of #40: task B3a, the bin/eval side of the upstream review. It is stacked on !97 (merged) and targets jecsanders-42-make-eval. The stage itself (B1 and B2) is built in a separate MR off main. Both work to the same contract, so either can land first.

  1. One answer file per agent. EvalFlow.with_answers wrote every agent's answer to answer.txt, and the file tool won't overwrite, so the judge's answer would have been lost. The suite's classifier keeps answer.txt, and every other agent writes answer.<agent>.txt. Result rows record the judge's answer as judge.
    • On deps-gitlab, whose flows/flow.yml has three classifiers, a case the gate sends to classify_impact or classify_spec_risk now counts as "No answer". Before, that classifier's tier was scored as a deps tier.
  2. Replaying the fetch. The sandbox can't reach upstream, but run_command steps pass EvalFlow.local?.
    • bin/eval snapshot takes fetch_upstream's compiled command from flows/deps.yml and runs it with Ruby, outside the sandbox. It runs in a scratch directory holding the case's saved mr.json, mr_diff.json and a tier.txt of low. It saves <case>.upstream.out, .upstream.json and .upstream_route.txt beside the case. The runner is Upstream.fetch in evals/lib/upstream.rb, so specs can reach it.
    • It never overwrites a saved file, and it skips a case with only some of the three saved.
    • It saves nothing from a fetch that timed out, wrote no JSON or route, or could not reach upstream, so the next snapshot tries again. The fetch runs in a process group of its own, so a timeout or an interrupt stops everything sh started.
    • In a run, EvalFlow swaps fetch_upstream for a stand-in that runs mv tier.txt tier_model.txt. It then copies the saved upstream.json and route when the model's tier is low, or writes route skip when it isn't.
    • review_upstream's upstream input becomes the saved stdout as a literal, the same way reads are given.
    • A flow without fetch_upstream is unchanged. A flow that keeps it but has no saved output raises EvalFlow::Unsaved, and bin/eval aborts with run bin/eval snapshot. --show-flow uses a placeholder instead, so it needs no fetch.
  3. Report.
    • A new Upstream stage section has per-group totals: judged, check, incomplete, skipped, judge unreadable, as expected, and lowered by the stage.
    • Its per-case table shows what the stage did, the judge's tiers, the tiers labelled, and whether those are more or less cautious than the first variant's. The judge's answer is read as keep_higher_tier reads it: one JSON object whose tier is low, medium or high. Less cautious is in bold. x marks a run its upstream doesn't expect, and lowered by the stage marks a run labelled below the model's tier.
    • Right after the summary, a new Less cautious than main section lists every case a later variant labels less cautiously, so none can be missed.
  4. Suites.
    • deps-pilots.yml documents an optional upstream: key: keep, raise, check or incomplete. No case has a value yet, because none can be snapshotted until the stage exists.
    • Approving a case whose upstream isn't keep counts as a wrong approval. Such a case doesn't count as low work in "low cases approved".
    • deps-upstream.yml scaffolds the six planted cases from #40's evaluation plan. Each is one of the six low Go module bumps in deps-pilots, with its merge request files copied unchanged. planted: says what to edit in the saved upstream output. None is planted yet.

What the stage MR must provide that the contract doesn't say

  1. fetch_upstream reads only mr.json, mr_diff.json and tier.txt from its working directory. The snapshot's scratch directory has nothing else, so a read of gate.json or route.txt would find nothing.
  2. It needs only Ruby, git and the two hosts. It can't rely on a runner environment variable, a token, or a file outside its directory. The snapshot stops it, and everything it started, after 300 seconds, so its own network timeouts must be shorter.
  3. Its stdout is exactly the judge's input, and it writes nothing to stderr on a clean run. A run gives the judge the saved stdout. If tool_responses of run_command carries more than stdout, the judge would see more in production than in the eval. P3 should check what reaches the next step.
  4. It reads the tier as decide_labels does: the whole file stripped, then its first line, stripped and lower-cased. The contract only says the first line "is not low", and the stand-in reads it the decide_labels way. If the fetch reads it any other way, an answer like Low, or one starting with a blank line, takes a different route in production than in the eval.
  5. checksum: "unchecked" with complete: true. The route is skip, so the judge doesn't run, and no keep_higher_tier row raises it unless "clean" excludes unchecked. Either the fetch never writes that pair, or keep_higher_tier raises it to medium. The scorecard reports it as check (checksum unchecked).
  6. The red-flag rule values. The red-flag case plants os/exec, the contract's example. The stage MR should list the rules it flags, so the case can use a real one.
  7. A fetch that can't reach upstream writes a reason starting fetch failed. The contract gives that only as an example. The snapshot relies on it to tell a failure worth retrying from an incomplete answer that belongs to the case, such as not a single Go module bump.

Once the stage lands, bin/eval run on a deps suite aborts until bin/eval snapshot has saved each case's upstream output. spec/eval already passes saved output to every eval_flow call on the real flows, and the deps chain spec pins only the classifier, its answer and write_tier_file, so the stage landing won't break spec/eval.

Not done here

  • No upstream output is saved yet, because no branch has the stage (B3b). The deps-upstream cases have their merge requests but no .upstream.* files.
  • No model call was made. bin/eval run without --show-flow and bin/eval snapshot both call the Duo CLI.

How to check

  • make check passes.
  • ruby bin/eval run deps-pilots --show-flow prints exactly what !97 (merged) prints on the current flow, and so does docs. On deps-gitlab the only difference is the file the two other classifiers save their answers to.
  • A synthetic two-agent flow with a fetch_upstream step (spec/eval/fixtures/upstream_flow.rb) covers the answer files, the stand-in and the judge's literal input. It also covers the refusal without saved output, the snapshot runner, and the no-op on a flow without the fetch. The stand-in's specs run its command in a scratch directory, and the timeout spec fails if the fetch outlives its sh.

🤖 Generated with Claude Code

Edited by Connor Sanders

Merge request reports

Loading
Loading