open-brainy/src
David Snelling 15d4f65dcf perf(open): the pending-embed fold is bounded by a checkpoint of the SET, not an empty-only mark
The low-water mark shipped in 10.4.9 can only be written when the pending
set is EMPTY, because it carries no set — it means "everything at or below
G is consumed". A brain holding even one id that never lands (an embed that
keeps failing, a data-less row reaped in memory only and re-folded every
open) never drains, so it never writes a mark, so the bound never engaged on
exactly the brains whose fold is expensive: `recover-pending-embeds` re-read
the WHOLE fact log at every open, on the open's foreground.

_system/pending_embeds_checkpoint.json carries the set: { generation,
pending, writtenAt } = "as of durable generation G the pending set was
exactly this list". Open seeds the set from the list and scans from G + 1,
so the fold is O(facts since G) whether or not the set ever drains. Measured
on a 301-row brain with one stuck id: 302 facts read before, 0 after; at 601
rows, 602 before, 0 after — same pending set both ways.

THE DURABILITY LAW, by construction. A checkpoint at head H taken while the
facts up to H are still buffered would be read back after a crash that
truncated the tail: an `embed.landed` in a truncated fact would be gone from
the log while the checkpoint still recorded its id as landed, and its
landing vector went with the fact — a LOST VECTOR. So a capture is refused
unless `0 < head <= committed`, the manifest watermark below which
FactLog.open() never truncates and which the group-commit flush only
advances after fsyncing the log. The (generation, set) pair is taken in one
synchronous instant with no await between reading the generations and
snapshotting the set. The one remaining asymmetry runs the safe way: an id
enqueued in memory whose marker lands at G+1 is captured as pending at G —
one idempotent re-embed, never a loss.

Written at clean close (inside closeDurableSteps, after the generation
store's own close flushed the log and advanced the manifest), at
drain-to-empty, and on a cadence of max(64, ceil(|pending| / 64))
transitions while open — an interval that holds the mechanism's amortized
cost at <= 64 ids written per transition however large the backlog grows, so
the cure cannot reintroduce the defect class it fixes. No timer, no knob.
The debt stays armed across attempts the durability law refuses, so a write
burst does not skip a checkpoint, it defers it.

Degradation is loud and always toward a LONGER scan: a torn checkpoint
throws typed on read (the adapter's tmp+rename write means it can never
parse into a partial list) and a malformed one is refused whole, both
falling back to the low-water mark — still written, still read — and then to
generation 1. The fold narrates which bound applied and how many facts it
read, on every open, so a bound that stops engaging is visible instead of
silent.

The worker's orphan reap splits: a row that is GONE clears durably (its
tombstone is in the log, or its create never was), while a present-but
data-less row keeps clearing in memory only and is carried in the checkpoint
list, so the bounded fold and a full fold from generation 1 agree exactly.
The crash-recovery contract is unchanged: the fold stays on the open's
foreground, markers re-armed when open() returns.
2026-09-02 10:20:38 -07:00
..
aggregation feat(engine): the wiring wave — stamps ride every flush, provider generations, waitForIndexed, adopt-backfill, match-all serves 2026-08-10 10:55:11 -07:00
cli refactor(8.0): remove dead, unreachable, and unwired modules 2026-06-24 15:18:40 -07:00
db perf(open): a sealed segment the manifest proves is below the bound is never read 2026-09-02 10:07:30 -07:00
embeddings chore: rename to @soulcraftlabs/brainy for Open Brainy on The Source 2026-08-27 17:07:09 -07:00
errors chore: rename to @soulcraftlabs/brainy for Open Brainy on The Source 2026-08-27 17:07:09 -07:00
events feat: brain.onChange — the in-process change feed for every committed mutation 2026-07-10 11:24:31 -07:00
graph perf(flush): an idle brain does no work — no periodic flush without a write 2026-08-28 10:44:38 -07:00
hnsw Merge branch 'next/zero-norm-unvector-door' 2026-08-27 13:54:06 -07:00
import feat(namespace): NO SPECIAL NAMES + storage fidelity — the ruled completion of the field-addressing law 2026-08-03 16:59:32 -07:00
importers refactor(8.0): remove dead/deprecated code (legacy sweep) 2026-06-29 10:09:39 -07:00
indexes/columnStore feat(log): log authority is the fleet default — adopt-at-open, oracle-gated; plus the power-cut throw-site cures and the loud torn-record contract 2026-08-11 08:37:38 -07:00
integrations chore: rename to @soulcraftlabs/brainy for Open Brainy on The Source 2026-08-27 17:07:09 -07:00
mcp chore: rename to @soulcraftlabs/brainy for Open Brainy on The Source 2026-08-27 17:07:09 -07:00
migration feat(namespace): NO SPECIAL NAMES + storage fidelity — the ruled completion of the field-addressing law 2026-08-03 16:59:32 -07:00
neural feat(plugin): an optional planFindPage door — an index that can plan a find answers it in one call 2026-09-01 13:11:16 -07:00
patterns chore(8.0): final pre-RC1 sweep — API consistency, named errors, orphans, zero-cast codebase 2026-06-11 14:51:00 -07:00
reprojection feat(reprojection): the one doors-open machinery — budget-capped, yielding, foreground-preempted, atomic-swap; poison records quarantine typed 2026-08-10 11:39:27 -07:00
storage fix(graph): the verb fast paths honour every requested type, source, and target 2026-09-01 12:23:03 -07:00
streaming chore(8.0): final pre-RC1 sweep — API consistency, named errors, orphans, zero-cast codebase 2026-06-11 14:51:00 -07:00
transaction fix(transact): metadata-index ops take their JSON-safe view at the crossing, not at construction 2026-08-31 12:59:40 -07:00
triple chore(8.0): Phase A + B — purge all @deprecated APIs + cacheManager dead branches 2026-06-09 15:33:56 -07:00
types feat(repair): repairIndex narrates every phase and its receipt carries the walls 2026-08-28 10:31:42 -07:00
universal refactor(8.0): remove dead, unreachable, and unwired modules 2026-06-24 15:18:40 -07:00
utils fix(find): the hybrid legs rank inside the filter, and only the page is read 2026-09-02 09:37:27 -07:00
vfs perf(vfs): repairContainment's reconcile is one paged edge walk, not one graph call per file 2026-09-01 12:48:38 -07:00
brainy.ts perf(open): the pending-embed fold is bounded by a checkpoint of the SET, not an empty-only mark 2026-09-02 10:20:38 -07:00
coreTypes.ts fix(vfs): the VFS root never persists a zero-norm vector 2026-08-27 09:28:44 -07:00
index.ts feat(contract): declare contract 1, serve three operators, refuse four by name 2026-08-28 10:57:43 -07:00
internals.ts feat: provider access to the fact log + shared stamp verifier via internals 2026-07-15 12:36:27 -07:00
plugin.ts fix(find): the hybrid legs rank inside the filter, and only the page is read 2026-09-02 09:37:27 -07:00
setup.ts chore(8.0): collapse dead defensive guards + redundant polyfills 2026-06-09 16:46:16 -07:00