Say what a federated client owns, and trim four comments

The set shares the reranker its facades borrow, not an embedder: each covered
database builds and closes its own. Sharing one needs the lender pattern inside
`Store`, since a store's embedder also serves writes and is closed with the
session, so it is left as follow-up rather than done here.

`reported_location` returned `client.location` and nothing else; its test
asserted that a mock returns what it was given. `list_documents` names its
results through `name_all`.
This commit is contained in:
Yiorgis Gozadinos 2026-08-28 09:11:30 +03:00
parent 249c51c65a
commit bee67e736a
No known key found for this signature in database
6 changed files with 14 additions and 33 deletions

View file

@ -460,7 +460,7 @@ def settings():
from haiku.rag.app import HaikuRAGApp from haiku.rag.app import HaikuRAGApp
config = get_config() config = get_config()
# Neither of these opens a database; the scope is whatever is configured. # Configuration-only; no database scope is resolved.
app = HaikuRAGApp(config=config, read_only=True) app = HaikuRAGApp(config=config, read_only=True)
app.show_settings() app.show_settings()

View file

@ -474,8 +474,9 @@ class HaikuRAG:
await facade._release_own() await facade._release_own()
self._clients.clear() self._clients.clear()
await self._session.aclose() await self._session.aclose()
# The set shares this client's embedder and reranker, so this is the # This client's own: the reranker its facades borrow, and the
# only place they are closed — and only if anything built them. # embedder it builds from configuration for work that names no
# database. Each covered database builds and closes its own.
await self._aclose_cached("embedder") await self._aclose_cached("embedder")
await self._aclose_cached("_own_reranker") await self._aclose_cached("_own_reranker")
self._closed = True self._closed = True

View file

@ -193,12 +193,14 @@ class SingleDatabaseSession:
filter: str | None = None, filter: str | None = None,
include_content: bool = False, include_content: bool = False,
) -> "list[Document]": ) -> "list[Document]":
documents = await self.document_repository.list_all( return self.name_all(
limit=limit, offset=offset, filter=filter, include_content=include_content await self.document_repository.list_all(
limit=limit,
offset=offset,
filter=filter,
include_content=include_content,
)
) )
for document in documents:
document.source = self.source
return documents
async def delete_document(self, document_id: str) -> bool: async def delete_document(self, document_id: str) -> bool:
"""Delete a document, cascading to children linked via """Delete a document, cascading to children linked via

View file

@ -20,8 +20,6 @@ async def database(state: APIState = Depends(get_state)) -> DatabaseInfo:
status_code=status.HTTP_503_SERVICE_UNAVAILABLE, status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
detail="database not configured", detail="database not configured",
) )
# The one database the ingester writes: a configured set is refused when the
# client opens, before this app is built.
[ref] = state.scope.databases [ref] = state.scope.databases
one, db_path = ref.connection(state.config) one, db_path = ref.connection(state.config)
return await gather_database_info(one, db_path or default_db_path(one)) return await gather_database_info(one, db_path or default_db_path(one))

View file

@ -1,5 +1,4 @@
import asyncio import asyncio
from pathlib import Path
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from textual.app import ComposeResult from textual.app import ComposeResult
@ -14,15 +13,6 @@ if TYPE_CHECKING:
from haiku.rag.client import HaikuRAG from haiku.rag.client import HaikuRAG
def reported_location(client: "HaikuRAG") -> "Path | str | None":
"""Where the database to report on is, or None where a set is covered.
What the client ended up covering is what says which of the two it is: a
client given one named database opens it rather than covering a set.
"""
return client.location
async def database_lines(client: "HaikuRAG") -> list[str]: async def database_lines(client: "HaikuRAG") -> list[str]:
"""What one database reports about itself, without naming its location. """What one database reports about itself, without naming its location.
@ -172,12 +162,10 @@ class InfoModal(ModalScreen):
"""Load and display database info.""" """Load and display database info."""
lines: list[str] = [] lines: list[str] = []
location = reported_location(self.client) location = self.client.location
if location is None: if location is None:
# Covering a set: report each database under its configured name, and # Report each database independently so one failure does not hide
# each on its own, so one that cannot be opened costs its own block # the rest. Names only: a location belongs in the configuration.
# rather than the whole panel. Names only, no paths — a location
# belongs in the configuration.
blocks = await asyncio.gather( blocks = await asyncio.gather(
*(self._report(name) for name in sorted(self.client.source_names)) *(self._report(name) for name in sorted(self.client.source_names))
) )

View file

@ -352,14 +352,6 @@ class TestReportedLocation:
source="alpha", source="alpha",
) )
def test_a_covered_set_reports_no_location(self):
from haiku.rag.inspector.widgets.info_modal import reported_location
client = MagicMock()
client.location = None
assert reported_location(client) is None
def test_a_named_remote_database_reports_its_uri(self): def test_a_named_remote_database_reports_its_uri(self):
session = self._session("s3://bucket/alpha.lancedb") session = self._session("s3://bucket/alpha.lancedb")