Skip to content

QA plan: Eval harness corpus setup — load dataset, seed vectors (#76)

Story: Eval harness corpus setup: load dataset, seed vectors (#76)
Feature: Retrieval-quality eval harness (#75)
Capability: Retrieval & generation API (#11)
Spec: specs/retrieval.md

TypeCoverage
Unitload_corpus.py reads the test split Parquet files at the pinned revision (fetched with huggingface-hub and read with pyarrow, per RAG003) and extracts (question, context, answer) triples
Unit--count limits rows to the specified value; values outside 1–500, or non-integers, raise an argparse usage error
Unit--revision is required and must be a 40-character lowercase commit SHA; a branch name such as main is rejected
UnitThe fetch fails with a clear error when the revision has no test split, when the dataset columns differ from the expected schema, or when the Hub is unreachable
UnitIdempotency: rows are keyed on (dataset_revision, content_hash), where content_hash is the SHA-256 of question and context; a rerun inserts nothing new
UnitBedrock embedding call receives the question text and returns a 1024-dim vector written to the embedding column; wrong-dimension vectors are rejected
UnitA rerun embeds only rows a partial run left without an embedding; --reembed re-embeds every selected row and produces identical vectors
UnitThe run summary reports row count, embedding dimension, dataset revision, the SHA-256 of the fetched Parquet bytes, and the corpus checksum; failures print no secret ARN or traceback
IntegrationAgainst Docker Postgres: --count 10 inserts exactly 10 rows into eval_corpus; all embedding columns are non-null vector(1024)
IntegrationRe-running with --count 10 on an already-seeded table makes zero net row changes
IntegrationEmbed call count matches the number of rows with a null embedding before the run

Note: eval/load_corpus.py is a CI script outside src/rag_sample/. Coverage floors from RAG006 do not apply. Tests validate correctness, determinism, and output format.

  • eval_corpus table migration merged (dataset_revision, content_hash, ordinal, question, context, ground_truth_answer, embedding vector(1024); unique on (dataset_revision, content_hash))
  • FakeEmbeddingProvider and FakeEvalCorpusRepository available in tests/stubs.py
  • Docker Postgres reachable in the local test environment
  • For the QA run: the QA eval CI role rag-sample-qa-eval-role applied through infra/bootstrap, and the qa-eval GitHub environment holding secrets AWS_QA_EVAL_ROLE_ARN and QA_DB_SECRET_ARN and variables QA_DB_CLUSTER_ARN and QA_DB_NAME
  • All unit tests pass
  • Integration: after --count 10, eval_corpus has exactly 10 rows with non-null vector(1024) embeddings
  • Idempotency integration test passes (second run produces zero new rows)
  • --count 0 and --count 501 both exit non-zero with a usage error in stderr; omitting --revision exits non-zero with a usage error
  • The manual-dispatch workflow eval-corpus.yml completes against QA Aurora at the pinned revision 586c0d0ddeb022fccd909c7b415cc2ca8660baa4, exits 0, and logs the row count and checksums

Unit and integration: local with Docker Postgres and FakeEmbeddingProvider. The Hugging Face fetch is replaced by an injected fetch function in loader tests; the fetch tests patch huggingface_hub and read a real Parquet file written to tmp_path. The QA run uses the live dataset, real Bedrock, and the RDS Data API under the eval CI role, assumed through GitHub OIDC from the qa-eval environment.

pytest, unittest.mock for the Hub and Bedrock call sites, pyarrow to write fixture Parquet. Docker Postgres integration fixture.

  • postgres_db fixture: Docker Postgres with migrations applied, eval_corpus emptied before and after each test
  • FakeEmbeddingProvider in tests/stubs.py: returns a 1024-dim vector per question
  • FakeEvalCorpusRepository in tests/stubs.py: in-memory eval_corpus for unit tests
  • In-memory records with question, context, answer keys, wrapped in a FetchedSplit by a stub fetch function
def test_load_is_idempotent_on_rerun() -> None:
# Given an eval table already seeded by one --count 10 run
repo = FakeEvalCorpusRepository()
_load(repo, count=10)
# When the loader runs again with the same revision and count
summary = _load(repo, count=10)
# Then no rows were added and nothing was re-embedded
assert len(repo.rows) == 10
assert summary["embedded_this_run"] == 0
  • The dataset schema (neural-bridge/rag-dataset-12000) could change column names at a new revision. The revision is pinned in eval-corpus.yml, and the loader asserts the expected columns.
  • Seeding 500 rows with live Bedrock adds latency. The --count default is 100; 500 rows fit inside the workflow’s 15-minute timeout.
  • If question text alone is not unique, a question-only key would merge rows. The key hashes question and context together.