Decide how far to unwind a ladder after a pass failed.
Total, and defensive about its inputs: levelsAtPassStart is clamped into
[0, loadedLevelCount] so a stale or never-initialised value can only ever
under-drop (keep more levels than the pass started with) rather than discard
levels the pass did not add. Under-dropping degrades to today's behaviour;
over-dropping would throw away committed work.
The returned action also accounts for folded payloads and restored full
snapshots, so every geometry makes the same retry/truncate/unwind choice.
loadedLevelCount / levelsAtPassStart track logical ladder progress;
retainedPayloadCount / payloadsAtPassStart separately reveal whether
the failed pass's appends still exist as individual payloads or were folded
into a cumulative payload before the failure surfaced.
Decide how far to unwind a ladder after a pass failed.
Total, and defensive about its inputs:
levelsAtPassStartis clamped into[0, loadedLevelCount]so a stale or never-initialised value can only ever under-drop (keep more levels than the pass started with) rather than discard levels the pass did not add. Under-dropping degrades to today's behaviour; over-dropping would throw away committed work.The returned action also accounts for folded payloads and restored full snapshots, so every geometry makes the same retry/truncate/unwind choice.
loadedLevelCount/levelsAtPassStarttrack logical ladder progress;retainedPayloadCount/payloadsAtPassStartseparately reveal whether the failed pass's appends still exist as individual payloads or were folded into a cumulative payload before the failure surfaced.