App instance lifecycle
An app instance (meroctl instance, v1’s context) is one running copy
of a bundle with its own state and its own Raft group. Its directory record
lives in the system group; its state lives only on its replicas.
Create
Section titled “Create”The node that takes the request does the checks it can, picks the replicas
and proposes one system command; the system log is where the decision is
made, so two racing creates cannot both exceed a quota. Nothing about the
app’s state exists until its own group forms on the replicas and its first
leader runs init, which is why the answer waits for that entry.
POST /apps { name, package+version | bundle, service?, initArgs?, org?, access?, confirmMethods?, metadata? }
by a passkey session, an unscoped API key, or (for its own package) a
package-bound session:
- Resolve the bundle. A package release (installed from the registry first if the cluster lacks it) or, on a development cluster, a raw bundle hash.
- Place. The node picks
--replicasnodes (3 by default) among the replica nodes on a mero-tee release approved to hold the app (its publisher’s, for a bound package; Release approvals) and not below the release’s runtime floor: one per zone first, least loaded first, then by load. Job nodes are never placed. No such node:503. The full rule and a worked example: Placement. - Record.
CreateAppapplies in the system group: the bundle must be known, the owner within their app quota, a member (at leastmember) of its organization, and a writer of the team foraccess: team. It assigns the app its group number. Every app is in an organization: the API picks it before, by the release’sinstanceOrg(the one named, the owner’s only one, or a new one it writes first; Where an instance goes). The default access isorg. - Start the group. Each replica’s reconcile loop starts the group; the first replica in the list forms it with all replicas as voters.
- Init. The group’s first leader runs
initwithinitArgsas the owner and appends theInitentry. The create request waits for it (up to 30 seconds) and answers{ appId, group, replicas, compute, links }, or422 INIT_FAILEDwith the app’s error, recorded on the instance (AppState::init_error) rather than leaving a dead app.
Calls, views and events go through any node (The write path,
Reads). The API takes the app id or its context id
(hex(SHA-256(app_id))), the id the app itself sees and hands to others.
Access, names and metadata
Section titled “Access, names and metadata”| Change | Route | Who |
|---|---|---|
| Grants | POST /apps/{app}/access |
The owner while a member, an admin, or whoever holds MANAGE_APPLICATION on each team it admits (before and after; org-wide for grants with no team); a frontend session moves its own package’s apps between its channels (App access) |
| Owner | POST /apps/{app}/transfer { to } |
The owner while a member, or an admin, with a passkey; to a member of the organization (below) |
| Organization | POST /apps/{app}/move { toOrg, bringMembers? } |
Its manager where it is, as an admin of the target, with a passkey; data stays put (Moving an app) |
| Metadata (a title, an icon; at most 16 KiB) | POST /apps/{app}/metadata |
The owner while a member, or an admin of its organization |
| An alias for the app | PUT /auth/aliases/{alias} |
Any account, for an app it reaches; aliases are the account’s own (below) |
Transfer, move and aliases
Section titled “Transfer, move and aliases”Three changes look alike and are not. A transfer changes who owns the instance; a move changes which organization it is in; an alias is a name one account gives it. None of them touches the instance’s data: the group, its replicas and its state stay where they are, and only the directory record in the system group changes.
| Transfer | Move | Alias | |
|---|---|---|---|
| Route | POST /apps/{app}/transfer { to } |
POST /apps/{app}/move { toOrg, bringMembers? } |
PUT /auth/aliases/{alias} { app } |
meroctl |
instance transfer <app> <account> |
instance move <app> <org> [--bring-members] |
instance alias add <alias> <app>, instance use <app> |
| Changes | owner (and, below cluster version 1.0.0-rc.32, the organization, out of a personal one) |
org, the grants, the payer |
The caller’s own names |
| Who | The app’s manager | Its manager where it is, as an admin of the target | Any account that reaches the app |
| Passkey | <app> / __transfer / { to } |
<app> / __move / { toOrg, bringMembers } |
None |
The transfer and the move need an unbound passkey session: a session opened on
an app’s frontend is refused both (403; Sessions &
authority). Each answers 412 CONFIRM_REQUIRED first, and the log judges the actor again where the command
applies. A refusal there is answered 400 REJECTED with the reason (the names
below are the node’s constants for those reasons), or 429 QUOTA_EXCEEDED
for a quota.
Transferring an app
Section titled “Transferring an app”POST /apps/{app}/transfer { to } hands the instance to another account.
- Who: its manager (
SystemState::manages_app): the owner while a member of the app’s organization (and, for an app on a team, while in that team), or an admin of the organization. Otherwise403. - To whom: a member (at least
member, not a guest) of the app’s organization. A transfer never moves an organization’s app out of it. - The personal-organization rule (below cluster version 1.0.0-rc.32). An
app in a personal organization handed to someone outside it went to the new
owner’s personal organization: the node makes it first if they have none, and the log
refuses the transfer if they still have none (
NO_PERSONAL_ORG). The app’steamaccess, which names a team of the organization it left, becomesorg. Its file bytes are charged to the new organization, within its quota, and its compute runs’ payer moves with it. From that version an organization flagged personal is one like any other, and the transfer is refused (400 REJECTED) before the passkey is asked for. - What it means. Who upgrades the app is now the new owner’s (for an
ownerpackage), and with it which code reads the data.
Moving an app to another organization
Section titled “Moving an app to another organization”POST /apps/{app}/move { toOrg, bringMembers } moves the instance into
another organization in one log entry (SystemCmd::MoveApp). The rules, in
the order the log judges them (Moving an app
has each in full):
- Who. The actor manages the app where it is now and is an admin or the
owner of
toOrg. The API refuses both first (403), and refuses with409 FEATURE_NOT_ACTIVEbefore the step-up while the cluster version lacks moves. - Grants. An
orggrant, or ateamgrant on its package’s app team, becomes ateamgrant on the target’s app team of the package, made when missing. Any other team is refused (MOVE_NEEDS_APP_TEAM): its leads, rows and capabilities are grants of the source the target’s admins never saw. Give the app anorgor app-team grant first. Named people andanyonestay. - Owner. The owner stays the owner and must be a member of the target
once the move is done (
MOVE_OWNER_NOT_IN_TARGET): invite them first, transfer the app to a member, or bring the members along. - Releases. Refused when the release sets that govern the app before
and after the move are both recorded and have no release in common (
MOVE_RELEASES_DISJOINT): the nodes holding the app would hold it unapproved. - Payer and quotas. The target pays from here on: the app’s file bytes
and its granted compute runs count against the target’s quotas (its own
override where the operator set one with
POST /ops/quotas, else the cluster’s, as every other charge counts them), and a move past them is refused (429 QUOTA_EXCEEDED). A move logged by a release before 1.0.0-rc.24 (noorg_quotason the entry) replays judging the cluster’s limits, as it did then; themoveOrgQuotasfeature keeps moves refused until every node reads the field. bringMembers. Every member of the source who reaches the app joins the target at their role there, capped atmember, and gets a row on the target’s app team.
The answer is { appId, from, org, access, created, added, revokedInvites }:
where it went, its access there, whether an app team was made, who was
brought in, and the source’s invites revoked because no app of the source is
left on the team they named.
Worked example. Ann made a notes instance in an organization of her own
(made with it) before Acme existed; it has org access there. She is now an admin of Acme
and moves it in: POST /apps/{notes}/move { toOrg: "<acme>" }. She manages
the app (its owner, in her own organization) and is an admin of the target.
Acme has app teams, so the instance gets team access on Acme’s app team for
notes, made now if missing, with Ann leading it. Ann is a member of Acme, so
the owner rule holds. Acme’s approved releases share one with her own
organization’s (the release the replicas run), so the releases rule holds. Acme pays for the instance’s files from this entry on.
Had the instance been on a restricted team of her own organization, the
move would have been refused MOVE_NEEDS_APP_TEAM until she set its access to
org.
Aliases
Section titled “Aliases”An alias is an account’s own name for an instance (Account::aliases): it
names nothing for anyone else and grants nothing.
PUT /auth/aliases/{alias} { app }sets it, for an app the caller reaches (404otherwise; a session bound to an app’s frontend, only for its own package’s apps). The app may be named by its id or its context id; the alias keeps the id. An alias is 1 to 64 characters, at most 1,000 per account; setting one again repoints it.GET /auth/aliasesanswers{ aliases: { alias: appId } },GET /auth/aliases/{alias}answers{ alias, appId }, andDELETE /auth/aliases/{alias}drops it.- Reaching the app is judged when the alias is used, not kept with it: an
alias of an app the account no longer reaches leads to the same
404as its id would.
meroctl resolves an alias wherever it takes an instance, and meroctl instance use <app> sets the alias default.
Replica moves
Section titled “Replica moves”The operator can move an instance to another replica set
(POST /ops/apps/{app}/replicas): new nodes join the group as learners, catch
up, and become voters, and nodes that left stop the group and delete its data
(Replica moves). A move only lands on
nodes whose release the app’s approver has approved; every refusal is in
Moving replicas.
Upgrade
Section titled “Upgrade”POST /apps/{app}/upgrade switches the instance to another release of its
package. It is code only: the new code reads the state as the old code left it
and no migration runs. The directory records the new bundle only once the upgrade
succeeded (Upgrades & migrations).
Delete
Section titled “Delete”DELETE /apps/{app} by its owner, or an admin of its organization, with a
passkey session. DeleteApp removes the directory record; each replica’s
reconcile loop then stops the group and deletes its data from that node.
An app is also deleted with its organization (DELETE /orgs/{org}, the owner
with a passkey step-up) and with the team it is deployed to (DeleteTeam takes
the team, the teams below it, and their apps, unless the deleter asks to keep
them: keepApps, Teams).