Skip to content

refactor(time): make clocks and timers injectable across services, SDK, and web - #261

Merged
karagozemin merged 1 commit into
Sub-Rosa-Issue:mainfrom
CemAyyildiz:issue-239-injectable-time
Aug 30, 2026
Merged

refactor(time): make clocks and timers injectable across services, SDK, and web#261
karagozemin merged 1 commit into
Sub-Rosa-Issue:mainfrom
CemAyyildiz:issue-239-injectable-time

Conversation

@CemAyyildiz

Copy link
Copy Markdown
Contributor

Summary

  • Adds @sub-rosa/time with Clock and Scheduler contracts, production (systemClock / systemScheduler) and deterministic fake implementations for tests.
  • Migrates first-party runtime code in the SDK, keeper, agent, web app, tlock, receipt-cli, and operational scripts to injected time dependencies with production-safe defaults.
  • Adds scripts/check-direct-time-access.mjs to block new direct Date.now / timer usage outside the approved time package adapters.

Scope

  • Service, SDK, hook, and script boundaries accept optional time / clock / scheduler overrides.
  • React hooks and UI components cancel timers on cleanup; keeper status server clears shutdown timers.
  • Time-sensitive unit tests use FakeClock / FakeScheduler instead of real sleeps where practical.
  • Stellar SDK transaction .setTimeout(N) calls are unchanged and excluded from the guard.

Closes #239

Test plan

  • pnpm time:test
  • pnpm time:guard and pnpm time:guard:test
  • pnpm --filter @sub-rosa/sdk test and pnpm --filter @sub-rosa/sdk typecheck
  • pnpm --filter @sub-rosa/keeper test and pnpm --filter @sub-rosa/keeper typecheck
  • pnpm --filter @sub-rosa/agent test
  • pnpm --filter @sub-rosa/web test
  • pnpm --filter @sub-rosa/tlock test

Made with Cursor

…-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>
@karagozemin
karagozemin merged commit 6548649 into Sub-Rosa-Issue:main Aug 30, 2026
2 of 3 checks passed
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.

refactor(time): make clocks and timers injectable across services, SDK, and web

2 participants