Skip to content

fathom.FactStore

fathom.FactStore

Bases: Protocol

Protocol defining the async fact-storage interface.

Source code in src/fathom/fleet.py
@runtime_checkable
class FactStore(Protocol):
    """Protocol defining the async fact-storage interface."""

    async def assert_fact(self, template: str, data: FactData) -> FactId:
        """Assert a fact and return its unique fact_id."""
        ...

    async def query(self, template: str, fact_filter: FactFilter | None = None) -> list[FactData]:
        """Return facts matching the template and optional filter."""
        ...

    async def retract(self, template: str, fact_filter: FactFilter | None = None) -> int:
        """Retract facts matching the template and optional filter. Return count removed."""
        ...

    async def count(self, template: str, fact_filter: FactFilter | None = None) -> int:
        """Count facts matching the template and optional filter."""
        ...

    async def subscribe(
        self,
        template: str,
        callback: Callable[[FactChangeNotification], Coroutine[Any, Any, None]],
    ) -> Callable[[], None]:
        """Subscribe to changes on a template. Return an unsubscribe callable."""
        ...

assert_fact(template, data) async

Assert a fact and return its unique fact_id.

Source code in src/fathom/fleet.py
async def assert_fact(self, template: str, data: FactData) -> FactId:
    """Assert a fact and return its unique fact_id."""
    ...

query(template, fact_filter=None) async

Return facts matching the template and optional filter.

Source code in src/fathom/fleet.py
async def query(self, template: str, fact_filter: FactFilter | None = None) -> list[FactData]:
    """Return facts matching the template and optional filter."""
    ...

retract(template, fact_filter=None) async

Retract facts matching the template and optional filter. Return count removed.

Source code in src/fathom/fleet.py
async def retract(self, template: str, fact_filter: FactFilter | None = None) -> int:
    """Retract facts matching the template and optional filter. Return count removed."""
    ...

count(template, fact_filter=None) async

Count facts matching the template and optional filter.

Source code in src/fathom/fleet.py
async def count(self, template: str, fact_filter: FactFilter | None = None) -> int:
    """Count facts matching the template and optional filter."""
    ...

subscribe(template, callback) async

Subscribe to changes on a template. Return an unsubscribe callable.

Source code in src/fathom/fleet.py
async def subscribe(
    self,
    template: str,
    callback: Callable[[FactChangeNotification], Coroutine[Any, Any, None]],
) -> Callable[[], None]:
    """Subscribe to changes on a template. Return an unsubscribe callable."""
    ...