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 <instance label> · <Host app> · <role>, built to pass check_name: label characters outside the rule are dropped, and a label that still fails is left out.
key_id
C0 key_id: hex(blake3(public key))[..16].
normalize_role
Lowercase; every character outside [a-z0-9-] becomes -; runs collapsed and trimmed; at most 32 characters; empty → general.
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.
workspace_worker_id
Workspace worker id: wkr_ + base32(blake3(instance ‖ “|” ‖ host ‖ “|” ‖ role))[..20], over the canonical instance id.