export const rootReceiptHistories = [ 'apply two accepted root receipts', 'cleanup from root publication', 'cancel root commit before acceptance', 'ignore an application rejection from the retired root', ] as const export type ProgressHistory = { route: 'conflict' | 'peer' | 'shared-key' | 'no-include' host: 'microtask' | 'timer' nonempty: boolean materialization: 'inline' | 'facade' shift: number rankScale: number moveWindow: boolean orderedFailureBeforeReload?: 'previous' | 'current' holdOutput: boolean cleanupHeldOutput?: boolean terminalWindowAdmission?: 'before-reload' | 'during-replay' | 'after-pause' rootReceipt?: (typeof rootReceiptHistories)[number] truncateDuringReload?: boolean interruptPause?: | 'cleanup' | 'cleanup-unawaited' | 'reload' | 'failure' | 'repeat' | 'source-crash' | 'source-first-load-failure' siblingReplay?: | 'held' | 'recovers' | 'fails' | 'abort-error' | 'replaces-abort-error' | 'recovers-with-held-output' holdFacade?: boolean } export type WindowRow = { id: number rank: number markers: Array details?: Array } export const pivotOf = (history: ProgressHistory) => history.shift + 3 export const terminalSourceInterruption = ({ interruptPause, }: ProgressHistory) => interruptPause === 'source-crash' || interruptPause === 'source-first-load-failure' // This replay can start its window before reload or at the answer callback. export const activeWindowBeforeReload = (history: ProgressHistory) => history.siblingReplay === 'replaces-abort-error' && !history.moveWindow export function sourceFacts(history: ProgressHistory) { const rows = [1, 2, 3, 4, 5].map((ordinal) => ({ id: history.shift + ordinal, rank: ordinal * history.rankScale, })) const marked = new Set( rows .filter( ({ id }) => id !== history.shift + 2 && (!history.nonempty || id !== history.shift + 4), ) .map(({ id }) => id), ) return { rows, marked } }