refactor(time): make clocks and timers injectable across services, SDK, and web - #261
Merged
karagozemin merged 1 commit intoAug 30, 2026
Conversation
…-Issue#239) Add @sub-rosa/time with system and fake Clock/Scheduler implementations, migrate first-party services and web code to injected time dependencies, convert time-sensitive tests to deterministic fakes, and add a repository guard against direct Date.now/setTimeout usage outside the time package. Closes Sub-Rosa-Issue#239 Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
@sub-rosa/timewithClockandSchedulercontracts, production (systemClock/systemScheduler) and deterministic fake implementations for tests.scripts/check-direct-time-access.mjsto block new directDate.now/ timer usage outside the approved time package adapters.Scope
time/clock/scheduleroverrides.FakeClock/FakeSchedulerinstead of real sleeps where practical..setTimeout(N)calls are unchanged and excluded from the guard.Closes #239
Test plan
pnpm time:testpnpm time:guardandpnpm time:guard:testpnpm --filter @sub-rosa/sdk testandpnpm --filter @sub-rosa/sdk typecheckpnpm --filter @sub-rosa/keeper testandpnpm --filter @sub-rosa/keeper typecheckpnpm --filter @sub-rosa/agent testpnpm --filter @sub-rosa/web testpnpm --filter @sub-rosa/tlock testMade with Cursor