Skip to content

A failing test is fixed from its evidence, or not changed at all - #928

Merged
coderhelm[bot] merged 4 commits into
mainfrom
test-fix-from-evidence
Dec 1, 2026
Merged

coderhelm[bot] merged 4 commits into
mainfrom
test-fix-from-evidence

Conversation

@nambok

@nambok nambok commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A run that fixes a failing or flaky end-to-end test now works from evidence, or changes nothing. It reproduces the failure first, names one class from a closed set, and puts the fix where that class says. Changes that hide a failure are refused on the diff. The fix is proven with as many runs as the test's measured failure rate needs. Each failure gets one run, and that run is reopened if the test fails again after the merge.

Before this, a fix pull request could open on a cause its own run called inferred. A wait could go into a page object for a cause outside the test. A sandbox whose network refused the site counted as the test failing every run. Every proof was twenty runs, whatever the rate.

Changes

  • common::e2e::fix_evidence (new, pure, tested):

    • Reproduction: a repeat run that failed, or a kept report with the exact error and its trace, screenshot or page snapshot. Runs that never reached the page (network refused, no browser, no address) are kept apart and never counted as failures. next_step returns fix, gather more evidence (for example "run 39 more with traces kept"), or quarantine with a reason.
    • Class: FailureClass is one of app bug, test bug, test data or environment, timing race, CI infrastructure or third party. Each class says where its fix may go. class_problems checks the class against the evidence:
      • a race must pass some runs;
      • an app bug cites app code and fails on the base;
      • CI infrastructure needs a run that never started, or a runner or network line;
      • a third party names a host that isn't the team's.
    • trace_problems requires at least one quoted trace line to appear word for word in the failing run's report.
    • first_bad and bisect_next find the last commit the test passed on.
    • Banned changes (judge_diff): a fixed sleep, a raised timeout, added retries, a poll, a loosened or removed assertion, a skip, and a selector that matches more than before (broadened_selectors is new). Also refused: a test-only change for an app bug, and any code change for a cause outside the code. A timeout or poll stands only for a timing race, and a broadened selector only for a test bug, and only with a Justify <kind>: line that quotes one of the diagnosis's trace lines. A sleep and retries never stand.
    • The cause is named: Diagnosis::from_notes reads Class:, Root cause:, Trace:, Cause in: and Why this fixes it: from the fixing agent's notes. cause_section writes Root cause, Class, Evidence, Why this fixes it, and Pass rate before and after.
    • Proof: repeats_for returns n = ln(1 - 0.95) / ln(1 - rate), with a floor of 10 and a cap of 300. That is 29 runs at 10%, 59 at 5% and 299 at 1%. proof holds a result to the head that failed and the target that failed. The proof routes run the repeats; this module only says how many and judges the result.
    • One run per failure: attach sends a new occurrence of the same test, or of a sibling test in the same spec with the same signature, to the open run.
    • After the merge: Watch reads the next default-branch runs (as many as the rate before the fix needs, at most 50). A failure returns Reopen with the new evidence. watch_result reads each run the way the history is counted: a run that failed as a whole, or in which the test didn't run (skipped, interrupted or absent), neither reopens the fix nor counts towards holding it.
    • Proof routes (from The proof's repeat count is chosen in one place, and its routes report runs that never reached the page apart #931): a repeat proof's route tally is a Measure, its repeat count comes from the failure rate measured before the fix (measured_repeats into proof_routes::repeat_count, in the ready gate and the owed proof), and its verdict is proof.
    • Quarantine: QuarantineTerms gives a quarantine an owner, a reason, a ticket and an expiry (14 days by default, at most 30). keep_terms fills them in for any quarantine that has none.
  • Fix pipeline (worker::passes::test_fix):

    • On CoderHelm's own alert runs, check_and_fix stops before any fix round when the failure isn't reproduced. The run ends saying how the failure was seen and what comes next. When the next step is quarantine, the test is quarantined with its terms (e2e::quarantine_for_fix).
    • Class problems, trace problems and the banned changes the existing guards don't catch become blocking items. A fix round gets them along with the rules.
    • The description gets the cause section whenever the writer leaves out any of its headings.
    • Evidence::reproduction and Evidence::ci_rate read the evidence already gathered. A reopened run reads its failure again instead of reusing what it stored before the merge.
  • Tests pass (worker::passes::e2e):

    • Reproduction and burn-in repeat runs are sized by the test's failure rate (runs_needed). Twenty is now the minimum, not the only count.
    • A fix ticket says whether the test is failing or flaky from its measured history, and carries the rules.
    • A test that fails the same way as another test in the same spec joins that test's open fix run. The run gets a progress note.
    • A merged fix is watched (start_watch, watch_merged). A failure after the merge reopens the same run through continuation_run_id.
  • Quarantine as a state:

    • Each test's record keeps its terms and its watch (Care).
    • The Tests summary carries quarantine_terms (owner, reason, ticket, since, expires_at, expired) and watch.
    • The quarantine route accepts owner, ticket and days, and clears the terms when a test is released or pinned.
    • Every save fills in terms for a quarantine that has none.
  • Incident case xe_test_fix_from_evidence and its page. It replays an invented bookstore suite once per class:

    • an app bug is fixed in the app, not the test;
    • a sleep-only fix is refused;
    • no reproduction means no code change;
    • duplicate alerts join one run;
    • a regression after merge reopens the run;
    • the repeat count scales with the flake rate.

    It also checks that the pipeline still calls each decision at its place.

The proof routes (preview, staging, the app started in the sandbox, CI) and the sandbox's egress belong to separate work. This change uses their interface and doesn't duplicate it: it hands them the test and repeats_for(rate).runs, and judges what they return with proof.

Verification

From services/:

  • cargo fmt --all --check
  • rustfmt --check --edition 2021 worker/src/passes/incidents/*.rs
  • cargo clippy -p common -p worker -p gateway --all-targets -- -D warnings
  • cargo test -p common -p worker -p gateway
  • .github/scripts/brand_spelling.py and .github/scripts/domain_examples.py

@nambok nambok added the ch-review CoderHelm reviews this pull request label Nov 30, 2026
coderhelm[bot]

This comment was marked as outdated.

A run fixing a failing or flaky end-to-end test reproduces the failure
first, names one class from a closed set (app bug, test bug, test data or
environment, timing race, CI infrastructure, third party) and puts the fix
where the class says. Runs that never reached the page are not counted as
failures. Without a reproduction there is no code change: the run gathers
more evidence or quarantines the test with an owner, reason, ticket and
expiry.

Banned changes are read from the diff: fixed sleeps, raised timeouts,
retries, polls, loosened assertions, skips, broadened selectors, a
test-only change for an app bug, and any change for a cause outside the
code. The description names the cause with its trace lines and the pass
rates. Repeat runs are sized by the measured failure rate. A sibling
failure joins the open run, and a failure after the merge reopens the
same run.
…oof is judged by the evidence

- The post-merge watch reads each default-branch run through
  fix_evidence::watch_result: a run that failed as a whole (bad_run) or in
  which the test never ran (no attempt, or every attempt skipped or
  interrupted) is not reached, so it neither reopens the fix nor counts
  towards holding it, the way history_measure already counts the history.
- The repeat proof's routes feed the evidence: their tally is a
  fix_evidence::Measure, the repeat count comes from the failure rate
  measured before the fix (measured_repeats into proof_routes::repeat_count,
  in ready_gate and the owed proof), and the verdict is fix_evidence::proof.
- The incident case is renamed xe_test_fix_from_evidence, since xd is taken.
@nambok
nambok force-pushed the test-fix-from-evidence branch from d354eb9 to 8d3811b Compare December 1, 2026 03:07
coderhelm[bot]
coderhelm Bot previously requested changes Dec 1, 2026

@coderhelm coderhelm Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved with notes 8d3811b (merged)

Comment thread services/worker/src/passes/test_fix.rs Resolved
Comment thread services/common/src/e2e/fix_evidence.rs Resolved
@coderhelm
coderhelm Bot dismissed their stale review December 1, 2026 03:12

Superseded by CoderHelm's latest review

coderhelm[bot]

This comment was marked as outdated.

@coderhelm
coderhelm Bot dismissed their stale review December 1, 2026 03:13

Superseded by CoderHelm's latest review

@coderhelm

coderhelm Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Post-merge health check: deploy cancelled: the deploy for 5f70bd5 was cancelled; nothing later deployed it.

coderhelm[bot]

This comment was marked as outdated.

@coderhelm coderhelm Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved with notes e51c4a4 (merged)

@coderhelm
coderhelm Bot merged commit 5f70bd5 into main Dec 1, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ch-review CoderHelm reviews this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant