Persist compact history transition evidence with recovery and resource pins
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { Change, CoreSnapshot, Document, ElementRecord, Id, OperationIntent, Registry } from '../canvas-core/types.ts';
|
||||
import { historyTransitionChanges } from '../canvas-core/history-transition.ts';
|
||||
import { ancestors } from '../canvas-core/document.ts';
|
||||
import type { FrozenRequest, LedgerSnapshot } from './ledger.ts';
|
||||
import type { OperationStatus } from './scheduler.ts';
|
||||
@@ -88,6 +89,11 @@ export function resourcePins(snapshot: CoreSnapshot, ledger: LedgerSnapshot, reg
|
||||
if (record.intent.operationType === 'asset.upload') pin(record.intent.resourceId, `operation:${record.intent.id}`);
|
||||
else changes(record.intent.changes, `operation:${record.intent.id}`);
|
||||
}
|
||||
const pending=[...ledger.operations.values()].filter(record=>record.phase!=='resolved'),earliest=pending.reduce((value,record)=>Math.min(value,record.intent.sequence),Infinity);
|
||||
for(const record of ledger.operations.values())if(record.intent.sequence>=earliest&&record.intent.historyTransition){
|
||||
if(record.intent.historyTransition.version!==1){complete=false;continue;}
|
||||
changes(historyTransitionChanges(record.intent.historyTransition),`history-transition:${record.intent.id}`);
|
||||
}
|
||||
for (const [owner, ids] of explicit) for (const id of ids) pin(id, owner);
|
||||
return Object.freeze({ complete, pins: readMap(new Map([...pins].map(([id, owners]) => [id, readSet(owners)]))) });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user