~/.xynthis/bmc/.
The record: 64 bytes per fact
Every durable fact is a fixed-layout 64-byte binary record:| Field | Size | Purpose |
|---|---|---|
| id | 8 B | Monotonic, never recycled |
| created_at, valid_from | 16 B | Timestamps (epoch seconds) |
| valid_until | 2 B | Validity window length in days (0 = open) |
| record type, flags, schema version | 3 B | Store discriminant, soft-delete bit, format version |
| confidence, source trust | 3 B | Born-with confidence and source weighting |
| signature | 32 B | 256-bit binary signature |
- One cache line per record. 64 bytes is the cache-line size on most CPUs, and the struct is declared with 64-byte alignment. A scan over records is a linear walk the prefetcher loves.
- No parsing. Loading a record is a size-checked byte copy into the struct. There is no deserialization step, no schema negotiation, no allocation per record.
- mmap-friendly. Fixed stride means record n lives at a computable offset, so the store files can be memory-mapped and read in place.
- A training substrate. Records are already tensors of bits and small integers. The same files that serve recall can feed a training loop without an export step. A binary-native classifier substrate exists behind a feature flag today; it runs in shadow mode only and is not on the live decision path yet.
Search: propose cheaply, verify precisely
Recall is two-stage. Stage 1 proposes. A locality-sensitive hash index over the bit signatures returns candidate ids. Matching is Hamming distance: XOR two signatures and count the differing bits, which modern CPUs do in a handful of instructions per 64-bit word. If the first probe comes back thin, a multi-probe pass widens the net. Stage 2 verifies. Only the proposed candidates get the expensive treatment: a precise cosine similarity against the stored quantized embedding, which replaces the cheap Hamming score for ranking. The full-precision comparison never runs over the whole store, only over the shortlist. Both stages run in-process and synchronously. No network hop, no query queue, no round trip. At the benchmark profile of a 10,000-record store (batched writes, consumer Apple-silicon laptop), search p95 is 792 µs and a full multi-store router query is 799 µs p95: under a millisecond end to end. Store-level behavior at 100,000 records and beyond is where the current optimization work is aimed; the 10k profile is measured and healthy, the million-record profile is not yet proven.Durability: assume the power cord gets pulled
Writes go through a per-store write-ahead log before they touch the main file. Each WAL entry carries a CRC32 checksum. Two durability modes exist: strict mode (the default) fsyncs per record, batched mode does group commit, one WAL write and one fsync per insert batch. On every open, the store replays the WAL and then repairs it:- A torn tail (the file ends mid-entry) or a zero-filled tail (the classic power-cut artifact) is detected and truncated back to the last good entry. Everything before the tear survives.
- A CRC mismatch on bytes that are fully present is fatal by design. That pattern means corruption, not a tear, and silently skipping it would hide data damage.
Scale: fewer bytes, more cores
Two levers keep the store fast as it grows, both measured. int8 rescore payloads. The stage-2 cosine pass needs the embedding, and that payload dominates disk volume: at 768 dimensions, the legacy f16 encoding costs 1,544 bytes per record, the int8 encoding costs 780, a 49.5% reduction. Recall is unaffected: cosine similarity is scale-invariant, so per-vector symmetric int8 quantization produced rank-for-rank identical results across every query in the recall eval, and a round-trip test pins cosine fidelity above 0.9999. int8 is the default for new stores; existing f16 files are auto-detected from their header and keep working with no migration. Sharding. The store can split into N fully independent shards, each with its own WAL, index, and files, searched in parallel with reversible id routing. On a 10-core Apple-silicon machine with 100,000 records, search throughput went from 1,428 to 3,422 queries per second at 4 shards, with p50 latency dropping from 697 µs to 249 µs. Inserts moved from 170,715 to 196,228 per second at 4 shards, and int8’s smaller payload added a further 13.6% insert win in the disk-bound 4-shard regime. Eight shards regressed (efficiency-core and fsync contention), so 4 is the measured sweet spot on this class of hardware. Measured single-threaded throughput at the 10,000-record batched profile, same laptop:| Operation | Throughput | p50 |
|---|---|---|
| Fact store insert | 145,735/s | 6 µs |
| Vector store insert | 178,098/s | 5 µs |
| Graph edge insert | 457,836/s | 2 µs |
| Fact store delete | 18,161/s | 55 µs |
| Search | 1,427/s | 697 µs |
The knowledge graph
Alongside the fact stores, BMC keeps a temporal knowledge graph of subject-predicate-object triples. Three properties make it more than an edge list:- Time is first-class. Every triple carries a validity window and a confidence. Queries can ask “as of” a moment: a fact that ended stays queryable inside its window instead of vanishing.
- Entities canonicalize. The entity index is built on a deterministic canonical key: trim, strip quotes and punctuation, drop a leading article, collapse whitespace, casefold. “Ada Lovelace”, “ada lovelace”, and ” The Ada Lovelace. ” land in one bucket, while the stored triple keeps its original surface form for display.
- Facts supersede. When a newer perception contradicts an older one (same subject and predicate, conflicting object), a consolidation sweep marks the older record stale. The sweep processes records in id order, so older facts get superseded by newer ones and never the reverse. Stale facts stop surfacing in recall but are not destroyed.