Skip to content

Latest commit

 

History

History

backend

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Helix Foundry backend

The Go module github.com/helixdb/helix-foundry/backend: Foundry's API and the workers behind it. They connect and sync data sources, have the ontology agent draft and revise ontologies, load versions into HelixDB, read documents, answer questions over a load and email people when their work is done. State is in MySQL (store, with its migrations embedded from store/migrations); synced tables and documents are in S3-compatible storage.

Build and test

Go as in go.mod, and Docker for the test databases.

go build ./...
go vet ./...
docker compose -f compose.test.yaml up -d --wait   # MySQL on 3307 and 3309, PostgreSQL on 5433
HELIX_TEST_ROOT_DSN='root:helix@tcp(127.0.0.1:3307)/' go test ./...
docker compose -f compose.test.yaml down -v

docker build . builds the standalone image.

The generated code in pb/gen is committed. After changing a .proto under pb/proto, regenerate it with buf:

buf generate && buf generate --template buf.internal.gen.yaml

Run it

../local runs Foundry on one machine: the site, this backend, the ontology agent, MySQL, SeaweedFS and HelixDB. It runs Foundry's release images; with FOUNDRY_SITE_IMAGE=helix-foundry/site:local and FOUNDRY_IMAGE=helix-foundry/foundry:local in its .env, docker compose build there builds the site and the backend from this checkout instead. The image's foundry init-secrets --dir DIR writes an install's secrets once (the compose file's first service), and local.secrets_dir (HELIX_LOCAL__SECRETS_DIR) reads them; with no foundry.ai.default.provider, foundry finds its AI default on the machine (package ai/detect).

Questions a generation waits on

The ontology agent may end a draft's turn asking what only the user can answer (needs_input). The generation then stores no version and waits, still its ontology's live generation, with the agent's session state (foundry_ontology_generations.turn_state, never sent over the API: it may quote the data) and the questions. Every agent's question has one shape (agentquestion): an answer in words, or a choice of 2 to 20 options (labels, each with an optional description) of which the person picks one, or several when the agent made it multiple, the agent's recommended answer marked (a label, or for an answer in words its suggested words; the engine names it default), and always their own words instead (one) or as well (several); agentquestion.Check checks answers ({question_id, options, text}) against the questions asked. AnswerOntologyGeneration (POST .../generations/{id}:answer, naming the question_round it answers, or the MCP's answer_generation_questions) queues it with the answers, and the next attempt sends the state back with feedback on the draft revision asked of; CancelOntologyGeneration (:cancel) ends it instead. The Assistant asks people only through its helix_foundry_ask_person tool (agent/ask.go: 1 to 4 questions of its own, or a generation's waiting round relayed as its agent wrote it), which ends its turn (asked, finished reason asked); the person's answers are the thread's next turn (SendFoundryAgentMessage with answers, kind answers), and a relayed generation's become its answer_generation_questions card unchanged, the only way the Assistant answers a generation. Questions no one answers in foundry.ontology.answer_days (7) take their recommended answers (or are left to the agent): the foundry-ontology-worker answers them on its next tick and carries on. Each answer pays for another turn, so a turn that asks once a generation has had foundry.ontology.max_question_rounds (3) rounds fails it. A first draft that loads once ready (load_when_ready) emails its requester at its first round (ontology_questions, from the foundry-notify-worker), since they have left the page. A start of a new version names the sources the current version wasn't drafted from, so the agent asks about those first.

Company research

A new ontology's wizard can start from the person's company (package companyresearch, api/company_research.go). ResearchFoundryCompany (POST /v1/workspaces/{id}/foundry/company-research, {domain}) reduces what was typed to its registrable domain (no IP, no name under no public suffix, no personal email provider's: INVALID_ARGUMENT in words the site shows), reads its website through connector.Guard with private addresses refused everywhere, locally too (https://<domain>/, else www., then up to three same-domain pages whose path or text says about, company, product, platform, solutions, pricing or customers; 5 s a page, 6 s in all, 512 KiB and 6,000 characters a page, 16,000 in all; redirects by hand, at most 3, https and the same registrable domain only), and has the workspace's extraction model write the company's name, a summary, an ontology name and up to five questions a website can't answer, each with a best guess (fetched false when nothing could be read: the model had the domain alone). DraftFoundryGoal (POST .../company-research/{research_id}:draft-goal, {answers, data}) writes a goal and a name from a stored research (NOT_FOUND unless the workspace's), the answers (INVALID_ARGUMENT for a question it didn't ask, or past 500 characters) and the site's inventory of the chosen data (at most 12,000 characters). Both answer within 55 s (the site waits 60), for an owner or admin as themselves (grantees, members and service keys are refused), after requireAI. Each model call is a row of foundry_company_research (migration 20261224000000), made before the call holding its worst-case cost, which the hourly cap and the month's budget count under the workspace's lock, and given its spend after (a call cut short keeps the larger); a research row holds the research the goal reads. A model that fails is UNAVAILABLE, reason FOUNDRY_RESEARCH_FAILED.

foundry.onboarding.research Default
per_user_per_hour 20 API: one person's calls an hour, research and goals together (RESOURCE_EXHAUSTED)
monthly_usd 2.0 API: a workspace's month; a call is made only while the month's spend and its worst case fit (FAILED_PRECONDITION, reason FOUNDRY_RESEARCH_BUDGET)

Hosted Helix

Hosted Helix (foundry.helix-db.com) runs this same code as a library inside its own server. It runs the module's migrations in one sequence with its own, and supplies what differs when hosted, such as sign-in and roles, workspaces, Helix databases, plans and the provider accounts connectors sign in with, through the module's interfaces. So REST paths and JSON shapes, tables and migrations, config keys, environment variable names and metric names are shared with the hosted deployment: change them on purpose, never as a side effect.

Where the host supplies ports.ProviderAccounts (hosted: WorkOS Pipes), GitHub and Linear connectors can be connected by signing in at the provider instead of entering a key: the account stays with the host's broker, and the connector asks it for a token each time it reads. The sync worker checks each account weekly and deletes, through the broker, the accounts deleted connectors and failed sign-ins let go. A standalone install has no broker, and every connector takes a key.

Foundry's emails go out through the host's mail (ports.Mail) from the foundry-notify-worker (package workers/foundry-notify-worker), which hosted runs as a task beside the sync worker, with foundry.notify.site_url set to the site's origin. It tells the person who asked for an ontology's first draft to be loaded when ready how that ended, and follows up once, a day later, with someone who watched the sample and brought no data of their own. A standalone install sends no email and doesn't run it.

The same worker sends the reminders a person asks for on the landing page, from a phone, to try Foundry on a computer (package reminder, table foundry_reminders). The site sends each request to the foundry-events door, POST /v1/reminders ({"email", "time_zone", "consent": "remind-v1", "client"}, answered {"next_send_at", "again"}) and POST /v1/reminders/stop ({"email"}, at each sign-in), with its secret as the bearer. The door holds no secret: it passes the bearer's SHA-256 to FoundryEventsService.CreateFoundryReminder and StopFoundryReminders, which compare it with foundry.reminders.secret_sha256 (empty: no new reminders, and the door answers 404). Each address gets one schedule: the first reminder at the next weekday 09:00 in the person's zone, then one each foundry.reminders.gap_days (7, 14 and 28 days) after the one before, stopping when the person signs in or unsubscribes, and never sooner than min_gap_days after the last when it asks again; at most about max_new_per_hour schedules start in an hour, and max_new_per_client_per_hour for one client (the site's key for a visitor's address). The secret is 64 lowercase hex digits (openssl rand -hex 32), and the door refuses any other bearer before it takes room. They go on their own subscription topic, ports.TopicFoundryReminder (foundry-reminder), which the host's SES contact list must hold before a deploy sends one, and whose unsubscribe footer is the host's. The door's ingress must route /v1/reminders as it routes /v1/sources/.

Self-healing audits run in the foundry-heal-worker (package workers/foundry-heal-worker), which hosted runs as a task beside the graph worker, on its ontology agent sidecar. With foundry.heal.enabled it audits each ontology's current load with the agent's Audit as the load becomes current and nightly, never while a graph job is live on the ontology, and stores the findings (foundry_heal_findings, foundry_heal_runs) the Suggestions page lists. A relationship's finding gathers every spelling its reports took (contract 4.8.0), and its fingerprint holds the declared name they're gathered under, so it moves with the ontology's links: each complete audit replaces the findings before it rather than summing with them, and a dismissal holds only for the spellings it was dismissed with. The first complete audit of a load on 4.8.0, as the load becomes current or nightly after the deploy, re-keys its findings so; until then the Suggestions page shows the earlier audit's. Off, the default, it does nothing, so a host may list the task everywhere. A standalone install runs it only with the flag on. Known limits: Foundry stores no source fields, so no audit checks source drift; and a run makes one Audit call per 1,000 reviewed documents, about 17 minutes for 1M at 1 s a page and hours at a 1 request a second plan rate limit, stopping incomplete after 4 hours; and a run stops once a graph job starts on its ontology, so an ontology whose jobs come more often than an audit takes (a connector syncing changes every few minutes) may never complete. Audits that resume across runs would lift both.

Founder

Founder is Foundry's own agent, which a person talks to in the site (package agent, where the Go names still call it the Assistant, tables foundry_agent_*). The foundry-agent-worker (package workers/foundry-agent-worker, role Roles.AgentWorker) claims the turns of api threads (a turn has its thread's runtime, so a later helper claims its own) as questions are claimed, under foundry.agent's caps (a turn's max_usd, max_steps and max_wall_secs, a user's per_hour, a workspace's monthly_usd and max_running; a reply runs at most 8 tool calls and a turn asks at most 3 Analyst questions), and runs each on the workspace's provider and its ask model (package agent/llm), never through the ontology engine but on the wire the engine uses for the kind: Claude on the Messages API (anthropic-sdk-go), OpenAI and Azure OpenAI on the Responses API (openai-go; Azure on its resource's v1 API with the api-key header), an OpenAI-compatible server on Chat Completions or Responses as its owner chose, at most its max_calls_in_flight at once from a process (per setting, so workspaces naming the same server never share slots), Ollama on its native /api/chat with num_ctx set to the setting's window (Ollama's /v1 can't set one and would cut the prompt silently), one call at a time, and Bedrock on Converse with its API key as a bearer token (no SigV4, any model Bedrock serves; cache points for Claude's). Every call dials through the deployment's guard (hosted, public addresses only, at call time) and no client reads ANTHROPIC_*, OPENAI_* or AWS_* from the environment. A model with a window (Ollama's) bounds the transcript a call sends to three quarters of what the window leaves; earlier turns go first, and a turn whose own work passes that bound (or context_tokens) ends with context before the call the window would cut. A model's reasoning goes back only to the same model at the same endpoint, and on a Responses API only while the setting reasons. While the model writes, its text shows as text_delta events every 250 ms, which the step's text events replace (FinishFoundryAgentText drops them); the transcript is what was said. A delta that can't be written waits for the next: only a lost lease ends the call. While foundry.agent.enabled, the foundry-ask-worker's probe of a saved setting the agent passed also checks its ask model calls a tool on this wire (llm.CheckTools: up to 3 answers before it records one that doesn't, within config.AIToolCheckTimeout, which foundry.ai.probe.lease must cover past AIProbeOverhead while the Assistant is on) and records it in probe_report.assistant (ai.AssistantCheck, the API's assistant_check): a failed check never fails the setting, and refuses Founder's turns on it, saying why. Its tools are the MCP's, a closed list of them (agent.Tools), served in memory as the person who sent the message, in the turn's workspace alone: the host opens them through integration.SessionHost. It changes nothing itself: prepare_operation under integration.ConfirmByPerson hands the confirmation to a sink that seals its token with the connectors' keyring and shows the person a card, and the site's :execute runs it once, as the clicker, through the same port with ConfirmByCaller, then queues the turn that goes on from its result. The one exception is agent.autoRun, a closed list: a create_dashboard in the turn's workspace, in a turn of a message the person wrote holding the word dashboard or dashboards, runs at once as the person, as an approved workflow action runs (re-authorized, its confirmation consumed once, a replay finding how it ran); a new dashboard is always unpinned and unpublished, its action_card and action_result events say auto, the model is told to give its link, and the site offers Undo (it deletes the dashboard with the API's own DeleteFoundryDashboard). Updates, pins, publishes, deletes and every other operation stay cards. It prepares the operations agent.Operations names (every one the MCP has but upload_document and create_event_source), and its model's schema for prepare_operation lists those alone; in a workflow's turn it runs at once what its owner approved for the step. Each card's display is Foundry's names for what the action acts on (agent.Cards, agent/display.go, one shape per operation), drawn when it is prepared and again, as the clicker, when :refresh renews its confirmation; its ontology must be one the workspace holds; target_named_by_user says whether the person named its target (its id, or its whole name) in the thread; a settle_review is checked against the review as the current load holds it (ListFoundryReviews, with the entities it concerns), read as the person; and a generate_ontology reading every connector is refused while the workspace holds the sample company's (integration.SampleDatabase), which is read only when named. A replayed prepare finds the card its turn stored and draws nothing again. A tool call that never ran is shown as a tool_result whose not_run says why (agent.NotRunReason). An ask or get_question that returned names its Analyst question on its tool_result (question: ontology_id, id, load_id, thread_id, status), whatever the output's size, so the site shows the Analyst's own answer in the conversation.

A source grant (package access, table foundry_access_grants) gives a principal (a user, a team or a service credential) a connector, a table, a document set, People enrichment, or everything in the workspace (access.TargetWorkspace, KIND_WORKSPACE, migration 20261223000000_foundry_access_workspace_grants.sql): every connector, table and set, now and later, never People enrichment, and narrowed by an audienced source's sharing as a connector's grant is. It names nothing, so deleting a connector or set never removes it; it gives a connector's tables and sets only while the connector is live (access.Sharing knows the workspace's live connectors), so a deleted one's, which loads and documents still name, go with the connector's own grants.

A restricted member of source grants talks to Founder too, read-only. Its six thread routes (send, list, get, delete, events, cancel) admit a grantee (access.Workspace); cards (:execute, :refresh, :dismiss), the runtime and helpers stay refused. Every attempt reads the person's agent.Reach from GetMyFoundryAccess as their session (a failed read retries, offering no tool; a standalone install serves it, answering that its owner is no grantee): a grantee's turn (ReachGrants) offers agent.GranteeTools alone (reads, asks, pinned dashboards, its own questions to the person), its sink allows, records and runs nothing, it relays no draft's questions, its prompt says so (granteePrompt), and an automation's turn whose owner is now restricted fails for good. The API stays the authority: every tool call reaches it as the user, whose access check narrows it to the grants, and an ask is the grantee's own, on the load its grants cover, under the grantee's question limits. A grantee's page context keeps only an ontology its grants cover, that load and a pinned dashboard. A thread is a grantee's to read only while they hold every grant its turns ran under (foundry_agent_threads.granted_targets, migration 20261206000000_foundry_agent_thread_grants.sql, model.FoundryAgentThread.Granted, access.Grants.Holds): NULL for a thread made or run with the whole view (before the restriction, or while they were an owner or admin), so it is never theirs; a grantee's send makes a thread holding what their grants give, an owner's or admin's send into a thread clears it at once, and the worker records the Reach at the start of every attempt and around each of a grantee's tool calls (agent.threadReach, turnRun.reachAround: a whole view's run clears it for good, a grantee's adds what they hold now; a grantee's turn in a thread whose grants they lost fails for good before the model reads it, one in a whole view's thread fails to retry, and a call during which their role or grants changed clears the thread and fails the turn for good before its result reaches the model or the person). A helper's CLI (local only, where no one is restricted) gets the same check each time its tool server is opened. The list leaves out NULL ones in SQL and those whose grants they lost after, and every route answers them not found, so narrowing grants takes away what Founder read under them, as it takes away an Analyst answer. A caller the host sent on as a grantee (ports.SourceGrantee) is refused. A host keeps this working by the three requirements in integration.SessionHost's comment.

On a standalone install, a workspace's owner may run its new threads on the Claude Code or Codex subscription they are signed in to, on their own computer, instead of the workspace's model (agent.Hosts, local/agent_host.go, the helper in ../agent-host). A thread keeps its runtime (api, claude_code, codex); the worker claims only api turns. Codex runs with the owner's own Codex setup, so choosing it needs their confirmation once (confirm_codex, kept as codex_confirmed_at, else FOUNDRY_AGENT_CODEX_UNCONFIRMED; a card can't give it), and a helper runs it only at agent.MinCodexVersion or later: its account says Codex's version, and an older one is shown outdated and left out of what the helper runs (agent.Runnable), so no claim leases it a turn; one of no version (it didn't start) isn't outdated, but is left out too. The owner pairs a helper with a one-time hxp_ code (CreateFoundryAgentHostPairing, ten minutes), which it spends for an hxh_ token; the directory keeps each code's and token's SHA-256 alone (local/directory/migrations/00003_agent_hosts.sql). On the integration listener, the helper long-polls POST /agent-host/claim; a claim leases a due turn of its runtime to a lease owner of its own under the Assistant's caps, opens it (its message in the transcript once, the system prompt, the CLI session to resume, and the thread in words for a CLI that lost it), and mints an hxr_ token bound to that claim: /mcp takes it for the Assistant's tools alone, as the turn's person, in its workspace, prepare-only, 25 calls and 3 questions, until the lease ends or the turn does; Foundry records each call as the worker does, and the helper reports only its model's text and how the turn ended (renew, text, finish). A claim of a turn whose earlier claim showed anything ends it as interrupted rather than run it twice; past its wall time, Foundry ends it. Revoking a helper stops its token and its turns' at once. A helper's turns cost nothing (their max_usd is 0) and count toward per_hour, steps and wall time. Sending in a helper's thread is FOUNDRY_AGENT_HOST_OFFLINE while no helper running it has called in 30 seconds. Hosts without helpers (api.Deps.AgentHosts nil) refuse the runtime routes (FOUNDRY_AGENT_HOSTS_LOCAL_ONLY) and run every thread on the worker; integration.Service.AgentHosts registers helix_foundry_get_assistant_runtime and the set_assistant_runtime, pair_assistant_helper and revoke_assistant_helper operations only where it is set.

foundry.agent.enabled is off by default: sends are refused (FOUNDRY_AGENT_DISABLED) and the worker claims nothing, so a host may list it everywhere. A standalone install turns it on, with its sessions in-process (local.AgentSessions). A host that turns it on implements integration.SessionHost for the worker's process and the API's (see its doc comment) and passes it as api.Deps.AgentSessions and to the worker through dig, with ports.Databases for actions on an existing database.

Slack

Helix Foundry for Slack (foundry.slack) brings Founder to Slack through Helix's own distributed Slack app, "Founder". An owner or admin adds it to a Slack workspace by OAuth v2 from Settings › Slack. Each person links their Slack account to their Foundry user once, and the bot answers their channel mentions and direct messages as that person (per_person). Instead, an owner or admin may make the install one shared bot for its Slack workspace (bot mode). It works through Founder's own API (integration.FounderAPI on the Session), so every check the site's calls pass also applies in Slack. Hosted Helix holds every install and every Slack secret: a standalone install holds none, and its owner links it to a Helix workspace, through which Slack reaches it (Helix's Slack relay). The same install can also be a Slack data connection's credential (foundry.slack.feed, below), and, with foundry.slack.follow, the bot answers a reply in its thread that doesn't mention it. Both are off on hosted until Slack confirms in writing that the app may keep copies of channel history.

How a message travels:

  1. Door (services/foundry-events/slack.go): POST /v1/slack/events and POST /v1/slack/interactivity on the secretless foundry-events door (ingest.<domain>), served while foundry.slack.enabled is on (404 otherwise). The door checks, in order: the body cap (512 KiB for events, 1 MiB for clicks), slack.Precheck of X-Slack-Signature and X-Slack-Request-Timestamp (±5 min), refusing with 400 and no RPC, then room to read the body (foundry.events.endpoint.slack's bounds). It sorts the body into a class (slack.Classify: bot for mentions, DMs, clicks and lifecycle events, reply for channel messages in a thread, feed for other channel messages and channel events; anything it can't read is bot) and holds that class's gate until the backend answers: endpoint.slack, slack_reply or slack_feed. No class takes another's room, and none takes the sends' gate's, so a channel flood never refuses a mention, a click or a reply. It then forwards the raw body to FoundryEventsService.ReceiveSlackRequest within 2.5 s, since Slack waits 3 s. Any backend error is a 500: Slack retries events at once, after 1 min and after 5 min, but never retries clicks. On Slack's last retry (X-Slack-Retry-Num 3), a reply or feed event the door can't take is answered 200 with X-Slack-No-Retry and recorded as a gap instead (the gaps runbook below); a bot event never is.
  2. API (api/slack.go ReceiveSlackRequest): it verifies the HMAC with signing_secret (401 on failure), answers url_verification, and parses the request with slack.ParseEvent or slack.ParseInteraction into closed sets. It finds the install by Slack team and records one foundry_slack_intake row, deduplicated by e:<event_id> or a hash of the click or shortcut. It makes no Slack Web API call. app_uninstalled and tokens_revoked revoke the install right there, unless they are older than the install's last change (a retry after a reinstall). Channel messages and channel events go to the data connection's buffer and the follow-up check instead (below).
  3. Worker (foundry-slack-worker, package workers/foundry-slack-worker, role Roles.SlackWorker, logic in slackbot): it claims intake under a fenced lease, one conversation at a time and in order.
    • It checks the sender: a full member of the install's team (Grid members by enterprise_user). Guests, bots, Slack Connect users and externally shared channels are refused with an ephemeral note.
    • A sender with no link gets a one-time link (hx_sl_, 10 minutes, carried in the URL fragment, sent ephemerally). Linking requires the Slack email to equal the Foundry email.
    • For a linked sender it opens their Session and calls Founder.SendFoundryAgentMessage with surface: SLACK. The client token comes from the Slack message, so a retry gives the same turn. The turn goes into the Founder thread its Slack thread continues (foundry_slack_threads, one per Slack thread and person).
    • It then follows the turn (foundry_slack_replies, leased for the whole follow). One reply message is updated as events arrive, spaced per install. Analyst answers, cards and questions are posted apart, each once per key at least once (an Analyst question polled with get_question is still one answer); one of several messages records each as it goes, so a post cut short goes on from the message it stopped at. Slack refusing one for good (an error code other than its own faults) records it refused and the follow goes on; refusing the reply's own message ends the follow. A turn whose events are gone (its thread purged or deleted) ends its reply "Stopped.". Founder's questions say how a reply in the thread reaches the bot (slack.RepliesIn): plainly in a direct message; in a channel without a mention while follow-ups are on and the install holds the history scopes (until someone else joins in, or a day passes), else by mentioning it; a draft's questions link to the draft's page instead, since a reply in Slack can't answer them.
    • The message shortcut, Ask Founder about this (message_action, callback foundry.ask_about; it needs the commands scope), is a message to the bot about another one: the API queues it as a shortcut row in that message's thread (i: and a hash of the pick), and the worker checks who asked as for a mention (link prompt, guests and Slack Connect users refused, bot mode and its per-person cap, which counts shortcuts), then sends Founder "Tell me what Foundry knows about this Slack message from @…" with the message quoted as data in a fence. Where conversations.info says the bot is in the channel it answers in the message's thread, which then continues like a mention's; otherwise (a channel it isn't in or can't see, someone else's direct message) it answers in a thread of the person's direct message with it, opened by "About @…'s message in #…:". A channel shared with another organisation gets nothing but a direct message saying so. Slack refusing the post in the channel moves the held reply to a direct message (MoveFoundrySlackHold) and tells the person so ephemerally there. Slack shows the shortcut only to installs holding commands, so older installs list it among what they lack (missingScopes) until added again; a Slack connection never needs it (slack.FeedScopes).
    • Clicks run, dismiss or re-prepare a card (only the action's person may), stop a turn, or unlink. A card clicked outside a direct message first asks conversations.info whether the channel is shared with another organisation (channels:read, groups:read, mpim:read): there nothing runs or is posted, and an install without those scopes is told to add the app again. A run's continuation has its reply held before the card is redrawn, so a retry or a card Slack lost still follows it. A workflow card whose Run approves steps (create_workflow, update_workflow with steps) has no Run in Slack, where its steps can't show: it links to its thread in Foundry (slack.RunsInFoundry), and a Run of an older card is refused there.
    • Slack's own stop button stops the clicker's turns in its thread; only someone with none there is told they can't.
    • Every Web API call goes through slack.Client's Limiter: per install and method at api_share of Slack's tier, and 1/s per channel for posts. A 429 defers the row or follow by its Retry-After; nothing sleeps. A deferral, or a wait behind a busy thread, isn't one of a row's max_attempts (failures counts those); attempts counts every claim, and 200 give the row up. A row given up after holding its reply releases it to the follower at once.
  4. Sweep (every 30 s, in the worker): it calls apps.uninstall for revoked installs Slack hasn't been told of (until then that team can't install again: FOUNDRY_SLACK_DISCONNECTING). Slack refusing it for good (such as no_permission), or failing for a day after the revoke, takes the install as uninstalled (outcome abandoned), and its team's admin removes the app in Slack; the app's credentials refused are logged as an error. Hosted, it revokes the bot key a revoked install still names (Slack's uninstall, a gone workspace, a purge or a disconnect), drops its source grants and clears it from the install, which lifts the host's lock on the key. It purges Slack-born Founder threads idle past retention.threads, or whose install is revoked: their messages, events and actions are deleted and their turns' text is blanked (the turn rows stay for spend). A Slack-born thread deleted on the site is purged as it is deleted. It also prunes intake past retention.intake and replies past retention.replies, and link tokens and install states 1 day after they expire (model.SlackSecretsKept). For the data connection it also prunes folded buffer rows and what unbound feeds held, ends the connections of installs removed past feed.orphan_retention, flips staged switches, and closes yesterday's days at feed.close_at (below).

Package slack is pure and holds Slack's side of all this: signature checks, events and clicks, safe mrkdwn (escaped, every mrkdwn object verbatim: true, links only under site_url, other URLs and domains in inline code), Block Kit, the renderers, the Web API client (every post and update sends parse=none and no unfurls) and the limiter. On Founder's side, a turn carries surface (site or slack; a continuation copies its action's). A Slack turn adds agent.slackPrompt to the system prompt, and agent.autoRun never runs in Slack, so every action is a card. Tables are in store/migrations/20261213000000_foundry_slack.sql. A bot token is sealed with the connectors' keyring under its install id (foundry_slack_install_tokens) and deleted once Slack knows the app is uninstalled. Hosted must:

  • set Session.Founder in its SessionHost (a FoundryServiceClient that forwards the user);
  • run the worker task;
  • route /v1/slack/ to the door;
  • call store.PurgeFoundrySlack when it deletes a workspace;
  • give FoundryEventsService.RecordFoundrySlackFeedGaps an authz entry for the door's identity alone (without it the door's gaps are refused and counted lost);
  • set foundry.slack.feed.enabled and follow.enabled per stamp (false on prod until Slack's written OK), and give the API, the sync worker and foundry-slack-worker the same values;
  • give the sync worker and foundry-slack-worker the data bucket (foundry.sync.data_bucket) and AWS, where the feed's day mirror lives.
Key (foundry.slack.*) Default Read by
enabled false all. Off: the door answers 404, the API refuses with FOUNDRY_SLACK_DISABLED, the worker idles
client_id, app_id API, worker: the stamp's app (not secret)
client_secret (HELIX_FOUNDRY__SLACK__CLIENT_SECRET), signing_secret (HELIX_FOUNDRY__SLACK__SIGNING_SECRET) API, worker: secrets, hosted only; a standalone install refuses them, and the door must not get them
site_url API, worker: the site's origin. Installs return to <site_url>/slack/installed (it must be one of the manifest's redirect URLs) and link prompts open /slack/link
install_allowlist [] (everyone) API: the workspaces that may add the app until Slack authorizes commercial distribution
http.listen :8104 worker health
poll_interval, lease, concurrency 1s, 3m, 16 worker (follows run 4 per slot). A message's claim is never renewed, so lease is at least a card's run (model.FoundryAgentExecutingFor) plus a minute
max_attempts, retry_backoff 5, 10s (doubling) worker: failed attempts to start a message's turn or run a click (deferrals and busy waits don't count)
api_share 0.5 worker: share of each Slack rate tier one replica uses, so 1 over the replica count
busy_wait 15m worker: how long a message waits behind a busy thread (at least foundry.agent.max_wall_secs + 1 min)
retention.threads 720h worker: at most 30 days (Slack's terms, the listing and the privacy policy)
retention.intake 168h worker: how long an intake row stays (its text is dropped once handled), at least 1h so Slack's retries are known
retention.replies 168h worker: how long a reply row stays after its follow ends
feed.enabled, follow.enabled false, false all: the data connection through the app, and unmentioned follow-ups. Either one asks Slack for the history scopes and message events (slack.Required); each needs enabled
follow.window 24h API: how long after the bot's last post in a thread a reply reaches it unmentioned, at most retention.threads
feed.spacing 2m API, worker: how long after a buffer's first waiting row its connection syncs, so a burst syncs once
feed.read_budget.rows, .bytes 50000, 64 MiB sync worker: one fold of the buffer; past it the connection syncs again at once
feed.max_buffered_rows 200000 API: unfolded rows per connection; past it a batch is recorded as a gap
feed.backend_in_flight 8 API: channel events one replica takes at once, 1 to 12 (half its database pool); past it it refuses at once
feed.directory_every, feed.redocument_every 1h, 24h sync worker: how often users, channels and members are listed again (at least 5m), and how often a closed day that keeps changing offers its document again (at least 1h)
feed.close_at 10m worker: how long after midnight UTC yesterday's days close, at least 6m (past Slack's last retry)
feed.gap_thread_lookback 24h worker: threads whose latest reply is this long before a gap have their replies read again too
feed.orphan_retention 168h worker: how long a connection whose install was removed keeps its data, frozen, before it is deleted
backfill.history_per_minute, replies_per_minute 1, 1 worker: calls a minute per method and Slack workspace, 1 to 50 (Tier 1)
backfill.page_limit 15 worker: messages a call asks for, 1 to 999
backfill.replies_days 30 worker, sync worker, API (the ETA): the newest days whose threads' replies are read, 1 to 90
backfill.gap_calls_per_day 60 worker: calls a connection spends repairing gaps a UTC day; 0 repairs none
backfill.max_attempts, retry_backoff, poll_interval 5, 1m (doubling), 5s worker
bot.per_hour, bot.per_user_per_hour 120, 20 API, worker: bot mode's turns an hour, in place of foundry.agent.per_hour, and one Slack user's messages to the bot an hour
bot.proposal_ttl 24h agent worker: how long a bot's proposal waits for an owner or admin to run it, at most retention.threads
relay.enabled false API, worker, door: Helix's Slack relay, hosted only. Off: the door answers its routes 404 and the API refuses with FOUNDRY_RELAY_DISABLED
relay.claim_wait, claim_poll 20s, 2s API: how long a claim waits for something to arrive (at most 20s), and how often it reads meanwhile
relay.delivery_ttl 10m API, worker: how long a bot's request waits for its install before it expires undelivered
relay.calls_per_minute, max_call_bytes 60, 64 KiB API: one link's calls to Slack a minute on one replica, beside Slack's own limits, and one call's body (16 KiB to 1 MiB)
relay.feed_ttl, feed_batch, feed_batch_bytes, feed_max_rows 24h, 500, 4 MiB, 100000 API, worker: how long a relayed install's channel message waits to be claimed before it becomes a gap, what one claim takes of them, and how many one install may hold before the rest are gaps

The door's Slack gates are foundry.events.endpoint.slack (the bot class and the read room: max_in_flight 64, max_bytes_in_flight 64 MiB, requests_per_second 200, burst_requests 400, and per address 100/s, burst 200, 32 in flight, since Slack sends every install's events from a few addresses), slack_feed (400/s, burst 800, 16 in flight, 32 MiB; per address 200/s, burst 400, 8 in flight) and slack_reply (100/s, burst 200, 8 in flight, 8 of the largest body; per address 50/s, burst 100, 4 in flight). An install needs foundry.agent.enabled too. Metrics, none carrying text or user, channel or workspace ids: helix_foundry_slack_requests_total{route,class,outcome} and helix_foundry_slack_feed_gaps_total{outcome} (door); helix_foundry_slack_received_total{route,outcome}, helix_foundry_slack_feed_events_total{outcome} and helix_foundry_slack_feed_gaps_taken_total{outcome} (API); helix_foundry_slack_intake_total{kind,outcome}, helix_foundry_slack_follows_total{outcome}, helix_foundry_slack_sweep_total{step,outcome}, helix_foundry_slack_backfill_total{method,outcome} and helix_foundry_slack_api_calls_total{method,outcome} (worker).

Setting up the Slack apps

slack/manifest/dev.yaml and prod.yaml define the two apps: "Founder (dev)", which is unlisted and for Helix's own sandboxes, and "Founder". slack/manifest_test.go keeps their scopes and events equal to slack.Required under each stamp's flags: prod's with follow-ups on and the data connection off (the history scopes and message events, no channel events), dev's with both on. Helix's Slack org owns both apps.

  1. At https://api.slack.com/apps, choose Create New App, then From a manifest, pick Helix's workspace, and paste the YAML file.
  2. Under Basic Information, copy the App ID and Client ID into the stamp's hosted config (foundry.slack.app_id, client_id), along with enabled: true, site_url (https://dev.foundry.helix-db.com or https://foundry.helix-db.com) and install_allowlist. Put the Client Secret and Signing Secret in the stamp's helixsvc-secrets as HELIX_FOUNDRY__SLACK__CLIENT_SECRET and HELIX_FOUNDRY__SLACK__SIGNING_SECRET, for the API and foundry-slack-worker pods only. The foundry-events door gets foundry.slack.enabled and no secret. The dev and prod apps never share values.
  3. Slack verifies the manifest's request URLs (https://ingest[.dev].helix-db.com/v1/slack/events and /interactivity) with a signed url_verification. That works only once the door routes them and the API holds the signing secret, so after the deploy open Event Subscriptions and Retry until the URL is verified.
  4. Manage Distribution: activate public distribution only to install outside the app's own workspace. For prod that waits for Slack's written sign-off (Commercial Distribution needs Slack Marketplace authorization), and until then install_allowlist limits who sees Add to Slack.
  5. Never turn on token rotation (it can't be turned off, and the bot doesn't refresh tokens) or org-wide deploy (the API refuses enterprise installs). To change scopes or events, edit the manifests and slack.Required's lists together, then paste the manifest under App Manifest. Turning a stamp's feed or follow on is such a change: update its app first, then the flags. Existing installs keep their old scopes until an owner adds the app again: Settings › Slack shows what each lacks (missingScopes), Add to Slack installs again (Start refuses only an install lacking nothing, FOUNDRY_SLACK_INSTALLED; with feed on, an install no Slack admin or owner made, or whose bot id is unknown, lacks something a connection needs, so it installs again too), and a grant still missing one is refused (FOUNDRY_SLACK_SCOPES). Prod's manifest has the history scopes and message events for follow-ups; its data connection waits for Slack's written OK.

The Slack data connection through the app

A Slack connection (kind slack) reads with one of two credentials, SlackConnectorConfig's oneof credential:

  • bot_token: the customer's own internal Slack app, polled as before, up to 365 days of history. Slack still lets internal apps read history at Tier 3, so this reads everything now.
  • helix_app: the workspace's install of Helix Foundry (where foundry.slack.feed is on, else FOUNDRY_SLACK_FEED_DISABLED), up to 90 days (config.MaxSlackAppHistoryDays, since Slack's free plans keep 90). It reads the public and private channels the bot is in, never direct or group messages, and never a channel shared with another organisation.

Settings with credential: app and not staged read through slackAppKind (connector/slack_app.go); the catalog picks it with Catalog.KindFor(kind, settings), and every place that dispatches on a kind calls it. Such a connector is pushed (connectors.pushed): it syncs when its feed has something, never on an interval (sync_every_seconds is refused). Either credential keeps Helix's own bot's messages without their text (by its bot user, bot_id or app id, non-empty values only), so a thread's counts stay Slack's.

Binding (create, or an edit to helix_app; api/slack_connector.go) needs a person signed in who is an owner or admin, the current storage notice (helix_app.notice_version equal to slackFeedNotice, which a new wording bumps, else FOUNDRY_SLACK_APP_NOTICE), and an install holding the scopes slack.Required names (FOUNDRY_SLACK_APP_SCOPES), added by a Slack workspace admin or owner (installer_admin, from users.info at Finish; FOUNDRY_SLACK_APP_ADMIN) whose bot id is known (bot_id, from auth.test at Finish; FOUNDRY_SLACK_APP_BOT_UNKNOWN). No install is FOUNDRY_SLACK_APP_NOT_INSTALLED. A Slack workspace has one live feed, a connector one, and a Grid org one (FOUNDRY_SLACK_APP_IN_USE, FOUNDRY_SLACK_APP_ENTERPRISE, with connector_id when the connection in the way is this workspace's). The bind lists the channels the bot is in (users.conversations: not archived, not shared, of a kind whose history scope it holds), and stores the connector, its feed (foundry_slack_feeds, with notice_version and bound_by) and a backfill window per channel in one transaction (CreateSlackAppConnector, UpdateSlackAppConnector); deleting the connector unbinds its feed in the same transaction. Tables: store/migrations/20261214000000_foundry_slack_feed.sql.

New messages come from Slack's events (message.channels, message.groups and the channel lifecycle events of slack.ChannelSubscriptions). The door classes them feed or reply; the API (api/slack_feed.go) takes at most feed.backend_in_flight at once per replica, refusing the rest at once (busy, a 5xx Slack retries) so mentions and clicks keep their database connections, and appends what the connection keeps to its buffer (foundry_slack_feed, deduplicated by e:<event_id>), numbered in commit order. The connection is due feed.spacing later. A buffer past feed.max_buffered_rows records a gap instead. A team with no install, and a shared channel, are dropped.

The mirror. The sync worker's slackAppKind folds the buffer, feed.read_budget at a time, into a day mirror: one immutable object per channel-day in the data bucket, indexed by foundry_slack_feed_days (partial, complete or lossy), under a compare-and-set on the feed's folded_seq (CommitFoundrySlackFold), so a worker that lost its lease writes nothing; replaced objects go to connector_replaced_snapshots. Of the feed's tables only the buffer's payloads hold message text, and only until folded. The change read renders the days a fold changed into the same messages and channel_days rows and Conversations documents a token's read writes, with the same version strings (TestSlackAppParity). A day's document is offered once the day is over and complete or lossy (a lossy one ends saying some messages may be missing), and again at most every feed.redocument_every while its threads keep changing. The users, channels and members are listed again every feed.directory_every, or when the readable channels change. The worker's sweep closes yesterday's days at feed.close_at past midnight UTC.

History (slackbot/backfill.go, every backfill.poll_interval) comes from Slack's Web API at Tier 1 (below). Each window is read newest first, gaps before channels joined (newest first) before channels bound: conversations.history, and conversations.replies of the threads with replies on the newest backfill.replies_days days, newest day first (older threads list only the replies that arrived as events). Each call first reserves its install's slot for its method (foundry_slack_slots, made with every install and shared by every replica); a 429 defers the slot by its Retry-After, a missing history scope by an hour, and nothing sleeps. A page, its progress and the threads it found are written in one transaction, under a compare-and-set on the window as read. slackStatus.backfill estimates what is left from the density read so far.

Switching a token connection to the app is staged (staged in its settings, slackStatus.switching): it keeps syncing by its token, untouched, while the app's backfill fills the mirror, and the sweep flips it (FlipSlackAppConnector: its days closed and folded, then a full read from the mirror) once every window (bound, joined or gap) and thread is read, also after that fold, so no day loses its document. helix_app.now flips at once. A new bot_token switches back: the feed is unbound and the connection syncs in full.

Its install decides slackStatus.state (syncer.SlackAppStateOf): LIVE; NEEDS_REINSTALL (missing_scopes); INSTALL_GONE, the app removed, whose syncs fail for good, so the schedule pauses and the data stays frozen until deleted_at (revoked + feed.orphan_retention, 7 days), when the sweep deletes the connection (a staged one reads by its token alone again); or TEAM_CHANGED, the workspace's install now of another Slack workspace. Adding the app to the same Slack workspace again re-points its feeds (repointFoundrySlackFeeds), records a gap of every channel from the removal to now, and resumes the schedule. events_limited_at says when Slack last dropped the team's events (shown for 24 hours), lossy_days how many days were published lossy.

Retention. Buffer rows go once folded (the sweep, every 30 s); the mirror keeps the window, and days that leave it leave the mirror and their rows. A feed unbound or deleted is marked deleting_at, and the sweep deletes its buffer, then its index (recording its objects for deletion), then the feed. The store's ConnectorDocumentsPublish.Expire takes documents that left a source's window out of every load of every ontology, refresh on or off (expireFoundryDocuments), but the syncer doesn't send a Slack day's exit as Expire yet: such a document is removed as a replaced one is. Nothing is used to train a model.

Unmentioned follow-ups (foundry.slack.follow, followSlackReply): a channel message in a thread the bot answered someone in (foundry_slack_threads) is taken as that person's next message while the bot posted there last apart from them (bot_at after others_at) and within follow.window; a message from anyone else in the thread sets others_at. In bot mode the thread is everyone's, and a reply from any of its people (foundry_slack_thread_people) reaches the bot on the same terms. A mention still comes through app_mention alone.

Slack's pace (verified 2026-11-21, https://docs.slack.dev/changelog/2025/05/29/rate-limit-changes-for-non-marketplace-apps): a commercially distributed app outside the Slack Marketplace (every app made since 2025-05-29) may call conversations.history and conversations.replies once a minute per method and Slack workspace, 15 messages a call, whatever the method references say. Internal apps keep Tier 3 and Marketplace apps are unaffected. So the defaults are 1 a minute and 15 a page: a 12-channel workspace's 90 days take about 2.5 days with replies_days 30. Raise backfill.*_per_minute and page_limit only once Slack lifts the limit for the app (Marketplace approval). Events aren't paced, but Slack sends an app at most 30,000 a team an hour, mentions and DMs included, and drops the rest (app_rate_limited, which the gaps runbook covers).

Bot mode

UpdateFoundrySlack with identity_mode BOT (owners and admins) makes the install one shared bot for its Slack workspace, hosted only (ports.BotCredentials; elsewhere FOUNDRY_SLACK_BOT_HOSTED_ONLY). The bot is a workspace service credential whose token no one holds and whose database grants stay empty; the host refuses to edit it, and a session for one given grants. What it reads is its scope (bot_scope, model.SlackBotScope, foundry_slack_installs.bot_scope, migration 20261227000000_foundry_slack_bot_scope.sql), which BOT with a bot_scope sets in place: WORKSPACE, a new bot's and every bot's from before, reads everything an unrestricted member reads, as an access.Reader (the API admits it only where access.ReaderAdmits: reads, asks and its own Founder threads, never workflows, never narrowed; GetMyFoundryAccess says reads_workspace, its threads hold no grants, its questions are its own and the ask worker reads them whole while its scope is still the workspace's); SOURCES reads only the sources Settings › Access gives it, as a grantee. Founder reads the scope each attempt and around a sources bot's calls (ReachBotWorkspace, ReachBotSources), so a thread run with the whole view can't go on once the scope narrows. Either way it reads through Foundry's typed reads (ReadFoundryGraph, asks), never a database's query-read. Any full member of the Slack team asks it without linking, in one Founder thread per Slack thread (principal service_credential, migration 20261215000000_foundry_agent_principals.sql), each message headed with who wrote it. bot.per_hour bounds its turns in place of foundry.agent.per_hour, bot.per_user_per_hour one Slack user's messages, and its Analyst questions take the workspace's ask limits. It runs nothing: an action it proposes (agent.ReachBot, integration.ConfirmByAdmin) is a channel card a linked owner or admin runs as themselves in two clicks, Review (drawn and validated as them, shown to them alone) then Run (a workflow's spec must still be the one reviewed), within bot.proposal_ttl; the bot's thread learns only the run's status and who decided. PER_PERSON revokes the credential and purges the bot's threads; an install removed any other way leaves it for the sweep to revoke. A Slack thread whose Founder thread read a source taken from the bot since (Founder then hides it) is told the conversation can't go on, and to ask in a new message. A credential revoked or changed fails the bot's turns, the bot says once that bot mode is off, and bot.broken shows it.

Helix's Slack relay

A standalone install reaches Slack through hosted Helix (foundry.slack.relay, the spec's L3). Hosted holds the app's install and bot token for it; the standalone install runs the bot (its own foundry-slack-worker), the data connector and the backfill, and calls Slack through hosted, which checks every call. A linked install is untrusted.

Linking (OAuth's code flow with PKCE): the owner's StartFoundryRelayLink keeps a state and a sealed verifier (foundry_local_relay_pending) and sends the browser to <local.relay.site_url>/relay/link, where an owner or admin of a Helix workspace authorizes it (AuthorizeFoundryRelayLink: a code of ten minutes, bound to the challenge and to the install's loopback http://localhost|127.0.0.1[:port]/settings/slack, under install_allowlist). Back there, CompleteFoundryRelayLink spends it at the door (RedeemFoundryRelayCode, once; refused once the authorizer is no longer an owner or admin) for an hx_rl_ token, which hosted keeps as a SHA-256 (foundry_relay_links, with the install's name, the machine's, and its loopback origin) and the install seals with its connector key (foundry_local_relay, directory migration 00004_slack_relay.sql). The owner's Add to Slack goes through the link too (StartFoundryRelaySlackInstall, its return bound to the link's origin, as the link's creator while they are still an owner or admin): hosted finishes the OAuth and stores an install serving that local workspace (model.SlackServesRelay, one live per destination), and the claims hand it to the install, which mirrors it with no token (MirrorFoundrySlackInstalls). Revoking a link (the install's Unlink, RevokeFoundryRelayToken, or hosted's Settings › Slack, RevokeFoundryRelayLink), or deleting its workspace (PurgeFoundrySlack), revokes its installs in the same transaction (the sweep uninstalls them from Slack) and expires their deliveries untold.

Deliveries. ReceiveSlackRequest checks a relayed install's requests as any (signature, team, dedupe) and queues them as deliveries (foundry_relay_deliveries, relay.delivery_ttl, no Slack call, no response_url), recording the channel and the users they name (foundry_relay_channels, foundry_relay_users, never a channel shared with another organisation, whose messages the hosted worker refuses in Slack). The install long-polls POST /v1/relay/claim (ClaimFoundryRelayDeliveries): it acks what it took by id, then waits up to relay.claim_wait, reading every claim_poll without a lock and leasing (FOR UPDATE SKIP LOCKED, a minute) only once something waits: the bot's requests first, then its channel messages and gaps while hosted's feed is on and the install's connector reads the team (feeds, its feed_on), and its thread replies alone while hosted's follow is on and the local install takes follow-ups (its follow_on, data connection or not), which the install takes as messages where its bot follows the thread (api.FollowSlackReply) (foundry_relay_feed, feed_batch rows and feed_batch_bytes a claim, past feed_ttl or feed_max_rows a gap). It queues each delivery as an intake row with the same id and dedupe key and appends the feed to its own feeds, so a delivery claimed twice is one row. Unlinked, the install's relay component (local/relay, always run) only reads its directory every 10 s; linked, it backs off from 1 s to a minute, jittered, while hosted can't be reached, and forgets a link hosted revoked. Hosted's worker sweep tells a conversation whose install hasn't called for 90 s that it is offline (a thread reply, at most every 10 minutes), says "Not delivered" of a delivery that expired (unacked a minute past its expiry, once claimed), and turns feed rows past feed_ttl into gaps. Retention: payloads go at ack or expiry, finished deliveries a day after, channels and users unseen for 30 days, codes a day after expiry.

Slack calls (POST /v1/relay/slack/{method}, CallSlackForRelay, api/relay_proxy.go), as the link's one install serving the call's local workspace: the bot's chat.postMessage, chat.update, chat.postEphemeral, users.info, conversations.open and agents.sessions.setStatus, and, only while hosted's feed is on, the connector's conversations.history, conversations.replies (each taking the install's Tier-1 slot, foundry_slack_slots, as hosted's backfill does), conversations.members, users.conversations, conversations.list, users.list and auth.test. A call names only channels and users the install was sent (or users.conversations listed, or conversations.open opened), is a JSON object within max_call_bytes naming no mass mention, and is rewritten as the bot's own posts are (mrkdwn verbatim, parse=none, no unfurls; no username, icons, as_user, reply_broadcast, link_names or metadata). The link's calls_per_minute and the install's share of Slack's tier pace it; one that can't go yet answers retry_after_s, which the install reads as Slack's Retry-After. A call naming a channel outside a direct message is refused when the channel is shared with another organisation, as conversations.info says: asked within the same pacing (the install's share of its tier, and its 429 held as any call's, answered retry_after_s), and kept on the replica 5 minutes, or an hour for "not shared" while hosted's feed subscribes channel_shared, which forgets the channel in foundry_relay_channels for every replica. A connector read (conversations.history, conversations.replies) of a channel the install was sent something from, or listed, within that hour asks nothing, since every way a channel is recorded leaves out a shared one. channel_unshared isn't subscribed: a channel shared then unshared is refused until it is seen again. Slack's answer comes back without tokens, and users.info's without email or phone. The install updates a reply every 6 s (hosted's bot 1.5 s), so a link's 60 calls a minute serve several replies at once.

On the standalone install (cmd/foundry: foundry.slack.enabled and the relay in its foundry.yaml; local.relay.url and site_url are pinned to https://ingest.helix-db.com and https://foundry.helix-db.com unless allow_custom_host, for Helix's development stamps), FoundryService serves Slack's settings, links and the relay's own routes to the owner (local/methods.go), the bot's links open on local.site_origin, and the workers get slackbot.Relayed and syncer.SlackCallers. Every link acts as the owner: only the Slack account that installed the app is offered one (access full, no email to compare); anyone else who writes is recorded once (foundry_slack_access_requests) and told the owner hasn't let them in, and the owner's SetFoundrySlackAccess READ gives them a link whose turns only read and ask, as the owner (foundry_agent_turns.read_only, agent.ReachReadOnly: the grantee tools and no prepare, in the worker and on helpers). Cards run only on the owner's own click and only while Approve changes from Slack is on (slack_approvals, UpdateFoundryRelay); off, the owner's turns are read-only too, since hosted vouches for who clicked. local/README.md says what leaves the machine and what Helix keeps.

Hosted must, for the relay: set foundry.slack.relay.enabled on the API, the Slack worker and the door; route /v1/relay/ to the door (gate foundry.events.endpoint.relay, and relay_max_waiting, 512, claims a pod holds, one a link); give every relay FoundryService method an authz entry, those it refuses too (GetFoundryRelay, StartFoundryRelayLink, CompleteFoundryRelayLink, UpdateFoundryRelay, UnlinkFoundryRelay and SetFoundrySlackAccess are a standalone install's: hosted answers FOUNDRY_RELAY_LOCAL_ONLY or FOUNDRY_SLACK_LOCAL_ONLY), and the FoundryEventsService relay methods one for the door's identity alone; and serve /relay/link. Metrics, none carrying text or ids: helix_foundry_events_relay_requests_total{route,outcome} (door), helix_foundry_relay_claims_total{outcome}, helix_foundry_relay_deliveries_total{outcome} and helix_foundry_relay_calls_total{method,outcome} (API), and the sweep's relay_offline, relay_expire and relay_feed steps. Hosted keeps per link only counts a day (foundry_relay_usage: deliveries, calls, refused, feed rows and bytes), which Settings › Slack's linked installs show. Scale: an online install costs the shared database a read every claim_poll (1,000 linked installs, about 500 reads a second); past that, wake waiting claims in process and lengthen claim_poll.

Alert runbook: Slack's requests failing

Hosted alerts when the 5xx and timeout share of helix_foundry_slack_requests_total passes 20% over 10 minutes. This matters because Slack disables the app's event subscriptions for every install when more than 95% of deliveries fail within 60 minutes. Mentions and DMs then stop arriving everywhere, and Slack does not resend what it dropped. Clicks are unaffected but fail just as visibly. Look at the outcome label:

  • internal, backend_unavailable or request_timeout: the backend or its MySQL is down or slower than 2.5 s. Check helix_foundry_slack_received_total{outcome="failed"} (the intake insert) and the backend's logs.
  • unverified (401): the API's signing_secret isn't the app's (it was regenerated, or the dev and prod secrets are swapped). Fix the secret and roll the API.
  • disabled (404): the door has foundry.slack.enabled on but the API has it off. Make them agree. Leaving Slack's routes off for an hour with live installs disables the subscriptions too.
  • rate_limited: a Slack gate is too tight for the traffic. Raise the gate of its class label: foundry.events.endpoint.slack (bot), slack_reply or slack_feed.
  • stale: the door pods' clocks are off. unsigned is not Slack (scanners), and Slack's deliveries don't count it.

Once fixed, if Slack has already disabled the subscriptions (the app's Event Subscriptions page shows Enable Events off), turn Enable Events back on there and save. Slack sends url_verification to the request URL again (Retry sends it again) and delivers events once it passes. A message sent meanwhile is lost: people send it again. The worker's own trouble shows elsewhere and doesn't trip Slack: helix_foundry_slack_intake_total{outcome="failed"}, helix_foundry_slack_follows_total{outcome="gave_up"}, helix_foundry_slack_api_calls_total{outcome="ratelimited"} and helix_foundry_slack_sweep_total{outcome="error"}.

Runbook: gaps in a Slack data connection

Slack never sends an event again once the last retry is answered or dropped, so every way a channel message can miss the buffer is recorded as a gap (a channel's minute, or every channel's) where the code can see it, and the backfill reads gaps again first. What to watch:

  • The door couldn't take a reply or feed event on Slack's last retry (its class's gate full, or the API failing): helix_foundry_slack_requests_total{outcome="gap_recorded"}. The pod holds the gap and sends what it holds every minute (RecordFoundrySlackFeedGaps, helix_foundry_slack_feed_gaps_total{outcome="flushed"}; retried while the API fails). gap_lost, or feed_gaps_total{outcome="lost"}, is a gap no one will read: a body naming no team, a pod holding 10,000 already, or the API refusing the call for good (PermissionDenied: hosted's authz entry for the door is missing; Unimplemented: an API without the method). Alert on any. A lot of gap_recorded means foundry.events.endpoint.slack_feed or slack_reply is too tight for the traffic, or the API is failing (the alert runbook above).
  • The door refused a reply or feed event on Slack's last retry for room it keeps per address, or before reading its body (the read room): anyone could make it refuse those, so the door holds no gap from such a body. It reads it in a small pod-wide room of its own (4 in flight, 10 a second) and sends it, with its signature headers, to RecordFoundrySlackFeedGaps as a signed event; the API verifies the signature with the app's signing secret before recording its gap (helix_foundry_slack_feed_gaps_total{outcome="verified"}, and gap_recorded). A false signature is refused as before and counted unverified, quietly; a verified event no feed reads is gap_unattributed. gap_unrecorded is a last retry lost with no gap: the room full (counted feed_gaps_total{outcome="unrecorded"} and logged once a minute, foundry slack last retries unrecorded) or the API failing (logged at once). Alert on any: a lot of it means a burst of Slack's last retries past an address's bounds (address_* of slack_feed and slack_reply, or endpoint.slack for the read room) or a flood of forged last retries.
  • The API refused for room: helix_foundry_slack_feed_events_total{outcome="busy"}, the replica's feed.backend_in_flight all taken. Slack retries, and only its last retry becomes a gap. Raising backend_in_flight past half the database pool would take mentions' connections: add API replicas instead. Each event is one append transaction, so past about 50 busy Slack workspaces, appends need batching or feed intake replicas of its own.
  • The buffer is full: feed_events_total{outcome="full"}, a connection with feed.max_buffered_rows unfolded, so the sync worker isn't folding it: look at the connection's syncs (failing, paused, or the worker down). The rows past the cap are gaps.
  • Slack dropped the team's events past its 30,000 an hour: feed_events_total{outcome="rate_limited"} and a warning log naming the install. The install's events_limited_at moves (the connection's page says so for a day), and every channel the feed reads gets a gap of that minute. Nothing on Helix's side fixes it; a team that hits it often reads everything with its own app's token instead.
  • The app was removed and added again: the reinstall records a gap of every channel from the removal to now.

Repair is capped: a connection spends at most backfill.gap_calls_per_day (60) calls a UTC day on gaps (foundry_slack_gap_budget), the gap's history and the threads whose latest reply was within feed.gap_thread_lookback before it. A gap past the budget is cancelled and its days close lossy (helix_foundry_slack_backfill_total{outcome="lossy"}): their documents say some messages may be missing, and slackStatus.lossy_days counts them. Raising the budget spends Tier-1 calls the history backfill needs; a day already lossy stays so.

The backfill's other outcomes: busy (another replica had the slot) and deferred (Slack's 429) are normal; scopes is an install without a history scope (adding the app again fixes it); refused is a token Slack refuses (the uninstall path ends it); failed is a window's last attempt after backfill.max_attempts; error is the store or keyring. A staged switch that never flips shows as helix_foundry_slack_sweep_total{step="flip",outcome="waiting"} (a sync live, or its settings changed) while its backfill is done.

Dashboards

A dashboard (package dashboard, tables foundry_dashboards and foundry_dashboard_shares, api/dashboards.go) is a spec of up to 20 tiles in rows of 1 to 3, each one typed query (the read contract's Query, the query read of ReadFoundryGraph, as an Analyst answer records its visuals' queries) of an ontology's current or a pinned load, shown as a table, bars, a line or a figure. It holds queries, never data: the site reads each tile through the load's :read as the person viewing it, so a dashboard shows no one more than they may read. Every member sees every dashboard (a grantee of source grants only the pinned ones); a member creates dashboards and changes their own while unpinned; owners and admins change any, pin up to 20 in every member's sidebar, and publish one. A workspace keeps 200. Edits, pins and publishes name the revision they were made from, so what is pinned or published is what its owner saw. An edit checks only the tiles it adds or points at another ontology or load (Spec.NewTargets): a tile whose pinned load or ontology went since blocks no other edit. A member deletes their own dashboard only while it is neither pinned nor published.

A dashboard's page in Foundry is how it is shared inside the workspace: every member who opens it reads it live, as themselves. A public link is the opt-in for people outside it. Publishing (:publish, owners and admins, else FOUNDRY_DASHBOARD_PUBLIC_ADMIN_ONLY; with foundry.dashboards.public_enabled, on by default, else FOUNDRY_DASHBOARD_PUBLIC_UNAVAILABLE; a standalone install never publishes, config.PublicDashboards; and while the workspace's owners keep public links on, else FOUNDRY_DASHBOARD_PUBLIC_OFF) reads every tile as the publisher, who must be able to query each tile's database, and keeps the outputs as a snapshot that names no workspace, ontology, load, entity or person by id, and keeps each query's shape only, never a value it tested such as start.ids (dashboard.NewSnapshot, PublicQuery; at most 512 KiB a tile and 2 MiB in all). Its transaction locks the ontologies its tiles read, as deleting one and turning People enrichment off do, and refuses (FOUNDRY_DASHBOARD_TILE_FAILED) when one was deleted meanwhile or has a purge pending. Its link's token is hxd_ and 256 random bits: the table keeps its SHA-256, which a request is looked up by, and the token sealed with the connectors' keyring, so owners and admins are shown the link again. A publish may set when its link ends (expiry: never, 7, 30 or 90 days from now; unset keeps a live link's own, foundry_dashboard_shares.expires_at): an expired link is served as an unpublished one, and publishing again makes a new link, never reviving the old. An owner turns public links off for the workspace in its dashboard settings (GET/PATCH .../foundry/dashboard-settings, foundry_dashboard_settings; no row is on): off, no link of the workspace is served or published, and turning them on again revives the links not unpublished or expired meanwhile. Each dashboard says why its caller may not publish it (publish_block) and whether its link shows (share.status). Republishing refreshes the snapshot at the same link; unpublishing (allowed with the flag off, so a link ended then stays ended), deleting the dashboard, deleting an ontology it reads, turning People enrichment off when one it reads ever applied profiles, or the workspace's deletion deletes it, and turning the flag off stops every link at once. The foundry-events door serves it, with no session, at GET /v1/shared-dashboards/{token} (services/foundry-events/shared.go: the address's bucket, 10 links that show nothing a minute, CORS for any page, never cached): its ingress must route /v1/shared-dashboards/ as it routes /v1/sources/. A host's MCP sets integration.Service.PublicDashboards from config.PublicDashboards, and its registry gives every dashboard method PermissionWorkspaceRead and a principal (the handlers decide by role, through ports.People), with the caller's query-read scope resolved for the preview and the publish, as for ReadFoundryGraph.

The MCP lists, gets and previews dashboards (helix_foundry_list_dashboards, helix_foundry_get_dashboard, helix_foundry_preview_dashboard_tile) and prepares create_dashboard, update_dashboard, delete_dashboard, pin_dashboard, unpublish_dashboard, and where offered publish_dashboard; a user who manages nothing of the workspace gets the prepare tool with the first three only (integration.memberOperations). Founder offers the same, each a card its person runs, but for a new dashboard the person's message asked for, which it makes at once (agent.autoRun). No tool returns a public link: a tool's output reaches an agent, its model provider and its transcripts, so the link is shown only on the dashboard's page in Foundry.

Workflows

People and agents read "workflow" for what the code calls an automation, and "use case" for what it calls a workflow (an outside agent's tracked task, shown on the ontology's Usage page): Go names, RPCs, tables, reason codes and metrics keep the code's words.

It runs only once its owner approved its spec with a click in Foundry (:approve takes a person signed in to the site, never SOURCE_MCP; no MCP tool approves): a spec edited by anyone or anything else waits for that click. The Assistant's card is that click too: the API approves exactly the steps a create_workflow or update_workflow card showed once its person runs it, and nothing for an edit whose card showed none (a new name or description). No step may start the work its trigger waits on (a sync of its connector, a load of its ontology), or each run would start another; loops through other automations, or through the refresh load a run's sync owes, are skipped as they fire (below). An Assistant step runs unasked only what fits an action the owner approved for it (allow, automation.Fits: the same operation and target, its payload bounded by its kind); a publish, approved or an action step, refreshes only the revision already at the dashboard's link, so an edit no one published since is never published unattended. Anything else it prepares waits for the owner as a card in the run's thread.

The foundry-automation-worker (package workers/foundry-automation-worker, role Roles.AutomationWorker, with foundry.automations.enabled; a standalone install runs it) fires schedules due (one run however long it was due), finds each event trigger's ended work by a cursor over its target's own index, counted once settle old (store.FindFoundryAutomationEnded), and walks queued runs a step at a time as their owner through integration.SessionHost. A fire's run and its cursor's move commit together, and a run's trigger key is unique per automation, so a fire runs at most once; an automation has at most one live run (an event waits for it, a schedule records a skipped run). An action step is marked executing before its call, so an attempt that dies in it leaves it failed, never run again; the run's lease (at least config.MinAutomationLease, twice an action's timeout) is renewed before every step. A sync_connector or create_load step then waits for its sync or load ("Waiting for the sync…"): the write that records it on the step (foundry_automation_run_nodes.job_id, store.AwaitFoundryAutomationJob) also marks the work as the run's, the run is handed back between reads (a tenth of the time taken, step_wait to a minute), a run picked up again after a restart waits on that job and never starts another, and the step ends as the work did (a sync that succeeded, a load ready or partial; else failed with why), or fails after an hour for a sync or 6 hours for a load, the work going on. A sync or load an automation's run started, by an action step or an action its Assistant step ran, names the run and how many automation runs led to it (connector_syncs/foundry_loads.started_by_automation_run_id and automation_chain_depth, migration 20261205000000_foundry_automation_causes.sql), and a refresh load takes the cause of the sync that owed it (foundry_ontologies.refresh_cause_*); a run's trigger event carries the automations behind it (caused_by_automations, chain_depth). An event trigger skips work its own automation started, directly or through automations it set off, or past 3 runs in a chain, recording a skipped run that says why. An Assistant step whose thread has a live turn (its owner ran a card an earlier step left) waits for it. A skipped run keeps no spec, the worker deletes runs that ended over 90 days ago a batch at a time, and deleting an automation deletes its runs in batches too. An Assistant step queues a turn (kind automation) that the foundry-agent-worker runs, under foundry.automations.monthly_usd and max_running, apart from people's Assistant budget. A workspace keeps max_per_workspace automations and starts runs_per_day runs a day; a failed run holds the next back by failure_backoff, doubling; pause_after_failures in a row pause it and email its owner (automation_paused), and an owner who lost access pauses it (store.PauseFoundryAutomationsOf, for a host's member removal, and the worker when the owner's session is refused). A notify step queues an automation_run email for the foundry-notify-worker, which takes every link out of the Assistant's words (URLs, mailto:, email addresses, IP addresses and bare domains); a standalone install sends none.

The foundry-automation-worker (package workers/foundry-automation-worker, role Roles.AutomationWorker, with foundry.automations.enabled; a standalone install runs it) fires schedules due (one run however long it was due), finds each event trigger's ended work by a cursor over its target's own index, counted once settle old (store.FindFoundryAutomationEnded), and walks queued runs a step at a time as their owner through integration.SessionHost. A fire's run and its cursor's move commit together, and a run's trigger key is unique per workflow, so a fire runs at most once; a workflow has at most one live run (an event waits for it, a schedule records a skipped run). An action step is marked executing before its call, so an attempt that dies in it leaves it failed, never run again; the run's lease (at least config.MinAutomationLease, twice an action's timeout) is renewed before every step. An Assistant step whose thread has a live turn (its owner ran a card an earlier step left) waits for it. A skipped run keeps no spec, the worker deletes runs that ended over 90 days ago a batch at a time, and deleting a workflow deletes its runs in batches too. An Assistant step queues a turn (kind automation) that the foundry-agent-worker runs, under foundry.automations.monthly_usd and max_running, apart from people's Assistant budget. A workspace keeps max_per_workspace workflows and starts runs_per_day runs a day; a failed run holds the next back by failure_backoff, doubling; pause_after_failures in a row pause it and email its owner (automation_paused), and an owner who lost access pauses it (store.PauseFoundryAutomationsOf, for a host's member removal, and the worker when the owner's session is refused). A notify step queues an automation_run email for the foundry-notify-worker, which takes every link out of the Assistant's words (URLs, mailto:, email addresses, IP addresses and bare domains); a standalone install sends none.

Founder's new chat and the new workflow page offer suggestions written for one ontology's current version (ListFoundryAutomationSuggestions, GET .../foundry/automation-suggestions?ontologyId=, api/automation_suggestions.go; package automation/suggest; tables foundry_automation_suggestions and foundry_automation_suggestion_ledger, migrations 20261204000000_foundry_automation_suggestions.sql and 20261207000000_foundry_automation_suggestion_kinds.sql, which deleted the rows written before kinds): prompts of four kinds, in order 2 questions, 2 dashboards, 2 changes to the ontology and 4 workflows (at most 10), each a kind, a title (32 characters), a prompt (400) that only fills the composer, a topic (24, a card's label), where it came from (source: model, questions, setup or fixed) and, for a workflow, an icon; the answer's source is its first workflow's. Any person of the workspace reads them, signed in or through the MCP (a grantee or a service key may not); where the deployment has workflows off (foundry.automations.enabled), the route still answers, without workflows. suggest.Fill fills each kind to its count, a prompt once per kind (case aside), every one passing Suggestion.Clean (no links, markup, ids, control or invisible format characters; a dashboard's prompt says "dashboard" as a word, so Founder makes it at once; a change's says "draft" or "revise", so Founder prepares a new version; a workflow has an icon): questions from the version's competency questions, then the model's, then fixed examples; dashboards from the model's, then one answering each competency question from the third on ("Build me a dashboard that answers: …"), then fixed; changes from the ontology's setup (suggest.SetupOf, read on every answer without the version's definition, GetOntologyVersionSources: its open unmatched audit findings by support, then the workspace's connections its generation's tables didn't read, then the document sets holding documents outside its scope, API sources and the sample company's connection and set left out), then the model's, then fixed; workflows from the model's, then a weekly emailed answer to each competency question (suggest.Fallback), then fixed. Without a current version every kind is fixed examples (suggest.Starter), its changes helping to connect data and draft the first version. A read with no row, or one that failed an hour ago, queues a write (once per version, under the workspace's lock, 20 a workspace an hour) with the version's questions, so polls never read the version again, unless foundry.agent.enabled is off or the AI setting can't be used, and says generating while it is queued or running and was queued under 2 minutes ago. The foundry-agent-worker makes up to 3 writes at once, each under a 2-minute lease (3 claims at most); a write on the owner's own server (Ollama, an OpenAI-compatible one), whose calls the process queues, gets the setting's call timeout and renews its lease to match. A write whose version is no longer current ends failed. It reads the ontology's name, the version's types, links and questions, its generation's goal, title and connectors and the sets it reads (never data rows, every list and string capped, all of it in blocks the model is told are data), and makes one call for every kind on the workspace's extraction model (llm.NewFor, reasoning off, at most 4,000 tokens out), offering only the suggest_for_founder tool ({questions, dashboards, ontologies, workflows}) and asking it to answer only by calling it, retried at most twice on an answer suggest.Parse keeps nothing of (it keeps each kind's first count that pass Suggestion.Clean, titles and prompts unique within a kind), or, after a wait of 2 then 4 seconds, a refusal a retry may pass, all within 60 seconds; the row stores what was kept as [{kind, title, prompt, topic, icon?}], and a read drops an item that doesn't pass. It writes nothing whose worst case the month's Assistant budget can't fit, and what every call spends is charged to that budget (people's pool) beside people's turns, in the ledger, whether the write ended, lost its lease or was cut short by the worker's stop (which leaves the row to its lease, unless the answer was in). The ledger also counts the hour's queues, and stays when rows go with their ontology. Rows go with their ontology and the workspace's work. A host registers the method in its authorization.

How much an ontology helps a workflow is recorded as a use case's runs (store/foundry_automation_workflows.go, migration 20261203000000_foundry_automation_workflows.sql, agent/workflows.go). Foundry makes one use case of each ontology a workflow uses (foundry_workflows.automation_id), named after it (kept in step as it is renamed) and counted in the ontology's 100: at the first run that uses the ontology, or when its owner approves steps that name it (an action's or an allowed action's create_load, a published dashboard's tiles; not what the trigger listens to). A run uses an ontology when an Assistant step calls a tool naming it (ontology_id, or a prepared action on it or on a dashboard that reads it) or an action step acts on it; its first use starts the run of that use case (automation_run_id, the owner's, its request the run's trigger and steps in words, automation.Request), and the Assistant step's reads and questions carry it as use_case_run_id, its id and its key (foundry_workflow_runs.automation_key, FoundryWorkflowRun.Recording()), which the agent loop sets for a workflow's turn and strips for every other, a helper's CLI turn's included: a model never names one, nor sees the field. The API records under such a run only a call naming its key, which no answer shows, so its id alone (on its pages and in get_workflow_run) records nothing for anyone, the owner's own agent included; once it is full or finished, those calls go on unrecorded. An action step is a use but no access: the access model records what an agent read of the ontology or sent to Foundry, and the engine's Assess takes reads, questions, sends and uploads only, so an action shows in the run's answer instead. The write that ends the workflow's run finishes its use case runs with what the run found (FoundryAutomationRunEnd.Answer), queueing their assessments, which the foundry-ask-worker's Assess judges under its own cap; a cancelled run, or one its workflow's deletion ended, finishes them unassessed. A run that uses no ontology starts none; an ontology with 100 use cases leaves the workflow's runs there untracked (foundry_automation_untracked, which the workflow's read says). Only Foundry starts and finishes those runs (the API refuses, reason FOUNDRY_WORKFLOW_OF_AUTOMATION), and the use case is deleted only once its workflow is, which keeps it and its runs as history; deleting the workspace finishes the open ones unassessed. A grantee of source grants sees none of these use cases, their runs or their insights, as it sees no workflow: a workflow runs with its owner's access, so its runs may speak of sources the grantee wasn't granted. The use case's client token is its own, never one a person's use case can take. Workflows' and their runs' reads carry their ontologies (FoundryAutomation.ontologies, FoundryAutomationRun.ontologies), use cases their workflow (FoundryWorkflow.automation, FoundryWorkflowRun.automation_run_id), and insights count a workflow's runs apart from its owner's own (FoundryWorkflowInsightSegment.automation). No RPC was added.

The new workflow page offers suggestions written for one ontology's current version (ListFoundryAutomationSuggestions, GET .../foundry/automation-suggestions?ontologyId=, api/automation_suggestions.go; package automation/suggest; tables foundry_automation_suggestions and foundry_automation_suggestion_ledger, migration 20261204000000_foundry_automation_suggestions.sql), at most 4, each a title, a prompt that only fills the composer, and an icon. The same callers as the other workflow routes. Until the Assistant has written them, and wherever it can't, they are the fallback from the version's competency questions (a weekly emailed answer to each of the first 4 with titles of their own, suggest.Fallback; none for a Definition v1). A read with no row, or one that failed an hour ago, queues a write (once per version, under the workspace's lock, 20 a workspace an hour) with the version's questions, so polls never read the version again, unless foundry.agent.enabled is off or the AI setting can't be used, and says generating while it is queued or running and was queued under 2 minutes ago. The foundry-agent-worker makes up to 3 writes at once, each under a 2-minute lease (3 claims at most); a write on the owner's own server (Ollama, an OpenAI-compatible one), whose calls the process queues, gets the setting's call timeout and renews its lease to match. A write whose version is no longer current ends failed. It reads the ontology's name, the version's types, links and questions, its generation's goal, title and connectors and the sets it reads (never data rows, every list and string capped, all of it in blocks the model is told are data), and makes one call on the workspace's extraction model (llm.NewFor, reasoning off), offering only the suggest_workflows tool and asking it to answer only by calling it, retried at most twice on an answer suggest.Parse keeps nothing of (no links, markup, ids, control or invisible format characters; titles 32 characters, prompts 400, unique), or, after a wait of 2 then 4 seconds, a refusal a retry may pass, all within 60 seconds. It writes nothing whose worst case the month's Assistant budget can't fit, and what every call spends is charged to that budget (people's pool) beside people's turns, in the ledger, whether the write ended, lost its lease or was cut short by the worker's stop (which leaves the row to its lease, unless the answer was in). The ledger also counts the hour's queues, and stays when rows go with their ontology. Rows go with their ontology and the workspace's work. A host registers the method in its authorization.

The MCP lists and gets workflows and their runs (helix_foundry_list_workflows, helix_foundry_get_workflow, helix_foundry_list_workflow_runs, helix_foundry_get_workflow_run) and prepares create_workflow, update_workflow, pause_workflow, resume_workflow, delete_workflow and run_workflow, which the Assistant prepares as cards too. A host that runs workflows registers the new FoundryService methods in its authorization, runs the worker where integration.SessionHost is provided, and calls PauseFoundryAutomationsOf in the transaction that removes a member.

Agent integrations

integration/ owns the Foundry MCP tool handlers and the ordinary HTTP Ask routes. It imports public Foundry contracts only. Hosts supply identity/authorization callbacks, database provisioning, durable confirmations and audit logging. Hosted Helix wires it into mcpinsights; the standalone binary registers it on its existing REST listener. Both use the existing API, question queue and workers.

HTTP clients POST /v1/ontologies/{ontologyId}/ask with a bearer, Idempotency-Key and {"question":"..."}, then GET the response's Location while it returns 202. Each call waits at most 25 seconds for a terminal question. A 200 includes status and the compact MCP result; it may be cannot_answer, failed or cancelled. Client disconnects do not cancel durable questions. See the OpenAPI contract, the Python tool and local setup.

The standalone install's confirmation table uses the directory's separate migration sequence. Hosted continues using its existing confirmation RPCs. Local setup supports connectors and documents, with API sources still disabled. local/compose.yaml publishes the install's listener on the host's loopback (FOUNDRY_MCP_PORT moves it): the Assistant's helper on the owner's computer reaches Foundry there, outside Docker. MCP, HTTP Ask and the helper's routes on it answer only for loopback, host.docker.internal and the host of local.site_origin, and refuse cross-origin requests; the site's routes are limited by the token, the helper's by tokens of their own.

Release the shared module first, then pin that commit in hosted Helix's Go/Bazel dependencies. For development across both checkouts, an untracked Go workspace can include each backend module; this does not replace the published module pin for CI. Hosted HTTP exposure uses foundryAskHTTP.enabled on the existing MCP ingress, enabled in development and disabled by default. No new DNS, TLS certificate, worker or ontology-agent release is needed. Publish immutable backend/site images and update the local Compose pins after testing. Roll back image pins or disable the HTTP ingress flag; retain existing volumes and the additive local confirmation table.