Skip to content
pleach
Reference

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.

Subpath@pleach/core

The 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 clauseWhat's checked
The row shape is locked and versionedA change to the AuditableCall wire format comes with an AuditRecordVersion bump.
Every row can reconstruct its configurationEvery event-log write stamps a manifest hash, the reference replay uses to recover the configuration active when the event fired.
The referenced manifest existsSessionRuntime wiring reaches the manifest write, so an event row points at a manifest that was written.
A referenced manifest survives retentionA retention pass leaves no surviving event pointing at a dropped manifest.
Every event type has a redaction decisionEach EventLogInput member has an entry in the scrubbable-fields allowlist.
Every event type is really producedEach EventLogInput member has a producer.
Event rows stay attributable to a tenantCore'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 clauseWhat's checked
The hash-chain wire-in stays intactEventLogWriter keeps stamping the chain that verifyChainForChat and generateProof read.
Canonicalization is versionedA canonicalization version constant pins the format. The verifier and writer share one canonicalization helper.
The replay surface holdsThe @pleach/eval subpaths (., ./scorers, ./replay, ./report) keep their exports and test coverage.
The graph stays a fixed latticeEvery 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 verify checks the permission ledger and exits 1 if the chain is broken. verifyChainForChat checks 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 pack on your package, install the tarball in an empty directory, and import each subpath you depend on under strict.

For your own rules, see Add your own checks.

Where to go next