Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

fix(ts): stop the bare word confidential from deleting a real request

李氵氵7c2010cbd074
diff --git a/laya-ts/src/email.ts b/laya-ts/src/email.ts
index 7fe82981..09c1cc24 100644
--- a/laya-ts/src/email.ts
+++ b/laya-ts/src/email.ts
@@ -45,7 +45,15 @@ const DEVICE_FOOTER = new RegExp(
"i",
);
const DISCLAIMER = new RegExp(
- "(confidential|intended (solely )?for the (use of the )?(named )?(addressee|recipient)|" +
+ // English is tied to a disclaimer noun and a disclaimer tail, the way the Portuguese branches
+ // below are. The bare word matched any sentence that merely mentioned it, so "Is this
+ // confidential?" and "Confidential: I need a refund." were deleted whole and the model was
+ // scored on an empty state. `[^.]` rather than `[^.\n]`: a footer wraps, so "are\nconfidential"
+ // must still match.
+ "(\\b(e-?mail|message|information|communication|transmission|contents?)\\b[^.]{0,60}" +
+ "\\bconfidential\\b[^.]{0,60}\\b(intended|solely|addressee|recipient|privileged|" +
+ "disclos|unauthori[sz]ed)|" +
+ "\\bconfidential\\b[^.]{0,60}\\b(and (may|is) (also )?privileged)|" +
"if you (have )?received this (e-?mail|message) in error|" +
"\\b(esta|este) (mensagem|e-?mail|mensaje|correo)\\b[^.]{0,80}(confidencia|sigilos|privilegiad)|" +
"\\b(uso exclusivo|exclusivamente|únicamente|unicamente)\\b[^.]{0,30}" +
diff --git a/laya-ts/tests/email-presets.test.ts b/laya-ts/tests/email-presets.test.ts
index 4f503cdb..3df2caac 100644
--- a/laya-ts/tests/email-presets.test.ts
+++ b/laya-ts/tests/email-presets.test.ts
@@ -40,6 +40,48 @@ describe("email+presets", () => {
expect(out.length).toBe(3000);
expect(out).not.toContain("old text");
});
+ // Python's `_DISCLAIMER` ties the English branch to a disclaimer noun and a disclaimer tail;
+ // laya-ts matched the bare word, so a one-sentence body that merely used "confidential" was
+ // cleaned to "" and the model was scored on an empty state. Expectations are Python's.
+ it("keeps a request that only mentions the word confidential (Python parity)", () => {
+ for (const body of [
+ "Is this confidential?",
+ "What is your confidentiality policy?",
+ "Please keep this confidential but process my refund.",
+ "Please treat this as confidential.",
+ "This is confidential - can you help?",
+ "Is the attached document confidential?",
+ "Confidential: I need a refund.",
+ "Please unlock my account, the contents are not confidential to anyone.",
+ "This message is intended solely for the named addressee.",
+ "Please forward this to billing. It is intended for the use of the recipient only.",
+ ]) {
+ expect(cleanEmailBody(body), body).toBe(body);
+ }
+ });
+ it("never cleans a body down to nothing (Python parity)", () => {
+ expect(cleanEmailBody("Is this confidential?").trim()).not.toBe("");
+ });
+ it("still drops the real footers those branches exist for (Python parity)", () => {
+ for (const body of [
+ "This email is confidential and intended solely for the named addressee.",
+ "This message is confidential and intended solely for the use of the individual to whom it is addressed.",
+ "The information in this email is confidential and may be privileged.",
+ "This email and any files transmitted with it are\nconfidential and intended solely for the named addressee.",
+ ]) {
+ expect(cleanEmailBody(body).trim(), body).toBe("");
+ }
+ });
+ it("keeps the request around a footer (Python parity)", () => {
+ expect(
+ cleanEmailBody(
+ "My account is locked.\nThis email is confidential and intended solely for the named addressee.\nPlease unlock it.",
+ ),
+ ).toBe("My account is locked. Please unlock it.");
+ expect(
+ cleanEmailBody("Please unlock it. This email is confidential and intended solely for the named addressee."),
+ ).toBe("Please unlock it.");
+ });
it("guard preset has jailbreak and harm_severity", () => {
const g = guardQuestions() as Record<string, any>;
expect(g.jailbreak.type).toBe("noul");