Skip to content

fix(squad): gate cross-squad agent @mentions on squad-assigned issues#67

Merged
furtherref merged 1 commit into
mainfrom
fix/squad-leader-cross-squad-mention-gate
May 21, 2026
Merged

fix(squad): gate cross-squad agent @mentions on squad-assigned issues#67
furtherref merged 1 commit into
mainfrom
fix/squad-leader-cross-squad-mention-gate

Conversation

@furtherref
Copy link
Copy Markdown
Owner

@furtherref furtherref commented May 21, 2026

Summary

Closes the "leader silently dispatches outside the roster" failure mode the 4-layer mention canonicalization couldn't reach: that defense only enforced label = UUID, not "is this UUID the right one to pick at all". When a squad leader (LLM, agent actor) called multica agent list to discover collaborators, the A2A bypass returned every workspace agent, the leader picked a same-role agent from a different squad, the canonicalized label matched perfectly — and the task got enqueued for the wrong squad's worker.

  • Server gate (enqueueMentionedAgentTasks) — on assignee_type='squad' issues with an agent author, agent-typed @mentions whose UUID is neither in squad_member nor the squad's LeaderID are dropped with a slog.Warn. The leader fallback covers legacy squads that predate CreateSquad's auto squad_member insert; transient DB errors fail open so a Postgres hiccup can't wedge legitimate dispatch.
  • Listing scope (ListAgents + new taskSquadMemberSet) — opt-in ?scope=task_squad query param narrows the response to the issue's squad iff the request comes from an agent actor on a real leader task. No-op for member actors, worker tasks, agent-assigned issues, and one-off CLI calls.
  • CLI default (multica agent list) — passes ?scope=task_squad whenever MULTICA_AGENT_ID / MULTICA_TASK_ID are set; --all opts back into the workspace-wide view.
  • Briefing reinforcementsquadOperatingProtocol now explicitly tells the leader the server silently drops out-of-roster mentions and forbids the multica agent list discovery shortcut.

Member-authored comments and @squad mentions intentionally bypass the gate — humans keep their agency, and squad routing already goes through the target squad's leader.

Test plan

  • go test ./internal/handler/ — full handler suite (10s)
  • go test ./cmd/multica/ — CLI suite (3s)
  • go test -run "TestEnqueueMentionedAgentTasks_SquadAssigned" -v — 5/5
  • go test -run "TestListAgents_TaskSquadScope" -v — 3/3
  • go test -run "TestRunAgentList_" -v — 3/3 (CLI flag wiring)
  • go test -run "TestBuildSquadLeaderBriefing" -v — 5/5 (incl. new OutOfRosterGuardClauses)
  • go build ./... + go vet ./... clean
  • Repro on the issue from the screenshots — verify the live banner now shows the leader's own squad member instead of Unknown Agent / 张桐 worker

🤖 Generated with Claude Code

Agent-authored comments on squad-assigned issues could @mention any
workspace agent the leader discovered via the A2A-bypassed
`multica agent list` and silently dispatch to an outside-squad agent —
the visible label canonicalized to whichever agent the leader picked,
but the dispatch was never the leader's own squad members.

Three layers, all server-side:
- enqueueMentionedAgentTasks drops agent @mentions whose UUID is
  neither in squad_member nor the squad's LeaderID, with a slog.Warn.
  Member-authored comments and @squad mentions bypass the gate.
- ListAgents honors a new ?scope=task_squad hint, narrowing the
  response to the issue's squad iff the request comes from an agent
  actor on a real leader task. No-op everywhere else.
- multica agent list passes the hint by default inside a daemon-managed
  agent task; --all opts out. squadOperatingProtocol calls out both
  the silent drop and the agent-list ban so leaders stop reaching
  outside the roster in the first place.

Tests cover gate negative / positive / leader fallback / member-author
bypass / mixed-mention per-mention behavior; server scope filter
on/off; CLI flag wiring with and without agent context.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
multica-web Ready Ready Preview, Comment May 21, 2026 10:44am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
multica-docs Ignored Ignored May 21, 2026 10:44am

@furtherref furtherref merged commit 79dff3b into main May 21, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant