feat: Slack integration — OAuth install, alert delivery, and MCP-backed Slack agent#246
Open
JeremyFunk wants to merge 10 commits into
Open
feat: Slack integration — OAuth install, alert delivery, and MCP-backed Slack agent#246JeremyFunk wants to merge 10 commits into
JeremyFunk wants to merge 10 commits into
Conversation
Adds apps/slack-agent, a standalone eve-framework Slack agent that
deploys itself to Railway (Docker) rather than Cloudflare Workers:
- Workers AI (REST) as the model backend, self-managed Slack app
(bot token + signing secret) instead of a Connect integration
- @workflow/world-postgres for durable runs; EVE_WORKFLOW_WORLD is
baked in at build time via the Dockerfile
- excluded from the bun workspace ("!apps/slack-agent") so its own
bun.lock and eve toolchain resolve independently
Also adds scripts/ingest-dummy.ts for pushing dummy OTLP traces/logs
at the local ingest gateway, drops turbo concurrency to 15, and
gitignores the .eve model-catalog cache.
The agent was posting raw tool-call JSON into Slack:
{"type": "function", "name": "ask_question", "parameters": {…}}
Not a formatting bug — a leaked tool call. @cf/meta/llama-3.3-70b-instruct-fp8-fast
only parses tool calls on non-streaming requests; eve's harness always streams, and
in streaming mode Workers AI returns that model's raw tool-call JSON as ordinary
`response` text deltas, which eve has no reason to treat as anything but assistant
text. (Even non-streaming it stringifies non-string args: "allowFreeform": "true".)
workers-ai-provider has a salvage path for leaked tool calls, but it's gated on a
forced tool choice — eve uses auto, so it never engages.
Switch to @cf/zai-org/glm-5.2, which streams OpenAI-shaped incremental
delta.tool_calls (name + id first, argument fragments keyed by index after) ending
in finish_reason: "tool_calls", and emits chain-of-thought on reasoning_content so
it maps to reasoning parts instead of message text. Bump the declared context
window to its 256K.
Verified through a live eve session: modelId workersai/@cf/zai-org/glm-5.2,
actions.requested → action.result, correct Tokyo time in prose.
Also documents the streaming-tool-call constraint, a curl to check any replacement
model's SSE shape, and the price trade-off vs gpt-oss-120b (also verified good, and
~5x cheaper on output if spend beats capability).
Includes the pending PORT 3000 -> 8080 alignment with the documented Railway setup.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
Your Pullfrog Router balance is exhausted. You have a card on file but auto-reload is disabled, so runs paused once your balance went past the overdraft buffer. Top up balance → · Enable auto-reload →
|
Ingest Rust Test + Benchmark ResultsCommit: Load Benchmark —
|
| Metric | main (median) | PR (median) | Delta |
|---|---|---|---|
| Requests/sec | 8939.63 | 11264.18 | +26.0% better |
| Rows/sec | 89396.31 | 112641.78 | +26.0% better |
| p50 latency | 6.99 ms | 5.52 ms | -21.1% better |
| p95 latency | 13.15 ms | 10.80 ms | -17.9% better |
| p99 latency | 15.72 ms | 11.83 ms | -24.7% better |
| Export catch-up | 0.026 s | 0.026 s | +1.0% worse |
| Max RSS | 15.52 MiB | 14.78 MiB | -4.7% better |
| Failures | 0 | 0 | same |
Same code path on both sides (same LOAD_TEST_INGEST_MODE), so the delta column is meaningful. Numbers come from ubuntu-latest, which is noisy — treat single-digit-percent deltas as noise.
PR load benchmark JSON (per-iteration)
[
{
"ingest_mode": "tinybird",
"requests": 2000,
"successes": 2000,
"failures": 0,
"rows_sent": 20000,
"rows_exported": 20000,
"imports": 10,
"duration_seconds": 0.173250705,
"export_catchup_seconds": 0.02609651,
"request_rps": 11543.964568571308,
"row_rps": 115439.64568571308,
"p50_ms": 5.254,
"p95_ms": 10.812,
"p99_ms": 15.784,
"max_rss_mb": 18.03515625,
"max_cpu_percent": 20.0,
"avg_cpu_percent": 20.0
},
{
"ingest_mode": "tinybird",
"requests": 2000,
"successes": 2000,
"failures": 0,
"rows_sent": 20000,
"rows_exported": 20000,
"imports": 11,
"duration_seconds": 0.178654354,
"export_catchup_seconds": 0.02611235,
"request_rps": 11194.801331290253,
"row_rps": 111948.01331290253,
"p50_ms": 5.532,
"p95_ms": 10.798,
"p99_ms": 11.832,
"max_rss_mb": 14.78125,
"max_cpu_percent": 0.0,
"avg_cpu_percent": 0.0
},
{
"ingest_mode": "tinybird",
"requests": 2000,
"successes": 2000,
"failures": 0,
"rows_sent": 20000,
"rows_exported": 20000,
"imports": 11,
"duration_seconds": 0.177554009,
"export_catchup_seconds": 0.026136705,
"request_rps": 11264.178214077947,
"row_rps": 112641.78214077948,
"p50_ms": 5.52,
"p95_ms": 10.552,
"p99_ms": 11.769,
"max_rss_mb": 14.6328125,
"max_cpu_percent": 0.0,
"avg_cpu_percent": 0.0
}
]main load benchmark JSON (per-iteration)
[
{
"ingest_mode": "tinybird",
"requests": 2000,
"successes": 2000,
"failures": 0,
"rows_sent": 20000,
"rows_exported": 20000,
"imports": 12,
"duration_seconds": 0.208447296,
"export_catchup_seconds": 0.026127761,
"request_rps": 9594.751471374328,
"row_rps": 95947.51471374328,
"p50_ms": 6.46,
"p95_ms": 12.266,
"p99_ms": 15.723,
"max_rss_mb": 15.515625,
"max_cpu_percent": 16.6,
"avg_cpu_percent": 16.6
},
{
"ingest_mode": "tinybird",
"requests": 2000,
"successes": 2000,
"failures": 0,
"rows_sent": 20000,
"rows_exported": 20000,
"imports": 13,
"duration_seconds": 0.223722871,
"export_catchup_seconds": 0.025458494,
"request_rps": 8939.63138887128,
"row_rps": 89396.3138887128,
"p50_ms": 6.992,
"p95_ms": 13.154,
"p99_ms": 14.947,
"max_rss_mb": 18.6796875,
"max_cpu_percent": 0.0,
"avg_cpu_percent": 0.0
},
{
"ingest_mode": "tinybird",
"requests": 2000,
"successes": 2000,
"failures": 0,
"rows_sent": 20000,
"rows_exported": 20000,
"imports": 11,
"duration_seconds": 0.247873411,
"export_catchup_seconds": 0.025861601,
"request_rps": 8068.634679013636,
"row_rps": 80686.34679013636,
"p50_ms": 7.583,
"p95_ms": 15.027,
"p99_ms": 21.262,
"max_rss_mb": 14.6015625,
"max_cpu_percent": 16.6,
"avg_cpu_percent": 16.6
}
]WAL-acked microbench (cargo bench --bench ingest_bench)
Compiling maple-ingest v0.1.0 (/home/runner/_work/maple/maple/apps/ingest)
Finished `bench` profile [optimized] target(s) in 14.32s
Running benches/ingest_bench.rs (target/release/deps/ingest_bench-581d2100de893627)
Gnuplot not found, using plotters backend
test ingest_accept/logs_10_rows_wal_ack ... bench: 99037 ns/iter (+/- 6982)
test ingest_accept/traces_10_spans_wal_ack ... bench: 121804 ns/iter (+/- 10192)
cargo test
test telemetry::tests::metrics_emit_exactly_the_jsonpaths_declared_in_datasources_ts ... ok
test telemetry::tests::migrate_legacy_shard_relocates_frames_into_lanes ... ok
test telemetry::tests::clickhouse_breaker_trips_sheds_and_recovers ... ok
test telemetry::tests::pipeline_can_start_for_clickhouse_only_without_tinybird_credentials ... ok
test telemetry::tests::clickhouse_export_drops_passworded_non_https_endpoint_without_sending ... ok
test telemetry::tests::sampling_keeps_errors_even_when_ratio_low ... ok
test telemetry::tests::scraper_contract::scraper_otlp_json_decodes_with_gateway_serde_and_encodes_to_rows ... ok
test telemetry::tests::signal_tag_round_trips_all_variants ... ok
test telemetry::tests::pipeline_e2e_exports_gzip_ndjson_to_fake_tinybird ... ok
test telemetry::tests::telemetry_signal_as_str_is_canonical_lowercase ... ok
test telemetry::tests::timestamp_has_nano_precision ... ok
test telemetry::tests::timestamps_match_clickhouse_datetime64_nine_format ... ok
test telemetry::tests::trace_encoder_matches_tinybird_row_shape ... ok
test telemetry::tests::traces_emit_exactly_the_jsonpaths_declared_in_datasources_ts ... ok
test telemetry::tests::wal_partial_drain_advances_cursor_without_truncating ... ok
test telemetry::tests::wal_round_trips_frame ... ok
test telemetry::tests::wal_truncates_after_full_drain_allowing_further_appends ... ok
test telemetry::tests::pipeline_e2e_exports_metrics_to_fake_tinybird ... ok
test telemetry::tests::pipeline_e2e_exports_traces_to_fake_tinybird ... ok
test telemetry::tests::pipeline_exports_ready_org_to_clickhouse_without_tinybird_calls ... ok
test telemetry::tests::slow_clickhouse_lane_does_not_block_cosharded_tinybird_org ... ok
test telemetry::tests::clickhouse_breaker_sheds_after_threshold_failures ... ok
test result: ok. 36 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.73s
Running unittests src/bin/load_test.rs (target/debug/deps/load_test-661a0aa1eb3f6d6d)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running unittests src/main.rs (target/debug/deps/maple_ingest-c33bf80c577edb95)
running 38 tests
test autumn::tests::allowed_only_no_balance_field ... ok
test autumn::tests::flat_sub_one_gb_remaining_still_allows ... ok
test autumn::tests::flat_hardcap_depleted_blocks ... ok
test autumn::tests::flat_hardcap_with_remaining_allows ... ok
test autumn::tests::flat_overage_allows ... ok
test autumn::tests::flat_unlimited_allows ... ok
test autumn::tests::nested_balance_object_with_remaining_allows ... ok
test autumn::tests::nested_overage_allows ... ok
test autumn::tests::nested_balance_object_depleted_blocks ... ok
test autumn::tests::null_balance_no_subscription_blocks ... ok
test tests::api_error_kind_maps_status_to_stable_label ... ok
test tests::api_error_from_pipeline_maps_variants_to_status ... ok
test autumn::tests::unrecognized_shape_returns_none ... ok
test tests::clickhouse_destination_is_terminal_in_dual_mode ... ok
test tests::cloudflare_log_record_maps_body_severity_and_attributes ... ok
test tests::cloudflare_ndjson_payload_parses_multiple_records ... ok
test tests::cloudflare_timestamps_support_rfc3339_unix_and_unix_nano ... ok
test tests::clickhouse_target_resolver_decrypts_current_schema_password ... ok
test tests::cloudflare_validation_payload_is_detected ... ok
test tests::decrypt_aes256_gcm_matches_node_crypto_fixture ... ok
test tests::enrichment_overwrites_tenant_fields ... ok
test tests::clickhouse_destination_uses_native_pipeline_even_in_forward_mode ... ok
test tests::extract_ingest_key_returns_sentinel_literal_unchanged ... ok
test tests::clickhouse_target_resolver_rejects_password_over_http ... ok
test tests::rejection_span_status_is_error_only_for_5xx ... ok
test tests::clickhouse_target_resolver_requires_current_schema ... ok
test tests::hash_is_deterministic ... ok
test tests::resolve_ingest_key_keeps_stale_schema_on_managed_native_path ... ok
test tests::resolve_ingest_key_returns_self_managed_false_when_no_settings_row ... ok
test tests::resolve_ingest_key_returns_none_when_hash_missing ... ok
test tests::resolve_ingest_key_returns_self_managed_true_when_active_settings_row ... ok
test tests::sentinel_token_matches_only_exact_literal ... ok
test tests::tinybird_destination_keeps_forward_mode_on_forward_path ... ok
test tests::resolve_connector_refreshes_routing_before_auth_cache_expires ... ok
test tests::resolve_ingest_key_refreshes_routing_before_auth_cache_expires ... ok
test autumn::tests::fails_open_on_transport_error ... ok
test tests::resolve_ingest_key_serves_last_known_routing_when_refresh_fails ... ok
test tests::forward_mode_switches_ready_org_to_clickhouse_without_forwarding_again ... ok
test result: ok. 38 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.19s
Doc-tests maple_ingest
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
An empty Schema.Struct({}) compiles to `{ anyOf: [{type:object},{type:array}] }`
in effect 4.0.0-beta.93, with no top-level `type: "object"`. Strict MCP clients
(the Vercel AI SDK used by the eve Slack agent) validate each tool's
inputSchema.type against z.literal("object"), so list_source_repositories (tool
#40) fails to parse and aborts the ENTIRE tools/list response — dropping every
Maple tool from the connection.
Normalize a no-property struct to an explicit empty object schema centrally in
toInputSchema so all current and future no-param tools stay MCP-compliant. Add a
test asserting every registered tool emits inputSchema.type === "object".
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
All deployed stages share the maple.dev registrable domain, but PR previews/staging run the dev Clerk instance while prod runs the production one. Both write __client_uat cookies on Domain=maple.dev, so browsing multiple environments makes the instances overwrite each other's session hints and ClerkJS handshakes against the wrong frontend API — surfacing as transient 403s on app-pr-N/api-pr-N and prod. Purge foreign-instance parent-domain __client_uat* cookies (suffix derived from the publishable key, mirroring @clerk/shared) before ClerkJS initializes. Mitigation until preview/staging move to their own registrable domain, per Clerk's same-domain limitation. Also document the channels:history Slack bot scope in the slack-agent README. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Resolve drizzle migration-numbering collision: both branches added a 0017. Renumber this branch's slack_workspaces migration to 0019 (regenerated via drizzle-kit onto main's 0017/0018 chain). Add slack entry to main's new useIntegrationOverviews() hook. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The shape proxy only treated a missing ELECTRIC_URL as "not configured". A deploy with ELECTRIC_URL + ELECTRIC_SOURCE_ID but no ELECTRIC_SECRET (e.g. a PR preview inheriting shared Infisical Electric config while its per-PR source step is skipped) forwarded an unauthenticated request to Electric Cloud, which returns 401 MISSING_SECRET — surfacing as a hard- broken shape stream in the browser instead of graceful degradation. Treat incoherent Cloud credentials (exactly one of source_id/secret) as not-configured and take the existing 503 path, and log the misconfig for telemetry. Adds isElectricConfigCoherent + unit tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
# Conflicts: # apps/web/src/routes/integrations.tsx
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
Full Slack ↔ Maple integration across three areas, built on the eve-based Slack agent introduced earlier on this branch:
Backend (packages/db, packages/domain, apps/api)
slack_workspacestable:team_id → orgIdbinding with AES-256-GCM-encrypted bot token and an auto-minted org-scopedmcp-kind API key (secret stored encrypted so it can be handed to the bot). Partial unique index enforces one active workspace per org; installs transactionally revoke/replace prior same-org workspaces, and a guarded upsert closes the concurrent cross-org install race.POST /v2/integrations/slack/install(admin) → single-use, TTL-bound state →GET /oauth/slack/callbackexchanges the code, mints the key, and redirects back to/integrations?integration=slack.GET/DELETE /v2/integrations/slack(status/uninstall — uninstall revokes both the row and the minted API key) andGET /v2/integrations/slack/channels(conversations.list proxy for the channel picker).GET /internal/slack/workspaces/:teamIdguarded by the constant-timemaple_svc_bearer; returns{orgId, teamId, teamName, botToken, mapleApiKey}.slack-botalert destination type: posts Block Kit viachat.postMessageusing the installed workspace token + configured channel; works with the existingPOST /v2/alerts/destinations/:id/test.Slack agent (apps/slack-agent)
webhookVerifierowns Slack v0 signature verification and extractsteam_id; per-team bot token resolved through a cached credentials client against the internal endpoint (SLACK_BOT_TOKENremains a single-workspace dev fallback)./mcpwith a per-session auth resolver that selects the installing org's API key from the session'steam_id— the bot gets the same tool set as the in-dashboard chat agent (listServices, searchTraces, findErrors, diagnoseService, …).MAPLE_API_BASE_URLbaking footgun.Web (apps/web)
slack-botdestination in notification settings with searchable channel picker (public/private, invite-the-bot hint), only offered when the integration is installed.Security review
An adversarial review of the OAuth flow, internal endpoint, crypto, and tenant isolation found no critical issues; its one real finding (ambiguous multi-workspace rows per org) is fixed as described above. Known accepted limitations, documented in the bot README: bot-side positive credential cache means uninstall takes up to ~5 min to fully propagate (MCP access dies immediately since the key is revoked), and concurrent events from different workspaces can make an outbound reply resolve the wrong team's token — which fails closed (Slack rejects the post).
Deployment notes
SLACK_CLIENT_ID/SLACK_CLIENT_SECRET(wired in alchemy.run.ts).MAPLE_API_BASE_URL(required at build time),MAPLE_INTERNAL_SERVICE_TOKEN.https://<api-host>/oauth/slack/callback, broaden bot scopes (see apps/slack-agent/README.md), enable public distribution.0017_fair_mandarin(slack_workspaces).Testing
eve build+ typecheck green; signature-verification/team-parsing/token-bridging verified by a 14-check standalone harness.🤖 Generated with Claude Code
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.