[codex] Add acquire-use-release helper#45
Conversation
Expose fx.acquireUseRelease with a fx.bracket alias for resource-safe workflows. Add runtime coverage for success, failure, and interruption finalization plus type coverage for acquire/use/release inference. Document resource safety guidance and add a changeset for the new public API.
Greptile SummaryThis PR adds
Confidence Score: 5/5Safe to merge — the change is a thin re-export with comprehensive runtime and type-level test coverage. The implementation delegates entirely to Effect's battle-tested No files require special attention.
|
| Filename | Overview |
|---|---|
| src/builders.ts | Adds acquireUseRelease and bracket as direct re-exports of Effect.acquireUseRelease, consistent with the pattern used for other thin wrappers in this file. |
| src/index.ts | Exposes acquireUseRelease and bracket on the fx object; placement and style are consistent with existing entries. |
| docs/resources.md | New Resource Safety guide with a worked example; release handler correctly uses fx.sync with an inner try/catch so the error channel stays clean. |
| test/runtime.test.ts | Adds runtime tests for success, failure, and interruption paths; the interruption test uses a Deferred + timeout guard to avoid a flaky pass. |
| test/types.test.ts | Type-level tests verify result, error (acquire union use only, release never leaks), and dependency inference for both acquireUseRelease and bracket. |
| docs/api-reference.md | Adds two rows to the builder table for the new methods; accurate and consistent with existing entries. |
| docs/README.md | Inserts a link to the new Resource Safety guide in the docs index at the correct alphabetical position. |
| .changeset/brave-owls-bracket.md | Minor-version changeset correctly describes both new public exports. |
Reviews (2): Last reviewed commit: "docs: keep release example error-free" | Re-trigger Greptile
Update the resource safety guide so the release callback handles cleanup failures inside fx.sync instead of returning a typed failure from fx.try. This keeps the example aligned with the guidance that acquire-use-release finalizers should not widen the typed error channel.
Summary
Adds a first-class resource safety helper to the root
fxAPI for Issue #33.Changes
fx.acquireUseReleaseas a typed wrapper around Effect's acquire/use/release primitive.fx.bracketas a shorter alias for the same workflow.Impact
Users can now model file handles, connections, locks, spans, and similar resources without dropping to
fluent-effect/effectfor the common acquire/use/release case. The helper preserves native Effect finalizer semantics: release receives the resource and exit value, runs on success/failure/interruption, and does not contribute a typed failure channel.Closes #33.
Validation
bun testbun typecheckbun fmt --checkbun lintbun run build