Skip to content

Use Effect Schema for Windows process diagnostics#3600

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

Use Effect Schema for Windows process diagnostics#3600
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/idiomatic-effect-patterns-b1f9

Conversation

@cursor

@cursor cursor Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • Replaced raw JSON.parse/manual record probing in Windows process diagnostics with Schema.fromJsonString plus a typed CIM process row schema.
  • Made Windows row normalization Option-based and exported parseWindowsProcessRows for focused coverage.
  • Switched the process query timeout constant to an effect/Duration value.
  • Added tests for Windows CIM JSON arrays, single-object output, malformed JSON, and structurally invalid rows.

Why

This keeps the diagnostics parser more idiomatic Effect, preserves tolerant handling of bad process rows, and makes the Windows path testable without invoking PowerShell.

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

Refactor Windows process diagnostics to use Effect Schema validation

  • Replaces manual type-checking in normalizeWindowsProcessRow with an Effect Schema struct (WindowsCimProcessRecord) for parsing and validating Windows CIM process records.
  • Changes parseWindowsProcessRows from an internal function to an exported one, using schema-based decoders for both array and single-object JSON payloads.
  • Replaces the PROCESS_QUERY_TIMEOUT_MS numeric constant with a Duration-typed PROCESS_QUERY_TIMEOUT, updating all callers accordingly.
  • Adds tests for Windows CIM JSON parsing, covering array input, single-object input, and malformed/incomplete JSON.
📊 Macroscope summarized 0bb0f53. 1 file reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted

🗂️ Filtered Issues

No issues evaluated.

cursoragent and others added 2 commits June 29, 2026 16:07
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 Jun 29, 2026

function parseWindowsProcessRows(output: string): ReadonlyArray<ProcessRow> {
function normalizeWindowsProcessRow(value: unknown): Option.Option<ProcessRow> {
return Option.flatMap(decodeWindowsProcessRecord(value), (record: WindowsCimProcessRecord) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium diagnostics/ProcessDiagnostics.ts:222

normalizeWindowsProcessRow runs the whole record through decodeWindowsProcessRecord, whose schema treats WorkingSetSize, PercentProcessorTime, and Status as typed optional fields. A record like { "ProcessId": 42, "ParentProcessId": 1, "Name": "node.exe", "WorkingSetSize": "4096" } previously produced a row with rssBytes: 0, but now decodeWindowsProcessRecord returns None because WorkingSetSize is a string, so the entire process row is silently dropped. Consider decoding only the required fields (ProcessId, ParentProcessId) strictly and reading the optional fields defensively, as the previous implementation did.

🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/server/src/diagnostics/ProcessDiagnostics.ts around line 222:

`normalizeWindowsProcessRow` runs the whole record through `decodeWindowsProcessRecord`, whose schema treats `WorkingSetSize`, `PercentProcessorTime`, and `Status` as typed optional fields. A record like `{ "ProcessId": 42, "ParentProcessId": 1, "Name": "node.exe", "WorkingSetSize": "4096" }` previously produced a row with `rssBytes: 0`, but now `decodeWindowsProcessRecord` returns `None` because `WorkingSetSize` is a string, so the entire process row is silently dropped. Consider decoding only the required fields (`ProcessId`, `ParentProcessId`) strictly and reading the optional fields defensively, as the previous implementation did.

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