Alpha's cloud is eliza's: @elizaos/cloud at the pin, which specifies its
own profile, routes, sign-in, device keys, entitlement, plans and billing
(.eliza/spec/cloud/). What Alpha owns, and this spec states, is which
deployment the app talks to in each environment, how Alpha's app is
registered with it as a native client, what its asset links must say,
which of its routes Alpha's screens reach through the phone, how an
operator brings a deployment up, including Alpha's own on Cloudflare, and
the gates a local cloud must pass.
The profiles, the seed and the commands that check them are apps/cloud.
- Local cloud: eliza's own server on this computer, and the gates Alpha's contract passes on it
- Provisioning: the operator's commands, in order, each read back before the next
- Rollout: Alpha's own cloud on Cloudflare, the serve step
As the owner, I want my phone to talk to one cloud, named once, so that my sign-in, my plan and my mail never go to a host the product did not choose.
A hosted environment's profile answers at its deployment's cloud and keeps its returns on its deployment's App Link host
@repo/deployment names the cloud and the App Link host of each
hosted environment. Alpha's hosted profile uses the same API origin and web
host, where Alpha's registration sends its sign-in and billing returns. The local environment runs
the staging profile on this computer, where the cloud's origin is known only
once it listens.
type Hosts = { cloud: str, appLinkHost: str }
type ProfileHosts = { api: str, webHost: str }
pure def profileFits(deployment: Hosts, profile: ProfileHosts): bool =
profile.api == deployment.cloud and profile.webHost == deployment.appLinkHostProduction and staging each use their own API and App Link hostnames. An API hostname in either environment also differs from the other environment's App Link hostname.
type HostNames = { apiHost: str, appLinkHost: str }
pure def hostedSeparate(production: HostNames, staging: HostNames): bool =
Set(production.apiHost).union(Set(production.appLinkHost)).intersect(Set(staging.apiHost).union(Set(staging.appLinkHost))).size() == 0As the owner, I want the cloud to send my sign-in back only to Alpha's own app, signed by Alpha's own key, so that no other app can take my account's key.
What a registration holds and how the cloud admits a client is eliza's
(spec/cloud/nativeClients/registry.md, "Story: Admit only a registered
native client"); applying it is eliza's client apply
(spec/cloud/nativeClients/registry.md, "Story: Apply my app's
registration from its reviewed file").
type Environment = Production | Staging
type ReturnUrl = { origin: str, path: str }
type Registration = {
clientId: str, environment: Environment, displayName: str, androidPackage: str,
certFingerprints: List[str], signInReturn: ReturnUrl, billingReturn: ReturnUrl, connectReturn: ReturnUrl
}
pure val alphaPackage = "ai.alphacompute.alphaphone"
pure val alphaName = "Alpha"The release signer is the public digest of the key Alpha's distributed
builds are signed with (legacy/android/release-signer.json). The debug
signer is the digest of the Android host's debug keystore; it is added here
when the Android area brings that keystore in, and until then staging trusts
the release signer alone.
pure val releaseSigner = "ED:BF:CA:CB:1D:A6:89:00:8B:F4:E7:D6:75:17:6C:30:2D:EC:F8:31:61:A8:77:EB:8B:1D:E4:FF:AE:04:45:ED"
pure val debugSigners: List[str] = List()
pure def signersOf(environment: Environment): List[str] =
if (environment == Staging) List(releaseSigner).concat(debugSigners) else List(releaseSigner)A debug keystore is in the repository; a release signed by it could be installed over a phone by anyone who holds the repository.
pure def lawTheReleaseSignerIsNoDebugSigner(environment: Environment): bool =
not(debugSigners.includes(releaseSigner)) and signersOf(environment).nthOr(0, "") == releaseSignerEach return is on the environment's web origin, at the paths Alpha's App Links open, and a Google connection returns to Alpha's own connect return
The sign-in and billing returns are the paths phones installed before this
rebuild already open (/alphaphone/auth/callback,
/alphaphone/billing/return). A Google connection finished for Alpha
redirects to /alphaphone/connect/return, which Alpha's App Link opens in
Alpha, so the owner is brought back rather than left on a page that only
says the connection is finished (spec/cloud/returnPages.md, "A Google
connection finished for an enabled registration without a connect return
shows ReturnToApp as connected, with no action"). Where the App Link did not
open Alpha, the cloud shows its page for that return, whose one action
opens Alpha.
pure val connectReturnPath = "/alphaphone/connect/return"
pure def registrationOf(environment: Environment, web: str): Registration = {
clientId: alphaPackage, environment: environment, displayName: alphaName, androidPackage: alphaPackage,
certFingerprints: signersOf(environment),
signInReturn: { origin: web, path: "/alphaphone/auth/callback" },
billingReturn: { origin: web, path: "/alphaphone/billing/return" },
connectReturn: { origin: web, path: connectReturnPath }
}eliza's registry refuses one (spec/cloud/nativeClients/registry.md, "A
registration is accepted only when the registry stays valid and no return
lies on the API origin, and it never changes how another client is
admitted"), so a registration whose web origin is its cloud's API origin
could never be applied.
pure def returnsOffApi(registration: Registration, api: str): bool =
registration.signInReturn.origin != api and registration.billingReturn.origin != api
and registration.connectReturn.origin != apiAn environment's asset links hold exactly one statement for Alpha's package, naming that environment's signers
type Statement = { packageName: str, fingerprints: List[str] }
pure def assetLinksNameAlpha(statements: List[Statement], environment: Environment): bool =
statements.select(s => s.packageName == alphaPackage) == List({ packageName: alphaPackage, fingerprints: signersOf(environment) })As the owner, I want my phone to use Alpha Cloud at the hosts Alpha names, with Alpha's model, sign-in and services.
Alpha deploys eliza's cloud on Cloudflare (Rollout) at the
hosted origins in @repo/deployment. The operator completes the profile
from apps/cloud/profile/candidate.example.json for those environments.
Alpha's own cloud offers inference, speech, maps, managed Google and billing, under Alpha's name, its entitlements for Alpha's package
The hosted speech profile gives the relay a secure WebSocket origin. The relay appends the provider's transcription and synthesis paths to that origin. The profile therefore supplies no endpoint path.
pure val ownCloudName = "Alpha Cloud"
pure val ownCapabilities: List[str] = List("inference", "speech", "maps", "managedGoogle", "billing")
pure def offersAlphasServices(name: str, audience: str, capabilities: List[str]): bool =
name == ownCloudName and audience == alphaPackage and capabilities == ownCapabilitiesThe reviewed profile names SIGN_IN_EMAIL in both environments. The API
Worker binds Cloudflare Email Sending to that name and allows it to send
from noreply@auth.alphaphone.dev only.
pure val ownMailSender = "noreply@auth.alphaphone.dev"
pure val ownMailBinding = "SIGN_IN_EMAIL"
pure def mailsAsAlpha(sender: str, binding: str): bool =
sender == ownMailSender and binding == ownMailBindingChat on Alpha's own cloud is Alpha's model, and a request that names no cap is quoted and sent at the longest reply its provider generates
Alpha's cloud sends chat requests directly to Cerebras in both hosted environments. Clef uses its own decision endpoint. Eliza's cloud quotes a call at its model's default cap and refuses one for a model that has none. It forwards only the caller's own cap. Alpha's phone names none, so the model's default is the longest reply its provider generates, never a shorter one.
pure val alphaModel = "qwen-3.8-27b"
pure val alphaModelLongestReply = 40960
pure def chatModelFits(endpoint: str, model: str, upstream: str, defaultCap: int): bool =
endpoint == "https://api.cerebras.ai/v1" and model == alphaModel and
upstream == alphaModel and defaultCap == alphaModelLongestReplyAs the owner, I want every screen that reads my account, plan, billing, referrals, maps, Google connection, mail and calendar to reach the cloud through my phone, so that none of them is refused because the phone could not load Alpha's list of cloud routes.
The app hands eliza's ElizaCloud plugin one route table, which eliza loads
only whole: one route that is not a device route a page may use refuses
every route (spec/os/signIn/cloudRequests.md, "A cloud table is loaded
only when every route is a device route the page may use"). The service
document and a device's own sign-out belong to sign-in and go through
eliza's sign-in plugin.
Each route of Alpha's cloud table is one of eliza's device routes by method and path, buffered, outside sign-in, and needs no fresh or stepped-up session
The phone attaches what each route's class asks for, and the page never
holds it (spec/os/signIn/cloudRequests.md): the device key; for Google
status and accounts and the Gmail and calendar reads (Mail), the device
lease, never the key; and for connecting or disconnecting Google and the
managed Gmail client's operations (Session), the account session the
phone holds after the owner signs in again. A request the phone holds back
for want of the lease or that session reads as a sign-in
(spec/app/platform/index.md). Alpha never asks for a fresh or stepped-up
session, so a route that needs one, or the sign-in's own session family,
could never be sent. Sign-in owns the routes under /api/v1/auth/,
/api/v1/app-auth/, /api/v1/api-keys/, /api/public/ and
/api/v1/voice/speech/.
type Verb = Get | Post | Patch | Delete
type Auth = Public | KeyOrSession | Mail | Session | FreshOnly
type Listing = { matches: int, buffered: bool, auth: Auth }
pure val signInPrefixes: List[str] = List("/api/v1/auth/", "/api/v1/app-auth/", "/api/v1/api-keys/", "/api/public/", "/api/v1/voice/speech/")
pure def pageRoute(listing: Listing, underSignIn: bool): bool =
listing.matches == 1 and listing.buffered and not(underSignIn) and listing.auth != FreshOnlyThe table lists every route Alpha's screens and eliza's managed mail client send, each with the query keys they send
Path parameters are written {name}. The Gmail and inbox routes, with
their keys, are the ones eliza's managed Gmail client
(@elizaos/plugin-inbox) builds.
type TableRoute = { verb: Verb, path: str, query: List[str] }
pure val cloudTable: List[TableRoute] = List(
{ verb: Get, path: "/api/v1/user", query: List() },
{ verb: Get, path: "/api/v1/referrals", query: List() },
{ verb: Post, path: "/api/v1/referrals/apply", query: List() },
{ verb: Get, path: "/api/v1/subscriptions/plans", query: List() },
{ verb: Post, path: "/api/v1/subscriptions/checkout", query: List() },
{ verb: Post, path: "/api/v1/subscriptions/checkout/confirm", query: List() },
{ verb: Post, path: "/api/v1/subscription/redeem", query: List() },
{ verb: Get, path: "/api/v1/subscription/entitlement", query: List() },
{ verb: Get, path: "/api/v1/subscription/entitlement-keys", query: List() },
{ verb: Get, path: "/api/v1/billing/limits", query: List() },
{ verb: Get, path: "/api/v1/billing/invoices", query: List() },
{ verb: Get, path: "/api/v1/billing/invoices/{invoiceId}", query: List() },
{ verb: Get, path: "/api/v1/maps/capabilities", query: List() },
{ verb: Post, path: "/api/v1/maps/geocode", query: List() },
{ verb: Post, path: "/api/v1/maps/places/search", query: List() },
{ verb: Post, path: "/api/v1/maps/places/details", query: List() },
{ verb: Post, path: "/api/v1/maps/routes", query: List() },
{ verb: Post, path: "/api/v1/maps/tiles/viewport", query: List() },
{ verb: Get, path: "/api/v1/maps/tiles/{z}/{x}/{y}", query: List() },
{ verb: Get, path: "/api/v1/eliza/google/status", query: List("side", "grantId") },
{ verb: Get, path: "/api/v1/eliza/google/accounts", query: List("side") },
{ verb: Post, path: "/api/v1/eliza/google/connect/initiate", query: List() },
{ verb: Post, path: "/api/v1/eliza/google/disconnect", query: List() },
{ verb: Get, path: "/api/v1/eliza/google/gmail/search", query: List("side", "grantId", "query", "maxResults", "pageToken") },
{ verb: Get, path: "/api/v1/eliza/google/gmail/read", query: List("side", "grantId", "messageId") },
{ verb: Get, path: "/api/v1/eliza/google/gmail/inbox-v1/capabilities", query: List("grantId") },
{ verb: Get, path: "/api/v1/eliza/google/gmail/inbox-v1/thread", query: List("grantId", "threadId", "offset", "historyId") },
{ verb: Get, path: "/api/v1/eliza/google/gmail/inbox-v1/attachment", query: List("grantId", "messageId", "partId", "historyId") },
{ verb: Get, path: "/api/v1/eliza/google/gmail/inbox-v1/drafts", query: List("grantId", "pageToken") },
{ verb: Get, path: "/api/v1/eliza/google/gmail/inbox-v1/draft", query: List("grantId", "draftId") },
{ verb: Post, path: "/api/v1/eliza/google/gmail/inbox-v1/operations", query: List() },
{ verb: Post, path: "/api/v1/eliza/google/gmail/inbox-v1/operations/{requestId}/dispatch", query: List() },
{ verb: Get, path: "/api/v1/eliza/google/gmail/inbox-v1/operations/{requestId}", query: List("grantId") },
{ verb: Get, path: "/api/v1/eliza/google/calendar/calendars", query: List("grantId", "side") },
{ verb: Get, path: "/api/v1/eliza/google/calendar/feed", query: List("grantId", "side", "calendarId", "timeMin", "timeMax", "timeZone") },
{ verb: Get, path: "/api/v1/eliza/google/calendar/events/{eventId}", query: List("grantId", "calendarId") }
)As the owner returning from a provider's consent page, I want one plain way back into Alpha that carries only what Alpha needs, and a clear message when the return cannot be used.
The provider sends the browser to Alpha's return page
(apps/app/public/delegation-return.html), which hands the result to the
app through Alpha's own link, alphaphone://cloud-delegation. The app,
not the page, checks that the state is the one it is waiting for.
The return page clears the query from its address, and hands back only a well-formed return with exactly one result
A return has exactly one state of 43 URL-safe characters, a code of at most 4096 characters or an error but never both, a description of at most 2000 characters only beside an error, no key twice and no other key. A cancelled authorization hands back the error alone; a reopened page with an empty query asks to go back to Alpha.
type ReturnQuery = {
given: int, repeated: bool, unknown: bool, stateValid: bool,
hasCode: bool, codeFits: bool, hasError: bool, hasDescription: bool, descriptionFits: bool
}
type ReturnAnswer = Reopened | InvalidReturn | Cancelled | Continue
pure def returnAnswer(q: ReturnQuery): ReturnAnswer =
if (q.given == 0) Reopened
else if (q.repeated or q.unknown or not(q.stateValid) or q.hasCode == q.hasError
or (q.hasCode and not(q.codeFits))
or (q.hasDescription and (not(q.hasError) or not(q.descriptionFits)))) InvalidReturn
else if (q.hasError) Cancelled
else Continue
pure def lawHandsBackOneResult(q: ReturnQuery): bool =
(returnAnswer(q) == Continue or returnAnswer(q) == Cancelled)
implies (q.stateValid and not(q.repeated) and not(q.unknown) and q.hasCode != q.hasError)
pure val qValues: Set[ReturnQuery] = Set(
{ given: 0, repeated: false, unknown: false, stateValid: false, hasCode: false, codeFits: true, hasError: false, hasDescription: false, descriptionFits: true },
{ given: 2, repeated: false, unknown: false, stateValid: true, hasCode: true, codeFits: true, hasError: false, hasDescription: false, descriptionFits: true },
{ given: 2, repeated: false, unknown: false, stateValid: true, hasCode: false, codeFits: true, hasError: true, hasDescription: false, descriptionFits: true },
{ given: 3, repeated: false, unknown: false, stateValid: true, hasCode: false, codeFits: true, hasError: true, hasDescription: true, descriptionFits: true },
{ given: 3, repeated: false, unknown: false, stateValid: true, hasCode: true, codeFits: true, hasError: true, hasDescription: false, descriptionFits: true },
{ given: 3, repeated: true, unknown: false, stateValid: true, hasCode: true, codeFits: true, hasError: false, hasDescription: false, descriptionFits: true },
{ given: 3, repeated: false, unknown: true, stateValid: true, hasCode: true, codeFits: true, hasError: false, hasDescription: false, descriptionFits: true },
{ given: 2, repeated: false, unknown: false, stateValid: false, hasCode: true, codeFits: true, hasError: false, hasDescription: false, descriptionFits: true },
{ given: 2, repeated: false, unknown: false, stateValid: true, hasCode: true, codeFits: false, hasError: false, hasDescription: false, descriptionFits: true },
{ given: 3, repeated: false, unknown: false, stateValid: true, hasCode: true, codeFits: true, hasError: false, hasDescription: true, descriptionFits: true },
{ given: 3, repeated: false, unknown: false, stateValid: true, hasCode: false, codeFits: true, hasError: true, hasDescription: true, descriptionFits: false }
)The query carries a one-time code; no other script, no referrer and no other request may see it.
type ReturnPage = { scripts: int, onlyItsHash: bool, sendsReferrer: bool, loads: int }
pure def returnPageSealed(page: ReturnPage): bool =
page.scripts == 1 and page.onlyItsHash and not(page.sendsReferrer) and page.loads == 0