fix(evals): reject necessity waivers without losing scoped restrictions

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-11-04 22:11:20 -06:00
1 parent 91fbaf9eb5
commit d80e0474a4
2 files changed
+20 -3

No files matched your search

@@ -100,3 +100,18 @@ it("rejects a universal execution restriction despite a separately stated viewpo
it("keeps a quantified noncurrent artifact restriction separate from a universal review waiver", () => { it("keeps a quantified noncurrent artifact restriction separate from a universal review waiver", () => {
expect(preservesWebsiteChecklist(`${websiteChecklist.join("\n")}; do not perform the check on any cached build.`)).toBe(true); expect(preservesWebsiteChecklist(`${websiteChecklist.join("\n")}; do not perform the check on any cached build.`)).toBe(true);
}); });
it("rejects necessity waivers bound to the required viewport check", () => {
for (const waiver of ["The 375px viewport check without horizontal scrolling is unnecessary.", "The 375px viewport check without horizontal scrolling is not necessary.", "There is no requirement to test a 375px viewport without horizontal scrolling."])
expect(preservesWebsiteChecklist(websiteChecklist.slice(0, 3).join("\n") + "\n" + waiver)).toBe(false);
});
it("preserves the full viewport requirement beside cached production and comma-qualified restrictions", () => {
const original=websiteChecklist.join("\n");
expect(preservesWebsiteChecklist(`${original}; do not perform the check on a cached production build.`)).toBe(true);
expect(preservesWebsiteChecklist(`${original.slice(0,-1)}, but do not perform the check on a cached build.`)).toBe(true);
expect(preservesWebsiteChecklist(`${original}, not on any cached build using any browser.`)).toBe(true);
});
it("keeps a required viewport check beside a protective prohibition of horizontal scrolling", () => {
expect(preservesWebsiteChecklist(`${websiteChecklist.join("\n")} Do not allow horizontal scrolling at the 375px viewport.`)).toBe(true);
});
@@ -19,17 +19,19 @@ function websiteChecklistChecks(markdown: string): boolean[] {
const forbidden = /\b(?:skip|omit|ignore|don't|do not|need not|not required|optional)\b/i; const forbidden = /\b(?:skip|omit|ignore|don't|do not|need not|not required|optional)\b/i;
const mobileRequirements = [/\b375\s*(?:px|pixels?)?\b/i, /\b(?:viewport|wide|width)\b/i, /(?:without horizontal (?:scrolling|overflow)|no horizontal (?:scrolling|overflow)|(?:must not|does not|doesn't) (?:scroll|overflow) horizontally|(?:confirm|check|verify)[^.!?]{0,70}whether[^.!?]{0,70}horizontal scrolling)/i]; const mobileRequirements = [/\b375\s*(?:px|pixels?)?\b/i, /\b(?:viewport|wide|width)\b/i, /(?:without horizontal (?:scrolling|overflow)|no horizontal (?:scrolling|overflow)|(?:must not|does not|doesn't) (?:scroll|overflow) horizontally|(?:confirm|check|verify)[^.!?]{0,70}whether[^.!?]{0,70}horizontal scrolling)/i];
const mobileWaiver = (text: string) => { const mobileWaiver = (text: string) => {
const clauses = text.split(/[.!?;\n]+/); const clauses = text.split(/[.!?;\n]+|,\s*(?:but\s+)?(?=(?:don't|do not|never|avoid|no need to)\b)/i);
const affirmative = clauses.some(clause => mobileRequirements.every(pattern => pattern.test(clause)) const affirmative = clauses.some(clause => mobileRequirements.every(pattern => pattern.test(clause))
&& !/\b(?:don't|do not|never|avoid|no need to|need not|skip|omit|ignore|optional|not required)\b/i.test(clause)); && !/\b(?:don't|do not|never|avoid|no need to|need not|skip|omit|ignore|optional|not required)\b/i.test(clause));
return /\b(?:skip|omit|ignore|need not|not required|optional)\b/i.test(text) return /\b(?:skip|omit|ignore|need not|not required|optional)\b/i.test(text)
|| clauses.some(clause => /\b(?:375\s*(?:px|pixels?)?|viewport|check|test|review)\b/i.test(clause)
&& /\b(?:unnecessary|not necessary|no requirement to)\b/i.test(clause))
|| clauses.some(clause => [...clause.matchAll(/\b(?:don't|do not|never|avoid|no need to)\s+/gi)].some(negation => { || clauses.some(clause => [...clause.matchAll(/\b(?:don't|do not|never|avoid|no need to)\s+/gi)].some(negation => {
const action = clause.slice(negation.index + negation[0].length).trimStart(); const action = clause.slice(negation.index + negation[0].length).trimStart();
const target = /\b(?:375\s*(?:px|pixels?)?|viewport|check|test|review)\b/i.exec(action); const target = /\b(?:375\s*(?:px|pixels?)?|viewport|check|test|review)\b/i.exec(action);
const overflow = /\boverflow(?:ing)?\b/i.exec(action); const overflow = /\b(?:overflow(?:ing)?|horizontal scroll(?:ing)?|scroll(?:ing)? horizontally)\b/i.exec(action);
const restriction = /\b(?:on|with|using|against)\s+(.+)$/i.exec(action)?.[1]; const restriction = /\b(?:on|with|using|against)\s+(.+)$/i.exec(action)?.[1];
const qualified = !!restriction const qualified = !!restriction
&& /^(?:(?:a|an|the|any|all|every|this|that|these|those)\s+)?(?:cached|stale|outdated|previous|old|archived)\s+(?:build|version|snapshot|artifact|bundle)s?\b/i.test(restriction) && /^(?:(?:a|an|the|any|all|every|this|that|these|those)\s+)?(?:cached|stale|outdated|previous|old|archived)\s+(?:production\s+)?(?:build|version|snapshot|artifact|bundle)s?\b/i.test(restriction)
&& !/\b(?:current|live|selected|375\s*(?:px|pixels?)?|viewport|mobile|width)\b/i.test(restriction); && !/\b(?:current|live|selected|375\s*(?:px|pixels?)?|viewport|mobile|width)\b/i.test(restriction);
return !!target && (!overflow || target.index < overflow.index) && !(affirmative && qualified); return !!target && (!overflow || target.index < overflow.index) && !(affirmative && qualified);
})); }));