Deferring object loading until first access, so large object graphs don't pay for what they don't touch.
Status: shipped (2026-07), with a few items left (below). In use by app collections and character sheet sections; tests/headless/TestLazyMaterializationNeutrality.js and TestPendingMaterialization.js cover it.
A stored slot marked lazy isn't loaded with its owner. It holds a placeholder until something reads it:
{
const slot = this.newSlot("locations", null);
slot.setShouldStoreSlot(true);
slot.setIsLazy(true);
}loadFromRecord puts an SvStoreRef (the record's pid) in the slot instead of instantiating the object and everything it reaches.onInstanceMaterializeLazySlot loads the object through the pool (whose identity map keeps one instance per pid) and writes it through the setter, so slot hooks and view sync fire as for any other change. No caller awaits anything. The objection in SvStorableNode ("no point in using this until we have coroutines") no longer applies.SvStoreRef is a load, so it marks nothing dirty and touches no timestamps. Hooks can tell: oldValue instanceof SvStoreRef means "there was no previous live value". Slot.isMaterializingAnyLazySlot() covers the one consumer that can't see the old value.SvStoreRef writes the pid back without loading it.subnodes included), and a deep tree gets a lazy boundary at each level.finalInitProto default on first access rather than at load (onInstanceMaterializeLazyDefault).SvLazyJsonRef, so importing a large object doesn't build subtrees nobody looks at.onFailedLazyLoadSlot<Name>() fallback. The SvStoreRef stays in the slot, so the next access retries (rate-limited by a negative cache on the ref), and a fallback written by the hook is a load, not a repair, so it isn't stored. An exception while deserializing propagates; it is a bug, not a missing record.The design and its measurements (boot went from 12.5 s to 8.3 s, with two-thirds of a mature store left unloaded) are in undreamedof.ai's "Slot Lazy Loading" plan.
finalInit() and afterInit() of a lazily held object run when it loads, not at boot. Nothing outside the subtree may rely on them having run.duplicate() loads the value: copying is an explicit "I need it" moment.setIsLazy(true) in SvStorableNode and its comment, and the commented-out hasBeenLoaded slot in SvJsonGroup, predate this design and can go.