Skip to content

Fix flaky tests the sharded CI exposed - #44

Merged
lobbystack merged 6 commits into
mainfrom
fix/flaky-tests
Nov 29, 2026
Merged

lobbystack merged 6 commits into
mainfrom
fix/flaky-tests

Conversation

@lobbystack

@lobbystack lobbystack commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

The sharded CI runs from PR #41 failed these tests once each. Each commit fixes one cause and adds a test that failed before the fix.

Root causes

  • Plugin calls counted disk time toward their one-second deadline (app-core task_commands::create_takes_an_assignee_…, both transcription:: tests, and the old task_inbox retry). The host left network and AI waits off the clock but counted workspace reads and object writes. On a slow disk a call passed its second after its file landed. The host then stopped the plugin and told the caller it failed, and the restarted store had lost the plugin's state: Tasks answered "The tasks plugin failed while running create." in place of JSON, and Transcription lost the recording it held, so its panel never changed. Reads and writes now count as waits. A 1.5 s sleep in app-core's object store reproduces each CI message exactly before the fix and passes after. The ci profile now retries no test.
  • A tab moved to another file that shared its ID (app-core outside_edit_storage::notes_that_share_an_id_…). If Noura read an open note half written while another file held the same ID, the tab followed the ID to that file, and the save wrote your typing there. A tab now takes an ID only while one file holds it. It failed 6 times in 400 in a Linux container before, and passed 600 of 600 after.
  • Object writes that missed the index didn't mark it stale (app-core task_project_storage::creates_whose_index_update_fails_…, found while stress testing). Only chat writes set the flag that makes the next read walk the workspace.
  • A late watcher report found the file a test wrote after silencing the watcher (app-core outside_changes::the_periodic_rescan_…). force_watch_fault now waits for a watcher poll that starts after the fault. The new test failed 30 times in 30 before.
  • The realtime test's long poll could end before the desktop's change committed (app-core sync_realtime::the_app_pings_reconnects_and_catches_up, failed on this PR's first run). With the channel down a pull waits until the next reconnect at most, and one lost connection put that 1 to 2 s away. The test now loses it four times, so the window is at least 7 s, and checks the step ends within 5 s.
  • The web timeout test raced its provider (local-core web_access::…configured_timeout). tokio's timeout polls the call before its timer, so on Windows' coarse timer the 20 ms answer could beat the 1 ms timeout. The provider now never answers.

Not fixed

app-ui plugin_pages::the_inbox_sections_end_on_one_edge hung for 600 s on Windows. It printed no panic, so a call in the test or a drop of its locals never returned. I couldn't reproduce it in 191 runs on macOS, and I found no lock or join that waits forever on this path.

A plugin call may run one second of its own work. The host left network,
AI, speech and paste waits off that clock, but counted the time Noura
spent reading the workspace and writing objects. On a busy disk a Tasks
or Transcription call could pass the second after its file landed: the
host stopped the plugin, told the caller it failed, and started a fresh
store that had lost the plugin's state.

That explains three failures on loaded Windows runners. task_commands
got "The tasks plugin failed while running create." instead of JSON.
Both Transcription tests wrote the start time, then lost the recording
the plugin held in memory, so the panel never showed Stop or the
problem. The retry nextest gave task_inbox came from the same cause, so
it goes, and the ci profile now retries no test.

Workspace reads and object writes now run as waits, like the network.
max_call_time still bounds the whole call. A new plugin-host test gives
reads and writes a disk three deadlines slow and expects both to finish.
The test gave the fetch a 1 ms timeout and a provider that answered
after 20 ms. tokio's timeout polls the call before its own timer, so a
thread that wakes once both have passed takes the answer. Windows wakes
timers on a tick of about 15 ms, and a busy runner can pause the thread
longer, so the test failed now and then on Windows.

The provider now never answers, and only the timeout can end the call.
A tab follows a managed note by its ID, and keeps that ID while it reads
the note without one, as when another app rewrites the file in place.
When two files held the ID, the tab still took it. If Noura then read
the open note half written, the other file held the ID alone, and the
tab moved there. The save that followed wrote your typing into that
other file.

The Linux CI run of notes_that_share_an_id_each_merge_and_resolve_in_
their_own_file hit this: the test's own write of One.md emptied the file
for a moment, the watcher read it, and the typing landed in Two.md. It
failed 6 times in 400 under load in a Linux container.

A tab now takes an ID only while no other file holds it, and follows its
path otherwise. Three new tests read the note empty beside a file with
its ID, with the copy there before the tab opened and after, and with
typing to save. Each moved the tab before this change.
Tests silence the native watcher, change a file, and expect only a
rescan or an injected event to report it. The watch thread could still
hold an event the platform sent before the fault, such as a late
FSEvents report of the fixture's files. Any outside event starts a full
walk, so applying that event after the test's change found the change
as if the silent watcher had reported it. On macOS CI,
the_periodic_rescan_finds_a_change_the_watcher_missed saw Missed.md
300 ms after the write.

The engine now numbers its watcher polls behind test-hooks, and the
app's force_watch_fault waits for a poll that starts after the fault.
A new test queues a report, silences the watcher, writes a file and
checks that the report's walk misses it. It failed 30 runs in 30 before
this change.
A create, update or move whose file landed but whose index update failed
reported RepairPending and said the next read would walk the workspace.
Only chat writes set the dirty flag that makes a read walk, though. For
an object, the watcher's report of the new file was the only other
thing that could, and that report reads as the engine's own write. A
list right after such a write could skip the walk and leave the object
out until the next periodic rescan.

app-core's creates_whose_index_update_fails_are_on_disk_and_the_index_
catches_up failed this way once under load. index_outcome now sets the
flag for every write, so the chat-only wrapper goes. A new local-core
test silences the watcher, refuses index writes, creates a task and
lists it once the index takes writes. It failed before this change.
… round

With the channel down, a pull waits for changes until the next reconnect
at most. The test dropped the connection once, which put the reconnect
1 to 2 s away, so the pull waited 1 s. The desktop's change committed
300 ms in, after a full sync round. On a busy Windows runner that round
took longer, the pull ended empty, and the test saw 0 records applied.

The test now loses the connection four times, so the reconnect is 8 to
16 s away, and checks that the step still ends within 5 s, at the
commit. With the desktop's round slowed by a second, the old test failed
3 runs in 3 and this one passes.
@lobbystack
lobbystack merged commit 4529634 into main Nov 29, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant