Add proof-backed parser byte reads and preserve retryable source failures

This commit is contained in:
2026-11-09 22:47:49 +08:00
parent f0ee0736b7
commit f11ea36b48
9 changed files with 220 additions and 14 deletions
+27
View File
@@ -617,3 +617,30 @@ excluded. Target component/version changes cancel with `target_changed`; removal
of the view canvas publishes fallback navigation and `canvas_changed` together.
Late updates/commit cannot use the canceled preview. Failed admission does not
replace the accepted baseline, and no chain, preview or gesture enters recovery.
Internal parser byte ports and read evidence (`import-byte-reader.ts`,
`import-read-proof.ts`) provide the next integration boundary for parsing before
whole-file hashing. NDJSON, JSON array, streaming document and its indexed
fallback all accept the optional `readBytes` port; the default Blob path keeps
its original slice request bounds and verifies the returned byte count.
The proof reader binds a file ID and byte length to SHA-256 hashes of aligned
16 KiB blocks, recording evidence only after an entire range is delivered.
A restored manifest can verify its recorded blocks before parsing resumes.
Unrecorded blocks are explicitly outside this proof: the manifest is neither a
whole-file digest nor authority to dispatch mutations. The current engine still
uses integrity version 1 and waits for its complete SHA; activating the new path
requires atomic job/proof checkpoints plus a durable verification/send barrier.
No recovery or source interpreter version changed in this unit.
The reader owns a hash Map (at most 4096 blocks for the 64 MiB source limit), a
bounded LRU byte Map (four blocks by default), and up to four shared in-flight
block Promises/four range reads. Each range is capped at 4 MiB. Aborted waiters
release their own read but do not free occupied native reads early or cancel
another waiter. Close fences late results and clears byte buffers; checkpoints
contain no byte buffers. These bounds do not assert native Blob memory release.
Byte I/O/capacity/integrity failures throw instead of becoming a terminal malformed
record. In particular a document reader preserves its ordinal for retry; the
engine pauses the import, retains its editable prefix, and resumes after the I/O
recovers. Ordinary malformed JSON/UTF-8 still uses the existing record diagnostics.