What a satellite is
apps/web is the central platform app. A satellite is a separate Next app on
its own subdomain that owns one slice of the product and shares the session with
web through cross-app auth.
apps/contacts (contacts.tuturuuu.com, port 7827) is the largest example: it
owns the entire workspace_users CRM surface (/[wsId]/users/* plus
workforce). apps/web no longer has a users section at all.
Shared logic lives in packages so both apps run one implementation:
Two shapes of ownership
Contacts kept shared logic in packages becauseapps/web still needed some of
it. apps/forms (forms.tuturuuu.com, port 7828) is the other shape: a
clean hard move. The forms product had no consumers outside itself, so the
feature moved wholesale with no extracted package, and apps/web retained
nothing but redirects.
Forms also owns every API route it needs — /api/v1/workspaces/[wsId]/forms/*
and the public /api/v1/shared/forms/* — instead of proxying them to web. Two
things forced that and are worth copying:
- Forms tables live in the Postgres
privateschema (getPrivateFormsClient(supabase) => supabase.schema('private')), so every read needs the admin client. An anon/RLS client cannot reach them at all, which means proxying to web buys nothing. - The public form-filling surface at
/f/<shareCode>is served to anonymous respondents. See the public-API note under API proxying below.
tuturuuu.com/<locale>/shared/forms/<shareCode>) get a
permanent 308 from web’s proxy, issued before the auth proxy runs so
respondents and social crawlers are never bounced to /login.
apps/admin follows the same hard-ownership rule for internal platform
operations. Infrastructure-only routes such as AI-credit administration,
translation tooling, and holiday administration live in that app. Shared route
shapes that its UI needs, including the root-admin workspace list and workspace
secret management, also have local Infrastructure handlers protected by the
Infrastructure app session and root-workspace membership. Do not add a new
Infrastructure UI call that depends on an apps/web fallback rewrite.
Responsive sidebar defaults
The shared satellite shell starts with its menu closed below the 768 px mobile breakpoint, including Mail and otherSidebarStructure consumers. CSS hides the
server-rendered menu before hydration. Mobile open/close controls use transient
state and preserve the remembered desktop preference. Desktop expanded, collapsed,
hover, and hidden behavior still applies. Hidden behavior suppresses navigation
on both screen sizes.
Regression coverage in
packages/ui/src/components/ui/custom/satellite-shell.test.tsx checks initial
mobile state, mobile toggles, desktop persistence, resizing, and server markup.
Cross-app navigation
Ontuturuuu.com, the sidebar app launcher links directly to the apex paths
for Meet, Mail and Calendar. Meet opens personal meetings. Mail and Calendar
use the selected workspace, or the personal workspace when none is selected.
Mail opens its inbox directly. The launcher regression test covers these
destinations.
The apex launcher entries for Web, Meet, Mail and Calendar use ordinary links
so opening an app starts a document navigation. Web, Meet, Mail and Calendar
opt into browser cross-document transitions in their Next.js and Worker
document entry points. A
supported browser can cross-fade between participating documents on the same
origin. The stylesheet respects reduced-motion preferences. This changes how
navigation is presented, while the destination still loads through its own
Worker and session checks.
The launcher opens apps in this tab by default (decided 2026-11-26, for
every app that renders the shared launcher). Same-tab switches are the fast
path: they reuse prefetched documents, cross-document transitions and the
back/forward cache, none of which help a new tab. A user who picks New
tab in the launcher’s “Open apps in” menu keeps that choice through the
shared tuturuuu-apps-launcher-open-mode cookie (.tuturuuu.com), and a
legacy stored choice migrates to it. Only users without a saved choice get
the default. Exceptions: Cmd/Ctrl-click and middle-click still open a new tab
because launcher items are ordinary links; the global command launcher
ignores this preference and opens Pay in a new tab and every other app in
this tab; on preview hosts outside
tuturuuu.com the cookie stays on that host. Regression coverage:
packages/satellite/src/components/apps-launcher-preference.test.tsx,
packages/satellite/src/components/apps-launcher.test.tsx and
packages/satellite/src/components/apps-launcher-apex.test.tsx.
In this-tab mode, the launcher’s links are prefetchable:
- Native Start apps (Mail, Tasks) render the shared Speculation Rules, which prefetch launcher links for another app on the page’s own origin; links to subdomain apps are not prefetched. API routes, server functions and sign-in or sign-out routes are excluded; see Shell Performance for the rules, cost and stop fence.
- On the apex origin, every launcher registers a rule for the public Tools entry while it is open in this-tab mode. Chromium triggers these rules on hover or pointerdown; an apex page from a native Start app (Mail, Tasks) carries both, other apex pages only the Tools rule. The Tools apex root GET selects the display language for the response without writing a locale cookie; explicit locale redirects still save the preference.
Shared UI translations
Each satellite must ship English and Vietnamese messages for the shared UI it renders, including its sidebar, account menu, settings dialog, workspace picker, and lazy dialogs. A product-only namespace check does not cover that shell. Copy missing shared values from the correspondingapps/web/messages locale;
preserve existing app-specific copy and scoped bundles rather than copying an
unrelated app’s entire common namespace.
Mind’s import-aware guard runs in the i18n workflow’s namespace check:
scripts/i18n-rendered-keys.js; update these when adding another wrapper/child
pair. Unknown dynamic expressions and unresolved workspace imports fail the
guard and need a source trace. Mind uses this whole-app check. The same CI job
also uses bun scripts/i18n-rendered-settings.js to check shared settings and
workspace components across active apps. That scan traces dashboard and Worker
runtime imports, checks both locales, and uses the filtered Web, Workspace and
marketing message sets where those providers apply. Colab uses its flat shell
catalog. The scan includes all branches of reached components. It cannot verify
which branches run in a browser.
scripts/i18n-rendered-keys.test.js covers missing keys in either locale, dynamic
families, forwarded translators, unrelated-screen exclusion and the real Mind
closure with its pre-fix keys removed. After adding keys with bun i18n:add, run
bun i18n:sort and retain only intentional bundle changes.
Cache Components: connection(), not dynamic
This matters more than it looks. Supabase-js issues fetch() under the hood, so
every server-component query is a fetch. A page with no dynamic signal gets
prerendered — and the prerender runs with no cookies:
contacts/users/database).
Rules
- Add
await connection()as the first statement of any authed page or layout that touches Supabase,getPermissions,getWorkspace, or the app session. A dynamic layout does not make its child pages dynamic — each page needs its own call. cacheComponentsalso prerenders GET route handlers. A Supabase-backed GET route with no dynamic signal is statically generated and its response is baked in at build time. Addawait connection()there too; every API route should reportƒ (Dynamic)in the build output.- Where it fits, prefer the true PPR shape: a static shell with the dynamic part
inside
<Suspense>andawait connection()inside the suspended component.apps/meet/[planId]is the reference. - Unit tests call pages and handlers outside a request scope, where
connection()throws. Stub it in the app’s vitest setup while keeping every other export:
bun validate does not compile Next apps, so it cannot see any of this. Require
the app’s real build in CI on the exact PR head when you change routes, pages,
or dependencies. Do not run builds on this machine.Browser refresh replay-store outages
The central browser refresh route (POST /api/v1/auth/cross-app-session/refresh)
requires available replay state before issuing replacement credentials. First use
and reuse within the configured browserRefreshReplayGraceSeconds continue;
reuse after grace returns 401. Signature, target, refresh scope, expiry,
current-user and required-MFA checks remain in force.
Missing replay storage or failed acquisition, read or write returns 503 with
Cache-Control: no-store, code APP_SESSION_REFRESH_UNAVAILABLE, and the stable
error App session refresh temporarily unavailable. This response contains no
credentials, performs no admin user lookup or token minting, and does not set or
clear session cookies. It indicates a temporary inability to authorize refresh;
it is not evidence that the session credential is invalid. The route does not
extend the configured grace interval or retry storage operations.
Satellite createRefreshPOST preserves central 503 and 403 MFA_REQUIRED
without minting local credentials or changing cookies. Other non-success refresh
responses remain invalid credentials; unknown errors are not relabeled as replay
storage outages. There are no automatic retries.
The shared proxy keeps using independently verified, unexpired, target-bound
access only after its existing current-MFA check and an expiry check after the
refresh response arrives. Replacement cookies are verified at response time. A refresh outage grants no
session authority and never admits expired access. With no valid access, protected
API and page paths return the same no-store 503, without login redirects,
credential minting or cookie changes. Custom page proxies and Lettin’s login
redirect preserve this distinction. Outer app proxies preserve terminal error
responses before locale, workspace and invite handling. Native runtime proxy
bridges also return terminal responses unchanged, including status, body and
headers; pending request-context cookies must not be appended. Bridge regression
coverage lives in each migrated app’s src/runtime/proxy-bridge.test.ts and checks
403/503 identity, no-store, no cookies, no redirect and no handler dispatch.
Existing anonymous API exceptions remain anonymous; a refresh outage does not create an authenticated
identity there. Healthy rotation and the existing shared-provider cookie cleanup
policy are unchanged.
Custom page adapters consume session claims only from an ok: true refresh
result, including an explicitly permitted fallback. A failed result never permits
reconstructing a session from the original request cookies: access can remain
cryptographically valid after its required MFA proof expires during an await.
Generic invalid-refresh and expired-token failures follow the existing login
redirect policy; dedicated MFA and availability failures retain their terminal
responses. Forms and Storefront public pages, and Forms, Storefront and Inventory
anonymous API exceptions, retain their existing policies. Finance returns terminal
auth failures before deployment pinning, so skew protection cannot add a deployment
cookie to an outage response; healthy responses still receive deployment pinning.
Regression coverage lives in the central refresh route suite, shared cross-app
server suite, packages/auth/src/proxy/refresh-outage.test.ts,
packages/auth/src/proxy/refresh-authority.test.ts, every custom adapter’s
proxy-refresh.test.ts, and the Finance, Learn, Calendar and Lettin suites.
Adapter coverage composes real signing, verification and final deadline checks
with mocked provider, refresh transport and locale boundaries. CI and browser
acceptance are required before claiming deployed outage behavior.
The CLI refresh endpoint has an explicit outage-continuation policy and is outside
this browser decision. Changing it requires a separate policy review.
Regression coverage lives in
apps/web/src/app/api/v1/auth/cross-app-session/refresh/route.test.ts: unavailable
storage/acquisition/read/write responses, stateful first use, the configured grace
boundary, post-grace rejection, and retained invalid-credential controls. These
handler fixtures do not establish hosted Redis or browser behavior.
Auth: resolve the actor from the app session
A registered satellite must resolve the acting user from Tuturuuu app-session auth — never from@tuturuuu/utils/user-helper, whose getCurrentUser /
getCurrentWorkspaceUser read Supabase auth directly. The internal-app-auth
guard in bun validate enforces this.
When a shared helper needs the actor, give it an injectable userId instead
of letting it resolve one:
getCurrentWorkspaceUser (web) now delegates to that same
@tuturuuu/utils/workspace-user-link helper, so there is one implementation and
web behavior is unchanged.
Workspace-user link repair must not require an optional platform display name.
New auth users initially have only a public.users.id; the repair RPC derives a
workspace profile name from display name, private full name, handle, email, and
finally a stable generic fallback. Membership remains mandatory, and the repair
does not create or broaden workspace access.
Personal workspace aliases in APIs
API routes that acceptpersonal must preserve the same authenticated actor
while resolving that alias. Use the actor-explicit helpers from
@tuturuuu/satellite/workspace-access: they verify the intended target app
before resolving personal, UUID, handle, or internal workspace identifiers,
and fall back to the request-scoped Supabase session only when no app-session
token is present. An invalid, expired, or mismatched app-session token must not
fall through to another identity. Passing only a cookie-backed client on a
satellite loses the app-session identity and incorrectly reports User not authenticated.
Route handlers must keep both values returned by the auth context: use the
explicit user for getPermissions({ user, wsId }), and the returned admin
client for workspace-scoped data operations. A request property is not an
actor for a satellite app session.
An admin-backed app-session client has no auth.uid(). Therefore a satellite
must not call a public RPC wrapper whose authorization derives from
auth.uid(). Call the private actor-aware RPC and pass the verified user ID in
its actor argument while preserving the route response shape.
The actorless-call trap
The lookup then returnsnull, the page 404s, and — because the render aborts
with Supabase fetches still in flight — those fetches outlive it and surface as:
setTimeout/after() anywhere in the tree. The cause
is the missing actor.
This is also why a satellite must not use the shared
@tuturuuu/ui/custom/workspace-wrapper: it calls bare getWorkspace(wsId)
internally, so every page rendering it inherits the bug. That took down the whole
apps/contacts users surface (20 pages) in production.
Give each satellite a src/lib/workspace.ts that resolves the actor once and
threads it through, plus an app-local wrapper that uses it:
scripts/check-internal-app-auth.js enforces both halves (no shared wrapper, no
actorless workspace, permission, or alias-normalization call) across every
registered satellite. Compatibility fallback is centralized in audited auth
wrappers and the shared workspace-access helper; individual routes are not
allowlisted.
One actor for the workspace shell
The workspace layout is the authentication boundary. Pass its verified user ID intoNavbarActions and render notifications from that same identity in
expanded, collapsed, and mobile navigation. Do not independently re-resolve
authentication for the notification bell: two resolvers can disagree and hide
the bell while the rest of the layout remains authenticated.
Reserved route placeholders
Selection sentinels such as Contacts group ID~ are navigation state, not
database identifiers. Parallel routes can begin rendering child pages before a
parent selection gateway replaces them, so app-local workspace wrappers must
stop those child loaders before any UUID filter runs. The parent gateway remains
responsible for group selection and selected-group navigation.
API proxying — and the catch-all trap
A satellite’snext.config.ts has a fallback rewrite sending any unmatched
/api/:path* to web. That is how contacts reaches endpoints it does not own.
The proxied web route must accept app sessions
Opt in explicitly, then authorize on workspace permissions (the calling app grants nothing by itself):members/invite had not. A narrow allowlist behaves
the same way for the apps it omits: { targetApp: 'teach' } on the user-group
storage route 401’d every Contacts request for group files. When you fix one route,
sweep the rest of its surface:
Public (anonymous) API routes on a satellite
apps/storefront and apps/forms both do this: match the public paths, and skip
the app-session refresh unless the caller happens to be signed in.
/f/<shareCode> as a public path so anonymous respondents are not
redirected to /login.
Related: a signed-in user on a satellite has an app-session JWT, not a
Supabase cookie. Code that asks supabase.auth.getUser() to decide “is this
person signed in” silently answers no for everyone. Forms’ response-copy
email flow hit exactly this and had to read the actor from the app session.
Next checks fallback rewrites only after dynamic routes. So
[locale]/[wsId]/[...catchAll] happily matches
/api/v1/workspaces/personal/settings as locale="api", wsId="v1" — shadowing
the proxy. The [wsId] layout then calls getWorkspace('v1') and every proxied
API call 404s:
proxy.ts middleware instead. It
handles /api in an earlier branch, so it structurally cannot shadow the proxy.
Contacts lists what it owns in CONTACTS_OWNED_ROUTE_PREFIXES; anything else
under /[wsId] redirects to web with path and query preserved.
Add an entry to that list whenever you migrate a module, or the middleware will
bounce the freshly-migrated route straight back to web. Mind prefix-vs-exact
matching: a bare
users entry that prefix-matches makes every /users/* path
look owned, so non-migrated routes 404 instead of redirecting.Translations
A satellite that renders broad shared UI must be in the checkedAPPS list
in scripts/i18n-namespace-check.js, not UNCHECKED_APPS.
Scanning only the app’s own source cannot see namespaces used inside
@tuturuuu/ui or @tuturuuu/satellite. Miss one and it surfaces as a runtime
MISSING_MESSAGE in production rather than a CI failure — which is exactly how
contacts shipped without the notifications namespace.
The shell components (user-nav-client, sidebar-structure-header,
workspace-select, settings-dialog-shell) read their strings through a bare
useTranslations() and then call t('common.dashboard'). A bare translator
carries no namespace argument, so the key-level scan cannot attribute those keys
to a namespace: it only requires them from apps listed in
BARE_ROOT_KEY_APP_SCOPES. Since common was scoped to nobody, the keys were
required of no app at all.
Contacts therefore passed the namespace check (it had common) while missing
850+ keys inside it, and shipped MISSING_MESSAGE: common.dashboard,
common.logout, nav-upgrade-dialog.*, and settings.back_to_app to production.
An app that renders the full dashboard shell belongs in
BARE_ROOT_KEY_FULL_SCOPE_APPS, which requires every bare root-qualified key the
shared packages can request. Use keyExceptions to opt out of product surfaces
the app does not render.
For narrower shared surfaces, register the owning apps in the matching scoped
consumer set. The workspace members-and-roles panel uses
SATELLITE_WORKSPACE_SETTINGS_APPS, so bun i18n:namespace-check requires its
ws-members.* and ws-roles.* keys from every satellite that mounts that
panel. The source scanner also follows typed shared helpers such as
t: (key: string) => string; otherwise helper-owned labels can evade a normal
useTranslations() scan and render their key paths in production. Keep
conditional product-only branches covered with an explicit key exception
rather than weakening the whole consumer scope.
Locale cookie scope
next-intl’s middleware writesNEXT_LOCALE itself, for example when a request
has no Accept-Language or carries an invalid locale cookie. That cookie is
host-only and not Secure. Every page proxy that runs next-intl therefore
exports a wrapped proxy:
- With
@tuturuuu/auth:withCanonicalLocaleCookie(handleProxy, { canonicalOrigins: [BASE_URL], webAppUrl })from@tuturuuu/auth/locale-cookie. - Without it (tools, marketing):
withSecureLocaleCookie(handleProxy, () => BASE_URL)from@tuturuuu/utils/locale-cookie.
Domain and Secure for every NEXT_LOCALE cookie
from the canonical origin, never from Host or an unproven X-Forwarded-Host.
A host-only cookie stays host-only. A cookie written with a Domain keeps the
shared-cookie scope of the canonical origin. Both are Secure on an https
origin. Value, Path, Max-Age and SameSite are unchanged. Cookies the
proxy writes itself use getCanonicalLocaleCookieOptions.
packages/auth/src/locale-cookie-adoption.test.ts fails for a next-intl proxy
that is not wrapped.
Moving a feature from web to a satellite
Resolve every import to an absolute path before moving anything. Afrom '@/' grep is not sufficient; each of these traps cost a broken build or a
failing test:
- Relative-sibling imports (
../../x) — invisible to a@/grep. - Dynamic imports —
await import('@/…')has nofromclause. - Side-effect imports —
import '@/lib/dayjs-setup'has nofromclause. - npm deps of the extracted file must be added to the target package.
vi.mockpaths silently break: a test mocking@/lib/xstops intercepting once the extracted module imports the package copy directly, so the real module runs unmocked.
1
Already a re-export shim
Rewrite the import straight to the package it re-exports.
2
Used only by the moving module
Move it along. A satellite maps
@/ to its own src, so the specifier often
needs no change at all.3
Still used by the origin app
Extract it to
@tuturuuu/users-core (server) or @tuturuuu/users-ui
(client) and point both apps at it. Keep a re-export shim in the origin app
when many files import it; repoint directly when only a few do.4
Mutually coupled modules
Move them together. Preserving their relative layout keeps every
cross-import valid with no rewrites at all.
connection() on data pages, the owned-routes list, removing the
origin app’s nav entry, an i18n backfill, active docs inventory, focused local
non-build checks, and exact-commit CI type/lint/test and real Next build evidence.
Rust/TanStack migration manifests remain frozen until explicitly resumed.
Deleting pages from
apps/web leaves apps/web/.next/types/validator.ts stale,
so type-check fails on paths that no longer exist. rm -rf apps/web/.next.Debugging a satellite in production
The Vercel CLI is the fastest path to a root cause:workspaceId: 'v1' in a WorkspaceHelper error is what exposed the catch-all
shadowing the API proxy.
Sign-in handoff diagnostics
The central Web routes for cross-app return, token verification, and session refresh emit one structured failure event with a fixed error code, route path, HTTP status, and a server-generated request ID. Match those fields against the reported UTC window. The event excludes credentials and request details such as query strings and cookies. On the central login page, a failed session handoff or interrupted browser session refresh offers a retry that keeps the app link. An unverified link offers to clear it. The login form and cross-app return route tests cover both the failure states and a signed-in Mail inbox handoff.Lettin deployment verification diagnostics
The Lettin deployment verifier retains its strict health, expected-version, D1, R2, login, and public-world route checks. Failed attempts record only an ordinal, fixed stage and failure category, HTTP status, and parse/match/timeout booleans. It never logs response bodies, exception text, request URLs, or version-tag values. Twelve attempts retain the 15-second request timeout and five-second delay, including the final delay. Exhaustion still fails deployment verification; these diagnostics identify a failed boundary without proving a provider-side cause. The colocated verifier fixtures run through Lettin’s owning Vitest configuration and cover those boundaries without live requests.Verified refresh authority
The shared Next.js proxy retains the exact access credential selected by the portable verifier. Initial selection keeps bearer, Web cookie, then local cookie precedence, with fallback only after cryptographic/scope/target rejection. Current MFA rejection of the selected credential does not select another actor or proof. Forwarded Authorization and refresh access input use that selected credential. A successful rotation verifies the resulting cookies independently of the old bearer before forwarding its selected replacement. The required-MFA owner returns whether current policy required the verified proof, and the bound proof when required, from its existing account/factor lookup. The proxy carries the earlier of access expiry and required proof expiry. Optional MFA proofs do not shorten access authority. A local time comparison after the last asynchronous lookup or refresh response must precede forwarding headers or cookies; no extra provider request, retry or authority cache supplies this check. An explicitnow option remains deterministic at every comparison.
packages/auth/src/proxy/refresh-authority.test.ts covers mixed credentials,
expiry during factor lookup, required proof expiry during a 503 while access is
still valid, signed replacement deadlines, optional policy, fixed time, invalid
signature/scope and current-factor rejection of a healthy replacement. The
existing refresh-outage tests retain status and cookie boundaries. Central route
unit tests replace request log draining with a typed pass-through to keep detached
log persistence outside the unit-test provider boundary. These tests require an
admitted isolated execution environment; source presence alone is not execution
evidence.
Opt-in public documents
@tuturuuu/satellite/public is the explicit public shell entry. The authenticated
default barrel, providers, app-session actors and tenant/permission guards keep
their existing contract. Public documents import only this entry and inject
framework Link/Image adapters; the shell uses shared UI branding and a theme-only
provider. It performs no session-cookie, Supabase or actor lookup. Sign-in is a
navigation affordance. User-specific content belongs to a separate private,
no-store endpoint, outside shared document caching.
Roadmap adopts this mode for its public snapshot at the apex /roadmap/ and
standalone root, with an apex canonical URL. EN/VI selection and filters stay
local to the public snapshot. Stage/evidence rules and the missing-public-receipt
reason remain authoritative. No other satellite automatically opts into this mode.
Roadmap’s response wrapper admits shared caching only for exact successful
GET/HEAD HTML representations without query variants or unsafe response headers.
Auth, server functions, errors and unknown representations stay private/no-store;
native asset policy and MIME remain with the asset supplier. The wrapper adds no
storage or background work. Actual immutable assets and hosted edge hits require
separate exact-artifact release acceptance.
Regression coverage: packages/satellite/tests/public-boundary.node-test.mjs
fences the first-party import graph and authenticated byte preimages;
packages/satellite/src/components/public-satellite-shell.test.tsx exercises SSR;
apps/roadmap/src/cache-policy.test.ts covers cache boundaries and stream/header
preservation. apps/roadmap/src/roadmap-data.test.ts covers the live data validator, the
evidence-only status engine, the shipped-feed safety filter and the host probe. Emitted auth-free bundles and
host-aware hydration remain required artifact checks.