fn ensure_registry(guard: &mut Option<BTreeMap<PortId, Arc<Port>>>)
Ensure the registry is initialized (called lazily).