summaryrefslogtreecommitdiffhomepage
path: root/packages/frontend/src/lib/snapshot-sequencer.ts
AgeCommit message (Collapse)Author
2026-06-01feat(frontend): SnapshotSequencer — reusable 'most-recent request wins' ↵Adam Malczewski
race guard Tiny, dependency-free class for the common pattern where a component fans out multiple HTTP calls that each return a full snapshot of shared state, and applying an older snapshot would clobber a newer one. begin() tags a new request, accept(seq) decides whether to apply the response. Pulled out as its own module (rather than inlined in ClaudeReset) because the next consumer of this pattern shouldn't have to re-derive it. The contract is small enough to test exhaustively in isolation: - accepts the first response unconditionally - accepts responses in send order - rejects an older response that arrives AFTER a newer one (the core race that motivated this) - rejects ALL stragglers once a newer one wins - handles the initial-load vs first-click race - equal seq is idempotent accept (defensive) - begin() seqs are monotonic and unique - state inspector reflects the watermark 8 tests, all green. No Svelte dependency — usable from any TS file.