Spaces:
Running
Running
File size: 1,010 Bytes
4f7cbb5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | /**
* Defamation wording gate — PHASE_1 §13, CLAUDE.md safety.
* Blocked words list matches "user reports / unresolved / alleged" only policy.
* Never label any entity "fraud/scam/criminal".
*/
const BLOCKED_WORDS = ["fraud", "scam", "criminal", "cheater", "thief"];
const BLOCKED_RE = new RegExp(`\\b(${BLOCKED_WORDS.join("|")})\\b`, "gi");
const REPLACEMENTS: Record<string, string> = {
fraud: "alleged issue",
scam: "user reports",
criminal: "user reports",
cheater: "unresolved",
thief: "unresolved",
};
export interface DefamationCheck {
safe: boolean;
flaggedTerms: string[];
redactedBody: string;
}
export function checkDefamation(body: string): DefamationCheck {
const flaggedTerms: string[] = [];
const replaced = body.replace(BLOCKED_RE, (match) => {
const lower = match.toLowerCase();
flaggedTerms.push(match);
return REPLACEMENTS[lower] ?? match;
});
return {
safe: flaggedTerms.length === 0,
flaggedTerms,
redactedBody: replaced,
};
}
|