code wiki / (root) / nx_ux_research_fetch.nx

nx_ux_research_fetch.nx source

↩ module page · 81 lines · 5546 B

1// nx_ux_research_fetch.nx -- the Nishi RESEARCHER's sovereign LIVE fetch grounding the BROWSER UX/CX 2// census in the real published research (operator: "matching a humans experience via digital anthropology 3// or whatever research sits out there"): usability heuristics (Nielsen), interaction laws (Fitts/Hick), 4// accessibility standards (WCAG: contrast/target-size/reflow), usability-testing methodology (the human 5// tests our synthetic user replaces), digital ethnography, and browser-UX conventions. Mirrors the proven 6// nx_font_research_fetch pattern (own TLS-1.3, Mozilla CA, idempotent have-skip) -> 7// knowledge/fetched/ux_*.raw. 100% sovereign. expect_exit: 0 license_tier: ORIGINAL 8import "nx_syscalls.nx" 9import "nx_x509_trust_store.nx" 10import "nx_trust_store_load_from_certdata.nx" 11import "nx_https_fetch_follow.nx" 12const K_MAGIC_4194304: i64 = 4194304 13const K_MAGIC_8388608: i64 = 8388608 14 15func ux_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 16func ux_putn(v: i64) -> i64 { 17 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 } 18 var m: i64 = v 19 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m } 20 let d: *u8 = sys_mmap(24) 21 var k: i64 = 0 22 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 23 var j: i64 = k - 1 24 while j >= 0 { sys_write(1, ((d as i64)+j) as *u8, 1); j = j - 1 } 25 return 0 26} 27func ux_have(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 } 28func ux_fetch(url: *u8, opath: *u8, store: *TrustStore, out: *u8, cap: i64) -> i64 { 29 if ux_have(opath) == 1 { ux_puts(opath); ux_puts(" [have-skip]\n" as *u8); return 1 } 30 let status: *i64 = sys_mmap(8) as *i64 31 let n: i64 = nx_https_fetch_follow(url, store, out, cap, 6, status) 32 ux_puts(url); ux_puts(" status=" as *u8); ux_putn(status[0]); ux_puts(" bytes=" as *u8); ux_putn(n) 33 if n <= 0 { ux_puts(" FETCH-FAIL\n" as *u8); return 0 } 34 var gz: i64 = 0 35 if n >= 2 { if out[0] == 0x1f as u8 { if out[1] == 0x8b as u8 { gz = 1 } } } 36 if gz == 1 { ux_puts(" [GZIP-skip]\n" as *u8); return 0 } 37 let fd: i64 = sys_openat_wr(opath, 0x1a4) 38 if fd < 0 { ux_puts(" SAVE-FAIL\n" as *u8); return 0 } 39 sys_write(fd, out, n) 40 sys_close(fd) 41 ux_puts(" SAVED\n" as *u8) 42 return 1 43} 44 45func main() -> i64 { 46 let r: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt" as *u8, 512, K_MAGIC_4194304) 47 if r <= 0 { ux_puts("UX: certdata load failed\n" as *u8); return 1 } 48 let store: *TrustStore = r as *TrustStore 49 ux_puts("CA roots=" as *u8); ux_putn(trust_store_count(store)); ux_puts("\n" as *u8) 50 let cap: i64 = K_MAGIC_8388608 51 let out: *u8 = sys_mmap(cap) 52 var ok: i64 = 0 53 54 ux_puts("== USABILITY HEURISTICS + INTERACTION LAWS (the census's UI axes) ==\n" as *u8) 55 ok = ok + ux_fetch("https://en.wikipedia.org/wiki/Heuristic_evaluation" as *u8, "knowledge/fetched/ux_heuristics.raw" as *u8, store, out, cap) 56 ok = ok + ux_fetch("https://en.wikipedia.org/wiki/Fitts%27s_law" as *u8, "knowledge/fetched/ux_fitts.raw" as *u8, store, out, cap) 57 ok = ok + ux_fetch("https://en.wikipedia.org/wiki/Hick%27s_law" as *u8, "knowledge/fetched/ux_hicks.raw" as *u8, store, out, cap) 58 ok = ok + ux_fetch("https://en.wikipedia.org/wiki/Usability" as *u8, "knowledge/fetched/ux_usability.raw" as *u8, store, out, cap) 59 60 ux_puts("== ACCESSIBILITY STANDARDS (contrast / target size / reflow -- mechanically checkable) ==\n" as *u8) 61 ok = ok + ux_fetch("https://en.wikipedia.org/wiki/Web_Content_Accessibility_Guidelines" as *u8, "knowledge/fetched/ux_wcag.raw" as *u8, store, out, cap) 62 ok = ok + ux_fetch("https://en.wikipedia.org/wiki/Web_accessibility" as *u8, "knowledge/fetched/ux_a11y.raw" as *u8, store, out, cap) 63 ok = ok + ux_fetch("https://en.wikipedia.org/wiki/Legibility" as *u8, "knowledge/fetched/ux_legibility.raw" as *u8, store, out, cap) 64 65 ux_puts("== USER-TESTING METHODOLOGY (what the synthetic user replaces) + DIGITAL ANTHROPOLOGY ==\n" as *u8) 66 ok = ok + ux_fetch("https://en.wikipedia.org/wiki/Usability_testing" as *u8, "knowledge/fetched/ux_testing.raw" as *u8, store, out, cap) 67 ok = ok + ux_fetch("https://en.wikipedia.org/wiki/Think_aloud_protocol" as *u8, "knowledge/fetched/ux_thinkaloud.raw" as *u8, store, out, cap) 68 ok = ok + ux_fetch("https://en.wikipedia.org/wiki/Digital_anthropology" as *u8, "knowledge/fetched/ux_diganthro.raw" as *u8, store, out, cap) 69 ok = ok + ux_fetch("https://en.wikipedia.org/wiki/User_experience" as *u8, "knowledge/fetched/ux_ux.raw" as *u8, store, out, cap) 70 ok = ok + ux_fetch("https://en.wikipedia.org/wiki/Customer_experience" as *u8, "knowledge/fetched/ux_cx.raw" as *u8, store, out, cap) 71 72 ux_puts("== BROWSER UX CONVENTIONS (chrome/scroll/tabs -- what humans expect) ==\n" as *u8) 73 ok = ok + ux_fetch("https://en.wikipedia.org/wiki/Graphical_user_interface" as *u8, "knowledge/fetched/ux_gui.raw" as *u8, store, out, cap) 74 ok = ok + ux_fetch("https://en.wikipedia.org/wiki/Scrolling" as *u8, "knowledge/fetched/ux_scrolling.raw" as *u8, store, out, cap) 75 ok = ok + ux_fetch("https://en.wikipedia.org/wiki/Tab_(interface)" as *u8, "knowledge/fetched/ux_tabs.raw" as *u8, store, out, cap) 76 77 ux_puts("== TOTAL SAVED/HAVE = " as *u8); ux_putn(ok); ux_puts(" / 15 ==\n" as *u8) 78 if ok >= 12 { ux_puts("UX-RESEARCH verdict=GREEN (>=12/15 banked)\n" as *u8); return 0 } 79 ux_puts("UX-RESEARCH verdict=RED\n" as *u8) 80 return 1 81}