Skip to content

feat: DenoFileSystem - #6682

Merged
tim-smart merged 11 commits into
mainfrom
feat/deno-file-system
Jul 28, 2026
Merged

feat: DenoFileSystem#6682
tim-smart merged 11 commits into
mainfrom
feat/deno-file-system

Conversation

@tim-smart

@tim-smart tim-smart commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • extract the FileSystem tests into a reusable conformance suite
  • preserve the existing Node assertions and fixture coverage
  • add documented opt-outs for the accepted Deno divergences

Testing

  • pnpm lint-fix
  • pnpm --filter @effect/platform-node-shared test --run test/NodeFileSystem.test.ts
  • pnpm check

Closes EFF-139
Closes EFF-159

Summary by CodeRabbit

  • New Features
    • Added a Deno-backed FileSystem implementation and exposed it via the platform-deno package.
  • Tests
    • Introduced a reusable, configurable filesystem test harness and migrated the Node FileSystem suite to use it.
    • Added dedicated Deno FileSystem tests and expanded fixture, temp directory/file (including scoped cleanup), read/write/append, truncation, and cursor-behavior coverage.
    • Updated the text fixture used for read validation.
  • Bug Fixes
    • Improved Deno error mapping to consistent platform error reasons.
  • Chores
    • Added a Deno @std/fs dependency and published a patch release note.

@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog Jul 28, 2026
@changeset-bot

changeset-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c90ffd7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 29 packages
Name Type
@effect/platform-deno Patch
effect Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@effect-slopcop effect-slopcop Bot added 4.0 enhancement New feature or request labels Jul 28, 2026
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 91d2b07d-4460-4fc6-ba18-f3d9e0e33d39

📥 Commits

Reviewing files that changed from the base of the PR and between 575c2bf and c90ffd7.

📒 Files selected for processing (1)
  • packages/effect/test/FileSystem.test-utils.ts
💤 Files with no reviewable changes (1)
  • packages/effect/test/FileSystem.test-utils.ts

📝 Walkthrough

Walkthrough

A reusable FileSystem test harness now runs filesystem behavior checks against injected layers, and Node delegates to it. The Deno platform adds a filesystem layer, error translation, public exports, conformance tests, and a patch changeset.

Changes

Filesystem conformance testing

Layer / File(s) Summary
Shared filesystem conformance harness
packages/effect/test/FileSystem.test-utils.ts, packages/effect/test/fixtures/text.txt, packages/platform-node-shared/test/NodeFileSystem.test.ts
Adds configurable layer-driven tests for fixture reads, temporary resources, truncation, cursor movement, append mode, and cleanup; Node delegates its suite to the shared harness.

Deno filesystem layer

Layer / File(s) Summary
Deno error translation
packages/platform-deno/src/internal/error.ts, packages/platform-deno/test/internal/error.test.ts
Maps Deno error names and codes to SystemErrorTag values while preserving operation metadata and causes.
Deno filesystem implementation
packages/platform-deno/package.json, packages/platform-deno/src/DenoFileSystem.ts
Adds Deno-backed file, directory, temporary-resource, metadata, watch, read, write, and position-tracking operations with a provided FileSystem layer.
Public integration and conformance coverage
packages/platform-deno/src/index.ts, packages/platform-deno/test/DenoFileSystem.test.ts, .changeset/add-deno-file-system.md
Exports the Deno filesystem layer, runs shared tests with Deno-specific expectations, and records a patch release.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant FileSystemTest
  participant DenoFileSystem
  participant DenoFsFile
  participant handleError
  FileSystemTest->>DenoFileSystem: invoke filesystem operation
  DenoFileSystem->>DenoFsFile: perform Deno filesystem call
  DenoFsFile-->>DenoFileSystem: return result or error
  DenoFileSystem->>handleError: translate Deno error
  handleError-->>FileSystemTest: return Effect result or PlatformError
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
packages/effect/test/FileSystem.test-utils.ts (3)

15-19: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Shadowed type parameter E.

runPromise's <E, A> shadows the outer <E> from testLayer. Harmless, but rename for clarity.

♻️ Suggested rename
-  const runPromise = <E, A>(self: Effect.Effect<A, E, Fs.FileSystem>) =>
+  const runPromise = <E2, A>(self: Effect.Effect<A, E2, Fs.FileSystem>) =>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/effect/test/FileSystem.test-utils.ts` around lines 15 - 19, Rename
the inner error type parameter in the nested runPromise function within
testLayer so it no longer shadows testLayer’s outer E parameter; update its
Effect type annotation consistently while preserving the existing behavior.

79-80: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Guard against a missing path separator.

If neither separator is found, separator is -1 and dir becomes the path minus its last character, producing a confusing failure instead of a clear one.

🛡️ Proposed fix
             const separator = Math.max(file.lastIndexOf("/"), file.lastIndexOf("\\"))
+            assert(separator > 0, `expected a path separator in ${file}`)
             dir = file.slice(0, separator)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/effect/test/FileSystem.test-utils.ts` around lines 79 - 80, Update
the path handling around the separator calculation to detect when neither "/"
nor "\\" is present before slicing. Handle this missing-separator case
explicitly with a clear failure, while preserving the existing directory
extraction when a separator is found.

237-253: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider an opt-out for truncate cursor clamping.

POSIX ftruncate doesn't move the file offset, so clamping the cursor to the new length is an Effect-level guarantee that a backend may not reproduce. Given the harness already exposes TestLayerOptions for accepted divergences, adding a flag here would avoid a forced patch later when another runtime is wired in.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/effect/test/FileSystem.test-utils.ts` around lines 237 - 253, Add a
`TestLayerOptions` opt-out for truncate cursor clamping, and update the test
around `file.truncate` and the subsequent current-position `file.seek` to honor
that option. Preserve the existing clamped-cursor expectation by default while
allowing backends that follow POSIX `ftruncate` semantics to disable it.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/effect/test/FileSystem.test-utils.ts`:
- Around line 15-19: Rename the inner error type parameter in the nested
runPromise function within testLayer so it no longer shadows testLayer’s outer E
parameter; update its Effect type annotation consistently while preserving the
existing behavior.
- Around line 79-80: Update the path handling around the separator calculation
to detect when neither "/" nor "\\" is present before slicing. Handle this
missing-separator case explicitly with a clear failure, while preserving the
existing directory extraction when a separator is found.
- Around line 237-253: Add a `TestLayerOptions` opt-out for truncate cursor
clamping, and update the test around `file.truncate` and the subsequent
current-position `file.seek` to honor that option. Preserve the existing
clamped-cursor expectation by default while allowing backends that follow POSIX
`ftruncate` semantics to disable it.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 22ac5ca7-4180-4e41-bdd6-0a3bce29e213

📥 Commits

Reviewing files that changed from the base of the PR and between ec656dc and 9f99890.

📒 Files selected for processing (3)
  • packages/effect/test/FileSystem.test-utils.ts
  • packages/effect/test/fixtures/text.txt
  • packages/platform-node-shared/test/NodeFileSystem.test.ts

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

File Name Current Size Previous Size Difference
basic.ts 6.63 KB 6.63 KB 0.00 KB (0.00%)
batching.ts 9.37 KB 9.37 KB 0.00 KB (0.00%)
brand.ts 6.26 KB 6.26 KB 0.00 KB (0.00%)
cache.ts 10.12 KB 10.12 KB 0.00 KB (0.00%)
config.ts 19.19 KB 19.19 KB 0.00 KB (0.00%)
differ.ts 18.42 KB 18.42 KB 0.00 KB (0.00%)
http-client.ts 20.88 KB 20.88 KB 0.00 KB (0.00%)
logger.ts 10.28 KB 10.28 KB 0.00 KB (0.00%)
metric.ts 8.55 KB 8.55 KB 0.00 KB (0.00%)
optic.ts 7.41 KB 7.41 KB 0.00 KB (0.00%)
pubsub.ts 14.20 KB 14.20 KB 0.00 KB (0.00%)
queue.ts 11.09 KB 11.09 KB 0.00 KB (0.00%)
schedule.ts 10.27 KB 10.27 KB 0.00 KB (0.00%)
schema-class.ts 18.16 KB 18.16 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 28.02 KB 28.02 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 24.34 KB 24.34 KB 0.00 KB (0.00%)
schema-string-transformation.ts 12.69 KB 12.69 KB 0.00 KB (0.00%)
schema-string.ts 10.35 KB 10.35 KB 0.00 KB (0.00%)
schema-template-literal.ts 14.49 KB 14.49 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 20.93 KB 20.93 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 23.38 KB 23.38 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 18.32 KB 18.32 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 18.00 KB 18.00 KB 0.00 KB (0.00%)
schema-toFormatter.ts 17.88 KB 17.88 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 21.52 KB 21.52 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 18.56 KB 18.56 KB 0.00 KB (0.00%)
schema.ts 17.43 KB 17.43 KB 0.00 KB (0.00%)
stm.ts 12.05 KB 12.05 KB 0.00 KB (0.00%)
stream.ts 9.37 KB 9.37 KB 0.00 KB (0.00%)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/platform-deno/src/internal/error.ts`:
- Around line 21-43: Add explicit native Deno error-name branches in the error
mapping around the existing errno switch, covering BadResource, InvalidData,
TimedOut, UnexpectedEof, WouldBlock, and WriteZero before errno fallback; retain
the existing NotCapable handling. In
packages/platform-deno/src/internal/error.ts lines 21-43, map each name to its
corresponding normalized tag, and in
packages/platform-deno/test/internal/error.test.ts lines 9-17 add raw
native-error cases verifying these mappings.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 16471d33-949b-4f4d-87c1-2c58d0b9e04c

📥 Commits

Reviewing files that changed from the base of the PR and between 9f99890 and 377f44f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • packages/effect/test/FileSystem.test-utils.ts
  • packages/platform-deno/package.json
  • packages/platform-deno/src/internal/error.ts
  • packages/platform-deno/test/internal/error.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/effect/test/FileSystem.test-utils.ts

Comment thread packages/platform-deno/src/internal/error.ts Outdated
@github-project-automation github-project-automation Bot moved this from Discussion Ongoing to Waiting on Author in PR Backlog Jul 28, 2026
Comment thread packages/platform-deno/src/DenoFileSystem.ts
Comment thread packages/platform-deno/src/DenoFileSystem.ts Outdated
@tim-smart
tim-smart force-pushed the feat/deno-file-system branch from f28533f to d3efdd8 Compare July 28, 2026 09:42
Comment thread packages/platform-deno/src/DenoFileSystem.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/effect/test/FileSystem.test-utils.ts`:
- Around line 29-40: Update the makeTempDirectory test and the corresponding
test around lines 93–108 to clean up every temporary directory or file created
during the test. Register a finalizer that removes the temporary resource after
assertions, including when assertions fail, while preserving the existing
persistence checks.
- Line 24: Replace the __dirname-based fixture paths in the test reads at lines
24, 116, 145, 161, and 185 with an ESM-safe path derived from import.meta.url,
using the existing fixture filenames and preserving the current readFile
behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: eccb2a06-2df6-4986-8f65-2e0f85b3f7bd

📥 Commits

Reviewing files that changed from the base of the PR and between 377f44f and 4f8eed1.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • .changeset/add-deno-file-system.md
  • packages/effect/test/FileSystem.test-utils.ts
  • packages/effect/test/fixtures/text.txt
  • packages/platform-deno/package.json
  • packages/platform-deno/src/DenoFileSystem.ts
  • packages/platform-deno/src/index.ts
  • packages/platform-deno/src/internal/error.ts
  • packages/platform-deno/test/DenoFileSystem.test.ts
  • packages/platform-deno/test/internal/error.test.ts
  • packages/platform-node-shared/test/NodeFileSystem.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • packages/platform-node-shared/test/NodeFileSystem.test.ts
  • packages/platform-deno/package.json
  • packages/platform-deno/test/internal/error.test.ts
  • packages/platform-deno/src/internal/error.ts
  • packages/effect/test/fixtures/text.txt

Comment thread packages/effect/test/FileSystem.test-utils.ts
Comment thread packages/effect/test/FileSystem.test-utils.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/effect/test/FileSystem.test-utils.ts`:
- Around line 204-228: Make the interrupted-read test around readAlloc
deterministic by replacing the fixed-size file and millisecond timeout/sleep
assumptions with a controllable slow-read seam that reliably interrupts while
I/O is in flight, then waits for completion before seeking and validating cursor
restoration. If no such seam is available, move this timing-sensitive case out
of the cross-platform conformance test into an appropriate platform-specific
test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 04350753-8009-4b56-ab32-209c15a970a9

📥 Commits

Reviewing files that changed from the base of the PR and between 4f8eed1 and 575c2bf.

📒 Files selected for processing (2)
  • packages/effect/test/FileSystem.test-utils.ts
  • packages/platform-deno/src/DenoFileSystem.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/platform-deno/src/DenoFileSystem.ts

Comment thread packages/effect/test/FileSystem.test-utils.ts Outdated
@tim-smart
tim-smart enabled auto-merge (squash) July 28, 2026 10:57
@tim-smart
tim-smart merged commit cd98622 into main Jul 28, 2026
15 checks passed
@tim-smart
tim-smart deleted the feat/deno-file-system branch July 28, 2026 10:58
@github-project-automation github-project-automation Bot moved this from Waiting on Author to Done in PR Backlog Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0 enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant