Repository navigation
AI-3763: match a tool approval to its person by kind - #2436
martinmitrevski merged 3 commits into
Conversation
…and kind
A call held for approval kept only the user id of the person it asked, so
any verified caller of that id answered it. A conversation's channel knows
its members by id alone, so a guest token naming a signed-in user's id got
through POST /conversations/{cid}/tool_approvals and allowed their call.
The held call now keeps whom it asked as a session owner: the session's
own user as the kind of caller that opened it, and the writer of a message
in a channel an agent config answers in as a backend names a user, since
the hook names the writer by id alone. The answer is checked with
Owner.Reaches, the rule a session's owner is reached by.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kanat
left a comment
There was a problem hiding this comment.
VERDICT: GO
Reviewed d12b39b1c merged onto main (641ee3038, then again onto 3d837a3fc). CI on the head: all checks pass, integration (router) included.
Merge conflict: GitHub shows this PR as CONFLICTING. acceleration/internal/api/connector_approvals_test.go conflicts with main: this PR adds TestAGuestGoingByTheUsersIdCannotAnswerThroughTheirConversation, and main added the three team tests (TestAUserInTheConfigsTeam..., TestAUserWhoLeftTheConfigsTeam..., TestAnAnswerWhileTheUsersTeamsCannotBeRead...) at the same place, plus imports. Keep both sides. With both kept, TestSessionConnectorsSuite passes.
Checked and sound:
- The fix holds. With
connector_approval.goreverted to the base, the new REST test fails: the guest gets a 204 where the test expects a 403. - I tried 7 mutations and the tests caught all 7: the person asked always held as server, always held as the session's kind, the writer held as authenticated,
CustomerIDdropped, the old id-only rule,Reachesreversed, and the REST call site dropping the caller's kind. - Only two paths answer an approval: the socket
tool_approval(sessionws.go:546) andPOST .../tool_approvals(conversations.go:122). On the socket the rule decides the same as before for every seat that reaches the session, so the body's "only the REST answer changes" holds. An answer forwarded to another node is re-authenticated there, becausenode.Forwardreplays the request headers. - Approvals pending across the deploy are not affected. A held call lives only in the memory of the node that holds it (
approvals.held), and the stored step'starget_user_idis never read for authorization. A call held on an old node is answered by the old rule until it ends, and a new node never reads a record from before the kind was kept. - Touched suites pass on the merged tree:
TestConnectorApprovalSuite,TestSessionConnectorsSuite,TestAppHooksSuite,TestChannelTypeTurnSuite,TestChatLoginsSuite,TestForwardedSessionSuite,TestSessionEventsSuite.gofmtandgo vet -tags integrationare clean.
There are no Blockers or Should fixes. R1.1 (Nit) and R1.2 (Question) are inline; each one is a follow-up.
kanat
left a comment
There was a problem hiding this comment.
Approving on the reviewer's GO (#2436 (review)). It conflicts with main in connector_approvals_test.go; keeping both sides works.
…63-a-tool-approval-is-matched-to-the # Conflicts: # acceleration/internal/api/connector_approvals_test.go
…y kind askedAs holds a writer who is the session's own user as the kind of caller that opened it, so a guest token of their id does not answer for them. The askedAs comment and the connectors skill said any verified token of the writer's id answers; they now name that exception. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
thesyncim
left a comment
There was a problem hiding this comment.
Reviewed at d12b39b merged with main b86e02f, and with #2384 (merged since), #2404, #2371, #2431 and #2432. No defect found: the approval, app hooks, channel type and forwarded session suites pass, and nine mutants of the rule are all killed. I'll approve once it is rebased.
- Conflict with main, in
connector_approvals_test.goalone: the imports, and the tests added afterTestTheUserMayAnswerThroughTheirConversation. Keeping both blocks works. - Nit: the ticket asks that a claimed guest keeps working. From reading it does (the claim moves the row to the account's kind), but no test shows it. Could one be added, or the line be answered in the description?
- Nit: the operation's description in
api/conversations.go(answerConversationToolApproval) still saystarget_user_idis who may answer. A caller of another kind with that id now gets the 403. Worth a sentence there and a spec regeneration, since a client author reads that and not the skill. - Question: a texted session is opened as an authenticated user whatever kind the linked user is (
channels/service.go). If an app links a guest-role user to a number, that guest no longer answers the call through the conversation. Is that intended? It does match how they reach the session.
kanat
left a comment
There was a problem hiding this comment.
Re-approving on the reviewer's GO (#2436 (review)). The new head merges main, and its test-file conflict keeps both sides. Its docs commit fixes the R1.1 Nit in comments and the skill only.
Fixes AI-3763, a follow-up from #2384 (AI-3725).
Why
A connector call held for approval kept only the user id of the person it asked, and an answer was accepted from the customer's backend or from anyone with that id (
by.UserID == asked,session/connector_approval.go).POST /v1/agents/conversations/{cid}/tool_approvalsrequires a verified caller who is a member of the channel. But a channel knows its members by id alone, so a token withrole: guestand a signed-in user's id passed both checks and allowed that user's call. Reproduced on main: the guest's answer was a 204 and the call ran.A session's owner is already matched by id and kind (
session.Owner.Reaches). #2384 matches a conversation's owner the same way, and this applies that rule to the person an approval asks.How it works
Before and after, for a call held for the session's own user
alice:alicealicealicealicealiceOnly the REST answer changes: a socket's seat already has to reach the session (
sessions.Get→Owner.Reaches), and the person a session asks is its own user. A message's writer in a channel an agent config answers in: any verified caller of their id, as before, unless the writer is the session's own user (a session opened through the API answering in the channel), who is asked as the kind of caller that opened it. The router reads onlymessage.user.idandnamefrom the hook (messageEventinapi/messagehooks.go), so nothing it reads proves a writer's kind. Stream's samplemessage.newalso carriesmessage.user.role; holding a writer by that is a follow-up (review R1.2). An anonymous caller naming them is refused, butPOST .../tool_approvalsalready refused it as unverified.Changes
heldCall.askedis anOwner, set byaskedAsTestACallerOfAnotherKindGoingByTheUsersIdMayNotAnswer,TestAGuestAnswersTheCallOfTheirSessionAndAUserOfTheirIdDoesNotAnswerConnectorApprovalchecksby.Reaches(asked)TestAGuestGoingByTheUsersIdCannotAnswerThroughTheirConversation(REST, end to end)KindServerTestAVerifiedCallerOfTheWritersIdAnswersTheCallTheirMessageAskedValidation
ConnectorApprovalSuitetests andTestAGuestGoingByTheUsersIdCannotAnswerThroughTheirConversationfail on main (0e5197a7a): the guest's REST answer was a 204, not a 403.KindServer(kills the guest/user tests), holding a writer as the session's kind (kills the writer test).-tags integration:internal/sessionTestConnectorApprovalSuite,internal/apiTestSessionConnectorsSuite,TestAppHooksSuite(chat channel approvals, approvals answered on another node),TestChannelTypeTurnSuite,TestChatLoginsSuite,TestForwardedSessionSuite,TestSessionEventsSuite.go test ./internal/sessionwithout the tag.main(d89d15dc7).connector_approvals_test.goconflicted with main's three team tests; both sides are kept. On the merge, the integration suites above pass again, andgo vet -tags integration ./internal/api ./internal/sessionis clean.🤖 Generated with Claude Code