Codenames come into play when cards are referenced in the code. Currently the Wagn code is in a transition that makes it necessary to make codename a much more formal concept. The API needs it, "Packs" are code and need to refer to codenames. When the new permissions code needs the *create rule, it is asking for a codename but we can't really support this well yet.
Codenames only need to exist for names that are refered to in the code. We can gain a lot of performance by not having codenames exist unless a codename based lookup might succeed, so there is a big incentive to have lazy creation of codenames. At the time a codename is referenced it can be created.
The "implicite" value of a codename, the codename for a card if it has never been referred to before must be the same as the card's key. The only issue is what happens when there are codename references in the code. We only care about the simple card references since we can handle segmented paths by doing each segment on its own as a simple path. We would just create that card as soon as it is referenced. If a card with a matching key already exists and it has no codename already, we can just assign it (with the key's value) then (this isn't a real change to the cardname, it just sets codename in the db to what is was already by implication).