From 555deafcbbc93a9e9269883e13807f2e2b987cc2 Mon Sep 17 00:00:00 2001 From: Hyungi Ahn Date: Sat, 2 May 2026 08:36:18 +0900 Subject: [PATCH] docs(nanoclaude): assert direct-path elif condition in tests Spec contract test #4: a normal direct response with non-empty natural text must classify as direct AND pass the leak guard, so the worker's direct-path elif fires instead of the chat_fallback branch. Co-Authored-By: Claude Opus 4.7 (1M context) --- nanoclaude/tests/test_classifier_io.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/nanoclaude/tests/test_classifier_io.py b/nanoclaude/tests/test_classifier_io.py index 30d4838..f876f6d 100644 --- a/nanoclaude/tests/test_classifier_io.py +++ b/nanoclaude/tests/test_classifier_io.py @@ -156,3 +156,19 @@ def test_actual_bug_payload_detected(): '추론 모델에게 전달할게요!", "prompt": "노래 가사를 분석해주세요."}' ) assert looks_like_router_json(text) is True + + +# ---------- combined: normal direct path stays out of fallback ---------- + + +def test_normal_direct_response_takes_direct_path(): + """Spec contract: a normal direct response with non-empty natural text + must be classified `direct` AND survive the leak guard, so the worker's + direct-path elif fires (not the chat_fallback branch).""" + raw = '{"action": "direct", "response": "안녕하세요! 무엇을 도와드릴까요?", "prompt": ""}' + parsed = parse_classification(raw) + assert parsed["action"] == "direct" + assert parsed["response"] + assert looks_like_router_json(parsed["response"]) is False + # The two assertions above together replicate the elif condition in + # worker.py: action=="direct" and response_text and not router-shaped.