from pathlib import Path
p=Path('/opt/struktur/social-media-agent/publish_ready.py'); s=p.read_text()
old='''def _mas_policy_violation(text: str) -> str:
low=text.casefold()
for prohibited in MAS_CONTENT_POLICY.get("prohibited", []):
phrase=str(prohibited).casefold()
if phrase == "agentensprache" and any(term in low for term in AGENT_LANGUAGE_TERMS): return "content_policy_agent_language"
if phrase and phrase != "agentensprache" and phrase in low: return "content_policy_" + re.sub(r"[^a-z0-9]+", "_", phrase).strip("_")
return ""'''
new='''def _mas_policy_violation(text: str) -> str:
low=text.casefold()
for prohibited in MAS_CONTENT_POLICY.get("prohibited", []):
phrase=str(prohibited).casefold()
if phrase == "agentensprache" and any(term in low for term in AGENT_LANGUAGE_TERMS): return "content_policy_agent_language"
if phrase and phrase != "agentensprache" and phrase in low: return "content_policy_" + re.sub(r"[^a-z0-9]+", "_", phrase).strip("_")
if any(term in low for term in ("garantieren", "garantiert", "garantie", "100% erfolg", "risikofrei")):
return "content_policy_fake_guarantee"
if any(term in low for term in ("nur heute", "sofort kaufen", "jetzt zuschlagen", "letzte chance", "sichern sie sich jetzt")):
return "content_policy_artificial_urgency"
if any(term in low for term in ("heilt schimmel", "schimmel heilt", "gesundheitsgarantie", "verhindert krankheit")):
return "content_policy_unsubstantiated_health_claim"
return ""'''
assert s.count(old)==1; p.write_text(s.replace(old,new)); print('policy gate sharpened')