npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@adjudicate/audit-postgres

v8.0.0

Published

Postgres durable governance trail for IBX Intent-Gated Execution.

Readme

@adjudicate/audit-postgres

Postgres durable governance trail for IBX Intent-Gated Execution.

Implements AuditSink from @adjudicate/audit against a partitioned-by-month intent_audit table. Adopters supply a Postgres writer that runs an INSERT; the sink flattens each AuditRecord into the table's row shape.

This README covers the audit sink + replay reader. The package also exports SDK-shape readers and additional stores (createPostgresAuditStore, governance-events, guard-fire-stats, outcomes, legacyV1ToV2) — see src/index.ts.

Schema

See migrations/. Migration 001 creates the base v1 table; the additive migrations widen it for later record versions (002 plan_jsonb, 003 nonce, 005 supersedes_jsonb, 008 v4 fields, 010 v5 metadata) plus the sibling stores (004 governance-events, 006 guard-fire-stats, 007 outcomes, 009 the (intent_hash, recorded_at) unique constraint).

Partitioned by recorded_at (range, monthly). Adopters create partitions monthly via cron, pg_partman, or their migration tooling. Retention is set by dropping old partitions according to the compliance window (typically 7y for financial intents, 2y for general transactional audit).

Usage

The reference INSERT is exported as INSERT_AUDIT_SQL — the single source of truth for the row shape — paired with auditInsertParams(row), which produces the bound parameter array in matching column order. Use them; do not hand-roll the statement. The row spans 25 columns (base v1 schema plus the v2–v5 additive migrations), and every column carries part of the tamper-evidence binding: omitting the v4 fields (audit_hash, signature_jsonb, kernel_identity_jsonb, …) makes verifyAuditRecord report missing_hash on read-back. The const + helper keep the column set complete and in sync by construction.

import {
  createPostgresSink,
  INSERT_AUDIT_SQL,
  auditInsertParams,
} from "@adjudicate/audit-postgres";
import { multiSink, createConsoleSink, createNatsSink } from "@adjudicate/audit";

const sink = multiSink(
  createConsoleSink(),
  createNatsSink({ publisher: natsPublisher }),
  createPostgresSink({
    writer: {
      insertAudit: (row) =>
        pool.query(INSERT_AUDIT_SQL, [...auditInsertParams(row)]),
    },
    onError: (err, record) => {
      Sentry.captureException(err, { extra: { intentHash: record.intentHash } });
    },
  }),
);

INSERT_AUDIT_SQL names all 25 columns explicitly ($1..$25) and ends with ON CONFLICT (intent_hash, recorded_at) DO NOTHING — the grain backed by the unique constraint from migration 009, so idempotent re-emit of the same record is a no-op. (A re-adjudication at a later recorded_at is a distinct row.)

Replay

readAuditWindow takes an AuditQueryFn — an object exposing fetchRows(window) — as its first argument. Adopters wrap their Postgres client in that shape (window ends are both inclusive).

import { readAuditWindow } from "@adjudicate/audit-postgres";
import { replay } from "@adjudicate/audit";

const query = {
  fetchRows: (window) => pool.query(/* SELECT … WHERE recorded_at BETWEEN … */)
    .then((res) => res.rows),
};

const records = await readAuditWindow(query, {
  fromIso: "2026-04-01T00:00:00Z",
  toIso: "2026-04-30T23:59:59Z",
  intentKind: "order.submit",
});

const report = replay(records, (r) => adjudicate(r.envelope, currentState, policy));
console.log(`${report.matched}/${report.total} matched, ${report.mismatches.length} divergences`);

The replay is deterministic — running today's policy against last month's records detects drift before any audit. Hook this into CI for "no divergence" regression fences.

Why a separate package

@adjudicate/audit stays free of Postgres-specific imports — adopters that ship to environments without Postgres (edge functions, mobile-first runtimes) do not pull in this dependency. The base AuditSink interface is everything they need.