Make diagnostics parsing more idiomatic Effect#3857
Draft
cursor[bot] wants to merge 3 commits into
Draft
Conversation
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>
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
decodeJsonResult(Schema.Record(...))helper instead ofJSON.parse.Optionvalues internally until returning the diagnostics result.ProcessRow.pgidis represented as anOptionand Windows PowerShell JSON parsing goes through Effect Schema decoding.assertfrom@effect/vitest.Why
These changes address focused places where diagnostics code was already Effect-based but still used ad-hoc JSON parsing and nullable internal fields. Using Schema-backed JSON decoding and
Optionmakes the parsing boundaries more testable and consistent with the rest of the Effect codebase while preserving the existing soft-fail diagnostics behavior.UI Changes
Not applicable; this is a server diagnostics refactor with no UI changes.
Checklist
Validation:
pnpm exec vp test run src/diagnostics/TraceDiagnostics.test.ts src/diagnostics/ProcessDiagnostics.test.ts src/diagnostics/ProcessResourceMonitor.test.ts(fromapps/server) — 17 tests passedpnpm exec vp check --fix— passed with existing warningspnpm exec vp run typecheck— passedNote
Refactor diagnostics parsing to use Effect
Optiontypes instead of nullablespgidfield onProcessRowfromnumber | nulltoOption.Option<number>across ProcessDiagnostics.ts, ProcessResourceMonitor.test.ts, and related tests.JSON.parsewith schema-based decoding (Schema,decodeJsonResult) in bothparseWindowsProcessRowsandaggregateTraceDiagnostics, so invalid JSON or malformed records now return empty results or are skipped rather than throwing.WindowsProcessRecordschema with stricter validation:ProcessIdmust be a positive integer,ParentProcessIdmust be non-negative, andstatusdefaults to'Live'when absent.Option-returning variants throughout span aggregation logic.parseWindowsProcessRowsnow yields[]instead of throwing.Macroscope summarized b5d4e92.