# Confluence

> Connect Confluence to LightHouse: the ways to connect, the read-only scopes, where the credential is held, and what is indexed.

**Built in the engine.** The engine reads Confluence pages from the spaces you name, on Atlassian Cloud or your own server.

## The ways to connect

- **In LightHouse**: In LightHouse, the card for this connector says your engineer configures it in your deployment; it cannot be connected from LightHouse yet \[Coming]. It connects in code.
- **From a terminal**: \[Coming]
- **In code**: below.

## Connect in code

Set three environment variables from your own secret store:

| Variable              | Value                                                                      |
| --------------------- | -------------------------------------------------------------------------- |
| `CONFLUENCE_BASE_URL` | Your site’s wiki address, for example `https://example.atlassian.net/wiki` |
| `CONF_EMAIL`          | The account’s email address                                                |
| `CONF_TOKEN`          | An Atlassian API token for that account                                    |

Then add a source card to your catalogue:

```yaml
- id: confluence-eng
  purpose: Read the engineering spaces' pages into the knowledge base.
  executor: python
  target: aal_engine.ingest.connector:run_card
  overseer: platform-lead@example.com
  budget_usd: 0
  effect: internal
  source:
    kind: confluence
    spaces: [ENG, OPS]
    label: standard
    limit: 500                  # pages per pull
    requires:
      reads: [pages in the ENG and OPS spaces, with their versions]
      reason: the engineering agents answer from the run books and designs
```

To check the credential by hand: `python -m aal_engine.connectors.confluence search 'space = ENG' 5` lists five pages.

## Permissions

The engine signs in with the account’s email and API token (HTTP Basic) and only reads. Give the account read access to the spaces you name, and nothing else: what it can read is what the engine can read. LightHouse’s card lists the scopes `read:page:confluence` and `read:space:confluence` for a scoped token.

The engine calls, all `GET`: `/rest/api/search` with a CQL query over your spaces’ pages, ordered by last modified, and `/rest/api/content/{id}` for each page’s body, version, space and ancestors.

## Where the credential is held

In your own secret store, passed to the engine as `CONF_EMAIL` and `CONF_TOKEN`. Rotate the token at [id.atlassian.com](https://id.atlassian.com/manage-profile/security/api-tokens) and update the secret.

## What is indexed

- **Pages** (`type = page`) in the named spaces, as plain text from their export view; images become `[image]`. Each keeps its space, version and ancestor path.
- **Never read:** blog posts, comments and attachments.
- **How often:** on the card’s schedule. Each pull reads up to `limit` pages modified since the last pull’s day.
- **Deletions:** a page deleted in Confluence is not yet removed from the corpus \[Coming]. Remove it by hand.

## Check it worked

- The source’s run note: `written N, unchanged N, quarantined N, removed N`.
- **Agents → Knowledge**: documents from `confluence`.

## Removing it

Remove the card and the secrets. Documents already written stay in the corpus until you delete them.

Source: https://docs.atlanticagenticlabs.com/connect/confluence/
