Undoing a 10,500-card sprint close took 282 s and redoing it 578 s, about
27 ms a card: each record of a History row cost some thirty database
round trips - a read per record in the preflight, two ownership checks
(two reads each) around every read, the same again around a readback
after every write, and the whole row read back record by record twice
more at the end.
Now a row's records are read in one query per type (readTargets), and
inspectScrumHistoryWrites takes that as readMany, bracketed by one
ownership check before and one after: the worker's claim and the source
row only ever go from current to displaced, so current before and after
the read means current throughout it. Every write keeps its ownership
check right before it, after the read it is computed from; the readback
after a write confirms the value landed and leaves ownership to the next
write's fence and the batch's final readback. A sprint or release that
thousands of cards name is looked up once, not once a card. The
permission check stays per card.
The 10,500-card start / close / undo / redo test went from 14 min 27 s
to 6 min 7 s on the same machine; all 18 Scrum tests pass.
tests/scrumHistoryWriteState.test.cjs pins one read and three checks
for a bracketed read, ownership lost during it, a short answer, a missing
record and identities checked before any read (negative), and that every
write in the path is still fenced after its read.
Thanks to xet7 !
Scrum History judged "the record has the expected values and revision"
as proof of which record it was. One deleted and recreated under the
same _id - a restore by someone else - passed that test, so a retried
undo could delete a record from another lifetime. Maintainer decision
of 2026-09-30: every Scrum sprint, release and event now carries a
random incarnation per lifetime, set where it is created (the Scrum
methods, a board transfer import's plan, and a Scrum History restore).
A new checkpoint records the incarnation each target has and, for a
record it creates, the one it will have, chosen before writing so a
replay recognizes its own insert; the write-state check refuses any
other lifetime. History content never carries an incarnation, so a
restore always starts a new lifetime, and an update never unsets it.
Checkpoints and records from before incarnations keep working as they
did, and their completion identity is unchanged.
Unit tests cover every state with and without incarnations and the
planned lifetimes; a full-app test creates, undoes and redoes a sprint,
then replaces it with an identical record of another lifetime mid-undo:
the retry refuses and leaves it, where the previous code deleted it.
562 server tests pass.
Thanks to xet7 !