uttrflow / uttrflow/uttrflow-swift

IdleReleaseTests.watchReleases still waits on a real 40 ms timer

Open
#502 0 comments 0 reactions 0 assignees View on GitHub
area:ai-suggestions enhancement good first issue P2
Dominant language
Swift
Stars
4
Forks
17
Avg merge
3h 32m
Merged PRs (30d)
277

Description

## What happens

`watchReleases` in `Tests/UttrflowPredictTests/IdleReleaseTests.swift:130-137` builds `IdleReleasingModel(model:idleAfter: .milliseconds(40))` and waits for the watch task to finish. The watch (`Sources/UttrflowPredict/IdleRelease.swift:177-188`) sleeps on the real clock with `Task.sleep(for: idleAfter / 4)` and checks `releaseIfIdle(at: .now)`, so the test's duration and outcome depend on real time passing on a busy machine.

#393 removed this kind of wall-clock dependence from the audio and pipeline tests (#407). This test was not part of that change.

## Why it matters

The project's rule is that tests wait on real signals, injected clocks or work counts, never on fixed sleeps, because timing tests flake under load. This one has not flaked yet, but it is the last of its kind in `UttrflowPredictTests`.

## How to check

Read the test and `watchForIdle()`. The other tests in the file already use `releaseIfIdle(at:)` with an explicit instant.

## Acceptance criteria

- `IdleReleasingModel` takes an injectable way to wait and to read "now" (for example a `Clock` generic parameter or a sleep closure, defaulting to the real `ContinuousClock`), without changing its public behaviour or its call site in `Sources/Uttrflow/UttrflowApp.swift`.
- `watchReleases` drives that seam instead of real time, and asserts the same thing: the watch releases the model once the window has passed, by itself.
- No test in the file sleeps or depends on wall-clock time.

## Where to start

- `Sources/UttrflowPredict/IdleRelease.swift` (the actor, and `watchForIdle()` at line 179)
- For the pattern, read how #407 changed `Tests/UttrflowPipelineTests/DictationPipelineTurnTests.swift`.
- Tests to extend: `Tests/UttrflowPredictTests/IdleReleaseTests.swift`.
- Before pushing, run `make verify` (export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer first). It is the same command CI runs, and it enforces the 95% coverage floor per module.
- Read [CONTRIBUTING.md](https://github.com/uttrflow/uttrflow-swift/blob/main/CONTRIBUTING.md) first, and say on this issue that you are taking it.

**Size:** M, about half a day.

Contributor guide

Open the contributing guide

Research direction

Read CONTRIBUTING.md, then inspect IdleReleasingModel and watchForIdle() in Sources/UttrflowPredict/IdleRelease.swift alongside IdleReleaseTests.swift. Compare the injected-time pattern from DictationPipelineTurnTests.swift, run the focused tests, and finish by running make verify; done means watchReleases uses no wall-clock sleep while preserving the existing release assertion and UttrflowApp.swift call site.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
testing-qa
Issue type
Refactor
Difficulty
3/5
Estimated time
Half a day
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.