fix(relay-node): a spawned session binds to its spawn registration instead of registering twice
A spawned worker's session can start before the spawn has saved its registration. That happens through the Codex SessionStart hook or the periodic activation pass. Activation only skipped spawns that were already saved, so the session went through register_session_with_origin / create_registration and got a second Relaycast agent. Whichever write landed last won. Either the spawn record was lost, taking the requester with it (so "Approvals from the spawning agent" fell back to the person), or an agent was left orphaned. On linuyc every worker a spawning agent started showed both identities, e.g. overlap-harvest next to codex-khaliqgant-are-overlap-N.
Fix:
- A spawn that is still in flight counts its session as spawned, so the activation pass skips it.
- A spawned session's own
/registerwaits up to 5 s for the spawn to save, then answers with that registration: same name@node, requester and invocation id. If the spawn never saves, the register call is refused. create_registrationnever overwrites a saved spawn registration. If it loses the race, it deletes the agent it just created. Saving a spawn deletes any non-spawned identity it displaces.- Codex SessionStart waits for the spawn registration.
Tests: spawn/tests/spawned_binding.rs, with 5 tests. The mocked-REST test only runs on CI.
Not covered here: a one-off cleanup of orphaned Relaycast agents that already exist, and a hosted MCP join_relay without a desktop address, which can still create a hosted participant.
🤖 Generated with Claude Code
![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.