Skip to content

Fork CI: quarantine ledger, log only (#1390 tier 3, part 1) - #1485

Merged
scuttletoby merged 4 commits into
mainfrom
fork/quarantine-log-only
Nov 30, 2026
Merged

scuttletoby merged 4 commits into
mainfrom
fork/quarantine-log-only

Conversation

@scuttletoby

Copy link
Copy Markdown
Owner

Part of #1390 (tier 3, "quarantine flaky tests automatically, but fix them first"), part 1: the ledger and the runner's verdict, log only.

What changes

  • Ledger: .github/fork-quarantine/, one JSON file per quarantined test (no shared list, so two PRs that add entries never conflict): test (a Python test listed as unittest), name (Class.test_x), issue, since, until (at most 48 h after since; since not in the future, with 10 min for clock drift). Format and rules are in its README.md.
  • fork-ci-unittest.py writes failed_names on each run line: each failure's test (a subtest counts as its test), null for a class or module fixture failure.
  • fork-ci-tests.cjs, for each failed test file that a live entry names, works out a verdict and:
    • prints ::notice ... quarantine (log only): <file> would not block | still blocks: <why>;
    • adds a quarantine field to that file's record (only then, so other records are unchanged);
    • marks the summary row "(quarantine would excuse it: log only)".
    • The exit code and the record's status are unchanged: every failure still fails.
  • When the verdict is "would not block": only when all of these hold:
    • every failed test of the file has a live entry;
    • the file failed only through its tests: no time-out, no fixture failure, no failure outside a test, and the number of named failures matches the failure count;
    • the PR changes neither the test file nor any of those entries (an entry counts once it is on the base, so no PR can excuse its own failure);
    • each of those tests was already defined in the file 7 days ago on the first-parent line. This is per test: a new test in an old file is never excused. A shallow checkout first fetches history with --filter=blob:none, and only when a failure has a live entry.
    • Any doubt (a git error, no commit that old) counts as "still blocks".
  • Entries that cannot be read fail every part of the runner. An entry that has ended gives a warning ("remove it").
  • .github/fork-quarantine/ is added to .github/fork-owned-paths.txt. .github/fork-* stops at the /, so without this a PR that only adds an entry would have run the app jobs.
  • New test file .github/scripts/fork-ci-quarantine.test.cjs, listed unweighted (about 0.2 s). Change entry: docs/fork/changes/repo/1390-quarantine-log-only.md.

No workflow change. I kept the code inside fork-ci-tests.cjs and did not add a module beside it: the kit-root job's sparse checkout holds only the runner's pinned files, and fork-contracts.test.py pins that list.

Left for later parts of tier 3

  1. Make it block less: the record check in fork-tests.yml (fork-ci-result) accepts a record whose quarantine.excused is true, and the runner stops counting it. That needs a workflow push. It should come after the log has shown what would have been excused.
  2. Find flakes automatically (red then green on the same tree, or red on a tree a train passed). It would write an entry and open or attach the fix issue.
  3. Vitest lanes (Test Web, Test Server). Their flakes are not covered, because only the unittest shim names failed tests.
  4. Maybe add .github/fork-quarantine/ to the merge-skip always_rerun list once entries change outcomes. In log-only mode they don't.

State question

  • Runs again: the verdict is pure. It comes from the ledger, the run's own output, the PR's changed files and git history, so a rerun gives the same verdict until an entry ends.
  • Stops half-way: nothing is written except the usual records. A runner that is killed fails as it does today.
  • Old or empty state: no folder, or an empty one, means no entries and no output (today's behaviour). An old shim line with no failed_names gives "still blocks: failed outside its tests". An ended entry only warns. An open PR from before this change never sees an entry it did not merge with, and an entry added on main applies to it only after it merges main.

General vs project

General: the ledger format, the rules and the runner code would fit any repo that uses this runner. The entries are project data.

Tests

Written to fail first: against main's fork-ci-tests.cjs and fork-ci-unittest.py, all 14 tests in fork-ci-quarantine.test.cjs fail (0 pass).

Run here:

  • node --test .github/scripts/fork-ci-quarantine.test.cjs: 14 passed. They cover the ledger, the verdict, the age check with a fake git, a real shim run (a failed test, failed subtests, a fixture error), and main() in a scratch tree (log only, the part still fails; no ledger means no verdict; a bad entry fails; an ended entry warns).
  • node --test .github/scripts/fork-ci-tests.test.cjs: 85 passed.
  • node --test .github/scripts/fork-changes-list.test.cjs: 33 passed.
  • The fork checks from fork-checks.yml: the schema, upstream-files and seam scripts pass on this branch, and their self-tests give 201 passed.
  • vp fmt / vp lint on the changed files: clean.

Not run here, or failing for environment reasons:

  • fork-contracts.test.py: 60 failures. All are secret-scan end-to-end and fork_ci_result script cases that need jq, which is not installed here; none touch the runner, the shim or records.
  • fork-owned-paths.test.py: its list checks pass; 4 result: checks fail with jq missing.
  • vp run check:changed: not run, because no TypeScript changed (it would run knip).

CI runs all of these.

🤖 Generated with Claude Code

The fork script test runner reads .github/fork-quarantine/ (one file per
flaky test, at most 48 h) and, for each failed test a live entry names,
reports and records whether quarantine would excuse it. Log only: every
failure still fails. The unittest shim now names each failed test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scuttletoby

Copy link
Copy Markdown
Owner Author

lens: code · reviewer: Claude Opus 5.5 (code lens, round 1) · read at: fc08715

blocker: none
major: quarantineVerdict skips both "the PR changes the test / the entry" checks when changes is null, so a PR that adds its own entry gets "would not block" on any run that is not a pull_request event, or whose merge-commit parents can't be read. That breaks the "no PR can excuse its own failure" rule, and part 2 would act on that record as it is. Details below.
minor: quarantineOldEnough matches def <method>( anywhere in the file, not in the entry's class. So NewTests.test_x, added on main 2 days ago, counts as 7 days old when an older OldTests.test_x exists in the same file.
minor: only the test file itself counts as "changed by the PR". A PR that breaks the script the quarantined test checks (for example fork-x.py for fork-x.test.py) gets its real failure excused for up to 48 h. This is normal for quarantine, but please say it in the README so whoever writes part 2 decides it on purpose.

Major: a null changes lets a PR excuse itself

prChanges returns null unless GITHUB_EVENT_NAME === "pull_request" and HEAD^2 resolves. The head runs from fork-kit/schedule-kick are workflow_dispatch runs on a PR's merge commit, and fork-checks-ran.py judges them "as that pull request's run". The rule Array.isArray(changes) && ... then lets the entry through. I reproduced it with the PR's own exports:

pull_request changes: {"excused":false,"why":"this pull request adds or changes .github/fork-quarantine/1-new.json ..."}
dispatch/push (changes null): {"excused":true,"why":"every failed test is quarantined until 2026-12-01T00:00:00Z (#1)", ...}

(quarantineVerdict(run, {failed:1, failedNames:["T.test_x"]}, live, {changes, oldEnough: () => true}), with the entry in changes for the first call and changes: null for the second.)
For weightOnlyWarns, null is the strict choice, but here it is the loose one. That goes against the PR's own rule that "any doubt counts as still blocks". Suggested fix: treat changes === null as "still blocks: cannot tell what this change touches". Or, for a push to main and a head run, work out the change from HEAD^1..HEAD the way prChanges does. Please add a test for the null case. Today the record is log only, so nothing is excused yet, but this is exactly the field part 2 reads.

What I checked and found sound

  • Log only: the exit code and status don't change. failed still counts every failure, quarantine is only added to the record, and the summary row still says failed. An unreadable entry (bad JSON, extra or missing keys, a non-.json file, a folder, an unlisted or non-unittest test, a bad time, more than 48 h, since in the future) adds to failed in every part. Ended entries only warn, and only in the part that runs the test.
  • Excuse rules: a fixture failure (null name), a time-out, missing failed_names, failed === 0 with a non-zero exit, and a mismatch between the name count and the failure count each give "still blocks". When two entries name the same test, the first by file name is used. If the PR's own entry sorts first it still blocks; if a base entry sorts first, the base entry is the one that counts, which is fine.
  • Shim: children can't write lines (FORK_CI_TEST_COUNTS is popped), and subtests map to their own test through counted. _ErrorHolder gives null, and __main__. is dropped, so names match the README's Class.test_x. Names from an imported module keep their module prefix and then fail the age check, which is safe.
  • Age check: any git error or missing commit gives false. The unshallow fetch runs only when a failure has a live entry.

State question

  • Runs again: same verdict until an entry ends. An ended entry turns into a warning, never into a failure.
  • Stops half-way: nothing new is written; a killed runner fails as it does today.
  • Old, empty or missing state: no folder means no entries. An empty folder or one with only the README does nothing. Any other read error on the folder throws and fails the part. A shim line from before this change gives "still blocks". A future since added on main fails every part for at most the time it lies ahead. That is loud but limits itself; worth a line in the README.

🤖 Generated with Claude Code

scuttletoby and others added 3 commits November 30, 2026 06:25
… entry's class

- quarantineVerdict: changes null (not a pull_request run, or no merge parents) now
  still blocks, since such a run could be adding its own entry.
- quarantineOldEnough: only a def inside the entry's own class counts.
- README: a pull request that breaks the script a quarantined test checks would get
  that failure excused while the entry is live (up to 48 h).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scuttletoby

Copy link
Copy Markdown
Owner Author

Fix round r1 (head cfced06)

  • major: quarantineVerdict now fails closed when changes is null (not a pull_request run, or the merge parents cannot be read): "still blocks: cannot tell what this change touches". One new row in the existing "never when ..." test.
  • minor: quarantineOldEnough only counts a def inside the entry's own class (new helper definesMethod). New row: T.test_a is not old enough when only Old.test_a exists.
  • minor: the README now says a PR that breaks the script a quarantined test checks would get that failure excused while the entry is live (up to 48 h), so part 2 decides it on purpose. It also names the unknown-change case under "still blocks".
  • Merged origin/main. Both new rows fail on the old code. fork-ci-quarantine.test.cjs and fork-ci-tests.test.cjs pass (99/99). Schema, upstream-files and seam checks pass locally.

🤖 Generated with Claude Code

@scuttletoby scuttletoby added the fork:merge-ready Merge conveyor: lenses done, merge when green (PRs) label Nov 30, 2026
@scuttletoby
scuttletoby merged commit 06060a1 into main Nov 30, 2026
33 checks passed
@scuttletoby
scuttletoby deleted the fork/quarantine-log-only branch November 30, 2026 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork:merge-ready Merge conveyor: lenses done, merge when green (PRs)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant