pub fn migrate_private_key(agent_dir: &Path) -> Result<bool, IdentityError>Expand description
Move one agent’s private key out of the agents tree (#850 option (c), step 2).
Scoped to a SINGLE agent on purpose. Every agent runs this for its own key at startup, so 27 agents starting together never contend — no two of them touch the same file. A sweep that migrated everyone from whichever process got there first would have that race for no gain.
Runs at startup rather than from mur update because mur update is not the
only upgrade path: build.sh --install + mur agent restart --stale never
invokes it, and neither does brew upgrade. A migration hooked there simply
would not run on those machines.
Refuses rather than overwrites when the destination already holds a
DIFFERENT key. Silently picking one would change the agent’s identity, which
forges attribution on every channel it has ever written to, and there is no
.prev and no rotation attestation to undo it with.
Returns Ok(true) when a key was moved. Idempotent: a second call finds
nothing. Never an error for “nothing to migrate”.