feat(shared): add Effect-idiomatic file lock (EffectFlock)#22681
Merged
kitlangton merged 1 commit intodevfrom Apr 16, 2026
Merged
feat(shared): add Effect-idiomatic file lock (EffectFlock)#22681kitlangton merged 1 commit intodevfrom
kitlangton merged 1 commit intodevfrom
Conversation
Parallel reimplementation of the existing Flock using Effect idioms: - Service/Layer architecture: reads lock root from Global.Service, filesystem ops via AppFileSystem (no mutable globals) - Automatic spans via Effect.fn for motel observability - Scoped heartbeat fiber (Effect.forkScoped + Schedule.spaced) replaces manual setInterval/clearInterval - Effect.retry + Schedule.exponential with jitter replaces the manual while-loop backoff - Typed errors: LockTimeoutError, LockCompromisedError, ReleaseError - Schema-validated lock metadata on read (Schema.fromJsonString) - Cached ensureDir per service instance (avoids mkdir syscall on every acquire) - Dual withLock for pipeable usage Includes 11 tests (perf comparison + correctness) using it.live.
aee7a24 to
12a485e
Compare
jerome-benoit
pushed a commit
to jerome-benoit/opencode
that referenced
this pull request
Apr 16, 2026
xywsxp
pushed a commit
to xywsxp/opencode
that referenced
this pull request
Apr 24, 2026
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.
Summary
Flockusing Effect idioms asEffectFlockGlobal.Service, FS ops viaAppFileSystem— no mutable globals, nosetGlobal()Effect.fnfor motel observabilitywithLockPerf comparison
~89% overhead (1.05ms vs 0.55ms per cycle) — dominated by Effect fiber scheduling and span creation. Negligible in real usage since flock guards npm installs, plugin config writes, etc.
Files
packages/shared/src/util/effect-flock.ts— implementationpackages/shared/test/util/effect-flock.test.ts— 11 tests (perf + correctness)Does not touch or replace the original
Flock— this is a parallel implementation for evaluation.