Prometheus Entity Management API
    Preparing search index...

    Every sync provider MUST implement this interface.

    Lifecycle:

    1. start(entityTypes, onPeerChange) — connect and begin syncing the given entity types. Subscribe to remote changes and call onPeerChange whenever peers update entities.
    2. pushLocalChange(type, id, fields) — called by the graph bridge whenever the local graph upserts an entity that belongs to this provider. Providers push the delta to connected peers.
    3. stop() — disconnect and clean up all resources.

    Optional extras:

    • getDoc(type, id) — providers that expose raw CRDT documents (e.g. Yjs) may implement this for advanced consumers.
    interface SyncProvider {
        getDoc?: (type: string, id: string) => unknown;
        name: string;
        pushLocalChange(
            type: string,
            id: string,
            fields: Record<string, unknown>,
        ): void;
        start(
            entityTypes: readonly string[],
            onPeerChange: PeerChangeHandler,
        ): Promise<void>;
        stop(): void;
    }
    Index
    getDoc?: (type: string, id: string) => unknown

    Optional: expose the raw CRDT document for a specific entity. Yjs provider returns the Y.Doc; Loro returns the LoroDoc. Return type is unknown to avoid forcing consumers to import the CRDT lib.

    name: string

    Human-readable name used in devtools and error messages.

    • Push a local graph write to connected peers. Called by the bridge after upsertEntity / replaceEntity fires for a managed entity type.

      Providers MUST be idempotent: they receive the same entity data they already wrote to the CRDT (the bridge does not diff), so a set() call on an already-set key is safe.

      Parameters

      • type: string

        Entity type.

      • id: string

        Entity id.

      • fields: Record<string, unknown>

        Current canonical fields from the graph (full snapshot or partial — see provider docs).

      Returns void

    • Connect to the sync fabric and start receiving peer changes for the listed entity types.

      Parameters

      • entityTypes: readonly string[]

        The set of entity type strings this provider is responsible for (as registered with registerSyncProvider).

      • onPeerChange: PeerChangeHandler

        Callback the provider MUST invoke when peers send updates. May be batched; the bridge handles debouncing.

      Returns Promise<void>

    • Tear down all network connections, subscriptions, and internal state. After stop() the provider MUST NOT call onPeerChange again.

      Returns void