@tty-pt/corm
Universal Node.js and Browser bindings forlibcormand the Corm Recall Kernel (cormr). Features persistent memory-mapped storage, in-process multi-axisCormEngine& HTOK v4 binary containers, candidate set algebra, streaming min-heap ranking, and multi-axis composable queries. Canonical C headers:<ttypt/corm.h>and<ttypt/cormr.h>.
๐ Full C & Storage Documentation: See the main libcorm GitHub README for mmap(2) B-tree/hash internals, typed key/value descriptors, and C multi-axis recall architecture.
1. Quickstart & Installation
npm config set @tty-pt:registry https://tty.pt/npm/
npm install @tty-pt/corm
Native OS & Mobile Packages (tty.pt): Prebuilt native C packages (libcorm) for Linux (apt, apk, pacman, dnf), macOS (brew), Windows (winget, MSYS2), and OpenBSD (pkg_add), plus static mobile sysroots for Android (https://tty.pt/android/) and iOS (https://tty.pt/ios/ โ libcorm.xcframework) are available via the tty.pt package repositories.
import { CormDb, CormEngine, CandidateSet, MinHeapRanker, htokPack, htokUnpack } from "@tty-pt/corm";
// 1. Persistent key-value storage with typed keys/values (u, a, 2u, 2s, s, b)
const db = new CormDb("./data.corm", "app_store");
db.put("member:101", { name: "Alice", role: "admin" });
const member = db.get("member:101");
console.log(member); // { name: "Alice", role: "admin" }
// 2. In-process multi-axis CormEngine & HTOK v4 binary envelopes
const packed = htokPack(JSON.stringify({ summary: "Zero-copy recall", text: "In-memory map" }));
console.log(htokUnpack(packed));
const engine = new CormEngine("./docs.db@lemma,sepal:a:b");
engine.putJson("1", JSON.stringify({ summary: "Zero-copy recall", text: "In-memory map" }));
const hits = engine.query({ expr: "lemma", axes: { lemma: "recall" }, topK: 5 });
// 3. Ultra-fast Candidate Set Algebra (cormr_set_t)
const setA = new CandidateSet();
setA.push(10).push(20).push(30).seal();
const setB = new CandidateSet();
setB.push(20).push(30).push(40).seal();
const intersection = setA.intersect(setB);
console.log(intersection.toArray()); // [20, 30]
// 4. Streaming Bounded Min-Heap Ranker (cormr_rank_t)
const ranker = new MinHeapRanker(3 /* topK */, 0.2 /* minScore */);
ranker.push(101, 0.85);
ranker.push(102, 0.95);
ranker.push(103, 0.40);
console.log(ranker.sorted()); // [{ ref: 102, score: 0.95 }, { ref: 101, score: 0.85 }, ...]
engine.close();
db.close();
2. Dual-Engine Runtime: Native Speed & Browser Portability
@tty-pt/corm operates on an infallible dual-engine runtime:
- Node.js Native (N-API): Executes native C99 compiled binaries with direct OS memory mapping (
mmap(2)), a 64-slot LRU engine cache (execCormCommand,CormEngine,closeCormEngine), HTOK v4 binary packing (htokPack,htokUnpack), and dynamic axis plugin loading (@lemma,@sepal,@joint,@islet). - Browser & Edge WebAssembly: When running in the browser, Cloudflare Workers, or environments without a C compiler, it seamlessly falls back to the pre-compiled
dist/corm.wasmshared-memory reactor on@tty-pt/stele.
3. Composable Multi-Axis Queries
The Corm Recall Kernel coordinates orthogonal domain axes (joint for time, islet for space, lemma for text, sepal for vectors) into unified boolean filtering and ranking:
import { CormDb, JointTemporalAxis, SepalVectorAxis } from "@tty-pt/corm";
const db = new CormDb("./workspace.corm");
const temporal = new JointTemporalAxis();
const vector = new SepalVectorAxis();
db.registerAxis(temporal);
db.registerAxis(vector);
// Compose: Filter by temporal window AND rank by dense vector cosine similarity
const hits = await db
.query()
.filter("temporal", { start: 1793405000, end: 1793415000 })
.rank("vector", { queryVector: [0.12, 0.85, 0.44] })
.topK(5)
.execute();
4. C Development Headers via NPM
This package includes the canonical C development headers in include/ and corm.pc:
# Include in your C Makefile without system installation:
CFLAGS += -I./node_modules/@tty-pt/corm/include
LDLIBS += -lcorm
5. Building from Source
make npm-build # Compiles native addon (build/Release/) and WASM reactor (dist/)
make npm-test # Runs verification test suite
License
BSD-2-Clause โ Copyright (c) 2026, Paulo Quirino <quirinpa@gmail.com>. See LICENSE.