Document session and save path !5

merged merged by cmc on 2026-10-05 00:06 UTC · krz/orgstar:phase1-document-session into main

Discussion

cmc

Adds the OrgDocument target and its plan.

  • threeWayMerge and lineEdits: line-based, Myers diff with prefix/suffix trimming, line endings kept.
  • DocumentState: edits against a revision through incremental reparse, grouped undo/redo, BOM-preserving encoding, reload of an unedited buffer, merge into an edited one, conflicts leave the buffer alone.
  • ViewState: selection and folds mapped through edits; folds pruned to existing headings.
  • Saver: read, merge if the file moved, check again, replace, read back. Every displaced version ends up on disk, in the buffer, or in recovery.
  • CoordinatedFileSystem (NSFileCoordinator, temp file, replaceItemAt with a kept backup) and FileRecoveryStore (last 20 per file).
  • Fault-injection tests put another writer's change before each read and before the replace. 30 new tests; all 117 pass; OrgDocument builds for iOS.