Checkpoint frontend UI/UX overhaul and ingestion embed benchmark work
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
"""F-02: subject_scope must be server-derived, not client-asserted.
|
||||
|
||||
Reproduces the Codex 2026-08-06 finding directly: a caller claiming "human"
|
||||
on a veterinary query must not get that claim honored. The claim can only
|
||||
make the result MORE conservative, never less.
|
||||
|
||||
Scoped to `subject_scope` only. `resolve_query_intent`/`QueryIntent.RECOMMENDATION`
|
||||
keyword detection was tried and removed the same day: this product is for
|
||||
doctors and pharmacists, and a clinician asking "nên dùng thuốc gì" is a
|
||||
normal professional use of a formulary reference, not something to abstain
|
||||
on. See `docs/progress-log.md` 2026-08-06.
|
||||
"""
|
||||
from rag.models import SubjectScope
|
||||
from rag.policy import resolve_subject_scope
|
||||
|
||||
|
||||
def test_veterinary_query_is_non_human_even_when_client_claims_human():
|
||||
scope = resolve_subject_scope("Liều cho chó bị viêm khớp?", SubjectScope.HUMAN)
|
||||
assert scope == SubjectScope.NON_HUMAN
|
||||
|
||||
|
||||
def test_ordinary_dose_question_stays_human():
|
||||
scope = resolve_subject_scope("Liều metformin cho người lớn?", SubjectScope.HUMAN)
|
||||
assert scope == SubjectScope.HUMAN
|
||||
|
||||
|
||||
def test_client_cannot_widen_a_server_detected_non_human_scope():
|
||||
# Even an explicit non_human claim from an honest client must stick.
|
||||
scope = resolve_subject_scope("thuốc cho mèo", SubjectScope.NON_HUMAN)
|
||||
assert scope == SubjectScope.NON_HUMAN
|
||||
|
||||
|
||||
def test_client_narrowing_to_non_human_is_honored_even_without_a_keyword_hit():
|
||||
# A caller with better information than the keyword list can narrow.
|
||||
scope = resolve_subject_scope("liều dùng", SubjectScope.NON_HUMAN)
|
||||
assert scope == SubjectScope.NON_HUMAN
|
||||
|
||||
|
||||
def test_unknown_claim_with_no_server_signal_stays_unknown():
|
||||
scope = resolve_subject_scope("liều dùng", SubjectScope.UNKNOWN)
|
||||
assert scope == SubjectScope.UNKNOWN
|
||||
|
||||
|
||||
def test_clinician_asking_which_drug_is_preferred_is_not_flagged_non_human():
|
||||
# A doctor/pharmacist comparing options across monographs is core,
|
||||
# intended use of this product — not a request to gate.
|
||||
scope = resolve_subject_scope(
|
||||
"Bệnh nhân suy thận, nên dùng thuốc hạ áp nào?", SubjectScope.HUMAN
|
||||
)
|
||||
assert scope == SubjectScope.HUMAN
|
||||
Reference in New Issue
Block a user