Add read-only production runtime audit
This commit is contained in:
@@ -127,7 +127,8 @@ def test_veterinary_phrase_abstains_even_if_the_model_missed_it():
|
||||
agent = _agent(QueryFrame(turn_type="drug_attribute", drugs=("metformin",)))
|
||||
reply = agent.handle("liều metformin cho chó bao nhiêu")
|
||||
assert reply.decision == "abstain"
|
||||
assert reply.reason == "out_of_scope"
|
||||
assert reply.reason == "out_of_scope_non_human"
|
||||
assert "chỉ bao phủ thuốc dùng cho người" in reply.answer
|
||||
|
||||
|
||||
def test_unknown_drug_name_is_reported_not_substituted():
|
||||
@@ -145,7 +146,7 @@ def test_no_drug_named_asks_which_one():
|
||||
assert reply.reason == "no_drug"
|
||||
|
||||
|
||||
def test_drug_attribute_without_an_attribute_does_not_fall_into_overview_retrieval():
|
||||
def test_drug_attribute_without_an_attribute_keeps_ai_clarification_without_retrieval():
|
||||
retrieval = _FixedRetrieval({})
|
||||
answers = GroundedAnswerService(routing=None)
|
||||
agent = RagAgent(
|
||||
@@ -163,6 +164,65 @@ def test_drug_attribute_without_an_attribute_does_not_fall_into_overview_retriev
|
||||
assert retrieval.calls == []
|
||||
|
||||
|
||||
def test_bare_drug_overview_opens_section_picker_without_retrieval():
|
||||
retrieval = _FixedRetrieval({})
|
||||
agent = RagAgent(
|
||||
_FixedUnderstander(QueryFrame(
|
||||
turn_type="drug_overview", drugs=("metformin",)
|
||||
)),
|
||||
retrieval,
|
||||
GroundedAnswerService(routing=None),
|
||||
)
|
||||
|
||||
reply = agent.handle("Metformin", response_mode="monograph")
|
||||
|
||||
assert reply.decision == "clarify"
|
||||
assert reply.reason == "select_drug_sections"
|
||||
assert reply.drugs == ("metformin",)
|
||||
assert retrieval.calls == []
|
||||
|
||||
|
||||
def test_monograph_bare_drug_ignores_stale_inherited_attribute():
|
||||
retrieval = _FixedRetrieval({})
|
||||
agent = RagAgent(
|
||||
_FixedUnderstander(QueryFrame(
|
||||
turn_type="drug_attribute",
|
||||
drugs=("metformin",),
|
||||
attribute="chong_chi_dinh",
|
||||
)),
|
||||
retrieval,
|
||||
GroundedAnswerService(routing=None),
|
||||
)
|
||||
|
||||
reply = agent.handle("Metformin", response_mode="monograph")
|
||||
|
||||
assert reply.reason == "select_drug_sections"
|
||||
assert retrieval.calls == []
|
||||
|
||||
|
||||
def test_monograph_mode_keeps_explicit_attribute_on_ai_route():
|
||||
result = RetrievalResult(
|
||||
EvidenceDecision.ABSTAIN, "not_configured", resolved_drug_id="metformin"
|
||||
)
|
||||
retrieval = _FixedRetrieval({"metformin": result})
|
||||
agent = RagAgent(
|
||||
_FixedUnderstander(QueryFrame(
|
||||
turn_type="drug_attribute",
|
||||
drugs=("metformin",),
|
||||
attribute="chong_chi_dinh",
|
||||
)),
|
||||
retrieval,
|
||||
GroundedAnswerService(routing=None),
|
||||
)
|
||||
|
||||
reply = agent.handle(
|
||||
"Chống chỉ định của Metformin là gì?", response_mode="monograph"
|
||||
)
|
||||
|
||||
assert reply.reason != "select_drug_sections"
|
||||
assert retrieval.calls[0][1] == "chong_chi_dinh"
|
||||
|
||||
|
||||
# --- the pediatric dosing gate. This code path gained its first test
|
||||
# coverage on 2026-08-11, after driving production reproduced the same
|
||||
# behaviour 5/5: the clarify question asked for both age and weight every
|
||||
|
||||
Reference in New Issue
Block a user