# PostgreSQL

> PostgreSQL: what the collector reads, how to connect it, its permissions, its certification by Atlantic Agentic Labs and its security posture.

Built, not certified Built and tested against recorded and synthetic responses (version 0.1.0, 21 November 2026). Not yet run against the vendor's sandbox or a client environment.

Reads the PostgreSQL tables and views you name, in place, through a read-only role in the client’s own network, so agents can answer from a register or a ledger without it being copied to a vendor. Every statement it sends is a SELECT, inside a read-only transaction.

Built against PostgreSQL 13 and later through psycopg 3 (SQL SELECT only).

## At a glance

| Collector                   | PostgreSQL, version `0.1.0`                                                                                              |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| Reads                       | PostgreSQL Global Development Group: PostgreSQL ([the vendor's documentation](https://www.postgresql.org/docs/current/)) |
| Family                      | Data                                                                                                                     |
| Kind                        | Database                                                                                                                 |
| Ways to connect             | Access token                                                                                                             |
| Scopes                      | - Read: `CONNECT on the database`, `USAGE on the schemas`, `SELECT on the named tables and views`                        |
| Read only                   | Yes                                                                                                                      |
| Vendor's API can move money | No                                                                                                                       |
| Personal data               | Content, Contact, Identity, Financial, Employment                                                                        |
| Hosts it may contact        | Only the hosts on your deployment's allow-list (`*`: the host is the one you give it)                                    |
| Vendor API versions         | PostgreSQL 13 and later (frontend/backend protocol 3.0) through psycopg 3; SQL SELECT only, in a read-only transaction   |
| Lowest engine version       | `0.47.1`                                                                                                                 |

## What it reads

- The tables and views you name (`schema.name`), with the key column, optionally an `updated` column, a `title` column and the `columns` to read (every column otherwise). A whole database is never the default.
- With an `updated` column, a pull reads rows later than the cursor less `margin_minutes` (five by default: a row committed by a long transaction carries a time from before it became visible), ordered by it. Without one, the table is read whole on every pull and an unchanged row costs nothing to rewrite; say so to the client before naming a large table.
- Rows are read through a server-side cursor, a page at a time, never a whole table at once.
- Deletions: every six hours the keys are listed (`SELECT <key>` only) and a row that has gone is withdrawn. A table that has gone, or that the role can no longer read, keeps its rows until it can be listed again. A table taken out of the configuration has its rows withdrawn.
- Text is kept to `max_chars` (100,000) and then marked truncated; a `bytea` value is named by its size and never written to the corpus.

## How to connect

1. In the database, create a role with `LOGIN` that holds `CONNECT` on the database, `USAGE` on the schemas and `SELECT` on the named tables and views, and nothing else: not a superuser, no `CREATEROLE`, `CREATEDB` or `REPLICATION`, and no table it owns or can write. Setting `ALTER ROLE ... SET default_transaction_read_only = on` as well is good practice; the collector sets it on its own session either way.
2. In LightHouse, open **Connectors**, choose **PostgreSQL**, and give the credential: the host, the port (5432 if left empty), the database name, the role and its password, and the TLS mode (`require` if left empty; `verify-full` where the server’s certificate can be checked). They are sealed in your browser to your deployment’s key and kept in your own secrets store; LightHouse never opens them. The deployment must be able to reach the database.
3. In code, set `POSTGRES_CREDENTIAL` to the credential’s JSON fields (`host`, `port`, `dbname`, `user`, `password`, `sslmode`) and add a `kind: postgres` source card with `tables`, `label` and `requires`. Install the engine’s `postgres` extra (psycopg 3).

## Permissions

`CONNECT`, `USAGE` on the schemas and `SELECT` on the named objects, and nothing else; read and write is not offered. Read-only is held three ways:

- The session is opened with `default_transaction_read_only=on`, each pull begins with `SET TRANSACTION READ ONLY` and confirms `transaction_read_only` is on, so PostgreSQL refuses any write.
- Before anything is read, the catalogue is asked (`pg_roles`, `has_table_privilege`) whether the role is a superuser, holds `CREATEROLE`, `CREATEDB` or `REPLICATION`, or can `INSERT`, `UPDATE`, `DELETE`, `TRUNCATE` or add a `TRIGGER` on any table it can see. If so, the pull is refused and the health check reports the connection as able to write, naming what it found.
- In the code, every statement goes through one function that refuses anything but a SELECT, so even a bug cannot write.

This collector speaks the PostgreSQL protocol through a database driver, not HTTP, so its read-only test is written its own honest way, as Oracle Database’s is: it runs the real connect path against a fake `psycopg` driver that records every statement sent, over a first pull, a reconciling pull and the health check, and asserts that every statement is a SELECT (or the `SET TRANSACTION READ ONLY` that opens each transaction), that the session asked for `default_transaction_read_only=on`, and that no write verb appears.

## Limits

- Every identifier (schema, table, column) is checked against PostgreSQL’s unquoted-identifier shape, lower-cased as PostgreSQL folds an unquoted name, and quoted; a value is only ever a bound parameter. A table named `x; drop table y` is refused before a connection is opened. A name that needs quoting (mixed case, spaces) is not supported.
- A table is `schema.name`, named once; a row with a null key is skipped.
- Pages are 50 to 5,000 rows (500 by default).
- The `margin_minutes` margin means a row is read again a little after it is first seen; the contract writer makes an unchanged row free.
- Up to twenty writable tables are named when a role is refused.
- The host it contacts is the one in the credential, inside the client’s network.

## Data handling

- The columns you name are copied into the deployment’s corpus under the source’s `label`; whatever the tables hold (names, contact details, financial or employment records) is copied, so name the columns, not the table, where a table holds more than the question needs.
- The credential is held in the client’s own store; the password is never written to logs, run notes or the corpus, and the health check reports a fixed result, never a server message.
- Nothing leaves the deployment: only counts reach LightHouse.

## Troubleshooting

| What you see                                                     | What it means                                                                              | What to do                                                           |
| ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------- |
| `name the tables to sync; a whole database is never the default` | `tables` is empty                                                                          | Name the tables                                                      |
| `not a PostgreSQL identifier`                                    | A schema, table or column name is not a plain identifier                                   | Use the plain name; no quotes, spaces or punctuation                 |
| `table is schema.name`                                           | A table was named without its schema                                                       | Write `schema.name`                                                  |
| `a table is named twice`                                         | The same table appears twice                                                               | Remove the duplicate                                                 |
| `the PostgreSQL role can change the database`                    | The role is a superuser, holds an administrative attribute, or can write a table           | Give the collector a role with `SELECT` on the named tables only     |
| `the transaction is not read-only`                               | Something between the deployment and the database (a pooler) dropped the read-only setting | Connect directly, or set `default_transaction_read_only` on the role |
| `only SELECT is ever run against a client's database`            | A statement that is not a read was about to be sent                                        | Report it; nothing was sent                                          |
| `PostgreSQL needs the engine's `postgres` extra`                 | psycopg is not installed                                                                   | Install `aal-engine[postgres]`                                       |
| Health check `auth_failed`                                       | Wrong role or password, or the database does not exist                                     | Fix the credential                                                   |

## Certification

Each entry is a run by Atlantic Agentic Labs, newest first. Only a run against the vendor’s sandbox or a client environment certifies a collector; a certification lasts six months, or less if the vendor publishes an API version the collector does not list. See [How collectors are certified](/collectors/certification/).

| Date             | Collector | Engine   | Vendor API                                                               | Method                              | Expires        |
| ---------------- | --------- | -------- | ------------------------------------------------------------------------ | ----------------------------------- | -------------- |
| 21 November 2026 | `0.1.0`   | `0.47.1` | PostgreSQL 13 and later (frontend/backend protocol 3.0); SQL SELECT only | Fixtures only: built, not certified | Not applicable |

## Security posture

From the collector’s last scan on the default branch. What each line means, and what blocks a release: [Security posture](/collectors/security/).

| Last scanned               | 25 November 2026                                                                                                                                                                                                      |
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Critical findings          | 0                                                                                                                                                                                                                     |
| High findings              | 0                                                                                                                                                                                                                     |
| Medium findings            | 0                                                                                                                                                                                                                     |
| Low findings               | 0                                                                                                                                                                                                                     |
| Info findings              | 0                                                                                                                                                                                                                     |
| Release blocked            | No                                                                                                                                                                                                                    |
| Network allow-list check   | Pass                                                                                                                                                                                                                  |
| Read-only behavioural test | Pass                                                                                                                                                                                                                  |
| SBOM (CycloneDX)           | Produced                                                                                                                                                                                                              |
| Dependency licences        | Pass                                                                                                                                                                                                                  |
| Scanners                   | bandit 1.9.4, semgrep 1.181.1, pip-audit 2.10.1, osv-scanner 2.7.0, cyclonedx-py 7.5.0, pip-licenses 5.5.5, gitleaks repository job aal-secrets, hosts_check tools/hosts_check.py, read-only test pytest -m read_only |

Source: https://docs.atlanticagenticlabs.com/collectors/catalogue/postgres/
