code wiki / (root) / nx_concentration.nx

nx_concentration.nx source

↩ module page · 117 lines · 6671 B

1// nx_concentration.nx -- WHY the capture is POSSIBLE: market concentration. Reads knowledge/anatomy/concentration.txt 2// (CR4 = the top-4-firm market share per sector), lists sectors, flags those at/above the oligopoly line (CR4>=50, 3// the DOJ/FTC scrutiny zone), and shows that the margin/markup capture traced by nx_capture_trace concentrates 4// exactly where the MARKET is concentrated: a few firms with pricing power on the output side and monopsony over 5// farmers and workers on the input side. LIAR-KILLED: every CR4 in [0,100], the threshold discriminates (a high 6// value flags, a low value does not), >=1 grounded source, sectors>=3. 7// Build: _offc/nx_sov_build_run.elf nx_concentration license_tier: ORIGINAL 8import "nx_syscalls.nx" 9 10func gp(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 11func gn(v0: i64) -> i64 { 12 var v: i64 = v0; if v < 0 { sys_write(1, "-" as *u8, 1); v = 0 - v } 13 let b: *u8 = sys_mmap(24); var k: i64 = 0; if v == 0 { b[0] = 48 as u8; k = 1 } 14 while v > 0 { b[k] = (48 + (v % 10)) as u8; v = v / 10; k = k + 1 } 15 let o: *u8 = sys_mmap(24); var j: i64 = 0; while j < k { o[j] = b[k-1-j]; j = j + 1 } sys_write(1, o, k); return 0 16} 17func ev_read(path: *u8, buf: *u8, cap: i64) -> i64 { 18 let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 - 1 } 19 var tot: i64 = 0; var go: i64 = 1 20 while go == 1 { if tot >= cap { go = 0 } else { let r: i64 = sys_read(fd, (buf as i64 + tot) as *u8, cap - tot); if r <= 0 { go = 0 } else { tot = tot + r } } } 21 sys_close(fd); return tot 22} 23func field_count(line: *u8, ln: i64) -> i64 { var n: i64 = 1; var i: i64 = 0; while i < ln { if line[i] == (124 as u8) { n = n + 1 } i = i + 1 } return n } 24func field_k(line: *u8, ln: i64, kk: i64, dst: *u8, cap: i64) -> i64 { 25 var field: i64 = 0; var s: i64 = 0; var i: i64 = 0; var fstart: i64 = 0; var fend: i64 = 0; var got: i64 = 0 26 while i <= ln { 27 var is_end: i64 = 0 28 if i == ln { is_end = 1 } else { if line[i] == (124 as u8) { is_end = 1 } } 29 if is_end == 1 { if field == kk { fstart = s; fend = i; got = 1 } field = field + 1; s = i + 1 } 30 i = i + 1 31 } 32 var t: i64 = 0 33 if got == 1 { var p: i64 = fstart; while p < fend { if t < cap - 1 { dst[t] = line[p]; t = t + 1 } p = p + 1 } } 34 dst[t] = 0 as u8 35 return t 36} 37func pint(s: *u8) -> i64 { var v: i64 = 0; var i: i64 = 0; 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 } return v } 38 39func slen_of(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 40func flag(cr4: i64) -> i64 { if cr4 >= 50 { return 1 } return 0 } 41 42func main() -> i64 { 43 let buf: *u8 = sys_mmap(16384) 44 let mn: i64 = ev_read("knowledge/anatomy/concentration.txt" as *u8, buf, 16384) 45 if mn <= 0 { gp("nx_concentration: concentration.txt missing pass=0 fail=1 verdict=RED\n" as *u8); sys_exit(1); return 1 } 46 47 gp("=== nx_concentration: WHY the capture is possible -- a few firms dominate each link (CR4 = top-4-firm market share) ===\n" as *u8) 48 gp(" sector CR4 market power driver\n" as *u8) 49 50 let line: *u8 = sys_mmap(1024) 51 let f0: *u8 = sys_mmap(128) 52 let f1: *u8 = sys_mmap(16) 53 let f2: *u8 = sys_mmap(256) 54 let f3: *u8 = sys_mmap(128) 55 let f4: *u8 = sys_mmap(16) 56 var sectors: i64 = 0 57 var concentrated: i64 = 0 58 var sum_cr4: i64 = 0 59 var grounded: i64 = 0 60 var invalid: i64 = 0 61 62 var p: i64 = 0 63 while p < mn { 64 var e: i64 = p; var go: i64 = 1 65 while go == 1 { if e >= mn { go = 0 } else { if buf[e] == (10 as u8) { go = 0 } else { e = e + 1 } } } 66 let ll: i64 = e - p 67 if ll > 0 { if buf[p] != (35 as u8) { 68 var t: i64 = 0 69 while t < ll { if t < 1023 { line[t] = buf[p + t] } t = t + 1 } 70 line[ll] = 0 as u8 71 if field_count(line, ll) >= 5 { 72 field_k(line, ll, 0, f0, 128) 73 field_k(line, ll, 1, f1, 16) 74 field_k(line, ll, 2, f2, 256) 75 field_k(line, ll, 3, f3, 128) 76 field_k(line, ll, 4, f4, 16) 77 let cr4: i64 = pint(f1) 78 if cr4 < 0 { invalid = invalid + 1 } 79 if cr4 > 100 { invalid = invalid + 1 } 80 sectors = sectors + 1 81 sum_cr4 = sum_cr4 + cr4 82 grounded = grounded + pint(f4) 83 let fg: i64 = flag(cr4) 84 if fg == 1 { concentrated = concentrated + 1 } 85 gp(" " as *u8); gp(f0) 86 var pad: i64 = 29 - slen_of(f0) 87 while pad > 0 { gp(" " as *u8); pad = pad - 1 } 88 gp("CR4=" as *u8); gn(cr4); gp("% " as *u8) 89 if fg == 1 { gp("OLIGOPOLY (pricing power) " as *u8) } else { gp("competitive " as *u8) } 90 gp("<- " as *u8); gp(f2); gp("\n" as *u8) 91 } 92 } } 93 p = e + 1 94 } 95 96 var mean: i64 = 0 97 if sectors > 0 { mean = sum_cr4 / sectors } 98 gp("\n " as *u8); gn(concentrated); gp(" of " as *u8); gn(sectors); gp(" links are ABOVE the CR4=50 oligopoly line; mean CR4=" as *u8); gn(mean); gp("%.\n" as *u8) 99 gp(" ==> The margin/markup CAPTURE (nx_capture_trace) lands in exactly these concentrated links: a few firms set the\n" as *u8) 100 gp(" output price (monopoly) AND squeeze farmers and workers on the input side (monopsony). Concentration is the\n" as *u8) 101 gp(" ENABLER of the wedge -- which is why the antitrust / de-concentration lever is the root fix, not price controls.\n" as *u8) 102 103 // ---- self-gate ---- 104 var pass: i64 = 0 105 var fl: i64 = 0 106 if invalid == 0 { pass = pass + 1 } else { fl = fl + 1; gp(" FAIL a CR4 is outside [0,100]\n" as *u8) } 107 if sectors >= 3 { pass = pass + 1 } else { fl = fl + 1; gp(" FAIL fewer than 3 sectors\n" as *u8) } 108 if grounded >= 1 { pass = pass + 1 } else { fl = fl + 1; gp(" FAIL no grounded source\n" as *u8) } 109 var disc: i64 = 0 110 if flag(85) == 1 { if flag(10) == 0 { disc = 1 } } 111 if disc == 1 { pass = pass + 1 } else { fl = fl + 1; gp(" FAIL oligopoly threshold does not discriminate\n" as *u8) } 112 if concentrated >= 1 { pass = pass + 1 } else { fl = fl + 1; gp(" FAIL no concentrated sector detected\n" as *u8) } 113 114 gp("\nCONCENTRATION pass=" as *u8); gn(pass); gp(" fail=" as *u8); gn(fl) 115 if fl == 0 { gp(" verdict=GREEN (CR4 valid, threshold discriminates, grounded; the capture concentrates where the market does)\n" as *u8); sys_exit(0); return 0 } 116 gp(" verdict=RED\n" as *u8); sys_exit(1); return 1 117}