From c172981c6c6931bb6f61350347715f3fc8526141 Mon Sep 17 00:00:00 2001 From: jaehwang Date: Mon, 23 Nov 2026 11:10:29 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=EB=A7=A4=EC=B9=AD=20=EC=97=86?= =?UTF-8?q?=EC=9D=84=20=EC=8B=9C=20=ED=8C=90=EB=A1=80=20=EB=AF=B8=EB=B0=98?= =?UTF-8?q?=ED=99=98=20=EB=B0=8F=20=ED=8C=90=EB=A1=80=20=ED=8C=90=EB=8B=A8?= =?UTF-8?q?=20=EC=A1=B0=EA=B1=B4=20=EC=A1=B0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/routes.py | 4 ++++ app/engine/legal_risk.py | 14 ++++++++------ docs/API_SPEC_BAIKAL.md | 3 +++ tests/test_api.py | 14 ++++++++++++++ tests/test_legal_risk.py | 14 ++++++++++++++ 5 files changed, 43 insertions(+), 6 deletions(-) diff --git a/app/api/routes.py b/app/api/routes.py index 9305628..4b71553 100644 --- a/app/api/routes.py +++ b/app/api/routes.py @@ -132,6 +132,10 @@ async def copyright_review( } if legal.llm_verdict == "likely": legal_status, legal_label = "suspected", "판례에 비추어 저작권 침해 의심" + # TODO: 일치가 없는 의심 낮음(no_registered_corpus_match)은 엔진이 판례·요약을 비워 보낸다. + # LLM 판단(USE_LLM_LEGAL_JUDGE)이 unlikely 인 경우는 일치가 있는 글이라 판례·요약이 그대로 + # 남는다. 바이칼 요청("의심 낮음이면 판례·요약 미반환")과 어긋나므로 LLM 판단을 운영에서 + # 켜기 전에 이 경우도 precedent_ids=[]·summary="" 로 맞춰야 한다. elif ( legal.llm_verdict == "unlikely" or legal.status == "no_registered_corpus_match" diff --git a/app/engine/legal_risk.py b/app/engine/legal_risk.py index 29f5e19..99de27c 100644 --- a/app/engine/legal_risk.py +++ b/app/engine/legal_risk.py @@ -241,10 +241,15 @@ class LegalRiskEngine: if not rights_verified: missing.append("저작권 귀속·이용허락·인용 요건") + # 탐지 일치(matches)가 없으면 호출부가 max_similarity=0 을 넘긴다. coverage 는 + # 일치 판정 전 후보와의 12자 이상 공통 구간이라 흔한 표현만으로도 0을 넘으므로 + # 등급 기준에 쓰지 않는다. 일치가 없으면 판례·요약도 붙이지 않는다. + no_match = max_similarity <= 0 if not self.precedents: status, level = "insufficient_precedent_data", None - elif max_similarity <= 0 and coverage <= 0: + elif no_match: status, level = "no_registered_corpus_match", "low" + related = [] else: status = "review_required" strong_copy = coverage >= 0.30 or longest_span >= 100 @@ -269,7 +274,7 @@ class LegalRiskEngine: precedent_grades=tuple((p.case_id, p.grade) for p in related if p.grade), judgment_summary=_rule_based_summary(status, related), ) - if self.judge is None or not related or (max_similarity <= 0 and coverage <= 0): + if self.judge is None or not related or no_match: return base request = LegalJudgeInput( @@ -333,10 +338,7 @@ def _rule_based_summary(status: str, related: list[Precedent]) -> str: if status == "insufficient_precedent_data": return "등록된 판례가 없어 판례에 따른 검토 의견을 제시할 수 없습니다." if status == "no_registered_corpus_match": - return ( - "등록 코퍼스에서 일치 증거가 확인되지 않아 판례 기반 침해 의심을 제시하지 않습니다. " - "다만 미매칭은 비침해 확정이 아닙니다." - ) + return "" ids = ", ".join(p.case_id for p in related[:3]) suffix = f" 등 {len(related)}건" if len(related) > 3 else "" return f"{ids}{suffix} 판례가 관련 판례로 검색되어 구체적인 사실관계 검토가 필요합니다." diff --git a/docs/API_SPEC_BAIKAL.md b/docs/API_SPEC_BAIKAL.md index dc43257..a3fd3b1 100644 --- a/docs/API_SPEC_BAIKAL.md +++ b/docs/API_SPEC_BAIKAL.md @@ -57,6 +57,9 @@ curl -X POST https://plagiarism.o2o.kr/v1/plagiarism/detect \ > `ai_generation_suspicion.level` 값은 `low`, `medium`, `high`, `unknown`이며, > 화면은 함께 반환되는 한글 `label`을 그대로 표시한다. +> 일치 구간이 없으면 `legal_judgment.status`는 `low`(침해 의심 낮음)이며, +> 이때 `legal_judgment.precedent_ids`는 `[]`, `legal_judgment.summary`는 `""`로 반환한다. + --- ## 2. 저작권 탭 경량 검사 — `POST /v1/plagiarism/review` diff --git a/tests/test_api.py b/tests/test_api.py index 39a63fc..7455567 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -65,6 +65,20 @@ def test_copyright_review_returns_only_mobile_tab_fields(): assert "score_semantics" not in body +def test_copyright_review_low_omits_precedents_and_summary(): + """35자 미만 본문은 일치가 날 수 없으므로 의심 낮음이고 판례·요약이 비어야 한다.""" + with TestClient(app) as client: + resp = client.post( + "/v1/plagiarism/review", + json={"doc_id": "mobile-low", "text": "창밖으로 보이는 숲은 오늘따라 푸르게 보였다."}, + ) + assert resp.status_code == 200 + legal = resp.json()["legal_judgment"] + assert legal["status"] == "low" + assert legal["precedent_ids"] == [] + assert legal["summary"] == "" + + def test_batch_flow(): with TestClient(app) as client: resp = client.post( diff --git a/tests/test_legal_risk.py b/tests/test_legal_risk.py index 3800347..cefff9f 100644 --- a/tests/test_legal_risk.py +++ b/tests/test_legal_risk.py @@ -43,6 +43,20 @@ def test_risk_requires_missing_facts_and_only_registered_case_ids(): assert len(result.missing_factors) == 3 +def test_no_detect_match_is_low_without_precedents_or_summary(): + """일치(matches)가 없으면 12자 공통 표현으로 coverage 가 있어도 의심 낮음이다.""" + judge = _FakeJudge() + result = LegalRiskEngine([_case()], judge=judge).assess( + max_similarity=0.0, coverage=0.2, longest_span=0, legal_tags=[], + ) + assert result.status == "no_registered_corpus_match" + assert result.risk_level == "low" + assert result.precedent_ids == () + assert result.precedent_grades == () + assert result.judgment_summary == "" + assert judge.request is None + + def test_repository_seed_is_valid(): cases = load_precedents("data/precedents/precedents.jsonl") assert cases