nx_llm_route.nx
buildroot/runtime/nx_llm_route.nx
about
nx_llm_route.nx -- MIXED-LLM ROUTING (companionchat CC6, 2026-08-30): a DATA ROW can send a chat turn to a stronger
backend FIRST; the local encoder-LLM stays the fallback; and the reply records which one answered (model_route), so a
route is never silent and an absent backend is never a mystery. Operator ask: "the companion intelligent, use your mixed llm".
CONF llm_routes.conf, rows `tag|trigger|a.b.c.d|port`: the FIRST row whose trigger appears (case-insensitive) in the user
turn selects the backend; trigger `*` matches every turn (a default route). Comments `#` and blank lines ignored. The conf
is read PER TURN (data, no rebuild) from the daemon cwd, then from the nishihost knowledge tree. No conf, no match, or a
malformed row = NO ROUTE, never a guess. The backend must speak the same OpenAI-shape /v1/chat/completions the local
worker speaks; nothing here re-implements dispatch -- the orchestrator prepends the routed candidate to its own list.
Contract symbol: go_llm_route. Gate: nx_llm_route_gate (fixture confs under /tmp, neg-controls for no-match and no-conf).
license_tier: ORIGINAL
dependencies 1 imports · 2 importers
imports: nx_syscalls.nx
imported by: nx_gen_orchestrator.nxnx_llm_route_gate.nx
structs
| none |
consts
| 13 | const LLR_CONF: *u8 = "llm_routes.conf" as *u8 |
| 14 | const LLR_CONF_ABS: *u8 = "/volume1/homes/elderwesto/nishihost/knowledge/llm_routes.conf" as *u8 |
| 16 | const LLR_MAXW: i64 = 8 |
| 17 | const LLR_TAG_CAP: i64 = 48 |
| 18 | const LLR_CH_PIPE: i64 = 124 |
| 19 | const LLR_CH_NL: i64 = 10 |
| 20 | const LLR_CH_CR: i64 = 13 |
| 21 | const LLR_CH_HASH: i64 = 35 |
| 22 | const LLR_CH_STAR: i64 = 42 |
| 23 | const LLR_CH_DOT: i64 = 46 |
| 24 | const LLR_CH_D0: i64 = 48 |
| 25 | const LLR_CH_D9: i64 = 57 |
| 26 | const LLR_PORT_MAX: i64 = 65535 |
functions
| 28 | func llr_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 29 | func llr_cat(dst: *u8, off: i64, s: *u8) -> i64 { var o: i64 = off; var i: i64 = 0; while s[i] != (0 as u8) { dst[o] = s[i]; o = o + 1; i = i + 1 } return o } called by 1: go_llm_route_label |
| 30 | func llr_lower(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c } called by 1: llr_has_ci |
| 33 | func llr_has_ci(hay: *u8, hn: i64, nd: *u8, nn: i64) -> i64 |
| 52 | func llr_parse_target(s: *u8, i0: i64, n: i64, w: *i64) -> i64 called by 1: go_llm_route_from |
| 81 | func go_llm_route_from(path: *u8, umsg: *u8, umlen: i64, out_tag: *u8, out_w: *i64) -> i64 |
| 134 | func go_llm_route(umsg: *u8, umlen: i64, out_tag: *u8, out_w: *i64) -> i64 |
| 140 | func go_llm_route_prepend(rw: *i64, wa: *i64, wb: *i64, wc: *i64, wd: *i64, wpa: *i64, wcount: i64) -> i64 |
| 150 | func go_llm_route_label(routed: i64, rwin: i64, tag: *u8, dst: *u8, off: i64) -> i64 |