SDK · 09

RegistryStore

The RegistryStore is the one optional persistent surface the SDK owns. It is a live view of every Neuron seen on a namespace: capabilities, status, last heartbeat. Anything beyond that - cost histograms, audit history, latency dashboards - is the developer’s to build on top.

abstract basecosmonapse.RegistryStore

The interface every backend must satisfy. Records are NeuronRecord instances keyed by neuron_id.

registry.pyi
class RegistryStore(ABC):
    async def connect(self) -> None: ...
    async def close(self)   -> None: ...
    async def upsert(self, record: NeuronRecord) -> None: ...
    async def mark_deregistered(self, neuron_id: str) -> None: ...
    async def touch_heartbeat(self, neuron_id: str, ts: datetime, status: str | None = None) -> None: ...
    async def get(self, neuron_id: str) -> NeuronRecord | None: ...
    async def list(self, *, capability: str | None = None, include_deregistered: bool = False) -> list[NeuronRecord]: ...

# Backends
MemoryRegistryStore()
SqliteRegistryStore("/var/lib/cosmonapse/registry.db")
PostgresRegistryStore(dsn="postgresql://user:pw@host/cosmonapse")

NeuronRecord

record.pyi
@dataclass
class NeuronRecord:
    neuron_id:      str
    capabilities:   list[str] = []
    version:        str | None = None
    status:         str = "registered"   # registered | draining | deregistered
    last_heartbeat: datetime | None = None
    registered_at:  datetime

    def to_dict(self) -> dict: ...

Bundled backends

ClassUse when
MemoryRegistryStore()Tests, ephemeral orchestrators, anything where losing state on restart is acceptable.
SqliteRegistryStore(path)Single-process production with zero extra dependencies.
PostgresRegistryStore(dsn=…)Multi-process production. asyncpg-backed, lazily imported. Use when more than one Dendrite needs to write to the same store.

Have a feature in mind?

The protocol, SDKs, and CLI are still pre-1.0. If something here is missing, ambiguous, or wrong - open an issue and propose a change. Every breaking change is debated in DECISIONS.md first.