@noopolis/stele
v0.0.2
Published
Noopolis causal-event envelope schema, parsing, and reconciliation (read/verify side).
Readme
@noopolis/stele
Reconciliation compatibility notes
streamKey(runId, system, streamId) is an opaque JSON tuple encoding. Do
not parse it by delimiters; callers that persist or compare keys must treat
the complete returned string as the identity.
checkSeqContiguity().gaps[*].missing contains sorted inclusive
{ from, to } ranges rather than one entry per missing sequence number. This
keeps sparse streams (including Number.MAX_SAFE_INTEGER) bounded in memory.
The shared causal-event schema and reconciler for the Noopolis ecosystem.
Stele defines the canonical shape of a causal event, the rules for parsing and
hashing it, and a deterministic reconciler that turns a stream of events into
causal chains. It is runtime-neutral (no browser or Node globals), depends only
on zod, and is consumed by tools like
Simfile to observe and replay runs.
npm install @noopolis/steleWhat it gives you
- Envelope — the
CausalEventschema (causalEventSchema), plusparseCausalEvent/validateCausalEvent, canonical JSON (canonicalJsonStringify), stable hashing (hashCausalEvent), JSONL parsing (parseCausalJsonl), the principal grammar, andCAUSAL_EVENT_VERSION. - Reconcile —
reconcileEventsreturns aReconcileResultwithbyEventIdrecords andoccurrencesByEventId; eachReconciledRecordcarrieslocalState,reasonCodes,reasons, and transitivestate. It never invents a missing link; usetraceCausesBackwardto walk an event's causes. - Seq —
checkSeqContiguityandstreamKeydetect gaps in a per-stream sequence, surfacingSeqGaps instead of silently stitching over them. - Sealed bundles —
reconcileCausalBundle(input)parses mixed raw JSONL text or bytes, uses onlynoopolis.causal-stream-final.v1records as final authority, and returnsinvalid,incomplete, orvalidwith deterministic parser, stream, and graph diagnostics.declaredFinalSeqremains a compatibility-onlyreconcileEventsoption and never seals a bundle. - Digest comparison —
compareCausalDigest(domain, subject, expectedHash)is a pure fail-closed SHA-256 comparison for a recognized domain. Exact UTF-8 and byte subjects are hashed exactly as supplied; digest declarations do not assign product-specific subjects or producers.
Example
import { parseCausalJsonl, reconcileEvents, traceCausesBackward } from "@noopolis/stele";
const { events, errors } = parseCausalJsonl(await readFile("ledger.jsonl", "utf8"));
const reconciliation = reconcileEvents(events);
const record = reconciliation.byEventId.get("moltnet:m2");
const edges = traceCausesBackward(reconciliation, "moltnet:m2");
// record?.state includes transitive cause state; record?.reasonCodes explain it.
// edges lists { from, to } cause links; missing causes are reported, never stitched.Design
- Deterministic. The same events reconcile to the same records and hashes, every time.
- Honest. A missing causal link is reported as incomplete, not papered over.
- Neutral. Pure data + math; no I/O, no environment assumptions.
github.com/noopolis/stele · part of the Noopolis ecosystem
