From 826ce2a1b855ed376239e83bfc6f11233c181c0e Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Fri, 15 May 2026 00:54:33 +0200 Subject: [PATCH] fix(cross-doc): suppress false positives when regex checks already pass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cross-search "not in text" findings are only shown when regex L1 completeness < 50%. This prevents false positives where the text IS the right doc_type but doesn't contain the specific cross-search keywords (e.g. Impressum passes 9/13 checks but lacks "§5 TMG"). Also: cross-search now checks entries with wrong text, not just empty. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../api/agent_compliance_check_routes.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/backend-compliance/compliance/api/agent_compliance_check_routes.py b/backend-compliance/compliance/api/agent_compliance_check_routes.py index 874ab48e..d135eca2 100644 --- a/backend-compliance/compliance/api/agent_compliance_check_routes.py +++ b/backend-compliance/compliance/api/agent_compliance_check_routes.py @@ -237,12 +237,15 @@ async def _run_compliance_check(check_id: str, req: ComplianceCheckRequest): # Apply profile context filter result = _apply_profile_filter(result, profile, doc_type) - # Add placement findings (doc found in wrong location) - for pf in placement_findings: - if pf.get("doc_type") == doc_type: - result.checks.insert(0, CheckItem(**{ - k: v for k, v in pf.items() if k != "doc_type" - })) + # Add placement findings — but only if the regex checks confirm + # the text doesn't match. If completeness >= 50%, the text IS the + # right doc_type despite missing cross-search keywords. + if result.completeness_pct < 50: + for pf in placement_findings: + if pf.get("doc_type") == doc_type: + result.checks.insert(0, CheckItem(**{ + k: v for k, v in pf.items() if k != "doc_type" + })) results.append(result) total_findings += result.findings_count