Skip to main content

Module register

Module register 

Source
Expand description

Worker registration and the instance card on Cloud (C0 2.0 §3.17.1, §3.18.1): E10 POST /v1/workers and E44 PATCH /v1/instances/{id}/card are signed by the instance key as domain ‖ canonical_json(body); E11 PATCH /v1/workers/{wkr} rides on the instance token alone.

Structs§

Account
CardState
InstanceCard
E44 response.
PresenceKey
The bound presence key, as E44 returns it.
RegisteredWorker
E10 response: the worker as Cloud stored it.
Registration
Who is registered: the workspace worker, or its alias in one public vault or swarm (place_ref = "{kind}:{id}").

Enums§

ConsentChannel
Consent channel the engine reports; the server derives the real one from the bound presence key and a card can only downgrade it.

Constants§

IDLE_RETIRE
How long a worker no session used stays before the sync retires it (lean-ctx cloud worker retire --idle defaults to the same).
INSTANCE_CARD_DOMAIN
SESSION_IDLE_RETIRE
How long the worker of an ended app session stays (its role is never attached again once the session is gone).
WORKER_DOMAIN

Functions§

announce_instance
E44 for the enrolled instance, at cloud connect and engine start. The engine reports os_presence only with a bound presence key (§3.8.4); the server derives the real channel.
ensure_registered
Register the worker a session attached to, once (E10 on the first event or bus post, SPEC-ENGINE §3.6), and remember it in the book. An already registered worker costs no request. Workers the book gave up are retired on Cloud first; one that cannot be retired now (offline, a Cloud without the route) is recorded and tried again next time, and the registration goes ahead (Cloud may still have room).
instance_card_body
The signed E44 body. clear_presence_key sends presence_key: null, which drops the bound key (e.g. after the helper was removed); a card can never set or replace one.
on_session_end
When an agent session ends: give up the workers of app sessions that no active session holds and none attached in the last SESSION_END_GRACE (a session still starting up). No request; Cloud hears of them with the next sync or registration (retire_evicted). A worker the ending session still holds goes with the sync’s sweep.
patch
E11: rename and/or a new card.
register
E10.
register_body
The signed E10 body. The name passes the local rule first (invalid_name, SPEC-ENGINE §3.6).
retire
Retire one worker of this instance on Cloud (C0 2.2 DELETE /v1/workers/{id}): it no longer counts against the 32-worker cap. Done as well when Cloud says it does not know the worker (404 not_found) or that another instance owns it (409 worker_not_owned): nothing of this instance is left to free. A 404 without that code (a Cloud that has no such route) is not done: the worker still counts there.
retire_evicted
Retire on Cloud the workers the book gave up for new ones (see attach::attach), so a registration is not refused with worker_cap_reached. Every queued worker is tried; one Cloud could not retire now stays queued, and the first such error is returned.
send_instance_card
E44.
sweep
The sync’s sweep (owner 09.11.: workers that are not active do not count): give up the workers idle for IDLE_RETIRE and those of ended app sessions idle for SESSION_IDLE_RETIRE, then retire on Cloud every worker queued so far. The ids given up now.