Upgrades & migrations
An upgrade moves an app instance to another bundle, usually another release of its package, and keeps its state: the new code reads what the old code stored (Upgrades & state). This page is about what the cluster does with it. How a release is parsed, verified and trusted when it is installed is in Packages & frontends.
Who may upgrade
Section titled “Who may upgrade”New code reads the app’s data, so an upgrade is one of the three decisions deployment governance assigns:
-
Owner side (default): the owner and admins of the app’s organization (
OrgRole::Adminor above), whatever its package’s signed manifest declares (upgrades: owner | publisher, App upgrades), and nobody else: not the member who created the app, a team’s lead, a holder ofMANAGE_APPLICATION, or the publisher, for an instance of another organization. Anyone else is refused403before the passkey, andapplyrefuses the entry (ownerApprovedUpgrades, below). Until every node runs 1.0.0-rc.33 the rule before holds, and entries logged before it replay as they applied: forownerthe app’s owner or whoever holdsMANAGE_APPLICATIONon its team or organization-wide; forpublisherthe publisher organization’sMANAGE_APPLICATIONholders, for every instance, and nobody until its key is bound.An app’s frontend asks
GET /apps/{app}/updatewhether there is a release to move to (available: a deployment’s offer, else the newest newer release the caller sees that the upgrade would take), whether the person may approve it (mayApprove) and who does (approvers), and sends the person to the consent page’s upgrade sheet. An instance from a deployment moves only to the release its deployment offers, which the sheet resolves for a person who never installed it; asking for it names no version. Its deployment’s managers choose that release, sodeploymentnames the deployment, and the install and upgrade sheets say who offers it (“Offered by acme (deployment<id>), run by the organization Acme Labs”): deployment names are not unique, so the id and the owner always come with the name.Each upgrades with a passkey session and a step-up over the exact upgrade (
POST /apps/{app}/upgrade { version | bundle }, then the412challenge; amigrateis refused, below). The assertion is recorded asconsenton the directory’sUpgradeAppcommand. A package may move frompublishertoownerin a later release, never back, and an app is never upgraded from anownerrelease to apublisherone. -
Operator: only the operator (
POST /ops/apps/{app}/upgrade), to a release it installed itself.
An instance from a deployment moves only to the release its
deployment offers for its package: the
deployment’s managers choose the release (OfferApp), and whoever holds the
instance’s upgrades only accepts it or not. Another version, another package
or a raw bundle is refused 409 OUTSIDE_DEPLOYMENT before the step-up, an
organization’s, publisher’s or unit’s run notes such an instance as failed,
and UpgradeApp refuses it again where it applies.
The developer decides the target, the organization’s owner and admins decide
whether to take it, and
nothing else is reachable; with upgrades: publisher the publisher’s run
takes the owner’s place, held to the same offer. An app the instance created
(a unit’s member) carries the same deployment and moves only with its unit, in
a unit upgrade to the release the deployment offers (POST /apps/{app}/upgrade-unit): alone, or in a unit run to any other release, it is
refused 409 OUTSIDE_DEPLOYMENT, before any passkey is asked for.
An owner or admin of the app’s organization may hand one app’s upgrades to CI
with an upgrade key: made once with a
passkey (403 for anyone else), it signs
each upgrade of that app to a signed release of its package in place of the
step-up, and the node refuses it everything else. Who may upgrade and the
deadline below are judged for it exactly as for a passkey, on its account, at
each upgrade: once that account is no longer an owner or admin there, the key
upgrades nothing.
Past a release deadline its
approver has not met, an upgrade is refused 409 RELEASE_DEADLINE before
anything runs.
A version alone means the app’s own package and service.
An instance runs a release, not only a WASM. A release’s frontend ships in
its signed .mpk and works with that release’s backend only, so approving a
release approves its frontend. The directory records the release each instance
runs (AppRecord::release: package, version, service), set when it is created
(the version named, or the release its deployment offers) and by every upgrade.
Releases may share a WASM: one that changes only the frontend is still an
upgrade, approved by whoever holds the app’s upgrades exactly as above, and
afterwards the instance runs, is reported at, and is served the frontend of the
new release. An instance recorded before releases were kept (or running a raw
development bundle) is taken to run the release its bundle ships in, if that
release was installed by the time the instance took the bundle.
Who may upgrade follows the release it runs. Its upgrades, its publisher
and so its approved releases are those of AppRecord::release
(SystemState::governing_release), not of whichever release first shipped the
same WASM: an instance of an owner release stays its owners’ even where a
publisher release of the package ships the same WASM, and a release installed
after an instance took a raw upload of the same WASM takes nothing from its
owner. A WASM belongs to one signer: a release of another signer’s package that
ships it is refused at install. One signer may ship it in several of its
packages, and each instance is judged by the release it runs. A cluster begun before this rule replays what it
logged then as it applied it: the first system leader on a release that judges
by the release writes AttributeByRelease (the attributeByRelease feature,
so only once the cluster version brings it), and the
rule holds from that entry on.
What the passkey signs. The challenge’s arguments are
{ bundle, migrate, manifest }: the target WASM’s hash and the target
release’s signed-manifest hash, so another manifest installed under the same
version (other outbound prefixes or frontend origins, the same WASM) is not
the upgrade that was approved. The node computes both; a target that changes
between the challenge and the assertion no longer matches it, and the upgrade
is refused. A raw development bundle has no manifest, and manifest is
null.
From the app itself. An app’s frontend cannot upgrade its instance (its
session is bound to its package). It asks the node for a consent request
({ kind: "upgrade", subject: { app, toVersion } }); the node’s own page shows
the capability sheet (outbound, frontend origins, interfaces, methods,
events, timers, the state version each side declares, build) and takes the owner’s passkey there
(The consent page).
Pinned instances
Section titled “Pinned instances”A release whose signed manifest declares lineage: pinned pins the instances
created from it, or upgraded into it, to its package and its publisher’s key:
the record’s lineage names both and its floor, the newest version the
instance has been judged at (raised by every move that applies, never
lowered), and nothing clears it, a later release that declares nothing
included. An upgrade that pins an instance is red (pinsLineage), and the
consent page says so before the owner approves it. Such an instance moves only
to a release of that package, still signed by that key, whose version is no
older than its floor or the release it runs (read as semver), whatever is
installed or uninstalled meanwhile. Another package, the operator’s
catalog and a raw bundle are refused 409 OUTSIDE_LINEAGE, an older release
409 LINEAGE_OLDER_RELEASE, before the step-up. Every path is judged again
before the upgrade reaches the app’s group (an organization’s or publisher’s
run, an update on its own, the operator’s upgrade where it holds app
upgrades: no one is exempt), since the group runs __upgrade before the
directory logs UpgradeApp, and UpgradeApp is judged once more where it
applies. Who approves the upgrade is unchanged: the lineage says only where it
may go.
The app’s group switches code before the directory records the upgrade, so a
switch whose record never followed (a crash, a refusal at apply) leaves the
group ahead: a later upgrade judged on the recorded code is refused
BundleMoved, which names the bundle the group runs. Upgrading to that release
repairs it: nothing runs, the record catches up and no restore point is taken.
If that release was uninstalled meanwhile, install it again first (or undo, or
restore); the directory knows only what it recorded, so it cannot keep that
release installed for the group.
An undo, the one move to an older release, goes back only along the lineage:
it returns code and state together to the restore point, so the older code
sees only state it already held, but undoing the upgrade that pinned an
instance from another package is refused 409 OUTSIDE_LINEAGE. The operator’s
restore takes a backup only when a release of the lineage ships both its
bundle and its compute component, and never one older than the instance’s
floor (409 LINEAGE_OLDER_RELEASE), whoever signs it: a pinned store is not
rolled back, and a fix ships as a newer release. The operator’s signature names
the bundle and compute component the restore runs. A holder’s import keeps the
pin, takes it again from the record’s release in the slice where the record
lost it, and is refused where this cluster holds that package under another
publisher, or not at all. It raises the floor to the release the record runs;
a floor that is missing or does not parse takes that release’s version, and
with no version that parses the import is refused. A floor is never set to a
version that does not parse. Every one of them, and moving the instance to
another organization, keeps the record’s lineage, and its floor only rises.
A pinning release is installed only from cluster version 1.0.0-rc.39
(409 FEATURE_NOT_ACTIVE below it), and must name a semver version.
What an upgrade runs
Section titled “What an upgrade runs”An upgrade is code only: the app’s state stays as the old code wrote it,
and the new code must read it (Upgrades & state).
calimero-sdk has no migration export yet, so nothing is planned from the
two ABIs and nothing reshapes the state; a named migrate is refused
MigrationsNotSupported. The state version each side declares
(#[app::state(version = N)]) does not decide whether an upgrade runs: the
consent page shows it, and flags a change, since the new code reads the old
data as it is.
So an app moves to any newer release of its package in one upgrade, however many releases or state versions that skips: nothing has to be applied one release at a time, and an app several releases behind is offered the newest one it can reach (below).
The runtime a release needs
Section titled “The runtime a release needs”A release’s signed manifest names the oldest runtime it runs on
(minRuntimeVersion): the merod release a node was built as. The node that
installs a release checks it against its own runtime
(Installing a release), and
records it with the release (PackageVersion::min_runtime_version). The
other nodes take the release’s WASM without verifying the .mpk, and a
cluster runs several releases while its nodes move to a new one, so the
cluster judges the requirement against the runtime of every node that would
run the app:
- Upgrades. An upgrade is refused
409 RUNTIME_TOO_OLDwhen any of the app’s replicas is on a node whose runtime is older than the target release needs;detailsnames the requirement and each such node ({ minRuntimeVersion, nodes: [{ node, runtime }] }). It is asked before the passkey step-up and on the consent page, and again where every upgrade path goes through (run_upgrade), which records the refusal as the app’s last upgrade. Nothing runs on the app’s group. - New apps. Placement leaves out the nodes whose runtime is older than
the release the app is created from; when none is left, the create is
refused
409 RUNTIME_TOO_OLD. - Replica moves.
POST /ops/apps/{app}/replicasrefuses409 RUNTIME_TOO_OLDa node the app is not on yet whose runtime is older than the release the app runs. A node it is on already is not judged, so an app can always be moved off one.
Each node names its runtime over the sealed peer channel (POST /internal/runtime, an attested node’s own answer), kept for 30 s. A node on
a release from before this answers 404: it is older than the asking
node, and judged so. A node that does not answer, or whose release is not a
version (a development build), is not judged, as before.
Which release an app can reach
Section titled “Which release an app can reach”Each app’s entry in GET /auth/apps and GET /orgs/{org}/apps names the
newer releases of its package its reader may see and move it to:
availableVersions: the newest 16, oldest first;latestReachable: the newest of all of them the upgrade would take now, ornull. It may be older than every release inavailableVersions;latestBlocked, only when the newest release is notlatestReachable: itsversion, thereasonand amessage.runtime: a replica’s node runs an older runtime than it needs, withminRuntimeVersionandnodesas the409names them;authority: the app’s owner upgrades it and the release would give its upgrades to the publisher.
Who may upgrade and release deadlines
are the same for every release of a package, so they decide whether to
upgrade, not which release to: the report leaves them to the app’s
upgradesHeldBy and approvals. A release recorded before releases kept
their runtime requirement is not judged by it here; the upgrade reads it
from the release’s .mpk and still refuses it.
Where an update may send data
Section titled “Where an update may send data”An app’s unit is the app and every app it created with it (uses in mode
create, transitively; never an app attached to it). Its egress is every
destination the releases of the unit may send a request to: each release’s
outbound prefixes, and the host of a declared secret no prefix names. Only
those destinations are reported; an empty list means no data leaves Calimero.
Any destination outside Calimero is just a destination, whatever runs there: the
platform keeps no list of trusted endpoints and never vouches for an external
one, a TEE (a private-inference service, say) included. An app that wants to
trust an external TEE verifies its attestation in its own code; the destination
is still listed.
GET /packages/{package}/{version}/capabilities answers a release’s unit
destinations before any instance exists (destinations, members), GET /apps/{app}/egress an instance’s as it runs now, and GET /apps/{app}/update
classifies the available update over the unit (as upgrade-unit would move its
members when it has any, else the app alone). The consent page’s upgrade sheets
carry the same verdict (unit) and say it in plain words: “This update can send
data to a new place:” and the new hosts when it adds any (red), else “Your data
stays in Calimero” or “This app can send data to:” and the hosts.
The classifier (calimero_bundle::update, the same code meroctl uses) calls
an update red when any of these holds, and green otherwise:
| Rule | Why |
|---|---|
The app or a member that stays is signed by another key (signerChanged) |
The code is no longer from whoever was trusted with it |
A destination after is covered by none before, members counted (egressAdded) |
Data may go somewhere it could not |
The app or a member declares another state version (stateVersionChanged) |
No migration runs, so the new code reads data in a shape it may not expect |
A member with egress joins or leaves the unit (memberAdded, memberRemoved) |
A joining member brings its own destinations; one that leaves is no longer upgraded under this consent |
A release newly calls a method of another app as the person (delegatedMethodsAdded) |
A new way to act as the user |
The app or a member, not pinned yet, moves into a release declaring lineage: pinned (pinsLineage) |
From then on it moves only to newer releases of that package by the same publisher (Pinned instances) |
New and removed methods are reported (newMethods, removedMethods) but do not
make an update red. The class decides how an update applies: a red one waits
for an owner’s or admin’s approval, for two of them under a secondApprover
policy (A second approver), and a green one applies on its
own only under a noDestinations policy, when the app’s unit has no destination
before or after it and the update removes no method and moves none of the apps
it created (Updates that apply on their own);
any other green update waits for one owner’s or admin’s approval.
The class at apply
Section titled “The class at apply”From cluster version 1.0.0-rc.34 (Feature::UpgradeClasses) every UpgradeApp
carries the class the proposing node computed for that app’s move (the app and
the members it has, as they run when it moves; in a unit’s run the instance
carries the whole unit’s class, its members moving to the run’s targets, and
each member its own). Apply cannot read a release’s ABI (it is in the .mpk), but the
log holds each release’s pinned signer, its outbound prefixes, its secrets’
hosts, whether it pins its instances. Apply classifies the move again from
those (SystemState::check_class) and refuses, 409 UPGRADE_CLASS_MISMATCH, a
class that leaves out a reason the log shows (a new signer, a destination no
release before reached, a pin), or that the classifier could never answer (red without
a reason, green with one). So no node can log a red update as green. What the
log cannot show (a state version, a method called as the person) is the
proposer’s to say. A move the log cannot rebuild (a release the app or a member
runs, or a target, no longer installed, which is allowed while another release
ships the same WASM) is never green: the log cannot confirm it, so apply refuses
a green class for it and takes a red one, gated as red. The API classifies such a
move red with an unclassified reason for each part the log lacks ({ code: "unclassified", member, package, version }, SystemState::unclassified), and
shows it the same way wherever it shows the class (GET /apps/{app}/update, the
consent page’s sheets and approval step; what compares the two sides, its
destinations, signer, state version and methods, is unknown: null in the API,
“Unknown” on the page), and
apply refuses an unclassified reason that names anything else, or one on a
move the log rebuilds. An entry carrying that reason needs cluster version
1.0.0-rc.35 (Feature::UnclassifiedUpdates), as rc.34 cannot decode it: below
it, under a secondApprover policy, the first approval, the upgrade and the
consent page of such a move are refused 409 FEATURE_NOT_ACTIVE before the
passkey (every node must run 1.0.0-rc.35 first), and without that policy the
upgrade is logged without a class, as rc.34 logs it; the update still shows red.
The class and its reasons are kept on the app’s last upgrade
(lastUpgrade.class, reasons). An entry without a class (an earlier
release’s, a raw bundle’s, or a release the classifier could not read) is taken
as red by every rule below; one logged before the feature replays as it applied.
The consent page cannot show such an update.
Its sheet builds the “before” side from the files of the release the app runs, and that release is gone.
Opening it answers 404 for a session opened on the app’s frontend and 400 NOT_A_RELEASE for any other.
Approve it from the command line or the API instead: meroctl instance update INSTANCE --version V (POST /apps/{app}/upgrade), which names the release by the app’s own record.
Under a secondApprover policy one owner or admin first runs meroctl instance approve-update INSTANCE --version V (POST /apps/{app}/upgrade-approvals), and another then runs instance update.
Both are refused 409 FEATURE_NOT_ACTIVE until every node runs 1.0.0-rc.35.
Update policies
Section titled “Update policies”How an app’s updates apply is its organization’s owner’s and admins’ to decide,
with a passkey (Feature::UpgradePolicies, 1.0.0-rc.34): SetUpgradePolicy { org, app?, policy }, consent org:<org> / __set_upgrade_policy / { app, policy }, through POST /orgs/{org}/upgrade-policy (every app of the
organization that has none of its own) or POST /apps/{app}/upgrade-policy (one
app); policy: null drops it. An app follows its own policy, else its
organization’s, else the defaults (GET on either route answers the one in
force and its source). Moving an app to another organization drops its own.
| Field | Default | Effect |
|---|---|---|
secondApprover |
off | A red (or unclassified) update needs two distinct owners or admins |
autoApply |
never |
noDestinations: a green update that removes no method and moves none of the apps it created, of an app whose unit has no destinations before or after it (no data leaves Calimero), applies on its own after the hold (Updates that apply on their own) |
holdHours |
24 | How long a green update waits before applying on its own: 24 to 168 (400 BAD_UPGRADE_POLICY) |
Nothing updates on its own by default.
Put together with the class above, an update goes one of these ways:
A second approver
Section titled “A second approver”Where the policy asks for one, a red update waits for two owners or admins. The
first approves with POST /apps/{app}/upgrade-approvals { version, unit? }, its
own consent (<app> / __approve_upgrade / { package, version, targets, class },
ApproveUpgrade), logged as a pending approval on the organization
(Org::pending_upgrades, one per app; with unit the members the unit’s
upgrade moves, by app).
A version the approver may not use (a release private to an organization they are
not in) answers 409 NOT_INSTALLED, as a version that does not exist, before any
passkey. Another owner or admin then upgrades as usual
(/upgrade, /upgrade-unit, the consent page, an organization’s or a
publisher’s run); UpgradeApp applies only with a live first approval of that
move by someone else (SystemState::update_gate), and records its approver
(lastUpgrade.approvedBy). Without one the API answers 409 SECOND_APPROVAL_REQUIRED before any passkey, and apply refuses the same. A
first approval lapses after a week (MAX_APPROVAL_AGE_SECS, judged at the
upgrade’s own time), once its approver is no longer an owner or admin, and once
every app it covers runs its target. A green update needs one approval whatever
the policy (409 ONE_APPROVAL for a first approval of it), and so does every
update without the policy. The operator’s upgrades (where it holds app upgrades)
are not judged by policies. A raw bundle carries no class, so under a second
approver it never applies. An update the log cannot classify (the release the app
runs uninstalled while another ships its WASM) is approved first like any red
one: the approval and the upgrade carry the unclassified class above.
A unit’s upgrade (/upgrade-unit, the consent page’s upgradeUnit) is judged
once, as a whole, under its instance’s policy, so it moves whole or not at all:
the unit’s class decides (a unit red only through a member waits too; its
page asks for the first of two approvals), a second approver’s first approval must be of
that very unit (unit, the same targets; a parent unit’s approval that covers the
instance too never stands in for it), and the instance’s UpgradeApp
carries the unit’s class. Each member the run then moves takes the instance’s
judgement in that run (SystemState::run_update_gate; its own class is still
checked against the log), so a member’s own policy never stops a unit half way.
A member’s own policy governs its upgrades alone. Only a unit’s consent
(__upgrade_unit) states member targets: an organization’s or a publisher’s run
keeps none, whatever its entry lists, so each app it moves is judged on its own.
GET /apps/{app}/update adds the policy in force (policy), the first
approvals waiting that cover the app (pendingApprovals), and on available
how many approvals it needs (approvalsNeeded) and who approved first
(approvedBy). GET /orgs/{org}/updates lists, for the organization’s owner
and admins, its apps with an update available or a first approval waiting, each
as GET /apps/{app}/update answers it, 50 apps a page (?after=): what the
node’s updates page shows.
Updates that apply on their own
Section titled “Updates that apply on their own”Under a noDestinations policy, a green update that removes no method and moves
none of the apps it created applies without anyone’s approval once its hold has
passed (Feature::AutoUpdates, 1.0.0-rc.34). The system leader looks every
AUTO_UPDATE_EVERY (5 s; node::auto_updates, from reconcile) for apps it
would move and the releases each could move to, newest first (SystemState::auto_update_candidates), classifies each move as
any upgrade does, and runs the first green one of each app through the usual
path, restore point first (api::upgrades::auto_upgrade), at most
MAX_AUTO_UPDATES_PER_PASS (16) apps a pass; an app it skips does not count.
A pass classifies at most MAX_AUTO_UPDATE_CLASSES_PER_PASS (64) moves, and
passes on a node take turns, so two never move the same app together. Only the
system leader’s pass moves anything: a pass on a node that no longer leads the
system group (a failover while it ran) stops before its next upgrade.
The entry is UpgradeApp { auto: true } with actor: "policy:auto-update"
(system::AUTO_UPDATE, never an account) and no consent: the policy is its
authority, and apply judges it again from the log alone
(SystemState::auto_update_gate):
- the app’s policy says
noDestinations, and the class is green (and agrees with the log, as The class at apply says); - it moves the app along its package to a newer release; never back;
- outside a deployment, the app’s owner may use that release (
sees_release: a private release only while the owner is a member of an organization it was installed for), judged from the logged cluster version that bringsFeature::PrivateReleases, so an entry logged before replays as it applied; - the app is no unit’s member (a member moves with its unit) and its unit, as the log holds it, has no destination before or after the move;
- its release keeps the unit’s members where they are: its
usesresolve each member to the release it runs, as creating the instance would pick it, among the releases its owner may use, its package’s signer signs or its deployment offers (from 1.0.0-rc.36,autoUpdateMembersStay;SystemState::moves_members); - its hold has passed: the upgrade’s own
atis at leastholdHoursafter the release was logged, its install (installedAt) or, for an instance of a deployment, its deployment’s offer of exactly that release (addedAt). Judged on logged times, never a node’s clock, so every replica agrees; - a restore point was taken where the upgrade runs on the app’s group.
Refusals: 409 AUTO_UPDATE_REFUSED, HOLD_NOT_OVER,
RESTORE_POINT_REQUIRED. The leader takes the newest release that may apply:
a newer red one, whether the log shows it (its destinations or signer) or only
the leader’s classification does (a state version that changed, a new way to
act as the person), waits for an owner or admin and does not hold back a quiet
one below it. So does a green one that drops a method (removedMethods): another
app may call it, and nothing records which, so a person decides on it. It never
takes one an update to failed or an undo left: an owner or admin decides on those.
Only the release’s own failure counts: the app’s
group ran the upgrade and it failed or refused it (lastUpgrade.ok: false),
and not when another move of the app won meanwhile: an update on its own names
the release it began from (UpgradeFailed { fromRelease }), and apply notes
nothing when the app runs the target already or no longer runs that release.
A failure before anything ran (a replica down, no restore point, a runtime not
ready yet, no leader) leaves no record; the leader tries that move again after
a backoff it keeps in memory (AUTO_UPDATE_RETRY_FIRST_SECS, 60 s, doubling to
AUTO_UPDATE_RETRY_MAX_SECS, 1 hour), and remembers a move it found not green
for NOT_GREEN_KEPT_SECS (1 hour), so the next pass reaches the apps after
it. Neither is replicated: a new leader starts without them, which only means
the work is done again. The record says lastUpgrade.auto: true. Only the app moves,
so an update whose release would move its members (its lock pins a member at
another release) is refused and waits for an owner or admin, who moves the unit
whole (upgrade-unit). Below 1.0.0-rc.36 it applied to the app alone and left
the members where they were.
Restore points and undo
Section titled “Restore points and undo”Every upgrade that runs on an app’s group takes a restore point first
(Feature::RestorePoints, 1.0.0-rc.34): the group’s sealed snapshot, brought up
to what the replica applied, copied with its manifest into that replica’s
<data>/restore-points/<app>/ exactly as a backup is written
(node::restore_points; on this node when it hosts the app, else the first
replica that answers internal/restore-point). UpgradeApp { restore_point }
names it in the log and the app keeps it as its one undo
(AppRecord::restore_point, types::RestorePoint): the release and bundle it
ran before, the upgrade’s time and run, and the file (its node, group, name,
SHA-256 and log index). A move that runs nothing on the group (the bundle it
runs already, a compute-only app) records one without a file; an upgrade that
took none leaves the app with none. A manual upgrade whose restore point
could not be taken still runs (and logs a warning); an update on its own does
not.
For UNDO_WINDOW_SECS (7 days, judged on the upgrade’s and the undo’s logged
times) an owner or admin may undo it: POST /apps/{app}/undo with a passkey
over <app> / __undo_upgrade / { apps: { <app>: { to, bundle, from, restorePoint } } } (SystemCmd::UndoUpgrade, SystemState::undo_args). The
app goes back to the release it ran and, where the upgrade ran on its group, to
the restore point’s state, in a new group the restore point’s node seeds as an
operator’s restore does (Node::seed_restore; calls answer 409 APP_RESTORING meanwhile). It is the one move to an older release. The
restore point is the state just before the upgrade, so whatever the app wrote
since is lost: GET /apps/{app}/undo says what would be undone and lost
before anyone decides (lostWrites: the group’s entries since the restore
point, its last write, and whether it wrote after the restore point was
taken), and the POST answers the same. Those are read from the replicas the
app is on now, never from the restore point’s node alone (it may be behind its
group, or a replica move may have taken the app off it): all are asked, a
majority must answer, and the furthest of them counts (every committed entry is
on a majority). Only an
applied index at or past the restore point’s counts entries or says nothing is
lost; below it, from a release that does not say, or with no majority
answering, each is null (any: null, unless a write after the restore point
was seen: true), never 0 or false: the undo does not say it loses no
writes it cannot see. A unit undoes together: an undo of
the instance reverts each member its unit’s upgrade moved in the same run
(SystemState::undo_set); a member that run moved is not undone alone (409 UNDO_NOT_AS_NAMED). Once the restore finishes (FinishRestore) the restore
point is spent; until then the undo may be sent again, which seeds it again.
Refusals, all before the passkey: 409 NO_RESTORE_POINT,
UNDO_WINDOW_PASSED, UNDO_STALE (the app no longer runs what the upgrade
moved it to), UNDO_RELEASE_GONE (the release it would return to is no longer
installed, as when its developer uninstalled it: Feature::UndoToInstalledRelease,
1.0.0-rc.36), RESTORE_POINT_UNAVAILABLE (its node does not answer or lost
it). An instance of a deployment may undo to a release the deployment no longer
offers: the undo is the customer’s way back for a week. The record says lastUpgrade.undo: true.
Storage stays bounded: a node keeps, per app, the file the app’s record names
and those taken in the last hour (an upgrade not logged yet), and sweeps the
rest every 10 minutes (RESTORE_POINT_SWEEP_EVERY), and a file past the undo
window. A restore point is a copy of the app’s state on one replica, counted as
the app’s storage and billed with the rest of its unit (to the developer, for an
instance of a deployment). If the node that holds it is gone, so is the undo.
Staged rollouts are not part of core
Section titled “Staged rollouts are not part of core”Core applies a green update on its own to every eligible instance once each one’s
hold has passed; it does not pace a release across customers in waves. Staging a
release across a fleet (a few instances first, then more, paused on failures) is
fleet orchestration, outside core: the operator’s tooling may do it by choosing
when to install or offer a release. An instance’s own policy (holdHours), its
restore point and the week’s undo are what core keeps for each one.
Running it
Section titled “Running it”The upgrade is an entry in the app’s own log, so it is ordered against the app’s calls: every call before it ran on the old code, every call after it runs on the new.
An app’s frontend asks for the same upgrade through the
consent page (kind: "upgrade"), which runs this
route as the person once they approve there.
- The app group’s leader prepares the target bundle, and refuses the upgrade while an active compute run will call a result method the target does not declare.
- It appends
Upgrade { bundle, computeBundle, base_index }. Every replica switches to the new bundle at that entry; no replica switches on its own, so there is no window in which replicas run different code. - Only then does the node record the new bundle and release in the system
directory (
UpgradeApp, which checks the upgrader’s authority again, checks the release ships the bundle, and noteslastUpgrade). An upgrade to a release with the same bundle runs nothing on the app’s group in an organization-wide run; it is recorded the same way.
Failure
Section titled “Failure”A refused upgrade leaves the app on its bundle with its state untouched.
Refused before anything runs: 409 RUNTIME_TOO_OLD (above) and 409 RELEASE_DEADLINE; refused by the app’s group: 422 UPGRADE_FAILED with the
reason. Either is recorded on the instance (UpgradeFailed sets the app’s
lastUpgrade with ok: false and the error), so a client can see why. The
app’s members read the last upgrade, with the release it went from and to
and the kind of actor, in GET /orgs/{org}/apps or GET /auth/apps; the
operator reads it without the account or the error in GET /ops/apps
(Deployment governance).
Upgrade runs
Section titled “Upgrade runs”An upgrade run moves many instances of one package to one version with a single decision: one passkey step-up (or one operator signature) for the whole run, then each app upgraded in turn. There are three kinds, by who starts it:
| Run | Route | Who | Apps it covers | Consent |
|---|---|---|---|---|
| An organization’s | POST /orgs/{org}/upgrade { package, version, team?, cascade? } |
Its owner or an admin, where owners hold app upgrades (before 1.0.0-rc.33: a holder of MANAGE_APPLICATION there, on team or organization-wide) |
The organization’s apps that run a release of package; with team, only those with team access to it, and with cascade to the teams below it too |
org:<org> / __upgrade_org / { package, version, team, cascade, migrate } |
| A publisher’s | POST /orgs/{org}/packages/{package}/upgrade { version } |
An owner or admin of the publisher of package (before 1.0.0-rc.33: an organization-wide MANAGE_APPLICATION holder there) |
Every instance of package that the starter may upgrade: those of the organizations they are an owner or admin of, never another’s (before 1.0.0-rc.33: every instance, chiefly those whose release declares upgrades: publisher) |
org:<org> / __upgrade_published / { package, version, migrate } |
| The operator’s | POST /ops/orgs/{org}/upgrade { package, version, team?, cascade? } |
The operator, where governance gives it app upgrades | As an organization’s run | The operator key’s signature over org:<org> / __upgrade_org / … (The operator) |
meroctl team upgrade trigger <org> --package P --version V [--team T [--cascade]] starts an organization’s run, meroctl team upgrade status <org> <run> follows it and meroctl team upgrade retry <org> <run> retries
it; meroctl ops upgrade-org starts the operator’s. A publisher’s run
has no command yet: meroctl raw post /orgs/<org>/packages/<package>/upgrade '{"version":"V"}'.
A run is kept by the organization that started it: the apps’ own for an
organization’s or the operator’s run, the publisher for a publisher’s run (so
its customers’ organizations never see it). Each keeps its newest 20
(UPGRADE_RUNS_KEPT).
How a run goes
Section titled “How a run goes”-
Checks before the passkey. The route checks who may start the run (an owner or admin of the organization,
403else, whichStartUpgradeRun’sapplyrefuses again) and that owners (not the operator) hold app upgrades. If the cluster lacks the release, the node installs it from the registry first, as the starter (where deployments aregranted, that install needs a deployer grant). -
The one consent. The step-up states the package, the version and the scope (
team,cascade), never the list of apps. That is what the passkey approves, and whatStartUpgradeRuncarries. -
What
applyderives. Where it applies, on every node,StartUpgradeRunverifies and spends the consent, then sets the run’s apps from the state and the method the consent names (SystemState::upgrade_run_apps), whatever list the proposing node sent:__upgrade_org: the organization’s apps ofpackagein the scope (org_run_apps);__upgrade_published: every instance that runs a release ofpackage(the release it runs,app_release, as an organization’s run and each app’sUpgradeApp { run }judge it) and that the starter may upgrade (published_run_apps: underownerApprovedUpgrades, the instances of the organizations the starter is an owner or admin of). An entry logged by a release before 1.0.0-rc.24 (noby_release) replays judging each app by the package its bundle was first recorded from, which left out an instance whose component another package’s release shipped first; thepublishedRunByReleasefeature keeps publisher runs refused until every node reads the field;__upgrade_org_retry: the apps the retried run failed on, still in the directory.
It clears
doneandfailed, and refuses a run id that any organization already holds. So a node cannot widen a run past what the passkey approved, and the answer to the request is the run as it applied. (Entries logged before the cluster’sRequireCurrentRulesmark replay as they were logged; The system group.) -
App by app. A background task on the node that started the run takes each app in turn and asks
SystemState::run_may_movefirst. An app is noted failed, with{ code: "NOT_IN_RUN", message }and without running anything, when the run does not name it, has already moved or failed it, the app no longer runs a release of the run’s package, or the run’s version is older than the release the app runs (a run never downgrades). Otherwise the app is upgraded as a single upgrade is (Running it), to the release ofversionwith the app’s own service. An app whose current WASM is already the target’s is only recorded (UpgradeApp, nothing runs on its group). A release the starter cannot see, or one that ships nothing for the app’s service, is notedNOT_INSTALLED. -
Judged again per app. Each app’s
UpgradeApp { run }names the run, andapplyfinds the run in whichever organization keeps it and checks: the same starter, the run not finished, the app one the run names, and a release of the run’s package and version that ships the bundle. The starter’s authority over that app (may_upgrade), deadlines and the runtime of every replica are judged as for any upgrade. A refusal at any point isUpgradeFailed, noted on the run’sfailedand on the app’slastUpgrade, and the run goes on with the next app. -
The end.
FinishUpgradeRunmarks it finished.
Status and retry
Section titled “Status and retry”GET /orgs/{org}/upgrades/{run} (any member of the organization that keeps
it) answers the run:
{ "runId": "k3J…", "package": "chat", "version": "1.4.0", "team": "t_support", "cascade": true, "by": "<account id, or operator>", "startedAt": 1762992000, "apps": ["a1", "a2", "a3"], "done": ["a1"], "failed": { "a3": { "code": "RUNTIME_TOO_OLD", "message": "…" } }, "finished": true}POST /orgs/{org}/upgrades/{run}/retry starts a new run over the old
run’s failed apps, under its terms (package, version, team, cascade), with a
fresh step-up over org:<org> / __upgrade_org_retry / { run } (the operator
signs the same statement for its own run). The usual reason to retry is a
failure that has since cleared: a replica on a runtime older than the release
needs (RUNTIME_TOO_OLD) once that node runs a newer one, or a release
deadline once the release is approved.
The task lives in the memory of the node that started the run: if that node stops mid-run, the run stays unfinished and the remaining apps are not upgraded until a retry or a new run.
Upgrading the cluster itself
Section titled “Upgrading the cluster itself”Moving nodes to a new mero-tee release is not an app upgrade: it is a new node
image. Nodes on the new release join the cluster, but receive an app’s data
only once that app’s approver has approved the release
(Release approvals). App frontends
follow the package: {label}.{apps-domain}/ serves the newest installed
release.
The cluster version
Section titled “The cluster version”During a rollout, nodes on the old and the new release replicate one system log together, for as long as an app’s approver keeps old nodes in use. An entry only the new release understands (a new command, or a new field that changes what an old one does) would change the state of the new nodes alone: an old node cannot apply it, and stops its group on it (below), so a cluster that proposed one too early would lose its old nodes. Earlier releases skipped such an entry instead, and kept answering reads and judging access from the state before it (a revoked API key still working there).
So each such shape is a feature with the first core release that applies
it (system::cluster_version::FEATURES), and the cluster has an active
cluster version: the newest version every node supports.
- What a node supports.
GET /healthanswersclusterVersion: the newest of the node’s core release and the features it knows (a build between two releases supports the coming one). A node from before this release answers only its corerelease, which counts in its place. A peer asks over the node’s sealed channel, so the answer comes from the attested image. - Raising it. The system leader asks every registered node (and every
member of the system group) at most every 10 seconds while the logged
version is below its own, and logs
SetClusterVersion { version, nodes }once every one of them answers and the oldest is newer than the logged version. Apply checks thatnodesnames every registered node and only those, that none is belowversion, and thatversionis newer than the logged one: it only moves forward. It is raised automatically, never by hand: raising it is safe only once every node supports it, which is what the leader checks, so an operator finishes a rollout (removes the old nodes,DELETE /ops/nodes/{id}) to raise it. A registered node that does not answer holds it where it is.GET /ops/placementshows the logged version (clusterVersion,nulluntil the first). - The gate. Every proposal goes through
Node::sys_write, which refuses a command using a feature above the active version with409 FEATURE_NOT_ACTIVE, naming the feature and the version it needs (details: { feature, needs, active }), before anything is logged. It judges on the logged version. When that is below but every node supports the feature now, the proposing node first has the version every node supports logged (SetClusterVersion,system::cluster_version::admit), then judges again on the logged one, so a cluster rolling between two releases keeps every feature both have, and no entry is in the log before the version that keeps older nodes out. OnlySetClusterVersionitself, and a cluster whose nodes are all below 1.0.0-rc.16 (which cannot decode it), are judged on what the nodes support alone. Routes that ask for a passkey step-up check before asking. - Older nodes stay out. Once a version is logged, the leader admits no node below it to the system group: a rollback means a new cluster, not an older node in this one. As every gated entry follows the version that brings it, the logged version is the one in effect.
- Apply reads only the logged version. A rule that waits for a feature reads the version logged before the entry, never what nodes advertise, so replaying a log is unchanged.
A node that still meets an entry it cannot decode (it runs an older release
than the log, or an app entry of a later entry format)
never skips it: its batch fails, which stops that group’s Raft core on the
entry, and the node applies nothing after it until it restarts on a release
that reads it. The group’s state there stays as it was before the entry; it
never moves on without it. It logs an error and counts the entry in
calimero_log_undecodable_entries_total{log} (system or app log): with every
feature gated it stays at zero. A stopped system group takes the node out of
the cluster’s system log; the other nodes go on.
| Feature | Command or field | Since |
|---|---|---|
moveApp |
MoveApp |
1.0.0-rc.15 |
appTeamJoin |
ScopeApps naming one app team’s join or keep |
1.0.0-rc.15 |
orgQuotas |
SetOrgQuotas (also 409 UPGRADE_PENDING first) |
1.0.0-rc.15 |
computePools |
SetPools (also 409 UPGRADE_PENDING first) |
1.0.0-rc.15 |
teamCloseDropsBelow |
UpdateTeam closing a team (join: invite), which takes the rows below it of whoever loses it; an earlier release keeps them |
1.0.0-rc.16 |
moveAccountsAppTeam |
MoveApp giving a moved DM’s people a row on its closed app team (accounts_in_app_team); an earlier release gives none |
1.0.0-rc.16 |
scopeByRelease |
ScopeApps judging an instance’s package by its release (by_release); an earlier release judges by the bundle |
1.0.0-rc.16 |
allApps |
SetAllApps, and an invite that gives every app added later (allApps); an earlier release cannot read the command and drops the invite’s flag |
1.0.0-rc.16 |
restoreApp |
RestoreApp and FinishRestore, an operator’s restore of an app from its sealed backup; an earlier release cannot read them |
1.0.0-rc.16 |
renameOrg |
RenameOrg, renaming an organization; an earlier release cannot read it |
1.0.0-rc.16 |
teamMembersBatch |
SetTeamMembers and RemoveTeamMembers, a member’s rows in several teams at once; an earlier release cannot read them |
1.0.0-rc.16 |
appTeamChildTeams |
ScopeApps naming one app team’s childTeams; an earlier ScopeApp refuses unknown fields |
1.0.0-rc.16 |
priceTable |
SetPriceTable, the operator’s compute prices; an earlier release cannot read it |
1.0.0-rc.19 |
computeOnly |
InstallPackage or CreateApp of a release with only a compute component; an earlier release ignores components and treats it as an app |
1.0.0-rc.19 |
pipelines |
InstallPackage of a release that registers pipelines; an earlier release drops them |
1.0.0-rc.19 |
namedPool |
AcquireRun naming a pool; an earlier release ignores pool and places the run by memory |
1.0.0-rc.19 |
attributeByRelease |
AttributeByRelease, the system leader’s one-time mark after which an app’s upgrades, publisher and release approvals follow the release it runs; an earlier release cannot read it. The leader writes it only once the logged cluster version brings it |
1.0.0-rc.19 |
currentRules |
RequireCurrentRules, the system leader’s one-time mark after which every entry applies under this release’s rules; an earlier release cannot read it. The leader writes it only once the logged cluster version brings it |
1.0.0-rc.19 |
wholeUnits |
CreateApp of a unit member with its instance’s deployment (unit_offer, the offer that covers it), and DeleteApp taking an instance’s unit with it (members); an earlier release ignores both fields, so it would refuse the member as not offered and keep the members running |
1.0.0-rc.32 |
deploymentSecrets |
SetDeploymentSecret and ClearDeploymentSecret, a deployment’s managers setting a secret’s value for every instance created from it; an earlier release cannot read them, so an instance led from it would send the operator’s value, or none, where another leader sends the deployment’s |
1.0.0-rc.32 |
autoUpdateMembersStay |
UpgradeApp with members_stay: an update on its own is refused where its release would move the unit’s members; an earlier release ignores the field and applies it to the app alone, leaving the members behind. Once the logged cluster version brings it, an entry without the flag is judged by it too |
1.0.0-rc.36 |
heldTeamGrants |
No entry: a rule SetTeamMember, SetTeamMembers, SetCapabilities and SetDefaultCapabilities apply from the logged version. Below admin, a team’s row, a row’s capabilities and a team’s default are set only on a team the actor sees, and grant only capabilities the actor holds organization-wide, as an invite’s. An earlier release would apply what this one refuses |
1.0.0-rc.38 |
inviteCreatorStanding |
No entry: a rule RedeemInvite (and a sign-up with an organization invite) and RedeemAppInvite apply from the logged version. An organization invite whose creator is no longer a member, is below its role, or no longer sees a team it names gives nothing; an instance invite whose creator no longer manages the instance’s grants names nobody. An earlier release would apply it |
1.0.0-rc.38 |
backupKeyApprovers |
No entry: a rule SetBackupKey applies from the logged version. An organization’s backup key is set only by its owner and admins, who approve its upgrades. An earlier release would take an org-wide MANAGE_APPLICATION holder’s |
1.0.0-rc.38 |
appReadLease |
No entry: each node’s app groups serve strong reads from a read lease, while every node reports a clock its host cannot slow (internal/clock, which an earlier release does not answer). Below it a strong read makes a majority round (Strong views use a lease) |
1.0.0-rc.40 |
pipelinedCalls |
baseDigest on a call in an app’s log: the leader builds a call before the calls ahead of it commit, and every replica applies it only on the state of that digest, refusing it (conflict) otherwise; an earlier release ignores the field and would apply it on a state it did not run on. Below it the leader builds each call on the applied state, one at a time |
1.0.0-rc.40 |
pipelineAppCaller |
pipelineStart in an app’s log with another app as its caller, a run a linked app starts; an earlier release has no route that admits one, so no run of an app’s is logged while a node is on it. Below it the start is refused |
1.0.0-rc.40 |
pipelineKeyScope |
CreateApiKey whose record has pipelines, a key that runs only the pipelines it names; an earlier release drops the field, so it would take the key for one that calls every method of its apps. Below it the key is not made |
1.0.0-rc.40 |
finalOutputsOnly |
finalSteps on pipelineStart in an app’s log, kept by the leader from its logged version: the run’s inputs and the outputs of every step its outputs does not name are held and never leave the app; an earlier release ignores the field and would let them out. Below it a start carries none and a run’s files are not held |
1.0.0-rc.40 |
fileRetention |
componentSweep and componentResultDays in an app’s log, and retention on a pipelineStart: a pipeline run’s inputs and outputs are released by the file retention rules on a timer; an earlier release cannot decode the sweep and would hold every file until the run’s record is dropped. Below it a run is started without the field and holds as before |
1.0.0-rc.40 |
runScopedFiles |
runKey on a pipelineStart and scope on the files a run makes: a pipeline run’s inputs and intermediates are wrapped under a run key that no backup carries; an earlier release ignores both and would open such a file with the app’s file key, which opens nothing |
1.0.0-rc.40 |
passkeyScopes |
passkeySites on a CreateAccount’s account or an ImportHolder’s slice: the frontend origin a passkey was registered on, which every sign-in and step-up holds it to; an earlier release drops it. Below it a sign-up on a package’s frontend is refused |
1.0.0-rc.40 |
pipelinesOnly |
InstallPackage of a release that ships only pipelines: an earlier release would hold its recorded part as a compute component it cannot load. Below it the API refuses the install |
1.0.0-rc.40 |
siteGrants |
A site grant in SetAccess, CreateApp or an ImportHolder’s apps: it admits the sessions opened on the instance’s own registered origins; an earlier release cannot decode it. Below it the API refuses the grant |
1.0.0-rc.40 |
xcallKeepsQueue |
keepQueue on a run’s outcome in an app’s log: an xcall past a full outbox goes to the dead letters alone and the queued messages stay; an earlier release ignores the field and would skip every queued message. Below it an entry applies as before |
1.0.0-rc.39 |
meteredBlobs |
componentBlob with metered in an app’s log: an upload charged to the app’s organization, whose record keeps the charge and gives it back when the blob is forgotten; an earlier release ignores the field and would never give it back. Below it uploads are not charged |
1.0.0-rc.39 |
ownerApprovedUpgrades |
UpgradeApp, StartUpgradeRun and CreateApiKey with owner_approves: only an owner or admin of the app’s organization upgrades it, starts a run of it or makes and uses an upgrade key for it; an earlier release ignores the field and would apply a member’s, a team lead’s or a publisher’s upgrade where a later one refuses it. Once the logged cluster version brings it, an entry without the flag is judged by it too |
1.0.0-rc.33 |
upgradeInDeployment |
UpgradeApp with in_deployment: an instance from a deployment moves only to the release its deployment offers; an earlier release ignores the field and would move it where a later one refuses |
1.0.0-rc.32 |
expireProofs |
ExpireProofs, the system leader’s one-time mark after which a sign-in’s or sign-up’s proof is forgotten once the session it opened expires (at a later entry’s own time), and a sign-in whose session expired by then is refused; an earlier release cannot read it, and would keep every proof. The leader writes it only once the logged cluster version brings it |
1.0.0-rc.31 |
backupKeys |
SetBackupKey and ImportHolder, the recovery disk’s backup keys and a holder’s import; an earlier release cannot read them |
1.0.0-rc.20 |
orgAppTeam |
CreateOrg with app_team: an organization made on the consent page from an app’s frontend starts with that app’s team; an earlier release ignores the field and makes the organization bare |
1.0.0-rc.22 |
moveOrgQuotas |
MoveApp with org_quotas; an earlier release ignores it and judges the target by the cluster’s limits instead of its own override |
1.0.0-rc.24 |
publishedRunByRelease |
StartUpgradeRun with by_release (a publisher’s run); an earlier release ignores it and picks instances by the package each bundle was first recorded from |
1.0.0-rc.24 |
orgCapabilities |
CreateOrg with capabilities: the organization’s member default capabilities, set in the creating entry; an earlier release ignores the field and leaves the default a new organization has |
1.0.0-rc.29 |
inviteCapabilities |
CreateInvite with capabilities: the bits a new member gets on redeeming; an earlier release drops the field, so they would get the organization’s default |
1.0.0-rc.29 |
clusterVersion |
SetClusterVersion |
1.0.0-rc.16 |
The rc.15 features were added before the gate: on a cluster whose every node
runs rc.15 or newer they work as before, and they are refused only while a
node on rc.14 or older replicates the log. An app log entry is gated the
same way (meteredBlobs is the first): the API writes the field only once the
logged version brings it, and the cluster version bounds every replica, since no
node below it joins.
In calimero-node
Section titled “In calimero-node”Where the node implements this chapter, by the names in its code: paths are under crates/node/src unless another crate is named.
The design and its reasons are above; a module’s own detail is in its //! doc, and the node’s mental model is crates/node/AGENTS.md.
Cluster version
Section titled “Cluster version”Code: system/cluster_version.rs, node/cluster_version.rs.
- Each gated shape is a
FeatureinFEATURES(Feature::since), named in the exhaustiveSystemCmd::features. Node::sys_writerefuses it throughNode::require_features, judged onSystemState::cluster_version, or on every node’s/healthclusterVersionwhen that is newer.- When every node supports a feature above the logged version,
cv::admitanswersAdmission::LogFirst, andraise_cluster_version_oncelogs that version first throughNode::sys_propose(the ungated write). - The system leader’s
reconcilecallsraise_cluster_version;joins_at_cluster_versionkeeps older nodes out of the system group. - Apply reads
SystemState::cluster_bringsat the entry’s own position. - An entry a node cannot decode stops its group there (
StateTx::fail). /healthadvertisesNode::advertises(cv::supported).- A cluster test holds one node below a feature with
testing::advertise_cluster_versioninCluster::start_with’sconfigure.
Upgrades are code-only
Section titled “Upgrades are code-only”A component upgrade is the app-log entry componentUpgrade, which swaps the bundle; a named migrate is refused MigrationsNotSupported.
The directory records the new bundle only once the upgrade succeeded.
The consent page’s stateVersion comes from each side’s calimero:abi.
Pinned instances
Section titled “Pinned instances”Code: system.rs (SystemState::within_lineage, SystemState::lineage_of), system/apps.rs, api/upgrades.rs.
PackageVersion::lineagerecords the manifest’slineage;Feature::PinnedLineagegates installing a pinning release.CreateAppandUpgradeAppsetAppRecord::lineagefrom the release that governs the instance, and never clear it; the classifier’spinsLineage(Release::pinned) is judged at apply fromPackageVersion::lineage.on_lineage(package and signer, any order) judges an undo;ships_on_lineageandrestores_oldera restore (never below the floor);imported_lineageanImportHolder’s record.within_lineageruns before the step-up, inrun_upgradebefore__upgradereaches the group, and inUpgradeApp’s apply, without an operator exemption.
Runtime requirements
Section titled “Runtime requirements”Code: runtime.rs, node/runtime.rs.
PackageVersion::min_runtime_versionis absent for older releases or after an older node applied the install;Node::min_runtime_ofthen reads the.mpk(consent_page::declared_min_runtime).- A node’s runtime is
Config::release, asked byNode::runtime_of_nodeand keptRUNTIME_KEPT. A404isNodeRuntime::Before, judged as the asker’s own; no answer or a non-version isUnknown, not judged. Node::require_runtimeguardsupgrade_app(before the step-up), the consent request,run_upgradeandops_set_replicas;Node::placeleaves such nodes out.latestReachableandlatestBlockedcome fromreport::upgrade_targets.
Upgrade runs
Section titled “Upgrade runs”- Who may start:
approves_upgrades, orSystemState::manages_appsbeforeFeature::OwnerApprovedUpgrades. StartUpgradeRunrecords atypes::UpgradeRun(newestUPGRADE_RUNS_KEPT); eachUpgradeApp/UpgradeFailednotes the app on the run and onAppRecord::last_upgrade.- Once
SystemState::current_rules_fromis set, apply derives the apps withSystemState::upgrade_run_apps:org_run_apps,published_run_appsor a retry’s failed apps. - A publisher’s run sets
StartUpgradeRun { by_release }(Feature::PublishedRunByRelease), judging each app byapp_release. SystemState::run_may_movejudges eachUpgradeApp { run };api::start_runasks it first and notesNOT_IN_RUN.
Upgrade keys
Section titled “Upgrade keys”Code: ApiKeyRecord::upgrades, types::UpgradeScope.
POST /auth/apikeys { upgrades: { app, package? } };api_key_argsstatesupgradesonly when set, so other keys’ consents are unchanged.- A package with no release the maker may use answers
404 no such package, as a missing one, before the passkey. - The key also holds the public half of an Ed25519 key derived from it (
proof::api_key_public). api::principalrefuses it everywhere (403 UPGRADE_KEY_ONLY); onlyapp_upgradetakes it (api::credential), withinSystemState::key_may_upgrade.- It signs in place of the step-up (
proof::sign_key_upgrade, carried inUpgradeApp::consent);authorizeverifies it under the key the log holds and spends it. upgrade_key_fits(.., owner_approves)gates making it (403before the passkey), andCreateApiKey { owner_approves }again at apply.upgrade_appandUpgradeAppjudge each use on the key’s account, so a key whose account lost the role upgrades nothing.UpgradeRecord::api_keynames the key (lastUpgrade.apiKey).
Update available
Section titled “Update available”Code: api/upgrades.rs: app_update.
GET /apps/{app}/update admits whoever GET /apps/{app} admits (principal, within, reaches), a bound session included.
It answers { app, running, available, mayApprove, approvers }:
availableis a deployment instance’s offer (source: deployment, the newest when several) that still serves (offer_serves), where it differs from the running release.- Otherwise it is the newest visible, reachable release (
source: release;report::newer_versions,report::newest_reachable); a bound session sees all of its package’s. availablecarries the classifier’s verdict, over the whole unit when the instance has members. That needs a caller who is a member of its organization or may use every release the members move to (member_targets_readable); otherwise it is over the app alone.mayApproveisapi::upgrade_refusal;approversismanagersuntilFeature::OwnerApprovedUpgrades.
Unit destinations
Section titled “Unit destinations”Code: egress.rs; the classifier is calimero_bundle::update.
egress::release_unitaddsdestinationsandmembersto the capability card (bothnullwhile a member release is not installed here).GET /apps/{app}/egressisegress::instance_unit, open to whoeverGET /apps/{app}admits; each member carries its owndestinations.egress::updategives aClassification:class,reasons, the egress diff (before,after,added,removed),newMethodsandremovedMethods.- The consent sheets add “That includes the apps it created.” only when the instance has members, and the
newDestinationsattention for destinations a member adds. - A single upgrade keeps members where they are; a unit’s moves its direct members as
unit_plandoes.
Update classes and policies
Section titled “Update classes and policies”Code: system/updates.rs, api/update_policies.rs.
The class
Section titled “The class”- The API’s
UpgradeAppcarriesclass(types::UpgradeClass) fromapi::upgrades::move_class;Nonefor a raw bundle, another package or an unreadable release. SystemState::check_classre-derives it, following the unit throughlinksas deep asMAX_UNIT_DEPTH, and refusesUPGRADE_CLASS_MISMATCH. It also refuses more thanMAX_CLASS_REASONSreasons.egress::judged_updateis the one verdict thatapprove_upgrade,api::upgrades::class_of,GET /apps/{app}/updateand the consent page’sapproval_steptake.egress::verdict_jsonrenders unknown facts (egress,stateVersionChanged,newMethods,removedMethods,signerChanged) asnull.api::upgrades::unclassified_gateanswers the409 FEATURE_NOT_ACTIVEbelowFeature::UnclassifiedUpdates; otherwiseclass_oflogs such a move without a class.UpgradeRecord::class,reasonsandapproved_bykeep it.- The consent page’s
upgrade_requestreads the “before” side throughrelease_of_app, which isNoneonce that release is uninstalled;api::upgrades::upgrade_appfalls back toapp.release.
Policies
Section titled “Policies”SetUpgradePolicy(Feature::UpgradePolicies) needsapproves_upgrades; its consent args aresystem::upgrade_policy_args.- It is kept on
Org::upgrade_policyandOrg::app_upgrade_policies;move_appdrops the app’s. types::UpgradePolicy’sholdHoursmust lie inMIN_HOLD_HOURS..=MAX_HOLD_HOURS(BAD_UPGRADE_POLICY);SystemState::upgrade_policy_ofresolves app, org, default.
A second approver
Section titled “A second approver”ApproveUpgrade(consent argssystem::approve_upgrade_args) logs atypes::PendingApprovalinOrg::pending_upgrades, withtargetsfor a unit. It answersONE_APPROVALwithout the policy or for a green class, andAPPROVAL_PENDINGfor another’s live approval of the same move.- A target the approver may not use (
SystemState::release_used) answers409 NOT_INSTALLED, as a missing version, before the passkey. For a deployment instance, anything but its offer that still serves (release_offered_to) is409 OUTSIDE_DEPLOYMENT.ApproveUpgraderefuses both at apply once the logged cluster version bringsFeature::PrivateReleases. SystemState::update_gateis asked byrun_upgradeandupgrade_appbefore the passkey and, throughrun_update_gate, at apply of every non-operatorUpgradeApp.approval_forandapproval_livefind a covering approval, elseSECOND_APPROVAL_REQUIRED;drop_spent_approvalsruns after each upgrade.- A unit is judged once under its instance’s policy:
run_update_gateat apply andapi::unit_gateforupgrade_unitbefore the passkey. The instance’sUpgradeAppcarries the unit’s class (api::upgrades::run_class) over the run’s targets. approval_forlooks at every live approval, so a parent unit’s covering one never hides the instance’s own.StartUpgradeRundropstargetsfrom any run but a__upgrade_unitconsent’s.- Each apply error is a
system::Rejectionof its ownRejectionKind.
Routes
Section titled “Routes”GET|POST /orgs/{org}/upgrade-policyandGET|POST /apps/{app}/upgrade-policy(policy_json).GET /apps/{app}/updateaddspolicy,pendingApprovalsandavailable.approvalsNeeded/approvedBy(api::upgrades::update_view).POST /apps/{app}/upgrade-approvalsanswersapprovalin thependingApprovalsshape (api::upgrades::approval_json).GET /orgs/{org}/updates?after=pagesMAX_UPDATES_PAGEapps.- CLI:
meroctl org upgrade-policy|updates,meroctl instance upgrade-policy|approve-update.
Updates on their own, restore points and undo
Section titled “Updates on their own, restore points and undo”Code: system/updates.rs, node/auto_updates.rs, node/restore_points.rs, api/undo.rs.
The pass
Section titled “The pass”Node::auto_updateruns fromreconcileeveryAUTO_UPDATE_EVERYand takesSystemState::auto_update_candidates(at).- It classifies moves newest first with
move_class, at mostMAX_AUTO_UPDATE_CLASSES_PER_PASS. - It runs each app’s first green move through
api::upgrades::auto_upgrade→run_upgrade(Upgrader::auto,Caller::System, actorsystem::AUTO_UPDATE). - A green move that drops a method is found from the leader’s verdict (
api::upgrades::move_verdict) and waits for a person. - Failures before anything ran are kept in
node::auto_updates::AutoUpdateMemory(at mostMAX_AUTO_UPDATE_MEMORY), with the backoff andNOT_GREEN_KEPT_SECS.
Passes take turns (Node::auto_update_turn), so a test’s pass waits for the timed one.
A pass that loses the system leadership stops before its next upgrade (leads_system).
At apply
Section titled “At apply”UpgradeApp { auto }carries no consent;apps::authorizeadmits it only withsystem::AUTO_UPDATE.SystemState::auto_update_gatejudges it, withSystemState::moves_membersoverrelease_of_useforUpgradeApp { members_stay }(Feature::AutoUpdateMembersStay).- Outside a deployment, the target must be a release the app’s owner may use (
sees_release, once the logged cluster version bringsFeature::PrivateReleases). - An automatic
UpgradeFailedcarriesfrom_release; apply notes nothing when another move won. - Refusal codes are
AUTO_UPDATE_REFUSED,HOLD_NOT_OVERandRESTORE_POINT_REQUIRED;UpgradeRecord::automarks the record. - Every update decision’s time is
types::update_now, whichtesting::shift_update_clockmoves in tests.
Restore points
Section titled “Restore points”run_upgradecallsapi::upgrades::take_restore_point→Node::take_restore_point, here or on a replica throughinternal/restore-point { op: take }.- It writes the group’s
fresh_snapshotwithbackup::write; a move that runs nothing on the group records{}. UpgradeApp { restore_point }setsAppRecord::restore_point; an upgrade without one clears it,RestoreAppclears it, andFinishRestorespends it after an undo.sweep_restore_pointskeeps the named file and those younger thanRESTORE_POINT_GRACE.
UndoUpgrade { app_id, apps }(consent argsSystemState::undo_args) coversundo_setand is judged bymay_undo. A retry while the restore runs is allowed.- It reverts bundle, compute and release and, with a file, moves the app to a new group with
PendingRestore { seed }, asRestoreAppdoes. POST /apps/{app}/undothen has that node seed it (Node::seed_undo→seed_undo_here→seed_restore) in its own task, after a fresh system read shows the undo, and waitsUNDO_WAIT.lostWritesisapi::undo::lost_writesoverNode::group_progress(internal/last-write’sappliedIndex,furthest_progress).restore_point_heregives onlytakenAt.UNDO_RELEASE_GONEis judged byUndoUpgrade { release_installed }(Feature::UndoToInstalledRelease,SystemState::undo_release_installed) or by the logged cluster version.