Serve cloud session routes from a separate auth plane - #2067
Draft
RhysSullivan wants to merge 3 commits into
Draft
RhysSullivan wants to merge 3 commits into
RhysSullivan wants to merge 3 commits into
Conversation
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
executor-cloud | ae0d45f | Sep 18 2026, 07:48 PM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
executor-marketing | ae0d45f | Commit Preview URL Branch Preview URL |
Sep 18 2026, 07:48 PM |
Contributor
Cloudflare preview
Sign-in is Cloudflare Access (one-time PIN to an allowed email). The preview has its own database and encryption key; it is destroyed when this PR closes. |
@executor-js/cli
@executor-js/config
@executor-js/execution
@executor-js/sdk
@executor-js/codemode-core
@executor-js/runtime-quickjs
@executor-js/plugin-file-secrets
@executor-js/plugin-graphql
@executor-js/plugin-keychain
@executor-js/plugin-mcp
@executor-js/plugin-onepassword
@executor-js/plugin-openapi
executor
commit: |
This branch has not been deployed
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.
Every
/api/*request goes throughgetAppPlane()inapps/cloud/src/server.ts,which dynamically imports
./app— the fullExecutorApp.makecomposition(plugin/OpenAPI/MCP/GraphQL catalogs, the execution substrate, Swagger, billing).
HttpApiBuilderregisters every group into one router at layer-build time, so alazy split inside the single
HttpApiis not expressible. The seam that isexpressible is the worker entry, where
servedByAppPlanealready lives.This adds a second, small plane for the session/auth surface.
Evaluated module closures (
scripts/start-closure.mjs)A sign-out on a cold isolate now evaluates 0.05 MB of plane code instead of the
app plane's 3.77 MB.
Remaining in the auth closure beyond startup:
error-logging(31 KB), the authAPI schemas (6 KB),
last-org-cookie(6 KB), the billingplanspredicates(2 KB),
app-authitself (1 KB).Routes moved to the auth plane
GET /api/auth/login,POST /api/auth/logout,GET /api/auth/callback,GET /api/auth/cli-loginGET /api/auth/me,GET /api/auth/organizations,GET /api/auth/pending-invitations,POST /api/auth/accept-invitationPOST /api/auth/create-organization,POST /api/auth/delete-organizationGET/POST/api/mcp-sessions/:mcpSessionId/executions/:executionId[/resume]GET /api/org/domains,POST /api/org/domains/verify-link,DELETE /api/org/domains/:domainIdEverything else under
/apistill goes to the app plane.servedByAuthPlaneisan exact allowlist, gated on
servedByAppPlane, with unit tests inapp-paths.test.ts.Why create-organization and the MCP approval endpoints stayed
The plan was to move them to the full plane so the auth plane would not pull
autumn-js or the MCP module. Neither pays off:
AutumnServiceis not reachable only fromcreateOrganization. The logincallbackreconciles the landed org's billed seat count on every sign-in(
forkReportMemberSeats), so the seam is on the most important auth routethere is. Splitting the group would have moved the endpoint without removing
the dependency.
@executor-js/cloudflare/mcp/session-stubis a typed RPC accessor plus onename helper from
execution-owner-directory, whichserver.tsalreadyimports statically for the DO export. It is in the startup closure either way.
Both are visible in the measured 0.05 MB, so keeping them cost effectively
nothing and avoided splitting an
HttpApiGroup.Shape
apps/cloud/src/extensions/session-routes.ts—makeSessionRoutes/makeOrgRoutes/apiPrefixedRouter, lifted out ofextensions/routes.ts.Both planes mount the same Layer values, so handlers, middleware order, prefix
and error rendering cannot drift apart.
apps/cloud/src/api/request-scoped.ts—RequestScopedServicesLive, lifted outof
api/layers.tsso depending on the per-request socket no longer drags inthe protected plugin API.
api/layers.tsre-exports it.apps/cloud/src/app-auth.ts— the plane: those two route layers plusApiErrorLoggingLiveoverCoreSharedServices+WorkerTelemetryLive, boundwith
toApiHandler(soHttpMiddleware.traceropens the samehttp.serverspan).
server.ts— a memoizedgetAuthPlane()besidegetAppPlane(), dispatchedfirst;
executor.dispatch.planegains the valueauthandexecutor.auth_graph.enteredmirrorsapp_graph.entered. The edit is confinedto those two spots.
Not included
/.well-known/*OAuth discovery still routes through TanStack Start. Serving itfrom the auth plane means re-declaring the MCP auth seam's discovery routes
(org-pinned resource ids, toolkit slugs) outside
cloudMcpAuth, which is a realdivergence risk for MCP client discovery and is not on the sign-out path.
Verified
bun run --cwd apps/cloud typecheck— clean.vitest run src/auth src/app-paths.test.ts src/api.request-scope.node.test.ts—250 passed.
server.tsdispatch):
cloud/logout-stale-session,cloud/auth-session,cloud/org-limit,cloud/org-switcher,cloud/surface-reachability,cloud/mcp-browser-approval-org-scope— all passed.