code wiki / _hdl_build / nx_gen_orchestrator.nx

nx_gen_orchestrator.nx

buildroot/runtime/_hdl_build/nx_gen_orchestrator.nx

121879 B2034 linesdepth 8pulls 36 transitivereach 6 importersview sourcekind librarytopic gen
docsdependenciesstructsconstsfunctions

about

nx_gen_orchestrator.nx -- the NAS-side Elder AI gen daemon (the sovereign gen-img, off Docker). Loopback HTTP backend behind nx_gen_gateway (which OPAQUE-gates /gen + prefix-strips). Routes: GET / -> the gen UI (batch form + results strip + gallery link) POST /api/generate -> validate -> POST the GPU worker /sdapi/v1/txt2img (batch_size=count) -> gp_response (decode/inject-GENREC/ingest/blob/sidecar) -> {cids[]} GET /img/<cid> -> serve the PNG blob (sidecar CID->path lookup) GET /api/recent?n= -> the most recent CIDs (results strip / gallery feed) POST /api/mesh -> {prompt} -> t2mesh (parametric SDF template) -> surface-nets -> STL on disk -> {object,verts,tris,stl} (the 3D lane; CPU in-process, no GPU worker) GET /mesh/<obj>.stl -> serve the emitted STL (name matched against the FIXED template vocabulary, client bytes never reach the filesystem path = traversal impossible) GET /health -> 200 Worker endpoint + store/blob/sidecar paths + generator-host are data-driven via argv (Rule 11/17). argv: [1]=listen_port [2]=worker_a [3]=worker_b [4]=worker_c [5]=worker_d [6]=worker_port [7]=store_prefix [8]=blobdir [9]=sidecar [10]=generator_host [11]=budget license_tier: ORIGINAL

dependencies 17 imports · 6 importers

nx_gen_pipeline.nx nx_syscalls.nx nx_sdfrender.nx nx_meshgen.nx nx_t2mesh.nx nx_companion_identity.nx nx_gen_worker.nx nx_companion_persona.nx nx_companion_wardrobe.nx nx_companion_state.nx nx_gen_orchestrator.nx nx_gen_mesh_gate.nx nx_gen_multiworker_gate.nx nx_gen_orchestrator_daemon.nx nx_gen_orchestrator_gate.nx nx_gen_real_gate.nx nx_photo_count_gate.nx

diagram shows first 10 each side; +7 more imports, +0 more importers in the complete lists below.

imports: nx_gen_pipeline.nxnx_syscalls.nxnx_sdfrender.nxnx_meshgen.nxnx_t2mesh.nxnx_companion_identity.nxnx_gen_worker.nxnx_companion_persona.nxnx_companion_wardrobe.nxnx_companion_state.nxnx_anatomy_risk.nxnx_render_coherence.nxnx_swarm_endpoint_lib.nxnx_llm_route.nxnx_companion_mind.nxnx_store_seed_lib.nxnx_tool_run.nx

imported by: nx_gen_mesh_gate.nxnx_gen_multiworker_gate.nxnx_gen_orchestrator_daemon.nxnx_gen_orchestrator_gate.nxnx_gen_real_gate.nxnx_photo_count_gate.nx

structs

none

consts

35const GEN_BATCH_CAP: i64 = 8
36const GEN_UI_HTML: *u8 = "<!doctype html><html><head><meta charset=utf-8><meta name=viewport content=\"width=device-width,initial-scale=1\"><title>Elder AI &mdash; Gen</title><style>body{font-family:system-ui,sans-serif;max-width:900px;margin:2vh auto;padding:0 16px;color:#cdd7e6;background:#0b1019}h1{font-size:1.25rem;color:#e8eef7}label{display:block;font-size:.78rem;color:#7c8aa5;margin:8px 0 2px}textarea,input,select{width:100%;padding:8px;box-sizing:border-box;border:1px solid #2a3550;border-radius:5px;background:#121a28;color:#e8eef7}.row{display:flex;gap:8px;flex-wrap:wrap}.row>div{flex:1;min-width:90px}button{padding:10px 18px;margin:12px 0;background:#2d6cdf;color:#fff;border:0;border-radius:6px;cursor:pointer;font-size:1rem}#s{font-size:.82rem;color:#7c8aa5;min-height:1.2em}#g{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:8px;margin-top:14px}#g img{width:100%;border-radius:6px;background:#121a28}a{color:#6ea8fe}.mt{margin-top:26px}#cl{background:#121a28;border:1px solid #2a3550;border-radius:6px;padding:10px;min-height:120px;max-height:340px;overflow-y:auto;font-size:.9rem}#cl>div{margin:6px 0}#cs{font-size:.78rem;color:#7c8aa5;min-height:1em}.cu{color:#6ea8fe;font-weight:600}.ca{color:#e8a0c0;font-weight:600}</style></head><body><h1>Elder AI &mdash; image generation</h1><label>Prompt</label><textarea id=p rows=3>a red fox in a snowy pine forest, photograph</textarea><label>Negative prompt</label><input id=n value=\"blurry, lowres\"><div class=row><div><label>Width</label><input id=w type=number value=512></div><div><label>Height</label><input id=h type=number value=512></div><div><label>Steps</label><input id=st type=number value=8></div><div><label>CFG</label><input id=c value=1.0></div><div><label>Seed (-1 rnd)</label><input id=sd type=number value=-1></div><div><label>Count</label><input id=cn type=number value=1 min=1 max=8></div></div><label>Sampler</label><select id=sm><option>euler</option><option>euler_a</option><option>dpm++_2m</option><option>heun</option><option>ddim</option></select><button onclick=gen()>Generate</button> <a href=\"/gen/\">gallery</a><div id=s>ready.</div><div id=g></div><script>function $(i){return document.getElementById(i)}\nasync function gen(){$('s').textContent='generating...';$('g').innerHTML='';try{var r=await fetch('/gen/api/generate',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({prompt:$('p').value,negative:$('n').value,width:+$('w').value,height:+$('h').value,steps:+$('st').value,cfg:$('c').value,seed:+$('sd').value,count:+$('cn').value,sampler:$('sm').value})});var j=await r.json();if(!r.ok){$('s').textContent='error: '+(j.error||r.status);return}$('s').textContent=j.count+' image(s) in '+j.ms+'ms';for(var i=0;i<j.cids.length;i++){var im=document.createElement('img');im.src='/gen/img/'+j.cids[i];$('g').appendChild(im)}}catch(e){$('s').textContent='error: '+e}}\nfetch('/gen/api/recent?n=24').then(function(r){return r.json()}).then(function(j){if(j&&j.cids){for(var i=0;i<j.cids.length;i++){var im=document.createElement('img');im.src='/gen/img/'+j.cids[i];$('g').appendChild(im)}}}).catch(function(){})\nasync function mesh(){$('ms').textContent='generating mesh...';$('mo').innerHTML='';try{var r=await fetch('/gen/api/mesh',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({prompt:$('mp').value})});var j=await r.json();if(!r.ok){$('ms').textContent='error: '+(j.error||r.status);return}$('ms').textContent=j.object+' -- '+j.verts+' verts, '+j.tris+' tris, watertight, '+j.ms+'ms';var a=document.createElement('a');a.href=j.stl;a.download=j.object+'.stl';a.textContent='download '+j.object+'.stl (print-ready)';$('mo').appendChild(a)}catch(e){$('ms').textContent='error: '+e}}</script><h1 style=\"margin-top:26px\">Elder AI &mdash; 3D object</h1><label>Object prompt &mdash; text to a printable watertight STL (vocabulary: ball, snowman, dumbbell, tree, mushroom, bottle, person, cactus, capsule)</label><input id=mp value=\"a snowman in the yard\"><button onclick=mesh()>Generate 3D</button><div id=ms>ready.</div><div id=mo></div>" as *u8
37const GEN_CHAT_HTML: *u8 = "<h1 class=mt>Elara &mdash; chat</h1><div id=cl></div><div class=row style='margin-top:8px'><div style='flex:4'><input id=ci placeholder='say something to Elara'></div><div><button onclick=say()>Send</button></div></div><div id=cs></div><script>var CHIST=[{role:'system',content:'You are Elara, a warm, affectionate, playful companion who speaks naturally and stays in character. Keep replies conversational.'}];function cadd(role,txt){var d=document.createElement('div');d.className=(role=='user'?'cu':'ca');d.textContent=(role=='user'?'you: ':'Elara: ')+txt;var cl=document.getElementById('cl');cl.appendChild(d);cl.scrollTop=1e9}\nasync function say(){var el=document.getElementById('ci');var t=el.value.trim();if(!t){return}el.value='';cadd('user',t);document.getElementById('cs').textContent='Elara is typing...';try{var r=await fetch('/gen/api/chat',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({message:t})});var j=await r.json();if(!r.ok){document.getElementById('cs').textContent='error: '+(j.error||r.status);return}var m=(j.choices&&j.choices[0]&&j.choices[0].message&&j.choices[0].message.content)||'(no reply)';cadd('assistant',m);if(j.images&&j.images.length){var cl=document.getElementById('cl');for(var ii=0;ii<j.images.length;ii++){var im=document.createElement('img');im.src='/gen/img/'+j.images[ii];im.style.maxWidth='170px';im.style.borderRadius='8px';im.style.margin='4px 4px 0 0';cl.appendChild(im)}cl.scrollTop=1e9}document.getElementById('cs').textContent=''}catch(e){document.getElementById('cs').textContent='error: '+e}}\ndocument.getElementById('ci').addEventListener('keydown',function(e){if(e.key=='Enter'){say()}})</script></body></html>" as *u8
346const GO_STEPS_FLOOR: i64 = 1
347const GO_STEPS_CEIL: i64 = 50
348const GO_STEPS_FALLBACK: i64 = 8
352const GO_PHOTO_SIZE: *u8 = "768x1024"
399const GO_CH_DOT: i64 = 46
400const GO_CH_COLON: i64 = 58
401const GO_CH_D0: i64 = 48
402const GO_CH_D9: i64 = 57
657const GO_CNT_CH_0: i64 = 48
658const GO_CNT_CH_9: i64 = 57
659const GO_CNT_CH_A_UP: i64 = 65
660const GO_CNT_CH_Z_UP: i64 = 90
661const GO_CNT_CH_A_LO: i64 = 97
662const GO_CNT_CH_Z_LO: i64 = 122
663const GO_CNT_CASE: i64 = 32
664const GO_CNT_MAX_GAP: i64 = 2
665const GO_CNT_TOKBUF: i64 = 16
666const GO_ALBUM_TSV: *u8 = "elara_album.tsv" as *u8
667const GO_ALBUM_OUT_CAP: i64 = 1048576
668const GO_ALBUM_MAX_DAYS: i64 = 60
669const GO_ALBUM_ROW_CAP: i64 = 32768
670const GO_DAYOFF_CONF_REL: *u8 = "knowledge/gen_day_offset.conf" as *u8
671const GO_DAYOFF_CONF_ABS: *u8 = "/volume1/homes/elderwesto/nishihost/knowledge/gen_day_offset.conf" as *u8
672const GO_FEED_CONF_REL: *u8 = "knowledge/gen_gallery_feed.conf" as *u8
673const GO_FEED_CONF_ABS: *u8 = "/volume1/homes/elderwesto/nishihost/knowledge/gen_gallery_feed.conf" as *u8
674const GO_FEED_TIMEOUT_MS: i64 = 8000
675const GO_FEED_OUT_CAP: i64 = 8192
676const GO_FEED_VAL_CAP: i64 = 512
677const GO_FEED_ARGV_SLOTS: i64 = 8
678const GO_CID_STRIDE: i64 = 80
679const GO_US_PER_S2: i64 = 1000000
680const GO_SECS_PER_HOUR: i64 = 3600
681const GO_SECS_PER_DAY: i64 = 86400
682const GO_STDERR: i64 = 2
683const GO_CH_TAB2: i64 = 9
684const GO_CH_NL2: i64 = 10
685const GO_CH_MINUS: i64 = 45
686const GO_CH_PIPE2: i64 = 124
688const GO_CAL_EPOCH_TO_ERA0: i64 = 719468
689const GO_CAL_DAYS_PER_ERA: i64 = 146097
690const GO_CAL_ERA_LAST_DAY: i64 = 146096
691const GO_CAL_DAYS_PER_4Y: i64 = 1460
692const GO_CAL_DAYS_PER_100Y: i64 = 36524
693const GO_CAL_DAYS_PER_YEAR: i64 = 365
694const GO_CAL_YEARS_PER_ERA: i64 = 400
695const GO_CAL_Q4: i64 = 4
696const GO_CAL_Q100: i64 = 100
697const GO_CAL_MARCH_NUM: i64 = 5
698const GO_CAL_MARCH_OFF: i64 = 2
699const GO_CAL_MARCH_CYCLE: i64 = 153
700const GO_CAL_MONTH_SHIFT_LO: i64 = 3
701const GO_CAL_MONTH_SHIFT_HI: i64 = 9
702const GO_CAL_MONTH_WRAP_AT: i64 = 10
703const GO_CAL_TWO_DIGITS: i64 = 10
1081const GO_CHAT_MODE_NORMAL: i64 = 0
1082const GO_CHAT_MODE_REGEN: i64 = 1
1083const GO_JOB_REGEN: i64 = 4
1084const GO_CHAT_MSG_CAP: i64 = 4096
1085const GO_SWIPE_INFO_BYTES: i64 = 64
1086const GO_SWIPE_NUM_CAP: i64 = 32
1088const GO_HISTORY_CAP: i64 = 1048576
1442const GO_W_PROMPT_CAP: i64 = 8192
1443const GO_W_REQ_CAP: i64 = 65536
1444const GO_W_RESP_CAP: i64 = 262144
1448const GO_WPLANE: *u8 = "/volume1/homes/elderwesto/nishihost/knowledge/store/writemode-"
1780const GO_JOB_GENERATE: i64 = 1
1781const GO_JOB_IMG2IMG: i64 = 2
1782const GO_JOB_CHAT: i64 = 3 // 2026-08-30: chat rides the same async lane -- a 17.6 s measured completion loses to the 15 s edge window every time

functions

39func go_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
40func go_itoa(dst: *u8, off: i64, v: i64) -> i64 { let t: *u8=sys_mmap(28); var m: i64=v; var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var o: i64=off; var q: i64=k-1; while q>=0{dst[o]=t[q];o=o+1;q=q-1} return o }
41func go_cat(dst: *u8, off: i64, s: *u8) -> i64 { var o: i64=off; var i: i64=0; while s[i]!=(0 as u8){dst[o]=s[i]; o=o+1; i=i+1} return o }
42func go_catb(dst: *u8, off: i64, src: *u8, n: i64) -> i64 { var o: i64=off; var i: i64=0; while i<n {dst[o]=src[i]; o=o+1; i=i+1} return o }
43func go_starts(buf: *u8, n: i64, pre: *u8) -> i64 { var i: i64=0; while pre[i]!=(0 as u8){ if i>=n {return 0} if buf[i]!=pre[i]{return 0} i=i+1 } return 1 }
called by 1: go_serve_conn
45func go_send(cfd: i64, status: *u8, ctype: *u8, body: *u8, blen: i64) -> i64
55func go_send_bin(cfd: i64, ctype: *u8, body: *u8, blen: i64) -> i64
65func go_400(cfd: i64, msg: *u8) -> i64 { let b: *u8 = sys_mmap(256); var o: i64 = go_cat(b,0,"{\"error\":\"" as *u8); o=go_cat(b,o,msg); o=go_cat(b,o,"\"}" as *u8); go_send(cfd, "400 Bad Request" as *u8, "application/json" as *u8, b, o); return 0 }
66func go_503(cfd: i64, msg: *u8) -> i64 { let b: *u8 = sys_mmap(256); var o: i64 = go_cat(b,0,"{\"error\":\"" as *u8); o=go_cat(b,o,msg); o=go_cat(b,o,"\"}" as *u8); go_send(cfd, "503 Service Unavailable" as *u8, "application/json" as *u8, b, o); return 0 }
69func go_read_full(cfd: i64, req: *u8, cap: i64) -> i64
90func go_find_seq(buf: *u8, n: i64, needle: *u8, nl: i64) -> i64
96func go_hdr_int(req: *u8, hend: i64, name: *u8, nl: i64) -> i64
called by 1: go_read_full calls 1: go_find_seq
107func go_reqpath(req: *u8, rn: i64, out: *u8, cap: i64) -> i64
called by 1: go_serve_conn
117func go_json_findval(body: *u8, blen: i64, key: *u8) -> i64
136func go_skip_sp(body: *u8, blen: i64, i0: i64) -> i64 { var i: i64=i0; var sk: i64=1; while sk==1 { if i<blen { if (body[i]&0xff)==32 { i=i+1 } else { sk=0 } } else { sk=0 } } return i }
137func go_json_str(body: *u8, blen: i64, key: *u8, out: *u8, outcap: i64) -> i64
159func go_json_int(body: *u8, blen: i64, key: *u8, dflt: i64) -> i64
173func go_json_raw(body: *u8, blen: i64, key: *u8, out: *u8, outcap: i64) -> i64
189func go_emit_jstr(dst: *u8, off: i64, s: *u8) -> i64
208func go_body_start(resp: *u8, n: i64) -> i64 { let he: i64 = go_find_seq(resp, n, "\r\n\r\n" as *u8, 4); if he < 0 { return 0 } return he + 4 }
211func go_sidecar_lookup(sidecar: *u8, cid: *u8, cidlen: i64, pathout: *u8) -> i64
241func go_serve_img(cfd: i64, path: *u8, plen: i64, sidecar: *u8) -> i64
287func go_serve_recent(cfd: i64, sidecar: *u8, k: i64) -> i64
354func go_default_steps() -> i64
373func go_append_turbo_args(dst: *u8, off: i64, steps: i64, cfg: *u8, neg: *u8, seed: i64) -> i64
406func go_swarm_worker(w: *i64) -> i64
called by 1: go_workers_assemble calls 1: se_addr
439func go_workers_assemble(cfg: *i64, ha: i64, hb: i64, hc: i64, hd: i64, wport: i64, wa: *i64, wb: *i64, wc: *i64, wd: *i64, wpa: *i64) -> i64
452func go_handle_generate(cfd: i64, body: *u8, bn: i64, cfg: *i64) -> i64
613func go_atoi(s: *u8) -> i64 { var v: i64=0; var i: i64=0; while s[i]!=(0 as u8){ let c: i64=s[i] as i64; if c<48{return v} if c>57{return v} v=v*10+(c-48); i=i+1 } return v }
called by 1: main
621func go_contains_ci(hay: *u8, hlen: i64, needle: *u8) -> i64
called by 1: go_handle_chat_mode
639func go_parse_count(s: *u8) -> i64
706func go_cnt_lo(c: i64) -> i64 { if c >= GO_CNT_CH_A_UP { if c <= GO_CNT_CH_Z_UP { return c + GO_CNT_CASE } } return c }
707func go_cnt_is_letter(c: i64) -> i64
712func go_cnt_is_digit(c: i64) -> i64 { if c >= GO_CNT_CH_0 { if c <= GO_CNT_CH_9 { return 1 } } return 0 }
714func go_cnt_word_at(s: *u8, n: i64, i: i64, w: *u8) -> i64
725func go_cnt_prefix_at(s: *u8, n: i64, i: i64, w: *u8) -> i64
called by 1: go_parse_count_any calls 1: go_cnt_lo
735func go_cnt_numword(s: *u8, n: i64, i: i64, wl: *i64) -> i64
called by 1: go_parse_count_any calls 1: go_cnt_word_at
754func go_parse_count_any(s: *u8, n: i64, tok: *i64) -> i64
806func go_scene_decount(s: *u8, n: i64, tok: *i64, out: *u8, cap: i64) -> i64
823func go_album_append(pcids: *u8, pn: i64) -> i64
844func go_civil_from_days(days: i64, ymd: *i64) -> i64
called by 1: go_day_str
862func go_day_str(epoch: i64, offhours: i64, out: *u8) -> i64
881func go_album_emit(b: *u8, n: i64, offhours: i64, dst: *u8, off: i64) -> i64
956func go_day_offset() -> i64
986func go_serve_album(cfd: i64) -> i64
997func go_feed_row(b: *u8, n: i64, key: *u8, out: *u8, cap: i64) -> i64
called by 1: go_gallery_feed
1095func go_handle_chat_mode(cfd: i64, body: *u8, bn: i64, cfg: *i64, mode: i64) -> i64
1352func go_handle_chat(cfd: i64, body: *u8, bn: i64, cfg: *i64) -> i64 { return go_handle_chat_mode(cfd, body, bn, cfg, GO_CHAT_MODE_NORMAL) }
1357func go_handle_regen(cfd: i64, body: *u8, bn: i64, cfg: *i64) -> i64
1368func go_handle_chat_select(cfd: i64, body: *u8, bn: i64) -> i64
1396func go_handle_chat_edit(cfd: i64, body: *u8, bn: i64) -> i64
1413func go_serve_chat_history(cfd: i64) -> i64
1435func go_streq(a: *u8, b: *u8) -> i64
1451func go_wmode(mode: *u8, reg: *u8, lane: *u8, structure: *u8) -> i64
1498func go_wsys(structure: *u8, out: *u8) -> i64
called by 1: go_handle_write calls 2: go_catgo_streq
1514func go_wq_catn(b: *u8, off: i64, v: i64) -> i64
called by 1: go_handle_write calls 1: sys_mmap
1525func go_handle_write(cfd: i64, body: *u8, bn: i64, cfg: *i64) -> i64
1607func go_wfs(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd, s, n); return 0 }
called by 1: go_write_stl calls 1: sys_write
1608func go_stlnum(fd: i64, v: i64) -> i64
called by 1: go_write_stl calls 2: sys_mmapsys_write
1618func go_write_stl(vbuf: *i64, fbuf: *i64, nf: i64, path: *u8) -> i64
1637func go_mesh_path(sp: *u8, blobdir: *u8, nm: *u8) -> i64
1645func go_handle_mesh(cfd: i64, body: *u8, bn: i64, cfg: *i64) -> i64
1683func go_name_eq(path: *u8, plen: i64, nm: *u8) -> i64
called by 1: go_serve_mesh_file
1695func go_serve_mesh_file(cfd: i64, path: *u8, plen: i64, blobdir: *u8) -> i64
1715func go_mood_label(st: *i64, out: *u8) -> i64
called by 1: go_serve_state calls 1: go_cat
1725func go_day_activity(out: *u8) -> i64
1741func go_serve_state(cfd: i64) -> i64
1759func go_serve_ui(cfd: i64) -> i64
1797func go_job_submit(cfd: i64, body: *u8, bn: i64, cfg: *i64, which: i64) -> i64
1820func go_handle_batch(cfd: i64, body: *u8, bn: i64, cfg: *i64) -> i64
called by 1: go_serve_conn calls 1: go_job_submit
1824func go_serve_batch(cfd: i64, path: *u8, plen: i64) -> i64
1842func go_png_dim(png: *u8, n: i64, wh: *i64) -> i64
called by 1: go_handle_img2img
1856func go_handle_img2img(cfd: i64, body: *u8, bn: i64, cfg: *i64) -> i64
1965func go_handle_anatomy(cfd: i64, body: *u8, bn: i64) -> i64
1986func go_serve_conn(cfd: i64, cfg: *i64) -> i64