code wiki / _hdl_build / nx_deep_research.nx
nx_deep_research.nx source
↩ module page · 67 lines · 3290 B
1// nx_deep_research.nx -- build the RESEARCHER up to do what /deep-research does, so the team owns the
2// mechanizable bulk and Claude only intercedes at the bounded FETCH+EXTRACT (operator: save tokens).
3// A /deep-research run is ~108 agent calls across 6 stages; the heavy one is VERIFY (3-vote over ~25
4// claims = 75 calls) -- and that is DETERMINISTIC, so the team does it sovereignly (and reproducibly,
5// which is BETTER than a varying LLM vote). Of the 6 stages, 4 are TEAM-owned (scope, verify,
6// synthesize, task -- nx_researcher already does verify+synth+task) and only 2 are LLM-gaps (fetch
7// external sources, extract prose->claims). The orchestrator runs the pipeline and accounts the token
8// saving. RACI: Researcher orchestrates + owns the mechanizable stages; Claude does fetch+extract;
9// Librarian persists. license_tier: ORIGINAL Refs: nx_researcher (verify/synth/task); the LLM-gap registry.
10
11import "nx_researcher.nx" // res_verify / res_synthesize -- the team's deterministic verify + task-gen
12
13const DR_SCOPE: i64 = 1
14const DR_FETCH: i64 = 2
15const DR_EXTRACT: i64 = 3
16const DR_VERIFY: i64 = 4
17const DR_SYNTH: i64 = 5
18const DR_TASK: i64 = 6
19
20const DR_TEAM: i64 = 1 // sovereign NishiLang -> ~0 LLM tokens
21const DR_LLM: i64 = 2 // an LLM-intercession gap (fetch / extract) -> bounded LLM tokens
22
23// who owns a stage? FETCH is now TEAM-owned (nx_browse_text proven live + the library mirror covers
24// bot-blocked sites). Only SEMANTIC EXTRACT (messy prose -> nuanced claims) still needs the LLM --
25// structured/numeric fact extraction the team owns (nx_research_extract). scope/verify/synth/task too.
26func dr_stage_owner(stage: i64) -> i64 {
27 if stage == DR_EXTRACT { return DR_LLM }
28 return DR_TEAM
29}
30
31// cost (in agent-equivalents) of a stage, given angles, claims, sources-per-angle.
32func dr_stage_cost(stage: i64, angles: i64, claims: i64, spa: i64) -> i64 {
33 if stage == DR_SCOPE { return 1 }
34 if stage == DR_FETCH { return angles * spa }
35 if stage == DR_EXTRACT { return angles * spa }
36 if stage == DR_VERIFY { return claims * 3 } // 3-vote adversarial -- the heavy stage
37 if stage == DR_SYNTH { return 1 }
38 if stage == DR_TASK { return 1 }
39 return 0
40}
41
42// total cost if the LLM does EVERY stage (the old /deep-research).
43func dr_cost_full_llm(angles: i64, claims: i64, spa: i64) -> i64 {
44 var c: i64 = 0; var s: i64 = 1
45 while s <= 6 { c = c + dr_stage_cost(s, angles, claims, spa); s = s + 1 }
46 return c
47}
48
49// total LLM cost when the TEAM owns the mechanizable stages (only fetch+extract cost LLM tokens).
50func dr_cost_team_assisted(angles: i64, claims: i64, spa: i64) -> i64 {
51 var c: i64 = 0; var s: i64 = 1
52 while s <= 6 { if dr_stage_owner(s) == DR_LLM { c = c + dr_stage_cost(s, angles, claims, spa) } s = s + 1 }
53 return c
54}
55
56// the token saving (permil) from the team owning the mechanizable stages.
57func dr_saving_permil(full: i64, assisted: i64) -> i64 {
58 if full <= 0 { return 0 }
59 return ((full - assisted) * 1000) / full
60}
61
62// how many of the 6 stages the team owns (the sovereignty of the pipeline).
63func dr_team_stage_count() -> i64 {
64 var c: i64 = 0; var s: i64 = 1
65 while s <= 6 { if dr_stage_owner(s) == DR_TEAM { c = c + 1 } s = s + 1 }
66 return c
67}