Skip to content

Use idiomatic Effect time and random in orchestration#2599

Closed
cursor[bot] wants to merge 3 commits intomainfrom
cursor/idiomatic-effect-patterns-1b98
Closed

Use idiomatic Effect time and random in orchestration#2599
cursor[bot] wants to merge 3 commits intomainfrom
cursor/idiomatic-effect-patterns-1b98

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 8, 2026

What Changed

  • Replaced orchestration engine global Date/Date.now() usage with DateTime.now, including command timing metrics and rejected receipt timestamps.
  • Replaced orchestration event ID generation from crypto.randomUUID() with Random.nextUUIDv4.
  • Added focused @effect/vitest coverage for deterministic random seeding and TestClock-backed rejected receipt timestamps.

Why

These changes keep orchestration behavior injectable and testable through Effect services instead of relying on global time/random sources.

UI Changes

Not applicable.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes
Open in Web View Automation 

Note

Replace native Date and crypto.randomUUID with Effect time and random in orchestration

  • Timestamps in OrchestrationEngine.ts (read model init, queue envelope startedAtMs, metrics durations, rejected receipt acceptedAt) now use DateTime.now via Effect instead of Date.now() / new Date().toISOString().
  • Event IDs in decider.ts now use Random.nextUUIDv4 via the new makeEventBase Effect function instead of crypto.randomUUID.
  • Both changes make behavior controllable under TestClock and seeded Random, with new tests verifying deterministic output in OrchestrationEngine.clock.test.ts and decider.random.test.ts.
  • Behavioral Change: timestamps and UUIDs are now sourced from Effect's clock and random, so any context without an explicit clock/random layer will use Effect's default real-time providers (no functional difference in production).

Macroscope summarized 41737ab.

cursoragent and others added 3 commits May 8, 2026 16:09
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants