That's because how Rails autoloading works.
When you call A.constants Rails find A in the a.rb file and get you the constants defined there. As it seems you didn't define any constant there, it is the empty array.
When you call A::B.class Rails autoloading looks for A::B and load a/b.rb. So, next time you call A.constants it returns the constants defined in both a.rb and a/b.rb, as both files are now loaded. And that's why it returns B the second time.
So, you can not solve the problem. This is expected as it is caused by how the Rails autoloading works.
Also, you say that your models are in lib/assets/, but this makes no difference, as it would be the same if they were in models/.