code wiki / (root) / nx_dr_route.nx

nx_dr_route.nx source

↩ module page · 45 lines · 2061 B

1// nx_dr_route.nx -- SOVEREIGN web-vs-private source ROUTER (DR-7). 2// DRBench (arXiv:2510.00172) measured the dominant failure of every deep-research agent: 3// they "consistently fail to identify when required information is missing from private 4// files and should instead be sourced from the web." This router fixes that BY 5// CONSTRUCTION: it scores each source's coverage of a sub-query and, whenever the private 6// corpus is insufficient, the route ALWAYS involves the web -- it can never dead-end on a 7// private-only answer that isn't there. Integer, deterministic. Imports ONLY nx_syscalls 8// = drift-immune. No hardware writes (Rule 26). 9// 10// module: nishi-core.research.dr_route 11// depends: nx_syscalls.nx 12// genealogy_id: drbench_2026_private_web_routing 13import "nx_syscalls.nx" 14 15// coverage permille = fraction of the query's terms found in a source index. 16func rt_coverage(hits: i64, total: i64) -> i64 { 17 if total < 1 { return 0 } 18 return (hits * 1000) / total 19} 20 21// route codes: 0=PRIVATE_ONLY 1=WEB_ONLY 2=BOTH 3=ESCALATE_WEB. 22// If private meets its bar -> PRIVATE_ONLY (or BOTH if web also needed). If private is 23// INSUFFICIENT -> WEB_ONLY (web meets bar) or ESCALATE_WEB (neither does, still search web, 24// never a private dead-end). Thresholds inclusive (>=). 25func rt_route(priv_cov: i64, web_cov: i64, priv_thr: i64, web_thr: i64) -> i64 { 26 var priv_ok: i64 = 0 27 if priv_cov >= priv_thr { priv_ok = 1 } 28 var web_ok: i64 = 0 29 if web_cov >= web_thr { web_ok = 1 } 30 if priv_ok == 1 { 31 if web_ok == 1 { return 2 } else { return 0 } 32 } 33 // private insufficient -> ALWAYS involves the web (the DRBench fix: never dead-end) 34 if web_ok == 1 { return 1 } else { return 3 } 35} 36 37// does this route consult the web? (everything except PRIVATE_ONLY) 38func rt_uses_web(code: i64) -> i64 { if code == 0 { return 0 } else { return 1 } } 39 40// does this route consult private data? (PRIVATE_ONLY or BOTH) 41func rt_uses_private(code: i64) -> i64 { 42 if code == 0 { return 1 } 43 if code == 2 { return 1 } 44 return 0 45}