# Release checks (/docs/audit-gates)



Pleach's CI checks the `@pleach/*` packages for the properties you
build on: an import resolves, a plugin hook is wired, an event type
has a redaction decision, a graph edge stays on the lattice.

You don't run these checks. They run in Pleach's own CI. This page
lists what they cover, the errors your app raises when the same rules
apply at runtime, and the checks you can run in your own project.

To read the same checks by the promise they back, see
[How the audit contract is checked](/docs/ci-enforcement). To go from
an error in your app to the fix, see
[When a check fails](/docs/gate-failures).

## The packages you install [#the-packages-you-install]

Each package is packed with `npm pack`, installed into an isolated
directory, and imported from there. That catches the failures a
monorepo build hides: a path that only resolves locally, or a
declaration file that never got emitted.

| What's checked                                                             | What it means for you                                                                             |
| -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| Every `package.json` `exports` key imports from a clean install            | A documented subpath resolves in your project, not only in Pleach's.                              |
| Every third-party import in `dist/` is declared                            | You don't hit a missing-module error from an undeclared dependency.                               |
| Every declared `.d.ts` path exists and isn't empty                         | Your editor and `tsc` get types for every subpath.                                                |
| `SessionRuntime` and `createPleachRuntime` import from an isolated install | The main entry points load outside Pleach's own workspace.                                        |
| `@pleach/core` holds no host-specific vocabulary                           | The core stays domain-agnostic: no brand names, vendor backends, or product terms.                |
| Every published package carries the same license terms                     | Each package declares FSL-1.1-Apache-2.0 and carries the canonical `LICENSE` and a `NOTICE` file. |

## The plugin contract [#the-plugin-contract]

The plugin contract runs both ways: a `contributeX` hook has to reach
something, and a host has to stay on the public surface.

| What's checked                                                                                    | What it means for you                                                        |
| ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| Every `contributeX` hook on `HarnessPlugin` has a `collectX` accessor and a consumer              | A hook you implement is read by the runtime. It doesn't silently go nowhere. |
| Every hook belongs to exactly one of the nine [contribution namespaces](/docs/plugins/namespaces) | The namespace map stays complete.                                            |

## The event log and hash chain [#the-event-log-and-hash-chain]

The event log is the record of every session turn.

| What's checked                                              | What it means for you                                                                                            |
| ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| Every core event type has a `SCRUBBABLE_FIELDS` entry       | Each one carries a redaction decision. An empty `[]` entry is a valid one.                                       |
| Every event type has a producer                             | A type in the union is one the runtime really writes.                                                            |
| The hash-chain wire-in stays intact                         | `verifyChainForChat`, `generateProof`, and `computeGenesisSeed` keep working against the rows the writer stamps. |
| `EventLogWriter` stamps a config-manifest hash on every row | Each row can recover the configuration that wrote it.                                                            |

## The config manifest [#the-config-manifest]

The [config manifest](/docs/config-manifest) records which runtime
configuration ran each session, content-addressed and referenced by
every event-log row.

| What's checked                                                            | What it means for you                                                                          |
| ------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| Two builds of the same configuration produce identical hashes             | A timestamp can't leak into a hash and make replay report a false change.                      |
| The event-log foreign key carries its canonical clauses                   | `REFERENCES`, `ON DELETE SET NULL`, and `DEFERRABLE INITIALLY DEFERRED` stay on the migration. |
| `SessionRuntime` wiring reaches the manifest write                        | New sessions record their manifest.                                                            |
| A retention pass leaves no surviving event pointing at a dropped manifest | Garbage collection doesn't orphan a row you still keep.                                        |

## Multi-tenant scoping [#multi-tenant-scoping]

| What's checked                                   | What it means for you                     |
| ------------------------------------------------ | ----------------------------------------- |
| Core's event log write paths carry the tenant id | Event rows stay attributable to a tenant. |

Core's base schema ships owner and service-role policies. The tenant
policies come with `@pleach/compliance`, so apply its
[tenant RLS schema tier](/docs/compliance#the-tenant-rls-schema-tier) and verify it on your database with `auditRlsPolicies()`.

## The graph and lattice [#the-graph-and-lattice]

The compiled agent graph obeys the four-stage lattice
(`anchor-plan` → `tool-loop` → `synthesize` → `post-turn`, one-way,
with a bounded `synthesize → tool-loop` re-entry, at most once per
turn).

| What's checked                                                                       | What it means for you                                                              |
| ------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------- |
| Every edge in the default graph stays on the lattice                                 | Replay reproduces a graph whose edges are fixed.                                   |
| Node and edge counts are identical for the same configuration                        | A compile is deterministic.                                                        |
| Every cross-stage edge is documented in the [edge catalog](/docs/graph-edge-catalog) | The catalog is a full list of transitions.                                         |
| Recovery runs in one place, the post-turn stream filters                             | A retry can't enter through a second path.                                         |
| The graph barrel's public and internal exports stay separated                        | The public graph surface doesn't shift between releases.                           |
| `ChatOptions.agentic === false` is respected at every recursive call                 | Single-call mode stays single-call.                                                |
| The `AuditableCall` row shape and `AuditRecordVersion` move together                 | The [row shape](/docs/auditable-call-row) changes additively, with a version bump. |

## Errors your app raises [#errors-your-app-raises]

Some of these rules also apply in your process. These are the ones
you can hit.

| What you did                                                          | What you see                                                                   |
| --------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| Registered a malformed plugin                                         | `PluginManager.register` throws `PluginValidationError` with the failing hook. |
| Added a graph node with no `subscribes` or `writes`                   | Registration refuses the node and names it.                                    |
| Declared a plugin node under a core node's name, at a different stage | Registration throws and asks you to rename the node.                           |

[When a check fails](/docs/gate-failures) has the fix for each one.

## Checks you can run [#checks-you-can-run]

Two commands ship in `@pleach/core`.

```bash
# Drive your plugin through a scenario battery; non-zero exit on a failed expectation
npx @pleach/core dev --plugin ./my-plugin.mjs --scenarios ./scenarios.json --assert ./expect.json

# Verify the permission ledger's chain; exits 1 if it's broken
npx @pleach/core audit verify
```

The [CLI reference](/docs/cli) lists every flag.

## Add your own checks [#add-your-own-checks]

Pleach's checks protect the packages. Your app has its own rules: a
per-tenant key never appears in logs, every domain tool has a
detector, a feature flag doesn't outlive its sunset date.

The pattern carries over:

* Write a script that walks the relevant source and asserts the rule.
  Exit non-zero with a message that names the file and line.
* Wire it into `package.json` and your PR-blocking CI job.
* Document it next to its siblings, so the next contributor knows it
  exists.

Keep one rule per script. Adding a rule means adding a check, not a
line on a review checklist.

## Where to go next [#where-to-go-next]

<Cards>
  <Card title="How the audit contract is checked" href="/docs/ci-enforcement" description="The same checks, indexed by the auditability and replayability promise each one backs." />

  <Card title="Publishing contract" href="/docs/publishing-contract" description="The packaging baseline every @pleach/* package shares." />

  <Card title="Plugin contract" href="/docs/plugin-contract" description="HarnessPlugin hooks, collectors, and consumer wiring." />

  <Card title="Host adapter" href="/docs/host-adapter" description="Plug a host runtime into @pleach/core via the dep-inversion contract." />

  <Card title="Event log" href="/docs/event-log" description="The append-only typed StreamEvent log, its hash chain, and the projection contract." />
</Cards>
