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
Test scope
Section titled “Test scope”| Type | Coverage |
|---|---|
| Unit | load_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 |
| Unit | The 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 |
| Unit | Idempotency: rows are keyed on (dataset_revision, content_hash), where content_hash is the SHA-256 of question and context; a rerun inserts nothing new |
| Unit | Bedrock embedding call receives the question text and returns a 1024-dim vector written to the embedding column; wrong-dimension vectors are rejected |
| Unit | A rerun embeds only rows a partial run left without an embedding; --reembed re-embeds every selected row and produces identical vectors |
| Unit | The 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 |
| Integration | Against Docker Postgres: --count 10 inserts exactly 10 rows into eval_corpus; all embedding columns are non-null vector(1024) |
| Integration | Re-running with --count 10 on an already-seeded table makes zero net row changes |
| Integration | Embed 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.
Entry criteria
Section titled “Entry criteria”eval_corpustable migration merged (dataset_revision,content_hash,ordinal,question,context,ground_truth_answer,embedding vector(1024); unique on(dataset_revision, content_hash))FakeEmbeddingProviderandFakeEvalCorpusRepositoryavailable intests/stubs.py- Docker Postgres reachable in the local test environment
- For the QA run: the QA eval CI role
rag-sample-qa-eval-roleapplied throughinfra/bootstrap, and theqa-evalGitHub environment holding secretsAWS_QA_EVAL_ROLE_ARNandQA_DB_SECRET_ARNand variablesQA_DB_CLUSTER_ARNandQA_DB_NAME
Exit criteria
Section titled “Exit criteria”- All unit tests pass
- Integration: after
--count 10,eval_corpushas exactly 10 rows with non-nullvector(1024)embeddings - Idempotency integration test passes (second run produces zero new rows)
--count 0and--count 501both exit non-zero with a usage error in stderr; omitting--revisionexits non-zero with a usage error- The manual-dispatch workflow
eval-corpus.ymlcompletes against QA Aurora at the pinned revision586c0d0ddeb022fccd909c7b415cc2ca8660baa4, exits 0, and logs the row count and checksums
Environments
Section titled “Environments”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.
Tooling
Section titled “Tooling”pytest, unittest.mock for the Hub and Bedrock call sites, pyarrow to write fixture Parquet. Docker Postgres integration fixture.
Fixtures and data
Section titled “Fixtures and data”postgres_dbfixture: Docker Postgres with migrations applied,eval_corpusemptied before and after each testFakeEmbeddingProviderintests/stubs.py: returns a 1024-dim vector per questionFakeEvalCorpusRepositoryintests/stubs.py: in-memoryeval_corpusfor unit tests- In-memory records with
question,context,answerkeys, wrapped in aFetchedSplitby a stub fetch function
How tests are written
Section titled “How tests are written”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 ineval-corpus.yml, and the loader asserts the expected columns. - Seeding 500 rows with live Bedrock adds latency. The
--countdefault is 100; 500 rows fit inside the workflow’s 15-minute timeout. - If
questiontext alone is not unique, a question-only key would merge rows. The key hashes question and context together.
© 2026 Benjamin Arunski