# Presets reference

> The presets entry of the registry, the built-in catalogue, how an entry expands, the rules and warnings, and the format of a preset definition.

The `presets` entry of the registry, the built-in catalogue, how an entry expands, the rules and warnings, and the format of a preset definition.

A preset is a versioned, sourced declaration of one third-party tool: its processor entry and every artefact it is known to use. To adopt one, follow [add a vendor with a preset](/docs/manual/guides/add-a-vendor-with-a-preset/). To write one, follow [contribute a preset](/docs/manual/guides/contribute-a-preset/).

> [!WARNING]
> A preset does not make a declaration true. A `draft` preset has not been checked against the live vendor at all. A `verified` one was true on the day its fixture last ran. Run `consent-kit audit` against your own site either way.

## Catalogue

| Preset | Version | Status | Parameters | Purpose slots | Declares |
| --- | --- | --- | --- | --- | --- |
| `plausible` | 1.0.0 | **draft** | `script` (required): the file name of your site's personalised script, such as `pa-XXXXX.js` | `analytics` (no expected basis) | Processor `plausible` (Plausible Insights OÜ, EE). Artefacts `plausible_script` (script, `https://plausible.io/js/<script>`) and `plausible_event` (endpoint, `https://plausible.io/api/event`). No cookies and no storage, as documented by the vendor; not yet observed in a browser. Its fixture has never been run. |
| `acme-analytics` | 1.0.0 | verified, synthetic | `origin` (default `http://127.0.0.1:4174`) | `analytics` (expects `consent`) | The fake analytics vendor of `examples/static-site`: processor `acme-analytics`, artefacts `acme_script`, `acme_id` (cookie `_acme_id`, 90 days), `acme_last_page` (localStorage) and `acme_collect` (endpoint). Not a real service. It exists to prove the mechanism end to end and as the reference for writing a preset. |

The `plausible` preset covers Plausible's cloud service loaded with the site's personalised script. It does not cover self-hosted Plausible or the legacy `script.js` snippet with `data-domain`.

## The presets entry

```yaml
presets:
  - use: plausible          # preset id
    version: 1              # major version: the newest 1.x.y; or an exact "1.0.0"
    purpose: analytics      # one of YOUR purpose ids
    with:
      script: pa-XXXXX.js   # the preset's parameters
```

| Field | Type | Meaning |
| --- | --- | --- |
| `use` | string, required | Preset id. |
| `version` | integer or string, required | An integer selects the newest version of that major. A string selects one exact version. |
| `purpose` | id | Your purpose id, for a preset with one purpose slot. |
| `purposes` | `{ <slot>: <your purpose id> }` | For a preset with several slots. Every slot must be mapped. Setting both `purpose` and `purposes` is an error. |
| `with` | `{ <parameter>: <value> }` | Parameter values. A parameter without a default is required. |
| `ids` | `{ <default id>: <your id> }` | Renames, for the processor and for artefacts. A rename is not an override. |
| `exclude` | string[] | Default ids of artefacts you do not use. Recorded as an override. |
| `overrides` | `{ processor: { <field>: <value> }, artefacts: { <default id>: { <field>: <value> } } }` | Local deviations from the documented defaults. Any field except `id` and `kind`. `null` removes an optional field. |

## Expansion

The entry above expands into what you would otherwise have written by hand:

```yaml
processors:
  - id: plausible
    name: Plausible Analytics
    legalEntity: Plausible Insights OÜ
    country: EE
    dpaUrl: https://plausible.io/dpa
    privacyUrl: https://plausible.io/privacy
artefacts:
  - { id: plausible_script, kind: script, src: https://plausible.io/js/pa-XXXXX.js, processor: plausible, purposes: [analytics] }
  - { id: plausible_event, kind: endpoint, url: https://plausible.io/api/event, processor: plausible, purposes: [analytics] }
```

- Expansion happens when the registry is loaded. Everything after that step (the compiler, the diff, the guard, the documents, the audit) receives a plain registry and does not know presets exist.
- Expanded entries come after the hand-written ones.
- No marker fields are added. The meaning of an expanded entry, and its contribution to the policy hash, is exactly that of a hand-written one. Replacing hand-written entries with a preset that declares the same thing is no change at all.
- An overridden value is validated exactly like a hand-written one.
- A preset declares its tool completely, so nothing is merged with hand-written entries of the same id (`preset/id-collision`).
- Two presets that declare the same processor id collide and must be renamed. Sharing one processor between several presets of the same vendor is not supported.

## What is reported

`consent-kit check` prints the adopted presets and, when there are any, the list "Local overrides of preset defaults". `check --json` carries both under `presets`. `consent-kit audit` prints the same lines at the end of its report.

```
Presets:
  acme-analytics@1.0.0 -> processor "acme-analytics", artefacts acme_script, acme_id, acme_last_page, acme_collect  [synthetic]
```

A draft preset is flagged on every run: `[DRAFT: not yet verified against the live vendor]`, followed by its unverified facts when it has any.

Overrides are information. They never fail the check. Each one is recorded with the documented default and its source:

| Field of an override record | Meaning |
| --- | --- |
| `preset`, `version`, `index` | Which preset use it belongs to. |
| `target` | `processor` or `artefact`. |
| `id`, `defaultId` | The id in your registry and the preset's default id. |
| `change` | `field` (one field differs) or `excluded`. |
| `field`, `documented`, `local` | The field, the preset's value and yours. |
| `source` | The vendor documentation behind the documented default. |

Provenance is a parallel structure, `applied`, one item per `presets` entry: the preset id and exact version, its status, whether it is synthetic, the parameter values, the slot-to-purpose mapping, the ids it wrote, and the list of unverified facts.

## Errors and warnings

Errors stop validation; see [validation rules](/docs/manual/reference/validation-rules/#presets): `preset/unknown`, `preset/purpose`, `preset/parameter`, `preset/id-collision`, `preset/override`, `preset/unresolved`.

Warnings are printed by `check` and never block: `preset/basis-mismatch`, `preset/redundant-override`, `preset/missing-locale`.

## Versions and re-consent

`privacy.lock.json` stores the expanded registry. Upgrading a preset therefore shows up in `consent-kit diff` as ordinary changes to ordinary artefacts, classified like a hand edit, and a material change needs the same purpose version bump.

Preset versions follow semver, with one rule on top: **any change that would be material under the material-change rule is a major version.** Pinning `version: 1` never brings a material change by itself; visitors are asked again only when you raise the major on purpose.

| Step | When |
| --- | --- |
| **major** | Any change classified `material` or `needs_review`: a new cookie, storage key, script or endpoint; a longer lifetime; a new origin; another legal entity or country; reworded visitor-facing text. Also anything that stops existing registries from resolving: a new required parameter, a removed parameter, a new or removed purpose slot, a removed or renamed default id. |
| **minor** | Any other change to what a registry ends up containing, such as a shorter cookie lifetime. |
| **patch** | Nothing a registry receives changes: sources, notes, `verified` flags, `status`, the fixture, the summary. |

Old versions stay in the catalogue, so a project pinned to an exact version keeps resolving.

## Preset definition

A preset is a `PresetDefinition` (declared in `packages/schema/src/presets/types.ts`). `packages/presets/src/catalogue/acme-analytics.ts` is a complete one.

| Field | Meaning |
| --- | --- |
| `id` | Catalogue id. |
| `version` | Semver, `MAJOR.MINOR.PATCH`. |
| `status` | `draft` until every fact is verified and the fixture has run green against the live vendor; `verified` after. |
| `synthetic` | `true` only for a vendor that does not exist. |
| `name`, `summary`, `docs` | The tool's name, a one-line summary, and the vendor's documentation home. |
| `parameters` | Values the project supplies. Each has a `description`, a `type` (`origin`: scheme, host and optional port, no path; `host`: a bare host name; `string`: anything matching `pattern`), an optional `pattern`, an optional `default` (without one the parameter is required) and an `example`. Used as `${name}` placeholders in string values. |
| `purposes` | Named slots the project binds to its own purposes. Each has a `description` and, optionally, an `expectedBasis` with a `basisReason`. |
| `processor.declares` | The processor entry; `id` is the default id. |
| `processor.facts` | One sourced fact per declared field other than `id` and `name`. |
| `artefacts[]` | Each has `declares` (the artefact, with the default id, `purposes` listing slots, and no `processor`) and the fact fields. |
| `statements[]` | Sourced claims that are not artefacts, such as "sets no cookies". Each has `text` and the fact fields. |
| `fixture` | How to load the tool on an empty page and which artefacts a page view must produce. |

A fact has `source` (the URL of the vendor's own documentation that states it), `verified` (a person read it there), `checkedOn` (the day, required when verified) and `note` (required when not verified).

A fixture is a descriptor, not a script:

```ts
fixture: {
  with: { origin: 'http://127.0.0.1:4174' },                  // parameter values for the run
  head: '<script src="${origin}/analytics.js"></script>',     // goes into <head> of an otherwise empty page
  expect: ['acme_script', 'acme_id', 'acme_last_page', 'acme_collect'],
  lastRun: null,                                               // { date, against: 'live' | 'offline', result }
}
```

It may also carry `body` (HTML for the page's `<body>`) and a `note`.

## API

```ts
import { parseRegistry, catalogue } from '@consent-kit/presets';

const result = parseRegistry(yamlText);          // schema's parseRegistry, bound to the built-in catalogue
if (result.ok) {
  result.registry;            // plain Registry, presets expanded
  result.presets?.applied;    // AppliedPreset[]
  result.presets?.overrides;  // OverrideRecord[]
  result.presets?.warnings;   // PresetWarning[]
}
```

| Export of `@consent-kit/presets` | What it does |
| --- | --- |
| `catalogue`, `plausible`, `acmeAnalytics` | Every version of every built-in preset, and the two definitions. |
| `parseRegistry(yaml, { catalogue? })`, `validateRegistry(input, { catalogue? })` | Validate a registry, expanding presets. The `consent-kit` CLI, the `parseRegistry` it re-exports, and the audit use these. |
| `resolvePresets(source, catalogue)` | The pure expansion step: `{ ok: true, registry, applied, overrides, warnings }` or `{ ok: false, errors }`. Never throws. |
| `selectPreset(catalogue, id, version)` | The definition a `use` / `version` pair selects. |
| `presetOrigin(applied, 'artefacts' \| 'processors', id)` | The preset use an entry came from, or `undefined` for a hand-written entry. |
| `adoptPreset(preset, { with?, locales? })` | "What the preset declares", as a minimal plain registry. |
| `checkPresetBump(previous, next)`, `checkCatalogueHistory(catalogue)`, `bumpBetween(from, to)` | Is the version step big enough for what changed? |
| `describePresets(report)`, `describeApplied`, `describeOverride` | The text lines `check` and the audit print. |

`parseRegistry` and `validateRegistry` of `@consent-kit/schema` accept `{ presets: catalogue }` and report `preset/unresolved` when a registry uses presets and none is given. A tool that forgets about presets fails loudly instead of silently dropping a vendor.

## Not built

- Generated Consent Mode style adapters.
- The scheduled job that runs every non-synthetic preset's fixture against the live vendor. Its core, `runPresetFixture` in `@consent-kit/audit`, exists; the runner, the vendor accounts and the workflow do not.
