Skip to content

Documentation / @etherfold/core / displacedBySuccessor

Function: displacedBySuccessor() ​

displacedBySuccessor(arriving, generations, slots, runtime): GenerationRecord[]

Defined in: packages/core/src/generation/registry.ts:646

WHAT A REGISTRATION INTO successor DISPLACES -- the rule BOTH containers apply, with ONE home (ADR-0071).

successor holds AT MOST ONE (ADR-0084), so registering into it replaces whatever it held, and the generation displaced is dead work: nothing promotes to it, nothing reverts to it, and re-folding it would be work for an answer nobody will ask for. This says WHICH records that covers; DROPPING them is the caller's, because dropping differs per container (one holds engines, the other receivers) while the rule does not.

The safety property is this function, and it is ONE clause ​

A generation ANY OTHER slot names is untouchable, which covers the incumbent (canonical) and the revert target (predecessor) together. Stated as one clause rather than left to follow from a loop, because it is the whole of what makes replacement safe and two copies of it in two containers is how a revert target gets deleted by the twin nobody was reading.

Kinds of record come back, and they are the same rule seen more than once:

  1. What successor NAMES, whether or not this process holds a fold for it -- after a restart it does not, and that is exactly the case the DURABLE slot exists for.
  2. Every generation this container HOLDS A FOLD FOR that no slot names, which is what a DECLINED drop leaves behind.
  3. And, on a runtime that answers unheldIsCollectable (below), every record no slot names that this container holds NO FOLD for either.

That third one is the ONE axis the two runtimes differ on, and the difference is whether anything ELSE would ever collect such a record: where an operator's reclaim will, a registration leaves rows it never touched alone.

Nothing is displaced at all when the registry has no canonical generation (the first registration takes canonical and supersedes nobody) or when canonical or successor ALREADY names the arriving generation (a restart on the canonical fold, or on the pending successor itself, takes nobody's place). That second clause is also what keeps a page RELOAD from collecting anything: the fold a tab arrives with is the one canonical names. What predecessor names is NOT in that clause: an arrival of it is RE-ARMED into successor (create, rule 3, ADR-0094), so it takes that slot and displaces what the slot held, exactly as any arrival does.

NEWEST FIRST, which is what lets a whole replaced chain go in ONE pass: the ordinary churn leaves a replaced WRITER with a replaced FOLLOWER on its stream, and the writer is only droppable once the follower is gone, so walking back to front drops them in the order that frees both.

Parameters ​

arriving ​

GenerationId

generations ​

readonly GenerationRecord[]

slots ​

GenerationSlots

runtime ​

DisplacementRuntime

Returns ​

GenerationRecord[]