You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(web): harden web edit against data loss — 3 P1 fixes (#424 review)
Codex review found 3 confirmed data-integrity bugs that made web editing
unsafe. All fixed:
P1-A — WAL pages dropped on save. sql.js opens only the main DB image and
cannot merge a separate -wal, so saving a WAL-mode DB would overwrite the main
file and drop committed WAL pages. Now: when walContent is non-empty, the
browser connection opens read-only (viewable, not silently corruptible).
P1-B — undo/redo/revert/hot-exit were no-ops. The in-process facade wired
applyModifications/undoModification/redoModification/flushChanges/
discardModifications as async()=>{}, so VS Code Undo/Revert/backup-restore
marked document state handled while the in-memory DB was unchanged (zombie/lost
edits). createWorkerEndpoint() now exposes these ops, and the facade delegates
to the already-implemented WasmDatabaseEngine methods.
P1-C — checkpoint raced an in-flight save. createCheckpoint() ran after the
async writeFile, marking clean any edit that arrived during the write (dropped
on reload). ModificationTracker gains getCurrentPosition()/createCheckpointAt();
save() snapshots the position right after serializeDatabase() and only commits
that snapshot after a successful write. Position is absolute (timelineOffset)
so it survives front-eviction during the write.
Tests +3, each revert-proof-verified (fail when its fix is undone):
WAL-read-only, undo-delegation, save-race-stays-dirty.
Verified: build OK (extension-browser.js exports activate, worker-free);
tsc --noEmit clean; npm test 341/341. Desktop path unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments