code wiki / _hdl_build / nx_corroborate.nx

nx_corroborate.nx source

↩ module page · 51 lines · 2988 B

1// nx_corroborate.nx -- cross-source corroboration over the HARVESTED corpus (the research-rigor step 2// that makes a fact trustworthy). A claim is only CONFIRMED when >=2 independent sources report the 3// SAME value; if sources report CONFLICTING values it is CONTESTED -- and the team flags it for the 4// Critic/operator rather than silently picking one (the honest discipline). This grounds the deep- 5// research VERIFY stage in the team's OWN fetched+mirrored library instead of hand-fed claims, and it 6// is REPRODUCIBLE: same corpus -> same verdict, which a one-shot LLM vote cannot guarantee. 7// Honest boundary: independence = distinct mirrored sources; detecting same-origin/syndicated copies 8// (true independence) is a deeper rung, flagged not faked. license_tier: ORIGINAL 9// 10// Pairs with nx_research_extract (re_stat_after pulls the value a source reports for a claim key) and 11// nx_library_cache (the corpus is the mirrored library). 12 13import "nx_research_extract.nx" // re_stat_after 14import "nx_syscalls.nx" 15 16const CO_UNFOUND: i64 = 0 // no source reports it 17const CO_SINGLE: i64 = 1 // exactly one source -- needs corroboration before it is trusted 18const CO_CONFIRMED: i64 = 2 // >=2 sources agree, none conflict 19const CO_CONTESTED: i64 = 3 // sources report conflicting values -> escalate, do not pick 20 21// the value source k reports for `key` (-1 if that source does not mention it). 22func co_value(ptrs: *i64, lens: *i64, k: i64, key: *u8) -> i64 { return re_stat_after(ptrs[k] as *u8, lens[k], key) } 23 24// over the N-source corpus, count sources AGREEING with `expected` and those reporting a DIFFERENT value. 25func co_agree(ptrs: *i64, lens: *i64, N: i64, key: *u8, expected: i64) -> i64 { 26 var a: i64 = 0; var i: i64 = 0 27 while i < N { let v: i64 = co_value(ptrs, lens, i, key); if v >= 0 { if v == expected { a = a + 1 } } i = i + 1 } 28 return a 29} 30func co_disagree(ptrs: *i64, lens: *i64, N: i64, key: *u8, expected: i64) -> i64 { 31 var d: i64 = 0; var i: i64 = 0 32 while i < N { let v: i64 = co_value(ptrs, lens, i, key); if v >= 0 { if v != expected { d = d + 1 } } i = i + 1 } 33 return d 34} 35 36// the corroboration verdict. ANY conflicting value flags CONTESTED (conservative + honest). 37func co_verdict(agree: i64, disagree: i64) -> i64 { 38 if disagree >= 1 { return CO_CONTESTED } 39 if agree >= 2 { return CO_CONFIRMED } 40 if agree == 1 { return CO_SINGLE } 41 return CO_UNFOUND 42} 43 44// one-call corroboration of a claim (key, expected value) against the corpus. 45func co_check(ptrs: *i64, lens: *i64, N: i64, key: *u8, expected: i64) -> i64 { 46 return co_verdict(co_agree(ptrs, lens, N, key, expected), co_disagree(ptrs, lens, N, key, expected)) 47} 48 49// does this claim become a BUILD TASK? only CONFIRMED claims (>=2 agreeing sources) do -- CONTESTED / 50// SINGLE / UNFOUND generate ZERO tasks (no wasted build on unsettled evidence). 51func co_taskable(verdict: i64) -> i64 { if verdict == CO_CONFIRMED { return 1 } return 0 }