DEV Community

Finley Li
Finley Li

Posted on

A Retried Case Is Not a Passed Case: Attempt-Level Traces for Eval Harnesses

An eval harness often grows a retry loop for mundane reasons: shared build machines, transient linker failures, or a test runner that occasionally exits nonzero under load. The loop is easy to add and easy to forget. The problem is not retry itself; it is collapsing several attempts into one verdict without recording what each attempt observed.

This article describes one failure mode, a record shape that exposes it, and observation-based controls a reader can use to check their own harness. The scenario is illustrative, not a reported incident. No executable commands are included; the checks are proposed observations, not results.

The scenario

A team grades AI-generated C++ patches. For each case, the harness compiles the patched tree, runs a test binary, and compares the generated out.txt with an expected artifact. A configuration bug points the expected-artifact path at out.txt itself, so the comparison is self-referential.

Attempt one times out while the test binary is writing out.txt, leaving a partial file. The harness retries. Attempt two reruns the case, overwrites out.txt, and then compares out.txt with out.txt. The bytes match. The case reports PASS.

The self-comparison is the defect. Retry is the condition under which the defect produced a green verdict: without a second attempt, the timeout would have surfaced as a failure. The verdict is untrustworthy because the expected artifact was never a fixed input; it was an output of the step it was supposed to check.

Why attempt-level records matter

A retry is a second execution of a stateful operation. The AWS Builders' Library entry on timeouts, retries, and backoff with jitter notes that retries add load to a dependency that may already be struggling, and that backoff with jitter spaces attempts so clients do not retry in lockstep. It also states the limit relevant here: neither mechanism proves that the preceding call had no side effects.

HTTP semantics make the same distinction from another angle. RFC 9110 section 9.2.2 defines idempotency in terms of the intended effect on the server, not identical responses, and says automatic retry of a non-idempotent request is safe only with knowledge that its semantics permit replay or that the original was never applied. A test case is not an HTTP request, but the reasoning transfers: retry safety depends on what the operation mutates.

'Passed on attempt two' is therefore a claim about attempt two's inputs. Those inputs may include files, caches, locks, or partial output left by attempt one. Collapsing attempts into one boolean discards that distinction.

Record shape

OpenTelemetry traces provide a useful model. A span describes one operation with a span ID, trace ID, timestamps, and optional attributes or events; a parent span ID relates a child operation to its parent within the trace. A trace describes instrumented work, not proof of external delivery. For an eval case, one case can be the parent span and each attempt a child span.

A minimal record can be JSON Lines or a table with these fields:

  • Parent: case_id, patch_sha, suite, attempt_count, verdict, golden_digest_before, golden_digest_after.
  • Child, one per attempt: attempt ordinal, exit_code, duration_ms, timed_out, and a short failure_class such as build, test, timeout, or harness.
  • Verdict: clean_pass only when one attempt exits zero; retried_pass when more than one attempt ran and the last exits zero; fail when the last attempt exits nonzero. A retried pass should not be merged into the clean-pass column.

The exact names are less important than the separation. The parent answers 'what did the case decide?' The children answer 'what did each attempt observe?' Without the children, a retried pass is indistinguishable from a clean pass.

Freeze golden artifacts during a case

The self-fulfilling pass above is a write-permission bug wearing a retry costume. The design rule is: golden files are read-only inputs for the duration of a case, materialized from a content-addressed store, and the harness refuses to start if the golden path is writable by the case process.

A substantive check is observational. Input: one case and its golden directory. Observe: a digest of the golden directory before the case starts and after it ends. If the digest changes, the case regenerated its own expected output; the verdict is untrustworthy regardless of what it says. If the digest is stable, that does not prove the case is correct, but it removes this specific self-certification path.

Controls to run before trusting an aggregate

These are proposed controls, not executed results. Each row states an input, the observation to make, and how to interpret a mismatch.

Control Input Observe Mismatch means
Empty diff No patch changes Verdict for a suite that does not explicitly accept no-op patches A clean pass suggests the grader may be vacuous; confirm whether the suite is supposed to require a behavioral change
Syntax break Remove a semicolon from a compiled source file Verdict and failure class Expected fail; a pass means the build or test path is not being exercised
One-shot failure Wrapper exits nonzero on attempt one only Attempt count and verdict Expected retried pass or flaky, never clean pass; a clean pass means retries are being folded away
Timeout Test sleeps beyond a documented per-case time budget Timeout flag, duration, verdict Expected timeout or fail, not clean pass; retrying a hung case multiplies wall clock without diagnosis

The empty-diff control needs a caveat: if the suite explicitly treats a no-op as valid, an empty diff passing is not evidence of a vacuous grader. The control is meaningful only for a grader whose pass verdict is supposed to mean 'the patch satisfies the suite.'

Gate on attempt count, not only the verdict

If the report has no attempt count, retries are invisible and flake rate is unmeasurable. Emit attempt_count and verdict per case, then gate on them. One reasonable policy is to fail the pipeline when a newly added case is retried_pass, and to track retried_rate as a first-class number. A harness that reports only pass/fail can report retry luck as patch quality.

Common failure modes

Retrying non-idempotent steps. Package installs, cache warmers, and code-generation steps can double-apply. A retry there mutates the environment the next attempt is graded in. Retry only when the operation's semantics permit replay or the original was never applied, as RFC 9110 frames the HTTP case.

Uncapped retries without jitter. On a shared build box this can produce a thundering herd, the load pattern the AWS guidance warns about. Backoff and jitter reduce lockstep; they do not prove the prior attempt was side-effect free.

Folding retried passes into clean passes. The aggregate then measures retry luck rather than patch quality, and the number can drift without anyone changing the grader.

A golden-update flag that defaults to on. If a flag can rewrite expected outputs during grading, the check becomes self-certifying. Make updates explicit and separate from grading.

Timeout treated as transient by default. A timeout may mean the case is hung, not that the machine hiccuped. Retrying can multiply wall-clock cost and still never surface a hung classification.

Tradeoffs and limits

If the grader is a pure function — parse a static file, compare two strings, no subprocess — attempts and retries are moot and the extra fields are noise.

Span-per-attempt also adds cardinality. On a large suite, cap attributes on attempt spans and sample if the trace backend starts rejecting them; keep case_id, attempt, and exit_code at minimum.

Recording attempts is not the same as fixing flakes. It makes them visible and gateable. Whether a given case should be retried at all depends on whether the underlying operation is idempotent and whether the failure is known to be transient.

Disclosure

This draft was produced with AI assistance. The scenario is illustrative, not a reported incident, and no executable commands are included. A human should verify the harness semantics and the cited OpenTelemetry, RFC 9110, and AWS sources before posting.

This article was created with AI assistance.

Top comments (0)