code wiki / _hdl_build / nx_teacher_learn.nx

nx_teacher_learn.nx source

↩ module page · 61 lines · 4685 B

1// nx_teacher_learn.nx -- closes the AUTONOMOUS-LEARNING loop: the team captures the lessons from its OWN 2// work session directly into the unified native capability store (no TSV), where they become immediately 3// consumable (recall) / schedulable (trainer) / masterable (mastery). This is the teacher's "grow from 4// caught-mistake signals" principle, run for real on THIS session's verified events. 5// 6// Every lesson below is from a REAL, verified event this session (Rule 4 -- not fabricated): the duplicate 7// Nishi Publisher caught by import resolution; the nx_wiki_devlog prose false-positive; the nxasm ctx-x- 8// output-path bug measured against a manual rc=0 build; the coordinate-through-store decoupling; the 9// runtime/ vs _hdl_build/ import path. Idempotent (dedup by rule). license_tier: ORIGINAL 10import "nx_teacher_merge.nx" 11import "nx_syscalls.nx" 12const K_MAGIC_4096: i64 = 4096 13 14func tl_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != 0 as u8 { n = n + 1 } sys_write(1, s, n); return 0 } 15func tl_putn(v: i64) -> i64 { 16 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 } 17 var m: i64 = v; if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m } 18 let d: *u8 = sys_mmap(24); var k: i64 = 0 19 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 20 var j: i64 = k - 1 21 while j >= 0 { sys_write(1, ((d as i64)+j) as *u8, 1); j = j - 1 } 22 return 0 23} 24func tl_learn(store: *u8, id: *u8, rule: *u8) -> i64 { 25 let r: i64 = tsyn_add_insight(store, "session-2026-06-20\x00" as *u8, id, rule) 26 tl_puts(" + "); tl_puts(id) 27 if r == 1 { tl_puts(" CAPTURED\n") } else { if r == 0 { tl_puts(" (already known -- dedup)\n") } else { tl_puts(" FAILED\n") } } 28 return r 29} 30 31func main() -> i64 { 32 tl_puts("=== Nishi Teacher LEARN: capture THIS session's verified lessons -> native capability store ===\n") 33 let store: *u8 = "knowledge/store/teacher-capability-\x00" as *u8 34 let h0: *i64 = ncfg_open(store) 35 var before: i64 = 0 36 if (h0 as i64) != 0 { before = ncfg_count(h0, "insight\x00" as *u8) } 37 38 var added: i64 = 0 39 added = added + tl_learn(store, "SL-001\x00" as *u8, "Before building an organ, CHECK it does not already exist (find nx_<name>*.nx + grep the capability): I reinvented the complete Nishi Publisher; the gate's import resolved to the REAL one (undefined ncfg_open) and caught it. Reinforces BL-012 DRY before-build.\x00" as *u8) 40 added = added + tl_learn(store, "SL-002\x00" as *u8, "An audit/grep is a COARSE first pass -- a flagged file may only MENTION the pattern in prose, not call it: nx_wiki_devlog only writes 'nx_aw_push' into its emitted HTML, it does not push. READ each flagged file before acting. Reinforces BL-003 measure-don't-assume.\x00" as *u8) 41 added = added + tl_learn(store, "SL-003\x00" as *u8, "nx_sov_build_run NXASM-FAIL rc=102 is the R1-T1-004 ctx-x-OUTPUT-path bug, also for MAIN-bearing organs (not only no-main libs per BL-029): the SAME .s assembles rc=0 to a neutral SHORT path manually (nx_cc_sovereign + nxasm_x86_main). Workaround = keep objects SMALL / do not over-stack imports.\x00" as *u8) 42 added = added + tl_learn(store, "SL-004\x00" as *u8, "Organs should COORDINATE THROUGH the shared native store + a request queue (pub_submit), NOT by importing each other -- loose coupling avoids the deep-import nxasm bloat AND is the publisher's intended decoupling (workstreams REQUEST, the publisher SHIPS, no direct push).\x00" as *u8) 43 added = added + tl_learn(store, "SL-005\x00" as *u8, "A runtime/ file's import search path is [own-dir, runtime/], NOT _hdl_build/: an organ that imports an _hdl_build-only dep (e.g. nx_arbiter, hence the Nishi Publisher) MUST live in _hdl_build/. The teacher->publisher handoff organ lives there for exactly this reason.\x00" as *u8) 44 45 let h1: *i64 = ncfg_open(store) 46 var after: i64 = 0 47 if (h1 as i64) != 0 { after = ncfg_count(h1, "insight\x00" as *u8) } 48 tl_puts(" insights "); tl_putn(before); tl_puts(" -> "); tl_putn(after); tl_puts(" (captured "); tl_putn(added); tl_puts(" new this session)\n") 49 50 // prove immediate consumability: recall one freshly-captured lesson from the store 51 let out: *u8 = sys_mmap(K_MAGIC_4096) 52 if tsyn_recall(store, "SL-001\x00" as *u8, out) == 1 { 53 tl_puts(" recall SL-001: ") 54 var k: i64 = 0 55 while out[k] != (0 as u8) { if k < 70 { sys_write(1, (out as i64 + k) as *u8, 1) } k = k + 1 } 56 tl_puts(" ...\n") 57 } 58 tl_puts(" the team now learns from its OWN work: these lessons are consumable (recall) + drillable (trainer) + masterable (mastery).\n") 59 if after >= before { sys_exit(0); return 0 } 60 sys_exit(1); return 1 61}