code wiki / (root) / nx_sclass_enforce_lib.nx

nx_sclass_enforce_lib.nx source

↩ module page · 26 lines · 1710 B

1// nx_sclass_enforce_lib.nx -- THE ONE canonical "gorgeous-by-default" S-class check (pure lib, no main). 2// Single source of truth for the 6 design-adoption invariants. Both the enforcement gate 3// (nx_brand_apply_enforced) and the fleet ship-gate (nx_ui_ship_gate) compose these -> zero duplicated 4// check logic (consolidation doctrine, [[feedback-sovereign-consolidation-no-shell]]). Composes 5// nx_uxcx_grade's pure byte-scan (uxg_*). license_tier: ORIGINAL 6import "nx_uxcx_grade.nx" 7 8func sce_tokens(h: *u8, n: i64) -> i64 { return uxg_has_lit(h,n,"var(--nx-" as *u8) } // canonical --nx- SSOT 9func sce_responsive(h: *u8, n: i64) -> i64 { return uxg_has_lit(h,n,"@media(max-width" as *u8) } 10func sce_motion(h: *u8, n: i64) -> i64 { return uxg_has_lit(h,n,"prefers-reduced-motion" as *u8) } 11func sce_focus(h: *u8, n: i64) -> i64 { return uxg_has_lit(h,n,":focus-visible" as *u8) } 12func sce_sovereign(h: *u8, n: i64) -> i64 { return uxg_sovereign_ok(h,n) } // no external http asset 13func sce_landmarks(h: *u8, n: i64) -> i64 { if uxg_has_lit(h,n,"<main" as *u8)==1 { return 1 } if uxg_has_lit(h,n,"<header" as *u8)==1 { if uxg_has_lit(h,n,"<footer" as *u8)==1 { return 1 } } return 0 } 14func sce_skiplink(h: *u8, n: i64) -> i64 { return uxg_skiplink_ok(h,n) } // a11y bypass (warn axis) 15 16// total violations of the 6-invariant bar. 0 = compliant (may ship). 17func sce_violations(h: *u8, n: i64) -> i64 { 18 var v: i64=0 19 if sce_tokens(h,n)==0 { v=v+1 } 20 if sce_responsive(h,n)==0 { v=v+1 } 21 if sce_motion(h,n)==0 { v=v+1 } 22 if sce_focus(h,n)==0 { v=v+1 } 23 if sce_sovereign(h,n)==0 { v=v+1 } 24 if sce_landmarks(h,n)==0 { v=v+1 } 25 return v 26}