nx_dr_verify.nx source
↩ module page · 60 lines · 2988 B
1// nx_dr_verify.nx -- SOVEREIGN citation-entailment verification loop (DR-3).
2// The deep-research vulnerability (Rios-Garcia et al. arXiv:2604.18805, 25k+ runs):
3// evidence is IGNORED in 68% of traces; refutation-driven belief revision happens in
4// only 26%. The fix is STRUCTURAL, not hope: every claim must be entailment-checked
5// against its source evidence, and anything that fails is DROPPED from context memory
6// (blueprint #1 citation traceability + DEER back-tracking of cited AND uncited claims,
7// arXiv:2512.17776). This organ forces evidence consumption by construction: an
8// unsupported claim can never enter memory.
9// Entailment proxy = token CONTAINMENT (fraction of the claim's tokens present in the
10// evidence), integer/permille -- the sovereign LEXICAL tier; PPMI (recall lane) and
11// the no-float LLM are the escalation tiers (same socket, honest tiering).
12// Imports ONLY nx_syscalls = drift-immune. No hardware writes (Rule 26).
13//
14// module: nishi-core.research.dr_verify
15// depends: nx_syscalls.nx
16// genealogy_id: textual_entailment_rte + deer_2026_backtracking + coscientist_reflection
17import "nx_syscalls.nx"
18
19// is token-id `tok` present in the evidence token-id array?
20func dv_contains(evidence: *i64, ne: i64, tok: i64) -> i64 {
21 var i: i64 = 0
22 while i < ne { if evidence[i] == tok { return 1 } i = i + 1 }
23 return 0
24}
25
26// entailment proxy: fraction of the claim's tokens found in the evidence, permille.
27// nc<1 -> 0 (an empty claim is unsupported).
28func dv_entail(claim: *i64, nc: i64, evidence: *i64, ne: i64) -> i64 {
29 if nc < 1 { return 0 }
30 var hit: i64 = 0; var i: i64 = 0
31 while i < nc { if dv_contains(evidence, ne, claim[i]) == 1 { hit = hit + 1 } i = i + 1 }
32 return (hit * 1000) / nc
33}
34
35// supported iff entailment >= threshold. An unsupported claim (entail 0) is dropped at
36// ANY threshold >= 1 -> cannot enter context memory unsupported (the structural fix).
37func dv_supported(claim: *i64, nc: i64, evidence: *i64, ne: i64, threshold: i64) -> i64 {
38 if dv_entail(claim, nc, evidence, ne) >= threshold { return 1 } else { return 0 }
39}
40
41// batch verification loop over per-claim entail scores (DEER groups claims for
42// verification -- cheaper AND more accurate). out_keep[i]=1 if scores[i]>=threshold.
43// Returns survivor count; out_dropped[0] = number dropped.
44func dv_batch(scores: *i64, n: i64, threshold: i64, out_keep: *i64, out_dropped: *i64) -> i64 {
45 var keep: i64 = 0; var drop: i64 = 0; var i: i64 = 0
46 while i < n {
47 if scores[i] >= threshold { out_keep[i] = 1; keep = keep + 1 }
48 else { out_keep[i] = 0; drop = drop + 1 }
49 i = i + 1
50 }
51 out_dropped[0] = drop
52 return keep
53}
54
55// belief-revision rate = fraction of claims DROPPED (revised away), permille. High =
56// the verifier is actively forcing evidence consumption (the antidote to the 26%).
57func dv_revision_rate(dropped: i64, n: i64) -> i64 {
58 if n < 1 { return 0 }
59 return (dropped * 1000) / n
60}