Skip to content

Effect v4 review fixes: apps/api MCP domain - #292

Open
JeremyFunk wants to merge 1 commit into
mainfrom
effect-v4/api-mcp
Open

Effect v4 review fixes: apps/api MCP domain#292
JeremyFunk wants to merge 1 commit into
mainfrom
effect-v4/api-mcp

Conversation

@JeremyFunk

@JeremyFunk JeremyFunk commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Domain 1 of the repo-wide Effect v4 review (/effect-review-v4, one Opus reviewer per domain). Scope: apps/api/src/mcp — 110 files.

Review verdict: FAIL (4 criticals, 16 warnings) → all criticals and warnings addressed; score was 7.5/10.

Criticals fixed

  • update-dashboard / query-data: Schema.decodeUnknownSync on agent-supplied ids/filters threw defects through catchDefect; now effectful decodes returning typed tool errors with discovery-tool guidance.
  • resolve-tenant: raw try/catch JSON.parse in the auth module → Schema.fromJsonString decoding; resolveMcpTenantContext moved to Effect.fnUntraced (per-request auth hot path).
  • inspect-widget: Effect.catchCause(() => succeed(SKIPPED_SUMMARY)) silently swallowed every failure/defect — now logs the cause first; the blanket warehouse-error catch now maps per-tag via toMcpQueryError.

Warnings fixed

  • resolveTimeRange / resolveDashboardTimeRange now read the Effect Clock instead of DateTime.nowUnsafe() (all ~20 tool call sites updated); time.test.ts asserts exact values under TestClock.
  • orgId + tool name annotated on every tool span centrally in the dispatcher (annotateCurrentSpan for the dispatch span, annotateSpans so the handler's own Effect.fn span inherits it) — previously only 22/57 tools annotated.
  • queryWarehouse gains an optional rowSchema (validated rows; unchanged behavior for existing callers).
  • Test migrations to @effect/vitest idioms (it.effect, assert.*) in app/dispatcher/regression tests; service access via yield* instead of static accessors.
  • New coverage: inspect-widget.test.ts (33 tests over reduce aggregates, EMPTY_GROUPING/METRIC_NOT_FOUND, all skip/error outcomes) and resolve-tenant.test.ts (29 tests over internal-token, OAuth audience binding, scoped-key rejection, actor resolution).

Also: dead McpTenantError deleted (never constructed), catchTag+catchTags folded, misc info-level cleanups.

Verification

  • apps/api tsc --noEmit clean
  • bun vitest run src/mcp: 18 files, 175 tests passed

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Fixes from a full effect-review-v4 pass over apps/api/src/mcp (110 files):

- Replace Schema.decodeUnknownSync on agent-supplied input with effectful
  decoding so invalid ids/filters return actionable tool errors instead of
  escaping as defects (update-dashboard, query-data)
- Replace try/catch JSON.parse with Schema.fromJsonString decoding
  (resolve-tenant, create-dashboard); untrace the auth hot path
- Log the cause before the inspect-widget catchCause fallbacks; map
  warehouse errors per-tag instead of collapsing the union
- Annotate orgId + tool on every tool span centrally in the dispatcher
  (annotateCurrentSpan + annotateSpans); drop dead McpTenantError
- Make resolveTimeRange/resolveDashboardTimeRange read the Effect Clock
  instead of DateTime.nowUnsafe, updating all tool call sites; time.test
  now asserts exact values under TestClock
- queryWarehouse gains an optional rowSchema for validated rows
- Migrate MCP tests to @effect/vitest idioms (it.effect, assert.*)
- Add test coverage for inspect-widget helpers (33 tests) and the
  resolve-tenant auth path (29 tests)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@pullfrog

pullfrog Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Your Pullfrog Router balance is exhausted.

You have a payment method on file but auto-reload is disabled, so runs paused once your balance went past the overdraft buffer.

Top up balance → · Enable auto-reload →

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Rerun failed job ➔View workflow run | via Pullfrog | Using Claude Opus𝕏

@github-actions

Copy link
Copy Markdown

🍁 Maple PR preview

The preview is ready:

Service Preview URL
Web app-pr-292.maple.dev
API api-pr-292.maple.dev
Chat chat-pr-292.maple.dev
Electric Sync sync-pr-292.maple.dev

Deployed from 0110a96 · View workflow run

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant