Skip to content

refactor: clear Konjo DRY, dead-code, and complexity gates - #12

Merged
wesleyscholl merged 1 commit into
mainfrom
claude/konjo-kyro-ffx3n6
Jun 19, 2026
Merged

refactor: clear Konjo DRY, dead-code, and complexity gates#12
wesleyscholl merged 1 commit into
mainfrom
claude/konjo-kyro-ffx3n6

Conversation

@konjoinfinity

Copy link
Copy Markdown
Contributor

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 (shared async stream() bridge + _format_prompt) and _OpenAIChatGenerator. OpenAIGenerator/SquishGenerator now inherit one generate/generate_stream implementation instead of triplicating it.
  • ingest/chunkers.py β€” extracted _EncoderBackedChunker mixin for the lazy-encoder load shared by SemanticSplitter and LateChunker.
  • Route tests β€” added 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)

  • Dropped the unused tracer_name param from cache.tracing.cache_span (get_tracer() takes no name; no caller passed it).
  • Renamed VectorStoreAdapter.upsert param vectors β†’ embeddings to match the concrete QdrantStore.upsert signature.

Complexity (all konjoai/ functions now ≀ 15)

Function Before After
suspicious.scan_for_suspicious 22 14
analytics.compute_analytics 19 12
crag.CRAGEvaluator.run 16 7
cache route _kmeans_cluster 16 A

Verification

  • pytest β€” 1287 passed, 7 skipped
  • Coverage β€” 83.3% (β‰₯80 gate)
  • DRY β€” 0 Β· vulture β€” clean Β· complexity β€” 0 functions >15 Β· ruff check/format β€” clean

Not included

  • Repo-wide ruff format drift (131 files) is driven by a newer ruff than the repo was formatted with and is continue-on-error in CI β€” left out to keep this diff focused; worth a separate version-pin PR.
  • Docstring coverage (interrogate 64% in konjoai/) β€” non-blocking in CI (80, continue-on-error); not addressed here.

πŸ€– Generated with Claude Code


Generated by Claude Code

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
@wesleyscholl
wesleyscholl marked this pull request as ready for review June 19, 2026 17:00
@wesleyscholl
wesleyscholl merged commit 2205c5d into main Jun 19, 2026
7 checks passed
@wesleyscholl
wesleyscholl deleted the claude/konjo-kyro-ffx3n6 branch June 19, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants