Measures: totals in the editor's index and its overview groups (#574)
- github
- github/openchronology/timeline-app
- commit
- main
- github/athanclark
The editor's TimelineIndex keeps its moments' measure totals by time in a MeasureTree (src/measure-tree.ts): an AVL tree over distinct times whose nodes keep their own values and their subtree's totals, one exact rational per measure. Addition is a monoid, so rotations regroup sums without changing them. - Built when first read for a timeline with measures, then kept up to date: a moment that moves or changes is one subtraction and one addition on a path; a change of declarations rebuilds it. - A range's totals in O(log n) (measureTotals); each overview group carries `totals` (canonical text by name, zeros left out), and coalesced groups add theirs (addTotals). - Tests check ranges, groups and coalesced groups against summing by hand through thousands of random inserts, moves, edits and deletions. The PostgreSQL and SQLite trees follow; durations count at their start in #576. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011fFY8eruEi1xAkkMBni13B https://github.com/circagraph/timeline-app/commit/843d1d7534e4fbe5f2473e29975e60f228cc07c4
Related
Open Measures: totals in the editor's index and its overview groups (#574) in the timeline