pa_module.index is set after calling the init() callback. Prior to that it's PA_IDXSET_INVALID. The init() callback can do things that cause hooks to be fired, and that in turn may make the module object visible to code that reads the module index. I'm not sure what would be the best way to fix this. The simplest way would be to add the new module to pa_core.modules before calling init(), but then module indexes would be consumed also by modules that fail to load. Perhaps that's not a significant problem, though.
Fixed in the next branch: http://cgit.freedesktop.org/pulseaudio/pulseaudio/commit/?h=next&id=8f2a37f9c12310c787a57f27eeb7ad3b859b84cb
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.