Skip to content

Centralize Effect runner boundaries and make MCP bridge Effect-native#108

Open
danielbdyer wants to merge 2 commits into
mainfrom
codex/refactor-effect.runpromise-and-runsync-usage
Open

Centralize Effect runner boundaries and make MCP bridge Effect-native#108
danielbdyer wants to merge 2 commits into
mainfrom
codex/refactor-effect.runpromise-and-runsync-usage

Conversation

@danielbdyer
Copy link
Copy Markdown
Owner

Motivation

  • Reduce ad-hoc Effect.runPromise / Effect.runSync usage scattered outside lib/composition/ by providing explicit boundary modules for controlled escapes.
  • Keep timeout/race semantics Effect-native while preserving existing Promise-facing provider contracts.
  • Replace Promise/async glue in MCP tool adapters with composable Effect.Effect chains so tool invocations compose with pipe/Effect.map/Effect.catchAll.

Description

  • Added dedicated boundary adapters: lib/application/effect-boundary.ts exposing runEffectPromiseBoundary and lib/infrastructure/mcp/effect-boundary.ts exposing runEffectSyncBoundary to centralize Effect.runPromise/Effect.runSync usage.
  • Refactored agent timeout logic in lib/application/agent-interpreter-provider.ts by introducing withAgentTimeoutEffect (Effect-native) and keeping the public Promise-facing withAgentTimeout which now escapes via runEffectPromiseBoundary.
  • Converted MCP internal bridge in lib/runtime/agent/mcp-bridge.ts to Effect-native contracts by changing McpToolInvoker, AgentTool.invoke, and AgentToolProvider.invoke to return Effect.Effect and composing invocation flows with Effect.map/Effect.catchAll.
  • Replaced inline Effect.runSync usage in lib/infrastructure/mcp/dashboard-mcp-server.ts with runEffectSyncBoundary so synchronous MCP handlers delegate to the explicit boundary.
  • Updated tests (tests/mcp-internal-bridge.laws.spec.ts) to run bridge/tool Effects via Effect.runPromise in test scope and adjusted invoker-failure assertions to validate typed error results instead of rejected promises.
  • Tightened the guard script scripts/check-effect-runners.cjs to allow runPromise/runSync only in lib/composition/** and the new dedicated boundary files.

Testing

  • Ran the effect boundary guard script with node scripts/check-effect-runners.cjs and it succeeded.
  • Ran MCP bridge law tests with Playwright: npx playwright test tests/mcp-internal-bridge.laws.spec.ts --reporter=line and all tests passed (45 passed).
  • Ran lint: npm run lint surfaced pre-existing unrelated lint issues (two domain files) and therefore reported failures unrelated to these changes.
  • Ran typecheck: npm run typecheck reported pre-existing unrelated diagnostics in generated/module wiring and lib/playwright/state-topology.ts, while the changes in the refactor path compile for the updated modules.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant