ADR-182 — The bot is the unit of connection, and its setup is a read model
- Status: Proposed — the operator chose the direction on 2026-12-01 (bot-first hub, upload and push into the team store, one pull request); this record awaits acceptance with that pull request.
- Date: 2026-12-01
- Deciders: jo (the direction), Claude (the design and the measurements)
- Relates to: ADR-018 (bot-secret bindings) · ADR-147 (a bound context is a pinned source) · ADR-161 (one resolver decides the credential a call spends) · ADR-172 (forge integrations project subscriptions)
- Serves: #3973 · epic #1412
Context
In the cloud studio, connecting a bot was spread across the surfaces that own each piece of wiring.
Four entry points enabled a bot on a repository, and they disagreed:
- the bot page → a bind wizard;
- the repository page;
- the integrations page's enable panel;
- the connection card.
The wizard enabled a bot without the cron, label filter or merge gate the panel set.
Secrets and funding lived elsewhere. Secrets sat on two other tabs. Funding (which credential a launch spends) sat on the team and org pages, and nothing checked it when a bot was enabled.
The word "binding" named two things: repo↔bot in the UI, secret↔bot in the API.
A custom bot could not be uploaded in cloud. The workspace upload refuses cloud mode, and the CLI had no team push.
The operator's question was where the entry point belongs. Every step but the forge connection is a property of one bot within one team:
- where it runs (integrations whose
bot_idshold it); - what wakes it (subscriptions, schedules, webhooks against its manifest's invocations);
- what it needs (its workflow's secrets);
- what it spends (the credential preview of a launch);
- whether it ran.
No store answers "the state of this bot". Building that answer in the client costs 8–10 calls, and there is no index from a bot to its repositories.
Decision
The bot is the unit of connection.
/bots/:nameis the hub. A Setup checklist reads six steps — source, repositories, triggers, secrets, funding, first run — each with a state and the action that completes it in place.- The repository page stays a secondary entry. It opens the same add-to-repo flow, pre-filled and multi-select.
/integrationskeeps the plumbing: forge accounts, connectors, webhooks, secrets, providers.- A forge connection is offered when the flow needs one, not as a prerequisite step.
The setup is a read model over the existing stores, never a second source of truth.
GET /api/teams/{id}/bots/{bot_id}/setupfolds integrations, connections, triggers, schedules, webhooks, bindings, team secrets, the credential preview and the run index into per-step states (ok | attention | missing | unknown | n/a).- It stores nothing. It reads the team in the path. It unseals nothing (secrets match by name). Each step is bounded on its own, and a source that fails reads
unknown, neverok. GET /api/teams/{id}/bots/setup-summaryfolds the same stores once for the list.- A new surface (CLI
iterion remote bots setup, MCP throughremote_api, a bot) reuses these endpoints instead of re-deriving the state.
A fact the read model shows travels with the result that produced it. It is not reconstructed from text.
- The credential preview now carries its funding refusal as a typed field (
CredentialPreview.Refusal), not only as a warning sentence. - "Calls a model" is asked of the workflow (
UsesLLM), not inferred from the preview's wires, which exist only for selected candidates.
- The credential preview now carries its funding refusal as a typed field (
A custom bot enters the team bot store by the editor's write path.
POST …/bot-sources/{slug}/importtakes a.botzor a folder (raw parts).- Both are read by
botsource.ReadBundleDir, the one definition of what a bundle contains, then compiled before they persist. iterion remote bots pushwrites the same store from the CLI.- An existing bot is replaced only on an explicit request, pinned to the version read.
Options considered
- Keep the integrations page as the entry and clean it up. It was the least work. Rejected: secrets and funding are per bot and would stay outside the flow.
- Bot-only: remove the repository entry. It was the lightest. Rejected: an administrator connecting a repository and putting three bots on it would lose the multi-select.
- Compute the setup in the studio. It needed no server work. Rejected: it costs 8–10 calls per view, has no bot→repositories index, and a CLI or MCP caller would re-derive the state.
- A bot linked to a git repository and re-synced on push. It is the most git-native option. Deferred: it is a new sync mechanism (webhook, conflicts with web edits) and belongs in its own record.
Consequences
- One flow enables a bot on a repository. The settings the old panel set — cron, label filter, merge gate, the existing-integration append rule — are now the only rules. The bind wizard and the enable panel are gone, and their URLs redirect into the flow.
- The setup state is only as right as the stores and resolvers it reads. A new kind of wiring (a trigger source, a credential tier) must be folded into its step, or the step under-reports. The setup tests pin each state rule.
- The read model answers for the caller's launch on funding, as the credential preview does. Two members can see different funding states for the same bot.
- The summary leaves secrets and funding out (
partial): each would cost a compile per bot. - The bot store stays text-only. A binary file in an upload is refused by name.
Open questions
- An index from a bot to its integrations, webhooks and schedules (
(tenant_id, bot_ids)), if team sizes make the per-team scan visible. GET /api/runs?bot=loads a team's whole run history because the bot filter is evaluated in Go (#3974). The read model bounds itself with a 30-day window meanwhile.
