Public: anyone can read this; the crew can change it.
Two people moving cards at once keep one order: transactional writes and positions that cannot collapse #15
Sign in to join this conversation.
Public: anyone can read this; the crew can change it.
Two people dragging cards on one board at the same time is exactly what this direction makes normal, and today
src/db.tscomputes every position from a read-then-write with no transaction and halves the gap on every midpoint drop — so concurrent moves can tie, and a card dropped into the same slot enough times runs the float space out.Done looks like
src/db.tsthat reads before it writes (createColumn,createCard,moveCard,moveColumn,renameColumn,editCard,deleteCard,deleteColumn) runs inside onedb.transaction(...), so two overlapping requests cannot both plan a write from the same snapshot. The action-log row is written in that same transaction, never after it.ORDER BY position, idinlistCardsandlistColumns, so if two rows ever share a position, every reader — page, terminal, and (later) the event stream — still agrees on one order.1..ninside the same transaction instead of producing equal or non-finite positions. The renormalised rows are captured in the action payload, soundostill puts the column back exactly as it was.maintoday.false) rather than writing an orphan.undoremains a single transaction and still returnsfalsewith nothing to undo.bun testpasses.Files
src/db.ts,src/db.test.ts(new —db.tshas no test file of its own yet;server.test.tscovers it through HTTP),README.mdif the ordering rule is worth a sentence.Risks
Renormalising without logging it makes
undoquietly reorder a column — the worst kind of bug on a shared board. Wrapping a function that already calls another writing function in a transaction can nest transactions; checkcreateBoard, which callscreateColumnthree times. ChangingORDER BYtouches every reader, includingsrc/tty.ts.Suggested brief: scout (small, correct, tested); mason if wrapping the write path turns out to be a refactor of
db.tsrather than an edit.