Skip to content

Read a fresh tree on every poll of wait, waitUntil, scrollUntil and stable - #162

Merged
bitomule merged 1 commit into
mainfrom
worktree-t-mav-148-wait-cached-tree
Dec 3, 2026
Merged

bitomule merged 1 commit into
mainfrom
worktree-t-mav-148-wait-cached-tree

Conversation

@bitomule

@bitomule bitomule commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Fixes #148.

Problem

Inside mav run the tree cache is only invalidated on the way into and out of a step. A polling step (wait, waitUntil, assert) polls many times inside one step, so after its first poll stored a tree every later poll got that same tree back until the timeout, even though the screen had changed.

Change

  • New treeCache.freshPoll() (an invalidate under the name of the reason), called between polls in waitForConditionSet (covers wait, waitUntil, assert), after each swipe in scrollUntil, between iterations of whileNotVisible, and between the two reads of a stable condition (two reads of one cache entry were equal by construction, so every screen was "stable").
  • It is never called before a loop's first check, so a passing assert still reuses the tree a previous read-only step left (covered by a test).
  • Local change: one small method in tree_cache.go, one-line calls in cli.go, tests in a new file.

Tests (new flow_poll_fresh_test.go)

Without the fix, on a fake driver whose tree changes on the second read:

  • TestWaitUntilSeesAChangeThatArrivesAfterTheFirstPoll: FAIL (wait_timeout)
  • TestWaitAfterAFailedPollReadsAgain: FAIL (wait_timeout)
  • TestStableConditionComparesTwoRealReads: FAIL (declared stable)
  • TestScrollUntilReadsAFreshTreeAfterEachSwipe: FAIL (scroll_until_timeout)
  • TestAFirstPollStillUsesTheCachedTree: passes before and after (guard against over-invalidating)

With the fix, all pass, and go test ./... is green.

whileNotVisible got the same one-line invalidation but has no dedicated test: its children normally dirty the cache themselves, so the stale case needs a read-only child.

@bitomule
bitomule force-pushed the worktree-t-mav-148-wait-cached-tree branch from 8d8a492 to 0734130 Compare December 2, 2026 23:49
@bitomule
bitomule force-pushed the worktree-t-mav-148-wait-cached-tree branch 2 times, most recently from 42087f7 to 9f09d1b Compare December 3, 2026 10:03
@bitomule
bitomule force-pushed the worktree-t-mav-148-wait-cached-tree branch from 9f09d1b to 9ba5362 Compare December 3, 2026 10:43
…table

Inside a run the tree cache is only dirtied on the way into and out of a step,
so a polling step kept being handed the tree its first poll stored until it
timed out. Invalidate between polls (never before the first one, so a passing
assert still reuses the cached tree).

Fixes #148
@bitomule
bitomule force-pushed the worktree-t-mav-148-wait-cached-tree branch from 9ba5362 to db53096 Compare December 3, 2026 10:46
@bitomule
bitomule merged commit d3673f2 into main Dec 3, 2026
1 check 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.

wait / waitUntil inside a flow keep polling the same cached tree, so they never see a change that arrives after the first read

1 participant