Stream native imports before full source verification with durable send seals

This commit is contained in:
2026-11-09 23:24:53 +08:00
parent f11ea36b48
commit 0ce3abbe04
17 changed files with 230 additions and 63 deletions
+32 -6
View File
@@ -619,8 +619,8 @@ 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
`import-read-proof.ts`) support progressive native imports before
whole-file hashing completes. 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.
@@ -628,10 +628,36 @@ 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.
whole-file digest nor authority to dispatch mutations. New native jobs use source
integrity version 2 and recovery format 17. Parser cursor, IDs, pending locators,
read evidence and accepted document changes publish through the same StateRoot.
The complete-source digest runs concurrently; content can display and be edited
before that digest finishes. Legacy source version 1 keeps its SHA-first path,
including array recovery 14 and streaming document recovery 16. Copy sources
retain their existing interpreters. IndexedDB schema remains 4; wire remains 2.
The scheduler admits no newly compiled project mutation while any accepted source
is unsealed or its seal has not reached storage. `durableImportSeals` is a derived
file-ID → SHA Map rebuilt from each successfully stored cut, not a permission
boolean or a second job store. Existing immutable requests keep their original
verified bodies. The gate is conservatively project-wide, including unrelated
new edits; dependency-scoped dispatch is not claimed.
Pause, partial success and cancel after an accepted prefix retain verification
and source pins. Cancel before any accepted content abandons verification without
blocking unrelated sends. Read/digest failure retains local content and the gate;
`retry()` rebuilds the reader and verifies again without restarting a cancelled
parser. Reopening verifies saved block evidence before continuing the same cursor
and IDs. Known complete hashes are checked before resumed parsing. A late SHA
seal changes source metadata without changing parser generation; every parser
checkpoint merges that current engine-owned metadata instead of reverting it.
Public runtime updates cannot forge or remove existing proof/hash evidence.
Readers and verification tasks belong to ProjectEngine, with per-job Maps and
AbortControllers. Recovery holds abort and later restart unfinished verification;
close fences late results and releases readers. Job source metadata is durable;
read caches, pending Promises and controllers are transient. No extra document,
business queue or history stack is introduced.
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