fix(broker): bump relaycast to 7.0.0 and reclaim agent names by audited takeover
Why
relaycast 8.2.0 made registration create-only and moved identity replacement to explicit, proof-authorized routes. POST /agents/{name}/rotate-token became requireAgentToken — self-rollover only — so the broker's register-or-rotate paths, which send the workspace key, can only return 401 Agent token required (at_live_...).
This is the root cause of every cloud agent step failing once its name had been used before. The tests covering these paths were green only because they mocked a server that no longer exists.
Verified against production (cast.agentrelay.com):
POST /v1/agents -> 201 at_live_…
POST /v1/agents (same name) -> 409 agent_already_exists
POST /v1/agents/x/rotate-token rk_live_ -> 401 Agent token required
POST /v1/agents/x/rotate-token at_live_ -> 200 rotated
Changes
Pin moved to =7.0.0 (relaycast#351), surfacing four call sites — two for rotate_agent_token's new agent-token argument, two for create_workspace requiring explicit provenance (a second breaking change already queued in that release).
Reclaiming a name the broker owns is now an audited takeover:
| path | before | now |
|---|---|---|
rotate_token_no_fallback | rotate with workspace key | genuine self-rollover with the cached agent token |
crash reclaim (auth.rs) | rotate with workspace key | recover_agent — it holds a work-unit identity proof, which is what recover exists for |
register_agent_token collision | silent rotate | take_over_agent, leaving an audit record |
That last one covers supervisor restart (maintenance.rs:569), offline-agent attach, and the broker reconnecting as itself — all of which keep working, with a stable name, and are now logged.
Safety
Takeover is confined to names this broker owns. The impersonation presence probe still runs first and still refuses a live agent, so takeover only ever applies where there is no live credential to strand — the relay#1545 property is preserved.
Where the probe has already resolved the incumbent, its id is threaded into the takeover so it doesn't repeat the lookup — one round trip, not two, on a path that runs per registration.
On the design choice
take_over_agent is deliberately explicit and audited in relaycast#349, so automating it deserves justification: the broker is the workspace owner, it is reclaiming agents it spawned, every seizure now writes an audit_id, and the live-agent refusal still gates it. The alternative — unique names per spawn — was considered and rejected here because it breaks stable-name addressing for supervisor restart; it remains the right choice for ephemeral agents, and is what our customer POC uses.
Testing
1016 tests pass, clippy clean on stable (rustc 1.98.0). Test mocks migrated from rotate-token to takeover/recover to match the server as it now behaves.
One test's tripwire changed meaning and is documented inline: GET /v1/agents/broker used to prove "the broker never presence-probes itself", but that endpoint now also pins expected_agent_id for takeover, so a hit count can't separate the two. The guarantee is instead asserted by the call succeeding — a regressed bypass would refuse the broker's own identity as live impersonation and fail the test.
Related
- relaycast#351 — the SDK fix (published as
relaycast 7.0.0) - relaycast#352 — unbreaks clippy on Rust 1.98
- AgentWorkforce/relay#1594 — the broker flattens 401/403 into
register auth error, discarding which request failed; still open and worth fixing on its own
🤖 Generated with Claude Code