Skip to content

Support remapping cores - #109

Merged
chm-diederichs merged 31 commits into
mainfrom
remap
Oct 21, 2026
Merged

chm-diederichs merged 31 commits into
mainfrom
remap

Conversation

@chm-diederichs

Copy link
Copy Markdown
Contributor

No description provided.

@chm-diederichs
chm-diederichs requested a review from a team October 19, 2026 15:06
@chm-diederichs chm-diederichs changed the title Remap Support remapping cores Oct 19, 2026
@chm-diederichs
chm-diederichs requested a review from a team October 21, 2026 09:08
Comment thread index.js Outdated
chm-diederichs and others added 20 commits October 21, 2026 16:05
An optional list of core mappings on block-1, persisted next to the core
table. Old readers ignore the flag, old blocks decode with mappings null.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A mapping redirects every read of a core to another core holding the same
blocks. The hook is asked once per referenced core when it is opened, so
getCore, getCoreKey, getContextByKey and getContext are async. The core
table keeps keys as referenced, mappings are learnt from checkpoints and
written back on the next one, and the node cache and diff key on the
opened core so both spellings share an entry.

move and checkout stay sync, remap runs before the next operation and
re-roots the tree if the hook moves it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
remap deduped on the in-flight promise, so a second move before the
first resolved was overwritten by the first mapping and never resolved
itself. The remap now loops until the context it handled is still the
current one.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Every core of a table is asked for when the checkpoint is inflated and
the tree remaps the core it is opened on, so the mapping of any key met
afterwards is known and getCore, getCoreKey, getContextByKey and
getContext are sync again. A key handed in by the caller of write or
createChangesStream is asked for before it is used.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The mappings sit next to the core table in the framed metadata struct
instead of on the block itself. The schema is versioned from here on so
the field, added in version 2, is only read when the metadata carries
the flags byte and older checkpoints decode as before.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A core whose mapping is not known yet is opened with a corestore preload
that asks the hook, so the session only ever opens on the core it maps
to and nothing in the tree has to resolve keys itself: getCore and the
context helpers are sync, the table is left as referenced, and the tree
no longer remaps itself on ready, move or checkout. Contexts carry the
key they were opened for, as a preloaded session has none until open.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Mappings are a table the tree is given, at open or through addMappings,
and learns from every checkpoint it inflates. The hook and the session
preload go, core resolution is a sync lookup, and cores() gains a
recursive walk over the core tables of every core reached so a caller
can find what to map before reading.

cores() now describes the root's core rather than the context the tree
was last moved onto.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
flushMappings only loads: it reads what the tree holds in its checkpoint
first, so only what is new is dirty, and moves a tree sitting on a
mapped core. A batch written with touch rewrites the root as it is so
the checkpoint carries the mappings, and writes nothing if they are in
one already. addMappings and Mappings.get go.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A batch written with mappings records them in its checkpoint, writing
one block of its own if there is nothing else to write and something is
new. Mappings are only ever loaded when a checkpoint is inflated, so
flushMappings, addMappings, touch and the mappings option go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread lib/mappings.js
Comment thread lib/context.js Outdated
Comment thread lib/mappings.js Outdated
Comment thread lib/context.js
Comment thread lib/context.js Outdated
Comment thread lib/write.js Outdated
@chm-diederichs
chm-diederichs merged commit f8f38fe into main Oct 21, 2026
4 checks passed
@chm-diederichs
chm-diederichs deleted the remap branch October 21, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants