Skip to main content

Module workers

Module workers 

Source
Expand description

Durable workers (SPEC-ENGINE §3.6, C0 2.0 section 2): the identity an agent has on Cloud instead of its process id.

  • Workspace places see wkr_ ids derived from the instance UUID, host app and role, which the server recomputes.
  • Public vaults and swarms see place-scoped aliases keyed by the worker_alias_key, derived in memory from the instance signing seed and never written or sent, so co-members who know the instance UUID can neither reproduce an alias nor link two places.

Modules§

attach
Which worker a session belongs to (SPEC-ENGINE §3.6): host app detection, role normalisation, the 32-worker cap and the local book of durable workers. Sessions (mcp-<pid>-<uuid>) are only a detail of the worker they attach to.
card
The capability card a worker presents (C0 2.0 worker.schema.json $defs/card; SPEC-ENGINE §3.6). history is server-computed and never sent.
keys
Worker keys of a place (E8 GET /v1/places/{p}/worker-keys?since=, C0 2.0 §3.17.2): the instance and alias keys that sign class-W events, cached per place so the replica verifies offline.
register
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.
roster
ctx_agent list as workers (SPEC-ENGINE §3.6, V5.3): active sessions are grouped by the worker they attach to; process ids are no longer shown as agents, sessions only as a detail line.

Structs§

WorkerAliasKey
The secret that keys place-scoped worker aliases and hlc.node.

Enums§

NameRefusal
Why a worker name is refused (C0 2.0 name vectors), checked in this order.

Constants§

GENERAL_ROLE
Role used when none is given or nothing survives normalisation.

Functions§

alias_hlc_node
hlc.node of this instance’s events in a public vault or swarm.
alias_signing_key
Ed25519 key that signs this instance’s events in a public vault or swarm (RESOLUTIONS R38). place_ref is "{kind}:{id}".
canonical_instance_id
The instance id as the server hashes it: the dashed lowercase UUID. A 1.x enrolment stores inst_<32 hex>; the same id in another spelling would give another worker id (E10 worker_not_owned, dogfood 25.10.).
check_name
The C0 2.0 worker-name rule, applied before a name leaves the engine. Returns the NFKC form that is sent.
default_name
Default name <computer> · <Host app> · <role>, built to pass check_name (rc4-39):
display_role
The role as a worker name shows it: a per-session worker’s role (<role>-s<tag>, session_role) without its session tag, which is an internal id; any other role as it is (dev-storybook stays).
is_format_char
A Unicode format character (general category Cf: bidi controls, zero-width spaces and joiners, the BOM): invisible, and able to reorder what a terminal or page shows, so never part of a label or a name.
key_id
C0 key_id: hex(blake3(public key))[..16].
live_keys_for_names
The (host_app, role) keys of the active local sessions that worker names count (worker_default_name). An agent registry that cannot be read is logged and names as if no sibling were live (bd 5!678: never swallowed silently).
normalize_role
Lowercase; every character outside [a-z0-9-] becomes -; runs collapsed and trimmed; at most 32 characters; empty → general.
reattach_name
The name worker must (re)register with, or None to keep the one it has. A worker without a name gets its default (worker_default_name). A worker that comes back with a default name a live sibling holds (a resumed session 1 while session 3 took the plain backend during its absence, bd 5!678) yields and takes the next free ordinal. Of two live workers with one name, the later registration keeps it: it claimed the name while the earlier one was gone. A name the person chose (not one of this worker’s default names) is never changed.
session_role
The role a session’s worker is registered under. Without an app session it is the normalised role, so every session of that role on this instance shares one worker. With an app session (LEAN_CTX_SESSION_ID, recorded as the presence’s app_session_id) it is <role>-s<tag>, where tag is base32(blake3(domain ‖ session))[..8] and the role is cut so the whole fits the 32-character role limit. Each session then gets its own durable worker (wkr_ id), stable for the life of that app session. Cloud recomputes the id from the role as sent, so this needs nothing new on Cloud, and Cloud’s self_verify check (worker id of the verdict == worker id of the result) then tells a worker session apart from a separate reviewer session on the same host.
shown_names
The names cloud worker list shows for workers, one per worker in order: the name Cloud accepted, else the default over the live siblings.
worker_default_name
The default name of worker, one of this instance’s workers in book: default_name over its host app and its role as people read them. Two workers that would read the same (two sessions of one role on one instance, rc4-39 review) are told apart by an ordinal on the role (backend, backend 2, …): names Cloud already accepted are taken, and the rest are named in book order, so the first keeps the plain name and a single worker never gets a number. Only siblings an active session holds (live, (host_app, role) keys) count: an ended or crashed session never pushes a new one to backend 2 (bd 5!678).
workspace_worker_id
Workspace worker id: wkr_ + base32(blake3(instance ‖ “|” ‖ host ‖ “|” ‖ role))[..20], over the canonical instance id.