Live sandbox and consumer verification lab for Auditstream against real PostgreSQL, PgBouncer (transaction mode), the compiled auditstream CLI binary, and real npm / packed .tgz installs of @auditstream/* with zero workspace symlinks.
- Infrastructure (
docker-compose.yml+docker/init/):- PostgreSQL (
PG_VERSION=19by default; compatible with15through19, with version-scopedPGDATA=/var/lib/postgresql/pg${PG_VERSION}insidepg_data). - PgBouncer
1.26(POOL_MODE=transaction,DEFAULT_POOL_SIZE=6,MAX_PREPARED_STATEMENTS=200,AUTH_TYPE=scram-sha-256). - Least-privilege runtime role
app_user(LOGIN), provisioned on boot. The migration ofauditstream init --app-role app_usercreates the owner role of each database and grantsapp_useronlySELECTonauditstream.changesandEXECUTEonauditstream.log_event. - Two isolated databases:
lab_drizzleandlab_prisma.
- PostgreSQL (
- Two live HTTP consumer apps (
apps/):apps/hono-drizzle: Hono + Drizzle ORM +@auditstream/node/hono+@auditstream/drizzle/pg(wrapPgPool), covering CRUD, excluded-column no-op updates (password_hash), delegatedai_agent+onBehalfOf, nestedSAVEPOINT+ rollback + full transaction rollback, direct rawpool.query,audit.log(), and an allowlistedGET /activityBFF feed.apps/prisma-api: Hono + Prisma 7 (@prisma/adapter-pg) +@auditstream/node/hono+@auditstream/prismaSQL comments plugin +auditTransaction()(set_configfallback),audit.log(), andGET /activity.
- Isolated staging (
scripts/bootstrap.sh):- Stages clean consumer copies into
.tmp/run/so tracked files inapps/stay clean andnode_modules/@auditstream/*never links to sibling monorepo directories. - Writes a per-app
pnpm-workspace.yaml(packages: ["."]) and.npmrc(registry=${NPM_REGISTRY}) before runningpnpm install --no-frozen-lockfile. - Runs real
auditstream init --app-role app_user(--migrations drizzleand--migrations prisma), applies the generated migrations, grantsapp_useraccess to the application tables, and verifies both databases withauditstream verify.
- Stages clean consumer copies into
- Docker & Docker Compose v2
- Bash (
3.2+including stock macOS/bin/bash) - Node.js
22.12+and pnpm 12 (the apps declarepackageManager: pnpm@12.15.0) psql,curl,jq,tar,xz,realpath, andsha256sum(orshasum)
-
Start PostgreSQL and PgBouncer:
docker compose up -d
-
Bootstrap both apps using the latest published GitHub Release binary (SHA-256 verified) and published npm
@auditstream/*packages:./scripts/bootstrap.sh
-
Run the automated end-to-end smoke suite (starts both HTTP servers via PgBouncer as
app_user, exercises all flows, checks tamper resistance and pooled PgBouncerpg_prepared_statements, and verifiesauditstream status,verify,historyincluding--diffand--format json, andexport):./scripts/smoke-interactive.sh
-
Run the unit tests (Node built-in test runner, zero extra dependencies; on Node
22.12–22.17, pass--experimental-strip-types):node --test tests/shared.test.ts tests/soak.test.ts
ci.yml runs the unit tests on Node 22.12 and 26, and the bootstrap, the smoke suite and a 30-second soak on PostgreSQL 15, 17 and 19 with the latest published CLI and packages. It runs on every pull request and once a week; a manual run can pin the CLI version.
gauntlet.yml runs the pre-release gauntlet when started by hand.
Run it before tagging an auditstream or @auditstream/* release, and again with the published version after the release. One command runs, for each PostgreSQL major in turn, on a clean stack:
docker compose up -d --waitwith thatPG_VERSION.scripts/bootstrap.shandscripts/smoke-interactive.sh(the fresh-user flow).soak/run.shand its invariant oracle.scripts/upgrade-check.sh, the upgrade from v0.1.0 to the candidate CLI.docker compose down -v.
It stops at the first failed step and exits non-zero, after writing the report for what ran:
./gauntlet.sh --pg-versions 15,17,19 --soak-seconds 120 --report release-verification-report.mdTest a release candidate with a local binary and packed tarballs (see Testing local release candidates), or published versions:
AUDITSTREAM_BIN=/path/to/auditstream/target/release/auditstream \
AUDITSTREAM_JS_TGZ_DIR=/path/to/packed-tarballs \
./gauntlet.sh --pg-versions 19 --soak-seconds 30 --report /tmp/release-verification-report.md
AUDITSTREAM_VERSION=0.2.5 ./gauntlet.sh --js-version 0.7.1--pg-versions <list>: PostgreSQL majors, comma-separated (default15,17,19).--soak-seconds <seconds>: soak duration for each version (default120, with the soak's default 40 workers).--report <path>: report path (defaultrelease-verification-report.md).--js-version <version>: packs@auditstream/{node,drizzle,prisma}at that version fromNPM_REGISTRYand installs them like local tarballs. Without it (and withoutAUDITSTREAM_JS_TGZ_DIR), the apps install what theirpackage.jsonranges resolve to.- The CLI comes from
AUDITSTREAM_BIN, else the releaseAUDITSTREAM_VERSION, else the latest release, which the gauntlet downloads again on every run so a cached older binary is never tested. Every step uses that one binary. - The gauntlet uses its own Compose project,
auditstream-lab-gauntlet(orCOMPOSE_PROJECT_NAME), so it never removes the volumes of a lab you started withdocker compose up. It needs the same ports, so stop that lab first, or setPG_PORT,PGBOUNCER_PORT,HONO_PORTandPRISMA_PORT. After an interrupted run that could not clean up,docker compose -p auditstream-lab-gauntlet down -vremoves its stack; the next run also removes it. - Logs of every step, the soak reports and the upgrade summaries are in
.tmp/gauntlet/.
The report gives the CLI version, where it came from and its SHA-256, the @auditstream/* versions installed, the lab commit, the result and duration of each step for each PostgreSQL version, the soak totals and latencies with its invariants, the upgrade check, the end of the log of a failed step, and the managed cloud status. Managed cloud poolers (Neon, Supabase) are not covered yet: the report says skipped (deferred, auditstream/auditstream#222).
fixtures/v0.1.0/ pins the SQL that the published v0.1.0 CLI generated for the lab's tables. scripts/upgrade-check.sh installs it in a fresh lab_upgrade database, writes 7 history rows as app_user (INSERT, UPDATE and DELETE with actors in SQL comments, set_config and log_event), and runs the candidate's verify, which reports the drift. It then refreshes the installation in place as verify directs: auditstream init --app-role app_user in the project that v0.1.0 wrote, and the migration it writes, which moves the history from the v0.1 role auditstream_owner to the database's own owner role. It fails unless verify is then clean, init is then up to date, and, after 6 more rows (and one change to an excluded column only, which records nothing), every row written before and after the upgrade is in the table, in history and in export. It needs only a running stack and the CLI, so it also runs alone:
./scripts/upgrade-check.sh --summary /tmp/upgrade.jsonThe engine documents a reinstall, not this upgrade, for users of 0.1.0 (its init reference). The check covers what the specification requires of a migration over the role v0.1 shared ("Upgrade from another owner role", which keeps every row) and what the engine tests in upgrades_a_v0_1_0_installation_in_place, with the published binaries.
Start gauntlet.yml from the Actions tab or with gh workflow run gauntlet.yml -R auditstream/auditstream-lab -f cli_version=0.2.5. Its inputs:
cli_version: the CLI release (empty for the latest).cli_ref: a branch, tag or commit ofauditstream/auditstreamto build the CLI from instead (takes precedence overcli_version).js_version: the@auditstream/*version from npm (empty for what the apps resolve).pg_versions(default15,17,19) andsoak_seconds(default120).
The job writes the report to its summary and uploads it as the release-verification-report artifact. It fails when the gauntlet fails.
Point bootstrap.sh at a locally built auditstream binary and a directory containing packed .tgz tarballs (auditstream-node-*.tgz, auditstream-drizzle-*.tgz, auditstream-prisma-*.tgz):
AUDITSTREAM_BIN=/path/to/auditstream/target/release/auditstream \
AUDITSTREAM_JS_TGZ_DIR=/path/to/packed-tarballs \
./scripts/bootstrap.sh
AUDITSTREAM_BIN=/path/to/auditstream/target/release/auditstream \
./scripts/smoke-interactive.shbootstrap.sh copies the tarballs into .tmp/run/tarballs, writes a per-app pnpm-workspace.yaml with overrides pointing to those tarballs, installs with pnpm install --no-frozen-lockfile, and fails immediately if any node_modules/@auditstream/* package is missing, dangling, or resolves outside its isolated app directory.
Override defaults via the shell or a local .env file (see .env.example; .env is gitignored):
PG_VERSION,PG_PORT,PGBOUNCER_PORT,PG_ADMIN_PASSWORD,APP_USER_PASSWORD,HONO_PORT,PRISMA_PORTAUDITSTREAM_BIN: path to a local executableauditstreambinary (honored bybootstrap.sh,smoke-interactive.sh, andsoak/run.sh).AUDITSTREAM_JS_TGZ_DIR: directory containing packed@auditstream/{node,drizzle,prisma}.tgztarballs (honored bybootstrap.sh).AUDITSTREAM_VERSION: pin a specific GitHub Release version,0.2.2or newer, such as0.2.4instead oflatest(cached separately per version under.tmp/bin/; honored bybootstrap.sh,smoke-interactive.sh, andsoak/run.sh).AUDITSTREAM_FORCE_DOWNLOAD=1: re-download the GitHub Release binary even if already cached (honored bybootstrap.sh,smoke-interactive.sh, andsoak/run.sh).NPM_REGISTRY: override the npm registry URL written into staged.npmrcfiles (defaulthttps://registry.npmjs.org/).
Override PG_VERSION (for example 15, 17, or 19). Always tear down the stack when switching versions cleanly:
docker compose down -v
PG_VERSION=15 docker compose up -d
./scripts/bootstrap.sh
./scripts/smoke-interactive.shStart both HTTP servers (connected to PgBouncer on 127.0.0.1:6432 as app_user):
./scripts/start-apps.shIn a second terminal, send sample requests to hono-drizzle (:3101) and prisma-api (:3102):
# 1. Create an invoice as human user alice (passwordHash is excluded from auditstream.changes)
HONO_INV_ID="$(curl -sS -X POST http://127.0.0.1:3101/invoices \
-H 'content-type: application/json' \
-H 'x-demo-user: alice' \
-H 'x-demo-tenant: acme' \
-d '{"status":"draft","total":"50.00","passwordHash":"secret-1"}' | jq -r '.id')"
# 2. Finalize as a delegated AI agent acting on behalf of alice (with a rolled-back savepoint)
curl -sS -X POST "http://127.0.0.1:3101/invoices/${HONO_INV_ID}/finalize" \
-H 'content-type: application/json' \
-H 'x-demo-agent: bot_billing' \
-H 'x-demo-on-behalf-of: alice' \
-H 'x-demo-tenant: acme' \
-d '{"amount":"125.50","description":"Q4 subscription","simulateSavepointRollback":true}'
# 3. Record an application event via audit.log() and inspect the allowlisted BFF activity feed
curl -sS -X POST "http://127.0.0.1:3101/invoices/${HONO_INV_ID}/events" \
-H 'content-type: application/json' \
-H 'x-demo-user: alice' \
-H 'x-demo-tenant: acme' \
-d '{"action":"invoice.exported","format":"pdf"}'
curl -sS 'http://127.0.0.1:3101/activity?limit=10' | jq
# 4. Exercise Prisma 7 + auditTransaction() (actor_source = set_config) on :3102
PRISMA_INV_ID="$(curl -sS -X POST http://127.0.0.1:3102/invoices \
-H 'content-type: application/json' \
-H 'x-demo-user: alice' \
-H 'x-demo-tenant: acme' \
-d '{"status":"draft","total":"80.00","passwordHash":"secret-2"}' | jq -r '.id')"
curl -sS -X POST "http://127.0.0.1:3102/invoices/${PRISMA_INV_ID}/approve" \
-H 'content-type: application/json' \
-H 'x-demo-agent: bot_approver' \
-H 'x-demo-on-behalf-of: alice' \
-H 'x-demo-tenant: acme' \
-d '{"status":"approved"}'Inspect the recorded audit trail with the live auditstream CLI:
CLI="$(cat .tmp/run/cli-bin.path)"
DRIZZLE_URL="postgresql://postgres:postgres_dev_password@127.0.0.1:5432/lab_drizzle"
PRISMA_URL="postgresql://postgres:postgres_dev_password@127.0.0.1:5432/lab_prisma"
(cd .tmp/run/hono-drizzle && "$CLI" --database-url "$DRIZZLE_URL" status)
(cd .tmp/run/hono-drizzle && "$CLI" --database-url "$DRIZZLE_URL" verify)
(cd .tmp/run/hono-drizzle && "$CLI" --database-url "$DRIZZLE_URL" history --table public.invoice --diff)
(cd .tmp/run/hono-drizzle && "$CLI" --database-url "$DRIZZLE_URL" history --table public.invoice --format json)
(cd .tmp/run/hono-drizzle && "$CLI" --database-url "$DRIZZLE_URL" export --format jsonl)
(cd .tmp/run/prisma-api && "$CLI" --database-url "$PRISMA_URL" history --table public.invoice --format json)Note: Demo HTTP headers (
x-demo-user,x-demo-agent,x-demo-on-behalf-of,x-demo-tenant) exist solely for local sandbox exploration. Production applications must derive actors and tenants from a verified session or JWT and fail closed on unauthenticated requests.
Run the concurrent HTTP + SQL soak generator and invariant oracle against both bootstrapped apps (hono-drizzle and prisma-api) via PgBouncer (DEFAULT_POOL_SIZE=6) while executing incremental auditstream export --format jsonl --cursor-file in parallel:
./soak/run.sh --duration 30 --concurrency 20 --out /tmp/soak-report.mdFull 2-minute contention run (defaults: --duration 120 --concurrency 40 --export-interval 2):
./soak/run.sh --duration 120 --concurrency 40Options:
--duration <seconds>— soak duration in seconds (default120).--concurrency <workers>— total parallel HTTP workers split evenly acrosshono-drizzleandprisma-api(default40, min2).--export-interval <seconds>— backgroundauditstream export --cursor-fileinterval in seconds (default2).--out <path>— Markdown summary report path (default.tmp/soak/soak-report.md).--json-out <path>— structured JSON report path (default derived from--out).-h, --help— show CLI usage and exit0.
What the soak workload exercises and verifies:
- 35 distinct human actors (
user_1..35) and 10 delegated AI agents (ai_agent+onBehalfOf) acrossINSERT/UPDATE/DELETE, Drizzle nestedSAVEPOINT+ fullROLLBACK, rawpool.query, Prisma SQL comments +auditTransaction(), excluded-onlypassword_hashupdates, mid-flightAbortControllercancellations,audit.log(), and cursor-paginatedGET /activity. - Periodic
app_usertamper attempts (DELETE/UPDATE/INSERTonauditstream.changes, asserting 100% rejection with SQLSTATE42501) and direct unattributed SQL writes over the same PgBouncer pool (asserting zero actor or context bleed). - Post-run invariant oracle verifying
0lost or extra committed2xxevents across both apps,0duplicateevent_ids,0rolled-back/excluded-only/secret leaks,0actor mismatches or unaccounted events,0auditstream=entries across all 6 distinct pooledpg_backend_pid()sessions,0HTTP5xxor unexpected status responses, andauditstream verifyexiting0.
Stop and remove all containers, networks, and volumes:
docker compose down -vTo also remove local staged installs and cached binaries:
rm -rf .tmp