Expand description
Typed generational arenas.
Topology lives in arenas rather than behind reference counting; see
docs/DATA_MODEL.md §11. Keys are small, Copy, comparable and hashable,
which is what makes stable entity identity possible at all.
Slots are generational: freeing a slot bumps its generation, so a stale key fails to resolve instead of silently aliasing whatever was allocated there next. That failure mode is worth eight bytes per key in a kernel where the alternative is a wrong answer rather than a crash.
§Keys are scoped to the arena that issued them
A generation catches a key that has outlived its slot. It cannot catch a key from a different arena, because index 3 generation 0 means something in every arena, so a handle from one document resolved against another comes back with whatever sits at that index, and answers confidently about the wrong entity. Nothing about the result says so.
Every arena therefore takes an identifier the first time something is put
in it, every key it issues carries that identifier, and every lookup
compares it. A foreign key resolves to None, exactly as a stale one does.
The cost is four bytes per key and one comparison per lookup, against a
whole class of silent wrong answers.
Cloning an arena keeps its identifier, because a clone is the same document and handles into it should keep working. Identifiers are per-process and are never serialized: a document read back from a file is a new arena with a new identifier, and the reader re-stamps the handles it read.
Structs§
Constants§
- UNSCOPED
- The identifier a key carries before it has been bound to an arena.