feat: replace 39 infringement cases with v3.0 18-item manuscript checklist

- data/taxonomy/cases_v3.0.json: 아카이빙DB v3.0 「2.원고점검체계18」 + 부록1-A 대표판례.
  항목↔태그 매핑은 원문 표가 없어 tag_basis(명시/추정)로 구분 (추정 7항목은 컴북스 확인 대기)
- 분류 후보를 엔진 판별 대상(M1·M2·M7·M10·P2)으로 한정
- admin detect 응답 case_candidates 에 matched_tags·reason·decision_steps·author_request 추가
  (author 응답에서는 기존대로 제외)
- /v1/taxonomy 에 항목별 판단 기준·판정 단계·문면·태그 근거 노출

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
HyeongBaeYangandClaude Opus 5.5 committed 2026-10-20 10:07:41 +09:00
1 parent 7d985b4ec3
commit 12bb82a015
10 files changed
+757 -1006

No files matched your search

+8 -8
View File
@@ -43,7 +43,7 @@ def test_out_of_scope_excluded_from_request():
assert rep["need_data_cases"] == 0
# --- 태그 → 케이스 도달 범위 회귀 (v1.3) ---------------------------------
# --- 태그 → 항목 도달 범위 회귀 (v3.0) ---------------------------------
from pathlib import Path
@@ -68,20 +68,20 @@ def _reachable():
def test_reachable_cases_cover_most_technical_detection_cases():
"""v1.3 ● 19건 중 16건이 태그만으로 후보에 오른다.
"""엔진 판별 대상 5항목 중 M1·M2·M10 이 태그만으로 후보에 오른다.
남은 B3·C1·D1 은 게재 사실·편집 개입·성명표시처럼 텍스트에서 알 수 없는
사실이 필요해 LegalContext 없이는 도달할 수 없다. 이 경계를 고정한다.
남은 M7(공동 원고)·P2(이중출판)는 성명표시·허위 저작자 표시처럼 작성자
관계를 알아야 하는 태그가 필요해 텍스트만으로는 도달할 수 없다. 이 경계를 고정한다.
"""
tax = load_taxonomy(ROOT / "data/taxonomy")
detectable = {c.case_id for c in tax.cases if c.detectable_internal}
reachable = _reachable()
assert detectable - reachable == {"B3", "C1", "D1"}
assert len(reachable & detectable) == 16
assert reachable == {"M1", "M2", "M10"}
assert detectable - reachable == {"M7", "P2"}
def test_no_tie_group_is_silently_collapsed():
"""동점군이 2건 이상이면 전부 반환된다 — 하나만 남으면 나머지가 사장된다."""
tax = load_taxonomy(ROOT / "data/taxonomy")
assert len(tax.find_cases(["reproduction", "citation_missing"])) == 7
assert len(tax.find_cases(["derivative_work", "substandard_derivative"])) == 2
assert len(tax.find_cases(["reproduction"])) == 2
assert len(tax.find_cases(["derivative_work", "substandard_derivative"])) == 1
+28 -5
View File
@@ -57,10 +57,12 @@ def test_admin_preserves_candidates_and_unknown_verdict():
assert response('admin').request_id != response('admin').request_id
def test_taxonomy_does_not_invent_missing_verdicts():
def test_taxonomy_verdicts_come_from_v3_checklist():
tax=load_taxonomy(Path('data/taxonomy'))
assert len(tax.cases)==39
assert all(c.publication_verdict is None for c in tax.cases)
assert len(tax.cases)==18
verdicts={c.case_id: c.publication_verdict for c in tax.cases}
assert verdicts['M1']=='조건부' and verdicts['M2']=='조건부(동의 확보)'
assert all(verdicts.values())
def test_real_detector_forwards_audience_for_direct_batch_and_review(tmp_path):
@@ -99,8 +101,14 @@ def test_real_detector_forwards_audience_for_direct_batch_and_review(tmp_path):
'doc_id':'admin-test','text':text,'options':{'threshold':0}}).json()
assert admin['audience']=='admin' and 'legal_risk' in admin
assert any(m['case_candidates'] for m in admin['matches'])
assert all(c['publication_verdict'] is None for m in admin['matches']
for c in m['case_candidates'])
verdicts={c.case_id: c.publication_verdict
for c in load_taxonomy(Path('data/taxonomy')).cases}
for m in admin['matches']:
for c in m['case_candidates']:
assert c['publication_verdict']==verdicts[c['case_id']]
assert c['reason'].startswith('엔진 주 태그') and c['matched_tags']
assert all(m['publication_verdict_status']=='review_required'
for m in admin['matches'] if m['case_candidates'])
def test_author_no_match_message_and_invalid_audience():
@@ -111,3 +119,18 @@ def test_author_no_match_message_and_invalid_audience():
assert result.model_dump()['ccl_basis'] == '등록된 비교 자료에서 일치 구간을 찾지 못했습니다.'
with pytest.raises(ValidationError):
DetectOptions(audience='public')
def test_case_reason_explains_tags_ties_and_draft_mapping():
from app.engine.detector import PlagiarismDetector
from app.engine.similarity import SimilarityHit
tax = load_taxonomy(Path('data/taxonomy'))
hit = SimilarityHit(doc_id='d', title='t', score=.9, text_sim=.45, lemma_sim=.3,
element_sim={'characters': .35}, evidence=[])
tie = tax.find_cases(['reproduction'])
m1, m10 = tie
reason = PlagiarismDetector._case_reason(m1, ['reproduction'], hit, tie)
assert '복제권' in reason and 'M1(남의 글을 옮겨 실었다)' in reason
assert 'text=0.45' in reason and 'M1, M10 중 하나로' in reason
assert '판단할 것: Q3' in reason and '추정치' not in reason
assert '추정치' in PlagiarismDetector._case_reason(m10, ['reproduction'], hit, tie)
+17 -19
View File
@@ -27,11 +27,10 @@ def test_taxonomy_loads_10_tags_and_cases():
tax = load_taxonomy(ROOT / "data/taxonomy")
assert tax is not None
assert len(tax.meta_tags) == 10, f"PDF IV장: 10종 메타 태그 필요, 현재 {len(tax.meta_tags)}"
# v1.3 IX장 총괄표 본문의 통계 줄은 "●16/○22 = 38"로 적혀 있으나 표를 실제로
# 세면 ●19/○20 = 39 다. 표를 기준으로 고정한다.
assert len(tax.cases) == 39, f"v1.3 IX장 총괄표: 39 케이스, 현재 {len(tax.cases)}"
assert sum(c.detectable_internal for c in tax.cases) == 19
assert sum(c.handling == "technical_detection" for c in tax.cases) == 19
# 아카이빙DB v3.0 「2.원고점검체계18」. 엔진 판별 대상은 M1·M2·M7·M10·P2.
assert len(tax.cases) == 18, f"v3.0 원고 점검 체계: 18항목, 현재 {len(tax.cases)}"
assert {c.case_id for c in tax.cases if c.detectable_internal} == {"M1", "M2", "M7", "M10", "P2"}
assert sum(c.handling == "technical_detection" for c in tax.cases) == 5
def test_taxonomy_has_required_legal_tags():
@@ -47,35 +46,34 @@ def test_taxonomy_has_required_legal_tags():
def test_taxonomy_case_groups():
tax = load_taxonomy(ROOT / "data/taxonomy")
groups = {c.case_id[0] for c in tax.cases}
assert {"A", "B", "C", "D", "E", "X"}.issubset(groups)
a_cases = [c for c in tax.cases if c.case_id.startswith("A")]
assert len(a_cases) == 27, f"PDF: A그룹(저자 가해) 27건, 현재 {len(a_cases)}"
counts = {g: sum(c.case_id.startswith(g) for c in tax.cases) for g in "MPR"}
# 원고 점검 M 11(M3a·M3b 포함) · 출간·계약 P 4 · 출간 후 보호 R 3
assert counts == {"M": 11, "P": 4, "R": 3}, counts
def test_case_mapping_returns_full_tie_group_not_one_arbitrary_pick():
"""reproduction+citation_missing 은 7개 케이스가 주/보조 태그까지 동일하다.
"""복제권만 잡히면 M1(남의 글)과 M10(자기 글 재수록)이 동점이다.
하나만 고르면 나머지 6건이 결과에 영원히 등장하지 않으므로 동점군을 모두 낸다.
둘은 작성자 관계로만 갈리므로 하나를 임의로 고르지 않고 동점군을 모두 낸다.
"""
tax = load_taxonomy(ROOT / "data/taxonomy")
ids = [c.case_id for c in tax.find_cases(["reproduction", "citation_missing"])]
assert set(ids) == {"A1", "A2", "A3", "A4", "A5", "A6", "A15"}, ids
assert all(i.startswith("A") for i in ids)
assert [c.case_id for c in tax.find_cases(["reproduction"])] == ["M1", "M10"]
assert [c.case_id for c in tax.find_cases(["reproduction", "citation_missing"])] == ["M1"]
def test_every_case_carries_v13_precedent_mapping():
"""39건 전부가 대표판례를 갖거나, 없는 이유를 명시한다. 빈칸은 허용하지 않는다."""
"""18항목 전부가 대표판례를 갖거나, 없는 이유를 명시한다. 빈칸은 허용하지 않는다."""
tax = load_taxonomy(ROOT / "data/taxonomy")
for c in tax.cases:
assert c.representative_precedents or c.representative_precedent_note, c.case_id
def test_high_risk_cases_marked():
def test_draft_tag_mappings_are_marked():
"""원문에 항목↔태그 표가 없어 초안으로 채운 7항목은 추정으로 표시돼야 한다."""
tax = load_taxonomy(ROOT / "data/taxonomy")
high_risk = [c for c in tax.cases if c.high_risk]
# PDF IX-6: 가중 위험 9건 — A10, A13, A21, A22, A23, B3, B4, C3, D1
assert len(high_risk) >= 7 # 본문에 high_risk=true 표시한 것 기준
guessed = {c.case_id for c in tax.cases if c.tag_basis == "추정"}
assert guessed == {"M3a", "M3b", "M4", "M5", "M6", "M10", "R1"}
assert all(c.tag_basis in ("명시", "추정") for c in tax.cases)
# ========== MinHash + LSH ==========