M-0: APIClock protocol + RealClock + ManualClock (G-002) #91

Open
opened 2026-05-12 19:36:36 +00:00 by KofTwentyTwo · 0 comments
KofTwentyTwo commented 2026-05-12 19:36:36 +00:00 (Migrated from github.com)

Goal

Add APIClock protocol + RealClock + ManualClock to JarvisAPI for deterministic time control (G-002).

Scope

  • APIClock protocol with now() -> Date and sleep(for:) async throws
  • RealClock — production conformer
  • ManualClock — test conformer with advance(by:)
  • NOT yet wired into surfaces

Files

packages/JarvisAPI/Sources/JarvisAPI/Clock.swift (new)

Acceptance

  • swift test --package-path packages/JarvisAPI green
  • ManualClock.advance(by:) deterministically resumes sleep(for:) awaiters
  • No imports of Foundation.Timer or wall-clock primitives in scenario code

Test

Unit tests in JarvisAPITests verify ManualClock semantics (advance triggers awaiters).

Parent epic

#4

Source

.planning/architecture/JARVIS-API-MIGRATION-PLAN.md §2.1 (M-0.2)
G-002 (deterministic clock)

## Goal Add APIClock protocol + RealClock + ManualClock to JarvisAPI for deterministic time control (G-002). ## Scope - `APIClock` protocol with `now() -> Date` and `sleep(for:) async throws` - `RealClock` — production conformer - `ManualClock` — test conformer with `advance(by:)` - NOT yet wired into surfaces ## Files `packages/JarvisAPI/Sources/JarvisAPI/Clock.swift` (new) ## Acceptance - [ ] `swift test --package-path packages/JarvisAPI` green - [ ] `ManualClock.advance(by:)` deterministically resumes `sleep(for:)` awaiters - [ ] No imports of `Foundation.Timer` or wall-clock primitives in scenario code ## Test Unit tests in JarvisAPITests verify ManualClock semantics (advance triggers awaiters). ## Parent epic #4 ## Source `.planning/architecture/JARVIS-API-MIGRATION-PLAN.md` §2.1 (M-0.2) G-002 (deterministic clock)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: KofTwentyTwo/Jarvis#91