Repository navigation
Fix three flaky tests: CalDAV listing reads one calendar, away-plan and focus-sound tests wait on work, not time - #2208
Merged
Merged
Conversation
TestPlanAwayStopsAtTheLimit checked that refusing a too-large away period is quick with a 1 s wall-clock limit. On an idle machine the call took up to 0.56 s, so with three packages testing in parallel it passed the limit (1.097 s seen). The property is that planning stops as soon as the changes pass the limit: the test now counts the series planned (canEdit is asked once per series) and wants exactly those whose fields pass it, 3 of 200. It fails with "planned 200 series, want 3" when the check moves after the loop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0187cnkXBm72ZSggGvrvUMKW
TestCalDAVLargeAccountBudgets failed its 1 s ceiling for a Depth 1 PROPFIND of a 500-task calendar (1.3 to 1.5 s here, also at the commit that added it): listing a calendar, a calendar-query and the first sync-collection loaded every task of the 10,000-task account, about 1.47 million allocations, so the ceiling sat at the real cost on a 4-core machine or a loaded runner. A project calendar's listing now reads its tasks by project_id (sync.ListWhere) into the partial view, with what serving them needs (the same serve step as fetch: refs, parents, labels, series), in list order. The Inbox and a calendar over maxNarrow tasks still read the whole view. On 10,000 tasks the PROPFIND fixed cost goes from 1,468,527 to 5,925 allocations and from 1.4 s to 46 ms; calendar-query from 1.5 s to 83 ms. TestCalDAVPartialViewServesWhatTheWholeViewServes used calendar-query as its whole-view reference; it now uses a multiget of more hrefs than maxNarrow (which reads the whole view) and also compares the PROPFIND. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0187cnkXBm72ZSggGvrvUMKW
Two hidden-tab tests turned the sound off with mutate() and one flush()
and then expected the background Long cancelled. The pref reaches the
engine through the user prefs live query (IndexedDB), which under CPU load
takes more than one macrotask, so the Long kept playing ("expected 10 to
be 2", seen on CI and 1 in 30 runs here with the CPU busy). The engine now
renders its sound setting and soundOff() waits for it, as the tests
already wait for the phase. 60 of 60 runs of the file pass under the same
load.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0187cnkXBm72ZSggGvrvUMKW
The partial-view test took its reference from listings that are now narrow themselves, and compared maps, so a dropped or reordered resource went unnoticed. davroutes.Server.SetWholeView makes every request read the whole view, as before partial views; the tests compare the three listings of a calendar (PROPFIND Depth 1, calendar-query, the first sync-collection) with it as ordered lists. New cases: a member of a shared project, an event-mode app password, a task blocked by one of an archived project (whose calendar stays 404 either way) and a calendar of 1,001 tasks. Both tests fail when the listing drops its last task or reverses its order. Also: task 2.2 of caldav-verified records the change, the design note says "up to 1.5 s on a loaded CI runner", the changelog fragment is named after the change, and narrow.go says why a calendar over maxNarrow is read twice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0187cnkXBm72ZSggGvrvUMKW
pixari
marked this pull request as ready for review
November 28, 2026 14:25
pixari
enabled auto-merge
November 28, 2026 14:25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
We fix three tests that failed once and passed on rerun. Each had a real cause.
1.
internal/httpapiTestCalDAVLargeAccountBudgets, the large CalDAV test. Its 1 s ceiling for a Depth 1 PROPFIND of a 500-task calendar was not generous: listing one calendar read the whole 10,000-task account (about 1.47 million allocations of fixed cost). That took 1.3 to 1.5 s on a 4-core sandbox, and on the commit that added the test as well (664d304), so the test failed every time here. On a CI runner it sat close enough to the ceiling to flake under load. We fixed the code, not the ceiling. A project calendar's listing (PROPFIND Depth 1, calendar-query, the first sync-collection) now reads only that calendar's tasks byproject_idinto the partial view, with what serving them needs (it reusesfetch's serve step: parents, blockers, labels, series), in list order (davroutes/narrow.golisting). The Inbox and a calendar of more thanmaxNarrowtasks still read the whole view. On 10,000 tasks:To compare against,
davroutes.Server.SetWholeViewmakes every request read the whole view, as before.TestCalDAVPartialViewServesWhatTheWholeViewServesand the newTestCalDAVPartialListingServesWhatTheWholeViewServescompare a calendar's three listings with it as ordered lists. The new test covers a member of a shared project, an event-mode app password, a task blocked by one of an archived project, and a calendar of 1,001 tasks. Both tests fail when the listing drops its last task or reverses its order. Task 2.2 and the design (D4) ofcaldav-verifiedrecord the change. The spec's budgets are the same. Changelog:changelog.d/Changed/caldav-verified.md.2.
internal/syncTestPlanAwayStopsAtTheLimit. It checked "refuses quickly" with a 1 s wall-clock limit. The call took up to 0.56 s on an idle machine and 1.097 s with three packages testing in parallel. The property is that planning stops as soon as the changes pass the limit, so the test now measures work: it counts the series planned (canEditis asked once per series) and wants exactly those whose fields pass the limit (3 of 200). With the check moved after the loop, the test fails with "planned 200 series, want 3".3.
webuseFocusTimer.test.tsx, "Turning the sound off stops a background Long and cancels a waiting tone" (expected 10 to be 2on #2204). The test turned the sound off withmutate()and oneflush(). The pref reaches the engine through the user prefs live query (IndexedDB), and under CPU load that takes longer than one macrotask, so the Long kept playing. The engine now renders its sound setting, andsoundOff()waits for it, the same way the tests already wait for the phase. The test after it, "Sound turned off while the tone waits", had the same race and is fixed the same way.No test is skipped, no limit is raised and nothing retries.
Runs
go test ./internal/httpapifailed on its first run (PROPFIND time: 1.304s (ceiling 1s): over budget), and again twice with the test alone, also at 664d304.internal/httpapipassed-count=20 -failfastwithGOMAXPROCS=2while a loop ofinternal/synctests ran beside it, and passed-race -count=3 -failfast. The large test passed 11 more runs on its own.go test ./internal/sync -run TestPlanAway -count=50passed.useFocusTimer.test.tsxfailed 1 of 30 runs with 6 busy-loop processes on 4 cores (expected 10 to be 2). After the fix, the whole file passed 60 of 60 runs under the same load.make staticcheck(deadcode included),go vet,make docs-check,node --test scripts/repo-checks.test.mjs,tscandeslintare clean.Checklist
openspec/changes/<name>/), or this PR has none (responses are unchanged; thecaldav-verifieddesign notes the listing)make checkpasses locally (three test fixes in one PR, as asked; we ran the parts listed above, not the fullmake check)Co-Authored-Bytrailerinternal/httpapi/policy.go(none)changelog.d/<Section>/<name>.md(not inCHANGELOG.md); size impact noted for new dependencies (none)https://claude.ai/code/session_0187cnkXBm72ZSggGvrvUMKW
Generated by Claude Code