@dxos/echo
    Preparing search index...

    Interface Registry

    Composable, in-memory registry of keyed ECHO entities.

    Entities are stored by id and queried via the standard ECHO Query API. A registry may delegate to an optional upstream registry: results from the local registry take precedence and upstream results fill in anything not found locally.

    Intended use cases include caches of schemas, operations, skills, routines, plugins, etc., sourced from 3rd-party plugins, local code, or local space objects.

    Types (schema-definition entities produced by Type.makeObject / Type.makeRelation) are stored the same way as any other entity — via add(). Use list().filter(Type.isType) to retrieve them.

    Scope: a Registry is independent of any ECHO space or Hypergraph — it is a process-local, in-memory cache. Wire one per space (e.g. as a Layer scoped to the space's Effect runtime) or share a single instance across spaces depending on the use case.

    The concrete implementation (and the makeRegistry / registryLayer factories) lives in @dxos/echo-client; this module declares only the interface so that the @dxos/echo API surface stays free of query-matching dependencies.

    interface Registry {
        "[TypeId]": typeof Registry.TypeId;
        changed: ReadOnlyEvent<void>;
        id: string;
        local: readonly Entity.Unknown[];
        query: QueryFn;
        add(entities: readonly Entity.Unknown[]): void;
        clear(): void;
        get(id: string): undefined | Entity.Unknown;
        getByURI(uri: string): undefined | Entity.Unknown;
        list(): Entity.Unknown[];
        remove(id: string): boolean;
    }
    Index

    Properties

    "[TypeId]": typeof Registry.TypeId
    changed: ReadOnlyEvent<void>

    Fires whenever local registry contents change (add, remove, or clear).

    id: string

    Stable per-instance identifier. Used to key process-local resources (e.g. memoized reactive atoms) to a specific registry instance, analogous to Database.spaceId.

    local: readonly Entity.Unknown[]

    All locally-stored entities. Does not include upstream entities — use list for that.

    O(n); allocates a new array on every read.

    query: QueryFn

    Run an ECHO query against the registry's entities (implements Database.Queryable).

    Matching happens in-memory over list. Scope (from) clauses are unwrapped and ignored — a direct registry query always targets the registry's own entities. The primary way to query registry contents is still through the database (db.query(...).from(Scope.registry())), which fans the database and registry together; this method is for querying a registry directly.

    Only locally-evaluable AST nodes are supported: select, filter, limit, from, options, and boolean combinators, plus full-text filters as case-insensitive all-terms containment. Server-side concerns (order, traversal, vector search, timestamp filters) throw or match nothing.

    O(n · filter size) linear scan of list() on every read; results are not cached between reads.

    Methods

    • Add or replace one or more entities in the local registry. Existing entries with the same id are replaced. Also indexes type entities by DXN for fast lookup.

      Parameters

      Returns void

      O(n) in entities, each indexed by id and URI, then one changed emission.

    • Get an entity by one of its addressing URIs — a type entity by its typename DXN (or, when persisted, its identifier EID), a keyed entity by its dxn:<key>[:<version>]. Accepts legacy DXN forms (normalized internally). Searches the local registry first, then falls back to the upstream registry. Narrow the result with Type.isType when a type entity is required.

      Parameters

      • uri: string

      Returns undefined | Entity.Unknown

      O(1) map lookup after URI normalization, then the same in the upstream on a miss.

    • Remove an entity by id from the local registry.

      Parameters

      • id: string

      Returns boolean

      true if an entity was removed, false if it was not found.

      O(u) in the URI index, which it scans for entries pointing at the entity.