Module

Audit

A queryable trail of the actions that matter — a sign-in, a refund, an entitlement granted, a secret rotated, a config change made from a browser — as durable rows, each attributed to the actor that caused it.

@pithy-sh/audit

Built for Enterprise
terminal
pithy add audit
Read the docs Source on GitHub

What it is for

A durable, queryable record of the actions that matter: logins, token refreshes, entitlement grants, admin configuration changes — each attributed to the right actor, including the dashboard when it is the one acting.

What it sits on

Your D1, through a seam in core.

The contract — the event shape and the emit method on the request context — lives in core, not here. Any capability records an event without importing this package, and with no audit capability composed, emit is a no-op recorder.

So an audited action can never break for want of auditing.

  • D1

License

Open source, on the Functional Source License.

FSL-1.1-MIT

The source is public, and you can read it, run it, change it and ship it in your product. Every other capability in the kit is MIT; this one is the exception, and it is the only one.

The single thing it forbids is a competing use — taking this and offering it to others as a substitute for it, or for something we already sell with it. Your own product is not that, and neither is consulting on it, teaching from it or researching it: those are named as permitted in the text.

Each version converts to MIT on the second anniversary of its release. That is not a promise we could quietly drop later; the grant is written into the license you already received.

The honest bit

An audit trail is not an authentication log.

Signing in is one of the things worth recording, and it is the one every auth library will hand you. It is also the least interesting: the questions an audit answers are who refunded that order, who granted this entitlement, who rotated that secret, and who changed the configuration on a Friday evening.

Those actions happen in payments, in the ledger, in secrets, in the dashboard — not in auth. A trail that lives inside an auth library can only ever see the door, which is why this is a capability of its own and why the contract lives in core rather than here. Any capability records an event without importing this package.

It also has to answer for the vendor. When the dashboard acts on your Worker it lands in this trail under its own actor kind, so what a tool did is answerable separately from what your people did.

If you build it yourself

Writing rows is easy. Attributing them is the work.

The question is never what happened. It is who did it, and how you know.

Actor attribution

A user, an admin, a scheduled job or the dashboard — distinguished, so what a vendor did is answerable separately.

A seam every capability can use

If recording an event requires importing the audit package, half of them will not, so the contract lives in core.

Never breaking the action

An audited operation must not fail because auditing did. With nothing composed, the recorder is a no-op.

Metadata that is not a leak

A trail is long-lived and queryable, which makes it exactly the wrong place for a receipt or a token.

Queryable at volume

Append-only, high volume, read by range — the shape a transactional database is worst at.

terminal
pithy add audit

In the dashboard

Administer it from a browser, without building the screen.

The trail itself, filterable by actor, action and environment — which is most of what an audit screen ever needs to be.

The dashboard is the admin interface for your own application: whatever this capability writes, your team can look up, check and act on from a browser. Reading is free, forever, with no time limit. Connect the project when you deploy.

Add it, and get on with the feature.

One command installs the package, wires its bindings into every environment your project declares, and runs its migrations.