Skip to content

fix(v2): member identity is a composite key — instanceId 'default' collapsed nine agents into one profile - #1267

Merged
lilyshen0722 merged 2 commits into
mainfrom
fix-member-key-collision
Aug 26, 2026
Merged

lilyshen0722 merged 2 commits into
mainfrom
fix-member-key-collision

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Sam's report: clicking any agent's profile (inspector sidebar render) shows Fable. Diagnosed from the key derivation: agentKeyOf = instanceId || agentName, and all nine BYO fleet seats share instanceId 'default' — one key, last-writer-wins, every click resolves to the same member. Key becomes agentName:instanceId via a shared util imported by both producer (chat author map) and consumer (inspector member map), unit-tested for the exact collision; the manage button also stops sending an instanceId as AgentsHub's ?agent= name param. 302/302.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TdEJoXUmbHmW5TFk7hfkbK

lilyshen0722 and others added 2 commits August 26, 2026 01:12
Verified #1259 live and the drawer was still invisible on phones: the
secondary-pane eraser at 760px (.v2-pane:not(...):not(...):not(...))
out-specifies the drawer rule 0-4-0 vs 0-1-0 and re-erased the mounted
pane. The inspector joins the :not exclusion list exactly as the pods
drawer did, and the invariant now pins the exclusion — the same bug
shipped twice through two different rules, which is what earns the pin.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TdEJoXUmbHmW5TFk7hfkbK
…llapsed nine agents into one profile

Sam: clicking any agent's profile (the inspector member render) showed
the same seat. Root cause: agentKeyOf was instanceId || agentName, and
every BYO fleet seat carries instanceId 'default' — the member map's
last writer won for the shared key, so every byline and member-row click
resolved to one agent. The key is now agentName:instanceId, extracted to
a shared util both the chat author map and the inspector import
(lockstep by construction — the collision existed because each side
derived its own key). The inspector's manage-navigate also stops passing
an instanceId as the ?agent= NAME param.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TdEJoXUmbHmW5TFk7hfkbK
@lilyshen0722

Copy link
Copy Markdown
Contributor Author

Gate at 1ecfc89f. One required change, three notes. The core fix is right — a composite key in a shared module imported by both producer and consumer is exactly the shape that makes the collision unrepeatable, and agentKeyFor is correct.

Required: the manage button's new params reach a component that reads none of them

navigate(`/v2/agents?podId=…&agent=…&instanceId=…`)

/v2/agents routes to V2YourTeamPage (V2App.tsx:266). I grepped it for URLSearchParams, useSearchParams and location.search — zero hits. It reads no query params at all, not agent, not instanceId, not even podId.

The comment added above the call is accurate about AgentsHub — AgentsHub.tsx:167 reads params.get('agent'), :171 reads params.get('instanceId') || 'default', and :478 matches on both. But AgentsHub is routed at /v2/agents/manage (V2App.tsx:285), which this button does not target.

So the hunk swaps one inert querystring for another, and documents a contract belonging to a route the destination never sees. The old ?agent=<instanceId> was broken; the new ?agent=<agentName>&instanceId=<id> is broken in a way that now reads as fixed, which is worse — the next person to touch this will trust the comment.

Two working targets already exist, either is a one-line change:

  • /v2/agents/manage?agent=${agentName}&instanceId=${instanceId} — AgentsHub, whose contract the new comment already describes correctly.
  • /v2/agent/${agentName}/${instanceId} — V2App.tsx:194 → V2AgentProfile, the composite-identity route. This is what V2YourTeamPage.tsx:409 itself uses, so there is a working precedent for the same navigation inside the very component the button currently lands on.

Note 1 — the CSS and layout-invariant hunks are already on main, byte-identical

The branch is 6 commits behind origin/main (merge-base d16268ff). Both hunks landed as #1261:

origin/main:frontend/src/v2/v2.css:5393
  .v2-pane:not(.v2-pane--rail):not(.v2-pane--main):not(.v2-pods-aside):not(.v2-pane--inspector)
origin/main:frontend/src/v2/__tests__/v2-layout-invariants.test.ts:133
  expect(v2).toContain(':not(.v2-pods-aside):not(.v2-pane--inspector)');

Same selector, same assertion, and the CSS comment above it is the same text word for word. git merge-tree --write-tree origin/main pr/1267 reports 0 conflicts, so the merge is safe and those two hunks are no-ops post-merge — I checked before raising it, because a stale base that touches v2.css is the shape that has bitten this repo twice.

Worth rebasing anyway: as it stands the diff asks a reviewer to re-review #1261, and it lets the author believe this PR fixed the phone-inspector bug when main already had.

Note 2 — the util test cannot see the wiring, which is where the bug lived

agentKey.test.ts imports agentKeyFor and nothing else. It proves the function returns distinct keys for two default-instance seats. It cannot observe that V2PodChat's author map and V2PodInspector's agentKeyOf both route through it — and that disagreement was the bug, not the function.

Revert V2PodInspector.tsx:746 to agent.instanceId || agent.agentName and you reproduce Sam's report exactly, with all three new tests green. Same shape as TASK-074: the unit is pinned, the wiring is not.

A structural guard is cheap and fits the existing invariant-test pattern in this repo — assert both components import from ../utils/agentKey, and that neither file still contains instanceId || . Stated from reading the diff, not from running it: the frontend harness (react-scripts test) does not run in a detached worktree on this machine, so I did not execute that mutation. The claim is safe regardless — a test file that imports neither component provably cannot assert anything about them.

Note 3 — the shared util and its caller disagree on name precedence

agentKeyFor resolves agent.agentName || agent.name. Ten lines above the call site, V2PodChat.tsx:501 resolves rawName as (agent as …).name || agent.agentName — the opposite order. If a row ever carries both and they differ, the map indexes under one name and keys under the other.

Pre-existing on the rawName side and not a regression, but the new shared util cements the disagreement rather than resolving it, and agentKey.test.ts covers name-only and agentName-only without ever setting both. One case with both present would settle which wins.

Smaller

if (!rawName) continue; sits after const key = agentKeyFor(agent), so the key is computed for rows that are then discarded. Cosmetic. The guard's semantics also changed — a row with an instanceId but no name used to be indexed and is now skipped, which is more correct and worth a word in the comment.

Not verified

Test & Coverage was still pending when I gated; the other nine checks are green. I did not run the frontend suite — the 302/302 in the body is taken as reported. And I did not confirm in a browser that the manage button currently misroutes; the finding is from the route table and a param grep, both of which I ran.

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