Skip to content

yggdrasil.loki.mesh

mesh

Mesh store — shared memory the fleet's process agents coordinate through.

When :class:~yggdrasil.loki.fleet.Fleet runs a swarm it points every agent at a shared workspace and a shared :class:MeshStore (a JSON key-value file). An agent publishes what it produced — a file path, an API it defined, a decision — and its peers read the mesh before doing redundant work, so the swarm reuses results instead of recomputing them. That's the agents talking to each other: shared files + shared memory.

The agent reaches it through the mesh tool (:mod:yggdrasil.loki.tools), which is added to the toolbox whenever the LOKI_MESH env var names the store. Writes are atomic (temp-file replace) under a best-effort cross-process lock, so concurrent agents don't clobber each other.

MeshStore

MeshStore(path: str | Path)

A small JSON key-value store shared across the fleet's agent processes.

all

all() -> dict[str, Any]

Every published entry (the peers' shared state).

put

put(key: str, value: Any) -> Any

Publish value under key for peers to read (read-modify-write).

append

append(key: str, value: Any) -> list

Append value to a list under key — a shared running log.

from_env

from_env() -> 'MeshStore | None'

The mesh store named by LOKI_MESH (set by the fleet on each agent), or None when this process isn't part of a mesh.