[FIX] Drive the last deadline tests from the same clock - #117
Merged
Conversation
#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
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.
#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