Chain delta journal checksums without rehashing every full recovery image

This commit is contained in:
2026-11-10 00:29:09 +08:00
parent d8bf6406c6
commit 5590d55bb1
6 changed files with 102 additions and 40 deletions
+31
View File
@@ -720,3 +720,34 @@ probe still exceeded the 240-second completion window. During the copy it accept
read-only diagnostics and displayed incremental content; commit/persistence costs
remain unresolved at that scale. Do not interpret the initial-scene improvement
or the batching checks as a passed 10000-node copy budget.
Browser storage writes `journalVersion: 2` deltas whose SHA-256 covers the ordered
JSON object `{journalVersion, baseRevision, baseChecksum, header, patches}`. The
prior checksum may belong to a full checkpoint, a v1 delta's reconstructed image,
or another v2 delta. Checkpoints and full-record fallbacks still hash the entire
image. Readers retain v1's full-image checksum rule and select the interpreter
explicitly; unknown journal versions fail. DB schema remains 4 and RecoveryImage
remains 1–17. This changes the internal journal interpreter, not wire protocol 2.
The recovery codec records exact UTF-8 byte lengths while producing immutable JSON,
including omission/null normalization and escaped Unicode. Only factory-owned
images expose the cached size, so choosing a smaller delta no longer first
serializes the complete owned image. Mutable callers retain defensive copying
and full size calculation. Noncanonical image header order/fields use a full
record to preserve exact serialization.
Each leader retains its last verified image/checksum and checkpoint revision in
WeakMaps. Both advance only after transaction completion. Every next cut still
checks stored metadata, prior checksum, continuous revision and local revision;
all file/depot writes remain atomic with the cut. Same-cut retries reread and
validate the chain, compare complete serialized images (including property order),
and keep the existing restrictions on new files. No Root cuts are skipped.
Recovery hashes/applies outside the read transaction, validates every reconstructed
image, and retains original frozen request bytes. A v1-only reader must reject a
v2 row rather than ignore its checksum semantics.
The 10000-child copy probe still exceeded its 240-second completion window after
this change. The exact hashed-input browser test proves removal of whole-image
hashing for ordinary adjacent delta writes; this is not a passed end-to-end copy
budget or a claim that encoding, rendering and dispatch costs are all resolved.