Gate ingester control-plane access logs to DEBUG

This commit is contained in:
Yiorgis Gozadinos 2026-06-09 12:46:17 +03:00
parent 4c186b01c7
commit 54524a4ea3
No known key found for this signature in database
3 changed files with 30 additions and 0 deletions

View file

@ -6,6 +6,10 @@
- Ingester control plane gains `GET /database` (LanceDB snapshot: stored version, embeddings, per-table counts/sizes, vector index, pending migrations, package versions — the data `haiku-rag info` prints) and `GET /config` (full effective config as YAML, secrets redacted). The dashboard surfaces both as on-demand collapsible Database and Configuration panels.
- `HaikuRAG.import_documents(imports)` batch-imports prepared documents (`DocumentImport`), writing the `documents`, `chunks`, and `document_items` tables once each regardless of batch size. `DocumentRepository.create` accepts `Document | list[Document]`.
### Changed
- Ingester control-plane per-request access logs are emitted only when the `haiku.rag` logger is at DEBUG.
### Fixed
- Ingester worker circuit breaker is now per-source: a streak of transient failures pauses claims only for the affected source's jobs while healthy sources keep flowing, instead of pausing the whole worker pool. Paused sources are excluded at the claim query.

View file

@ -21,6 +21,13 @@ if TYPE_CHECKING:
logger = logging.getLogger(__name__)
def _api_access_log_enabled() -> bool:
"""Per-request access logging only when the haiku.rag logger is at DEBUG.
The dashboard polls the control plane every few seconds, so at the normal
INFO level the access log is pure noise."""
return logging.getLogger("haiku.rag").isEnabledFor(logging.DEBUG)
class BatchReport(BaseModel):
"""Outcome of a one-shot batch run: terminal job counts after the queue
drained, plus any sources whose discovery sweep did not complete."""
@ -254,6 +261,7 @@ class IngesterApp:
host=ingester_cfg.api.host,
port=ingester_cfg.api.port,
log_level="info",
access_log=_api_access_log_enabled(),
lifespan="off",
)
server = uvicorn.Server(config)

View file

@ -635,6 +635,24 @@ async def test_dashboard_served_unauthenticated(state):
assert "opBadge" in body
def test_api_access_log_gated_on_debug():
"""uvicorn per-request access logging is off at the ingester's normal INFO
level (the dashboard polls every few seconds) and on at DEBUG."""
import logging
from haiku.rag.ingester.app import _api_access_log_enabled
haiku_logger = logging.getLogger("haiku.rag")
original = haiku_logger.level
try:
haiku_logger.setLevel(logging.INFO)
assert _api_access_log_enabled() is False
haiku_logger.setLevel(logging.DEBUG)
assert _api_access_log_enabled() is True
finally:
haiku_logger.setLevel(original)
@pytest.mark.asyncio
async def test_dashboard_wires_database_and_config_panels(state):
"""The on-demand Database and Configuration panels are present and call