code wiki / _hdl_build / nx_ui_zss.nx

nx_ui_zss.nx

buildroot/runtime/_hdl_build/nx_ui_zss.nx

14299 B231 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic ui
docsdependenciesstructsconstsfunctions

about

nx_ui_zss.nx -- ui-validation V1b (sovereign DETERMINISTIC engine). The EXACT-OPTIMAL structural tree-edit-distance: real ZHANG-SHASHA (ZSS) over the DOM tree. Closes the honest gap nx_ui_tdist left (postorder-Levenshtein = a tractable approximation; ZSS = the true tree-edit-distance that respects tree structure in its edit operations). Reconstructs the tree from the postorder (tag,depth) DOM serialization: leftmost-leaf-descendant l[] and keyroots derive directly from depth; then the ZSS forestdist DP. NO model. KAT-GATED: `selftest` proves ZSS on known small-tree distances BEFORE any page is judged (anti-navel-gaze: a hard algorithm must earn a green self-test first). HONEST ENVELOPE: exact ZSS over the SOURCE DOM tree, node-capped for tractability; ZSS over the RENDERED AXTree = the browser-lane follow-on. nx_ui_zss selftest | dist <urlA> <urlB> [connect] exit: 0 (selftest GREEN / dist computed) | 1 selftest RED | 4 fetch-fail | 2 usage. license_tier: ORIGINAL expect_exit: 0

dependencies 1 imports · 0 importers

nx_tool_run.nx nx_ui_zss.nx

imports: nx_tool_run.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main z_w z_b z_kat z_b ↻ z_bn z_zss z_lfd z_keyroots z_min3 z_fetch tr_run_capture sys_mmap sys_pipe2 sys_fork sys_close sys_dup3 sys_execve_clean sys_close ↻ sys_execve sys_exit sys_read sys_wait4 wait_exit_code z_parse z_hash z_isletter z_void z_bn ↻ sys_openat_wr sys_renameat

structs

none

consts

13const K_MAGIC_30000: i64 = 30000
14const K_MAGIC_2166136261: i64 = 2166136261
15const K_MAGIC_16777619: i64 = 16777619
16const K_MAGIC_2147483647: i64 = 2147483647
17const K_MAGIC_5000: i64 = 5000
18const K_MAGIC_4096: i64 = 4096
19const K_MAGIC_524288: i64 = 524288
20const K_MAGIC_2048: i64 = 2048

functions

22func z_w(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
called by 1: main
23func z_b(rep: *u8, pos: i64, s: *u8) -> i64 { var p: i64 = pos; var i: i64 = 0; while s[i] != (0 as u8) { if p < K_MAGIC_30000 { rep[p] = s[i]; p = p + 1 } i = i + 1 } return p }
called by 2: z_katmain
24func z_bn(rep: *u8, pos: i64, v: i64) -> i64 { var p: i64 = pos; var m: i64 = v; if m < 0 { if p < K_MAGIC_30000 { rep[p] = 45 as u8; p = p + 1 } m = 0 - m } 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 { if p < K_MAGIC_30000 { rep[p] = t[k - 1 - i]; p = p + 1 } i = i + 1 } return p }
called by 2: z_katmain
25func z_min3(a: i64, b: i64, c: i64) -> i64 { var m: i64 = a; if b < m { m = b } if c < m { m = c } return m }
called by 1: z_zss
26func z_hash(buf: *u8, s: i64, e: i64) -> i64 { var h: i64 = K_MAGIC_2166136261; var i: i64 = s; while i < e { let c: i64 = buf[i]; var lc: i64 = c; if c >= 65 { if c <= 90 { lc = c + 32 } } h = (h ^ lc) * K_MAGIC_16777619; h = h & K_MAGIC_2147483647; i = i + 1 } if h == 0 { h = 1 } return h }
called by 1: z_parse
27func z_void(buf: *u8, s: i64, e: i64) -> i64 { let ln: i64 = e - s; if ln == 3 { if buf[s]==(105 as u8) { if buf[s+1]==(109 as u8) { if buf[s+2]==(103 as u8) { return 1 } } } } if ln == 5 { if buf[s]==(105 as u8) { if buf[s+1]==(110 as u8) { return 1 } } } if ln == 2 { if buf[s]==(98 as u8) { if buf[s+1]==(114 as u8) { return 1 } } if buf[s]==(104 as u8) { if buf[s+1]==(114 as u8) { return 1 } } } if ln == 4 { if buf[s]==(109 as u8) { if buf[s+1]==(101 as u8) { return 1 } } if buf[s]==(108 as u8) { if buf[s+1]==(105 as u8) { return 1 } } } return 0 }
called by 1: z_parse
28func z_isletter(c: i64) -> i64 { if c >= 65 { if c <= 90 { return 1 } } if c >= 97 { if c <= 122 { return 1 } } return 0 }
called by 1: z_parse
30func z_parse(buf: *u8, n: i64, lab: *i64, dep: *i64, cap: i64) -> i64
called by 1: main calls 3: z_hashz_isletterz_void
64func z_lfd(dep: *i64, n: i64, l: *i64) -> i64
called by 1: z_zss
76func z_keyroots(l: *i64, n: i64, kr: *i64) -> i64
called by 1: z_zss
86func z_zss(lab1: *i64, dep1: *i64, n1: i64, lab2: *i64, dep2: *i64, n2: i64) -> i64
called by 1: main calls 3: z_lfdz_keyrootsz_min3
136func z_kat(rep: *u8, pos: i64, name: *u8, got: i64, want: i64, fails: *i64) -> i64
called by 1: main calls 2: z_bz_bn
142func z_fetch(url: i64, connect: i64, buf: *u8, cap: i64, olen: *i64) -> i64
called by 1: main calls 1: tr_run_capture
149func main(argc: i64, argv: *i64) -> i64