code wiki / _hdl_build / nx_research_auto.nx

nx_research_auto.nx source

↩ module page · 51 lines · 3025 B

1// nx_research_auto.nx -- the AUTONOMOUS research loop (operator: "keep building the teams ability to 2// handle autonomously"). One tick = the team running its own research round, end to end, GOVERNED so 3// it stays broad-and-polite and self-monitored so it knows when to keep going, re-task, or stop -- 4// no human in the loop. Composes three proven organs: 5// * nx_polite_crawl -- pc_research_gate: a round only counts if it was BROAD + POLITE (no blowback) 6// * nx_research_synth -- rs_scan: mechanically corroborate the fetched corpus (>=2 sources -> admit) 7// * nx_loop_monitor -- lm_classify/lm_action: PRODUCTIVE -> continue, DRY -> re-task, STALL -> restart 8// The tick returns the team's own decision so the loop self-drives. HONEST: live fetch is the 9// NAS-side egress step (nx_browse_text via the governor); this tick is the autonomous CONTROL + 10// corroboration + monitoring that wraps it, gate-proven offline over a simulated round. 11// LAWS: struct-free, integer-only. license_tier: ORIGINAL 12import "nx_polite_crawl.nx" 13import "nx_research_synth.nx" 14import "nx_loop_monitor.nx" 15import "nx_syscalls.nx" 16 17// per-round inputs/outputs of one autonomous research tick. 18// in: distinct_hosts, total_requests, req_per_host[], n_hosts, corpus bytes (buf,len), 19// prev_zero_streak (consecutive dry rounds before this one) 20// out: out[0]=gate_ok(broad+polite) out[1]=new_admitted out[2]=monitor_verdict out[3]=action 21// out[4]=updated_zero_streak 22// returns the ACTION (LM_CONTINUE / LM_RETASK / LM_RESTART) -- the team's self-decision. 23func ra_tick(distinct_hosts: i64, total_requests: i64, req_per_host: *i64, n_hosts: i64, 24 corpus: *u8, corpus_len: i64, prev_zero_streak: i64, out: *i64) -> i64 { 25 // 1) POLITENESS+BREADTH GATE: a round that wasn't broad-and-polite is REJECTED outright 26 // (better to bank nothing than to risk bot blowback). min 50 hosts, <=2/host, >=500permil breadth. 27 let gate: i64 = pc_research_gate(distinct_hosts, total_requests, req_per_host, n_hosts, 50, 2, 500) 28 out[0] = gate 29 30 // 2) CORROBORATE the fetched corpus mechanically (only if the round was admissible) 31 var admitted: i64 = 0 32 if gate == 1 { 33 let scan: *i64 = sys_mmap(64) as *i64 34 rs_scan(corpus, corpus_len, "\nC" as *u8, scan) 35 admitted = scan[1] 36 } 37 out[1] = admitted 38 39 // 3) SELF-MONITOR: did this round bank wins? update the dry-streak, classify, decide. 40 var zero_streak: i64 = prev_zero_streak 41 if admitted > 0 { zero_streak = 0 } else { zero_streak = prev_zero_streak + 1 } 42 let advancing: i64 = 1 // the loop is making requests (not hung) when gated ok 43 var adv: i64 = advancing 44 if gate == 0 { adv = 0 } // a rejected round = not advancing usefully 45 let verdict: i64 = lm_classify(admitted, adv, zero_streak, 3) // dry after 3 zero rounds 46 let action: i64 = lm_action(verdict) 47 out[2] = verdict 48 out[3] = action 49 out[4] = zero_streak 50 return action 51}