pub(crate) fn persisted_agent_identity(
mstore: &Store,
block_id: &str,
) -> Option<PersistedAgentIdentity>Expand description
The db_agents row for the agent shown on block_id, if it has one,
plus that agent’s token.
Resolves the block → row the same way the identity injector does
(identity/resolver/inject.rs): block.meta.agentId first, then the
latest active launch on this block. A quick-launch pane (launchAgent
in agent-model.ts, whose agentId is a provider key like "claude")
has no row and gets None — it has no slug or UID in the identity
sense, and deriving either from its display name would recreate the
lossy path spec §1.1 measured as the root defect.
The token is minted here, at spawn, rather than at row creation: every
row that exists today predates the table, so “mint at creation” would
leave them all without one. agent_token_ensure is idempotent, so a
row created in the future gets the same token on every spawn.
A store error is logged and treated as “unknown”, never as a spawn failure: this is disambiguation, not a gate, and spec §10 constraint 1 forbids a store read from making a healthy agent unreachable.