How the audit contract is checked
How CI backs the auditability and replayability contract — what each clause promises, what's checked, and what you can verify yourself.
The auditability and replayability contract isn't only a promise in prose. Pleach's CI checks each clause below. This page pairs every clause with what's checked and what a broken clause looks like.
For the same checks by subsystem, see Release checks.
@pleach/coreThe auditability contract
The promise: every model call writes a typed, tenant-scoped, reconstructable row to the event log (one per request when the provider audits every attempt).
| Contract clause | What's checked |
|---|---|
| The row shape is locked and versioned | A change to the AuditableCall wire format comes with an AuditRecordVersion bump. |
| Every row can reconstruct its configuration | Every event-log write stamps a manifest hash, the reference replay uses to recover the configuration active when the event fired. |
| The referenced manifest exists | SessionRuntime wiring reaches the manifest write, so an event row points at a manifest that was written. |
| A referenced manifest survives retention | A retention pass leaves no surviving event pointing at a dropped manifest. |
| Every event type has a redaction decision | Each EventLogInput member has an entry in the scrubbable-fields allowlist. |
| Every event type is really produced | Each EventLogInput member has a producer. |
| Event rows stay attributable to a tenant | Core's event-log write paths carry tenantId. |
AUDIT_RECORD_VERSION_HISTORY records every additive version bump.
See the AuditableCall row for the
field-by-field shape.
The replayability contract
The promise: a recorded session re-executes deterministically against an untampered log, and the chain makes any later edit detectable.
| Contract clause | What's checked |
|---|---|
| The hash-chain wire-in stays intact | EventLogWriter keeps stamping the chain that verifyChainForChat and generateProof read. |
| Canonicalization is versioned | A canonicalization version constant pins the format. The verifier and writer share one canonicalization helper. |
| The replay surface holds | The @pleach/eval subpaths (., ./scorers, ./replay, ./report) keep their exports and test coverage. |
| The graph stays a fixed lattice | Every compiled cross-stage edge is on the allowed list. Replay can only reproduce a graph whose edges are fixed. |
verifyChain returns { ok: true } or a row-precise
{ ok: false, failedIndex, expected, actual, reason }, so a broken
chain names the row.
See Tamper-evident hash chain for what the chain proves, and Eval and replay for the replay path that reads it.
When the checks run
CI runs the contract checks on changes to the packages. It also packs each package on changes, installs it into a scratch directory, and imports it from there. Nightly and weekly runs repeat that for core and a subset of the packages, so a packaging break that no change touched still surfaces between releases.
Verifying the contract yourself
A host embedding @pleach/core inherits the contract but not the CI.
You can verify the parts that matter in your deployment:
- The chain.
npx @pleach/core audit verifychecks the permission ledger and exits1if the chain is broken.verifyChainForChatchecks a chat's event-log rows from your own code. - Your plugin.
npx @pleach/core dev --plugin … --scenarios … --assert …drives a battery and exits non-zero on a failed expectation. - Your install. Run
npm packon your package, install the tarball in an empty directory, and import each subpath you depend on understrict.
For your own rules, see Add your own checks.
Where to go next
Release checks
The same checks, organized by subsystem.
AuditableCall row
The typed per-call row shape locked at AuditRecordVersion.
Tamper-evident hash chain
What the chain proves and how to verify it.
Eval and replay
The replay surface that reads the chain to assert deterministic re-execution.
Config manifest
The content-addressable configuration snapshot the config-manifest hash points back to.
Release checks
The checks that protect the `@pleach/*` packages you install — package shape, plugin contracts, event-log integrity, multi-tenant scoping, and the graph lattice — and the checks you can run yourself.
When a check fails
What you see when your code breaks a Pleach rule, what it means, and the fix — the lookup an agent can read straight from an error to the change.