Skip to content

test: audit CI history for flaky tests and fix them #666

Done

Description

@jatmn

🤖 Kit for jatmn

Status (refreshed 2026-11-24, main at b6d14bc)

Done (merged)

Allowlist burn-down: tools/test-flake-allowlist.tsv is down from 483 rows / 637 findings when #683 landed to 413 rows / 529 occurrences (470 real-clock, 59 fixed-sleep).

Left to do

  1. Keep burning down the allowlist (the clock entries are most of it).
  2. Updater controller_tests::api_role_serves_reads_while_a_superseded_launcher_clear_waits_for_the_writer: its allowlist row is gone, but no loop run has confirmed the flake is fixed.
  3. scripts/ci-workflow-test.mjs (around line 985) flake reported 2026-11-20: still open.
  4. Post the final audit list here, then close.

The other load-sensitive tests from the test audit (TA-043 in #741) are tracked here.


Go through recent GitHub Actions runs on main and on PRs, and find tests that failed and then passed on a rerun or a later run without any code change.

Scope

  • Look back over the last 30 days of runs (Validate / Checks: frontend, rust-core, rust-bot, rust-api).
  • For each flaky test, record its name, the job it runs in, how often it fails, what the failure message says, and the likely cause (real clock, fixed sleeps, substring matches, test order, shared DB or ports, transaction timing).
  • Fix each one at the root, for example with a fixed or fake clock, waiting on a condition instead of a fixed delay, exact matches, or isolated fixtures. Don't add retries or skips.
  • Prove each fix by running the test in a loop locally.

This builds on #661 (the 802 substring match, the Database Usage freshness timing test, and the transaction timing flake), which can be folded into this work or fixed first.

Done when the audit list is posted here and every flaky test it found is either fixed or has its own issue.

Activity

  1. jatmn commented on Nov 18, 2026

    @jatmn
    OwnerAuthor

    🤖 Kit for jatmn

    Scope addition: lints that stop new flaky tests

    This idea comes from the no-fixed-sleep and no-flake-masking rules in interfere-inc/landmines. We're not adopting that package: it's Oxlint-only and built around Vitest/MSW, and it doesn't cover Rust.

    1. Rust (dylint): add a lint that flags real std::thread::sleep / tokio::time::sleep and wall-clock reads (SystemTime::now, Instant::now, chrono::Utc::now) inside #[test] / #[tokio::test] code. Tests should wait on a signal or channel, or use a paused or injected clock instead. Each existing hit goes either into a shrink-only allowlist or into a fix.
    2. Frontend (ESLint, tools/eslint): add a matching rule for the frontend test files. It bans setTimeout-based waits and Date.now() / new Date() without a fake clock.
    3. No flake masking: CI fails if a test adds retries (nextest retries, retry loops around assertions) or raises a timeout to make a test pass.
    4. The allowlist can only shrink. A test added to it needs a linked backlog issue.

    The current flakes in #661 (the "2 min ago" vs "1 min ago" freshness check and the transaction timing flake) are exactly the cases these rules would catch, so fixing #661 should come first or go alongside this.

  2. jatmn commented on Nov 18, 2026

    @jatmn
    OwnerAuthor

    🤖 Kit for jatmn

    Another flake for this audit: controller_tests::ordinary_exit_after_idle_keeps_health_during_stalled_control

  3. jatmn commented on Nov 18, 2026

    @jatmn
    OwnerAuthor

    🤖 Kit for jatmn

    Backlog note from #682 (merged): PR Reviewer flagged a P3 follow-up. The staging publish retry decides whether to retry by string-matching the registry's unknown blob error text. That's brittle if the message wording changes. Tracking it here with the other flaky-test follow-ups. It doesn't block anything.

  4. jatmn commented on Nov 18, 2026

    @jatmn
    OwnerAuthor

    🤖 Fixer for jatmn

    Two flaky tests from the 30-day CI audit in #683's PR body still need a real fix. I checked all five tests from that audit against the 9 fixes in #682. Three are already handled: #682 fixes ordinary_exit_after_idle_keeps_health_during_stalled_control and userinfo_prefix_and_slash_hide_voice_the_caller_cannot_view. Members partial-import explanation opens inside narrow screens was already fixed on main by #638 (#637). #682 (merged, closing #661) doesn't touch the two below, so I'm queuing them here. Both failed and then passed on a rerun of the same commit.

    1. tenant::tests::note_intent_retries_keep_one_entry_and_original_timestamp (crate jmodguard, src/tenant/tests.rs, rust-core lane)

      • Evidence: run https://github.com/jatmn/jModGuard/actions/runs/42771344124 on 2026-11-10 at commit f9b4abb. Attempt 1 failed in Checks / rust-core and attempt 2 passed in Checks / rust-core.
      • Failure: panic at src/tenant/tests.rs:1085, called Result::unwrap() on an Err value: SQLite failure: database is locked.
      • Suspected cause: the test joins two concurrent note-intent appends against the same fixture SQLite database. Under CI load, one writer can hit the lock while the other holds it, and that path surfaces SQLITE_BUSY instead of waiting. To fix it, I need to check how the fixture connection is configured compared with production, for example whether it has a busy timeout. Making the writes sequential would drop the concurrent idempotency coverage the test exists for.
    2. tests::launcher_periodic_tick_never_steals_a_live_foreign_fence_after_expiry (jmodguard-updater, jmodguard-launcher bin, crates/updater/src/main.rs, rust-core lane)

      • Evidence: run https://github.com/jatmn/jModGuard/actions/runs/43894725795 on 2026-11-16 at commit d726f3c. Attempt 1 failed in Checks / rust-core after 20.5 s, and attempt 2 passed in Checks / rust-core.
      • Failure: panic at crates/updater/src/main.rs:3879, assertion failed: other.renew_launcher_fence().await.unwrap().
      • Suspected cause: the test uses a real sleep to cross the first owner's lease expiry, then expects the second owner's renewal to succeed. Wall-clock sleep and the database's expiry check can drift apart under scheduling load, so the renewal can land on the wrong side of the lease boundary. To fix it, the expiry handoff needs to be controlled, with an injected or paused clock, or by setting the lease expiry directly in the fixture. The check that a live foreign fence is never stolen has to stay.

    These two are the follow-ups #683 leaves open on this issue.

  5. jatmn commented on Nov 18, 2026

    @jatmn
    OwnerAuthor

    🤖 Kit for jatmn

    #683 merged. The flaky-test lints now run in the Dylint, frontend and contracts gates, and CI rejects new allowlist entries or higher counts. Keeping this issue open to burn down the inherited allowlist (637 existing Rust findings across 483 entries) recorded in #683.

  6. jatmn commented on Nov 20, 2026

    @jatmn
    OwnerAuthor

    🤖 Fixer for jatmn

    Four draft PRs are open against this issue:

    Local stress runs while that work was going on turned up three flakes in tests none of those PRs touch. All of them showed up with the machine's load average between 33 and 48.

    1. controller_tests::api_role_serves_reads_while_a_superseded_launcher_clear_waits_for_the_writer (crates/updater)
      • Failed: once in ci-preflight.sh --affected, with a 404 health reply after 20 s.
      • Then: passed 5 of 5 when run alone.
      • It already has an inherited sleep row.
    2. scripts/ci-workflow-test.mjs:985 ("each retry must stall before its second page")
      • Failed: once in preflight.
      • Then: passed 3 of 3 when run alone.
    3. crates/bot/tests/launcher_revision.rs:124
      • Failed: the get() health request failed with BrokenPipe in 8 of 160 runs of the base test binary (8 parallel copies, pinned to 2 CPUs). It hit 3 of 160 with test: replace fixed sleeps with signals in bot tests #737's binary.
      • The failure is in the shared helper, before each test's own assertions.

    None of the four PRs fixes these.

  7. jatmn commented on Nov 24, 2026

    @jatmn
    OwnerAuthor

    I fixed the late control result replay flake in draft #799. The draft has the before-and-after stress results.

  8. 27 remaining items

  9. jatmn commented on Nov 30, 2026

    @jatmn
    OwnerAuthor

    PR #1088 merged at d3f41d8. Ten in-memory text_spam::tests detector tests now take their origin from a paused Tokio clock, and their ten clock allowances are gone. The allowlist is down from 258 rows / 346 occurrences to 248 / 336. The changed tests passed 40 serial runs and 24 parallel runs, and the bot-scoped lint fails on exactly those ten tests when the old file is restored.

    The scripts/ci-workflow-test.mjs pagination flake (#820) and the updater launcher-clear loop confirmation (#820, #906, #1028) are already resolved on main. The issue stays open for the remaining allowlist burn-down.

  10. removed their assignment
    on Nov 30, 2026
  11. jatmn commented on Dec 5, 2026

    @jatmn
    OwnerAuthor

    fix-issue-queue claim 2026-12-05T17:27:32Z b9e8da268d2d01310968e0e73dd2d4fec67c293f7dfcfb50c20ab2872b68e987

  12. self-assigned this
    on Dec 5, 2026
  13. jatmn commented on Dec 6, 2026

    @jatmn
    OwnerAuthor

    Final CI flake audit

    All 15 PRs in this queue have merged. The allowlist had 168 entries covering 242 occurrences when the queue started. It now contains only its two header lines. Workspace-wide pinned Dylint returned zero warnings and errors on the exact tree merged as af5f3ed. Allowlist on main at closure

    Observed CI failures

    The initial audit records five named tests that failed and then passed on the same revision, their failure counts, symptoms and merged fixes. The November 18–30 follow-up covers 752 direct CI runs and 261 main publication runs. The logging delivery, updater startup receipt and late control result findings have merged fixes in #1078, #1020 and #799. The separately reported API authorization snapshot race was fixed in #1111. Initial audit · November follow-up

    Earlier same-revision recoveries Lane Observed failures and resolution
    note_intent_retries_keep_one_entry_and_original_timestamp rust-core One failure. The local guild writer used the read-only busy timeout. #695 corrected the lock wait.
    userinfo_prefix_and_slash_hide_voice_the_caller_cannot_view rust-bot Three failures and two unchanged recoveries. #682 corrected fixture ordering. The historical voice failure did not reproduce during this queue, so the original cause remains unconfirmed.
    Members partial-import explanation opens inside narrow screens frontend One failure. The fixture queried Members before its route remounted. #638 waits for that remount.
    launcher_periodic_tick_never_steals_a_live_foreign_fence_after_expiry rust-core One failure. #695 explicitly expires the stored lease instead of assuming elapsed time made it eligible.
    ordinary_exit_after_idle_keeps_health_during_stalled_control rust-core Four failures and two unchanged recoveries. #682 waits for the replacement child to record its start. #1198 also verifies the actual restart deadline.
    saturated_delivery_slots_retry_a_bounded_number_of_reconciled_payloads rust-bot Two queue-delivery timeouts. #1078 loads configuration before the measurement and waits for actual sends.
    api_role_startup_receipts_log_one_info_line_per_unreachable_link_attempt rust-core One warning where the fixture expected INFO for a refused connection. #1020 keeps the refused port reserved.
    late_control_result_is_retrievable_and_replay_does_not_apply_twice rust-bot One StillWaiting response in the follow-up window. #799 synchronizes with response publication.

    From November 30 at 00:00 UTC through December 5 at 19:22 UTC, the extension examined 299 direct CI and 86 publication runs. Failed, retried and cancelled runs were checked across attempts. Five failed jobs subsequently passed the same test on the same checkout. Counts below are observed failures in this interval.

    Lane and test Failures and symptoms Cause, recovery and fix
    Frontend, a fragment-only preview stays read-only on the round trip through Administration Two Firefox launches crossed the 30-second BiDi announcement deadline. Both passed on the same checkout on a later attempt. #1098 handles the failed browser launch using a fresh process/profile. First run · Second run
    rust-core, updater exit_code_child_retries_empty_and_partial_records One timeout waiting for an exit code. The test passed in 1.286 s on the same checkout. #1111 waits for complete record publication and reports 32 passing repetitions. Failure · Recovery
    rust-api, startup::tests::newer_guild_store_exits_instead_of_waiting One failure of the wall-time assertion. The test passed on the same checkout. #1184 checks the actual retry hook and reports 40 serial plus 40 contention passes. Failure · Recovery
    Frontend, an owner request recovers a partial create under the same ID and reports the last completion One missing form input, followed by a pass on checkout ffd4caf. The companion test, an owner create whose saved request ID has closed starts a new request, lost its content element once in a publication run. #1190 reproduced both failure signatures with a request reference containing 401. The app uses the HTTP status for numeric auth failures, and the tests wait for the rendered error and refresh. Both cases passed 64 targeted executions in total. The hosted logs omit the original reference values, and the companion failure has no verified same-checkout recovery. Partial-create failure · Recovery · Companion failure

    The two outstanding verification requests in the issue body were completed. The updater test api_role_serves_reads_while_a_superseded_launcher_clear_waits_for_the_writer ran 12 times with 20 split-request probes. The workflow pagination test ran 24 times, including 12 with delayed startup. Updater #906 · Pagination #820

    The frontend lint also reports the Firefox shutdown helper's five-second escalation timer. The helper waits on the real process exit/error signal, cancels the timer on exit, and sends SIGKILL only if termination stalls. The hosted frontend gate passed with this process watchdog present. Frontend job

    The final audit interval ran from December 5 at 19:22 UTC through the merge of #1200 on December 6 at 00:32:49 UTC. It covered 27 direct CI runs and 13 main publication runs. All 13 publications passed on their first attempt. One release PR workflow recorded action_required with zero jobs. Two CI jobs failed when npm audit returned HTTP 403 before the Rust tests began. The integration job passed on a rerun of the same commit. API job · Integration job · Integration rerun

    The later rust-api job on PR #1193 exposed one failure of dual_process_readonly_api_delegates_backup_pause_and_restore_to_bot_writer. The integration fixture claimed the bot writer lease and launched an export while startup recovery still held the writer. The bot correctly refused the write pause, and the fixture failed its successful-export assertion. The same test passed on a later checkout. The rerun of the original checkout was cancelled before reaching the test. Failed export · Later pass

    The backup-export fixture now waits for the bot writer to finish startup recovery. Holding real recovery reproduced the write refusal. With the fix, a delayed recovery let the export proceed, and permanently held recovery failed at the fixture’s 180-second watchdog. All 22 hosted checks passed on the merged change. Backup fixture fix

    The rust-bot test old_or_unknown_launcher_child_is_refused_without_readiness_and_exits_cleanly failed once after the refused bot served health and received SIGTERM. The parent expected exit code 0 and observed a signal exit. Attempt 2 passed the same test in 0.179 seconds on the identical checkout a4d717d. The bot and runtime sources also match main at b6432b6. PR #1200 registers SIGTERM before publishing health or refusal. On the original process a controlled delay at registration reproduced signal 15. The fixed process exited 0, left the database and ready marker absent, and retained the expected HTTP responses. Both affected tests passed 20 serial and 12 contended runs each. The Unix signal was exercised on Linux. Windows fallback coverage was compile-only. Failure · Same-checkout recovery

    Merged work and verification

    Work Merged PRs
    Removed the remaining allowlist entries in API, bot logging, image spam, core and runtime, snapshot and membership, workers, and moderation tests #1186, #1187, #1188, #1189, #1191, #1192, #1193
    Corrected the owner-request sign-out, backup-export startup race, and SIGTERM registration order found in the CI audit #1190, #1196, #1200
    Cleared 181 additional compiler findings in bot, database, and updater tests #1194, #1195, #1197, #1198, #1199

    #1193 removed the last 39 allowlist rows, covering 54 occurrences. #1194 removed 14 additional bot findings in activation and userinfo tests. All 12 affected tests passed 20 serial and 12 contended repetitions each. Final allowlist removal · Bot fixtures

    The core database tests also had 27 inherited compiler findings outside the allowlist. The merged tests cover a renewal that expires while waiting for a connection, an applied update whose response arrives at its deadline, and rollback and recovery after both forms of snapshot cursor stall. All 22 hosted checks passed. These compiler findings are tracked separately from observed CI failures. Core database fixtures

    The updater startup and migration fixes removed 56 inherited diagnostics in 14 tests. The updated launcher-clear case verifies that the first application read succeeds before writer activation and that the clear is persisted afterward. All 14 tests passed 20 serial and 12 contended runs each. All 21 hosted checks passed on the merged change. Updater fixtures

    The two final updater PRs removed 47 child-exit and health findings and 37 reservation and selection findings. Main at 87759de has the exact combined tree that passed full-workspace pinned Dylint with zero findings and all 187 updater tests. The allowlist is empty. The individual PR heads passed 544 and 480 focused test executions, respectively. Child exits and health · Reservations and selection

    The final SIGTERM fix passed all 22 hosted checks on cbb1df0. The main publication triggered by that merge reused the PR validation. SIGTERM fix · Main publication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions