Skip to content

[FIX] Drive the last deadline tests from the same clock - #117

Merged
tornikegomareli merged 1 commit into
mainfrom
fix/deadline-clock-family
Sep 3, 2026
Merged

[FIX] Drive the last deadline tests from the same clock#117
tornikegomareli merged 1 commit into
mainfrom
fix/deadline-clock-family

Conversation

@tornikegomareli

Copy link
Copy Markdown
Owner

#115 gave the insertion service's deadlines an injectable clock, and the two tests that failed on its own CI run were in other files. TaskWaitingTests and PromptShapingServiceTests each raced a Task.sleep against real time and asserted the elapsed time was small, which asserts that the runner was fast enough rather than that the deadline was honoured.

InsertionClock is generalized to DeadlineClock and now taken by awaitValue and by PromptShapingService as well as by the insertion service. All three are the same mechanism racing a sleep, so a second near-identical seam would only mean a second fake to keep in step, and DrivenClock moves out of TextInsertionServiceTests so every suite with a deadline can reach it. Production behaviour is unchanged: the live clock is the same continuous clock these deadlines already used.

Five tests drop from wall-clock bounds of two and five seconds, and from 150ms of real sleeping, to under 100ms each. I checked they still bite by breaking the timeout paths three ways, and they caught all three. My first rewrite of returnsAsSoonAsTheTaskFinishes caught only two: it asserted a flag after the wait, which passes whether or not the wait waited, because the task usually finishes on its own first. It now reports whether the task had finished at the moment the wait returned, and fails on that third break.

Closes #116

#115 fixed the insertion family. The two tests that failed on its own CI
run were in other files: TaskWaitingTests and PromptShapingServiceTests
each raced a Task.sleep against real time and asserted the elapsed time
was small, which asserts the runner was fast enough.

InsertionClock is generalized to DeadlineClock and taken by awaitValue
and PromptShapingService as well, because all three are the same
mechanism racing a sleep and a second near-identical seam would only
mean a second fake to keep in step. DrivenClock moves out of
TextInsertionServiceTests for the same reason.

Five tests drop from wall-clock bounds of two and five seconds, and from
150ms of real sleeping, to under 100ms each. Verified by mutation: the
timeout paths were broken three ways and the tests caught all three. The
first rewrite of returnsAsSoonAsTheTaskFinishes did not catch one of
them, passing on a race instead, so it now reports whether the task had
finished at the moment the wait returned.

Closes #116

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012Abfbei4sXuCngAWEH8Z2k
@tornikegomareli
tornikegomareli merged commit 7c57372 into main Sep 3, 2026
1 check passed
@tornikegomareli
tornikegomareli deleted the fix/deadline-clock-family branch September 3, 2026 21:00
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.

The wall-clock deadline tests outside TextInsertionServiceTests still measure the runner

1 participant