code wiki / _hdl_build / nx_connect_fair_rank.nx
nx_connect_fair_rank.nx
buildroot/runtime/_hdl_build/nx_connect_fair_rank.nx
about
nx_connect_fair_rank.nx -- CONNECT capability: FAIRNESS-BY-CONSTRUCTION ranking (the CIQ roadmap's #1
vision build; incumbents score 0 here -- popularity-biased ranking -> paid boosts -> rich-get-richer).
This is a REAL, principled exposure-fair re-ranker: each round we recommend the top-S candidates, but
the FAIR policy discounts each candidate's relevance by the attention it has already received
(score = quality*SCALE/(exposure+1)), so exposure rotates to relevant-but-under-shown profiles instead
of concentrating on a fixed few. The MEASURED head-to-head proves the exceed, BY CONSTRUCTION:
- INCUMBENT (popularity): rank by pure quality every round -> the same top-S monopolize exposure.
- NISHI (fair): rank by exposure-discounted quality -> exposure spreads.
We measure exposure inequality via the integer Gini coefficient (permil) for BOTH, plus the relevance
delivered (sum of shown qualities). GATE (no-float, named thresholds): FAIR Gini must be < half the
popularity Gini (a real fairness exceed), AND FAIR must retain >= RELEVANCE_FLOOR_PCT of popularity's
relevance (we do not tank quality to get fairness). 100% sovereign, integer-exact. license_tier: ORIGINAL expect_exit: 0
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 15 | const FR_M: i64 = 8 // candidate profiles |
| 16 | const FR_K: i64 = 40 // recommendation rounds |
| 17 | const FR_S: i64 = 3 // slots shown per round |
| 18 | const FR_GINI_HALVE: i64 = 2 // FAIR Gini must be < POP Gini / FR_GINI_HALVE (fairness exceed margin) |
| 19 | const FR_REL_FLOOR_PCT: i64 = 70 // FAIR relevance must be >= this % of POP relevance |
functions
| 21 | func rw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 22 | func rn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1} sys_write(1,bb,k); return 0 } |
| 25 | func gini_permil(x: *i64, n: i64) -> i64 called by 1: main |
| 36 | func simulate(q: *i64, expo: *i64, fair: i64) -> i64 |
| 68 | func main() -> i64 |