Skip to content

Features/langfuse tests#7

Merged
GishB merged 5 commits into
mainfrom
features/langfuse-tests
Apr 14, 2026
Merged

Features/langfuse tests#7
GishB merged 5 commits into
mainfrom
features/langfuse-tests

Conversation

@GishB
Copy link
Copy Markdown
Owner

@GishB GishB commented Apr 14, 2026

Summary

Добавлено полное unit-test покрытие для всех интеграций в src/modules/, исправлен production-баг и обновлён README с бейджами.

Changes

  • Unit-тесты (tests/modules/):
    • redis_extRedisAdapter (span wrapping, save/get) + UserRateLimiter (INCR/EXPIRE pipeline) — 24 теста
    • chroma_extChromaAdapter (query/RAG, filtering, reranking) + MyEmbeddingFunction (retry/backoff) + BM25Reranker + data_reader/db_writer52 теста
    • postgres_extPostgresClient (pool lifecycle, double-checked locking, health) — 12 тестов
    • langfuse_extLangfuseClient (init, auth check, startup) — 7 тестов
  • Bug fix: исправлен некорректный f-string в PostgresClient.get_pool_stats, который падал с ValueError при вызове
  • Docs: добавлены статичные бейджи в README (tests 102/102, coverage 79%, Python 3.12)
  • Coverage: coverage.xml перегенерирован по всем 102 тестам

GishB added 4 commits April 15, 2026 01:36
Observability:
- Added current_span ContextVar to track active LangGraph node span.
- Wrapped all agent nodes (base, core, loop) with manual Langfuse spans;
  LLM callbacks are now scoped to the node span via CallbackHandler(stateful_client=span).
- Updated RedisAdapter and ChromaAdapter to nest their spans under current_span
  instead of attaching directly to the root trace.
- Removed global CallbackHandler from /chat router to avoid duplicate spans.

Tests:
- Added tests/service/api/v1/test_router.py covering /test_invoke (success & 424)
  and /chat (success & rate-limit).
- Added tests/agents/profkom_consultant/nodes/test_base.py for
  update_user_history_context (append, trim, 1:1 sync).

Fixes:
- Fixed history trim bug: model_answers now uses [-HISTORY_LIMIT:] instead of
  [-trim_count:], keeping Q&A lists synchronized.

Deps:
- Added pytest, pytest-asyncio, httpx to dev dependencies.
- Added pytest-cov to dev dependencies.
- Generated coverage.xml from current test suite (7 tests, all passing).
Added pytest suites covering:
- redis_ext: RedisAdapter (save/get/spans/health) + UserRateLimiter (incr/remain/reset/ttl/health)
- chroma_ext: ChromaAdapter (init/query/filter/rerank/RAG), MyEmbeddingFunction (retry/batch/call),
  BM25Reranker (fit/rerank), data_reader (chunk/signature/topic), db_writer (sync/orphan cleanup)
- postgres_ext: PostgresClient (pool lifecycle, conn loop, checkpointer, stats, close, health)
- langfuse_ext: LangfuseClient (init, client/handler creation, health_check, on_startup)

Fixes:
- Fixed f-string bug in PostgresClient.get_pool_stats that raised ValueError at runtime.

Coverage:
- Regenerated coverage.xml from full suite (102 tests passing).
@GishB GishB added the enhancement New feature or request label Apr 14, 2026
@GishB GishB merged commit e26f744 into main Apr 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant