Skip to content

Expose caller identity to app code - #2346

Open
JustYannicc wants to merge 4 commits into
UsefulSoftwareCo:v2from
JustYannicc:feat/app-caller-identity
Open

JustYannicc wants to merge 4 commits into
UsefulSoftwareCo:v2from
JustYannicc:feat/app-caller-identity

Conversation

@JustYannicc

@JustYannicc JustYannicc commented Oct 23, 2026 •

Copy link
Copy Markdown

Summary

The app-authoring docs already expose each caller's linked accounts as ctx.user.accounts. This adds ctx.user.id to that existing context so apps can attribute records and usage to the caller independently of linked accounts, including apps with no account requirements.

user: { accounts } and app: { accounts } keep their documented meanings. The host supplies the new opaque ID after authentication; public tool input cannot choose it. The factory form still receives no ctx.user for app-scoped background work, so factories read the ID with ctx.user?.id. The same PR expands the authoring docs with this distinction and guidance for shared app storage and caches.

App-scoped schedules and workflows keep no ctx.user. Hosts without user identities may leave ctx.user.id undefined. User-scoped tool and skill caches now include the caller, since app factories can produce different declarations for users with identical accounts.

This advances the app host protocol to 14 and the framework package to 0.0.1-beta.109. Adapters retain protocols 1 through 13. Review caller propagation through the runtime and workflow preparation, then the cache keys and portable host binding.

Verification

  • bun run format and bun run check passed on the rebased candidate 019867a0. The protocol checker confirms protocols 1 through 13 are unchanged and protocol 14 keeps their bundles running.
  • Rebase verification through the repository's scoped testing SDK passed on Local, self-host and managed local Cloud. The hosted checks covered two authenticated callers, factory and declaration-cache isolation, spoofed input, portable host scopes, HTTP subscription snapshots, workflow steps and MCP calls. Local calls also covered spoof resistance and portable host scopes.
  • Before the rebase, the committed caller scenarios passed on Local, self-host and managed local Cloud. Selected retained-build and caller-free app schedule/workflow scenarios passed. Negative controls failed at the caller assertions when propagation or caller-only context was dropped, then passed after correction.

A minimal authored handler is:

query({ input: object({}) }, async (ctx) => ctx.user.id)

The shared-app scenario asserts that its result equals each caller's authenticated session ID. It also asserts that a supplied tool-input ID cannot replace that result. Reproduce it with either target:

bun run e2e:self-host --test-name 'shared app handlers and cached dynamic tools retain'
bun run e2e:cloud --test-name 'shared app handlers and cached dynamic tools retain'

Production/deployed Cloud and user schedules or webhooks were not separately exercised. No full suite was run locally.

all: updates the workspace apps version in bun.lock for host protocol 14

@JustYannicc
JustYannicc force-pushed the feat/app-caller-identity branch from 6575eae to 019867a Compare October 25, 2026 08:22

This branch has not been deployed

No deployments
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