Admit durable scoped image uploads during partial model loading

This commit is contained in:
2026-11-09 14:35:41 +08:00
parent 5b35519562
commit 3a71c9ac57
21 changed files with 191 additions and 61 deletions
+3 -3
View File
@@ -12,7 +12,7 @@ function index(document:Document){let value=relations.get(document);if(!value){c
/** The caller captures this proof with the same document that becomes source bytes. */
export function loadingImportAdmission(snapshot:EngineSnapshot,target:Id,selection?:readonly Target[]):LoadingImportAdmission|undefined {
const state=snapshot.runtime.loading;if(!state)return;
if(state.version!==5||!snapshot.runtime.loadingRead)throw fault('model_loading');
if((state.version!==5&&state.version!==6)||!snapshot.runtime.loadingRead)throw fault('model_loading');
const source=snapshot.runtime.loadingRead,document=snapshot.document,required=new Set<Id>([target]);
const requireScope=(id:Id)=>{required.add(id);if(!ownerReady(state,source,document,id))throw fault('loading_scope_incomplete',[id]);};requireScope(target);
if(selection){
@@ -32,7 +32,7 @@ export function loadingImportAdmission(snapshot:EngineSnapshot,target:Id,selecti
return freeze({version:1 as const,sourceToken:state.sourceToken,operationSequence,requiredCanvasIds:[...required].sort()});
}
export function validateLoadingImportAdmissions(runtime:EngineSnapshot['runtime']):void {
const state=runtime.loading;if(!state||state.version!==5)return;
const state=runtime.loading;if(!state||(state.version!==5&&state.version!==6))return;
let maxSequence=0;for(const record of runtime.ledger.operations.values())maxSequence=Math.max(maxSequence,record.intent.sequence);
for(const job of runtime.imports?.values()??[]){validateImportJob(job);if(job.projectId!==runtime.acknowledged.projectId)throw fault('invalid_loading_import',[job.id]);const proof=job.source?.loadingAdmission;if(!proof||proof.version!==1||proof.sourceToken!==state.sourceToken||proof.operationSequence>maxSequence||!proof.requiredCanvasIds.includes(job.source!.targetCanvasId)||proof.requiredCanvasIds.some(id=>!structuralRequestScope(runtime,runtime.loadingRead!,id)))throw fault('invalid_loading_import',[job.id]);}
}
@@ -40,7 +40,7 @@ export function validateLoadingImportAdmissions(runtime:EngineSnapshot['runtime'
/** Revalidate the frozen copy topology before planning or resuming its source.
* Later source chunks may add unrelated owners, so compare only the closed cut. */
export function validateLoadingCopySource(snapshot:EngineSnapshot,job:ImportJob,document:Document):void {
const state=snapshot.runtime.loading,proof=job.source?.loadingAdmission;if(!state||state.version!==5||!proof)return;
const state=snapshot.runtime.loading,proof=job.source?.loadingAdmission;if(!state||(state.version!==5&&state.version!==6)||!proof)return;
const source=snapshot.runtime.loadingRead!;let expected=source.document;
for(const record of [...snapshot.runtime.ledger.operations.values()].sort((a,b)=>a.intent.sequence-b.intent.sequence))if(record.intent.sequence<=proof.operationSequence)expected=applyChanges(expected,record.intent.changes,false);
const selection=job.preparation?.selection??job.source?.plan?.selection;if(!selection)throw fault('invalid_loading_import',[job.id]);