Skip to content

refactor: destroy Storage facades#21956

Merged
kitlangton merged 3 commits intodevfrom
kit/migrate-storage-facade
Apr 11, 2026
Merged

refactor: destroy Storage facades#21956
kitlangton merged 3 commits intodevfrom
kit/migrate-storage-facade

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

Summary

First facade destruction using the new AppRuntime composition. Migrates Session.diff from the Storage.read promise facade to a direct service yield, deletes the Storage facades + makeRuntime, and converts storage.test.ts to full effectful style.

Changes

  • session/index.tsSession.layer now requires Storage.Service; Session.diff uses yield* storage.read(...) instead of Effect.tryPromise(() => Storage.read(...))
  • storage/storage.ts — deleted read, write, update, remove, list async facades and the per-service makeRuntime
  • test/storage/storage.test.ts — fully converted to testEffect + it.live + Effect.gen. Raw fs / Bun.write / tmpdir / try/finally replaced with AppFileSystem.Service / tmpdirScoped / Effect.addFinalizer
  • test/share/share-next.test.ts — switched from Session.layer to Session.defaultLayer since Session now requires Storage
  • specs/effect-migration.md — new "Destroying the facades" section documenting the migration process, including the Layer.fresh trick for letting inner Effect.provide override layers cached in the outer testEffect runtime's memoMap

Test plan

  • bun run typecheck clean
  • Full suite: 1885 pass, 0 fail
  • CI green

Migrates Session.diff from Effect.tryPromise(() => Storage.read(...)) to
a direct yield, deletes the Storage async facades and per-service
makeRuntime, and converts storage.test.ts to full effectful style using
testEffect + it.live + Effect.gen.

Adds a "Destroying the facades" section to the effect-migration spec
documenting the process and the Layer.fresh trick for letting inner
Effect.provide override layers that are already cached in the outer
testEffect runtime's memoMap.
- Fold Storage.Service yield into the scope() helper so the 10 scope
  tests can destructure { root, svc } instead of yielding twice
- Drop local writeJson/writeText helpers in favor of the existing
  AppFileSystem.writeWithDirs method
- Use Exit.isFailure(exit) instead of stringly-typed exit._tag check
- Rename map → remap (less generic) and rename remapped → remappedFs
- Add comments explaining the remap pattern and the Layer.fresh
  workaround for cached Storage instances
@kitlangton kitlangton force-pushed the kit/migrate-storage-facade branch from cc580a6 to 2cbb55c Compare April 11, 2026 01:11
@kitlangton kitlangton merged commit 5cd4c6e into dev Apr 11, 2026
7 of 9 checks passed
@kitlangton kitlangton deleted the kit/migrate-storage-facade branch April 11, 2026 01:21
mrsimpson pushed a commit to mrsimpson/opencode that referenced this pull request Apr 14, 2026
xywsxp pushed a commit to xywsxp/opencode that referenced this pull request Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant