Skip to content

fix(store): scope the offboarding sweep and settings read to the active provider - #848

Merged
davidmckayv merged 4 commits into
CopilotKit:mainfrom
rahul05ranjan:fix/offboarding-sweep-provider-predicate
Nov 2, 2026
Merged

davidmckayv merged 4 commits into
CopilotKit:mainfrom
rahul05ranjan:fix/offboarding-sweep-provider-predicate

Conversation

@rahul05ranjan

Copy link
Copy Markdown

Fixes #783.

What this changes

The two brokered_connections reads that carried no provider predicate now filter on the active brokerProvider, like the other eleven selects in connections.ts:

  • retireConnectionsFor — the offboarding sweep. Before: on a deployment holding both providers' rows, the sweep would have called the active broker's revoke() for a connection filed under the other provider — a vendor that would not recognise it — while the audit row recorded vendorRevocationRequested about access that was never removed.
  • brokeredConnectionsFor — the settings-page read. Before: a foreign-provider row would be silently dropped from the page when its app failed to resolve at the active provider's canonical scheme.

Both sites' comments said a future flow must add this predicate; this adds it, together with the regression test the issue's acceptance asks for. No behavior changes today: assertActivatable still refuses to boot a deployment whose rows disagree with the configured provider, so neither read can meet a foreign row — the predicate is free now and already right when the provider sunset flow relaxes that refusal.

Where it runs

  • New state that outlives a request? None. Two existing SELECTs gain a predicate; nothing is written, held, or memoised.
  • What happens on the second replica? Nothing new: the predicate lives in the query, so every replica reads the same rows. There are no new process-local structures.
  • Anything serialised? No new writes at all. The delete after the sweep was already scoped to the inArray(brokeredConnections.app, withdrawn...) list derived from this read, so a foreign row is never deleted either — that needed no change.
  • Anything fanned out to a browser? No.
  • New listener, port, or schedule? No.

Boundary and audit

  • Every acting call still goes through the gateway: unchanged; this is store-internal.
  • New refusals and new failures each write a row: no new refusal. The sweep skipping a foreign row is the fix, not a refusal: the trail never claims a withdrawal this deployment could not have performed.
  • Nothing new is trusted from the client: unchanged.

Changelog

  • A line in CHANGELOG.md under Unreleased, or a sentence on why a deployment behaves no differently afterwards: no deployment behaves differently — a mixed-provider deployment cannot boot today (assertActivatable), and on a single-provider deployment the predicate matches every row.

Proof

What I ran and read (no Postgres on this arm64 CI box, so the test itself runs in CI, not here):

  • Read both reads on main at their exact locations (brokeredConnectionsFor's select, retireConnectionsFor's brokered select), each carrying the comment naming this as the sunset-flow work item.
  • The predicate is byte-identical in shape to the same file's other reads, e.g. the brokeredConnection deployment-row select: eq(brokeredConnections.provider, brokerProvider).
  • Read the delete that follows the sweep (inArray(..., withdrawn.map(...))): withdrawn is built from this read, so a filtered read means a foreign row is neither revoked, nor deleted, nor audited — nothing else in the method needs the predicate.
  • Added offboarding does not revoke or audit another provider's rows beside the two neighboring offboarding tests: it seeds one composio row and one arcade row for the same user, runs the sweep through the same brokerSpy/freshStore harness as its neighbors, and asserts retired: 1, exactly one revoke: call, the arcade row still standing, and exactly one mcp.account_disconnected audit row (gmail, vendorRevocationRequested: true). On main the sweep reads the arcade row too, so the spy revokes it, retired is 2, the row is deleted, and two audit rows exist — every assertion in the test fails there.
  • Could not run bun test locally: the suite needs a live Postgres, which this host does not have. The test follows the file's existing harness line for line; CI is the authoritative run.

…ve provider

retireConnectionsFor and brokeredConnectionsFor read brokered
connections keyed (holder, userId) only, so a row filed under another
provider would be revoked through the wrong broker while the audit row
claimed the vendor was asked, or dropped silently from the settings
page. Both reads now filter on the active brokerProvider, the predicate
the other eleven selects in the file already carry. Unreachable while
assertActivatable refuses mixed deployments; this keeps the two reads
correct the moment the provider sunset flow relaxes that refusal.

Fixes CopilotKit#783

Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
The sweep now reads only the active broker's rows, but the delete after it
still matched on holder, user and app name alone. The same app filed under
the other provider is a separate row the sweep never revoked, and the delete
took it anyway, dropping the only record of a connection still live at that
vendor. The delete now carries the same provider predicate as the read.

The test's foreign row is now the same app under the other provider, the one
row the unscoped delete can reach; a different app never entered the delete's
app list, so the test passed with or without the predicate.

@davidmckayv davidmckayv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Checked together with the other fixes on one tree with the full test suite, and merging.

@davidmckayv
davidmckayv merged commit 2e6e40b into CopilotKit:main Nov 2, 2026
@rahul05ranjan

Copy link
Copy Markdown
Author

Thanks for merging #848 (fix(store): scope the offboarding sweep and settings read to the active provider)! 🎉

By the way, I'm currently open to new opportunities (Full Stack (PHP, NodeJs, Python) / Data Science / Applied AI / Devtools, based in India). If you or anyone around is hiring, I'd love to connect:
LinkedIn: https://www.linkedin.com/in/rahulswt7/ · GitHub: https://github.com/rahul05ranjan

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.

brokered_connections: two reads carry no provider predicate (blocks the provider sunset flow)

2 participants