Skip to content

Extract InstanceStore.provide helper#25372

Merged
kitlangton merged 1 commit intodevfrom
kit/instance-store-provide
May 2, 2026
Merged

Extract InstanceStore.provide helper#25372
kitlangton merged 1 commit intodevfrom
kit/instance-store-provide

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

Summary

  • Adds `InstanceStore.provide(input, effect)` — loads the cached instance context and provides `InstanceRef` to the wrapped effect.
  • Refactors the HttpApi instance-context middleware (`makeInstanceContext` + manual `provideService(InstanceRef)`) to use the new helper.
  • Gives non-middleware callers (CLI bridges, background jobs) a single primitive for entering an instance scope from Effect-native code.

Why

The instance-context middleware was inlining `store.load` + `Effect.provideService(InstanceRef, ctx)`. Any other Effect-native call site that needs to enter an instance scope would copy that same pattern. Extracting it as `InstanceStore.provide` removes the duplication and makes the next conversion (CLI commands moving to native Effect bodies) a one-liner.

Tests

  • `bun run test test/project/instance.test.ts test/server/httpapi-instance-context.test.ts` — 15/15 pass
  • `bun run typecheck` — clean

Adds InstanceStore.provide(input, effect) — loads the cached instance
context and provides InstanceRef to the wrapped effect. Replaces the
inline makeInstanceContext + provideService(InstanceRef) dance in the
HttpApi middleware, and gives non-middleware callers (CLI bridges,
background jobs) a single primitive for entering an instance scope
from Effect-native code.
@kitlangton kitlangton force-pushed the kit/instance-store-provide branch from 3a18a72 to b964366 Compare May 2, 2026 02:36
@kitlangton kitlangton merged commit 160928a into dev May 2, 2026
9 checks passed
@kitlangton kitlangton deleted the kit/instance-store-provide branch May 2, 2026 02:42
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