code wiki / _hdl_build / nx_meet_signals.nx

nx_meet_signals.nx source

↩ module page · 66 lines · 3894 B

1// nx_meet_signals.nx -- P5: the anti-fake signal table as EDITABLE DATA (LIBRARY, no main). A data-driven twin of 2// the hardcoded R6 scorer (nx_meet_trust), so an operator can tune detection -- add a buzzword, change a weight -- 3// by editing a `sig|<kind>|<dir>|<weight>|<phrase>` file, no recompile. kind=resume|posting, dir=fake(subtract)| 4// good(add). The numeric digit-bonus stays structural (a char-class, not a phrase). The gate PROVES this reproduces 5// the hardcoded reference on the R6 fixtures (so nothing regresses) AND that editing the table changes detection. 6// license_tier: ORIGINAL 7import "nx_syscalls.nx" 8import "nx_meet_lib.nx" 9import "nx_meet_trust.nx" 10const K_MAGIC_1024: i64 = 1024 11 12func sig_streq(a: *u8, b: *u8) -> i64 { 13 let al: i64 = mlen(a); let bl: i64 = mlen(b) 14 if al != bl { return 0 } 15 var i: i64 = 0 16 while i < al { if a[i] != b[i] { return 0 } i = i + 1 } 17 return 1 18} 19func sig_atoi(s: *u8) -> i64 { 20 var v: i64 = 0; var i: i64 = 0 21 while s[i] != (0 as u8) { let c: i64 = s[i] as i64; if c >= 48 { if c <= 57 { v = v * 10 + (c - 48) } } i = i + 1 } 22 return v 23} 24 25// the default signal table -- BYTE-FOR-BYTE the markers + weights hardcoded in nx_meet_trust (so the data-driven 26// scorer reproduces it exactly). The digit-bonus (+14 resume / +12 posting) stays structural in sig_score. 27func sig_default() -> *u8 { 28 return "sig|resume|fake|18|as an ai\nsig|resume|fake|18|language model\nsig|resume|fake|14|results-driven professional\nsig|resume|fake|14|passionate team player\nsig|resume|fake|10|detail-oriented\nsig|resume|fake|12|synergy\nsig|resume|fake|12|hit the ground running\nsig|resume|fake|12|think outside the box\nsig|resume|fake|10|go-getter\nsig|resume|fake|10|proven track record\nsig|resume|good|12|@\nsig|resume|good|12|http\nsig|resume|good|10|%\nsig|resume|good|8|github\nsig|posting|fake|12|competitive salary\nsig|posting|fake|12|fast-paced environment\nsig|posting|fake|18|be your own boss\nsig|posting|fake|18|unlimited earning\nsig|posting|fake|10|rockstar\nsig|posting|fake|10|ninja\nsig|posting|fake|10|wear many hats\nsig|posting|fake|12|always hiring\nsig|posting|fake|10|work hard play hard\nsig|posting|fake|10|like a family\nsig|posting|good|12|http\nsig|posting|good|12|$\nsig|posting|good|6|remote\n" as *u8 29} 30 31// score `text` (0..100, higher=authentic) using the signal table sig[0..sn). isposting selects the kind. 32func sig_score(text: *u8, isposting: i64, sig: *u8, sn: i64) -> i64 { 33 let n: i64 = mlen(text) 34 let lc: *u8 = sys_mmap(n + 16); trust_lc(text, n, lc) 35 var s: i64 = 50 36 if trust_has_digit(lc, n) == 1 { if isposting == 1 { s = s + 12 } else { s = s + 14 } } 37 let f0: *u8 = sys_mmap(16); let f1: *u8 = sys_mmap(16); let f2: *u8 = sys_mmap(16); let f3: *u8 = sys_mmap(16); let phr: *u8 = sys_mmap(K_MAGIC_1024) 38 var i: i64 = 0 39 while i < sn { 40 var le: i64 = i 41 while le < sn { if sig[le] == (10 as u8) { break } le = le + 1 } 42 mfield(sig, i, le, 0, f0, 16) 43 if sig_streq(f0, "sig" as *u8) == 1 { 44 mfield(sig, i, le, 1, f1, 16) 45 mfield(sig, i, le, 2, f2, 16) 46 mfield(sig, i, le, 3, f3, 16) 47 mfield(sig, i, le, 4, phr, K_MAGIC_1024) 48 var km: i64 = 0 49 if isposting == 1 { if sig_streq(f1, "posting" as *u8) == 1 { km = 1 } } else { if sig_streq(f1, "resume" as *u8) == 1 { km = 1 } } 50 if km == 1 { 51 if trust_has(lc, n, phr) == 1 { 52 let w: i64 = sig_atoi(f3) 53 if sig_streq(f2, "fake" as *u8) == 1 { s = s - w } else { s = s + w } 54 } 55 } 56 } 57 i = le + 1 58 } 59 if s < 0 { s = 0 } 60 if s > 100 { s = 100 } 61 return s 62} 63func sig_is_fake(text: *u8, isposting: i64, sig: *u8, sn: i64) -> i64 { 64 if sig_score(text, isposting, sig, sn) < 50 { return 1 } 65 return 0 66}