You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[AI-3382] .NET SDK: a connections resource and an optional userId - #2099
A backend that connects its users' accounts (Linear, GitHub) has only generated operations in the .NET SDK (AI-3375). It would set X-Stream-User-Id by hand and keep it equal to owner.user_id. The user is now an optional userId on each call (AI-3387).
VisionAgentsClient.Connections (flat, no agents level)
├─ CreateAsync(connectorId, NewConnectionOptions?{Label, UserId}) POST /v1/agents/connections
├─ AuthorizeAsync(id, AuthorizeOptions?{ReturnUrl, UserId}) POST /v1/agents/connections/{id}/authorizations
├─ GetAsync(id, userId?) GET /v1/agents/connections/{id}
├─ ListAsync(ConnectionFilter?{ConnectorId, UserId}) GET /v1/agents/connections (every page, limit 200)
└─ DeleteAsync(id, userId?) DELETE /v1/agents/connections/{id}
userId / UserId
owner (create)
X-Stream-User-Id
list owner_type
"alice"
{type: user, user_id: alice}
alice, every call, reads included
user
null or ""
{type: app}
none from the parameter; a client's own UserId option is left as it is
app
Create, authorize and list take sealed options records, so a user cannot land where a label or connector belongs. Get and delete take string? userId last, before the CancellationToken.
A user goes through the internal ActingFor that Dispatch already uses: the server credential plus X-Stream-User-Id.
An empty connection id is refused before any request is sent.
What the router answers (acceleration/internal/api/connections.go:742mayReach):
a backend reaches app connections whatever user it sends;
a user's connection is reached only with that user;
a list with a user holds only that user's connections.
a section "A user's own accounts", one entry, one note
Backend is internal sealed class (Backend.cs:143); ActingFor is internal (VisionAgentsClient.cs:125), its only caller is Dispatch (Dispatch.cs:218). The backward-compatibility test of the brief therefore does not apply (decision Q0.1).
Validation
Full suite in Docker: 323 total, 316 passed, 7 skipped (live), 0 failed (base: 309, 302, 7). ConnectionsTests runs on the existing Kestrel TestRouter, which records method, path, query, headers and body of every request, reads included.
a 404 or 409 returned as success instead of RouterException
Mutations: 17 mutants on Connections.cs plus 16 on the options and empty-string rules (author, round 1 and fix 1); round 2 reran 11, 0 survived. One fix-1 mutant did not build, a rerun was killed (mut-fix1.log).
Live on staging with a test user: create linear (pending, owner user), authorize (https launch URL, handoff token, 10 minute expiry), get, list with the user holds it and the app list does not, get as another user and with no user are 404 connection_not_found, delete; the user ends with 0 linear connections, as before (live/live-fix1.log).
Review rounds
Round
Verdict
Findings
Sha
1
not a GO
R1.1 options records (adjacent strings), R1.2 three surviving mutants, R1.4 changelog (#2099): fixed; R1.3 (a client made for one user loses its user token when a call names another) is a ticket
67c72f990
2
NO-GO
R2.1 Blocker: dotnet format --verify-no-changes red; fixed by c05d9159e, whitespace only
a8f964d20
3
GO
R2.1 closed (dotnet format --verify-no-changes exits 0; the old lines fail it); no new findings (review)
VisionAgentsClient.Connections creates, authorizes, reads, lists (every page) and deletes
connections. Each call takes an optional userId, sent as owner.user_id on create and as
X-Stream-User-Id on every call, reads included; none is the app's own connection.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This change adds a .NET VisionAgentsClient.Connections resource. It supports creating, authorizing, getting, listing, and deleting connector connections. Option and filter records accept user, label, return URL, and connector ID values. Requests use app context when the user ID is null or empty, and use ActingFor(userId) otherwise. Listing retrieves pages of up to 200 items. Tests cover request headers, ownership, pagination, validation, encoded IDs, and cross-user errors. The README, changelog, and SDK skill text describe the new API.
Merge Risk: Moderate · up to b3be9
The new Connections.CreateAsync cannot pass connector inputs or an authentication scheme, so creating connections for some connectors will be refused. Calls that omit the user can still carry a user identity configured on the client, which contradicts the documented app-owned behavior. Resolve these before merging.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
The reason will be displayed to describe this comment to others. Learn more.
Reviewed at 67c72f9 merged onto main (fa2a6a6). .NET suite in Docker: 321 total, 314 passed, 7 skipped (live), 0 failed. CI was pending when I read it.
Live check on staging: an app connection is reached by get, authorize and delete calls that name a user, and the user's list leaves it out. This matches the README and the router's mayReach.
Mutations: 12 checked, 3 survived (R1.2).
Checked and sound: the header is sent on every call, reads included. The owner and the header come from one value. The list reads every page with the same filter. An empty id is refused before any request is sent. No existing public signature changes. There is no public acting helper to deprecate: Backend and ActingFor are internal.
The reason will be displayed to describe this comment to others. Learn more.
[Should fix] R1.1 Three of these methods take two optional strings side by side with no names: CreateAsync(connectorId, label, userId), AuthorizeAsync(id, returnUrl, userId) (:56) and ListAsync(connectorId, userId) (:75). A user id passed second still compiles:
CreateAsync("linear", "alice") sends {"connector_id":"linear","label":"alice","owner":{"type":"app"}}. That is an app-owned connection, which any of the app's agents may be bound to.
ListAsync("alice") lists the app's connections to a connector named alice, with no X-Stream-User-Id.
AuthorizeAsync(id, "alice") sends alice as the return_url.
A probe test on the stand-in router shows the first two. The tests here (ConnectionsTests.cs:17-21) also pass these arguments by position.
Fix: put the optional parts of these three methods in a sealed options record with a UserId field. The sdk-dotnet skill says options are sealed records, and Go #2095 does the same with ConnectionRequest, AuthorizeOptions and ConnectionFilter. For example: CreateAsync(string connectorId, NewConnectionOptions? options = null, CancellationToken), AuthorizeAsync(string id, AuthorizeOptions? options = null, ...) and ListAsync(ConnectionFilter? filter = null, ...). GetAsync and DeleteAsync can keep string? userId = null: the id is required there, so a swap gives a 404, not the wrong owner.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in a8f964d: CreateAsync, AuthorizeAsync and ListAsync take NewConnectionOptions, AuthorizeOptions and ConnectionFilter (sealed records with UserId), so a user cannot land in a label, return URL or connector. Test: ConnectionsTests.AFilterWithAConnectorAndNoUserListsTheAppsConnectionsOfThatConnector and the updated AUserGivenIsTheOwnerAndTheHeaderOnEveryCallReadsIncluded; reverting the user wiring (create, authorize, list) fails them.
The reason will be displayed to describe this comment to others. Learn more.
[Should fix] R1.2 Three mutants survive ConnectionsTests:
Label = label (no Blank)
ReturnUrl = returnUrl (:58, no Blank)
the owner's user_id hardcoded to "alice" (:37). Every test uses alice, so nothing catches it.
Test to add: call CreateAsync("linear", "", "bob") and expect the body {"connector_id":"linear","owner":{"type":"user","user_id":"bob"}}. Call AuthorizeAsync("conn-1", "", "bob") and expect the body {}. I ran this test in a scratch copy: it fails under each of the three mutants and passes on head.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in a8f964d: ConnectionsTests.EmptyOptionalStringsAreLeftOutAndTheOwnerIsTheUserGiven (label "", returnUrl "", user bob). Mutants R1, R2, R10 now fail it.
The reason will be displayed to describe this comment to others. Learn more.
[Question] R1.3 Take a client made for one user (ApiSecret + UserId, behind the proxy). When a call names another user, Backend.Acting replaces the client's user token with the server token. Go #2095 sets only ActingFor (connections.go:189) and keeps the client's UserID, so Go sends the user's token and the router refuses it, because connections are server side only. This widens nothing: the client already holds the secret, and Dispatch already acts the same way on the base. The empty-user case matches Go. Whether to align the given-user case with Go is for the orchestrator to decide; this goes to a ticket, not this PR.
`VisionAgentsClient.Connections` creates, authorizes, reads, lists and deletes connections: `CreateAsync("linear", userId: "alice")`, `AuthorizeAsync(id, returnUrl, userId)` for the consent's launch URL, handoff token and expiry, `GetAsync(id, userId)`, `ListAsync(connectorId, userId)` reading every page, and `DeleteAsync(id, userId)`; a user given is sent as the owner and as `X-Stream-User-Id`, and none is the app's own connection.
…wrong place can no longer become a label
CreateAsync, AuthorizeAsync and ListAsync take NewConnectionOptions, AuthorizeOptions and
ConnectionFilter with a UserId; GetAsync and DeleteAsync keep userId. Tests: empty label and
return URL are left out, the owner is the user given, a connector-only filter lists the app's.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
Delta review, round 2: NO-GO (one Blocker, CI). Head a8f964d on main fa2a6a6.
Blocker (CI, unchanged code): the dotnet job fails at "Check formatting" (dotnet format --verify-no-changes, ci.yml:265). sdks/dotnet/tests/GetStream.VisionAgents.Tests/ConnectionsTests.cs:90-95 (the switch { ... } in AListReadsEveryPageWithTheSameFilter) sits 4 spaces too far left. I reproduced the same 5 WHITESPACE errors locally in Docker; running dotnet format in sdks/dotnet fixes it. The block is identical in the previous head; round 1 saw CI still pending. Fix: run dotnet format, commit.
Prior findings
R1.1 fixed. NewConnectionOptions, AuthorizeOptions and ConnectionFilter are sealed records with UserId; GetAsync/DeleteAsync keep string? userId. Positional misuse no longer compiles. Names fit the Go reference (ConnectionRequest is already the generated wire model in Generated/Models.cs, so NewConnectionOptions avoids the clash) and match DispatchOptions and SimulationRunQuery.
R1.2 fixed. EmptyOptionalStringsAreLeftOutAndTheOwnerIsTheUserGiven kills my mutants: label not blanked, returnUrl not blanked, owner user_id constant.
Q0.3 holds: an empty user clears only the acting-for user (SendAsync blanks it, then uses the client as it is); pinned by AUserGivenReplacesTheOneTheClientWasMadeForAndNoneLeavesItAsItIs.
Checks: full .NET suite in Docker on the head: 323 total, 316 passed, 7 skipped (live), 0 failed. 11 mutants (create/authorize/list ignore the options user, list drops the connector, list owner_type fixed either way, create swaps label and user, owner always app, and the three above): 11 killed, 0 survived. No new findings in the changed hunks.
Whitespace only, in ConnectionsTests.cs (the list test's switch
expression), so CI's dotnet format --verify-no-changes passes.
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Fixed in c05d915: dotnet format in sdks/dotnet (whitespace only, ConnectionsTests.cs:90-95). dotnet format --verify-no-changes exits 0 in Docker (it exited 2 with the same 5 WHITESPACE errors on a8f964d). Build with -warnaserror: 0 warnings, 0 errors. Suite: 323 total, 316 passed, 7 skipped (live), 0 failed.
## Why
A backend that connects its users' accounts (Linear, GitHub) has only
the generated operations in the Go SDK. It sets `X-Stream-User-Id` by
hand and must keep it equal to `owner.user_id`: the router refuses a
user connection whose two values differ
(`acceleration/internal/api/connections.go:765`).
This is the first of the seven server SDKs (AI-3375). Its shape was
decided in #video-ai on 2026-11-19:
- flat `api.Connections()`, with no `agents.` level;
- the user is a per-call parameter, as Chat's server SDKs pass
`user_id`;
- no per-user client.
The other six copy it, and merge after this PR:
- JavaScript [#2110](#2110)
- Python [#2103](#2103)
- Ruby [#2102](#2102)
- PHP [#2101](#2101)
- .NET [#2099](#2099)
- Rust [#2100](#2100)
## How it works
```
api.Connections()
├─ Create(ctx, ConnectionRequest{Connector, Label, UserID})
│ UserID set -> owner {type: user, user_id: UserID} + X-Stream-User-Id: UserID
│ UserID empty -> owner {type: app} + no X-Stream-User-Id
├─ Authorize(ctx, id, AuthorizeOptions{ReturnURL, UserID}) -> launch URL, handoff token, expiry
├─ Get(ctx, id, ConnectionOptions{UserID})
├─ List(ctx, ConnectionFilter{Connector, UserID}) owner_type user|app, reads every page
└─ Delete(ctx, id, ConnectionOptions{UserID})
```
```go
conn, err := api.Connections().Create(ctx, client.ConnectionRequest{Connector: "linear", UserID: "alice"})
auth, err := api.Connections().Authorize(ctx, conn.ID, client.AuthorizeOptions{ReturnURL: returnURL, UserID: "alice"})
conn, err = api.Connections().Get(ctx, conn.ID, client.ConnectionOptions{UserID: "alice"})
```
The user is always the `UserID` of the call's options struct. No two
strings sit side by side, so a call cannot swap them.
| Call | `X-Stream-User-Id` | What the router answers |
| --- | --- | --- |
| `UserID: "alice"` | `alice`, also on reads | alice's connection; an
app connection is reached too (`mayReach`, `connections.go:742-745`) |
| `UserID` empty | none: only the acting-for user is cleared, and a
client's own `UserID` stays | the app's connections |
| `List` with `UserID` | `alice` | only alice's connections |
A per-call copy of the client's `stream.Backend` gets `ActingFor =
userID` (`client/connections.go:187-191`). Results are the generated
`acceleration.Connection` and `acceleration.Authorization`. Refusals are
`*stream.RouterError`.
The change is additive only, per Chat's "deprecate, never break" rule.
Go had no public acting-for helper, so nothing is deprecated here; the
other SDKs deprecate theirs (AI-3387).
## Changes
- `sdks/go/client/connections.go`: the resource.
- `client/client_test.go`: the stand-in router now records each
request's headers. It serves the connection routes with the router's own
owner rules (`ownerOf`, `mayReach`).
- `sdks/go/README.md`: new section "A user's own accounts".
- `CHANGELOG.md`: one entry.
- `.claude/skills/sdk/SKILL.md`: a note for the other SDKs. In each, the
user is an optional named parameter (`userId` / `user_id`) and the
optional parts are an options object. Also, "connections" leaves the
sdk-go known-gaps list.
## Validation
`go test -race ./client/... && go test . && go vet ./... && go vet -tags
e2e .` in `sdks/go`: pass. CI: green on `92148e5fe`.
| Test | Defect it catches |
| --- | --- |
| `TestAUsersConnectionNamesThemAsOwnerAndActingUser` | owner and header
differ, or one has no user |
| `TestAnAppConnectionNamesNoUser` | an app connection sent with a
`user_id`, or with the client's acting user |
| `TestACallNamingAUserReachesAnAppConnectionButListsOnlyTheUsers` |
docs and code disagree on reach |
| `TestEveryCallSendsTheUserItNamesAsTheActingUser` | owner and header
differ on any call, reads included; an app call sends a header |
| `TestAuthorizingAnswersWhereAndHowLongTheConsentRuns` | return URL or
user dropped; launch URL, token or expiry lost |
| `TestAUsersConnectionIsReachedOnlyAsThem` | get, authorize or delete
sent with no user or the wrong one |
| `TestListingReadsTheOwnersConnectionsEveryPage` | only one page read,
wrong `owner_type`, connector dropped |
| `TestDeletingAConnectionRemovesIt` | delete not sent, sent as someone
else, or `force` sent |
| `TestAConnectionWithNoIDIsRefusedBeforeTheRouter` | an empty id sent
as `/v1/agents/connections/` |
| `TestAConnectionRefusalIsTheRoutersError` | a refusal or a cancelled
request returned as success |
Mutations: 30 of 30 killed (`mutate.py`). They cover every condition,
branch and constant in `connections.go`, including the user dropped from
each of the five calls.
Review rounds:
- Round 1 NO-GO, fixed:
- `ForUser` kept the parent client's team;
- the docs disagreed with the router on reach.
- The team then dropped `ForUser` for a per-call user (R2.1, `UserID`
naming R2.2).
- Round 3 GO; its two nits (`Get` and `Delete` took a bare `userID`
string) are fixed by `ConnectionOptions`.
- Follow-up: AI-3385 (the user's email for connectors that check it).
Live run on the staging router with the final signatures, as user
`e2e-ai3376` and connector `linear`. The id is shortened to a prefix.
The deferred delete found nothing, so nothing was left behind.
```
create: id=afa8b1… connector=linear owner=user/e2e-ai3376 status=pending
authorize: kind=consent launch_url_https=true handoff_token_set=true expires_in_10m=true
get: status=pending
get as another user: refused=true
list: count=1 contains=true
list app: contains=false
delete: ok; get after delete: refused=true
list after delete: count=0
delete (deferred): no such connection
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Major · Data Integrity & Integration · Quick win
Clear the inherited user when a Connections call omits userId.
When VisionAgentsClient is built with UserId, SendAsync sends a null or blank userId through _client unchanged. The request then carries that client's identity. On a server-secret client with Authenticate off, it sends X-Stream-User-Id. With Authenticate on, which is the default for the hosted router, it signs a user JWT for UserId. CreateAsync and ListAsync still set the app owner in the body and query, so the request names two different owners. The README and CHANGELOG state that an omitted user selects the app's own connection. The PR also states that X-Stream-User-Id is sent only when a user is provided.
An omitted user must select app scope. An explicit user must keep its current path. Update AUserGivenReplacesTheOneTheClientWasMadeForAndNoneLeavesItAsItIs, which asserts the inherited ada header. Update the .NET note in .claude/skills/sdk/SKILL.md to match.
Suggested fix
--- "a/sdks/dotnet/src/GetStream.VisionAgents/Connections.cs"+++ "b/sdks/dotnet/src/GetStream.VisionAgents/Connections.cs"@@ -151,12 +151,8 @@
/// </summary>
private async Task<T> SendAsync<T>(string? userId, Func<VisionAgentsClient, Task<T>> send)
{
userId = VisionAgentsClient.Blank(userId);
- if (userId is null)- {- return await send(_client).ConfigureAwait(false);- }- using var acting = _client.ActingFor(userId);+ using var acting = _client.ActingFor(userId ?? "");
return await send(acting).ConfigureAwait(false);
}
}
The reason will be displayed to describe this comment to others. Learn more.
GO at a8991f8 (delta round 3, reviewed merged onto main ba565cd).
Prior findings
R2.1 (dotnet format, Blocker): fixed. dotnet format --verify-no-changes exits 0 on this head merged with current main. Mutation: restoring the 5 lines of ConnectionsTests.cs from the previous head makes it exit 2 with WHITESPACE errors at :92-:95; restored.
R1.1, R1.2, R1.4: stay fixed (no code change since round 2, where all 11 mutants were killed). R1.3 stays a ticket (Question, not blocking).
…2128)
## Why
The other server SDKs are adding a per-call user. JavaScript, Python,
Ruby and PHP deprecate their per-user helper in open PRs (#2110, #2103,
#2102, #2101); .NET (#2099) and Rust (#2100) add the per-call user and
have no public helper to deprecate. Go still recommends
`Backend.ActingFor`, a field that fixes one user for every request a
backend makes. `client.Connections()` (#2095) already takes the user as
`UserID` per call. This deprecates `ActingFor` and moves the two
examples off it. It keeps working: only a `Deprecated:` paragraph is
added. The note names what exists today: `UserID` on
`client.Connections()` calls, `XStreamUserId` on
`CreateScheduledTaskParams`, a per-call `acceleration.RequestEditorFn`;
`client.Agent(...)` calls take no per-call user yet, so `ActingFor`
stays their way.
## How it works
```
before example ──> Backend{ActingFor: user} ──> X-Stream-User-Id
after example ──> per-call user ───────────────> X-Stream-User-Id
(UserID of the call, or the header on the call)
SDK itself (Dispatch.Answer, Connections.api)
──> still sets ActingFor on a copy of the backend, each line with
//nolint:staticcheck // SA1019 (golangci-lint's form, as acceleration/cmd/usage)
```
No public API is added: every call site the examples needed already had
a per-call user. The SDK's own two writes send exactly what they sent on
base.
| Call site | Now | Request change |
| --- | --- | --- |
| `crew_assistant` create | `Backend{}`;
`CreateScheduledTaskParams.XStreamUserId` (already set) | none |
| `crew_assistant` run, delete | `Backend{}`; a backend reaches a task
of its customer without naming the user (`session.Owner.Reaches`, server
kind) | `X-Stream-User-Id` no longer sent on run and delete |
| `swift_assistant` list Gmail | `client.Connections().List(ctx,
ConnectionFilter{UserID, Connector})` | adds `limit=200` and follows
every page (the old call read the first 25) |
| `swift_assistant` proxy POST | `Backend{}.Resolve()`, then
`credentials.Set(stream.UserHeader, user)` on the raw request; kept raw
so the 1 MiB read cap stays | none |
Other readers of `ActingFor` (grep over `sdks/go`, `examples`, `tui`,
`.claude/skills`, READMEs): `stream/backend.go` (`Credentials`, the
field), `agents/dispatch.go`, `client/connections.go` (both write it,
with a nolint), `client/connections_test.go` (reads it, with a nolint),
`.claude/skills/sdk/SKILL.md:447` (a note about every SDK, left as
written, with one line appended). The Go README and `sdk-go` skill never
recommended it.
## Validation
- `cd sdks/go`, `GOWORK=off`: `gofmt -l`, `go mod tidy -diff`, `go vet
./...`, `go vet -tags e2e .`, `go test -race ./...` all pass. Each
touched example: `go build ./... && go vet ./...` pass; `crew_assistant`
tests pass.
- staticcheck (via `golangci-lint -E staticcheck`): no SA1019 in
`sdks/go`, either example or `tui`; the six findings left are in files
this PR does not touch.
- Backward compatibility:
`TestABackendBuiltWithActingForSendsWhatItAlwaysDid` pins method, path
and headers of three `ActingFor` backends (local router, behind the
proxy, team and categories). The expected values were read off a client
built the same way on the base commit (ab01365). It fails if the
header is dropped, sent only in one mode, or read from another field.
- `TestActingForAUserKeepsTheServersToken`: the user goes in the header,
never into the token, and the token keeps its server claim.
- `Dispatch.Answer` and `Connections` keep their existing header tests
(`TestAMessageWrittenToARunningSession...`, the connections suite); each
fails with its `ActingFor` write removed.
- New example tests (run locally; CI runs neither example's tests):
`TestGmailCallsNameTheUser` (swift: the Gmail list and the proxy POST
name the user) and `TestTheAgentSpeaksFirstInTheUsersConversation`
(crew: the task is created naming the user).
- Examples: a throwaway probe test recorded every request of both
examples on base and on this branch; the diffs are the two rows above
and nothing else. The probe is not committed; the two example tests
above pin the user on those requests.
- Mutants over the changed lines (the two SDK writes dropped; the token
losing its server claim; `Credentials` dropping or mode-limiting the
header; the swift list and proxy and the crew create dropping the user):
all killed.
Not checked: nothing run against a real router, as no request changes
for existing callers.
## Review rounds
| Round | Verdict | Findings | Sha |
| --- | --- | --- | --- |
| 1 | NO-GO | R1.1 exported `Backend.Acting` removed (internal writes
keep `//nolint:staticcheck` with the reason); R1.2 deprecation note
names only what exists; R1.3 four surviving mutants now killed (swift
list/proxy, crew create, token server claim); R1.4 skill note links the
open SDK PRs: fixed. R1.5 example `go.sum`: ticket AI-3399; per-call
user on `client.Agent`: ticket AI-3398 | `8ca1c3635` |
| 2 | NO-GO | R1.1-R1.3 verified, 10/10 mutants killed; R2.1 skill note
claimed .NET and Rust deprecate a helper (they have none public): fixed
| `ecab56d1b` |
| 3 | GO | R2.1 closed; claims checked against each SDK PR's diff
([review](#2128 (review)))
| `0526b858c` |
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Files skipped from review as they are similar to previous changes: 1
CHANGELOG.md
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Qualify the instruction to omit the user.
If the client already has VisionAgentsOptions.UserId = "alice", omitting userId preserves that identity. On an unproxied request, GetAsync can therefore return Alice’s connection rather than restricting access to app connections. With proxy authentication, the client can instead send a user token that the server-only endpoint refuses. Document that callers need a server client without a configured user for this workflow. (raw.githubusercontent.com)
Tools
LanguageTool
[grammar] ~407-~407: Use a hyphen to join words.
Context: ... may be bound to. Connections are server side only.
The reason will be displayed to describe this comment to others. Learn more.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (2)
Major · Allow callers to supply required connector inputs. · Connections.cs:66-71
sdks/dotnet/src/GetStream.VisionAgents/Connections.cs:66-71 Major · Data Integrity & Integration · Quick win
Allow callers to supply required connector inputs.
If a connector requires an input such as a region with no default, CreateAsync cannot send its value. ConnectionRequest.Inputs stays null, so the request cannot satisfy the connector schema. Add an inputs property to NewConnectionOptions and forward it to the request.
Major · Allow callers to select an authentication scheme. · Connections.cs:66-71
sdks/dotnet/src/GetStream.VisionAgents/Connections.cs:66-71 Major · Data Integrity & Integration · Quick win
Allow callers to select an authentication scheme.
If a connector has multiple non-static authentication schemes, the request contract requires auth_scheme. CreateAsync cannot set it, so callers cannot create a connection for that connector through this resource. Add an authentication scheme option and forward it to ConnectionRequest.AuthScheme.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 1 remain after this review.
…2103)
## Why
A backend that connects its users' accounts (Linear, GitHub) had only
generated operations in the Python SDK (AI-3375). It had to set
`X-Stream-User-Id` by hand and keep it equal to `owner.user_id`: the
router refuses a user connection whose two values differ
(`acceleration/internal/api/connections.go:765`). The user is now an
optional `user_id` on each call (AI-3387).
The Go reference,
[#2095](#2095), is MERGED.
Siblings: [#2099](#2099) .NET,
[#2100](#2100) Rust,
[#2101](#2101) PHP,
[#2102](#2102) Ruby,
[#2110](#2110) JS.
## How it works
```
api.connections (one flat resource, server side only)
├─ create(connector_id, *, label=None, user_id=None) -> Connection
├─ authorize(id, *, return_url=None, user_id=None) -> Authorization (launch_url, handoff_token, expires_at)
├─ get(id, *, user_id=None) -> Connection
├─ list(*, connector_id=None, user_id=None) -> every page
└─ delete(id, *, user_id=None)
```
| `user_id` | owner (create) | `X-Stream-User-Id` | list |
| --- | --- | --- | --- |
| `"alice"` | `{type: user, user_id: alice}` | `alice`, every call,
reads included | `owner_type=user` |
| `None` | `{type: app}` | none; a client built for a user still names
that user | `owner_type=app` |
- A call naming a user replaces whoever the client acts for and the user
it was built for (behind the proxy, that user would get a token of their
own).
- Every option is keyword-only, so a user id cannot land in a label's or
connector's slot.
- A device client (user token) naming a user is refused with
`ValueError` before any request, as `for_user` already was.
What the router answers (`connections.go:742-748` `mayReach`):
- a call naming a user still reaches the app's connections;
- a user's list holds only that user's connections.
```
before (deprecated, still works) after
api.for_user("u", team="finance") -> stream.Client(team="finance")
.router("clinic") -> .router("clinic", user_id="u")
.agent("docs") -> .agent("docs", user_id="u")
```
## Changes
Callers found with `grep -rn "for_user\|acting_for"` over
`plugins/stream`, its README, `examples/` and `docs/`:
| Piece | Before | After |
| --- | --- | --- |
| `Client.connections` | none | `Connections`: `create`, `authorize`,
`get`, `list`, `delete`; `Connections`, `Connection`, `Authorization`
exported |
| `Client.agent` | no user | keyword-only `user_id=None`, last |
| `Client.router` | no user | keyword-only `user_id=None`, last |
| `Client.for_user` | public | public, `DeprecationWarning` (attributed
to the caller) + docstring pointing at `user_id` |
| `_backend.py` `acting_for(backend, user_id)` | | the internal path;
`dispatch.py:293` and `accelerated.py:170` keep using it |
| `plugins/stream/README.md`, `teams.py` docstring | `for_user` |
`user_id=` on `agent`/`router` |
| `tests/test_teams.py:240,249` (integration) | `for_user` | unchanged:
deprecated calls still work |
| `CHANGELOG.md`, `.claude/skills/sdk/SKILL.md` | | one entry, one note
|
## Validation
`uv run --no-sync pytest plugins/stream -m "not integration"`: 673
passed (647 on base), by the round-2 reviewer on `d03a0634b`. `ruff
check`, `ruff format --check` and `mypy plugins/stream/vision_agents`:
clean.
| Test | Defect it catches |
| --- | --- |
| `test_a_users_connection_names_them_as_owner_and_acting_user` | owner
and header differ, label lost |
| `test_an_app_connection_names_no_user` | app connection sent with a
user, or its header dropped for a client built for a user |
| `test_every_call_sends_the_user_it_names_and_an_app_call_sends_none` |
a call (reads too) without its user; an app call with a header |
| `test_the_user_named_on_the_call_replaces_whoever_the_client_acts_for`
| behind the proxy, a token signed for the client's own user |
|
`test_a_call_naming_a_user_reaches_an_app_connection_but_lists_only_theirs`
| wrong `owner_type`, reach rule broken |
| `test_a_users_connection_is_reached_only_as_them` |
get/authorize/delete with no user or the wrong one |
| `test_authorizing_answers_where_and_how_long_the_consent_runs`,
`test_authorizing_without_a_return_url_sends_none` | return URL dropped
or sent empty; launch URL, token or expiry lost |
| `test_listing_reads_every_page_of_one_connector`,
`test_listing_the_apps_asks_for_the_apps_of_every_connector` | one page
only; connector or limit dropped |
| `test_a_page_marked_more_without_a_cursor_ends_the_list`,
`test_a_page_marked_last_ends_the_list_whatever_cursor_it_carries` | a
loop on a broken page |
| `test_deleting_a_connection_removes_it` | delete not sent, or `force`
sent |
| `test_a_connection_with_no_id_is_refused_before_the_router` | empty id
sent as a bare collection path |
| `test_every_option_is_named_never_positional` | a user id accepted in
the label, return URL or connector slot, on connections, `agent`,
`router` |
| `test_a_refusal_is_the_routers_error` | a refusal returned as success
|
| `test_an_agent_for_a_user_names_them_on_every_request`,
`test_a_router_for_a_user_names_them_whoever_the_client_acts_for` |
`user_id` not sent as `X-Stream-User-Id` |
| `test_an_agent_without_a_user_sends_what_it_sent_before`,
`test_a_router_without_a_user_opens_as_it_did_before` | backward
compatibility: paths, bodies and `X-` headers equal those probed on base
`fa2a6a66d` |
|
`test_an_agent_without_a_user_keeps_the_user_the_client_was_built_for`,
`test_agent_and_router_without_a_user_keep_the_proxy_token_user_of_the_client`
| `agent()`/`router()` with no user drop the client's own user |
| `test_a_device_cannot_name_a_user` | a device acting for another user,
incl. `user_id=""` |
| `test_a_user_named_on_the_call_is_what_for_user_was` | the replacement
signs other claims than `for_user`; wrong warning, stacklevel |
Mutations: the author's 37 killed (every condition, constant, user
hand-off, the deprecation warning and each keyword-only `*`). Round 2
reran the reviewer's 10: 8 killed, 2 equivalent (`mutate_r1.py`,
delta-2.md).
Live on the staging router, test user, connector `linear`: create (owner
user, pending), authorize (https launch URL, handoff token, 10 minute
expiry), get, get as another user is 404, list holds it and the app list
does not, delete; list after delete is 0.
## Review rounds
| Round | Verdict | Findings | Sha |
| --- | --- | --- | --- |
| 1 | not a GO (two Should fix) | R1.1 a no-user call cleared the
client's own user, R1.2 three surviving mutants: fixed; N2 cursor type,
N3 README wording: fixed; N1 stale `for_user(team=)` line in the sdk
skill: ticket | `9f8751678` |
| 2 | GO | no new findings | `d03a0634b` |
| 4 | GO | base merge of #2122 resolved in `__init__.py` (main's import
without `ensure_agent` + `Connections`); patch unchanged; ruff, mypy,
674 tests pass
([review](#2103 (review)))
| `452a64e77` |
Head `359f79d31` adds main merges and restores main's CHANGELOG lines on
top of the GO sha.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…2102)
## Why
A backend that connects its users' accounts (Linear, GitHub) has only
generated operations in the Ruby SDK (AI-3375). It would set
`X-Stream-User-Id` by hand and keep it equal to `owner.user_id`. The
user is now an optional `user_id:` on each call (AI-3387).
The Go reference,
[#2095](#2095), is MERGED.
Siblings: [#2099](#2099) .NET,
[#2100](#2100) Rust,
[#2101](#2101) PHP,
[#2103](#2103) Python,
[#2110](#2110) JS.
## How it works
```
client.connections (flat, no agents. level)
.create(connector, label:, user_id:) POST /v1/agents/connections
.authorize(id, return_url:, user_id:) POST /v1/agents/connections/{id}/authorizations -> launch_url, handoff_token, expires_at
.get(id, user_id:) GET /v1/agents/connections/{id}
.list(connector:, user_id:) GET /v1/agents/connections?owner_type=user|app&limit=200 (every page)
.delete(id, user_id:) DELETE /v1/agents/connections/{id}
```
| Call | Owner | `X-Stream-User-Id` |
| --- | --- | --- |
| `user_id: "alice"` | `{type: user, user_id: alice}` | `alice`, on
every call, reads included |
| `user_id` omitted or `""` | `{type: app}` | none from `user_id`; an
empty one drops the `acting_for` user |
| client built with its own `user_id:` | unchanged from base | still
sent (left as base behaves, as in Go) |
What the router answers (`acceleration/internal/api/connections.go`
`mayReach`, `ownerOf`):
- an app's connection is reached by any backend call, whatever `user_id`
it sends;
- a user's connection is reached only naming that user;
- `list` with a user holds only that user's connections.
## Changes
| Piece | Before | After |
| --- | --- | --- |
| `Client#connections` | none | `create` / `authorize` / `get` / `list`
/ `delete`, each with optional `user_id:` |
| `Client#get`, `post`, `put`, `patch`, `delete`, `socket` | the
backend's user only | optional `user_id:` last; `nil` keeps the
backend's user, `""` drops it |
| `Backend#acting_for` | public | still works, `@deprecated`, points at
`user_id:` |
| `Dispatch#answer` | `backend.acting_for` | `backend.acting` (`@api
private`), same requests |
| `Backend#headers` | no argument | optional `acting_for:` keyword |
| `README.md`, `CHANGELOG.md`, `.claude/skills/sdk/SKILL.md` | | a
section, one line, one note for the other SDKs |
Wrappers callers used `acting_for` for: `git grep -n acting_for --
sdks/ruby examples docs '*.md'` finds one caller, `Dispatch#answer`.
README, examples and docs name none. So `user_id:` sits on every request
level (the six `Client` verbs) and on each `connections` method.
## Validation
`docker run --rm -v "$PWD:/repo" -v va-ruby-bundle:/usr/local/bundle -w
/repo/sdks/ruby ruby:4.0 sh -c "bundle install && bundle exec rake"`:
249 runs, 1074 assertions, 0 failures (base: 230). Run on head
`ed95799c9` by the round-2 reviewer. The later commits only merge main
and restore main's CHANGELOG lines.
The stand-in `LocalRouter` records every request's method, path, body
and headers.
| Test | Defect it catches |
| --- | --- |
| `test_a_user_s_connection_names_the_user_as_owner_and_header` | owner
and header differ, or one has no user |
| `test_no_user_is_the_app_s_connection_with_no_header` | an app
connection sent with a user |
| `test_the_user_given_wins_over_whoever_the_client_acts_for` | the
deprecated acting user overrides the parameter |
| `test_authorize_without_a_user_on_an_acting_client_names_nobody` |
authorize keeps the acting user (`.to_s` dropped) |
| `test_list_without_a_user_on_an_acting_client_names_nobody` | list
keeps the acting user |
| `test_delete_without_a_user_on_an_acting_client_names_nobody` | delete
keeps the acting user |
| `test_create_sends_the_connector_given` | connector hard-coded |
| `test_authorize_sends_the_return_url_and_answers_the_consent` | return
URL dropped; launch URL, token or expiry lost |
| `test_get_and_delete_name_the_user_only_when_given` | get/delete
header missing or sent without a user |
| `test_list_reads_every_page_of_the_user_s_connections` | one page
read; header missing on a page |
| `test_list_without_a_user_is_the_app_s_and_names_nobody` | wrong
`owner_type`, or a header on the app list |
| `test_list_stops_on_a_page_that_has_no_more_or_no_cursor` | endless
paging |
| `test_an_empty_id_is_refused_before_sending` | an empty id sent as a
bare collection path |
| `test_another_user_s_connection_is_the_router_s_not_found` | a refusal
returned as success |
| `test_a_user_given_is_named_with_the_client_s_own_credential` | user
sent with the wrong credential, on each verb and the socket |
| `test_an_empty_user_names_nobody_even_on_a_client_acting_for_one` | an
empty `user_id:` keeps the acting user |
| `test_a_user_that_is_not_text_is_sent_as_text` | `headers` fails on a
non-String user |
| `test_a_request_without_a_user_is_the_one_sent_before` | backward
compatibility: every verb, the socket and `Backend#headers` send what
base `fa2a6a66d` sent |
| `test_dispatch_answers_for_the_writer_and_for_nobody_as_before` |
`Dispatch#answer` changes its requests |
Mutations: the author's 35 mutants, all killed (`mut/run-1.log`); the 5
survivors of round 1 are killed by the round-1 fix, 0 of 5 survive in
round 2. Two round-1 mutants are equivalent (reviewer-1.md).
Live on the staging router (`live/run-1.log`): create (pending, user
owner), authorize (launch URL, handoff token, expiry), get, get without
the user and as another user (`connection_not_found`), list (the user's
one, not in the app's list), delete. Nothing left behind.
## Review rounds
| Round | Verdict | Findings | Sha |
| --- | --- | --- | --- |
| 1 | NO-GO | R1.1 (five surviving mutants, tests added), R1.2 (docs on
empty `user_id:` fixed) | `3e01c84b6` |
| 2 | GO | no Blocker, no Should fix; Nit: test count in this body
(updated above) | `ed95799c9` |
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…Id (#2110)
## Why
A backend that connects its users' accounts (Linear, GitHub) had only
generated operations in the JS SDK (AI-3375, AI-3378). It would set
`X-Stream-User-Id` by hand and keep it equal to `owner.user_id`. The
user is now an optional `userId` on each call, never a client of its own
(AI-3387).
The Go reference,
[#2095](#2095), is MERGED.
Siblings: [#2099](#2099) .NET,
[#2100](#2100) Rust,
[#2101](#2101) PHP,
[#2102](#2102) Ruby,
[#2103](#2103) Python.
## How it works
```
api.connections (server side only)
├── create(connectorId, { label?, userId? }) POST /v1/agents/connections
├── authorize(id, { returnUrl?, userId? }) POST /v1/agents/connections/{id}/authorizations
├── get(id, { userId? }) GET /v1/agents/connections/{id}
├── list({ connectorId?, userId? }) GET /v1/agents/connections (every page, 200 a page, newest first)
└── delete(id, { userId? }) DELETE /v1/agents/connections/{id}
```
| `userId` | body / query | header | credential |
| --- | --- | --- | --- |
| given | `owner: {type: user, user_id}`, `owner_type=user` |
`X-Stream-User-Id` on every call, reads included | the app's server
token |
| left out or `""` | `owner: {type: app}`, `owner_type=app` | none added
| the client's own |
- A client built with `BackendOptions.userId` still sends that user on a
call without `userId`, as on its other calls.
- A client built on the deprecated `actingFor` drops its user on a call
naming none: the call is the app's.
- `userId` on a client that is not server side (a device, or a page on a
customer-id router) is a `ConfigurationError` before any request. A
server reached by customer id may name a user.
What the router answers (`acceleration/internal/api/connections.go`
`mayReach`, `ownerOf`, `listConnections`):
- the app's connections are reached whatever `userId` a call names;
- another user's is not found;
- `list({ userId })` holds only that user's.
No `force`, `auth_scheme`, `inputs` or all-users list.
## Changes
| Piece | Before | After |
| --- | --- | --- |
| `api.connections` | none | `create`, `authorize`, `get`, `list`,
`delete`, each with an optional `userId` in the options object |
| `Backend.actingFor` | public | public and working, `@deprecated`,
points at `userId` |
| `Backend.speakingFor` | none | `@internal`: the old `actingFor` body;
used by `connections` and `Dispatch.answer` (`src/dispatch.ts:264`) |
| Public wrappers that used `actingFor` | | none: `git grep -n
actingFor` over `sdks/js`, `examples/`, `docs` finds only
`Dispatch.answer` (internal) and tests. Every new parameter is optional
and last |
| `README.md`, `CHANGELOG.md`, `.claude/skills/sdk/SKILL.md` | | a
section, one entry, one note |
## Validation
`cd sdks/js && npm ci && npm test` (the SDK's real HTTP test router,
with a stand-in for the router's owner rule that records every request):
745/745 pass at `eaee43956` (fixer 2). Round 2 on `246c2dab7`: `npm ci`,
`types --check`, `npm test` 744/744, build: all exit 0.
| Test (`tests/connections.test.ts`) | Defect it catches |
| --- | --- |
| `names a user's connection as its owner and as the user acted for, so
the router takes it` | owner and header differ |
| `still speaks as the app's backend for a user, since a user's own
token is refused here` | a user token sent instead of the server one |
| `sends the user on every call about their connection, reads included`
| a call without its user |
| `names no user for the app's own connection, on any call` | a header
on an app call |
| `reads an empty user id as the app, rather than as a user nobody is` |
`""` taken as a user |
| `reaches the app's connection whoever it names, and only a user's own`
| reach rule broken |
| `lists every page of one user's connections, newest first, and not the
app's or another user's` | one page only; wrong owner |
| `stops at a page that says it is the last, or that gives no cursor to
go on from` | endless paging |
| `keeps one connector's when asked, and asks for every connector's
otherwise`; `asks for the connector it was given, and every connector's
for an empty one` | connector dropped or hard-coded |
| `leaves a label out of the request when none is given`; `sends the
label it was given` | label sent empty or lost |
| `sends the return URL it was given, and the user without one` | return
URL lost |
| `refuses a call naming no connection before asking the router` | an
empty id sent |
| `leaves a client built for a user sending that user when a call names
none, as its other calls do`; `keeps a client's own user when a call
names the empty user` | the client's own user cleared |
| `drops the deprecated actingFor user on a call naming none, so the
call is the app's` | the deprecated user leaks into an app call |
| `refuses to name a user on a device, which holds its own user's token`
| a device or page acting as a backend |
| `lets a server reached by customer id name a user, since it holds no
user's token` | the refusal widened to customer-id servers |
| `is still reached through the deprecated actingFor, sending what it
sent before userId` | backward compatibility: four backend shapes send
what base `fa2a6a66d` sent |
The existing dispatch test still asserts `answer`'s request unchanged.
Mutations: the author's 28 killed (`mutations.log`, `mutate.py`; three
paging ones by the 20 s test timeout). Round 2 reran the round-1 set:
all killed but two surviving mutants that are moved base code or
equivalent. Round 2's M3 survived, then was killed by the new row.
Live on the staging router, test user: connection to `linear`: create,
authorize, get (pending), list, delete; nothing left behind.
## Review rounds
| Round | Verdict | Findings | Sha |
| --- | --- | --- | --- |
| 1 | NO-GO | R1.1 `userId` refused off a server, R1.2 deprecated user
dropped on a no-user call, R1.3 six surviving mutants, R1.5 changelog
`(#2110)`: fixed; R1.4 `@internal` not stripped from dist, X1 cross-SDK
device check: tickets | `3fefe3055` |
| 2 | NO-GO (R2.1 Should fix) | R2.1 customer-id server refusal pinned
(`d96b127d7`), R2.2 changelog blank line (`eaee43956`): fixed |
`246c2dab7` |
| 3 | GO | R2.1 and R2.2 closed; M3 re-run and killed by the new row; no
new findings
([review](#2110 (review)))
| `77b528d78` |
Head `77b528d78` adds a main merge and restores main's CHANGELOG lines.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
## Why
A backend that connects its users' accounts (Linear, GitHub) had only
generated operations in the PHP SDK (AI-3375). It would set
`X-Stream-User-Id` by hand and keep it equal to `owner.user_id`. The
user is now an optional `userId` on each call (AI-3387).
The Go reference,
[#2095](#2095), is MERGED.
Siblings: [#2099](#2099) .NET,
[#2100](#2100) Rust,
[#2102](#2102) Ruby,
[#2103](#2103) Python,
[#2110](#2110) JS.
## How it works
```
$client->connections
├─ create(NewConnection) POST /v1/agents/connections
├─ authorize($id, AuthorizeOptions) POST /v1/agents/connections/{id}/authorizations
├─ get($id, ?string $userId = null) GET /v1/agents/connections/{id}
├─ list(ConnectionFilter) GET /v1/agents/connections (every page, limit 200)
└─ delete($id, ?string $userId = null) DELETE /v1/agents/connections/{id}
```
`NewConnection($connectorId, $label, $userId)`,
`AuthorizeOptions($returnUrl, $userId)` and `ConnectionFilter($userId,
$connectorId)` are readonly option objects (Go's `ConnectionRequest`,
`AuthorizeOptions`, `ConnectionFilter`). A string where an object goes
is a `TypeError` before anything is sent, so a user id cannot land in a
label, return URL or connector slot.
| `userId` | owner (create) | `X-Stream-User-Id` | list asks |
| --- | --- | --- | --- |
| `'ada'` | `{type: user, user_id: ada}` | `ada`, every call, reads
included | `owner_type=user` |
| left out or `''` | `{type: app}` | none, whoever the backend otherwise
acts for | `owner_type=app` |
- Behind the proxy the user is a header beside the server token, never a
user token.
- A device backend (`asUser`) and an empty id are refused before a
request is sent.
What the router answers (`acceleration/internal/api/connections.go:742`
`mayReach`):
- an app connection is reached by every backend call, one naming a user
included;
- a user's list holds only theirs.
## Changes
| Piece | Before | After |
| --- | --- | --- |
| `Client::$connections` | none | `Connections`: `create`, `authorize`,
`get`, `list`, `delete` |
| `NewConnection`, `AuthorizeOptions`, `ConnectionFilter` | none |
readonly options objects with `userId` |
| `Backend::onBehalfOf` | public | public and working, `@deprecated` in
favour of the `userId` parameter; calls `writingFor` |
| `Backend::speakingFor($userId)` | none | `@internal`: server
credential plus the header, none when empty (drops the backend's own
user); used by `Connections` |
| `Backend::writingFor($userId)` | none | `@internal`: the old
`onBehalfOf` body; used by `Worker/Dispatch.php:193`, so an empty writer
on a backend built with a user still sends that user, as on base |
| `Backend::actingFor` | signs a user token | unchanged: the device
path, not deprecated |
| Public wrappers that used `onBehalfOf` | | none: `grep -rn onBehalfOf`
over `sdks/php`, README, `examples/`, docs finds only `Dispatch::answer`
(internal) and the sdk skill |
| `README.md`, `CHANGELOG.md`, `.claude/skills/sdk/SKILL.md` | | a
section, one entry, one note |
## Validation
Round-3 reviewer on the head merged onto main, in Docker: `phpunit
--testsuite unit` OK (360 tests, 945 assertions); `phpstan analyse`
(max) no errors; `bin/generate.php ... --check` up to date (round 2).
`ConnectionsTest` runs on the `php -S` stand-in router and checks
method, path, query, body and headers of every request.
| Test | Defect it catches |
| --- | --- |
| `testAUsersConnectionNamesThemAsOwnerAndActingUser` | owner and header
differ, label or user dropped |
| `testAnAppConnectionNamesNoUser` | app connection with a user, or with
the backend's own user |
| `testEveryCallNamingAUserSendsItReadsIncluded` | a call without its
user |
| `testBehindTheProxyTheUserIsAHeaderBesideTheServersToken` | a user
token minted behind the proxy |
| `testWithNoProxyTheCustomerHeaderStaysBesideTheUser` | the customer
header lost |
| `testAuthorizingAnswersWhereAndHowLongTheConsentRuns` | return URL
dropped; launch URL, token or expiry lost |
| `testAStringWhereTheOptionsObjectGoesIsRefusedBeforeSending` | the old
string signature, where a user lands in a label |
| `testListingReadsEveryPageOfOneConnector` | one page only; connector
dropped |
| `testListingStopsOnACursorItAlreadyFollowedOrAnEmptyOne` | endless
paging |
| `testAnAppListByConnectorSendsNoUser`,
`testAnAppAuthorizationWithAReturnUrlSendsNoUser`,
`testAnAppConnectionWithALabelIsOwnedByTheApp` | a user swapped with
connector, return URL or label inside the objects |
| `testAnotherUsersConnectionIsTheRoutersNotFound` | a refusal returned
as success |
| `testRefusedBeforeSending` | a device backend or an empty id sent |
|
`ClientTest::testOnBehalfOfAnEmptyUserKeepsTheUserTheBackendWasBuiltWith`
| `onBehalfOf('')` changes the base request |
| `ClientTest::testADeviceBackendCannotActOnBehalfOfAUser` | the device
refusal of `onBehalfOf` removed |
|
`WorkerTest::testAnswerForAWriterWithoutAnIdKeepsTheUserTheBackendWasBuiltWith`
| `Dispatch::answer` request differs from base for an empty writer |
Backward compatibility: no public wrapper gained a parameter. The
existing `onBehalfOf` tests (`ClientTest`) and `Dispatch::answer` tests
(`WorkerTest`) pass unchanged.
Mutations: the author's 22, 21 killed and 1 equivalent (`mut/run1.log`);
the fixer's N1, N3 and O1-O6 killed; round 2 reviewer's 10 killed; round
3 rerun: 6 checked, 0 survived. Two mutants (an empty label or connector
sent) are equivalent, as the router trims or skips them.
Live on the staging router through the proxy, test user: create linear
(pending, owner user), authorize (consent, launch URL and handoff token
set, 600 s), get, get as another user and as the app are 404
`connection_not_found`, list holds it and the app list does not, delete
then get is 404; 0 left.
## Review rounds
| Round | Verdict | Findings | Sha |
| --- | --- | --- | --- |
| 0 (author question) | decision | R0.1 an empty writer must keep the
backend's own user as on base: fixed | `9fd8394f0` |
| 1 | NO-GO | R1.1 options objects, R1.2 two surviving mutants, R1.3
stale skill note: fixed | `9fd8394f0` |
| 2 | NO-GO | R2.1 three swap mutants (tests added), R2.2 named
`userId:` in docs: fixed | `81c2213cb` |
| 3 | GO | none | `9f649ea85` |
Head `ee224c707` adds main merges and restores main's CHANGELOG lines on
top of the GO sha.
## Questions
- PHP's `Backend::actingFor` signs a user token (the device path). In Go
and JavaScript `actingFor` names the server-side helper, so the same
name differs across SDKs. Left as the brief says.
- `Folder/Connector.php` (`fixedConnection`) has its own page loop over
`GET /v1/agents/connections`. It could call
`$client->connections->list(...)`. Not changed here.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…2100)
## Why
A backend that connects its users' accounts (Linear, GitHub) had only
generated operations in the Rust SDK (AI-3375). It had to build a whole
client with `ClientOptions::user_id` and keep it equal to
`owner.user_id`: the router refuses a user connection when the two
differ (`acceleration/internal/api/connections.go` `ownerOf`). The user
is now an optional `user_id` on each call (AI-3387).
The Go reference,
[#2095](#2095), is MERGED.
Siblings: [#2099](#2099) .NET,
[#2101](#2101) PHP,
[#2102](#2102) Ruby,
[#2103](#2103) Python,
[#2110](#2110) JS.
## How it works
```
client.connections() sdks/rust/src/connections.rs
├─ create(&NewConnection{connector, label, user_id}) -> types::Connection
├─ authorize(id, &AuthorizeOptions{return_url, user_id}) -> types::Authorization (launch_url, handoff_token, expires_at)
├─ get(id, user_id: Option<&str>)
├─ list(&ConnectionFilter{connector, user_id}) owner_type user|app, limit=200, every page
└─ delete(id, user_id: Option<&str>) no force
```
| `user_id` | owner (create) | `X-Stream-User-Id` |
| --- | --- | --- |
| `Some("alice")` | `{type: user, user_id: alice}` | `alice`, every
call, reads included |
| `None` or `Some("")` | `{type: app}` | none from the call; a client's
own `ClientOptions::user_id` stays as built (as Go) |
- Options structs (`Default`) rather than adjacent `Option<&str>`, so a
label cannot be swapped for a user.
- A user named goes through the existing `pub(crate) Client::acting_for`
(dispatch's path, `dispatch.rs:374`): it clones the client, sets
`acting_for` and clears `ClientOptions::user_id`.
- An empty id is refused before any request.
What the router answers (`connections.go:742` `mayReach`):
- every backend call reaches an app connection, even one naming a user;
- `list` with a user holds only that user's;
- another user's connection is a 404, as for one that does not exist.
## Changes
| Piece | Before | After |
| --- | --- | --- |
| `Client::connections()` | none | `Connections` with `create`,
`authorize`, `get`, `list`, `delete` |
| `NewConnection`, `AuthorizeOptions`, `ConnectionFilter` | none |
`Default` structs with `user_id`, re-exported in `lib.rs` |
| `Backend.acting_for`, `Client::acting_for` | `pub(crate)` | unchanged:
no public helper, so nothing to deprecate and no `#[deprecated]`
(`backend.rs:189`) |
| Existing public wrappers | | none changed: searched `sdks/rust`,
README, `examples/`, docs. `connections` is the only wrapper taking
`user_id`, so no backward-compatibility test |
| `README.md`, `CHANGELOG.md`, `.claude/skills/sdk/SKILL.md` | | a
section "A user's own accounts", one entry, one note |
## Validation
`cargo fmt --all --check`, `cargo clippy --workspace --all-targets -- -D
warnings`, `cargo run -p generate -- --check` and `cargo test`, in
`rust:1` per the sdk-rust skill: pass (round-2 reviewer, all 12 test
targets and doctests). The tests use the axum stand-in router
(`tests/support`), which records method, path, query, body and headers.
| Test | Defect it catches |
| --- | --- |
| `a_users_connection_names_them_as_owner_and_acting_user` | owner and
header differ; label dropped; `auth_scheme`/`inputs` sent |
|
`an_app_connection_names_no_owner_and_leaves_the_clients_own_user_as_it_is`
| `None`/`""` sent as a user; a client's own user cleared by a call
naming nobody |
| `every_call_sends_the_user_it_names_and_only_that_one` | header
missing on a call; header without a user; two headers |
| `behind_the_proxy_a_user_is_named_by_the_header_beside_a_server_token`
| a user token minted instead of the server token plus header |
| `authorizing_answers_where_and_how_long_the_consent_runs` | return URL
dropped; launch URL, token or expiry lost |
| `listing_reads_the_owners_connections_every_page` | one page only;
cursor not sent; wrong `owner_type`; connector or limit dropped |
| `a_list_naming_an_empty_user_is_the_apps_not_a_users` | an empty user
listed as `owner_type=user` or sent as a header |
| `the_apps_list_names_no_connector_unless_asked` | app list sent as
user, or with an unasked connector |
| `listing_stops_at_a_page_that_says_no_more_or_names_no_cursor` | a
cursor followed after `has_more: false` or when empty |
| `deleting_a_connection_sends_no_force` | `force` sent |
| `a_connection_with_no_id_is_refused_before_the_router` | an empty id
sent as a bare collection path |
| `another_users_connection_is_the_routers_not_found` | a refusal not
returned as `Error::Router` |
Mutations: the fixer's 22 killed (`fix-1-mutate.log`); round 2 reran
them plus 4 more: 26 checked, 0 survived.
Live on the staging router, test user, connector `linear`, booleans and
statuses only (`live/live-2.log`): create (owner user, pending),
authorize (https launch URL, token, expiry set), get, get as another
user and as the app are 404, list holds it and the app list does not,
delete; cleanup found 0 leftovers.
## Review rounds
| Round | Verdict | Findings | Sha |
| --- | --- | --- | --- |
| 1 | NO-GO | R1.1 options structs, R1.2 surviving list mutant, R1.3
changelog form, R1.4 `None` keeps the client's own user: all fixed |
`bbf74b9fd` |
| 2 | GO | no new findings | `b2083269b` |
Head `eca728e67` adds a main merge and restores main's CHANGELOG lines
on top of the GO sha.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A backend that connects its users' accounts (Linear, GitHub) has only generated operations in the .NET SDK (AI-3375). It would set
X-Stream-User-Idby hand and keep it equal toowner.user_id. The user is now an optionaluserIdon each call (AI-3387).The Go reference, #2095, is MERGED. Siblings: #2100 Rust, #2101 PHP, #2102 Ruby, #2103 Python, #2110 JS.
How it works
userId/UserIdowner(create)X-Stream-User-Idowner_type"alice"{type: user, user_id: alice}alice, every call, reads includedusernullor""{type: app}UserIdoption is left as it isappstring? userIdlast, before theCancellationToken.ActingForthat Dispatch already uses: the server credential plusX-Stream-User-Id.What the router answers (
acceleration/internal/api/connections.go:742mayReach):Changes
VisionAgentsClient.ConnectionsCreateAsync,AuthorizeAsync,GetAsync,ListAsync,DeleteAsyncNewConnectionOptions,AuthorizeOptions,ConnectionFilterUserId(Go'sConnectionRequest,AuthorizeOptions,ConnectionFilter)Backend.Acting,VisionAgentsClient.ActingFor[Obsolete]sdks/dotnet, its README,examples/,docs/), so none got auserIdREADME.md,CHANGELOG.md,.claude/skills/sdk/SKILL.mdBackendisinternal sealed class(Backend.cs:143);ActingForisinternal(VisionAgentsClient.cs:125), its only caller is Dispatch (Dispatch.cs:218). The backward-compatibility test of the brief therefore does not apply (decision Q0.1).Validation
Full suite in Docker: 323 total, 316 passed, 7 skipped (live), 0 failed (base: 309, 302, 7).
ConnectionsTestsruns on the existing KestrelTestRouter, which records method, path, query, headers and body of every request, reads included.AUserGivenIsTheOwnerAndTheHeaderOnEveryCallReadsIncludedowner_type=userNoUserIsTheAppsOwnConnectionAndSendsNoHeader(null and""){}EmptyOptionalStringsAreLeftOutAndTheOwnerIsTheUserGivenuser_idhard-codedABackendActingForAUserKeepsItsServerCredentialAUserGivenReplacesTheOneTheClientWasMadeForAndNoneLeavesItAsItIsAListReadsEveryPageWithTheSameFilter(and a theory on stop conditions)AFilterWithAConnectorAndNoUserListsTheAppsConnectionsOfThatConnectorowner_typeAConnectionIdIsOnePathSegmentAnEmptyConnectionIdIsRefusedBeforeAnythingIsSentAnotherUsersConnectionIsTheRoutersNotFoundRouterExceptionMutations: 17 mutants on
Connections.csplus 16 on the options and empty-string rules (author, round 1 and fix 1); round 2 reran 11, 0 survived. One fix-1 mutant did not build, a rerun was killed (mut-fix1.log).Live on staging with a test user: create linear (pending, owner
user), authorize (https launch URL, handoff token, 10 minute expiry), get, list with the user holds it and the app list does not, get as another user and with no user are 404connection_not_found, delete; the user ends with 0 linear connections, as before (live/live-fix1.log).Review rounds
(#2099): fixed; R1.3 (a client made for one user loses its user token when a call names another) is a ticket67c72f990dotnet format --verify-no-changesred; fixed byc05d9159e, whitespace onlya8f964d20dotnet format --verify-no-changesexits 0; the old lines fail it); no new findings (review)a8991f844🤖 Generated with Claude Code