Admit scoped structural edits with snapshot identity manifests and replay proofs
This commit is contained in:
@@ -10,3 +10,12 @@ export function validateCanvasElementCounts(value:unknown,canvasIds:readonly Id[
|
||||
for(const count of Object.values(counts)){if(typeof count!=='number'||!Number.isSafeInteger(count)||count<0)throw fault('invalid_model_coverage');sum+=count;if(!Number.isSafeInteger(sum))throw fault('invalid_model_coverage');}
|
||||
if(sum!==total)throw fault('invalid_model_coverage');
|
||||
}
|
||||
|
||||
/** All active IDs in the capture, including records not yet received. */
|
||||
export type ElementOwners=Readonly<Record<Id,Id>>;
|
||||
export function validateElementOwners(value:unknown,counts:CanvasElementCounts,total:number):asserts value is ElementOwners {
|
||||
if(!value||typeof value!=='object'||Array.isArray(value)||Object.keys(value).length!==total)throw fault('invalid_model_identity');
|
||||
const actual:Record<Id,number>=Object.create(null);
|
||||
for(const [id,owner]of Object.entries(value)){if(!id||typeof owner!=='string'||!Object.hasOwn(counts,owner))throw fault('invalid_model_identity');actual[owner]=(actual[owner]??0)+1;}
|
||||
if(Object.keys(counts).some(id=>(actual[id]??0)!==counts[id]))throw fault('invalid_model_identity');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user