Files
orca/src
Neil c2ab75f5e4 fix(diffs): reject a revalidation payload that predates the live draft
Adversarial review (Opus) proved the settle-time `dirty` re-check was still a
TOCTOU: `acknowledgeSectionSave` clears `dirty` on its own timeline, and nothing
in the edit or save path bumps the section load token, so a fetch started before
an edit could settle after the save and commit pre-draft disk bytes. The user's
saved text silently reverted on screen, and because the edit-state scope is now
stable, the remount cleared the undo history instead of merely orphaning it.

Pin the draft at fetch start and commit only when the draft has not moved, or
when the payload agrees with the draft that replaced it -- a post-save
revalidation is fresh and must still land.

Also aligns the diffSession restore predicate with Pierre's canRestoreDiffSession
(old-side name plus element-wise line compare). Pierre THROWS on a retained
session that cannot resume against the delivered old file, so the looser
join('') check risked manufacturing that error on a renamed file.
2026-09-10 18:13:31 -07:00
..