Skip to content

Refactor provider session reaper timing with Effect primitives#3689

Draft
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/idiomatic-effect-patterns-9162
Draft

Refactor provider session reaper timing with Effect primitives#3689
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/idiomatic-effect-patterns-9162

Conversation

@cursor

@cursor cursor Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • Replaced provider session reaper raw millisecond constants/options with Effect Duration values.
  • Replaced Date.parse/Clock.currentTimeMillis idle checks with DateTime.make, DateTime.now, and DateTime.distance.
  • Reworked ProviderSessionReaper tests to use @effect/vitest, TestClock, and partial Layer.mock services instead of real-clock polling/full fake service objects.

Why

This keeps the reaper's lifecycle policy testable through Effect services and aligns the module with the codebase's idiomatic Effect guidance around Duration, DateTime, dependency injection, and deterministic clocks.

UI Changes

Not applicable; no UI changes.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes (not applicable)
  • I included a video for animation/interaction changes (not applicable)

Verification

  • PATH="/home/ubuntu/.nvm/versions/node/v24.18.0/bin:$PATH" pnpm exec vp test run src/provider/Layers/ProviderSessionReaper.test.ts (from apps/server): 6 passed
  • PATH="/home/ubuntu/.nvm/versions/node/v24.18.0/bin:$PATH" pnpm exec vp run typecheck (from repo root): passed
  • PATH="/home/ubuntu/.nvm/versions/node/v24.18.0/bin:$PATH" pnpm exec vp check (from repo root): passed
Open in Web View Automation 

Note

Refactor provider session reaper to use Effect Duration primitives and TestClock

  • Replaces millisecond number options (inactivityThresholdMs, sweepIntervalMs) with Duration.Input types in ProviderSessionReaperLiveOptions, requiring callers to update their configuration.
  • Rewrites time handling in makeProviderSessionReaper to use DateTime and Duration APIs instead of Clock.currentTimeMillis and raw arithmetic; invalid lastSeenAt values are now skipped with a warning instead of causing errors.
  • Refactors tests in ProviderSessionReaper.test.ts to use TestClock and Effect-native test utilities, eliminating async polling helpers and ManagedRuntime in favor of deterministic, synchronous assertions.
  • Risk: inactivityThreshold and sweepInterval option names are breaking changes for any existing callers of makeProviderSessionReaperLive.
📊 Macroscope summarized 80f0439. 1 file reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted

🗂️ Filtered Issues

No issues evaluated.

cursoragent and others added 3 commits July 4, 2026 16:07
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 vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 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.

1 participant