Repository navigation
fix(whiteboards): put a content hash in the board revision - #1462
Open
croakingtoad wants to merge 3 commits into
Open
croakingtoad wants to merge 3 commits into
croakingtoad wants to merge 3 commits into
Conversation
added 3 commits
November 20, 2026 14:54
A save publishes by rename, which frees the old inode; ext4 hands it to the next file, and mtime moves in coarse ticks. Two same-size saves in one tick then got the same dev:ino:size:mtime stamp, so a stale compare-and-set from another core (desktop + Server Edition on one project) could overwrite a newer board. The stamp now ends in the scene's sha256; a revision-only read hashes the file in 1 MiB chunks instead of holding it.
…s-core window now is The revision check reads and hashes the whole scene, so the window between two cores' check and rename is no longer just a stat long.
croakingtoad
marked this pull request as ready for review
November 20, 2026 20:21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
A whiteboard's revision (used for compare-and-set on save) was
dev:ino:size:mtimeNs. A save publishes by rename, which frees the old inode; ext4 hands that inode straight to the next file, and mtime moves in coarse ticks. So two same-size saves within one mtime tick could produce identical revisions. A stale compare-and-set from another process writing the same folder (e.g. a desktop app and a Server Edition on one project) would then pass and overwrite a newer board.The fix
The revision now ends in the sha256 of the scene bytes:
dev:ino:size:mtimeNs:sha256. What is left after that (same inode, size, tick and bytes) is the very file the caller saw.readRegularFileBytesNoFollowhashes from the same descriptor it reads, so the stamp is consistent with the bytes returned.read: false) still reads the file to hash it, but through a reused 1 MiB buffer, so a scene near the 64 MB cap is never held in memory whole.whiteboards.tsnow says what that window is: a read-and-hash of the scene plus the temp write and rename.Tests
Added to
src/core/read-regular-file.test.ts:read: false) gives the same stamp, on a file larger than one hash chunk.