Repository navigation
The Chat store migrates in place: a schema step keeps every Chat, so a turn still running across an update is followed to its end - #252
Merged
Conversation
…a turn still running across an update is followed to its end Until now a store of another schema was renamed aside and a fresh one opened, so after any schema change the start found no Chat that was running a turn: its results stayed on the Computer until it idled out. The schema is now numbered steps (MIGRATIONS), as Code-OSS keeps its own SQLite stores (sessionDatabase.ts, runMigrations): a change appends the next version, and the steps above the file's user_version run once, in one begin-immediate transaction, re-read under the lock, with foreign keys off around it and checked before commit (sqlite.org/lang_altertable.html#otheralter). The first step is 20, the schema staging stores are at. A store older than that (the released v0.2.x stores are at 16, protocol major 1) is copied aside with VACUUM INTO by the window holding the write lock, then replaced in place, as Firefox Places replaces schemas it no longer migrates; nothing is renamed any more, which SQLite documents as a way to corrupt a file another connection holds. A store a newer Studio wrote is refused before anything writes to it, as Android's SQLiteOpenHelper.onDowngrade does by default. The journal mode is set only after the version is accepted, best effort as Code-OSS's configureSqliteJournal. Signed-off-by: SitgesRun <169425442+SitgesRun@users.noreply.github.com>
SitgesRun
force-pushed
the
store-migrations
branch
from
November 15, 2026 22:05
077ba0b to
3b3a340
Compare
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.
Until now, a Chat store of another schema was renamed aside and a fresh one opened. So after any schema change, the
Studio's start found no Chat that was running a turn, and that turn's results stayed on the Computer until it idled
out. Now the store migrates in place: a schema step keeps every Chat.
What changes
core/store.ts:SCHEMA_VERSION/SCHEMAbecomeMIGRATIONS, numbered steps, after Code-OSS's own SQLite stores(
src/vs/platform/agentHost/node/sessionDatabase.ts,runMigrations). A schema change appends the next version, and astep that has shipped is never edited. The steps above the file's
user_versionrun once, in onebegin immediatetransaction (
Store.tx). The version is read again under the lock. Foreign keys are off around the transaction andchecked before commit (https://www.sqlite.org/lang_altertable.html#otheralter). The first step is 20, today's staging
schema.
VACUUM INTOby the window that holds the write lock, thenreplaced in place. Firefox Places does the same for schemas it no longer migrates. The released v0.2.x stores are at
16 (protocol major 1, whose turns major-2 code cannot follow). Nothing is renamed any more: SQLite documents renaming
as a way to corrupt a file another connection holds (https://www.sqlite.org/howtocorrupt.html). The person is told in
one line where the copy went.
SQLiteOpenHelper.onDowngradedoesby default. Its schema, rows and journal mode stay as they were. The journal mode is set only after the version is
accepted, best effort, as Code-OSS's
configureSqliteJournal.test/storeMigrations.test.ts, which covers a newer store in either journal mode, a failed step rollingeverything back, schemas 2 and 11 copied aside once, and two real processes behind a barrier racing a current, a fresh
and a schema 11 store. One more test is in
protocolFlow.test.ts: a Chat whose turn still runs across a schema step isfollowed after the step, and its results land.
boundFolder.test.tsand the set-aside test inchats.test.tsaredeleted; what they checked is covered in the new file.
The plan was reviewed by Codex (read-only) in three rounds before coding. The last verdict was "Ready to code".
What I ran
SCHEMA_VERSION = 21and the newprotocolFlow test.
scripts/test-on-pine-dev.sh studio dd614c4…printedtests 330,pass 326,fail 3. The new testfailed with
AssertionError: nothing is set aside(actual{ schema: 20, path: '…/studio.sqlite.schema20-20261115T215948Z' }). The other two failures assert schema 20, asexpected on that scratch commit.
scripts/test-on-pine-dev.sh studio 3b3a340printed (the same on 077ba0b, before the Codex fix)npm test: 19s: tests 336,pass 335,fail 0,cancelled 0,skipped 1,render smoke: 30 of 30 pages rendered, anddone: PASSED in 97s. All 9 new tests show ✔ in the runlog.
npx tsc -p .: no errors in the changed files. The errors it does print come from the main checkout'snode_modules, which lacks
dugite.Codex on the code (read-only, after the gate)
One finding, B: the child-process test resolved on
exit, which can come before the child's stdout has drained. It nowwaits on
close(https://nodejs.org/api/child_process.html#event-close). Codex's verdict: "Matches revision 4; noproduction blocker, vacuous regression assertion, or substantive dead code found."