Skip to main content

Module m4a_attach

Module m4a_attach 

Source
Expand description

POST /m4a/attach: on-demand m4a account for a provider session the node did not spawn (spec live-session-m4a-attach).

Caller: m4a-agent mcp running inside that provider session. Checks, all required:

  1. owner: the ops listener’s owner-only control token (a file only the node’s OS user can read) – checked by the router before this module runs;
  2. policy: HATCHERY_M4A_ATTACH=auto (default off: nothing is adopted) and the provider in HATCHERY_M4A_ATTACH_PROVIDERS (default: all built-in providers);
  3. process: the given pid is alive and descends (within a few generations) from a live process of that provider. Then the node provisions a per-session account (own registry entry, own store root and key) keyed by the provider session id (or the provider’s pid when none is known) and returns nick, session id and a fresh capability. The capability is returned once, never logged.

Structs§

Proc

Constants§

POLICY_ENV
PROVIDERS_ENV

Functions§

handle
Handles the request; table is the current process table (injected for tests).
pick_adopted
The adopted session an attach belongs to: the session it names, else the one on the provider’s command line when that one is adopted, else the only adopted session. Several adopted sessions and nothing to tell them apart is an error, never a new account.
policy_allows
process_table
The live process table.
provider_ancestor
Walks from pid up the parent chain; returns the nearest process whose image is the provider.
provider_images
Process image base names that count as provider.
query_get
valid_session