code wiki / _hdl_build / nx_p2pdist_census.nx
nx_p2pdist_census.nx source
↩ module page · 102 lines · 8078 B
1// nx_p2pdist_census.nx -- HONEST MEASURED census of our P2P CONTENT-DISTRIBUTION ecosystem vs the June-2026
2// S-class bar (BitTorrent v1/v2, IPFS/libp2p, WebTorrent, Napster/Gnutella mesh). Drives the general
3// nx_capability_census engine against the sovereign-banked knowledge/fetched/p2pdist_*.raw corpus. Encodes today's
4// truth: we have a DEEP sovereign BitTorrent FOUNDATION (peer-wire + DHT + magnet + seeding daemon + extension
5// protocol, all live on the NAS at :18793) -- but the DISTRIBUTION-ECOSYSTEM layer the operator wants (the hub as
6// an ENABLER: data-lands -> multi-transport publish; hub<->spoke, spoke<->spoke, hub<->hub mesh) is the GAP set.
7// GREEN = measurement honest + grounded. Sovereign nx_cc->nxasm. expect_exit: 0 license_tier: ORIGINAL
8import "nx_capability_census.nx"
9import "nx_syscalls.nx"
10const K_MAGIC_2097152: i64 = 2097152
11
12func w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
13func wn(v: i64) -> i64 { var m: i64=v; if m<0{w("-" as *u8);m=0-m} let t:*u8=sys_mmap(24); 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; let o:*u8=sys_mmap(24); while i<k{o[i]=t[k-1-i];i=i+1} sys_write(1,o,k); return 0 }
14func row(label: *u8, term: *u8, organ: *u8, exceed: *u8, subj: *i64, ns: i64, buf: *u8, cap: i64, st: *i64) -> i64 {
15 let comp: i64 = cc_comp_attest(subj, ns, term, buf, cap)
16 let our: i64 = cc_our_grade(organ, exceed)
17 let v: i64 = cc_verdict(comp, our)
18 w(" "); w(cc_verdict_str(v)); w(" us="); w(cc_grade_str(our)); w(" them(src="); wn(comp); w(") "); w(label); w("\n")
19 st[0]=st[0]+1
20 if our>=3 { st[1]=st[1]+1 }
21 if our==4 { st[2]=st[2]+1 }
22 if v==3 { st[3]=st[3]+1 }
23 if v==2 { st[4]=st[4]+1 }
24 if v==1 { st[5]=st[5]+1 }
25 if v==0 { st[6]=st[6]+1 }
26 st[7]=st[7]+comp
27 return 0
28}
29
30func main() -> i64 {
31 w("=== NISHI P2P DISTRIBUTION ECOSYSTEM vs S-class (BitTorrent/IPFS/WebTorrent/Napster) -- CENSUS (Jun 2026) ===\n" as *u8)
32 w("them(src)=banked knowledge/fetched/p2pdist_*.raw. us=EXCEEDS>PRESENT>ABSENT (disk-fact, never self-scored).\n\n" as *u8)
33 let cap: i64 = K_MAGIC_2097152
34 let buf: *u8 = sys_mmap(cap)
35 let st: *i64 = sys_mmap(128) as *i64
36 var z: i64=0; while z<8 { st[z]=0; z=z+1 }
37
38 let subj: *i64 = sys_mmap(8 * 24) as *i64
39 subj[0]="knowledge/fetched/p2pdist_a_bittorrent.raw" as *u8 as i64
40 subj[1]="knowledge/fetched/p2pdist_a_p2p.raw" as *u8 as i64
41 subj[2]="knowledge/fetched/p2pdist_a_merkle.raw" as *u8 as i64
42 subj[3]="knowledge/fetched/p2pdist_a_torrentfile.raw" as *u8 as i64
43 subj[4]="knowledge/fetched/p2pdist_b_dht.raw" as *u8 as i64
44 subj[5]="knowledge/fetched/p2pdist_b_kademlia.raw" as *u8 as i64
45 subj[6]="knowledge/fetched/p2pdist_b_pex.raw" as *u8 as i64
46 subj[7]="knowledge/fetched/p2pdist_c_ipfs.raw" as *u8 as i64
47 subj[8]="knowledge/fetched/p2pdist_c_cas.raw" as *u8 as i64
48 subj[9]="knowledge/fetched/p2pdist_d_webtorrent.raw" as *u8 as i64
49 subj[10]="knowledge/fetched/p2pdist_d_webrtc.raw" as *u8 as i64
50 subj[11]="knowledge/fetched/p2pdist_e_nat.raw" as *u8 as i64
51 subj[12]="knowledge/fetched/p2pdist_e_holepunch.raw" as *u8 as i64
52 subj[13]="knowledge/fetched/p2pdist_e_stun.raw" as *u8 as i64
53 subj[14]="knowledge/fetched/p2pdist_f_napster.raw" as *u8 as i64
54 subj[15]="knowledge/fetched/p2pdist_f_gnutella.raw" as *u8 as i64
55 subj[16]="knowledge/fetched/p2pdist_f_gossip.raw" as *u8 as i64
56 subj[17]="knowledge/fetched/p2pdist_f_overlay.raw" as *u8 as i64
57 subj[18]="knowledge/fetched/p2pdist_g_cdn.raw" as *u8 as i64
58 subj[19]="knowledge/fetched/p2pdist_g_magnet.raw" as *u8 as i64
59 let ns: i64 = 20
60 let none: *u8 = "runtime/nx_DOES_NOT_EXIST_zzqq.nx" as *u8
61 let sov: *u8 = "runtime/_hdl_build/nx_portability_proof_census.nx" as *u8
62
63 w(" -- FOUNDATION we HAVE (sovereign BitTorrent stack, live on the NAS :18793) --\n" as *u8)
64 row("BITTORRENT swarm client (own peer-wire protocol)" as *u8, "BitTorrent" as *u8, "runtime/nx_peerwire.nx" as *u8, sov, subj, ns, buf, cap, st)
65 row("SEED / be a source (hub -> spoke)" as *u8, "seed" as *u8, "runtime/nx_torrent_up.nx" as *u8, none, subj, ns, buf, cap, st)
66 row("LIVE seeding daemon (persistent hub source)" as *u8, "seed" as *u8, "runtime/nx_torrent_daemon.nx" as *u8, none, subj, ns, buf, cap, st)
67 row("DHT peer discovery (Kademlia, decentralized)" as *u8, "Kademlia" as *u8, "runtime/nx_dht_get_peers.nx" as *u8, none, subj, ns, buf, cap, st)
68 row("MAGNET link (infohash content addressing)" as *u8, "magnet" as *u8, "runtime/nx_magnet.nx" as *u8, none, subj, ns, buf, cap, st)
69 row("PIECE exchange (spoke <-> spoke pieces)" as *u8, "peer" as *u8, "runtime/nx_peer_piece.nx" as *u8, none, subj, ns, buf, cap, st)
70 row("EXTENSION protocol (PEX / metadata exchange)" as *u8, "peer exchange" as *u8,"runtime/nx_peer_ext_handshake.nx" as *u8, none, subj, ns, buf, cap, st)
71 row("CONTENT-ADDRESSED store (CID / hash-keyed)" as *u8, "hash" as *u8, "runtime/nx_module_cas.nx" as *u8, none, subj, ns, buf, cap, st)
72 row("SWARM health + re-seed durability" as *u8, "seed" as *u8, "runtime/nx_torrent_health.nx" as *u8, none, subj, ns, buf, cap, st)
73 row("SOVEREIGN own P2P stack (no libtorrent/WebRTC dep)" as *u8, "BitTorrent" as *u8, "runtime/nx_torrent_get.nx" as *u8, sov, subj, ns, buf, cap, st)
74
75 w("\n -- S-CLASS-EXCEED GAPS: the distribution-ecosystem layer (the hub as ENABLER + full mesh) --\n" as *u8)
76 row("MULTI-TRANSPORT publish ENABLER (data-lands -> torrent+DL+API)" as *u8, "distribution" as *u8, "runtime/_hdl_build/nx_dist_publish.nx" as *u8, none, subj, ns, buf, cap, st)
77 row("HUB-TO-HUB replication (mesh of hubs)" as *u8, "overlay" as *u8, "runtime/_hdl_build/nx_hub_replicate.nx" as *u8, none, subj, ns, buf, cap, st)
78 row("Distribution INDEX (Napster-style: who has what)" as *u8, "Napster" as *u8, "runtime/_hdl_build/nx_dist_index.nx" as *u8, none, subj, ns, buf, cap, st)
79 row("NAT traversal / hole-punch (spoke<->spoke behind NAT)" as *u8, "hole punching" as *u8, "runtime/nx_nat_traverse.nx" as *u8, none, subj, ns, buf, cap, st)
80 row("GOSSIP / epidemic announce (mesh dissemination)" as *u8, "gossip" as *u8, "runtime/_hdl_build/nx_gossip.nx" as *u8, none, subj, ns, buf, cap, st)
81 row("BitTorrent v2 merkle (SHA-256 piece tree)" as *u8, "merkle" as *u8, "runtime/nx_bt_v2_merkle.nx" as *u8, none, subj, ns, buf, cap, st)
82
83 let total: i64=st[0]; let have: i64=st[1]; let permil: i64=(have*1000)/total
84 w("\n TALLY: axes=" as *u8); wn(total); w(" HAVE=" as *u8); wn(have); w(" (" as *u8); wn(permil); w("permil)" as *u8)
85 w(" EXCEEDS=" as *u8); wn(st[2]); w(" AHEAD=" as *u8); wn(st[3]); w(" PARITY=" as *u8); wn(st[4]); w(" GAP=" as *u8); wn(st[5])
86 w("\n corpus attestations=" as *u8); wn(st[7]); w("\n" as *u8)
87
88 let g_real: i64 = cc_our_grade("runtime/nx_peerwire.nx" as *u8, none)
89 let g_fake: i64 = cc_our_grade(none, none)
90 var liar_ok: i64=1; if g_real!=3 { liar_ok=0 } if g_fake!=0 { liar_ok=0 }
91 var corpus_ok: i64=0; if st[7]>0 { corpus_ok=1 }
92 w(" honesty: liar-kill=" as *u8); if liar_ok==1 { w("ARMED" as *u8) } else { w("DISARMED" as *u8) }
93 w(" corpus-grounded=" as *u8); if corpus_ok==1 { w("YES" as *u8) } else { w("NO" as *u8) } w("\n" as *u8)
94
95 w("\n=== P2PDIST-CENSUS verdict=" as *u8)
96 if liar_ok==1 { if corpus_ok==1 {
97 w("GREEN. Read: DEEP sovereign BitTorrent foundation (AHEAD -- own stack); " as *u8); wn(st[5])
98 w(" GAPs = the distribution-ecosystem layer (publish-enabler, hub<->hub, index, NAT-traversal, gossip, BTv2) = the build ladder.\n" as *u8)
99 sys_exit(0); return 0
100 } }
101 w("RED (unbanked corpus -> run nx_p2pdist_research_fetch)\n" as *u8); sys_exit(1); return 1
102}