akw-factory-floorsfloors.akwlabs.dev · ga

Loaders

The same rows in PGlite Postgres and in Redis.

The JSONL files are the record. Every database here is a rebuildable cache of them.

PGlite Postgres

npm run load:pglite                    # in memory
npm run load:pglite -- --dir .pglite   # on disk

Drops and recreates schema floors on every run, then loads both files:

Table Rows
floors.manifest one per floor, slug primary key
floors.mailroom one per mailroom row, (floor, seq) primary key

floors.mailroom.floor carries a foreign key to floors.manifest.slug, so a mailroom that names a floor the manifest does not know fails the load instead of loading quietly.

Redis, via ioredis

REDIS_URL=redis://127.0.0.1:6379 npm run load:ioredis
npm run load:ioredis -- --reset

The keyspace is declared in src/load/ioredis.ts and nowhere else. An undeclared prefix is drift.

Key Type Holds
floors:index SET every floor slug
floors:manifest:<slug> HASH one manifest row, a field per column
floors:mailroom:<slug> STREAM the append-only log, one entry per row

A mailroom is append-only, so it is a Stream and not a list. XADD cannot rewrite an entry, which is the same guarantee the file gives.