discard_copied_key inferred ownership by rereading the source's vault.keyref:
a staged copy whose account differed from (or had no) source pointer was taken
as the clone's own entry. If the source vault moved while the clone was still
copying (before custody), the staged pointer still named the SOURCE's entry,
the source path had no pointer, and the rollback deleted the source's only key.
own_copied_key now returns the exact entry it created; create_profile keeps it
and, on failure, deletes that entry and nothing else. A pointer-save failure
inside custody deletes the new entry even when the pointer landed, since the
staged clone is discarded with the error.
Review: Greptile on f9f9c0408c.
Every keychain account is random, so an entry whose vault.keyref was never
saved is a key Hermes can neither find nor remove later (a retry mints another).
New entries made by key creation, migrate --to keychain and clone custody now go
through save_new_ref: if saving the pointer fails, the entry is deleted unless
the pointer did land. migrate --to keychain then reports that vault.key stays.
A --clone-all create that fails after the copy got its own entry (layout,
publish rename) deletes that entry while unwinding; it compares against the
source's pointer, so the source's entry is never touched. Clone custody also no
longer trusts a copied pointer that happens to name the clone's own path (a
renamed profile cloned back into its old name): a clone always gets a new entry.
Review: Greptile on b322737dfd.
A clone copied vault.keyref, which names the SOURCE's keychain entry, and only
switched to an entry of its own on first open. If the source ran
`hermes vault key migrate --to file` before the clone was ever opened, the
source deleted its (sole-owner) entry and the clone could no longer find a key.
create_profile(clone_all=True) now gives the staged vault its own entry, owned
by the final profile path, before the publish rename. When the keychain cannot
be reached at that moment the clone is refused with a ValueError naming the way
out, instead of being published sharing the source's entry. A source whose own
entry is already gone is copied as-is (no worse off than the source). Lazy
adoption on first open stays for renames and clones made before this.
_clone_staging_dir moves to profiles_initialization (the staging-tree sibling)
to offset profiles.py's growth under the file-size ratchet.