code wiki / (root) / nx_research_investigate.nx

nx_research_investigate.nx source

↩ module page · 55 lines · 2581 B

1// nx_research_investigate.nx -- S4: the INVESTIGATION LOOP over the S1-S3 research cycle (recursive self-growth, 2// $0). DISTINCT from nx_research_loop.nx (the 2026-06-17 physics/energy/frontier autonomous driver). This one 3// drives the grounding cycle: synthesize (S1) -> verify (S2) -> ground-check (S3) -> if grounding GAPS remain, 4// investigate again -- and decides HONESTLY when to stop: GROUNDED (0 gaps) / BUDGET (iteration cap) / STALLED 5// (gaps stopped decreasing, so it never loops forever). gaps = uncited + unverified + unanswered sub-questions. 6// The control is deterministic/$0; the per-iteration synthesis composes S1-S3 (model-gated). This is the 7// "propose -> gate -> measure -> bank -> next" loop we run by hand every session, made an organ. license_tier: ORIGINAL 8import "nx_syscalls.nx" 9const RIV_MAGIC_1000000: i64 = 1000000 10 11const RIV_GROUNDED: i64 = 0 12const RIV_BUDGET: i64 = 1 13const RIV_STALLED: i64 = 2 14const RIV_CONTINUE: i64 = 3 15 16// total open gaps in a report iteration. 17func riv_gaps(uncited: i64, unverified: i64, unanswered: i64) -> i64 { return uncited + unverified + unanswered } 18 19// the loop decision. 0 grounded (done) / 1 budget (done) / 2 stalled (done) / 3 continue. 20func riv_next(gaps: i64, iter: i64, max_iter: i64, prev: i64) -> i64 { 21 if gaps == 0 { return RIV_GROUNDED } 22 if iter + 1 >= max_iter { return RIV_BUDGET } 23 if gaps >= prev { return RIV_STALLED } 24 return RIV_CONTINUE 25} 26 27// run the controller over a per-iteration gap sequence (each entry = that iteration's report gap-count, from the 28// real S1-S3 grounding stats). fills trace[0..iterations) with the gaps seen. out[0]=iterations out[1]=final_gaps 29// out[2]=status. returns status. Deterministic $0 proof of the control; the live loop feeds real grounding stats 30// and re-synthesizes between iterations. 31func riv_run(gaps_seq: *i64, nseq: i64, max_iter: i64, trace: *i64, out: *i64) -> i64 { 32 var iter: i64 = 0 33 var prev: i64 = RIV_MAGIC_1000000 34 var status: i64 = RIV_CONTINUE 35 var go: i64 = 1 36 while go == 1 { 37 go = 0 38 var idx: i64 = iter 39 if idx >= nseq { idx = nseq - 1 } 40 let gaps: i64 = gaps_seq[idx] 41 trace[iter] = gaps 42 status = riv_next(gaps, iter, max_iter, prev) 43 if status == RIV_CONTINUE { 44 prev = gaps 45 iter = iter + 1 46 if iter < nseq { go = 1 } else { status = RIV_BUDGET } 47 } 48 } 49 var fidx: i64 = iter 50 if fidx >= nseq { fidx = nseq - 1 } 51 out[0] = iter + 1 52 out[1] = gaps_seq[fidx] 53 out[2] = status 54 return status 55}