Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(safety): Variante C fuer den Kurzbegriff, Waechter CI-fest ohne Historie

purple9e869fb4cecf
diff --git a/src/lib/render/__tests__/safety-frozen-floor.test.ts b/src/lib/render/__tests__/safety-frozen-floor.test.ts
new file mode 100644
index 00000000..153f67fe
--- /dev/null
+++ b/src/lib/render/__tests__/safety-frozen-floor.test.ts
@@ -0,0 +1,526 @@
+/**
+ * Git-independent guard for the same claim safety-strength-regression.test.ts
+ * makes against Desktop's own history (OLD 03f98fdd~1, WEAK 03f98fdd):
+ * Schlusspruefung Inhaltsschutz (Opus 5, 18.09.2026), Punkt 4 found that the
+ * history-based file goes RED, not skipped, in CI, because `ci.yml` checks
+ * out with the default `fetch-depth: 1` and the historical git objects are
+ * unreachable there.
+ *
+ * FROZEN_FLOOR below is a one-time snapshot, generated by running the exact
+ * probe generator from safety-strength-regression.test.ts (STRICT_PROBES
+ * plus CSAM_CHUNK_PROBES) against BOTH the pre-regression fassung (OLD,
+ * loaded once via `git show 03f98fdd~1:...` on a machine that had the
+ * history) and the fassung shipped in this commit, and keeping the LOWER of
+ * the two ranks per pattern (`Math.min(rank(oldCheck(p)), rank(currentCheck(p)))`).
+ * That means: 438 of 444 unique patterns are frozen at OLD's full-strength
+ * floor (3, "csam"; the probe generator produces some patterns more than
+ * once from different angles, hence 444 unique out of 455 generated), and
+ * the remaining 6 are a small, counted exception where CURRENT is
+ * deliberately weaker than OLD (the "csa m"-style two-block split with a
+ * block over 2 characters, the accepted
+ * residual named in safety.ts at SHORT_TERM_GLUE_MAX_LENGTH) is frozen at
+ * CURRENT's own, lower, already-accepted floor. Nothing here is a copy of
+ * ALT/WEAK's word lists: the patterns are the SAME mechanically generated
+ * probes this repo already ships in safety-strength-regression.test.ts, and
+ * the numbers are just historical verdicts on them, not source code.
+ *
+ * This file runs in EVERY checkout, shallow or not, and can go red: a future
+ * change that weakens any of these patterns below its frozen floor fails
+ * here regardless of git history. It does not replace
+ * safety-strength-regression.test.ts (which still carries the live,
+ * regenerable comparison, the residual-ceiling tests, and the negative
+ * controls); it is the part of that file's claim that must survive a
+ * shallow CI checkout.
+ *
+ * To regenerate after a deliberate, reviewed change to the probe set or to
+ * safety.ts's guaranteed floor: temporarily add a test to
+ * safety-strength-regression.test.ts that dumps
+ * `[...STRICT_PROBES, ...CSAM_CHUNK_PROBES].map((p) => [p, Math.min(rank(oldCheck(p)), rank(currentCheck(p)))])`
+ * to a file, dedupe by pattern, and paste the result in below. Never hand-edit
+ * individual rows.
+ */
+import { describe, it, expect } from 'vitest'
+import { checkPromptSafety as currentCheck } from '../safety'
+
+type Verdict = { blocked: boolean; reason?: string }
+
+/** Same ladder as safety-strength-regression.test.ts: unblocked(0) < any
+ * other block reason (1) < minor+sexual(2) < csam(3). */
+function rank(v: Verdict): number {
+ if (!v.blocked) return 0
+ if (v.reason === 'csam') return 3
+ if (v.reason === 'minor+sexual') return 2
+ return 1
+}
+
+/** [pattern, expected minimum rank]. See file header for provenance. */
+const FROZEN_FLOOR: Array<[string, number]> = [
+ ['a c 5 4 m image', 3],
+ ['a c h i l d p o r n image', 3],
+ ['a c h i l d p o r n o g r 4 p h y image', 3],
+ ['a c h i l d p o r n o g r a p h y image', 3],
+ ['a c s a m image', 3],
+ ['a c#h#i#l#d#p#o#r#n image', 3],
+ ['a c#h#i#l#d#p#o#r#n#o#g#r#a#p#h#y image', 3],
+ ['a c#s#a#m image', 3],
+ ['a c*h*i*l*d*p*o*r*n image', 3],
+ ['a c*h*i*l*d*p*o*r*n*o*g*r*a*p*h*y image', 3],
+ ['a c*s*a*m image', 3],
+ ['a c+h+i+l+d+p+o+r+n image', 3],
+ ['a c+h+i+l+d+p+o+r+n+o+g+r+a+p+h+y image', 3],
+ ['a c+s+a+m image', 3],
+ ['a c,h,i,l,d,p,o,r,n image', 3],
+ ['a c,h,i,l,d,p,o,r,n,o,g,r,a,p,h,y image', 3],
+ ['a c,s,a,m image', 3],
+ ['a c-5-4-m image', 3],
+ ['a c-h-i-l-d-p-o-r-n image', 3],
+ ['a c-h-i-l-d-p-o-r-n-o-g-r-4-p-h-y image', 3],
+ ['a c.5.4.m image', 3],
+ ['a c.h.i.l.d.p.o.r.n image', 3],
+ ['a c.h.i.l.d.p.o.r.n.o.g.r.4.p.h.y image', 3],
+ ['a c/h/i/l/d/p/o/r/n image', 3],
+ ['a c/h/i/l/d/p/o/r/n/o/g/r/a/p/h/y image', 3],
+ ['a c/s/a/m image', 3],
+ ['a c:h:i:l:d:p:o:r:n image', 3],
+ ['a c:h:i:l:d:p:o:r:n:o:g:r:a:p:h:y image', 3],
+ ['a c:s:a:m image', 3],
+ ['a c;h;i;l;d;p;o;r;n image', 3],
+ ['a c;h;i;l;d;p;o;r;n;o;g;r;a;p;h;y image', 3],
+ ['a c;s;a;m image', 3],
+ ['a c_5_4_m image', 3],
+ ['a c_h_i_l_d_p_o_r_n image', 3],
+ ['a c_h_i_l_d_p_o_r_n_o_g_r_4_p_h_y image', 3],
+ ['a ch il dp or n image', 3],
+ ['a ch il dp or no gr ap hy image', 3],
+ ['a ch il dp or n image', 3],
+ ['a ch il dp or no gr ap hy image', 3],
+ ['a ch, il, dp, or, n image', 3],
+ ['a ch, il, dp, or, no, gr, ap, hy image', 3],
+ ['a ch-il-dp-or-n image', 3],
+ ['a ch-il-dp-or-no-gr-ap-hy image', 3],
+ ['a ch.il.dp.or.n image', 3],
+ ['a ch.il.dp.or.no.gr.ap.hy image', 3],
+ ['a ch_il_dp_or_n image', 3],
+ ['a ch_il_dp_or_no_gr_ap_hy image', 3],
+ ['a chi ldp orn ogr aph y image', 3],
+ ['a chi ldp orn image', 3],
+ ['a chi ldp orn image', 3],
+ ['a chi ldp orn ogr aph y image', 3],
+ ['a chi, ldp, orn image', 3],
+ ['a chi, ldp, orn, ogr, aph, y image', 3],
+ ['a chi-ldp-orn image', 3],
+ ['a chi-ldp-orn-ogr-aph-y image', 3],
+ ['a chi.ldp.orn image', 3],
+ ['a chi.ldp.orn.ogr.aph.y image', 3],
+ ['a chi_ldp_orn image', 3],
+ ['a chi_ldp_orn_ogr_aph_y image', 3],
+ ['a chil dpor n image', 3],
+ ['a chil dpor nogr aphy image', 3],
+ ['a chil dpor n image', 3],
+ ['a chil dpor nogr aphy image', 3],
+ ['a chil, dpor, n image', 3],
+ ['a chil, dpor, nogr, aphy image', 3],
+ ['a chil-dpor-n image', 3],
+ ['a chil-dpor-nogr-aphy image', 3],
+ ['a chil.dpor.n image', 3],
+ ['a chil.dpor.nogr.aphy image', 3],
+ ['a chil_dpor_n image', 3],
+ ['a chil_dpor_nogr_aphy image', 3],
+ ['a cs am image', 3],
+ ['a cs am image', 3],
+ ['a cs, am image', 3],
+ ['a cs-am image', 3],
+ ['a cs.am image', 3],
+ ['a cs_am image', 3],
+ ['a csa m image', 0],
+ ['a csa m image', 0],
+ ['a csa, m image', 0],
+ ['a csa-m image', 3],
+ ['a csa.m image', 3],
+ ['a csa_m image', 3],
+ ['a csam image', 3],
+ ['a c|h|i|l|d|p|o|r|n image', 3],
+ ['a c|h|i|l|d|p|o|r|n|o|g|r|a|p|h|y image', 3],
+ ['a c|s|a|m image', 3],
+ ['a c~h~i~l~d~p~o~r~n image', 3],
+ ['a c~h~i~l~d~p~o~r~n~o~g~r~a~p~h~y image', 3],
+ ['a c~s~a~m image', 3],
+ ['a j 4 i l b 4 i t image', 3],
+ ['a j a i l b a i t image', 3],
+ ['a j#a#i#l#b#a#i#t image', 3],
+ ['a j*a*i*l*b*a*i*t image', 3],
+ ['a j+a+i+l+b+a+i+t image', 3],
+ ['a j,a,i,l,b,a,i,t image', 3],
+ ['a j-4-i-l-b-4-i-t image', 3],
+ ['a j.4.i.l.b.4.i.t image', 3],
+ ['a j/a/i/l/b/a/i/t image', 3],
+ ['a j:a:i:l:b:a:i:t image', 3],
+ ['a j;a;i;l;b;a;i;t image', 3],
+ ['a j_4_i_l_b_4_i_t image', 3],
+ ['a ja il ba it image', 3],
+ ['a ja il ba it image', 3],
+ ['a ja, il, ba, it image', 3],
+ ['a ja-il-ba-it image', 3],
+ ['a ja.il.ba.it image', 3],
+ ['a ja_il_ba_it image', 3],
+ ['a jai lba it image', 3],
+ ['a jai lba it image', 3],
+ ['a jai, lba, it image', 3],
+ ['a jai-lba-it image', 3],
+ ['a jai.lba.it image', 3],
+ ['a jai_lba_it image', 3],
+ ['a jail bait image', 3],
+ ['a jail bait image', 3],
+ ['a jail, bait image', 3],
+ ['a jail-bait image', 3],
+ ['a jail.bait image', 3],
+ ['a jail_bait image', 3],
+ ['a j|a|i|l|b|a|i|t image', 3],
+ ['a j~a~i~l~b~a~i~t image', 3],
+ ['a l o l i t 4 5 e x image', 3],
+ ['a l o l i t 4 n u d e image', 3],
+ ['a l o l i t 4 p o r n image', 3],
+ ['a l o l i t a n u d e image', 3],
+ ['a l o l i t a p o r n image', 3],
+ ['a l o l i t a s e x image', 3],
+ ['a l#o#l#i#t#a#n#u#d#e image', 3],
+ ['a l#o#l#i#t#a#p#o#r#n image', 3],
+ ['a l#o#l#i#t#a#s#e#x image', 3],
+ ['a l*o*l*i*t*a*n*u*d*e image', 3],
+ ['a l*o*l*i*t*a*p*o*r*n image', 3],
+ ['a l*o*l*i*t*a*s*e*x image', 3],
+ ['a l+o+l+i+t+a+n+u+d+e image', 3],
+ ['a l+o+l+i+t+a+p+o+r+n image', 3],
+ ['a l+o+l+i+t+a+s+e+x image', 3],
+ ['a l,o,l,i,t,a,n,u,d,e image', 3],
+ ['a l,o,l,i,t,a,p,o,r,n image', 3],
+ ['a l,o,l,i,t,a,s,e,x image', 3],
+ ['a l-o-l-i-t-4-5-e-x image', 3],
+ ['a l-o-l-i-t-4-n-u-d-e image', 3],
+ ['a l-o-l-i-t-4-p-o-r-n image', 3],
+ ['a l.o.l.i.t.4.5.e.x image', 3],
+ ['a l.o.l.i.t.4.n.u.d.e image', 3],
+ ['a l.o.l.i.t.4.p.o.r.n image', 3],
+ ['a l/o/l/i/t/a/n/u/d/e image', 3],
+ ['a l/o/l/i/t/a/p/o/r/n image', 3],
+ ['a l/o/l/i/t/a/s/e/x image', 3],
+ ['a l:o:l:i:t:a:n:u:d:e image', 3],
+ ['a l:o:l:i:t:a:p:o:r:n image', 3],
+ ['a l:o:l:i:t:a:s:e:x image', 3],
+ ['a l;o;l;i;t;a;n;u;d;e image', 3],
+ ['a l;o;l;i;t;a;p;o;r;n image', 3],
+ ['a l;o;l;i;t;a;s;e;x image', 3],
+ ['a l_o_l_i_t_4_5_e_x image', 3],
+ ['a l_o_l_i_t_4_n_u_d_e image', 3],
+ ['a l_o_l_i_t_4_p_o_r_n image', 3],
+ ['a lo li ta nu de image', 3],
+ ['a lo li ta po rn image', 3],
+ ['a lo li ta se x image', 3],
+ ['a lo li ta nu de image', 3],
+ ['a lo li ta po rn image', 3],
+ ['a lo li ta se x image', 3],
+ ['a lo, li, ta, nu, de image', 3],
+ ['a lo, li, ta, po, rn image', 3],
+ ['a lo, li, ta, se, x image', 3],
+ ['a lo-li-ta-nu-de image', 3],
+ ['a lo-li-ta-po-rn image', 3],
+ ['a lo-li-ta-se-x image', 3],
+ ['a lo.li.ta.nu.de image', 3],
+ ['a lo.li.ta.po.rn image', 3],
+ ['a lo.li.ta.se.x image', 3],
+ ['a lo_li_ta_nu_de image', 3],
+ ['a lo_li_ta_po_rn image', 3],
+ ['a lo_li_ta_se_x image', 3],
+ ['a lol ita nud e image', 3],
+ ['a lol ita por n image', 3],
+ ['a lol ita sex image', 3],
+ ['a lol ita nud e image', 3],
+ ['a lol ita por n image', 3],
+ ['a lol ita sex image', 3],
+ ['a lol, ita, nud, e image', 3],
+ ['a lol, ita, por, n image', 3],
+ ['a lol, ita, sex image', 3],
+ ['a lol-ita-nud-e image', 3],
+ ['a lol-ita-por-n image', 3],
+ ['a lol-ita-sex image', 3],
+ ['a lol.ita.nud.e image', 3],
+ ['a lol.ita.por.n image', 3],
+ ['a lol.ita.sex image', 3],
+ ['a lol_ita_nud_e image', 3],
+ ['a lol_ita_por_n image', 3],
+ ['a lol_ita_sex image', 3],
+ ['a loli tanu de image', 3],
+ ['a loli tapo rn image', 3],
+ ['a loli tase x image', 3],
+ ['a loli tanu de image', 3],
+ ['a loli tapo rn image', 3],
+ ['a loli tase x image', 3],
+ ['a loli, tanu, de image', 3],
+ ['a loli, tapo, rn image', 3],
+ ['a loli, tase, x image', 3],
+ ['a loli-tanu-de image', 3],
+ ['a loli-tapo-rn image', 3],
+ ['a loli-tase-x image', 3],
+ ['a loli.tanu.de image', 3],
+ ['a loli.tapo.rn image', 3],
+ ['a loli.tase.x image', 3],
+ ['a loli_tanu_de image', 3],
+ ['a loli_tapo_rn image', 3],
+ ['a loli_tase_x image', 3],
+ ['a l|o|l|i|t|a|n|u|d|e image', 3],
+ ['a l|o|l|i|t|a|p|o|r|n image', 3],
+ ['a l|o|l|i|t|a|s|e|x image', 3],
+ ['a l~o~l~i~t~a~n~u~d~e image', 3],
+ ['a l~o~l~i~t~a~p~o~r~n image', 3],
+ ['a l~o~l~i~t~a~s~e~x image', 3],
+ ['achildporn', 3],
+ ['achildpornography', 3],
+ ['acsam', 3],
+ ['ajailbait', 3],
+ ['alolitanude', 3],
+ ['alolitaporn', 3],
+ ['alolitasex', 3],
+ ['c h i l d p o r n', 3],
+ ['c h i l d p o r n o g r a p h y', 3],
+ ['c s a m', 3],
+ ['c#h#i#l#d#p#o#r#n', 3],
+ ['c#h#i#l#d#p#o#r#n#o#g#r#a#p#h#y', 3],
+ ['c#s#a#m', 3],
+ ['c*h*i*l*d*p*o*r*n', 3],
+ ['c*h*i*l*d*p*o*r*n*o*g*r*a*p*h*y', 3],
+ ['c*s*a*m', 3],
+ ['c+h+i+l+d+p+o+r+n', 3],
+ ['c+h+i+l+d+p+o+r+n+o+g+r+a+p+h+y', 3],
+ ['c+s+a+m', 3],
+ ['c,h,i,l,d,p,o,r,n', 3],
+ ['c,h,i,l,d,p,o,r,n,o,g,r,a,p,h,y', 3],
+ ['c,s,a,m', 3],
+ ['c/h/i/l/d/p/o/r/n', 3],
+ ['c/h/i/l/d/p/o/r/n/o/g/r/a/p/h/y', 3],
+ ['c/s/a/m', 3],
+ ['c:h:i:l:d:p:o:r:n', 3],
+ ['c:h:i:l:d:p:o:r:n:o:g:r:a:p:h:y', 3],
+ ['c:s:a:m', 3],
+ ['c;h;i;l;d;p;o;r;n', 3],
+ ['c;h;i;l;d;p;o;r;n;o;g;r;a;p;h;y', 3],
+ ['c;s;a;m', 3],
+ ['ch il dp or n', 3],
+ ['ch il dp or no gr ap hy', 3],
+ ['ch il dp or n', 3],
+ ['ch il dp or no gr ap hy', 3],
+ ['ch, il, dp, or, n', 3],
+ ['ch, il, dp, or, no, gr, ap, hy', 3],
+ ['ch-il-dp-or-n', 3],
+ ['ch-il-dp-or-no-gr-ap-hy', 3],
+ ['ch.il.dp.or.n', 3],
+ ['ch.il.dp.or.no.gr.ap.hy', 3],
+ ['ch_il_dp_or_n', 3],
+ ['ch_il_dp_or_no_gr_ap_hy', 3],
+ ['chi ldp orn', 3],
+ ['chi ldp orn ogr aph y', 3],
+ ['chi ldp orn', 3],
+ ['chi ldp orn ogr aph y', 3],
+ ['chi, ldp, orn', 3],
+ ['chi, ldp, orn, ogr, aph, y', 3],
+ ['chi-ldp-orn', 3],
+ ['chi-ldp-orn-ogr-aph-y', 3],
+ ['chi.ldp.orn', 3],
+ ['chi.ldp.orn.ogr.aph.y', 3],
+ ['chi_ldp_orn', 3],
+ ['chi_ldp_orn_ogr_aph_y', 3],
+ ['chil dpor n', 3],
+ ['chil dpor nogr aphy', 3],
+ ['chil dpor n', 3],
+ ['chil dpor nogr aphy', 3],
+ ['chil, dpor, n', 3],
+ ['chil, dpor, nogr, aphy', 3],
+ ['chil-dpor-n', 3],
+ ['chil-dpor-nogr-aphy', 3],
+ ['chil.dpor.n', 3],
+ ['chil.dpor.nogr.aphy', 3],
+ ['chil_dpor_n', 3],
+ ['chil_dpor_nogr_aphy', 3],
+ ['childpornimage', 3],
+ ['childpornographyimage', 3],
+ ['cs am', 3],
+ ['cs am', 3],
+ ['cs, am', 3],
+ ['cs-am', 3],
+ ['cs.am', 3],
+ ['cs_am', 3],
+ ['csa m', 0],
+ ['csa m', 0],
+ ['csa, m', 0],
+ ['csa-m', 3],
+ ['csa.m', 3],
+ ['csa_m', 3],
+ ['csam', 3],
+ ['csamimage', 3],
+ ['c|h|i|l|d|p|o|r|n', 3],
+ ['c|h|i|l|d|p|o|r|n|o|g|r|a|p|h|y', 3],
+ ['c|s|a|m', 3],
+ ['c~h~i~l~d~p~o~r~n', 3],
+ ['c~h~i~l~d~p~o~r~n~o~g~r~a~p~h~y', 3],
+ ['c~s~a~m', 3],
+ ['j a i l b a i t', 3],
+ ['j#a#i#l#b#a#i#t', 3],
+ ['j*a*i*l*b*a*i*t', 3],
+ ['j+a+i+l+b+a+i+t', 3],
+ ['j,a,i,l,b,a,i,t', 3],
+ ['j/a/i/l/b/a/i/t', 3],
+ ['j:a:i:l:b:a:i:t', 3],
+ ['j;a;i;l;b;a;i;t', 3],
+ ['ja il ba it', 3],
+ ['ja il ba it', 3],
+ ['ja, il, ba, it', 3],
+ ['ja-il-ba-it', 3],
+ ['ja.il.ba.it', 3],
+ ['ja_il_ba_it', 3],
+ ['jai lba it', 3],
+ ['jai lba it', 3],
+ ['jai, lba, it', 3],
+ ['jai-lba-it', 3],
+ ['jai.lba.it', 3],
+ ['jai_lba_it', 3],
+ ['jail bait', 3],
+ ['jail bait', 3],
+ ['jail, bait', 3],
+ ['jail-bait', 3],
+ ['jail.bait', 3],
+ ['jail_bait', 3],
+ ['jailbaitimage', 3],
+ ['j|a|i|l|b|a|i|t', 3],
+ ['j~a~i~l~b~a~i~t', 3],
+ ['l o l i t a n u d e', 3],
+ ['l o l i t a p o r n', 3],
+ ['l o l i t a s e x', 3],
+ ['l#o#l#i#t#a#n#u#d#e', 3],
+ ['l#o#l#i#t#a#p#o#r#n', 3],
+ ['l#o#l#i#t#a#s#e#x', 3],
+ ['l*o*l*i*t*a*n*u*d*e', 3],
+ ['l*o*l*i*t*a*p*o*r*n', 3],
+ ['l*o*l*i*t*a*s*e*x', 3],
+ ['l+o+l+i+t+a+n+u+d+e', 3],
+ ['l+o+l+i+t+a+p+o+r+n', 3],
+ ['l+o+l+i+t+a+s+e+x', 3],
+ ['l,o,l,i,t,a,n,u,d,e', 3],
+ ['l,o,l,i,t,a,p,o,r,n', 3],
+ ['l,o,l,i,t,a,s,e,x', 3],
+ ['l/o/l/i/t/a/n/u/d/e', 3],
+ ['l/o/l/i/t/a/p/o/r/n', 3],
+ ['l/o/l/i/t/a/s/e/x', 3],
+ ['l:o:l:i:t:a:n:u:d:e', 3],
+ ['l:o:l:i:t:a:p:o:r:n', 3],
+ ['l:o:l:i:t:a:s:e:x', 3],
+ ['l;o;l;i;t;a;n;u;d;e', 3],
+ ['l;o;l;i;t;a;p;o;r;n', 3],
+ ['l;o;l;i;t;a;s;e;x', 3],
+ ['lo li ta nu de', 3],
+ ['lo li ta po rn', 3],
+ ['lo li ta se x', 3],
+ ['lo li ta nu de', 3],
+ ['lo li ta po rn', 3],
+ ['lo li ta se x', 3],
+ ['lo, li, ta, nu, de', 3],
+ ['lo, li, ta, po, rn', 3],
+ ['lo, li, ta, se, x', 3],
+ ['lo-li-ta-nu-de', 3],
+ ['lo-li-ta-po-rn', 3],
+ ['lo-li-ta-se-x', 3],
+ ['lo.li.ta.nu.de', 3],
+ ['lo.li.ta.po.rn', 3],
+ ['lo.li.ta.se.x', 3],
+ ['lo_li_ta_nu_de', 3],
+ ['lo_li_ta_po_rn', 3],
+ ['lo_li_ta_se_x', 3],
+ ['lol ita nud e', 3],
+ ['lol ita por n', 3],
+ ['lol ita sex', 3],
+ ['lol ita nud e', 3],
+ ['lol ita por n', 3],
+ ['lol ita sex', 3],
+ ['lol, ita, nud, e', 3],
+ ['lol, ita, por, n', 3],
+ ['lol, ita, sex', 3],
+ ['lol-ita-nud-e', 3],
+ ['lol-ita-por-n', 3],
+ ['lol-ita-sex', 3],
+ ['lol.ita.nud.e', 3],
+ ['lol.ita.por.n', 3],
+ ['lol.ita.sex', 3],
+ ['lol_ita_nud_e', 3],
+ ['lol_ita_por_n', 3],
+ ['lol_ita_sex', 3],
+ ['loli tanu de', 3],
+ ['loli tapo rn', 3],
+ ['loli tase x', 3],
+ ['loli tanu de', 3],
+ ['loli tapo rn', 3],
+ ['loli tase x', 3],
+ ['loli, tanu, de', 3],
+ ['loli, tapo, rn', 3],
+ ['loli, tase, x', 3],
+ ['loli-tanu-de', 3],
+ ['loli-tapo-rn', 3],
+ ['loli-tase-x', 3],
+ ['loli.tanu.de', 3],
+ ['loli.tapo.rn', 3],
+ ['loli.tase.x', 3],
+ ['loli_tanu_de', 3],
+ ['loli_tapo_rn', 3],
+ ['loli_tase_x', 3],
+ ['lolitanudeimage', 3],
+ ['lolitapornimage', 3],
+ ['lolitaseximage', 3],
+ ['l|o|l|i|t|a|n|u|d|e', 3],
+ ['l|o|l|i|t|a|p|o|r|n', 3],
+ ['l|o|l|i|t|a|s|e|x', 3],
+ ['l~o~l~i~t~a~n~u~d~e', 3],
+ ['l~o~l~i~t~a~p~o~r~n', 3],
+ ['l~o~l~i~t~a~s~e~x', 3],
+ ['mychildpornfile', 3],
+ ['mychildpornographyfile', 3],
+ ['mycsamfile', 3],
+ ['myjailbaitfile', 3],
+ ['mylolitanudefile', 3],
+ ['mylolitapornfile', 3],
+ ['mylolitasexfile', 3],
+ ['thechildpornlist', 3],
+ ['thechildpornographylist', 3],
+ ['thecsamlist', 3],
+ ['thejailbaitlist', 3],
+ ['thelolitanudelist', 3],
+ ['thelolitapornlist', 3],
+ ['thelolitasexlist', 3],
+ ['xxchildpornographyxx', 3],
+ ['xxchildpornxx', 3],
+ ['xxcsamxx', 3],
+ ['xxjailbaitxx', 3],
+ ['xxlolitanudexx', 3],
+ ['xxlolitapornxx', 3],
+ ['xxlolitasexxx', 3],]
+
+describe('frozen floor: every pattern stays at or above its historically measured minimum', () => {
+ it('CURRENT never drops below the frozen minimum rank for any pattern', () => {
+ const regressions: string[] = []
+ for (const [pattern, minRank] of FROZEN_FLOOR) {
+ const actual = rank(currentCheck(pattern))
+ if (actual < minRank) {
+ regressions.push(`"${pattern}": expected >= ${minRank}, got ${actual} (${JSON.stringify(currentCheck(pattern))})`)
+ }
+ }
+ expect(regressions, regressions.join('\n')).toEqual([])
+ })
+
+ it('sanity: the table is not degenerate', () => {
+ expect(FROZEN_FLOOR.length).toBeGreaterThan(400)
+ const atFullStrength = FROZEN_FLOOR.filter(([, r]) => r === 3).length
+ const accepted = FROZEN_FLOOR.filter(([, r]) => r < 3).length
+ expect(atFullStrength).toBeGreaterThan(400)
+ // The accepted, named exception (residual chunked/glued "csam" over the
+ // glue boundary) is small and counted; if this grows without a matching
+ // update to safety.ts's own comments, something regenerated the table
+ // over a real weakening instead of a reviewed one.
+ expect(accepted).toBeLessThanOrEqual(10)
+ })
+})
diff --git a/src/lib/render/__tests__/safety-strength-regression.test.ts b/src/lib/render/__tests__/safety-strength-regression.test.ts
index 1f840922..85c2367a 100644
--- a/src/lib/render/__tests__/safety-strength-regression.test.ts
+++ b/src/lib/render/__tests__/safety-strength-regression.test.ts
@@ -86,6 +86,36 @@ let oldCheck: CheckFn
let weakCheck: CheckFn
let partialCheck: CheckFn
+/**
+ * Schlusspruefung Inhaltsschutz (Opus 5, 18.09.2026), Punkt 4: `ci.yml`
+ * checks out with the `actions/checkout` default `fetch-depth: 1` (a
+ * shallow clone), so `git show 03f98fdd~1:...` cannot resolve the object
+ * and this whole file went RED in CI, not skipped. `git cat-file -e` here
+ * is the same synchronous, side-effect-free check `katalog-paritaet-web`
+ * uses for a missing Web checkout, applied to a missing git object instead
+ * of a missing file. This gates the describe blocks below so a shallow
+ * checkout SKIPS them loudly (stderr message) instead of failing; a
+ * fetch-depth fix (or a normal, unshallowed local clone) makes them run
+ * again automatically. The frozen-floor table in
+ * safety-frozen-floor.test.ts does not need any of this: it carries no git
+ * dependency at all and is what actually guards CI.
+ */
+function hasGitObject(sha: string): boolean {
+ try {
+ execFileSync('git', ['cat-file', '-e', `${sha}:${PATH_IN_REPO}`], { cwd: REPO_ROOT, stdio: 'ignore' })
+ return true
+ } catch {
+ return false
+ }
+}
+const HAS_DESKTOP_HISTORY = hasGitObject(OLD_SHA) && hasGitObject(WEAK_SHA) && hasGitObject(PARTIAL_SHA)
+const HISTORY_GRUND =
+ '[safety-strength-regression] Vergleich gegen historische Desktop-Fassungen uebersprungen: ' +
+ `git-Objekte fuer ${OLD_SHA}, ${WEAK_SHA} oder ${PARTIAL_SHA} nicht erreichbar (flacher Checkout? ` +
+ 'fetch-depth). Der git-unabhaengige Waechter mit demselben Anspruch steht in ' +
+ 'safety-frozen-floor.test.ts und laeuft immer.'
+if (!HAS_DESKTOP_HISTORY) process.stderr.write(HISTORY_GRUND + '\n')
+
async function loadFromGit(cwd: string, sha: string, pathInRepo: string): Promise<CheckFn> {
const source = execFileSync('git', ['show', `${sha}:${pathInRepo}`], {
cwd,
@@ -99,6 +129,7 @@ async function loadFromGit(cwd: string, sha: string, pathInRepo: string): Promis
}
beforeAll(async () => {
+ if (!HAS_DESKTOP_HISTORY) return
oldCheck = await loadFromGit(REPO_ROOT, OLD_SHA, PATH_IN_REPO)
weakCheck = await loadFromGit(REPO_ROOT, WEAK_SHA, PATH_IN_REPO)
partialCheck = await loadFromGit(REPO_ROOT, PARTIAL_SHA, PATH_IN_REPO)
@@ -285,7 +316,7 @@ const LEGITIMATE_PROMPTS = [
'a minority report style poster',
]
-describe('B1 (Runde 1): the fix is never weaker than the pre-regression version', () => {
+describe.skipIf(!HAS_DESKTOP_HISTORY)('B1 (Runde 1): the fix is never weaker than the pre-regression version', () => {
it('every strict probe (letter-spaced + long-term chunked): CURRENT rank >= OLD (03f98fdd~1) rank', () => {
const regressions: string[] = []
for (const text of STRICT_PROBES) {
@@ -316,7 +347,7 @@ describe('B1 (Runde 1): the fix is never weaker than the pre-regression version'
})
})
-describe('B1 (Runde 4): the fix is never weaker than the WEAK (03f98fdd) fassung either', () => {
+describe.skipIf(!HAS_DESKTOP_HISTORY)('B1 (Runde 4): the fix is never weaker than the WEAK (03f98fdd) fassung either', () => {
it('every strict probe (letter-spaced + long-term chunked): CURRENT rank >= WEAK (03f98fdd) rank', () => {
const regressions: string[] = []
for (const text of STRICT_PROBES) {
@@ -337,19 +368,22 @@ describe('B1 (Runde 4): the fix is never weaker than the WEAK (03f98fdd) fassung
* CURRENT closes that gap completely for the long terms (STRICT_PROBES
* above, zero regressions) and leaves only chunked/glued "csam" open,
* measured here so a future change cannot silently regress it further:
- * this count may only go DOWN. It is not required to be zero, because
- * closing it fully (matching a bare "csam" glued inside a longer token,
- * e.g. "xxcsamxx", or split as "cs am") would require a whole-string check
- * on "csam" itself, which reintroduces the false-alarm class in
- * LEGITIMATE_PROMPTS above (review-w2ui.md, Runde 4: "der Rest ist
- * ausschliesslich csam-Verklebung ... und ohne Teilstringsuche auf vier
- * Buchstaben nicht zu haben").
+ * this count may only go DOWN. It is not required to be zero: Schlusspruefung
+ * Inhaltsschutz (Opus 5, 18.09.2026) measured that fully closing it (a bare
+ * "csam" glued inside a longer token via arbitrary-length chains, not just
+ * an adjacent pair) needs a whole-string check on "csam" itself, which
+ * reintroduces the false-alarm class in LEGITIMATE_PROMPTS above. Variante
+ * C from that same review (per-whitespace-token compaction plus gluing two
+ * ADJACENT tokens of at most 2 characters each, see
+ * SHORT_TERM_GLUE_MAX_LENGTH in safety.ts) closes most of what is left
+ * without reopening that false alarm; the residual below is what stays
+ * open after Variante C, not before it.
*/
it('residual gap on chunked/glued "csam" probes against OLD: measured, may only shrink', () => {
const stillWeakerThanOld = CSAM_CHUNK_PROBES.filter((t) => rank(currentCheck(t)) < rank(oldCheck(t)))
- // Measured on this probe list (41 chunked/glued "csam" probes): 29. May
- // only shrink from here.
- const RESIDUAL_CEILING_OLD = 29
+ // Measured on this probe list (41 chunked/glued "csam" probes) after
+ // Variante C: 6 (was 29 before it). May only shrink from here.
+ const RESIDUAL_CEILING_OLD = 6
expect(
stillWeakerThanOld.length,
`residual vs OLD: ${stillWeakerThanOld.length} of ${CSAM_CHUNK_PROBES.length}\n${stillWeakerThanOld.join('\n')}`,
@@ -358,9 +392,9 @@ describe('B1 (Runde 4): the fix is never weaker than the WEAK (03f98fdd) fassung
it('residual gap on chunked/glued "csam" probes against WEAK: measured, may only shrink', () => {
const stillWeakerThanWeak = CSAM_CHUNK_PROBES.filter((t) => rank(currentCheck(t)) < rank(weakCheck(t)))
- // Measured on this probe list (41 chunked/glued "csam" probes): 25. May
- // only shrink from here.
- const RESIDUAL_CEILING_WEAK = 25
+ // Measured on this probe list (41 chunked/glued "csam" probes) after
+ // Variante C: 4 (was 25 before it). May only shrink from here.
+ const RESIDUAL_CEILING_WEAK = 4
expect(
stillWeakerThanWeak.length,
`residual vs WEAK: ${stillWeakerThanWeak.length} of ${CSAM_CHUNK_PROBES.length}\n${stillWeakerThanWeak.join('\n')}`,
@@ -374,14 +408,16 @@ describe('B1: zero false alarms on ordinary prompts', () => {
expect(currentCheck(text).blocked, text).toBe(false)
}
})
+})
+describe.skipIf(!HAS_DESKTOP_HISTORY)('B1: zero false alarms on ordinary prompts (historischer Beleg)', () => {
it('sanity: ALT and WEAK both DID false-alarm on several of these (that is why the whole-string check on "csam" was removed, not just narrowed)', () => {
const oldFalseAlarms = LEGITIMATE_PROMPTS.filter((t) => oldCheck(t).blocked)
expect(oldFalseAlarms.length).toBeGreaterThan(0)
})
})
-describe('NEGATIVE CONTROL: the checks above have teeth', () => {
+describe.skipIf(!HAS_DESKTOP_HISTORY)('NEGATIVE CONTROL: the checks above have teeth', () => {
it('WEAK (03f98fdd) IS measurably weaker than OLD on the full probe list', () => {
const regressions = ALL_PROBES.filter((t) => rank(weakCheck(t)) < rank(oldCheck(t)))
// This is the point of the "never weaker than OLD" describe block above:
@@ -410,6 +446,81 @@ describe('NEGATIVE CONTROL: the checks above have teeth', () => {
})
})
+/**
+ * Variante C (Schlusspruefung Inhaltsschutz, Opus 5, 18.09.2026): the
+ * short-term ("csam") check in safety.ts glues two ADJACENT whitespace
+ * tokens when both are at most SHORT_TERM_GLUE_MAX_LENGTH (2) characters
+ * long. This directly exercises that mechanism and the false-alarm
+ * boundary it was measured against, WITHOUT reading an external word list:
+ * a large-scale sweep (235976 words of the system dictionary as single
+ * tokens and as pairs, 46 ordinary prompts) was run by hand for this round
+ * and is not repeated here on every CI run; this is the fast, portable
+ * regression guard for the same mechanism.
+ */
+describe('Variante C: the short-term token-glue check', () => {
+ it('catches a two-block split of "csam" (both blocks at most 2 characters)', () => {
+ for (const text of ['cs am', 'a cs am image', 'cs.am', 'cs-am', 'cs_am']) {
+ expect(currentCheck(text).blocked, text).toBe(true)
+ expect(currentCheck(text).reason, text).toBe('csam')
+ }
+ })
+
+ it('catches "csam" glued inside a longer single token (no real space)', () => {
+ for (const text of ['xxcsamxx', 'mycsamfile', 'thecsamlist', 'acsam', 'csamimage']) {
+ expect(currentCheck(text).blocked, text).toBe(true)
+ expect(currentCheck(text).reason, text).toBe('csam')
+ }
+ })
+
+ it('does NOT glue across a block longer than 2 characters ("csa m" stays open, a known accepted residual)', () => {
+ // Documents the boundary, not a gap to close here: "csa"(3) + "m"(1)
+ // does not satisfy "both <= 2", by design (see safety.ts comment on
+ // SHORT_TERM_GLUE_MAX_LENGTH). Counted in the residual-ceiling tests
+ // above.
+ expect(currentCheck('csa m').blocked).toBe(false)
+ })
+
+ it('never blocks two-letter English words placed next to each other (the false-alarm boundary the bound of 2 was measured against)', () => {
+ // Every common two-letter (or shorter) English word next to every other
+ // one of them: none of the 26*26 pairings spells "csam". This mirrors
+ // the review's 165-real-word, 27225-pair dictionary sweep at a size that
+ // runs on every CI invocation without reading an external file.
+ const SHORT_WORDS = [
+ 'a', 'i', 'am', 'an', 'as', 'at', 'be', 'by', 'do', 'go', 'he', 'if',
+ 'in', 'is', 'it', 'me', 'my', 'no', 'of', 'on', 'or', 'so', 'to', 'up',
+ 'us', 'we',
+ ]
+ const falseAlarms: string[] = []
+ for (const a of SHORT_WORDS) {
+ for (const b of SHORT_WORDS) {
+ const text = `${a} ${b}`
+ if (currentCheck(text).blocked) falseAlarms.push(text)
+ }
+ }
+ expect(falseAlarms, falseAlarms.join(', ')).toEqual([])
+ })
+
+ it('REJECTED variant, documented not shipped: gluing when only ONE neighbor is short (not both) DOES false-alarm ("vitamin c samples")', () => {
+ // Not implemented in safety.ts: SHORT_TERM_GLUE_MAX_LENGTH gates on BOTH
+ // neighbors. This test proves why, by reimplementing the rejected
+ // "at least one" rule locally and showing it flags an ordinary sentence
+ // that the shipped "both" rule correctly lets through.
+ const compactToken = (t: string) => t.replace(/[^a-z0-9]+/g, '')
+ const looseGlueHits = (text: string): boolean => {
+ const tokens = text.toLowerCase().split(/\s+/).filter(Boolean).map(compactToken)
+ if (tokens.some((t) => t.includes('csam'))) return true
+ for (let i = 0; i + 1 < tokens.length; i++) {
+ const a = tokens[i]
+ const b = tokens[i + 1]
+ if ((a.length <= 2 || b.length <= 2) && (a + b).includes('csam')) return true
+ }
+ return false
+ }
+ expect(looseGlueHits('vitamin c samples')).toBe(true)
+ expect(currentCheck('vitamin c samples').blocked).toBe(false)
+ })
+})
+
describe.skipIf(!WEB)('B1 gegen Webs main-Branch (die heute produktive Fassung)', () => {
it('CURRENT ist gegen Webs main auf keiner strengen Probe schwaecher', () => {
const regressions: string[] = []
diff --git a/src/lib/render/safety.ts b/src/lib/render/safety.ts
index 501fed84..39cbadbd 100644
--- a/src/lib/render/safety.ts
+++ b/src/lib/render/safety.ts
@@ -222,11 +222,50 @@ export function checkPromptSafety(
// above for why "csam" is excluded from this check and stays run-only.
const compactAll = base.replace(/[^a-z0-9]+/g, '')
const compactLeet = deleeted.replace(/[^a-z0-9]+/g, '')
+ // Schlusspruefung Inhaltsschutz (Opus 5, 18.09.2026), Variante C: closes
+ // most of what is left for the SHORT term ("csam") after the checks above,
+ // without reopening the whole-string false alarm MIN_WHOLE_STRING_TERM_LENGTH
+ // exists to avoid. Two parts, both scoped to real whitespace, never
+ // merging two ordinary words across a plain space:
+ // 1) compact EACH whitespace-token on its own ("c*s*a*m" -> "csam" is
+ // one token, no real space inside) and test it for "csam" as a
+ // substring. Measured safe: 0 hits trying every one of the 235976
+ // words in the system dictionary as "a WORD image".
+ // 2) additionally glue two ADJACENT tokens when BOTH are at most
+ // SHORT_TERM_GLUE_MAX_LENGTH characters long (after compaction), to
+ // catch a two-block split like "cs am" that step 1 alone cannot see
+ // (neither token contains "csam" by itself, and `runs` above does not
+ // apply either: a two-or-more-character block is not a
+ // single-character run). The bound is measured, not guessed: at 2,
+ // zero false alarms across the same dictionary check pairwise (165
+ // real words of that length, 27225 pairs) and across a set of
+ // ordinary prompts; at 3, two of those pairs read as ordinary short
+ // English prose and would false-alarm. Never raise this bound without
+ // re-measuring both.
+ // Reduces the measured residual for chunked/glued "csam" by 67% against
+ // the currently-live production fassung and 86% against the fassung
+ // before the original regression, at zero new false alarms.
+ const SHORT_TERM_GLUE_MAX_LENGTH = 2
+ const compactToken = (t: string) => t.replace(/[^a-z0-9]+/g, '')
+ const tokenCompactions = (text: string) => text.split(/\s+/).filter(Boolean).map(compactToken)
+ const shortTermHits = (tokens: string[]) => {
+ if (tokens.some((t) => t.includes('csam'))) return true
+ for (let i = 0; i + 1 < tokens.length; i++) {
+ const a = tokens[i]
+ const b = tokens[i + 1]
+ if (a.length <= SHORT_TERM_GLUE_MAX_LENGTH && b.length <= SHORT_TERM_GLUE_MAX_LENGTH && (a + b).includes('csam')) {
+ return true
+ }
+ }
+ return false
+ }
if (
readable.some((t) => ALWAYS_BLOCKED.test(t)) ||
runs.some((r) => ALWAYS_BLOCKED_COMPACT.test(r)) ||
LONG_COMPACT.test(compactAll) ||
- LONG_COMPACT.test(compactLeet)
+ LONG_COMPACT.test(compactLeet) ||
+ shortTermHits(tokenCompactions(base)) ||
+ shortTermHits(tokenCompactions(deleeted))
) {
return { blocked: true, reason: 'csam' }
}