Repository navigation
feat(llm-helper): the transcript audit store - the Node twin of the Python pack's build (RFC-0012) - #126
Merged
Conversation
…ython pack's build (RFC-0012) Record version 2 carries each turn's facts inside the compare-and-set; llm.chat sends a write event after every accepted turn and the integrity check behind a closing turn to transcript.audit, a private function with one instance that fills what PostgreSQL lacks and releases the working record only after the check; a sweep repairs lost events and stopped runs. pg as a dev dependency, the schema and purge files byte-identical with the Python pack, the development setup on Colima with pgweb, 28 tests and a live test; the helper's test fakes shared through a fixture. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…twin built, PR #126 opened Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
acn-ericlaw
added a commit
that referenced
this pull request
Nov 17, 2026
… as landed Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This was referenced Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
RFC-0012 build plan step 2: the Node twin of mercury-python #59, field for field.
transcript(fields)fills the Python dataclass's defaults;recordJsonwritesv: 2in the Python key order with each turn's facts (trace id and path, correlation id, the model call's UTC bounds, status, stop reason, request id, usage,messages: [first request message, response]), the first turn's system prompt, catalog, correlation id and the loop'sx-graph-id/x-node, and the closingretention, all inside the compare-and-set;recordFromstill reads version 1. The 66 shared loop vectors pass unchanged.transcript.audit, a private composable function with ONE instance, registered at boot whenllm.transcript.audit: postgresis configured. After every accepted turnllm.chatsends{conversation, turn}through a localPostOffice.send; a closing turn adds{conversation, check: true}behind it. The function reads the record and writes the rows the store lacks in one transaction; the check releases a closed record to itsretentiononly after the audit holds every turn, and marks it; an open record is only filled. Until the check, a closed record waits withllm.transcript.audit.grace(1d). A sweep (llm.transcript.audit.sweep.ms, 60 s, one replica per interval on Redis) sends a check for every record whose audited mark lags. A failed write is logged by type and SQLSTATE, never by content, and never refuses a turn.audited,markAudited,release,unaudited,sweepLock): Redis keepsauditedas a third hash field the compare-and-set never touches, set by a Lua that never resurrects a released record; the sweep reads two fields per record overscanIteratorpages.PostgresAuditStoreonpg.Pool(the new dev dependency, like the SDK andredis);$nplaceholders, JSON as text cast tojsonb, stamps as text cast totimestamptz- the same statements as the Python pack.MemoryAuditStoreholds the reference semantics for tests and parity.extensions/llm-helper/schema/postgres.sqlandpurge.sql, byte-identical with the Python pack;dev/postgres-up.sh(postgres:17-alpine + pgweb on 8081),postgres-down.sh,audit-purge.sh; the audit keys inapplication.yml(the database user and password from the environment, since a-Dvalue is never substituted); README "The audit store"; CHANGELOG Unreleased Added 1.test/fixtures/llm-helper-fakes.mjs, shared by both helper test files;test/transcript-audit.test.mjshas the Python file's 28 cases one for one plus the live test gated onLLM_TRANSCRIPT_AUDIT_TEST_URL.npm test: 498 tests, 433 passed, 0 failed, 65 skipped. Verified live on Colima: the live test green on the container, the purge dry run, the containers removed.Why
The two helpers must write the same rows from the same record, since a Node helper and a Python helper on one Redis serve the same conversations (the loop contract's requirement, ADR-0033). This is the lockstep step of RFC-0012's build plan, holding to the Python build's precisions recorded in the design spec's section 14 (constant JSON shapes for
requestandresponse; a closed record's mark set by its check after the release; any closed record waiting with the grace; the statement order and the text casts). The one Node-specific decision:ssl: truemaps to{ rejectUnauthorized: false }, the twin of libpq'ssslmode=require, so a managed database's private CA works out of the box, documented in the README.Next: the
-Denvironment-variable substitution in all four runtimes (Eric's request), then the engines' two headers and theorder-assistantdrive.🤖 Generated with Claude Code
Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com