code wiki / _hdl_build / nx_ui_tdist.nx
nx_ui_tdist.nx
buildroot/runtime/_hdl_build/nx_ui_tdist.nx
about
nx_ui_tdist.nx -- ui-validation V1 (sovereign DETERMINISTIC engine). Real structural TREE-EDIT-DISTANCE:
upgrades nx_ui_struct's flat-fingerprint to an ORDER + DEPTH sensitive tree metric. Parses HTML into a
POSTORDER (tag,depth) token sequence (a DOM-tree serialization: each element emitted after its children,
carrying its nesting depth) and computes edit distance between two pages' sequences. Catches subtree
add/remove, reordering, and nesting changes that a flat count misses. DETERMINISTIC, LLM-free, air-gap.
★KAT-GATED: `selftest` proves the edit-distance core correct (identical=0, insert=1, substitute=1,
delete=1) BEFORE any page is judged -- correctness proven, not asserted (the anti-navel-gaze discipline).
HONEST ENVELOPE: postorder-serialization edit distance = a TRACTABLE tree-structure metric; full
Zhang-Shasha ZSS tree-edit-distance over the RENDERED AXTree = the exact-optimal follow-on (needs the
sovereign browser's live accessibility tree, browser lane). Assumes well-formed server-emitted markup.
nx_ui_tdist 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
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
structs
| none |
consts
| 15 | const K_MAGIC_30000: i64 = 30000 |
| 16 | const K_MAGIC_2166136261: i64 = 2166136261 |
| 17 | const K_MAGIC_16777619: i64 = 16777619 |
| 18 | const K_MAGIC_2147483647: i64 = 2147483647 |
| 19 | const K_MAGIC_5000: i64 = 5000 |
| 20 | const K_MAGIC_4096: i64 = 4096 |
| 21 | const K_MAGIC_524288: i64 = 524288 |
| 22 | const K_MAGIC_2048: i64 = 2048 |
functions
| 24 | func td_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 |
| 25 | func td_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 } |
| 26 | func td_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 } |
| 27 | func td_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: td_lev |
| 29 | func td_hash(buf: *u8, s: i64, e: i64) -> i64 called by 1: td_tokens |
| 37 | func td_void(buf: *u8, s: i64, e: i64) -> i64 called by 1: td_tokens |
| 46 | func td_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: td_tokens |
| 48 | func td_tokens(buf: *u8, n: i64, toks: *i64, cap: i64) -> i64 |
| 87 | func td_lev(a: *i64, na: i64, b: *i64, nb: i64) -> i64 |
| 108 | func td_kat(rep: *u8, pos: i64, name: *u8, got: i64, want: i64, fails: *i64) -> i64 |
| 114 | func td_reads(path: *u8, buf: *u8, cap: i64) -> i64 calls 1: sys_read |
| 123 | func td_fetch(url: *i64, connect: i64, buf: *u8, cap: i64, olen: *i64) -> i64 |
| 130 | func main(argc: i64, argv: *i64) -> i64 |