mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-31 20:09:11 +00:00
ccdfb64921
An entry revision advances on every change to that entry, which makes it a cheap marker for what has moved on in a rundown. The client did not maintain it: an optimistic entry carried the old revision, so the entry the server returned always differed from ours by that one field. That difference is enough to defeat structural sharing. A new entries object recomputes the rundown metadata, which fires the effect behind the list, which re-renders every visible row. Editing one title on a fourteen entry rundown cost eight structural and sixty-one attribute mutations, twice over. - optimistic patches apply the same revision bump the server does, so an unchanged entry keeps its identity and a refetch costs nothing to render - the rundown metadata memo keys on the fields the derivation reads, so a change of rundown revision alone no longer churns the list - editing an entry now reads the server response, which is the authority on what was applied, and only writes when it differs from what we predicted Measured on the same edit: eight to four structural, sixty-one to forty-one attribute mutations. Both changes are needed, neither helps on its own. Two bugs found on the way. A swap stored the pre increment revision, so swapped entries were indistinguishable from untouched ones. The optimistic batch edit spread the request envelope onto the entry rather than the patch, so it never applied the edit it was predicting. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011a5cbVjNC5XXF88b2PkUCa
51 lines
2.3 KiB
Markdown
51 lines
2.3 KiB
Markdown
# Ontime domain invariants
|
|
|
|
Load only for touched domains. Add only stable, recurring invariants; not one-off bugs.
|
|
|
|
## Rundowns and entries
|
|
|
|
- Keep `entries`, `order`, `flatOrder` normalised.
|
|
- Keep group membership, group entry lists, child `parent` references consistent.
|
|
- Preserve entry identity and supported types across patch, clone, group, ungroup, reorder.
|
|
- Distinguish loaded vs background rundown. Prefer explicit rundown ID over global current state.
|
|
- No caller-owned rundown mutation unless explicitly contracted.
|
|
- Revisions mark change: a rundown revision advances on every commit, an entry revision on every
|
|
change to that entry. Delays carry no revision. Optimistic client updates apply the same bump the
|
|
server does, so an unchanged entry keeps its identity and clients can compare revisions to tell
|
|
what moved on.
|
|
|
|
## Persistence, realtime, cache
|
|
|
|
- No partial commit on failure.
|
|
- Preserve revision/transaction semantics for loaded and background rundowns.
|
|
- Persist before websocket refetches, runtime updates, integration notifications, or cache assumptions.
|
|
- Notify only invalidated consumers; never leave client cache stale.
|
|
- Avoid duplicate listeners, notifications, invalidations, lifecycle effects.
|
|
- Reconnect/refetch must converge on authoritative state.
|
|
- Align query keys and websocket refetch keys with the changed resource.
|
|
|
|
## Timers
|
|
|
|
Use temporal values by meaning: `Instant` for epoch time, `TimeOfDay` for local time since midnight, `Duration` for elapsed time, `Day` for calendar offsets. Convert through `timeCore`; never interchange as raw numbers.
|
|
|
|
Active work: [runtimeState time-core migration](../migrations/runtime-state-time-core.md).
|
|
|
|
When relevant, cover interactions among:
|
|
|
|
- midnight/day offsets;
|
|
- linked events/gaps;
|
|
- delays/skipped entries;
|
|
- count-to-end;
|
|
- absolute/relative offsets;
|
|
- warning, danger, finish, roll, end-action transitions;
|
|
- loaded/next-event state.
|
|
|
|
Pass time/state explicitly to keep rules deterministic and unit-testable.
|
|
|
|
## Imports and migrations
|
|
|
|
- Treat project files, spreadsheets, custom fields, migrated data as untrusted.
|
|
- Preserve fields the import/migration does not own.
|
|
- Validate/parse into the current model before runtime logic.
|
|
- Avoid source mutation; test round trips and non-mutation when preservation matters.
|