Buck nine fix sourcestamps with unknown codebase

Fix a bug and add test-coverage for it.

I found it difficult to back-port this to master since the stampsByCodebase doesn't exist in that branch.