todo-app/lib
Krzysztof kuhy Rudnicki 313368530a Restore notes at their own edit time, not "now"
Backup recovery and file import both wrote restored notes through `upsert`,
which stamps a fresh clock. Under crdt_sync's per-field last-writer-wins that
makes a *restore* outrank every other device: the restoring device claims it
edited every field just now, so it silently overwrites newer edits made
elsewhere on the next sync.

This is not hypothetical. The new desktop app seeded itself from BACKLOG.md and
rewrote 245 of 330 field clocks to today under a fresh node id, then synced --
taking authority over the phone for ~74% of all fields. Content happened to
survive (the copy came from the same data; only a trailing newline on 5 notes
differed via the Markdown round-trip), but nothing about the mechanism
guaranteed that.

The legacy sqlite migration already did the right thing for exactly this
reason, so the fix is to use that same helper everywhere a note is *restored*
rather than newly written. Renamed legacyRecordFor -> recordAtNoteTime, since
it is no longer migration-specific.

The freshness check in importNotes is unchanged: it decides whether the import
wins *locally*. The clock decides whether it wins on *other* devices, and an
import must not win there merely by being recent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-20 14:24:13 +02:00
..
data Restore notes at their own edit time, not "now" 2026-07-20 14:24:13 +02:00
desktop Add the desktop wrapper, and stop the test suite eating BACKLOG.md 2026-07-20 13:33:25 +02:00
sync Add the desktop wrapper, and stop the test suite eating BACKLOG.md 2026-07-20 13:33:25 +02:00
ui Make the app compile and run for web, behind platform seams 2026-07-20 13:14:03 +02:00
frame_stats_io.dart Make the app compile and run for web, behind platform seams 2026-07-20 13:14:03 +02:00
frame_stats_web.dart Fix the web instrument's arming flag, and let the wrapper redirect its paths 2026-07-20 13:47:38 +02:00
frame_stats.dart Make the app compile and run for web, behind platform seams 2026-07-20 13:14:03 +02:00
main.dart Make the app compile and run for web, behind platform seams 2026-07-20 13:14:03 +02:00