Forks read through to their source's index instead of copying it
- github
- github/openchronology/timeline-app
- commit
- main
- github/athanclark
A fork or duplicate of a timeline's head now pins the source at its index clock and records the levels it reads (oc_timelines.index_bases and index_clocks, at most four): nothing is copied, so a fork of any size is ready at once. Its index is its own rows over each level's rows at that level's clock; what it changes becomes its own row, and what it removes is hidden by a hidden row of its own. One level past the limit copies, as before. - Server queries read through with indexReader (index-versions.mjs): row-by-row checks of nearer levels, hashed keys for scans, and a key lookup that takes the first version down the levels. Saves, history, merges, retention and copies all read through. - The walks in the database hand forks to _lineage variants generated from the originals. A fork's changed nodes take the path above them with them, and a changed moment its node, so each step down starts at the level its parent was found at and usually takes one lookup. They run without JIT or sequential scans, as do a fork's transactions. - A fork rewritten whole reads through to nothing. Index rows outlive their timeline while forks read them (oc_release_index, run on delete, replaces the foreign keys). - Saves that retire 1,000 versions or more, and large saves to forks, refresh statistics. - Tags count entities with the same tags together first. At 200,000 moments, reads on a fork take 1.1 to 1.5 times those on its source, also after both moved 5,000 moments (bench/fork-reads.mjs); test/fork-read-through-postgres.mjs is the oracle. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011fFY8eruEi1xAkkMBni13B https://github.com/openchronology/timeline-app/commit/a8eb4f4b4b1bd482848e33a118cb1bdfe51feef3
Open Forks read through to their source's index instead of copying it in the timeline