feat(sofiia-console): add runbooks index status endpoint

GET /api/runbooks/status returns docs_root, indexed_files, indexed_chunks, last_indexed_at, fts_available; docs_index_meta table and set on rebuild

Made-with: Cursor
This commit is contained in:
Apple
2026-03-03 04:35:18 -08:00
parent ef3ff80645
commit 63fec4371a
5 changed files with 85 additions and 2 deletions

View File

@@ -93,3 +93,23 @@ def test_runbooks_raw_400_for_invalid_path(sofiia_client):
"""Raw returns 400 for path traversal attempt."""
r = sofiia_client.get("/api/runbooks/raw?path=../../../etc/passwd")
assert r.status_code == 400
def test_runbooks_status_after_rebuild(sofiia_module, tmp_path, tmp_docs_with_rehearsal, monkeypatch):
"""After rebuild, status shows indexed_files > 0, indexed_chunks > 0, last_indexed_at set."""
import app.docs_index as docs_index_mod
import app.docs_store as docs_store_mod
monkeypatch.setenv("SOFIIA_DATA_DIR", str(tmp_path / "sofiia-data"))
loop = asyncio.get_event_loop()
async def run():
await docs_index_mod.rebuild_index(tmp_docs_with_rehearsal)
return await docs_store_mod.get_docs_index_status()
status = loop.run_until_complete(run())
assert status["indexed_files"] >= 1, status
assert status["indexed_chunks"] >= 1, status
assert status.get("last_indexed_at") is not None, status
assert "docs_root" in status
assert "fts_available" in status