Skip to content

RouterStore

The port that keeps the installation's routers: immutable versions, each a branch per type, a default branch and a recognizer.

Port: RouterStore, declared in indx_interfaces.protocols over the models in indx_interfaces.routers (ADR-0078).

A Router is a key, a version number and a RouterSpec: a label, one Branch per document type, a default Branch, and optionally a Recognizer (a classifier, the facet it answers and a threshold). A branch names a reader to pin, chunkers, lanes per unit and embedding spaces. The store keeps every version of every router.

class RouterStore(Protocol):
def put(self, owner: OwnerId, router: Router) -> None: ...
def get(self, owner: OwnerId, router_id: RouterId, version: int) -> Router | None: ...
def versions(self, owner: OwnerId, router_id: RouterId) -> tuple[Router, ...]: ...
def list(self, owner: OwnerId) -> tuple[Router, ...]: ...
def delete(self, owner: OwnerId, router_id: RouterId) -> bool: ...

A sixth store port, because the ports split by aggregate. A version never changes after it is written, so a plan that named one can always be read back; publishing and restoring both write the next version. A router is never an entry point and never moves the snapshot hash (ADR-0074). Three backends ship: memory, sqlite and postgres, named by INDX_ROUTER_STORE.

  • Owner. Every method takes an OwnerId first, and nothing crosses owners.
  • Identity. Within an owner, a version is its key and number. The server writes the next number; put of a key and number already there replaces nothing new, since the server never writes one twice.
  • Order. versions returns one router’s versions oldest first. list returns the latest version of each router, by key.
  • Idempotence. delete drops every version of a router; one that is not there is False.
  • Validation. The model refuses a branch listed twice for one type. The server, not the store, checks that each type exists and each ID is installed.

tests/unit/test_store_conformance.py holds every installed backend to these rules.