Skip to content

Use idiomatic Effect for workspace file reads#3404

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

Use idiomatic Effect for workspace file reads#3404
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/idiomatic-effect-patterns-8a8f

Conversation

@cursor

@cursor cursor Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • Replaced the node:fs/promises read path in WorkspaceFileSystem.readFile with Effect platform FileSystem APIs (realPath, scoped open, handle stat/read).
  • Added granular Schema.TaggedErrorClass causes for workspace read safety failures.
  • Converted the workspace filesystem tests to assert style and added coverage for truncation and binary-file rejection.

Why

This keeps workspace file reads inside Effect services end-to-end, avoids direct Node filesystem APIs, and makes read failures more structured and testable while preserving existing read behavior.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • UI changes not applicable

Verification

  • pnpm run test src/workspace/WorkspaceFileSystem.test.ts (from apps/server) — 8 tests passed
  • pnpm exec vp check — 0 errors, existing unrelated lint warnings
  • pnpm exec vp run typecheck — passed
Open in Web View Automation 

Note

Refactor WorkspaceFileSystem.readFile to use idiomatic Effect APIs with typed error causes

  • Replaces node:fs/promises calls with Effect FileSystem APIs (realPath, open, stat) in WorkspaceFileSystem.ts.
  • Adds three typed error classes — WorkspaceReadFileResolvedOutsideRootError, WorkspaceReadFileNotFileError, and WorkspaceReadFileBinaryFileError — as structured causes inside WorkspaceFileSystemError.
  • Binary files are now explicitly rejected before decoding by scanning the read buffer for a NUL byte.
  • Updates tests in WorkspaceFileSystem.test.ts to use @effect/vitest assertions and adds coverage for truncation and binary file rejection.

Macroscope summarized 201f654.

cursoragent and others added 3 commits June 20, 2026 16:05
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:L 100-499 changed lines (additions + deletions). labels Jun 20, 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