Repository navigation
Support remapping cores - #109
Merged
Merged
Conversation
mafintosh
reviewed
Oct 21, 2026
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>
mafintosh
reviewed
Oct 21, 2026
mafintosh
reviewed
Oct 21, 2026
mafintosh
reviewed
Oct 21, 2026
mafintosh
reviewed
Oct 21, 2026
mafintosh
reviewed
Oct 21, 2026
mafintosh
reviewed
Oct 21, 2026
Removed duplicate checks for core keys and optimized context retrieval.
mafintosh
approved these changes
Oct 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.