code wiki / _hdl_build / nx_research_fetch_test.nx

nx_research_fetch_test.nx source

↩ module page · 44 lines · 3608 B

1// nx_research_fetch_test.nx -- the RESEARCHER actually does FETCH + EXTRACT (no Claude limiting). 2// It opens a real socket to a live HTTP server, GETs the page, renders HTML->text (nx_browse_text = 3// the team's sovereign fetch), then EXTRACTS the facts by pattern (nx_research_extract). On the 4// website-abandonment research it must pull: 53% abandon, >3s load threshold, 10s decision window, 5// and detect that the 3-click rule is DEBUNKED (the correction the Critic demanded). Exit 0 if the 6// team fetched a 200 and extracted the right facts. license_tier: ORIGINAL 7 8import "nx_browse_text.nx" // nx_browse_text + br_addr_ipv4 -- the team's sovereign fetch 9import "nx_research_extract.nx" // re_stat_after / re_has -- the team's pattern extract 10import "nx_syscalls.nx" 11 12func ft_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 13func ft_num(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;k=1}; while m>0 {t[k]=48+(m%10); 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 } 14 15func main() -> i64 { 16 ft_puts("=== RESEARCHER: FETCH a live page + EXTRACT the facts (sovereign, no Claude) ===\n" as *u8) 17 let addr: *u8 = sys_mmap(32) 18 br_addr_ipv4(addr, 127, 0, 0, 1, 8099) // localhost:8099 (a live HTTP server) 19 let scratch: *u8 = sys_mmap(16384); let out: *u8 = sys_mmap(16384) 20 let status: *i64 = sys_mmap(8) as *i64; let verdict: *i64 = sys_mmap(8) as *i64 21 let n: i64 = nx_browse_text(addr, "/" as *u8, 1, "127.0.0.1" as *u8, 9, scratch, 16384, out, 16384, status, verdict) 22 ft_puts(" fetch: status=" as *u8); ft_num(status[0]); ft_puts(" rendered-bytes=" as *u8); ft_num(n); ft_puts("\n --- fetched text (the team SEES the page) ---\n" as *u8) 23 if n > 0 { sys_write(1, out, n); ft_puts("\n" as *u8) } 24 if n <= 0 { ft_puts(" FETCH FAILED (is the server up on 127.0.0.1:8099?)\n" as *u8); sys_exit(1); return 1 } 25 26 // EXTRACT the facts by pattern -- the team owns this, it is not an LLM-gap 27 let abandon: i64 = re_stat_after(out, n, "found that" as *u8) 28 let load_s: i64 = re_stat_after(out, n, "longer than" as *u8) 29 let decide_s:i64 = re_stat_after(out, n, "within" as *u8) 30 let debunked:i64 = re_has(out, n, "debunked" as *u8) 31 ft_puts(" EXTRACTED: abandon=" as *u8); ft_num(abandon); ft_puts("% load-threshold=" as *u8); ft_num(load_s); ft_puts("s decision-window=" as *u8); ft_num(decide_s); ft_puts("s 3-click-rule-debunked=" as *u8); ft_num(debunked); ft_puts("\n" as *u8) 32 33 let r: *i64 = sys_mmap(8*8) as *i64 34 r[0] = 0; if status[0] == 200 { r[0] = 1 } // real 200 fetched over a socket 35 r[1] = 0; if abandon == 53 { r[1] = 1 } // extracted the abandonment stat 36 r[2] = 0; if load_s == 3 { r[2] = 1 } // extracted the load threshold (confirmed) 37 r[3] = 0; if decide_s == 10 { r[3] = 1 } // extracted the decision window 38 r[4] = 0; if debunked == 1 { r[4] = 1 } // extracted the CORRECTION (3-click debunked) 39 var pass: i64 = 0; var i: i64 = 0 40 while i < 5 { pass = pass + r[i]; i = i + 1 } 41 ft_puts("----\n passed " as *u8); ft_num(pass); ft_puts("/5\n" as *u8) 42 if pass == 5 { ft_puts(" THE TEAM DID IT: fetched a live page over a sovereign socket + extracted the cited facts. Claude was NOT in the loop.\n" as *u8); sys_exit(0); return 0 } 43 ft_puts(" FAIL\n" as *u8); sys_exit(1); return 1 44}