# Governed outbound connectors

Connect your Ferrite applications and embedded agents to GitHub, Google, Linear, and Slack using scoped capability grants, digest-bound write approvals, and a resident credential vault.

When an application or embedded agent needs to read issues, update documents, or post messages in external SaaS tools, handing raw OAuth tokens directly to application code creates an uncontrolled credential boundary. Ferrite separates provider credentials from application code through **governed outbound connectors**: the resident Connector Hub holds the provider OAuth tokens, while your application composes the `gatekeeper` contract and typed provider packages (`connector-github`, `connector-google`, `connector-linear`, `connector-slack`) to call external services through expiring capability grants and digest-bound write approvals.

## Add a connector package

Install the provider package you need. Installing any provider package automatically installs its `gatekeeper` contract dependency under your application's `src/` tree while keeping `Cargo.toml` at a single crate dependency (`ferrite-app`):

```bash
ferrite add connector-github
ferrite add connector-google
ferrite add connector-linear
ferrite add connector-slack
```

Each provider package exposes typed read and write operations plus an in-memory fixture backend so every permission rule, approval flow, and failure path can be tested deterministically with `ferrite test`.

## Wire the Connector Hub binding and grant

To call a live Connector Hub from a deployed application, declare a `connectors-egress` binding in `ferrite.json` and bind a write-only secret handle carrying the scoped connector grant (default handle `ferrite_connector_grant`; use distinct handles if an app accesses separate personal and work connections):

```bash
ferrite connectors grant --provider github --app my-app --handle ferrite_connector_grant
ferrite connectors list
ferrite connectors revoke <grant-id>
```

The provider packages share `gatekeeper::broker::BrokerTransport` to talk to the Connector Hub over your declared `connectors-egress` binding. Raw provider OAuth tokens stay inside the Connector Hub vault and never enter the constrained application process.

## Capability grants, write approvals, and audit trails

Every connector enforces three runtime invariants defined in `gatekeeper`:

- **Scoped, expiring capability grants.** Every operation checks a `CapabilityGrant` bound to specific resource scopes, an expiration timestamp, and a revocation epoch. Raising a principal's revocation epoch in `EpochRegistry` invalidates every earlier grant immediately.
- **Digest-bound write approval queues.** Side-effecting actions (such as opening a pull request or appending to a document) return a `WriteReceipt<T>` carrying the durable action ID, a cryptographic digest of the reviewed arguments, the approval state, and any applied effect. Because approval binds to the argument digest, modified arguments cannot reuse an existing approval. Pass the same idempotency key, arguments, and simulation mode when polling or retrying: `BrokerError::NotSent` is safe to retry with the same key, while `BrokerError::Unconfirmed` signals that the external service may already have applied the write.
- **Observation audit trail.** Every allowed and refused read is recorded with its timestamp, resource unit, sharing policy, and decision. Refused attempts keep a separate saturating counter and at most 32 recent records so a flood of refusals cannot evict allowed observation history. Where a connector manages local tokens in `TokenVault`, only SHA-256 fingerprints (`token_fingerprints()`) are exposed, never raw secrets.

## Boundaries and operational notes

- **No ambient authority in `gatekeeper`.** The source package performs no network I/O, reads no system clock, and draws no entropy on its own; timestamps (`TimestampMs`) and transport handles come explicitly from your application.
- **Fixed-offset schedules only.** Because constrained applications carry no system `tzdata` database, `gatekeeper::calendar` accepts `"UTC"` and fixed UTC offsets such as `"+02:00"` or `"-05:30"`, and rejects IANA timezone names at registration.
- **Persist state you need across restarts.** When running a self-contained in-app `gatekeeper` queue without the resident Connector Hub, pending approvals, applied receipts, and in-memory observation trails do not survive process restarts or scale-to-zero; persist durable audit records to your application's [Key-value Store](/developers/store/).
- **Review and revert in the Dashboard.** Operators can inspect, approve, reject, or revert supported connector writes from the Ferrite Dashboard; each provider package documents which external actions are reversible.

## Next steps

- Give an embedded product agent governed external tools in [Agent SDK](/developers/agent-sdk/).
- Learn how write-only secrets and declared egress protect outbound calls in [Secrets & Egress](/developers/secrets-egress/).
- Expose your own governed apps to teammates inside Claude with [App Hub and Code Mode](/developers/app-hub-code-mode/).
