feat: Slack integration — OAuth install, alert delivery, and MCP-backed Slack agent#246
Open
JeremyFunk wants to merge 41 commits into
Open
feat: Slack integration — OAuth install, alert delivery, and MCP-backed Slack agent#246JeremyFunk wants to merge 41 commits into
JeremyFunk wants to merge 41 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 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
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 | 15352.06 | 12111.72 | -21.1% worse |
| Rows/sec | 153520.61 | 121117.22 | -21.1% worse |
| p50 latency | 3.91 ms | 4.83 ms | +23.4% worse |
| p95 latency | 7.57 ms | 9.50 ms | +25.5% worse |
| p99 latency | 9.89 ms | 11.56 ms | +16.8% worse |
| Export catch-up | 0.026 s | 0.027 s | +2.2% worse |
| Max RSS | 15.83 MiB | 15.12 MiB | -4.5% 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.1657743,
"export_catchup_seconds": 0.02555001,
"request_rps": 12064.596261302264,
"row_rps": 120645.96261302264,
"p50_ms": 4.83,
"p95_ms": 9.788,
"p99_ms": 14.654,
"max_rss_mb": 15.1171875,
"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": 10,
"duration_seconds": 0.161472913,
"export_catchup_seconds": 0.02654584,
"request_rps": 12385.978321949267,
"row_rps": 123859.78321949267,
"p50_ms": 4.777,
"p95_ms": 9.322,
"p99_ms": 11.556,
"max_rss_mb": 14.19921875,
"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": 12,
"duration_seconds": 0.165129279,
"export_catchup_seconds": 0.026508339,
"request_rps": 12111.722476545181,
"row_rps": 121117.22476545181,
"p50_ms": 4.993,
"p95_ms": 9.504,
"p99_ms": 11.542,
"max_rss_mb": 16.71875,
"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": 9,
"duration_seconds": 0.130275667,
"export_catchup_seconds": 0.025934987,
"request_rps": 15352.061102861211,
"row_rps": 153520.6110286121,
"p50_ms": 3.859,
"p95_ms": 7.573,
"p99_ms": 9.89,
"max_rss_mb": 15.828125,
"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": 9,
"duration_seconds": 0.135152472,
"export_catchup_seconds": 0.02599498,
"request_rps": 14798.101510122582,
"row_rps": 147981.0151012258,
"p50_ms": 4.113,
"p95_ms": 8.175,
"p99_ms": 11.515,
"max_rss_mb": 18.12109375,
"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": 9,
"duration_seconds": 0.129020732,
"export_catchup_seconds": 0.025870536,
"request_rps": 15501.384692190399,
"row_rps": 155013.84692190398,
"p50_ms": 3.913,
"p95_ms": 7.53,
"p99_ms": 8.266,
"max_rss_mb": 15.02734375,
"max_cpu_percent": 0.0,
"avg_cpu_percent": 0.0
}
]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 15.74s
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: 83050 ns/iter (+/- 7542)
test ingest_accept/traces_10_spans_wal_ack ... bench: 111293 ns/iter (+/- 10364)
cargo test
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_metrics_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::pipeline_e2e_exports_gzip_ndjson_to_fake_tinybird ... ok
test telemetry::tests::traces_emit_exactly_the_jsonpaths_declared_in_datasources_ts ... ok
test telemetry::tests::trace_encoder_matches_tinybird_row_shape ... ok
test telemetry::tests::wal_round_trips_frame ... ok
test telemetry::tests::wal_partial_drain_advances_cursor_without_truncating ... ok
test telemetry::tests::wal_truncates_after_full_drain_allowing_further_appends ... 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 41 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_overage_allows ... ok
test autumn::tests::flat_hardcap_with_remaining_allows ... ok
test autumn::tests::flat_unlimited_allows ... ok
test autumn::tests::nested_balance_object_depleted_blocks ... ok
test autumn::tests::nested_overage_allows ... ok
test autumn::tests::nested_balance_object_with_remaining_allows ... ok
test autumn::tests::null_balance_no_subscription_blocks ... ok
test autumn::tests::unrecognized_shape_returns_none ... ok
test tests::clickhouse_destination_uses_native_pipeline_even_in_forward_mode ... ok
test tests::api_error_from_pipeline_maps_variants_to_status ... ok
test tests::api_error_kind_maps_status_to_stable_label ... 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_requires_current_schema ... ok
test tests::cloudflare_validation_payload_is_detected ... ok
test tests::decrypt_aes256_gcm_matches_node_crypto_fixture ... ok
test tests::clickhouse_target_resolver_rejects_password_over_http ... ok
test tests::clickhouse_target_resolver_decrypts_current_schema_password ... ok
test tests::enrichment_overwrites_tenant_fields ... ok
test tests::extract_ingest_key_returns_sentinel_literal_unchanged ... ok
test tests::rejection_span_status_is_error_only_for_5xx ... ok
test tests::hash_is_deterministic ... ok
test tests::replay_budget_disabled_when_limit_is_zero ... ok
test tests::replay_budget_scopes_totals_per_session_and_org ... ok
test tests::replay_budget_truncates_session_at_its_ceiling ... ok
test tests::resolve_ingest_key_keeps_stale_schema_on_managed_native_path ... ok
test tests::resolve_ingest_key_returns_none_when_hash_missing ... ok
test tests::resolve_ingest_key_returns_self_managed_false_when_no_settings_row ... 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_ingest_key_refreshes_routing_before_auth_cache_expires ... ok
test tests::resolve_connector_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. 41 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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
# Conflicts: # apps/web/src/routes/integrations.tsx
Electric Cloud ignores electric_publication_default: with --manual-table-publishing each Cloud source creates its own publication (cloud_electric_pub_svc_<name>) and refuses to add tables to it, so every shape request 400'd with "missing from the publication". After the source activates, mirror the migration-owned table list into the cloud publication(s) via an idempotent server-side DO block. Co-Authored-By: Claude Fable 5 <[email protected]>
Replace the placeholder light-blue palette in agent/lib/chart.ts with the Maple dark-theme tokens (tokens.css .dark, oklch converted to hex for resvg): card surface + hairline border canvas, border/50 grid, muted axis ink, gradient area fills, and per-unit semantic series colors (latency amber, throughput purple, error-rate red, bytes teal, counts blue). Type is now Geist Mono: the Dockerfile decompresses the @fontsource woff2 faces to TTF (resvg reads TTF only) into the system font dir. Co-Authored-By: Claude Fable 5 <[email protected]>
resvg-js 2.x's loadSystemFonts discovers fonts on Linux via fontconfig's /etc/fonts/fonts.conf; the slim production image has no fontconfig package, so font discovery silently found nothing and every glyph (title, axis labels, latest-value label) was dropped from the PNG — charts shipped as bare lines on a card. Point resvg directly at the font dirs the Dockerfile populates (fontDirs needs no fontconfig), keep loadSystemFonts for local dev, and set the Geist Mono default. Verified in a node:24-slim container against resvg-js 2.6.2. Co-Authored-By: Claude Fable 5 <[email protected]>
…publication The Electric role owns the cloud publication but not the synced tables (owned by the ephemeral migrate-step pscale role), so ALTER PUBLICATION ADD TABLE failed with "must be owner of table api_keys". Assume each table-owner role via GRANT <owner> TO CURRENT_USER first — the same trick reset-preview-branch.ts uses, backed by the inherited postgres grant's admin over the ephemeral roles. Co-Authored-By: Claude Fable 5 <[email protected]>
…ion mirror GRANT <table-owner> TO the Electric role is a dead end — replication roles can't receive role grants on PlanetScale, so run 30050755374 still failed with "must be owner of table actors" (and the DO block's RAISE NOTICE diagnostics never reach the client). Instead the main CI role now reassigns the synced tables' ownership to postgres (allowed: it owns them and is a member of postgres), which the Electric role also inherits — making it a table owner for the ALTER PUBLICATION mirror. All statements run client-side with per-statement error logging. Co-Authored-By: Claude Fable 5 <[email protected]>
…eset works
The reuse path never actually ran: reset-preview-branch.ts tried to GRANT the
prior run's pscale_api_* roles to CURRENT_USER, but PlanetScale refuses to
grant those roles at all ("permission denied to grant role", run 30051727304),
so DROP PUBLICATION electric_publication_default failed with "must be owner"
and every deploy fell back to the ~9-minute delete → recreate path.
Every pscale role inherits `postgres`, so hand ownership over at the END of
each deploy instead:
- new packages/db/scripts/normalize-preview-ownership.ts (db:normalize-preview,
run after migrate + grant in the workflow) — REASSIGN OWNED BY CURRENT_USER
TO postgres as the main role, covering the drizzle schema, all of public,
and electric_publication_default
- electric-pr-branch.ts reassigns the Cloud source's cloud_electric_pub_svc_*
publication to postgres after activation (its owner is the replication role)
The next run's role then owns everything via its own postgres membership and
the reset's drops just work. Both steps are non-fatal: an un-normalized branch
only costs the next deploy the recreate fallback, never correctness.
Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
From the PR #255 code + security reviews: - reset-preview-branch.ts: refuse to run outside CI without RESET_PREVIEW_CONFIRM=1 — the script empties whatever DATABASE_URL points at and the connected role inherits postgres, so a stray prod/stg URL in a developer shell must not be enough to gut a real database - reset-preview-branch.ts: drop migration-created extra schemas (owned by postgres post-normalization; vendor/system schemas untouched) so a replayed CREATE SCHEMA migration can't wedge every subsequent deploy with no recreate fallback - reset-preview-branch.ts: run the inactive-replication-slot sweep over the replication-role connection (REPLICATION_DATABASE_URL) — the main role deliberately lacks the REPLICATION attribute, so the old sweep could never actually drop a slot; warn loudly on failure (a stale slot pins WAL) - planetscale-pr-branch.ts: mint the Electric replication credential before the reset and pass it through; mask the full exported connection URLs, not just the raw passwords (encodeURIComponent can defeat raw-password masking) - planetscale-pr-branch.ts: drop the dead ALTER SYSTEM fallback (equally permission-denied on PlanetScale) and downgrade the params-convergence timeout from a deploy-failing error to a warning — Electric activates without the params (run 30055008127) - electric-pr-branch.ts: append sslmode=require when the URL never carried an sslmode param (previously only replaced an existing one); fail fast when `services create` returns no service id instead of dying later with a misleading get-secret error - all three sweeps: hard-fail when GITHUB_REPOSITORY/GITHUB_TOKEN are absent — a token-less sweep resolves every PR to "unknown", skips everything, and green-no-ops forever, which is the exact failure class the safety net exists to catch - comment fixes: nonexistent mintReplicationCredential reference, stale MAPLE_PG_URL mention in the Electric workflow step, single-repo naming caveat on the sweep workflow Co-Authored-By: Claude Fable 5 <[email protected]>
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.