Make the first RAG slice executable without risking production data
Some checks failed
verify / verify (push) Has been cancelled
Some checks failed
verify / verify (push) Has been cancelled
The Stage 1 foundation now proves provider contracts with mocks and validates PostgreSQL/pgvector ingestion, approval binding, retrieval, reranking, and idempotency using only synthetic data. Live Bailian validation remains gated on rotating the exposed key. Constraint: The key shown in chat is compromised and cannot be used or committed Rejected: Mark Stage 1 complete from mock and offline results | real three-model smoke is still required Confidence: high Scope-risk: moderate Reversibility: clean Directive: Do not enable real-data ingestion until Stage 3 cloud approval and outbound manifest controls are enforced end to end Tested: make verify; 41 pytest tests; strict mypy; Ruff; Compose config; pinned image build; empty-volume migration; role denial; two idempotent 20-vector seeds; database restart persistence Not-tested: Live Bailian calls require a newly rotated key; React product UI is not implemented
This commit is contained in:
37
backend/tests/unit/test_demo_data.py
Normal file
37
backend/tests/unit/test_demo_data.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[3]
|
||||
SAMPLE_ROOT = PROJECT_ROOT / "data" / "samples" / "public"
|
||||
|
||||
|
||||
def load_jsonl(path: Path) -> list[dict[str, Any]]:
|
||||
return [json.loads(line) for line in path.read_text(encoding="utf-8").splitlines()]
|
||||
|
||||
|
||||
def test_demo_corpus_is_synthetic_pending_hash_bound_approval_and_unique() -> None:
|
||||
documents = load_jsonl(SAMPLE_ROOT / "demo_documents.jsonl")
|
||||
|
||||
assert len(documents) == 20
|
||||
assert len({document["doc_id"] for document in documents}) == 20
|
||||
assert all(document["source_type"] == "synthetic" for document in documents)
|
||||
assert all(
|
||||
document["review_state"] == "LOCAL_PARSED_PENDING_CLOUD_REVIEW" for document in documents
|
||||
)
|
||||
assert all(document["cloud_policy_id"] == "synthetic-demo-v1" for document in documents)
|
||||
assert all("cloud_approved" not in document for document in documents)
|
||||
assert all(
|
||||
"虚构" in document["content"] or "演示" in document["content"] for document in documents
|
||||
)
|
||||
|
||||
|
||||
def test_demo_queries_only_reference_existing_documents() -> None:
|
||||
documents = load_jsonl(SAMPLE_ROOT / "demo_documents.jsonl")
|
||||
queries = load_jsonl(SAMPLE_ROOT / "demo_queries.jsonl")
|
||||
document_ids = {document["doc_id"] for document in documents}
|
||||
|
||||
assert len(queries) == 10
|
||||
assert len({query["qid"] for query in queries}) == 10
|
||||
assert all(set(query["expected_doc_ids"]) <= document_ids for query in queries)
|
||||
assert any(not query["answerable"] and not query["expected_doc_ids"] for query in queries)
|
||||
Reference in New Issue
Block a user