circagraph
Sign inSign up

openchronology/timeline-app on GitHub

The OpenChronology repository on GitHub, mirrored by och-import-github: issues and pull requests as durations (ongoing while open), what happened to them as moments, plus releases, milestones, commits and branches. The Branches view shows the most recently active branches each in a track of its own.

Source: https://github.com/openchronology/timeline-app

3,131 moments · 2026-10-05 CE 20:21:49 UTC – 2026-11-16 CE 12:10:45 UTC · by @athan · @athan

#577 Measures: declarations, exact values, validation and formats (#572)

–

  • github
  • github/openchronology/timeline-app
  • github/openchronology/timeline-app#577
  • pull request
  • state:merged

Closes #572, part 1 of #570. Moments and durations can carry **measures**: named, exact quantities such as a cost in cents or hours worked. This PR adds the declarations, values, validation and formats. Totals, the editor fields and presentation come in #573–#576. ## Format ```json "measures": { "cost": { "type": "mpz", "label": "Cost (cents)" }, "hours": { "type": "mpq" } } ``` An event gives its values in `metadata.measures`, as text: `{"cost": "123456", "hours": "3/2"}`. - **Types:** `mpz` holds whole numbers and `mpq` holds fractions. Both are unbounded and exact. - **Values:** integers, fractions or decimals, always as text. They're stored canonically (`6/4` becomes `3/2`, `12.50` becomes `25/2`), and zeros are left out. - **Size:** values are bounded like times, by length and by the server's digit limit, which moves to `numeric.ts`. - **Refused:** values for measures the timeline doesn't declare, and fractions for `mpz` measures. Errors name the entity. ## Changing declarations - **Plain saves:** a save may add measures, relabel them, or widen `mpz` to `mpq`. - **Rewrites:** renaming, removing or narrowing a measure rewrites values with `remeasuredEntities`: - renamed values move to the new name; - removed values are dropped; - narrowing is refused while any value is a fraction. - **On a server:** these go through `POST /api/timelines/{id}/measures` (`server/measure-change.mjs`). It's one save, streamed like `map-times`. A plain sparse save that tries one gets a 409. ## Where it goes - **Server:** - `oc_timelines.measures`, written by saves, rebuilds and sparse saves; - kept by forks, history settings, merges, retention, log writers, metadata, documents and `.ochx` exports; - documented in OpenAPI. - **Desktop:** `timeline_extras` in `.och` files, patches and `och-convert`. - **Editor:** - the index, drafts and server metadata; - settings conflicts and pull-request summaries. ## Tests - `test/measures.test.mjs` (unit). - `test/measures-postgres.mjs`, added to CI: saves, sparse saves, the 409 guard, `POST /measures` (renames, removals, narrowing), sliced patches, copies. - Locally, these also pass: `npm test` (apart from `contents.test`'s known local ENOBUFS; it passes in a clean worktree), Rust `cargo test --lib`, `incremental-postgres`, and `default-view-live-postgres`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_011fFY8eruEi1xAkkMBni13B https://github.com/circagraph/timeline-app/pull/577

Related

Open #577 Measures: declarations, exact values, validation and formats (#572) in the timeline

#577 Measures: declarations, exact values, validation and…