code wiki / _hdl_build / nx_researcher_deep.nx

nx_researcher_deep.nx source

↩ module page · 65 lines · 4071 B

1// nx_researcher_deep.nx -- the team's RESEARCHER does DEEP RESEARCH to PRODUCE a spec, instead of taking 2// what Claude/the operator says (operator: "the researcher shouldnt do what you do and just take what i say 3// it should deep research the space to get us the information for a spec... find lots of sources and catalog 4// them and pass them to the librarian and synthesize the information like you do with deep research"). The 5// loop (the deep-research pattern, run by the TEAM): question -> ANGLES (fan-out) -> fetch sources -> extract 6// -> CATALOG to the Librarian/Library -> CORROBORATE (a fact needs >=2 independent sources) -> SYNTHESIZE -> 7// a GROUNDED spec. A fact with only 1 source (incl. "Claude said"/"operator said") is HEARSAY -> rejected. 8// license_tier: ORIGINAL Wires nx_browse_text (fetch) + nx_research_extract + nx_library_cache (Librarian) + 9// nx_corroborate into the deep-research loop. 10 11import "nx_syscalls.nx" 12 13const RD_ANGLES: i64 = 5 // fan-out breadth (matches the deep-research workflow's 5 angles) 14 15// total sources cataloged across all angles -- find LOTS of sources, pass them to the Librarian. 16func rd_sources_cataloged(per_angle: *i64, n_angles: i64) -> i64 { 17 var s: i64 = 0; var i: i64 = 0 18 while i < n_angles { s = s + per_angle[i]; i = i + 1 } 19 return s 20} 21 22// a fact is CORROBORATED iff >= 2 independent cataloged sources confirm it (1 source = hearsay). 23func rd_corroborated(n_confirming: i64) -> i64 { if n_confirming >= 2 { return 1 } return 0 } 24func rd_is_hearsay(n_confirming: i64) -> i64 { if n_confirming < 2 { return 1 } return 0 } 25 26// a fact is ADMITTED to the spec iff it is cataloged (in the Library, with provenance) AND corroborated. 27func rd_admit_fact(n_confirming: i64, cataloged: i64) -> i64 { 28 if cataloged == 1 { if rd_corroborated(n_confirming) == 1 { return 1 } } 29 return 0 30} 31 32// count admitted facts over the candidate set. 33func rd_admitted_count(confirming: *i64, cataloged: *i64, n: i64) -> i64 { 34 var c: i64 = 0; var i: i64 = 0 35 while i < n { if rd_admit_fact(confirming[i], cataloged[i]) == 1 { c = c + 1 } i = i + 1 } 36 return c 37} 38 39// the synthesized spec is GROUNDED iff every admitted fact has >=2 sources AND >=1 hearsay fact was rejected 40// (proving the loop actually filters, not rubber-stamps). 41func rd_spec_grounded(admitted: i64, total_candidates: i64) -> i64 { 42 if admitted < total_candidates { return 1 } // at least one candidate was filtered out (a real gate) 43 return 0 44} 45 46// ---- S-CLASS SCALE + MECHANIZATION + EXCEED-vs-CLAUDE (operator: "hundreds of sources, dont build toy 47// level... exceeds how you do it with current capabilities mechanized up with a future local llm augmenting 48// it in a unified fashion") ---- 49// the 7 stages: 0 fetch, 1 dedup, 2 catalog, 3 corroborate, 4 rank, 5 semantic-extract(LLM), 6 synthesize. 50const RD_NSTAGES: i64 = 7 51// MECHANIZED = deterministic, no LLM (fetch/dedup/catalog/corroborate/rank/synthesize-structure). Only the 52// SEMANTIC-EXTRACT stage needs the LLM -- the future LOCAL LLM (Modelwright) augments JUST that, unified. 53func rd_stage_mechanized(stage: i64) -> i64 { if stage == 5 { return 0 } return 1 } 54func rd_mechanized_permil() -> i64 { return 6 * 1000 / RD_NSTAGES } // 6 of 7 stages mechanized 55// LLM calls happen ONLY on corroborated clusters (the irreducible semantic core), NOT per source -> far fewer 56// than Claude's per-source agent fan-out. 57func rd_llm_calls(corroborated_clusters: i64) -> i64 { return corroborated_clusters } 58// EXCEEDS Claude's deep-research iff it ingests MORE sources AND spends FEWER LLM calls (cheaper) -- the 59// mechanized bulk does the scale; the LLM does only the irreducible part. 60func rd_exceeds_claude(our_sources: i64, claude_sources: i64, our_llm: i64, claude_llm: i64) -> i64 { 61 if our_sources > claude_sources { if our_llm < claude_llm { return 1 } } 62 return 0 63} 64// reproducible on the mechanized stages (same inputs -> same outputs); only the LLM stage is stochastic. 65func rd_reproducible_permil() -> i64 { return 6 * 1000 / RD_NSTAGES }