Skip to content

[FIX] Drive the insertion deadlines from an injectable clock - #115

Merged
tornikegomareli merged 1 commit into
tornikegomareli:mainfrom
Swagatar-LLC:fix/insertion-clock-seam
Sep 3, 2026
Merged

[FIX] Drive the insertion deadlines from an injectable clock#115
tornikegomareli merged 1 commit into
tornikegomareli:mainfrom
Swagatar-LLC:fix/insertion-clock-seam

Conversation

@jhampton

@jhampton jhampton commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

This is the injectable-clock fix you sketched as option 2 on #82, after the reruns on #68 pushed the flake from occasional to constant. The clipboard reader's snapshot deadline and the copy wait now run on an InsertionClock seam in Dependencies, continuous in production and driven by hand in the tests, so the whole family holds or advances time itself: the happy-path tests arm deadlines that can never elapse, and the timeout tests force the deadline instead of racing a real timer against the runner, which makes the assertion "the deadline was honoured" rather than "the machine was fast enough". That also retires the 2-second busy-skip ceiling whose own comment recorded a CI failure at 50ms, and the 1-second scheduling waits I flagged on #68 become generous event budgets that only spend themselves on a genuinely broken run. I routed waitForCopy through the same clock deliberately: it is the same real-deadline shape in the same file and one seam serves both, which is a shade past what I promised on #82, so I would rather say it here than let the diff imply it. Production behaviour is unchanged, since the live clock is the same continuous clock the deadlines used before. The full suite is green locally on Apple Silicon at 433 passed with the four expected media-fixture skips, and the insertion class now finishes with no real sleeping at all. I used Claude Code for most of the writing under my direction and can explain every line.

Closes #82

@tornikegomareli
tornikegomareli merged commit 431b89e into tornikegomareli:main Sep 3, 2026
1 of 2 checks passed
jhampton added a commit to Swagatar-LLC/Talkify that referenced this pull request Sep 3, 2026
The shaping work those notes described has now landed upstream (tornikegomareli#68,
tornikegomareli#111, tornikegomareli#113, tornikegomareli#114) along with the insertion-clock fix (tornikegomareli#115), so keeping
it in fork-unreleased.md would republish upstream release notes as if
they were fork-only changes. The file accumulates again as fork work
lands; empty is the correct resting state, and swagatar-release.sh
already falls back to the build disclaimer when it is.

Co-Authored-By: Vorno <agents-noreply@swagatar.co>
tornikegomareli added a commit that referenced this pull request Sep 3, 2026
#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


Claude-Session: https://claude.ai/code/session_012Abfbei4sXuCngAWEH8Z2k

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
jhampton added a commit to Swagatar-LLC/Talkify that referenced this pull request Sep 3, 2026
The shaping work those notes described landed upstream in tornikegomareli#68, tornikegomareli#111 and
tornikegomareli#114, and the insertion-clock fix in tornikegomareli#115, so shipping them from the
fork would republish upstream's release notes as fork-only changes. The
file accumulates again as fork work lands; empty is its resting state,
and swagatar-release.sh falls back to the build disclaimer when it is.
jhampton added a commit to Swagatar-LLC/Talkify that referenced this pull request Sep 4, 2026
The shaping work those notes described landed upstream in tornikegomareli#68, tornikegomareli#111 and
tornikegomareli#114, and the insertion-clock fix in tornikegomareli#115, so shipping them from the
fork would republish upstream's release notes as fork-only changes. The
file accumulates again as fork work lands; empty is its resting state,
and swagatar-release.sh falls back to the build disclaimer when it is.
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.

TextInsertionServiceTests has a flaky family that fails on CI and passes on re-run

2 participants