Skip to content

Documentation / @etherfold/core / openGenerationRegistry

Function: openGenerationRegistry() ​

openGenerationRegistry(port, caps): Promise<GenerationRegistry>

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

Open the registry, and SWEEP every stream subtree it does not know about.

Why the sweep is here, and why it is on OPEN ​

The ordinary reaping rule cannot reach an orphan. Reaping fires when a stream's LAST GENERATION goes, and a subtree written before generations existed -- under the chain-<chainId> placeholder the segmented-stream work left behind, or under any digest rule a later change replaces -- has no generation whose departure could fire it. Nothing enumerates it, nothing deletes it, and it does not even count against maxStreams, because the registry never learns of it. Left alone, every browser that ran the earlier code and then upgrades keeps its entire pre-upgrade stream forever, in the one runtime where storage headroom is argued at length.

It is keyed on "the registry does not know this digest" and NEVER on a particular placeholder value, so it collects an orphan from any cause, including a later redefinition of the digest rule and a crash between a generation's record going and its stream being dropped.

WHAT THE REGISTRY KNOWS IS NOW TWO THINGS, and that is ADR-0087's half here ​

A stream is KEPT when the last generation folding it goes away, so "claimed by no registered generation" stopped being the same question as "nothing ever fetched this". Read the narrow way, this sweep would undo the keep at the next restart -- silently, in the precise window the keep exists for, with a green gate. So the comparison is against the generations AND the registry's own STREAM RECORDS (GenerationRegistryState.keptStreams): a deliberately-kept stream is one this registry RECORDED, which survives a restart because it is a row, and a pre-generation orphan was never recorded and is still collected. The sweep's own stated purpose is untouched.

It runs on OPEN rather than on a timer, because that is the one moment the known set is authoritative and nothing is mid-write. There is deliberately no other way to run it.

Parameters ​

port ​

GenerationRegistryPort

caps ​

GenerationCaps

Returns ​

Promise<GenerationRegistry>