Skip to content

effectify Bus service: migrate to Effect PubSub + InstanceState#18579

Merged
kitlangton merged 19 commits intodevfrom
kit/effectify-bus
Mar 26, 2026
Merged

effectify Bus service: migrate to Effect PubSub + InstanceState#18579
kitlangton merged 19 commits intodevfrom
kit/effectify-bus

Conversation

@kitlangton
Copy link
Contributor

Summary

  • Replace manual subscription Map with PubSub.unbounded per instance via InstanceState
  • Per-type PubSubs + wildcard PubSub, cleaned up via addFinalizer (shutdown on instance disposal)
  • Add makeRuntime to run-service.ts — single runtime object with runPromise + runFork
  • Legacy facade preserved: publish/subscribe/subscribeAll same signatures, no caller changes
  • Extract Format.file() for explicit formatting — tools call it directly instead of publishing File.Event.Edited
  • Drop Bus.once (zero callers)

Test plan

  • bun run turbo typecheck passes
  • Format tests pass (test/format/)
  • SSE event streaming works (event route uses Bus.subscribeAll)
  • File formatting works after edit/write/apply_patch
  • Instance disposal cleans up subscriptions (PubSub.shutdown ends streams)

opencode-agent bot added a commit that referenced this pull request Mar 22, 2026
opencode-agent bot added a commit that referenced this pull request Mar 22, 2026
opencode-agent bot added a commit that referenced this pull request Mar 22, 2026
opencode-agent bot added a commit that referenced this pull request Mar 22, 2026
opencode-agent bot added a commit that referenced this pull request Mar 22, 2026
opencode-agent bot added a commit that referenced this pull request Mar 22, 2026
opencode-agent bot added a commit that referenced this pull request Mar 22, 2026
opencode-agent bot added a commit that referenced this pull request Mar 22, 2026
opencode-agent bot added a commit that referenced this pull request Mar 22, 2026
opencode-agent bot added a commit that referenced this pull request Mar 22, 2026
opencode-agent bot added a commit that referenced this pull request Mar 22, 2026
opencode-agent bot added a commit that referenced this pull request Mar 22, 2026
opencode-agent bot added a commit that referenced this pull request Mar 22, 2026
opencode-agent bot added a commit that referenced this pull request Mar 22, 2026
opencode-agent bot added a commit that referenced this pull request Mar 22, 2026
opencode-agent bot added a commit that referenced this pull request Mar 22, 2026
opencode-agent bot added a commit that referenced this pull request Mar 22, 2026
opencode-agent bot added a commit that referenced this pull request Mar 22, 2026
opencode-agent bot added a commit that referenced this pull request Mar 22, 2026
opencode-agent bot added a commit that referenced this pull request Mar 23, 2026
opencode-agent bot added a commit that referenced this pull request Mar 23, 2026
opencode-agent bot added a commit that referenced this pull request Mar 23, 2026
opencode-agent bot added a commit that referenced this pull request Mar 23, 2026
opencode-agent bot added a commit that referenced this pull request Mar 23, 2026
opencode-agent bot added a commit that referenced this pull request Mar 23, 2026
opencode-agent bot added a commit that referenced this pull request Mar 24, 2026
opencode-agent bot added a commit that referenced this pull request Mar 24, 2026
opencode-agent bot added a commit that referenced this pull request Mar 24, 2026
opencode-agent bot added a commit that referenced this pull request Mar 24, 2026
opencode-agent bot added a commit that referenced this pull request Mar 24, 2026
opencode-agent bot added a commit that referenced this pull request Mar 24, 2026
opencode-agent bot added a commit that referenced this pull request Mar 24, 2026
opencode-agent bot added a commit that referenced this pull request Mar 24, 2026
opencode-agent bot added a commit that referenced this pull request Mar 24, 2026
opencode-agent bot added a commit that referenced this pull request Mar 25, 2026
@opencode-agent
Copy link
Contributor

⚠️ Blocking Beta Release

This PR cannot be merged into the beta branch due to: Merge conflicts with dev branch

Please resolve this issue to include this PR in the next beta release.

- Replace manual subscription Map with PubSub.unbounded per instance
- Per-type PubSubs + wildcard PubSub, cleaned up via addFinalizer
- InstanceDisposed published before PubSub shutdown so subscribers see it
- Add makeRuntime to run-service.ts (single runtime with runPromise + runFork)
- Legacy facade preserved: publish/subscribe/subscribeAll same signatures
- subscribe/subscribeAll fork stream consumer fibers, return interrupt function
- Extract Format.file() for explicit formatting, remove event-driven subscription
- Inline Format.file() calls in write/edit/apply_patch tools
- Drop Bus.once (zero callers)
- Keep makeRunPromise as deprecated wrapper for existing services
- Replace manual subscription Map with PubSub.unbounded per instance
- Per-type PubSubs + wildcard PubSub, cleaned up via addFinalizer
- InstanceDisposed published before PubSub shutdown so subscribers see it
- Replace makeRunPromise with makeRuntime (single runtime with runPromise + runFork)
- Update all 19 services to use makeRuntime destructuring
- Legacy facade preserved: publish/subscribe/subscribeAll same signatures
- subscribe/subscribeAll fork stream consumer fibers, return interrupt function
- Extract Format.file() for explicit formatting, remove event-driven subscription
- Inline Format.file() calls in write/edit/apply_patch tools
- Drop Bus.once (zero callers)
- Add runCallback to makeRuntime (returns interrupt function directly)
- Simplify forkStream to use runCallback instead of runFork + Fiber.interrupt
- Add 6 bus tests covering publish/subscribe, unsubscribe, subscribeAll,
  and InstanceDisposed delivery on instance disposal
- Plugin: use bus.subscribeAll() Stream + forkScoped instead of callback facade
- Vcs: use bus.subscribe() Stream + forkScoped instead of acquireRelease callback
- Status: use bus.publish() Effect directly instead of Effect.promise wrapper
- Rewrite Vcs test to use facade functions (shared memoMap ensures singleton Bus)
- Add Bus integration tests for subscribe cleanup and instance disposal
- tmpdirScoped uses FileSystem.makeTempDirectoryScoped (auto cleanup on scope close)
- Git init uses ChildProcessSpawner.spawn + ChildProcess.make (proper Effect pattern)
- Effect-native bus tests use withServices + Bus.layer + Effect.scoped + forkScoped
…ewrite format tests

- Add provideInstance, provideTmpdirInstance to test/fixture/fixture.ts
- Delete test/fixture/instance.ts (withServices no longer needed)
- Rewrite format tests to use provideTmpdirInstance + testEffect (fully Effect-native)
- Effect-native bus tests use provideTmpdirInstance
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