> ## Documentation Index
> Fetch the complete documentation index at: https://trytilde.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy and environments

> Create an ontology project and its environments, bind each environment's connections and secrets in tilde.config.ts, deploy with tilde deploy, roll back, and give agents the ontology as tools.

An **ontology project** is one folder of your repository, `ontologies/<name>/`. An **environment** is an isolated place where one version of it runs, such as `staging` or `production`, with its own data, connections, and secrets. A **version** is an immutable build of one commit. Deploying rolls a version out to an environment.

Ontologies run only on Tilde Cloud. There is no local ontology runtime: you build and check locally or in CI, and run on Tilde Cloud.

For a first deploy, start with [Deploy the project](https://trytilde.ai/docs/project/deploy.md). This page covers environments, bindings, and rollbacks in more depth.

## Create a project and an environment

**1. Create the project**

In **Foundry**, select **Create project**. Use the ontology's folder name: lowercase letters, digits, and dashes, such as `crm` for `ontologies/crm/`. Choose the team that owns it, or the whole organisation.

**2. Create an environment**

Open the project, select **Environments**, then **Create environment**, and name it, such as `production`. Switch on **Serve its spaces in Live** if people should open its [spaces](https://trytilde.ai/docs/foundry/spaces.md).

**3. Declare it in tilde.config.ts**

List the ontology and its environments in `defineProject`, with what each environment binds. See [Bind connections and secrets](#bind-connections-and-secrets).

A dry run tells you when a project or environment is missing, with a link that creates it.

## Deploy

`tilde deploy` at the repository's root builds every ontology in `tilde.config.ts` on your machine or in CI, uploads it as a version, binds each environment, and rolls it out, one environment at a time. Tilde never builds your code: it validates what you upload, and deploys it. Install `@trytilde/ontology` in each ontology's package and `@trytilde/spaces` in its spaces package, and pin them in your lockfile.

See [Deploy the project](https://trytilde.ai/docs/project/deploy.md) for the steps, `--dry-run`, `--check`, CI, and every option.

## Bind connections and secrets

Each environment binds the ontology's [connections](https://trytilde.ai/docs/foundry/sources-and-models.md#connections) to your organisation's [connections](https://trytilde.ai/docs/connections.md), and its secrets to your team's [secrets](https://trytilde.ai/docs/connections.md#secrets). Declare both in `tilde.config.ts`:

```ts tilde.config.ts theme={"system"}
import { defineProject, github, linear, ontology, secret, slack } from "@trytilde/iac";
import type { connections } from "./ontologies/crm/connections.ts";

export const project = defineProject({
  ontologies: {
    crm: ontology<typeof connections>({
      environments: {
        staging: {
          connections: { linear: linear.ref("acme-sandbox"), github: github.ref("acme"), slack: slack.ref("acme-sandbox") },
          secrets: { APP_DB_PASSWORD: secret.ref("STAGING_DB_PASSWORD") },
        },
        production: {
          connections: { linear: linear.ref("acme"), github: github.ref("acme"), slack: slack.ref("acme") },
          secrets: { APP_DB_PASSWORD: secret.ref("PROD_DB_PASSWORD") },
        },
      },
    }),
  },
});
```

* `ontology<typeof connections>` types each binding by its connection's provider, so binding `linear` to a GitHub connection does not compile. The import is type-only.
* Connections and secrets are only referenced. Create them in Tilde. A missing one blocks the deploy, with a link that creates it.
* Tilde checks that the version declares exactly the connections and secrets each environment binds: an unbound one blocks the deploy.
* Unbinding a connection cuts off access within minutes. Different environments can bind the same connection to different accounts.

## Settings

**Settings** are plain values handlers read, declared with `setting(default)` in the ontology's `env`. They keep their defaults unless the environment overrides them through the management API.

An ontology has two kinds of secret. Pipeline secrets, declared with `defineSecrets`, are bound to your team's secrets in `tilde.config.ts`, as above. Handler secrets, declared with `secret()` in `env` and read from `ctx.secrets`, are set in the environment's **Secrets** section. Values are write-only.

## Roll back

The environment's page lists its deployments. Select **Roll back** to deploy the previous version again, or **Roll back to this** on any earlier deployment. A rollback reuses the stored version, so nothing is built.

## Give an agent the ontology

The **Tilde Foundry** tool provider gives agents an environment's reads and actions as tools. The connection holds only the environment's ID, and no key: Tilde issues a short-lived token for each call, and the ontology's policies decide it.

**1. Connect the environment**

In **Connections**, choose **Tilde Foundry**, name the connection, and enter the environment's ID.

**2. Add it to the agent**

In the agent's spec, select the tools from that connection, such as `connection.ref("tilde_ontology/crm").tools("listCustomers")`. See [Agents as code](https://trytilde.ai/docs/deployment/iac/connections-and-tools.md). You can also add them on the agent's **Tools** tab. See [Manage tools](https://trytilde.ai/docs/tools/management.md#choose-an-agents-tools).

**3. Grant the capability**

Allow the tools in the agent's `tools.invoke` [capability](https://trytilde.ai/docs/iam.md#agent-capabilities).

**4. Permit the agent in policies**

Write [policies](https://trytilde.ai/docs/foundry/policies.md) for `principal.type == "agent"`, or for the specific agent.

The tool list follows each deploy. A call the policies deny reaches the agent as the tool's error. Give each agent only the tools its role needs, and keep its policies just as narrow: both are enforced. Foundry tools are not available to agents you run against a local open-source Tilde.

## Who can do what

Ontology projects have their own [access actions](https://trytilde.ai/docs/operator-access.md#resource-access). Environments and spaces follow their project.

* `view` lets a person see the project and open its spaces in Live.
* `edit` lets them change environments, connections, and secrets.
* `deploy` lets them deploy and roll back.
* `share` lets them change the project's visibility, ownership, and grants.
* `write_streams` lets a management API key write to the project's [custom streams](https://trytilde.ai/docs/foundry/sources-and-models.md#custom-streams).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.