Skip to content

Who a run acts as

Every entry in an app’s log records its caller, and every run sees that caller through the host. Because the node runs the call itself, for a caller it authenticated, there is no separate question of who signed a write: the log says who asked, and the leader that ran it is the cluster.

The API builds the caller from the request’s credential; a client cannot name one. An app reads it with env::caller() (crates/sdk/src/env.rs):

Caller When
Account(id) A passkey session.
ApiKey { key_id, account } An API key acting for account.
Public No credential, for a #[app::public] method, where the instance admits a caller without an account (no access grant does).
System The node itself: a timer tick (#[app::every]), a compute run’s result method (#[app::compute_result]), the dead-letter handler onXcallFailed.
App(id) A message or synchronous call from app id (Cross-app calls).

A person has one identity everywhere: an account is the same on every device, so two of one person’s devices are the same caller.

env::org() is the app’s organization, env::org_role(account) an account’s role in it (Guest, Member, Admin, Owner), and env::in_team(account, team) its teams. The node answers from the system group’s state at the entry the run applies on, so every replica agrees. Every app is in an organization (an account’s own apps in its personal organization, which it owns), so env::org() names one for every app a node of this release runs. The guards module still has a branch for an app with none (the owner holds every role, any other account Member), which only a test harness without an organization reaches (Access control).

use calimero_sdk::env::{self, OrgRole};
use calimero_sdk::guards;
// Inside an #[app::logic] method: members write, admins also moderate.
let me = guards::require_member()?; // LoginRequired / Forbidden otherwise
let is_admin = env::org_role(&me) >= Some(OrgRole::Admin);

Timers and result methods run as System and cross-app deliveries as App(source); neither has an account, so guards::require_member() refuses them with LoginRequired. A method that should run this way says so in its ABI: allow(system) (implied by every) or allow(app = ..), and the node refuses every other caller kind for it.