Runtime events forwarder
Everything a person would want to hear about on a runtime (Allternit Desktop or a cloud computer running allternit-api) is written to a ledger first. The forwarder sends the rows that matter to the cloud event backbone, which fans them out to push, Platform API webhooks and MCP Events subscribers.Ledgers
One classification
events_feed::classify decides what a ledger row means. The notification feed and the forwarder both use it, so Desktop notifications and cloud events can’t disagree. Rows it doesn’t match are ignored by both.
usage.threshold is emitted by the cloud, not by runtimes.
Delivery
- The signature is the runtime relay scheme: HMAC-SHA256 keyed with
sha256(device_token)over<ts>.POST./api/v1/runtime/events.<sha256(body)>(relay_auth::signed_headers). - The cloud finds the device key by
x-allternit-runtime-id(runtimeIdin the runtime identity file, orALLTERNIT_RUNTIME_ID). The device token itself is never sent. Without a runtime id the forwarder sends nothing. - The cloud answers
200with one result per event (accepted,duplicate,ignored,too_largeorinvalid). Any 2xx moves the cursor past the whole batch.401,5xxor no answer leaves it where it was. - Only the paired owner’s rows are sent. Rows on incognito threads never leave the runtime. A runtime that isn’t paired sends nothing.
datais an allowlist of payload fields (ids, provider, decision,textcut to 240 characters, bot and thread names). Other payload fields stay on the runtime.- Every event from a bot ledger also carries
botId,threadId(when it has one) andbotAvatar(anhttps://URL only) indata, next to the top-levelbot_idandthread_id. - Batches hold up to 100 ledger rows per source. A pass runs every 5 seconds, sooner while a backlog drains.
Approval fields
Anapproval.requested whose inbox item is still open when the forwarder reads it also carries:
When
approveInline is true, text is the whole text (300 characters or fewer) instead of the 240-character preview.
One event per approval:
- Gateway approvals and held channel posts are written to the bot ledger by
gateway_runner::create_approval. - An email held for the owner’s OK is written by
inbox_needs::record_email_draft. - A Factory approval is written to its bot’s ledger, or to the owner ledger when it has no bot.
- A coding-session permission ask is written to the owner ledger by
v1_routes::record_gizzi_permission_ask. It is idempotent per request id.
approvalId, so the event id is rt:approval:<approvalId>:requested.
Status snapshot
status.snapshot is the runtime’s current state for the phone’s Live Activity, widget and badge. It does not come from a ledger: status_snapshot.rs builds it every 5 seconds and posts it on its own to the same route with the same signature, only when it changed and at most once per 5 seconds. Each send has a new id (rt:snap:<unix ms>). The cloud keeps the latest one per runtime and never shows it as an alert. A cloud that doesn’t know the type answers 4xx, and the runtime waits 10 minutes before it tries again. The ledger forwarder is not affected.
- Bot status is one of
waiting_approval,needs_input,blocked,failed,workingoridle, from the bot’s pending approvals and its threads. Blocked and failed threads count for 24 hours. - Focus is the bot with the oldest pending approval. If there is none, it is the bot that has waited longest for input. Next comes the most recent blocked or failed bot, then the most recently active working bot. With none of these,
focusisnull. focus.privateandneedsYouRows[].privateare true when the item is addressed to another person. Show a generic line in a plain push.- Limits:
botsholds up to 20,needsYouRowsup to 4, andlineup to 80 characters.questionis up to 140.needsYoulists every open inbox id, so the cloud can remove notifications for items that left it.progressis not sent yet.pausedis alwaysfalsefor now. - Loops come from gizzi-code’s
GET /v1/automations/loopson loopback, polled every 5 seconds while a loop runs and every 60 seconds otherwise. Only running and paused loops are listed (up to 5). When a poll fails,loopsis left out, so a gizzi restart does not end a loop’s Live Activity. The request uses Basic auth fromGIZZI_PASSWORDwhen the gizzi server has a password. lastRoutineis the newestroutine.completedorroutine.failedon the owner’s bots.atis in Unix seconds.
Exactly once (in effect)
- Deterministic ids.
rt:be:<bot_events.id>orrt:ue:<runtime_user_events.id>. Approvals usert:approval:<approvalId>:requested/:resolved, so the same approval written to two stores is one event. - Cursor after success.
cloud_event_cursors(V236) keeps the last forwarded row per cloud account and source. It moves only after the cloud answers 2xx. A failed post or a crash resends the same batch, and the cloud drops ids it has already seen. - Backoff. Failures retry after 10 s, doubling up to 5 minutes. The last error is kept in
cloud_event_cursors.last_error. - No replay on pairing. A new cursor starts at the end of the ledger, so pairing a runtime doesn’t send its history.
Subscriptions logins
The subscription gateway doesn’t push events. allternit-api’s subscription sync pulls it every minute (and right after a sign-in in Settings) for every owner with a bound Sessions computer, a linked Agent Gateway account, or a local gateway:GET v1/accounts: each login’ssession_healthis compared with the last value seen (subscription_login_health, V236). A change toauth_requiredorchallenge_presentedrecordssubscription.login_needed. A change from one of those back toreadyrecordssubscription.signed_in, as does a new login that is already ready. An outage and its recovery record nothing.GET v1/tasks?status=needs_user: each task updated in the last 24 hours is recorded once assubscription.task.needs_user. The prompt is not copied.
runtime_user_events and reach the cloud through the forwarder like every other event. Clients that showed login state by polling session_health can subscribe to these events instead.