Measures: the PostgreSQL change index, balances and split totals (#595)
- github
- github/openchronology/timeline-app
- commit
- main
- github/athanclark
A server timeline keeps a change index alongside its other trees: a persistent AVL tree (oc_change_nodes, rooted at change_root) of the times its measures' changes apply, each node with its own changes and its subtree's totals. - Versioned like the other index tables, so forks share and retire its rows; separation views build their own (oc_view_change_nodes). - Written whole by rebuilds and views (changePoints), kept by sparse saves: each changed moment's and duration's old changes taken away and new ones added, durations moving with the moments they follow. - oc_change_prefixes (with its view and fork variants) reads the changes up to several times along one path each, in one call per query. - Overviews split their totals across summaries and give balances, as the editor does (partitionTotals, windowBalances), so every change in the window counts once. - Index version 4: timelines with measures indexed before are rebuilt once; changing where a measure's durations apply rebuilds the index too. - Ongoing durations' placeholders no longer adjust totals, which already count their changes. - test/measure-balance-postgres.mjs (in CI) checks split totals and balances against hand sums, through sparse saves, in a copy reading through to its original and in a tag separation. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011fFY8eruEi1xAkkMBni13B https://github.com/circagraph/timeline-app/commit/02138ece7bc3ea2fdb1c8b40a76ae5e98f28417d
Related
Open Measures: the PostgreSQL change index, balances and split totals (#595) in the timeline