vellum-assistant / gateway
AGENTS.md1.4k starsChanged 5 months agoMITView on GitHub
All inbound HTTP endpoints — APIs, webhooks, OAuth callbacks, or any route that receives requests from the internet — MUST be routed through the gateway (gateway/). Never add ingresses, routes, or listeners directly to the daemon runtime (assistant/). Why: the gateway is the single point of ingress, handling TLS termination, auth, rate limiting, and routing. Exposing the daemon directly bypasses these protections and breaks the deployment model. Provider webhook payloads (Telegram, WhatsApp, Slack, email/Resend, …) are untrusted external input. Parse…
Trending
More talk lately.thin dataabout the whole repository
Who's talking about vellum-ai/vellum-assistant
- @githubfeed.bsky.social“🚀 GitHub Intelligence Drop project-golem (JavaScript • 🟢) ⭐ 592 → …”Bluesky · May 13, 2026 · 1 likes
- sudosubin/agents.nix“agent-plugins.github.vellum-ai.vellum-assistant: init at 0.12.6”GitHub · Oct 4, 2026
- sudosubin/agents.nix“agent-skills.github.vellum-ai.vellum-assistant: init at 0.12.6”GitHub · Oct 4, 2026
- awesome-selfhosted/awesome-selfhosted-data“Add Vellum”GitHub · Sep 15, 2026
- janhq/awesome-local-ai“Add Vellum personal AI assistant”GitHub · Sep 15, 2026
The biggest 5 of 14 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 14
Talked about on GitHub and Bluesky (14 times).
On GitHub · 13
- Oct 4, 2026agent-plugins.github.vellum-ai.vellum-assistant: init at 0.12.6 — sudosubin/agents.nix0 reactions
- Oct 4, 2026agent-skills.github.vellum-ai.vellum-assistant: init at 0.12.6 — sudosubin/agents.nix0 reactions
- Sep 15, 2026Add Vellum — awesome-selfhosted/awesome-selfhosted-data0 reactions · 3 comments
- Sep 15, 2026Add Vellum personal AI assistant — janhq/awesome-local-ai0 reactions
- Sep 15, 2026Add Vellum personal AI assistant — mihaiwillberich/awesome-desktop-ai-assistants0 reactions
8 more on GitHub
- Sep 15, 2026Add Vellum personal AI assistant — punkpeye/awesome-mcp-clients0 reactions
- Sep 15, 2026Add Vellum personal AI assistant — elyase/awesome-personal-ai-assistants0 reactions
- Sep 14, 2026Add Vellum to alternatives and comparison table — T31K/awesome-openclaw-alternatives0 reactions
- Aug 26, 2026feat: send a canned denial when the gateway refuses a sender — vellum-ai/imessage0 reactions
- Aug 24, 2026feat: pick the iMessage provider from a dropdown — vellum-ai/imessage0 reactions
- Aug 24, 2026feat: add Linq as a selectable iMessage provider — vellum-ai/imessage0 reactions
- Aug 14, 2026feat: engine settings, Lightpanda, and a plugin browser skill — vellum-ai/browser0 reactions
- Aug 2, 2026vellum-ai — Viktor6886/evaself0 reactions
On Bluesky · 1
- May 13, 2026🚀 GitHub Intelligence Drop project-golem (JavaScript • 🟢) ⭐ 592 → https://github.com/Arvincreator/project-golem vellum-assistant… — @githubfeed.bsky.social1 likes and repost
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository96 other files it gives its agents.
- AGENTS.mdAGENTS.md
- assistant/AGENTS.mdAGENTS.md
- cli/AGENTS.mdAGENTS.md
- clients/AGENTS.mdAGENTS.md
- skills/AGENTS.mdAGENTS.md
- assistant/CLAUDE.mdCLAUDE.md
- gateway/CLAUDE.mdCLAUDE.md
- skills/assistant-migration/references/claude.mdCLAUDE.md
- add-mcp-integrationSkill
- cli-testingSkill
- releaseSkill
- updateSkill
- vellum-boundary-guardSkill
- vellum-change-reviewSkill
- vellum-feature-flag-rolloutSkill
- vellum-migration-checklistSkill
- vellum-pr-readinessSkill
- vellum-skill-authoringSkill
- vellum-test-selectionSkill
- vellum-user-facing-copySkill
- amazonSkill
- api-mappingSkill
- assistant-migrationSkill
- chat-complex-documentsSkill
- chatgpt-importSkill
- cli-discoverSkill
- conversation-launcherSkill
- daily-briefingSkill
- deepgram-voiceSkill
- deploy-fullstack-vercelSkill
- discord-app-setupSkill
- doordashSkill
- elevenlabs-voiceSkill
- email-setupSkill
- fish-audioSkill
- frontend-designSkill
- geo-auditSkill
- geo-writingSkill
- gmailSkill
- gmail-triggerSkill
- google-calendarSkill
- guardian-verify-setupSkill
- headless-claude-codeSkill
- inbox-cleanupSkill
- inbox-managementSkill
- influencerSkill
- linear-app-setupSkill
- llm-cost-optimizerSkill
- llm-provider-setupSkill
- macos-automationSkill
- mailgun-setupSkill
- mcp-setupSkill
- meme-generatorSkill
- memory-corpus-ingestSkill
- notificationsSkill
- notionSkill
- oura-setupSkill
- ouraSkill
- outlook-calendarSkill
- outlookSkill
- The first 60 shown.
The file
We split this AGENTS.md into the rules it gives an agent
6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 5
All inbound HTTP endpoints — APIs, webhooks, OAuth callbacks, or any route that receives requests from the internet — MUST be routed …
- Very specific: line 29
All assistant API requests from clients, CLI, skills, and user-facing tooling MUST target gateway URLs.
- Distinctive: line 33
Migration rule: If a needed endpoint is not available at the gateway, add a gateway route/proxy first, then consume it.
- Very specific: line 118
No barrel files: Do not add an index.ts that re-exports siblings.
- Very specific: line 202
Adding a new exempt channel: update ADMISSION_POLICY_EXEMPT_CHANNELS in packages/gateway-client/src/admission-policy-contract.ts AND …
- Very specific: line 245
Adding a capability: add the field to CapabilitySet + the three class records (GUARDIAN_CAPABILITIES, CONTACT_CAPABILITIES, …
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Gateway — Agent Instructions
Public API / Webhook Ingress
All inbound HTTP endpoints — APIs, webhooks, OAuth callbacks, or any route that receives requests from the internet — MUST be routed through the gateway (gateway/). Never add ingresses, routes, or listeners directly to the daemon runtime (assistant/).
Concretely:
- Define new routes in the gateway and have the gateway forward requests to the assistant over the internal HTTP transport.
- The gateway's public URL is controlled by the public ingress URL setting. All externally-facing URLs you generate or advertise (callback URLs, webhook registration URLs, etc.) must be derived from this setting — never hardcode a hostname or port.
- The daemon should remain unreachable from the public internet. It only receives traffic from the gateway over the internal network.
- Webhook handlers must read request bodies via
readLimitedBody()/readLimitedBodyBytes()(gateway/src/http/read-limited-body.ts), which enforcemaxWebhookPayloadByteson the actual streamed bytes. Never callreq.text()/req.json()/req.formData()directly on unauthenticated ingress — the Content-Length header is attacker-controlled and absent on chunked requests, so a header-only guard can be bypassed up to the server-widemaxRequestBodySize.
Why: the gateway is the single point of ingress, handling TLS termination, auth, rate limiting, and routing. Exposing the daemon directly bypasses these protections and breaks the deployment model.
Provider Webhook Payload Validation
Provider webhook payloads (Telegram, WhatsApp, Slack, email/Resend, …) are untrusted external input. Parse them with tolerant Zod schemas co-located in the provider module — a normalize.ts, a dedicated schemas file (slack/message-schemas.ts), or the webhook route where normalization is split — never trust a blanket as / as unknown as cast off JSON.parse.
- Schema-first, co-located. Define the schema in a module co-located with the normalizer(s) that consume it and derive the type with
z.infer(single source of truth). These input schemas stay local to the provider directory — do not hoist them topackages/gateway-client(that package is for schemas that cross the gateway↔daemon↔web wire, e.g. the normalizedGatewayInboundEventoutput). - Tolerant, not strict. Validate each field's type but
.optional().catch(undefined)it so a malformed field collapses rather than rejecting the whole payload; the existing downstream null-checks then drop an unprocessable message. Require only the fields the normalizer actually keys on (identity / dedup).safeParseat the boundary and drop-or-acknowledge malformed input individually, so one bad message can't crash a batch. receivedAtis the gateway's wall clock (new Date().toISOString()), never a provider-supplied timestamp — routing an untrusted time intonew Date()is a crash class, and receipt time is the correct semantic anyway.- Preserve
raw. In a direct normalizer, keep the original payload verbatim on the event (raw: payload); only the parsed working copy is schema-shaped. Split-normalization paths that first map the provider payload onto a shared canonical shape (the email family — email/Resend/Mailgun →VellumEmailPayload) carry that canonical payload asraw, by the email channel's design.
Reference implementations: telegram/normalize.ts (plus a compile-time cross-check against the @grammyjs/types dev dependency), whatsapp/normalize.ts, http/routes/resend-webhook.ts, and the slack/ module — schemas in slack/message-schemas.ts (cross-checked against @slack/types), with normalizers split by event family (see Module Organization).
Gateway-Only API Consumption
All assistant API requests from clients, CLI, skills, and user-facing tooling MUST target gateway URLs. Never construct URLs using the daemon runtime port (7821) or RUNTIME_HTTP_PORT for external API consumption.
Exception boundary: The gateway service itself may call the runtime internally. Tests may use direct runtime URLs for isolated unit/integration scenarios. Intentional local daemon-control paths (e.g. health probes) are exempt; the authoritative allowlist lives in assistant/src/__tests__/gateway-only-guard.test.ts.
Migration rule: If a needed endpoint is not available at the gateway, add a gateway route/proxy first, then consume it. Do not work around a missing gateway endpoint by hitting the runtime directly.
Ban on hardcoded runtime hosts/ports: Do not embed localhost:7821, 127.0.0.1:7821, or runtime-port-derived URLs in docs, skills, or user-facing guidance. Always reference gateway URLs instead. A CI guard test (gateway-only-guard.test.ts) enforces this — any new direct runtime URL reference in production code or skills will fail CI.
SKILL.md retrieval contract: For config/status retrieval in bundled skills, use bash + canonical CLI surfaces. Start with assistant config get for generic config keys and secure credential surfaces (assistant credentials, assistant keys) for secrets. Do not use direct gateway curl for read-only retrieval paths. Do not use credential store lookup commands (security find-generic-password, secret-tool) in SKILL.md. host_bash is not allowed for Vellum CLI retrieval commands unless a documented exception is intentionally allowlisted.
SKILL.md proxied outbound pattern: For outbound third-party API calls from skills that require stored credentials, default to bash with network_mode: "proxied" and credential_ids instead of manual token/credential store plumbing. This keeps credentials out of chat and enforces credential policies consistently.
SKILL.md gateway URL pattern: For gateway control-plane writes/actions that are not exposed through a CLI read command, use $INTERNAL_GATEWAY_BASE_URL (injected by bash and host_bash). Do not hardcode localhost/ports in skill examples, and do not instruct users/agents to manually export the variable from Settings. For public ingress URLs (e.g. OAuth redirect URIs, webhook registration), use assistant config get ingress.publicBaseUrl or load the public-ingress skill — do not inject public URLs as environment variables.
Control-Plane Route Shapes — Clients Emit Scoped, Boundaries Strip to Flat
Clients always emit assistant-scoped URLs (/v1/assistants/{id}/...) — multi-tenant cloud routing needs the id. A single-assistant boundary strips the prefix before the gateway routes the request:
- Cloud/managed: the platform's Django
RuntimeProxyViewstrips/v1/assistants/{id}/and forwards the flat path to the gateway. - Self-hosted (macOS Electron / local / remote gateway):
rewriteForSelfHostedIngress(clients/web/src/lib/api-interceptors.ts) flattens contact-family paths (contacts,contact-channels) to the same flat shape; every other segment is forwarded scoped, verbatim.
Route-registration consequences (gateway/src/index.ts):
- Contacts (
/v1/contacts...,/v1/contact-channels...) are served on flat routes only — both boundaries deliver flat, so no assistant-scoped contact mirrors exist. The self-hosted flattening covers the entirecontacts/contact-channelssegment family, not just the CRUD writes: invites requests land on the gateway's flat edge-scoped invite routes (the same gateway invite engine the daemon relays to), and daemon-only subpaths (contacts/search,contacts/prompt) match no flat registration and fall through the runtime-proxy catch-all to the daemon verbatim. - Other control-plane families (channel-admission-policy, channel-permission-overrides, trust-rules, backups) register flat + assistant-scoped variants: the self-hosted rewrite forwards their paths verbatim, so a scoped mirror must catch that traffic. These stores are gateway-global — the scoped variant matches and discards the id.
- Invariant: never remove a flat gateway control-plane route. Cloud's prefix strip means the flat family is the load-bearing production path even when repo-local clients appear to emit only scoped URLs. The flat channel-admission-policy routes were removed once on that mistaken theory (
2fb435314f) and had to be restored before #35150 merged (53fcfa7cc2re-added the schema entries the removal took out); both commits are squashed out ofmain's history, so they resolve on GitHub and not in a clone.
Trust Management in Docker Mode
In Docker mode, the gateway is the sole owner of trust rule storage. Trust files (trust.json, actor-token-signing-key) live on the gateway security volume (/gateway-security), configured via GATEWAY_SECURITY_DIR. No other container has access to this volume.
The assistant reads and writes trust rules via the gateway's HTTP trust API instead of accessing the filesystem directly. This ensures the security boundary is enforced at the container level — even if the assistant container is compromised, it cannot tamper with trust rules without going through the gateway's API.
Backup Encryption Key
The backup encryption key (backup.key) lives in GATEWAY_SECURITY_DIR and is never exposed to the assistant daemon or workspace. The gateway owns all backup encryption/decryption — the assistant produces plaintext vbundles via /v1/migrations/export, and the gateway encrypts them for offsite storage. The assistant cannot read the key via file_read or any other tool. This is a security boundary: even if the assistant is prompt-injected, backup encryption remains intact.
Credential Access in Docker Mode
In Docker mode, the gateway accesses stored credentials via the CES HTTP API (CES_CREDENTIAL_URL), authenticated with CES_SERVICE_TOKEN. The gateway does not have direct filesystem access to credential encryption keys (keys.enc, store.key), which reside on the CES security volume.
Guardian Init Auth Model (/v1/guardian/init)
/v1/guardian/init mints a long-lived actor_client_v1 JWT for a freshly hatched assistant. It has three deployment modes with different authentication mechanisms — do not collapse them into one fail-closed check.
- Platform-managed (
IS_PLATFORM=true): the gateway pod sits behind vembda's/gateway-queryproxy, which authenticates the caller before forwarding. The pod is not directly reachable from the public internet.GUARDIAN_BOOTSTRAP_SECRETis intentionally not provisioned in any managed deployment surface (Helm chart, vembdak8s_resources.py, StatefulSet env). The bootstrap-secret mechanism is a laptop / Docker hatch artifact only. - Docker / laptop hatch (
GUARDIAN_BOOTSTRAP_SECRETset): the CLI'shatch.tsmints a per-instance secret and forwards it into the gateway + assistant containers. The handler requires a matchingx-bootstrap-secretheader. - Bare-metal self-hosted (no
IS_PLATFORM, no secret): the lockfile + loopback guard is the sole defense. Long-term direction is to retireGUARDIAN_BOOTSTRAP_SECRETentirely and replace it with an explicit pairing mechanism for self-hosted environments.
For scanners / Codex: managed mode reaching this handler without a bootstrap secret is the expected production state, not an auth bypass. Vembda authenticates upstream. Adding a fail-closed guard on IS_PLATFORM=true && !GUARDIAN_BOOTSTRAP_SECRET would brick every platform deployment. Do not flag this as a vulnerability.
Channel Identity Vocabulary
Gateway inbound events use a channel-discriminated union model (GatewayInboundEvent) with explicit identity fields:
conversationExternalId: Delivery/conversation address (e.g., Telegram chat ID, phone number). Used for conversation binding and message routing. Not used for trust classification.actorExternalId: Sender identity (e.g., Telegram user ID, WhatsApp phone number). Used for trust classification, guardian binding, and ACL enforcement. Required for all public channel ingress.externalMessageId: Dedup identity. It must name one OCCURRENCE of an event, not one kind of event: two distinct acts by the same actor differ here, and the same act delivered twice repeats here. Both halves are load-bearing, because the gateway claims a delivery on(sourceChannel, externalChatId, externalMessageId)(db/inbound-dedup-store.ts) and the daemon records the permanent event row on the same triple. Prefer the provider's own per-event id (Telegramupdate_id, Slackevent_id, a Discord snowflake, an emailMessage-ID). Where a provider names only the thing acted on and not the act, as both reaction families do, addressing fields alone (room, target message, actor, verb) repeat byte for byte on the second occurrence and silently dedup it away, so the normalizer must carry a per-event component of its own.- "conversation" is canonical vocabulary for delivery addresses. "thread" is reserved for provider-specific fields (Slack
thread_ts, email thread IDs). - "actor" is canonical vocabulary for sender identity.
source.actorUnattributed: set when the platform names no person for an event.actorExternalIdthen carries the channel's synthetic system id (discord-system,slack-system) and is not an identity claim: the gateway seeds no contact from it, and the runtime's ACL neither resolves a member nor denies, applying the event only to a row the daemon already holds for that chat. Only event kinds that cannot start a turn may carry it; today that is the delete family (Discord names no author; Slack names the author, never the deleter, and the author may be the assistant itself). Theno_onekill switch still applies, since it keys on the policy alone.
Trust/guardian decisions must be keyed on actorExternalId only — never fall back to conversationExternalId for actor identity.
Room admission is one verdict, two adapter halves. Whether the gateway acts on an inbound message at all is decided by channels/room-admission.ts over a neutral candidate: self and bot authors drop first, a direct chat is admitted on its own lane without a mention, a room only when the message addresses the bot, a chat kind the product does not serve is refused, and an unknown bot identity drops rather than admits. Each channel builds the candidate from its own facts (discord/admit.ts, telegram/admit.ts): how the platform proves a chat is direct (guild absence, chat.type) and how it proves a message is addressed (a mentions array, text entities, a reply to the bot's post). Extend the verdict, never a copy of it; a platform-only rule rides a neutral fact (Discord's legacy allow-list is roomAllowed). A drop is never silent: every channel logs it through channels/admission-drop-log.ts, one promoted line per reason and conversation, with a drop that names no conversation promoted every time. Slack's socket filter predates this and still carries the same rules inline; converging it is queued with the Slack envelope work.
Physical DB column names (externalUserId, externalChatId) are unchanged; the rename is at the API/type layer only.
Provider words that are not our words. A Discord guild is what Discord's
own UI calls a server; the word survives only in its API (guild_id, the
guilds OAuth scope). Use it when naming what the API returns, and use
"server" in anything a person reads: UI copy, setup instructions, error
messages, notification text. The same rule covers any provider term its own
product does not show users.
guild_id also carries meaning past naming. Discord ingress reads its absence
as "this is a DM" (discord/admit.ts), so a parse that collapses a malformed
value to undefined would admit a public channel through the DM branch. Read
the comments there before changing how the field is parsed.
Module Organization
Organize gateway code by concern, not by technical layer — group by what code does, not what it is. This mirrors the web client's rule (clients/web/docs/CONVENTIONS.md → "Organize by domain, not technical layer"), which is the fuller treatment of the shared principles; the gateway-specific shape:
- Provider ingress lives under
src/<provider>/(slack/,telegram/,whatsapp/,email/, …). Each provider directory is a domain module — organize within it by concern rather than piling everything into onenormalize.ts:- Directory / IO layer — stateful clients and caches that call the provider's authenticated Web API. Example:
slack/user-directory.ts(users.info/conversations.inforesolution with an LRU cache and in-flight de-duplication). This layer reads a trusted API, distinct from untrusted-ingress normalization. - Pure helpers — one file per concern (e.g.
actor.ts,attachments.ts,render-text.ts): input→output functions with no module-level state or I/O. - Schemas & types — the tolerant Zod ingress schemas (see Provider Webhook Payload Validation above), their
z.infertypes, and any compile-time cross-checks against the provider's official types. - Normalizers — split by event family, each turning a validated event into the canonical
GatewayInboundEvent.
- Directory / IO layer — stateful clients and caches that call the provider's authenticated Web API. Example:
- No barrel files. Do not add an
index.tsthat re-exports siblings; import from the source file directly. - No single-file directories. A directory holding exactly one file should be flattened up a level — directories organize multiple files.
- Split by concern, not by line count — but a file that has grown to span multiple concerns (past a few hundred lines) is the signal to extract, not to keep appending.
The slack/ module is the worked example of this shape.
Long-Lived Channel Transports Own Their Liveness
A channel that holds a persistent socket (Discord Gateway, Slack Socket Mode)
must be able to conclude on its own that its connection is dead, and recover,
without waiting for a close event. A half-open socket, the shape a NAT rebind
or a vanished peer leaves behind, reports itself OPEN indefinitely and fires
nothing at all: no message, no error, no close. Recovery that waits to be told
never runs.
Three things are required, and a transport missing any one of them has a silent multi-hour outage in it:
- A liveness signal the transport generates itself. Inbound quiet proves
nothing, because a quiet workspace and a dead socket are indistinguishable.
Discord rides its protocol heartbeat and tracks the ACK
(
discord/heartbeat.ts). Slack Socket Mode has no application-level heartbeat, so it probes the transport directly with a WebSocket ping frame and requires a pong (slack/socket-liveness.ts). Prefer a probe you send over a timeout you wait out. - A bound on the pre-established window. A handshake that stalls produces
neither
opennorclose, so it falls outside any watchdog that arms on a live connection. SeeHELLO_DEADLINE_MS(Discord) andCONNECT_DEADLINE_MS(Slack). - Teardown that does not wait on a close event. Recovery closes the dead
socket and proceeds on a timer whether or not the close ever lands. See
killAndRecover(Discord) andforceReconnect(Slack).
Derive every threshold from something measured, and record the derivation in the constant's docstring. A number chosen to feel safe against expected traffic will be wrong: Socket Mode connections were assumed to rotate about hourly, and were then observed rotating several hours apart, which is exactly the kind of assumption an inbound-silence threshold would have been built on.
The process-wide SleepWakeDetector is not a substitute for any of this. It
fires only when the whole process was suspended, so it misses every connection
that dies while the gateway is healthy and logging normally.
Channel Trust Classification & Admission Policy
The gateway owns per-channel AdmissionPolicy storage (gateway/src/db/admission-policy-store.ts, HTTP in gateway/src/http/routes/channel-admission-policy.ts) and attaches the floor to every forwarded inbound via sourceMetadata.admissionPolicy. The runtime (assistant/src/runtime/routes/inbound-stages/admission-policy.ts) emits admitted: true | false based on TRUST_CLASS_RANK[trustClass] >= ADMISSION_FLOOR[policy].
A default row per enforced channel is seeded at startup (seedAdmissionPolicyDefaults in gateway/src/db/seed-admission-policy.ts) — trusted_contacts for every channel except vellum (guardian_only). Per-channel defaults live only in that seed; the store/cache fall back to ADMISSION_POLICY_DEFAULT (trusted_contacts) only if a row is somehow absent.
5 policies, ranked floors (seed default trusted_contacts):
| Policy | Floor | Notes |
no_one | 5 | Hard-deny at gateway before forwarding (kill switch in handle-inbound.ts). Includes the guardian — this channel is OFF. |
guardian_only | 4 | Seeded default for vellum and vellum-shared. |
trusted_contacts | 3 | Seeded default for all other channels; also the read-path safety fallback. |
any_contact | 2 | May surface Slack DM / email upgrade challenge on deny. |
strangers | 1 | May surface upgrade challenge. |
Exempt channels (no policy ever applies — gateway AND runtime both short-circuit):
platform— internal platform control plane.a2a— assistant-to-assistant peer traffic (out of human-trust model).
phone is now an enforced channel (voice ingress reads the policy): it seeds the universal default trusted_contacts and accepts PUT like other enforced channels.
For exempt ids, PUT /v1/assistants/:id/channel-admission-policy/:channelType returns 403, the GET list omits them, and the runtime short-circuits admitted: true in admission-policy.ts (defense in depth). Codex finding from #35006 review: exemption checks must live in both the gateway route handler AND the runtime stage — single-side enforcement creates a misuse wedge.
Hidden channels (ADMISSION_POLICY_HIDDEN_CHANNELS = vellum, vellum-shared, whatsapp): managed automatically, not user-configurable, but (unlike exempt channels) still enforced at runtime:
- The GET list omits them, and
PUT/DELETEreturn 403 (isAdmissionPolicyHiddenChannel). - They are not exempt — the runtime still evaluates rank-vs-floor, so a real inbound channel like
whatsappkeeps its admission floor. - Their floor is pinned to the seed default;
seedAdmissionPolicyDefaultsoverwrites any drifted/legacy row at startup (e.g. a stalewhatsapp = no_one), so a stranded floor can't silently block a channel the user can no longer see or reset. The guardian is always max-rank onvellum, so itsguardian_onlyseed default never locks them out — there is nono_onepicker or 422 kill-switch path for hidden channels.
Both the flat (/v1/channel-admission-policy/...) and assistant-scoped (/v1/assistants/:id/channel-admission-policy/...) route variants are registered. The flat routes carry all cloud traffic — the platform strips the scoped prefix before forwarding — and must never be removed (see "Control-Plane Route Shapes" above). Admission policy is gateway-global, so the scoped variant matches and discards the id.
Split enforcement (locked decision):
- Gateway kill switch —
handle-inbound.tsenforces theno_onefloor before forwarding. Zero contact-table lookups, zero daemon I/O, true kill. - Runtime floor — every other policy flows through the gateway unchanged; the runtime evaluates rank-vs-floor inside
admission-policy.ts. This keeps the canonical gateway classifier (gateway/src/risk/trust-verdict-resolver.ts) as the single source ofTrustClasstruth (no fork): the runtime consumes the stamped verdict; the daemon'sactor-trust-resolver.tsis only a residual sync guardian-or-unknown view for the vellum reset-drift path. - Gateway vs runtime reciprocity: this section records which channels the gateway enforces; the runtime's evaluation lives in
assistant/src/runtime/routes/inbound-stages/admission-policy.ts, which readsTRUST_CLASS_RANKandADMISSION_FLOORfrom the shared contract. Either side getting out of sync is a bug, not an over-defended boundary.
Adding a new policy: extend the AdmissionPolicy union in packages/gateway-client/src/admission-policy-contract.ts, add its floor in ADMISSION_FLOOR, update the openapi schema, and update gateway/src/__tests__/channel-admission-policy-routes.test.ts + assistant/src/runtime/routes/inbound-stages/admission-policy.test.ts. Do not add a 6th floor without also bumping the TRUST_CLASS_RANK ceiling to match.
Adding a new exempt channel: update ADMISSION_POLICY_EXEMPT_CHANNELS in packages/gateway-client/src/admission-policy-contract.ts AND EXEMPT_CHANNEL_TYPES in gateway/src/db/admission-policy-store.ts. The gateway route (403), GET-list omission, runtime short-circuit, and seed-skip all read from these — symmetric enforcement is required so a stray runtime call (test harness, internal IPC) can't bypass the floor.
Hiding a channel from the UI (still enforced): add it to ADMISSION_POLICY_HIDDEN_CHANNELS in packages/gateway-client/src/admission-policy-contract.ts (and the web mirror HIDDEN_CHANNELS in clients/web/src/lib/channel-admission-policy/types.ts). The GET-list omission, PUT/DELETE 403, and seed re-pin all read from this set. Use this — not the exempt set — for a channel that must keep enforcing a floor but should not be user-configurable, so its admission check is never short-circuited.
Channel Permission Matrix (cells: cascade key × contact-type → RiskThreshold)
The gateway owns channel-permission matrix storage (gateway/src/db/channel-permission-store.ts, table channel_permission_overrides, IPC in gateway/src/ipc/channel-permission-handlers.ts). Each cell maps a cascade selector × contact-type (trust class) to a RiskThreshold (none | low | medium | high; the Strict/Conservative/Relaxed/Full-access presets are the web presentation layer over these values).
- Cascade, least → most specific:
workspace→adapter→channel_type(dm | private | public) →channel(external channel ID).ChannelPermissionStore.resolve()walks most-specific-first and returns the first cell set for the contact-type. - Vocabulary contract:
packages/gateway-client/src/channel-permission-contract.ts(selectors, thresholds, scopes, resolve request). The contact-type axis is the canonicalTrustClass— granularity intentionally stops there; do not add per-individual-contact cells. - IPC surface:
list_channel_permission_overrides,set_channel_permission_override,delete_channel_permission_override,resolve_channel_permission_threshold. Writes validate the adapter against the gateway channel registry. - HTTP surface (configuration clients):
GET/PUT /v1/channel-permission-overrides+POST /v1/channel-permission-overrides/delete+POST /v1/channel-permission-overrides/resolve(gateway/src/http/routes/channel-permission-overrides.ts), published in the gateway OpenAPI spec for the web SDK. Mirrors the IPC list/set/delete/resolve with the same contract schemas and adapter validation. Resolve over HTTP is read-only (settings.read) and exists so configuration clients can display the effective fall-through without re-implementing the cascade walk client-side (which drifts as the cascade evolves); the runtime evaluator keeps using the IPC resolve. Flat + assistant-scoped variants,settings.read/settings.writescopes: same shape as channel-admission-policy. - Migration provenance:
m0012-migrate-slack-channel-permissionslifts Slack-skillchannelPermissionsprofiles withtrustLevel: "restricted"into channel-scoped Strict cells (non-guardian contact-types). Per-tool fields (blockedTools/allowedToolCategories) have no matrix representation — they stay in the Slack skill config, enforced by the legacy deterministic channel gate inassistant/src/tools/tool-approval-handler.ts. - Runtime consumption (per-tool-call evaluation): the assistant's permission checker (
assistant/src/permissions/checker.ts) builds a resolve query from the turn'sPolicyContext(adapter = source channel, conversation type, external channel ID, contact-type = trust class) and threads it into the threshold cascade inassistant/src/permissions/gateway-threshold-reader.ts. The cell sits between the per-conversation override (most specific) and the global defaults; the winning threshold feedsDefaultApprovalPolicy.evaluateasautoApproveUpTo, composing cell RiskThreshold × tool RiskLevel with the untouched capability floor (resolveSensitiveToolDecision). Fail-safe semantics: a cell transport failure falls through to global on the cached read, but the pre-prompt refresh keeps its prompt (returns null) rather than falling through to a possibly-looser global. Slack statesconversationTypefor every room it can classify (slackConversationVisibilityingateway/src/slack/message-normalizer.ts: a public channel ispublic, a private channel or group DM isprivate, a DM isdm), so thechannel_typetier matches Slack rooms as well as DMs.
Trust Classes → Capabilities (what an actor may do)
Two orthogonal axes, do not conflate them:
- Admission (above) — who gets in the door.
TRUST_CLASS_RANKvsADMISSION_FLOOR, enforced across gateway + runtime. - Capabilities — what an actor may do once admitted. Resolved in the runtime, never on the gateway.
Trust classes (TrustClass in packages/gateway-client/src/trust-verdict-contract.ts; the daemon imports it and never redeclares it) are the role, ranked by TRUST_CLASS_RANK:
| Class | Rank | Meaning |
guardian | 4 | Matches the active guardian binding for this (assistant, channel). |
trusted_contact | 3 | Active contact channel, not the guardian. |
unverified_contact | 2 | Contact channel that is pending/unverified — known but not verified. |
unknown | 1 | No contact record, no identity, or blocked/revoked. Fail-closed. |
The gateway classifies the actor at ingress (keyed on actorExternalId) and forwards the resolved trustClass; it is persisted in retry payloads, the journal store, and conversation CRUD. The gateway does not compute capabilities.
Capability resolution lives in assistant/src/runtime/capabilities.ts. resolveCapabilities(trustClass) → CapabilitySet is the single fail-closed trust boundary for the "what may they do" axis, separating permissions from the raw class the way RBAC separates permissions from roles:
- Total & fail-closed. Accepts any string or
undefined; anything not a recognized class (incl. legacy strings like"non_guardian") resolves to theunknownset. The lookup uses an own-property check so inherited keys ("__proto__","constructor","toString") also fail closed. trusted_contact≡unverified_contact. They share the sameCapabilitySetobject — the distinction is admission-only. Pinned bycapabilities.test.ts.CapabilitySetfields:canSelfApproveTools,sensitiveToolApproval(self | escalate-and-wait | deny),canManageSchedules,canUseVerificationControlPlane,canSelfAuthorizeArchiveBySender,canAccessMemory,canAccessPrivilegedDocuments,canRunUnsandboxedShell,mayBeInteractive,canActUnderDiskPressureCleanup,promptTrustGuidance(none | social-engineering-defense | stranger-warning). All the booleans exceptmayBeInteractiveare guardian-only;mayBeInteractiveis also true for contacts.
How call sites use it. Read a named capability instead of re-deriving from the raw class — e.g. if (!resolveCapabilities(trustClass).canAccessMemory) skip. Context-dependent decisions compose a capability primitive with runtime context rather than encoding it in the table: resolveRoutingState uses mayBeInteractive && guardianRouteResolvable; document-tool uses canAccessPrivilegedDocuments || executionChannel === "vellum"; the self-approval race guard uses !canSelfApproveTools && <pending-row state>. The legacy isUntrustedTrustClass helper has been removed — use !resolveCapabilities(x).<cap>.
Stateless. Capabilities are derived on read from the already-persisted/forwarded trustClass; nothing capability-shaped is stored or sent on the wire.
Adding a capability: add the field to CapabilitySet + the three class records (GUARDIAN_CAPABILITIES, CONTACT_CAPABILITIES, UNKNOWN_CAPABILITIES) + the MATRIX in capabilities.test.ts. Adding a trust class: add a member to TrustClass (the Record<TrustClass, …> tables then fail to compile until every column is filled) and a matrix row.
Intentionally NOT capability-gated (these are identity / admission-flow decisions, not permissions, and stay raw class checks): calls/* guardian-identity call routing, inbound-message-handler heartbeat/timezone side-effects, surface-action-routes drift-heal re-resolution, and channel-retry-sweep trust-class parsing.
Operator CLI (gateway contacts)
The gateway package ships an operator CLI (gateway/src/cli/, bin gateway) for gateway-owned contact ACL. This is the write surface for a contact's assistant-access ceiling. Do not add that write to assistant contacts.
gateway contacts list
gateway contacts get <contactId>
gateway contacts set-risk-threshold <contactId> --threshold none|low|medium|high|inheritThe CLI talks to the running gateway over its IPC socket (set_contact_threshold, contacts_list_rich, contacts_get_rich). It does not open gateway.sqlite itself.
From the host: vellum exec --service gateway -- gateway contacts .... Do not add a vellum gateway contacts verb.
Guardian Requests (gateway-owned)
The gateway owns guardian approval requests and their delivery records: the guardian_requests and guardian_request_deliveries tables (src/db/guardian-request-store.ts), fronted by src/approvals/guardian-request-service.ts and exposed to the daemon over the guardian_requests_* IPC routes (src/ipc/guardian-request-handlers.ts; shared contract in packages/gateway-client/src/guardian-request-contract.ts). The daemon holds no request state — it relays everything through assistant/src/channels/gateway-guardian-requests.ts and keeps the daemon-domain side effects: notifications, card delivery/withdrawal, pending-interaction resume, grant minting into its scoped_approval_grants.
- Decide atomicity (the core invariant).
guardian_requests_decidecommits the status CAS (pending → approved|denied, first-writer-wins) and the decision's ACL outcome (activate_member,seed_unverified,block,mint_outbound_session) in ONE gateway transaction. A failed outcome rolls back the CAS — the request stayspendingand the guardian can decide again; anapprovedrequest without its ACL write cannot exist, and deciding twice never applies two outcomes. There is no reopen path. - Schema notes. There is no
source_typecolumn: the wire DTO'ssourceTypeis derived fromsource_channel(phone→ voice,vellum→ desktop, else channel), and the list route translates asourceTypefilter intosource_channelpredicates. The requester-side conversation issource_conversation_id. Request ids are caller-supplied and load-bearing: the interaction-promotion paths (tool_approval, andpending_questionforask_question) reuse the pending-interaction id as PK, and every other create mints a UUID (voicepending_questionrows carry their interaction id inpending_question_idinstead). The insert is strict, so a caller that can create concurrently (the escalation path runs once per sibling tool call in a turn) must mint an id unique per call. - Expiry is daemon-keyed for interaction-bound kinds.
tool_approval/pending_questionrequests die with the daemon's in-memorypendingInteractionsmap, so the daemon callsguardian_requests_expire_interaction_boundat boot; the gateway never expires them on its own restart, and the boot call never touches persistent kinds. Persistent kinds (access_request,tool_grant_request) expire via the daemon's 60s sweep:guardian_requests_list_expired_pendingreturns a bounded, read-only batch of past-deadline pending rows, the daemon runs each row's card withdrawal and requester notice, and only then confirms with the per-requestguardian_requests_expireCAS, so a lost response or crash leaves the row listed for the next round instead of stranding its side effects. The decide CAS carries anexpires_atguard, so a decision arriving past the deadline loses the arbitration atomically. - Provenance. The tables moved here from the assistant DB: gateway data migration m0015 backfilled them, and m0016 (checkpoint-gated on m0015, with a final catch-up copy) dropped the assistant-side tables.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

