Measures: declarations, exact values, validation and formats (#572)
- github
- github/openchronology/timeline-app
- commit
- main
- github/athanclark
A timeline declares measures, named exact quantities its moments and durations carry (#570): `measures: {name: {type: "mpz" | "mpq", label?}}` in its settings, and values under `metadata.measures` as text. - Core (src/measures.ts): declarations validated (lowercase names, at most 32, labels); values parsed exactly from integers, fractions or decimals, stored canonically ("1250", "3/2"), zeros left out, bounded like times (length and the server's digit limit, now in numeric.ts). Documents, sparse saves and durations check values against the declarations: an undeclared name, or a fraction for an `mpz` measure, is refused, naming the entity. - Declaration changes: a save may add, relabel or widen (mpz to mpq). Renaming, removing or narrowing rewrites values (remeasuredEntities): renamed values move, removed ones drop, and narrowing is refused while a fraction remains. On a server that is POST /api/timelines/{id}/measures (server/measure-change.mjs), one save streamed like map-times; a plain sparse save making such a change gets 409. - Server: oc_timelines.measures, written by saves, rebuilds and sparse saves, copied to forks, in history settings, merges, retention, log writers, metadata, documents and exports; OpenAPI schemas. - Desktop: `measures` in the .och file's timeline_extras, patches and och-convert. Editor: the index, drafts, server metadata, settings conflicts and pull-request summaries carry it. - Docs (measures.md), unit tests and a PostgreSQL test (in CI). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011fFY8eruEi1xAkkMBni13B https://github.com/circagraph/timeline-app/commit/8d1d40451e8d61d653ce1497d24106a610be2e91
Related
Open Measures: declarations, exact values, validation and formats (#572) in the timeline