refactor: clear Konjo DRY, dead-code, and complexity gates - #12
Merged
Conversation
Quality sweep across the konjoai package and route tests: DRY (67 β 0): - generator.py: extract _BaseGenerator (shared async stream bridge + prompt formatting) and _OpenAIChatGenerator; OpenAI/Squish now inherit one generate/generate_stream implementation instead of triplicating it - chunkers.py: extract _EncoderBackedChunker mixin for the lazy-encoder load shared by SemanticSplitter and LateChunker - route tests: add tests/unit/_route_harness.py (SettingsStub, GeneratorStub, make_app, clear_proxy_env, default result fixtures) and point the crag/self-rag/decomposition/timeout route tests at it Dead code (vulture): - drop unused tracer_name param from cache.tracing.cache_span - rename adapters.base VectorStoreAdapter.upsert param vectors β embeddings to match the concrete QdrantStore signature Complexity (all konjoai functions now β€ 15, CLAUDE.md limit): - suspicious.scan_for_suspicious 22 β 14 (extract finding builders) - analytics.compute_analytics 19 β 12 (extract histogram + hourly helpers) - crag.CRAGEvaluator.run 16 β 7 (partition + result builders) - cache route _kmeans_cluster 16 β A (split seed/Lloyd/summarise) No behavior change: 1287 passed, 7 skipped; coverage 83.3%. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016qhBs76YizHXGRK2yRu6VA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A full Konjo quality check surfaced three failing gates on
mainβ DRY (merge-blocking, 67 violations), complexity (4 functions over CLAUDE.md's β€15 limit), and dead code. This PR clears all three with behavior-preserving refactors. No production logic changed.DRY (67 β 0)
generate/generator.pyβ extracted_BaseGenerator(sharedasync stream()bridge +_format_prompt) and_OpenAIChatGenerator.OpenAIGenerator/SquishGeneratornow inherit onegenerate/generate_streamimplementation instead of triplicating it.ingest/chunkers.pyβ extracted_EncoderBackedChunkermixin for the lazy-encoder load shared bySemanticSplitterandLateChunker.tests/unit/_route_harness.py(SettingsStub,GeneratorStub,make_app,clear_proxy_env, default result fixtures); the crag / self-rag / decomposition / timeout route tests now import it instead of redefining the same scaffolding.Dead code (vulture)
tracer_nameparam fromcache.tracing.cache_span(get_tracer()takes no name; no caller passed it).VectorStoreAdapter.upsertparamvectorsβembeddingsto match the concreteQdrantStore.upsertsignature.Complexity (all
konjoai/functions now β€ 15)suspicious.scan_for_suspiciousanalytics.compute_analyticscrag.CRAGEvaluator.run_kmeans_clusterVerification
pytestβ 1287 passed, 7 skippedNot included
ruff formatdrift (131 files) is driven by a newer ruff than the repo was formatted with and iscontinue-on-errorin CI β left out to keep this diff focused; worth a separate version-pin PR.interrogate64% inkonjoai/) β non-blocking in CI (80, continue-on-error); not addressed here.π€ Generated with Claude Code
Generated by Claude Code