Skip to content

Deepen architecture: dead-code removal, eval judge rewire, vector-store seam fix - #17

Merged
elkaix merged 4 commits into
mainfrom
spec/rag-architecture-deepening-1
Jul 12, 2026
Merged

elkaix merged 4 commits into
mainfrom
spec/rag-architecture-deepening-1

Conversation

@elkaix

@elkaix elkaix commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Deletes ResponseGenerator, utils.py, and observability.traced_stage — all verified zero-caller (repo-wide grep, not just the flagging review).
  • Rewires EvalRunner to call src.evaluation's judges directly instead of through three deleted reshape-only wrapper functions in eval/metrics/generation.py; hoists the duplicated JSON-fence-stripping parser into evaluation.parse_json_response.
  • Adds ChromaVectorStore.get_by_doc_id() and rewires RAGBackend.get_document_chunks to use it, closing the one place backend reached into vector_store's private ChromaDB collection directly.

Implements sequencing step 1 (of 6) of #16.

Test plan

  • Full suite: 279 passed
  • New tests added for get_by_doc_id (vector-store + backend level) and for _score_question's judge-metric wiring (previously untested directly)
  • Code review (standards + spec axes) run; findings addressed in the last commit

elkaix added 4 commits July 12, 2026 11:32
ResponseGenerator, the utils.py helpers, and the traced_stage decorator
all had zero production callers (verified by repo-wide grep, not just
the review that flagged them). traced_stage's helpers (_coerce_attr,
_OTEL_SCALARS) and its dedicated tests go with it; the one call site
that referenced it in a comment (backend.py) is updated to describe the
inline-span pattern actually in use.

Resolves part of spec #16 sequencing step 1.
judge_faithfulness/judge_answer_relevancy/judge_context_precision in
eval.metrics.generation were pure reshape wrappers around
src.evaluation's judges — runner._score_question was their only
caller. Deleting them concentrates the reshape at that one call site
instead of leaving it as an indirection with nothing behind it.

Also hoists the markdown-fence-stripping JSON parser (previously
duplicated between evaluation.py and generation.py's factual-match
judge) into evaluation.parse_json_response, the shared implementation.

Adds direct coverage of _score_question's judge-metric wiring
(previously only exercised indirectly via the runner's end-to-end
test), guarding this rewire and any future one.

Resolves part of spec #16 sequencing step 1.
…leak

RAGBackend.get_document_chunks reached into
self.vector_store._collection directly and parsed ChromaDB's raw batch
response — the one place backend crossed the vector store's seam
instead of going through its public interface.

get_by_doc_id returns plain dicts (chunk_id, content, metadata) rather
than SearchResult: this is a metadata filter, not a similarity search,
so there's no meaningful score to attach, and forcing one onto
SearchResult would misrepresent what the result is.

Adds direct backend-level coverage of get_document_chunks, which had
none before this change.

Resolves the remainder of spec #16 sequencing step 1.
- Architecture.md's generation.py row still described the deleted
  wrapper functions; correct it to describe the direct-call path.
- _score_question duplicated the (reasoning, details_json) -> dict
  reshape for faithfulness and context_precision; extract _judge_details
  as the single reshape used by both (answer_relevancy's 2-tuple return
  doesn't fit the same shape, so it stays inline).
- Tighten the judge-metrics test: the previous assertion vacuously
  passed for answer_correctness instead of checking its value.
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.

1 participant