Skip to content

Use Effect idioms in diagnostics and keyed worker#2783

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/effect-codebase-idioms-9435
Draft

Use Effect idioms in diagnostics and keyed worker#2783
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/effect-codebase-idioms-9435

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 22, 2026

What Changed

  • Updated the process resource monitor to represent timing policy with Duration, repeat sampling with Schedule.spaced, and store/report the latest sampling error as Option.
  • Reworked KeyedCoalescingWorker queue state to use Option instead of null/undefined sentinels, preserving undefined values as valid queued work.
  • Switched touched tests to @effect/vitest assert style and added focused coverage for the new Option-backed paths.

Why

These are small Effect idiom improvements that make monitor timing easier to test with Effect primitives and remove sentinel values from queue state, including fixing the edge case where an explicitly undefined queued value would be dropped.

UI Changes

None.

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

Use Effect idioms for Option types and scheduling in diagnostics and keyed worker

  • Replaces null/undefined sentinel values with Option types for lastError in ProcessResourceMonitor and for key values in KeyedCoalescingWorker, fixing cases where undefined values were silently treated as absent.
  • Replaces the manual forever loop in ProcessResourceMonitor with Effect.repeat(Schedule.spaced(SAMPLE_INTERVAL)) for cleaner scheduling.
  • Clamps window and bucket durations to a minimum of 1 second in aggregateProcessResourceHistory via Duration.max.
  • Updates tests in both modules to use @effect/vitest assert API and adds coverage for undefined enqueue and Option-mapped sampling errors.
  • Behavioral Change: KeyedCoalescingWorker now processes keys whose latest value is undefined rather than skipping them; ProcessResourceMonitor now clamps sub-1s window/bucket inputs.

Macroscope summarized bd57f3b.

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 22, 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.

1 participant