Use Effect Schema for Windows process diagnostics#3600
Draft
cursor[bot] wants to merge 2 commits into
Draft
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
|
|
||
| function parseWindowsProcessRows(output: string): ReadonlyArray<ProcessRow> { | ||
| function normalizeWindowsProcessRow(value: unknown): Option.Option<ProcessRow> { | ||
| return Option.flatMap(decodeWindowsProcessRecord(value), (record: WindowsCimProcessRecord) => { |
Contributor
There was a problem hiding this comment.
🟡 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
JSON.parse/manual record probing in Windows process diagnostics withSchema.fromJsonStringplus a typed CIM process row schema.parseWindowsProcessRowsfor focused coverage.effect/Durationvalue.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
Note
Refactor Windows process diagnostics to use Effect Schema validation
normalizeWindowsProcessRowwith an Effect Schema struct (WindowsCimProcessRecord) for parsing and validating Windows CIM process records.parseWindowsProcessRowsfrom an internal function to an exported one, using schema-based decoders for both array and single-object JSON payloads.PROCESS_QUERY_TIMEOUT_MSnumeric constant with aDuration-typedPROCESS_QUERY_TIMEOUT, updating all callers accordingly.📊 Macroscope summarized 0bb0f53. 1 file reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted
🗂️ Filtered Issues
No issues evaluated.