fix(studio): rebase the debounced write on the current document - #256
Merged
Merged
Conversation
53 tasks
LeadcodeDev
force-pushed
the
fix/studio-stale-write
branch
2 times, most recently
from
September 22, 2026 08:35
3ba4914 to
64683cc
Compare
write_prop/write_root_field/write_content capture m.raw (the ENTIRE document) at edit time, then 250 ms later serialize that snapshot over the whole file. If the notify watcher reloads the model from an agent/editor write during that window, the payload's raw is already stale and the flush wipes the agent's change completely — not just the edited pointer. write_and_note then registers the result in the self-write ledger, so app/mod.rs:141 makes the watcher skip the resulting event: memory holds the agent's version, disk holds the studio's stale version, and nothing ever reconciles them. No error is shown (m.write_error = None on success). This is the crate's headline workflow (baseline/diff review of agent edits), so the race is routine, not exotic. Fix: Before flushing, re-read the file and verify it still matches what the payload was derived from (hash the source at snapshot time, compare at write time); on mismatch, re-apply the single pointer mutation to the CURRENT disk content instead of replaying the stale whole-document snapshot, or surface a conflict in write_error. Do not register a self-write for a flush whose base no longer matches the disk. Refs #220
LeadcodeDev
force-pushed
the
fix/studio-stale-write
branch
from
September 22, 2026 08:45
64683cc to
85f344b
Compare
LeadcodeDev
added a commit
that referenced
this pull request
Sep 22, 2026
write_prop/write_root_field/write_content capture m.raw (the ENTIRE document) at edit time, then 250 ms later serialize that snapshot over the whole file. If the notify watcher reloads the model from an agent/editor write during that window, the payload's raw is already stale and the flush wipes the agent's change completely — not just the edited pointer. write_and_note then registers the result in the self-write ledger, so app/mod.rs:141 makes the watcher skip the resulting event: memory holds the agent's version, disk holds the studio's stale version, and nothing ever reconciles them. No error is shown (m.write_error = None on success). This is the crate's headline workflow (baseline/diff review of agent edits), so the race is routine, not exotic. Fix: Before flushing, re-read the file and verify it still matches what the payload was derived from (hash the source at snapshot time, compare at write time); on mismatch, re-apply the single pointer mutation to the CURRENT disk content instead of replaying the stale whole-document snapshot, or surface a conflict in write_error. Do not register a self-write for a flush whose base no longer matches the disk. Refs #220
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.
Severity Medium, category correctness. Location:
crates/rustmotion-studio/src/editor/inspector.rs:2119Impact
write_prop/write_root_field/write_contentcapturem.raw(the ENTIRE document) at edit time, then 250 ms later serialize that snapshot over the whole file. If the notify watcher reloads the model from an agent/editor write during that window, the payload'srawis already stale and the flush wipes the agent's change completely — not just the edited pointer.write_and_notethen registers the result in the self-write ledger, soapp/mod.rs:141makes the watcher skip the resulting event: memory holds the agent's version, disk holds the studio's stale version, and nothing ever reconciles them. No error is shown (m.write_error = Noneon success). This is the crate's headline workflow (baseline/diff review of agent edits), so the race is routine, not exotic.Fix
Before flushing, re-read the file and verify it still matches what the payload was derived from (hash the source at snapshot time, compare at write time); on mismatch, re-apply the single pointer mutation to the CURRENT disk content instead of replaying the stale whole-document snapshot, or surface a conflict in
write_error. Do not register a self-write for a flush whose base no longer matches the disk.Evidence the audit read
Part of the September 2026 audit remediation chantier. Refs #220 (RM-13).