Repository navigation
Conversation
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BcfKmNq1KK5uCkbJAKTEmQ
runAsDelegate(userAccount, delegate, fn) runs work for a known user through something acting on their behalf, outside that user's request. requireSessionUser() returns that user; currentDelegate() the delegate; there is no request or response. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BcfKmNq1KK5uCkbJAKTEmQ
A delegated call is checked like an http call, never trusted like system work: its user is its session. Access functions get the delegate and no request. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BcfKmNq1KK5uCkbJAKTEmQ
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BcfKmNq1KK5uCkbJAKTEmQ
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
A third call context,
delegated, besidehttpandsystem: work done for a known user by something acting on their behalf, outside that user's request.requireSessionUser()returns the user;currentDelegate()returns the delegate (undefinedin every other context). There is no request or response.getCallContext()is{kind: 'delegated', userAccount, delegate, linkedAuth}, withlinkedAuth = {userAccount, delegate}— the shape a request'slinkedAuthhas.checkQueryAccesschecks a delegated call exactly like an HTTP call (its user is its session). Onlysystemwork and calls outside any context stay trusted. Access functions getlinkedAuth.userAccount, thedelegate, andrequest: undefined.Why
An MCP server for Linked apps (
@linked.cm/mcp, in progress) lets a person connect an agent that reads and changes data through the app's shapes (DSL-JSON queries, declared provider methods), as that person. The endpoint checks a per-connection key, then has to run queries as the key's owner.Today
checkQueryAccessreturns early for any call that is nothttp, so a query run for an agent outside a request would skip every store rule. The only workaround is a fake request object carryinglinkedAuth, which depends on internals. The query plane's exports (queryPlane,collectQueryTargets) already cover the rest; this context is the one missing piece.Compatibility
No existing context is reinterpreted; nothing is renamed or removed. A minor changeset.
@_linked/serverhas a small follow-up (a delegated transaction is bound to its user, notsystem), opened as a draft PR that depends on this release.Tests
src/utils/CallContext.test.ts: user, delegate, no request; survivesawaitand timers; refuses a missing user or delegate id; the delegate can't be changed; system work inside it has no user.test/query-access.test.mjs(a newdescribe): aread: 'none'store refuses a delegated read (control: the same query assystemwork is not checked; an HTTP call is refused the same way); a store without a rule admits delegated reads and writes; a function rule sees the user, the delegate and no request, and can refuse delegates while admitting the user's own request; raw SPARQL off is refused.npm test: 78 unit + 123 call tests pass.Questions
delegated/runAsDelegate/currentDelegate. Happy to rename.http" as trusted? Audited here:checkQueryAccess,BackendProviderrequest fields; in server:transactionCaller,RemoteDataset's user token.The plan is in
docs/plans/001-delegated-call-context.md.🤖 Generated with Claude Code
https://claude.ai/code/session_01BcfKmNq1KK5uCkbJAKTEmQ