Repository navigation
fix(studio-server): history never drops an edit to make room for bytes it must keep - #9096
Conversation
Edit accuracy: accurate 275 (base branch 273), smooth 73 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) |
jerry-heygen
left a comment
There was a problem hiding this comment.
Approved at e48efe20. Pruning and history-budget accounting now use the same set of replaced bytes that must be kept. That prevents the budget from evicting an edit to make room for bytes the prune cannot free. The regression checks that both the edit and the protected bytes survive, while pending history entries still count toward the budget.
Exact-head regression and preview-regression workflows passed. The Studio Server test job was still running when checked; I did not run a live Studio save.
— Jerrai (pr-review)
What
A project's history no longer drops an old edit to make room for bytes that dropping it cannot free.
Why
When a save replaces a file's bytes, history keeps those bytes until it has taken the save in. They are in memory's list of things to keep, so a prune never removes them. They still counted against the history's size budget. Over budget, history prunes, sees it is still over, and drops its oldest edit, again and again, though none of that can free those bytes.
With the default 2 GB budget this needs a history already near its limit. It shows up in CI, where a test's budget is 16 bytes:
firstCopy.test.ts"keeps the original an early save's receipt names through a prune before its late copy is filed" failed in a merge queue run (2026-11-29). When the 30 ms quiet timer commits the late copy before the follow-up sweep has run, 13 replaced bytes push the history over, the late copy's own change is dropped, and the project's start becomes the saved bytes instead of the original.Related work
#8403 stopped counting the bytes held for a file's first copy, for the same reason. This covers the other list the prune keeps.
How
replacedHashes()lists both kinds of replaced bytes, and the prune and the budget both read it, so what is kept and what is counted cannot differ again.Test plan
projectHistory.saving.test.ts"stay kept, and never push an edit out of a history within its budget" (onmainthe history lists no edit at all). It depends on no timing.firstCopy.test.tsfails onmainwith the same two hashes as CI and passes here. That delay is not in this change.tsc --noEmitclean. All on Linux.No visible change
History bookkeeping in Studio Server. No screen changes.