code wiki / (root) / nx_research_synth_qwen.nx

nx_research_synth_qwen.nx

buildroot/runtime/nx_research_synth_qwen.nx

15708 B369 linesdepth 10pulls 22 transitivereach 10 importersview sourcekind librarytopic research
docsdependenciesstructsconstsfunctions

about

nx_research_synth_qwen.nx -- S1 of the Tesla growth ladder: SOVEREIGN GROUNDED SYNTHESIS. Given a question + N retrieved source passages, the pretrained sovereign Qwen (nsv_generate, in-process, no HTTP, $0, integer-deterministic) generates a MULTI-SENTENCE answer that cites each claim [n] back to a numbered source. The organ's RESONANT property (Tesla law #1) is not the generation -- it is the DETERMINISTIC GROUNDING CHECK that runs at $0 with NO model: every content word of the answer must trace to a cited source, and every citation must be in range. A hallucinated claim (word absent from all sources) or a fabricated citation ([5] when 2 sources exist) is caught mechanically. This is the anti-hallucination discipline FARS lacked (its own audit: 5.7% hallucinated citations, 7.4% fabricated results). Composes: nx_nofloat_serve_core (nsv_init/nsv_generate). Model-call pattern mirrors nx_qwen_extract (proven). The grounding functions (rsq_ground_report / rsq_parse_cites / rsq_is_refusal) need NO model -> the gate proves the mechanism in miniature (law #3), and the generative path is marker-gated for NAS measurement. NEXT (S2): each ungrounded claim -> nx_evidence_verify_gate for external confirm/discredit. license_tier: ORIGINAL

dependencies 3 imports · 3 importers

nx_syscalls.nx nx_nofloat_serve_core.nx nx_text_sentences.nx nx_research_synth_qwen.nx nx_research_report.nx nx_research_synth_qwen_gate.nx nx_research_verify_synth.nx

imports: nx_syscalls.nxnx_nofloat_serve_core.nxnx_text_sentences.nx

imported by: nx_research_report.nxnx_research_synth_qwen_gate.nxnx_research_verify_synth.nx

structs

none

consts

18const RSQ_MODEL: *u8 = "/home/elderwesto/nx_stage/nx_real_model.gguf"
19const RSQ_SRCCAP: i64 = 600 // per-source byte cap inside the prompt
20const RSQ_MAXPROMPT: i64 = 4000 // hard byte guard (<< NSV_MAXIN=16384 tok-scratch; ~1600 tok < NSV_MAXT=2048)
21const RSQ_MAXNEW: i64 = 64 // synthesis needs a 2-4 sentence answer (extraction used 16)
22const RSQ_MODE: i64 = 0 // 0 = i32 lossless (faithful default)
23const RSQ_MINWORD: i64 = 5 // a content word is len>=5 (filters most function words)

functions

34func rsq_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
35func rsq_lc(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c }
36func rsq_is_alnum(c: i64) -> i64
42func rsq_cat(dst: *u8, off: i64, s: *u8, n: i64, cap: i64) -> i64
called by 1: rsq_build_prompt
47func rsq_cats(dst: *u8, off: i64, s: *u8, cap: i64) -> i64
called by 1: rsq_build_prompt
52func rsq_catd(dst: *u8, off: i64, d: i64, cap: i64) -> i64
called by 1: rsq_build_prompt
59func rsq_ci_match_at(buf: *u8, pos: i64, blen: i64, word: *u8, wlen: i64) -> i64
called by 1: rsq_ci_contains calls 1: rsq_lc
68func rsq_ci_contains(buf: *u8, blen: i64, word: *u8, wlen: i64) -> i64
78func rsq_word_end(ans: *u8, i: i64, alen: i64) -> i64
88func rsq_eqword(ans: *u8, off: i64, wlen: i64, w: *u8) -> i64
called by 1: rsq_is_stop calls 1: rsq_lc
99func rsq_is_stop(ans: *u8, off: i64, wlen: i64) -> i64
118func rsq_present_in_sources(ans: *u8, off: i64, wlen: i64, srcv: *i64, nsrc: i64) -> i64
129func rsq_ground_report(ans: *u8, alen: i64, srcv: *i64, nsrc: i64, out: *i64) -> i64
154func rsq_parse_cites(ans: *u8, alen: i64, cites: *i64, maxc: i64, srcrange: i64, out: *i64) -> i64
called by 2: rsq_verdictmain
182func rsq_is_refusal(ans: *u8, alen: i64) -> i64
called by 2: rsq_verdictmain calls 1: rsq_ci_contains
190func rsq_verdict(ans: *u8, alen: i64, srcv: *i64, nsrc: i64, htol: i64, out: *i64) -> i64
210func rsq_sentence_cite(ans: *u8, s: i64, e: i64, nsrc: i64, outp: *i64) -> i64
233func rsq_span_overlaps_src(ans: *u8, s: i64, e: i64, srcv: *i64, c: i64) -> i64
252func rsq_claim_verdict(ans: *u8, alen: i64, srcv: *i64, nsrc: i64, out: *i64) -> i64
285func rsq_build_prompt(q: *u8, srcv: *i64, nsrc: i64, pr: *u8, cap: i64) -> i64
309func rsq_load() -> i64
337func rsq_ready() -> i64 { return g_rsq_ready }
called by 2: rp_reportrvs_answer
341func rsq_synth(q: *u8, srcv: *i64, nsrc: i64, ans: *u8) -> i64