Skip to content

test(siri): drive Spotlight cooldown and deferred-removal assertions with fakeAsync (#23380) - #23398

Merged
aryanorastar merged 2 commits into
BasedHardware:mainfrom
ocakciomursel-pixel:fix/siri-spotlight-cooldown-test-determinism-23380
Oct 25, 2026
Merged

aryanorastar merged 2 commits into
BasedHardware:mainfrom
ocakciomursel-pixel:fix/siri-spotlight-cooldown-test-determinism-23380

Conversation

@ocakciomursel-pixel

@ocakciomursel-pixel ocakciomursel-pixel commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #23380

Summary

  • Converts the Spotlight cooldown and deferred-removal tests in app/test/services/siri_integration_test.dart (including delete and newly locked memory submitted during cooldown reach Spotlight after cooldown) from wall-clock Future<void>.delayed / drainIndexForTest waits to deterministic fakeAsync time progression.
  • Because SiriIntegration uses clock.now() and Timer for native call timeouts, index cooldown windows, and deferred-removal retry flushes, driving both the timeout/cooldown clock and retry timers via FakeAsync prevents scheduler pressure in full-suite runs (flutter test --concurrency=2) from expiring the 80 ms cooldown before intermediate call-count assertions execute.

Product invariants affected

  • None (test-only determinism improvement for the existing Spotlight cooldown and deferred-removal contract).

Failure Mode & Blast Radius

  • Restricted to app/test/services/siri_integration_test.dart. No production code paths are modified.

UI-Evidence: none — test-only change with no visual UI surface changes.
Failure-Class: none

View guided diff

@Git-on-my-level

Copy link
Copy Markdown
Member

Verdict: this is the right fix and correctly scoped - test-only determinism work with no production code touched and a proper changelog fragment.

  • app/test/services/siri_integration_test.dart - all five converted tests ("delete and newly locked memory...", "removal ledger cap...", "failed owner repair...", "pending removals... discarded on account change", "same-owner session refresh retains pending removals") keep their original assertions intact; only the waiting strategy changes. Replacing Future<void>.delayed(130ms) with time.elapse(...) removes the scheduler-pressure race where the 80 ms cooldown could expire before the intermediate expect(host.calls, 1) check ran.
  • The mechanism checks out against the source: the cooldown gate reads clock.now() (_indexSuspendedUntil in app/lib/services/siri_integration.dart), and fakeAsync installs a zone clock, so elapse advances the retry timers and the cooldown window together - deterministic instead of racy.
  • drainIndexForTest() is just the queued-work tail (Future<void> drainIndexForTest() => _queuedIndexTail), so time.flushMicrotasks() is an equivalent drain inside the fake zone; no assertion was weakened.
  • Swapping addTearDown(() => host.firstDelete.complete()) for an explicit host.firstDelete.complete() + flushMicrotasks() at the end of each body is safe - pending fake timers are discarded on zone teardown, so a failing assertion can't wedge the suite. Good catch keeping the completer cleanup.
  • app/changelog/unreleased/20261023-siri-spotlight-cooldown-test-determinism.json - correct kind: "none" fragment for a test-only change.

USER IMPACT: none - internal change; users will notice no behavior difference, the test suite just stops flaking under concurrency.

Nothing blocking. Optional nit: the "advance timers and the cooldown clock together" comment on the first converted test is helpful - the two session tests do the same double-duty elapse(130) without it.

AI-generated maintainer feedback on behalf of the Omi maintainers.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution flutter flutter work labels Oct 23, 2026

@aryanorastar aryanorastar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed f668040. No merge-blocking findings. The fakeAsync zone drives both production clock.now() and timer deadlines, removing the 80 ms wall-clock scheduling race while preserving the cooldown, deferred deletion, repair retry and account-fencing assertions. The production Spotlight source is byte-identical to current main; the changelog correctly declares no store-build behavior change.

Independent verification:

  • All 28 tests pass on the exact PR head with --concurrency=2.
  • A local prospective merge with current main 18c4a38 passed ten shuffled runs (seeds 23380–23389): 280 test executions passed.
  • All 14 selected make preflight checks pass.
  • Scratch-only negative controls confirm the key test fails if cooldown suppression is disabled or deferred-removal retries are suppressed. It still passes with a 250 ms real wall-clock stall before flushing queued work, exceeding the virtual 80 ms cooldown. All temporary changes and the prospective merge were restored; nothing from these controls is part of the PR.
  • Exact-head Dart Analyze & Tests CI passed 7,121 tests, with four skipped; source Formatting/Hygiene and Mobile Release Eligibility pass. Latest metadata preflight passes. An older canceled metadata attempt is superseded by that successful metadata run, not counted as a source-code failure or a passing canceled job.

This resolves the test determinism issue #23380. It is not a production Spotlight behavior fix and needs no app/backend release or customer/device verification.

@aryanorastar
aryanorastar merged commit 047049a into BasedHardware:main Oct 25, 2026
42 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flutter flutter work positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky Spotlight cooldown assertion in the full Flutter suite

3 participants