Persist versioned Blob recovery cuts with cooperative JSON serialization

This commit is contained in:
2026-11-10 19:01:25 +08:00
parent b051509dee
commit 8958d835b9
8 changed files with 155 additions and 26 deletions
+31 -2
View File
@@ -230,7 +230,7 @@ formats 1–12 and reject unknown future formats. A reopened binding can display
shared local bytes, and undo/redo reuse the asset without uploading again. The
workspace closes projects before its depot; retiring the identity fences late work.
The browser adapter uses IndexedDB version 4. After a proven stored-upload cut, a
The browser adapter uses IndexedDB version 5 (files retain their version-1 pointer format). After a proven stored-upload cut, a
project's `files` row holds an opaque pointer to digest-addressed `asset-bytes`.
Unconfirmed uploads and import source files keep their original Blob rows. Use
`readFile` / `scanFiles`; direct assumptions that every raw files-store row is a
@@ -362,7 +362,8 @@ same bytes. Legal prefixes survive malformed array/footer tails with an explicit
partial result. Headers following the elements array require indexed preparation
to establish ownership first. Legacy parser 4 jobs keep their indexed interpreter.
New document jobs use recovery v16; legacy document jobs keep v15 (readers accept
1–16, reject 17), without changing DB v4 or the wire protocol. Resource-bearing
1–16, reject 17). That parser change retained DB v4 and the wire protocol; the
subsequent checkpoint representation upgrade uses DB v5 separately. Resource-bearing
records use fresh authorization when the host provides a depot and authority;
missing capabilities or denied resources produce explicit partial results.
Complete service acceptance remains pending. Source SHA verification still reads
@@ -957,3 +958,31 @@ resource authorization limits, durable send barriers and source ordering remain
in force. Hosts that set a lower runner ceiling retain that ordinary-batch bound. An
indivisible SCC can exceed the soft unit limit under its existing hard byte and
change-count limits.
Full browser recovery cuts now use a versioned envelope:
`{checkpointVersion:1, header:{formatVersion,rootRevision,localRevision}, bytes:Blob, checksum}`.
The Blob contains exact UTF-8 `JSON.stringify(image)` bytes, not another document
model. It can represent a checkpoint or a full replacement journal cut. Delta
journals retain versions 1/2; legacy object cuts remain readable. DB v5 fences DB
v4 clients before these rows are written. Recovery envelope/wire versions do not
change. Rolling application code back requires retaining the v5 storage reader;
an old v4 client cannot open the upgraded database.
For codec-owned sealed images, serialization splits large containers/strings and
uses existing codec byte facts to stringify small owned subtrees natively. It
preserves key order, escaping and surrogate pairs, yielding on the shared soft
time/work budget before starting an IDB write transaction. External images retain
the defensive capture/native JSON path. Each yield rechecks the storage owner.
The complete Blob and checksum are prepared first; head, cut, files and depot
changes still commit in one transaction. No Root is skipped. Reopening validates
headers/sequence, hashes exact Blob bytes, decodes strict UTF-8, checks the decoded
header and then applies later deltas. Future checkpoint versions reject reads
and writes; malformed/tampered data is never treated as an empty document. Legacy
recovery, JSON parse, recovery-image encoding, same-cut retry comparison and
individual native operations still have synchronous work; this is not a strict
6ms bound for all storage paths or a disk-space reduction guarantee.
A blocked schema upgrade retires its pending open. If the old connection closes
later, that abandoned request aborts in `onupgradeneeded` rather than silently
upgrading after rejection. A fresh adapter can retry once the blocking client has
closed; closing an adapter before its upgrade event also aborts the pending open.