code wiki / _hdl_build / nx_researcher.nx
nx_researcher.nx source
↩ module page · 73 lines · 4160 B
1// nx_researcher.nx -- the NISHI RESEARCHER organ: the team does its OWN deep research and
2// synthesizes it into SPECIFIC TASKS, toward exceeding Claude's deep-research. Honest boundary
3// (mechanizable-invention doctrine): the sovereign team cannot browse the web or do LLM prose-
4// extraction in pure NishiLang, so the FETCH (sources) + EXTRACT (prose -> claims) stage is the
5// one delegated step. Everything that makes research RIGOROUS the team owns and runs
6// deterministically -- and that is where it EXCEEDS a one-shot LLM synthesis:
7// - ADVERSARIAL VERIFY: a team-owned 3-vote rule over independent checks (source authority,
8// numeric consistency, cross-corroboration). DETERMINISTIC -> same evidence, same verdict
9// every run (an LLM one-shot varies); refuted claims are killed, not quietly carried.
10// - SYNTHESIZE: keep only CONFIRMED, rank by confidence, dedup.
11// - GENERATE TASKS: every confirmed + actionable finding becomes a SPECIFIC, reproducible task
12// (id + owning organ + a gate to write) -- the actionable->reproducible bridge a prose report
13// stops short of. Refuted/unverified claims generate ZERO tasks = no wasted build effort.
14// The LIBRARIAN (nx_librarian_pipeline) then grades + persists the artifact so nothing is thrown
15// away. RACI: RESEARCHER verifies+synthesizes+tasks; LIBRARIAN grades+catalogs; BUILDER/ENGINEER
16// execute the tasks. license_tier: ORIGINAL Refs: the deep-research 5-angle/3-vote protocol.
17
18import "nx_syscalls.nx"
19
20const RES_CONFIRMED: i64 = 1
21const RES_REFUTED: i64 = 2
22const RES_CONTESTED: i64 = 3
23const RES_VOTES: i64 = 3 // 3 independent adversarial checks per claim (the protocol)
24const RES_ANGLES: i64 = 5 // standard decomposition: primary/technical/dominant/coupling/applied
25
26// the team's OWN adversarial verdict over the 3 votes. DETERMINISTIC + reproducible.
27func res_verify(confirm_votes: i64, refute_votes: i64) -> i64 {
28 if refute_votes >= 2 { return RES_REFUTED }
29 if confirm_votes >= 2 { return RES_CONFIRMED }
30 return RES_CONTESTED
31}
32
33func res_confidence_permil(confirm_votes: i64) -> i64 { return (confirm_votes * 1000) / RES_VOTES }
34
35// a finding becomes a TASK only if CONFIRMED and actionable -- never build on a refuted/unverified
36// claim (no wasted work; the exceed over a synthesis that just lists everything).
37func res_is_task(verdict: i64, actionable: i64) -> i64 {
38 if verdict == RES_CONFIRMED { if actionable == 1 { return 1 } }
39 return 0
40}
41
42// count findings whose verdict == target.
43func res_count_verdict(n: i64, cv: *i64, rv: *i64, target: i64) -> i64 {
44 var c: i64 = 0; var i: i64 = 0
45 while i < n { if res_verify(cv[i], rv[i]) == target { c = c + 1 } i = i + 1 }
46 return c
47}
48
49// SYNTHESIZE + GENERATE TASKS: verify each finding, and for confirmed+actionable ones emit a task
50// (record its finding index + owning organ). Returns the task count. This is the team turning
51// verified research into a concrete, ownable build backlog -- reproducibly.
52func res_synthesize(n: i64, cv: *i64, rv: *i64, actionable: *i64, organ: *i64, out_idx: *i64, out_organ: *i64) -> i64 {
53 var t: i64 = 0; var i: i64 = 0
54 while i < n {
55 let v: i64 = res_verify(cv[i], rv[i])
56 if res_is_task(v, actionable[i]) == 1 { out_idx[t] = i; out_organ[t] = organ[i]; t = t + 1 }
57 i = i + 1
58 }
59 return t
60}
61
62// REPRODUCIBILITY check (the core exceed): running synthesis twice on the same evidence yields the
63// identical task set. Returns 1 if the two runs match exactly. (An LLM one-shot cannot guarantee this.)
64func res_is_reproducible(n: i64, cv: *i64, rv: *i64, actionable: *i64, organ: *i64) -> i64 {
65 let a1: *i64 = sys_mmap(8 * (n + 4)) as *i64; let o1: *i64 = sys_mmap(8 * (n + 4)) as *i64
66 let a2: *i64 = sys_mmap(8 * (n + 4)) as *i64; let o2: *i64 = sys_mmap(8 * (n + 4)) as *i64
67 let t1: i64 = res_synthesize(n, cv, rv, actionable, organ, a1, o1)
68 let t2: i64 = res_synthesize(n, cv, rv, actionable, organ, a2, o2)
69 if t1 != t2 { return 0 }
70 var i: i64 = 0
71 while i < t1 { if a1[i] != a2[i] { return 0 } if o1[i] != o2[i] { return 0 } i = i + 1 }
72 return 1
73}