code wiki / (root) / nx_elara_state.nx

nx_elara_state.nx

buildroot/runtime/nx_elara_state.nx

38238 B737 linesdepth 6pulls 11 transitivereach 0 importersview sourcekind tooltopic elara
docsdependenciesstructsconstsfunctions

about

nx_elara_state.nx -- F975 rung 1: the COMPANION STATE-COHERENCE ENGINE. THE KEYSTONE (operator charter 2026-07-23): "she DRESSES HERSELF UP and KEEPS herself dressed ... a synthetic human ... with LOGICAL CONSISTENCY based on her INTERNAL THOUGHT PROCESS ... who FLOWS THROUGH THE DAY, not scene to scene or clip to clip." That is only possible if ONE state store holds her wardrobe/mood/location/arousal/energy/arc/dynamic and the chat persona + the gen prompt composer + the wardrobe logic ALL read AND write it. Without it, "she stays dressed" is per-image luck; with it, consistency is BY CONSTRUCTION -- what she SAYS == what she WEARS == where she IS, across turns. This is rung 1: PERSISTENT, AGENT-WRITABLE current state on the sovereign seg-store, MCP-exposed. Each `set` also appends to a per-session TIMELINE (append-only, real-clock stamped) so rung 2 (F920 idle day-arcs / dream-cycle advancing state between interactions) has the substrate to flow over. NOT gen: no image is produced here -- this is the mind's state, which the (GPU-gated) gen path reads. OO/SCALE: state is CID-keyed NXR1 records on nx_seg_store via nx_registry (last-write-wins per key, O(log) get, additive history). Composes proven organs; introduces no new storage format. VERBS get <session> -> JSON of every state field (charter defaults for unset ones) set <session> <field> <value> -> update one field (validated field name) + timeline append dress <session> <outfit_key> [loc] -> set outfit (+ location) THROUGH the elaragram- rules: refuses an unknown outfit, and (if loc given) flags an exposure-ceiling conflict -- the "keep herself dressed appropriately" primitive timeline <session> [max] -> the flowing-day log, newest last selftest -> gate, verdict=GREEN|RED FIELDS (charter-derived, the only settable names): outfit location mood arousal energy activity arc_stage dynamic. `dynamic` = the reversible relational stance (e.g. submissive|dominant|switch) so a companion can act sub while the operator acts domme, or the reverse, per companion. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_canon_cid.nx nx_seg_store.nx nx_registry.nx nx_elara_state.nx

imports: nx_syscalls.nxnx_canon_cid.nxnx_seg_store.nxnx_registry.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mkdir es_eq es_selftest sys_mmap es_cat es_udec sys_now_us sys_mmap ↻ sys_clock_gettime_mono es_get_field sys_mmap ↻ es_key es_cat ↻ es_ch reg_get reg_key reg_cat ss_get sys_mmap ↻ ss_scan sys_mmap ↻ ss_manifest_dyn ss_scan_seglist es_field_default es_field_index es_eq ↻ es_field_name es_eq ↻ es_puts sys_write es_set_field sys_mmap ↻ es_key ↻ es_cat ↻ es_udec ↻ sys_now_realtime_ms sys_mmap ↻ sys_clock_gettime_real reg_put

structs

none

consts

35const ES_MAGIC_4096: i64 = 4096
36const ES_MAGIC_4194304: i64 = 4194304
37const ES_MAGIC_8192: i64 = 8192
38const ES_MAGIC_1024: i64 = 1024
39const ES_MAGIC_16384: i64 = 16384
40const ES_MAGIC_3600: i64 = 3600
42const ES_STORE: *u8 = "knowledge/store/elarastate-" as *u8
43const ES_GRAM: *u8 = "knowledge/store/elaragram-" as *u8 // the wardrobe grammar plane (nx_sqlite_rows)
44const ES_NFIELD: i64 = 8
625const ES_TZ_OFFSET_SEC: i64 = 0 - 18000

functions

46func es_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 3: es_dresses_selftestmain calls 1: sys_write
47func es_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
48func es_eq(a: *u8, b: *u8) -> i64
57func es_cat(d: *u8, o: i64, s: *u8) -> i64 { var p: i64 = o; var i: i64 = 0; while s[i] != (0 as u8) { d[p] = s[i]; p = p + 1; i = i + 1 } return p }
58func es_ch(d: *u8, o: i64, c: i64) -> i64 { d[o] = c as u8; return o + 1 }
59func es_udec(d: *u8, o: i64, v: i64) -> i64
70func es_jesc(d: *u8, o: i64, s: *u8, n: i64) -> i64
90func es_field_name(i: i64) -> *u8
101func es_field_default(i: i64) -> *u8
called by 1: es_get_field
112func es_field_index(name: *u8) -> i64
119func es_key(kb: *u8, session: *u8, field: *u8) -> i64
130func es_timeline_append(session: *u8, field: *u8, value: *u8) -> i64
150func es_set_field(session: *u8, field: *u8, value: *u8) -> i64
165func es_get_field(session: *u8, field: *u8, out: *u8) -> i64
192func es_timeline_emit(session: *u8, max: i64) -> i64
239func es_emit_state(session: *u8) -> i64
267func es_r32(p: *u8, o: i64) -> i64 { let a: i64=p[o]; let b: i64=p[o+1]; let c: i64=p[o+2]; let d: i64=p[o+3]; return (((((a<<8)|b)<<8)|c)<<8)|d }
272func es_nxr1_field_cap(rec: *u8, reclen: i64, key: *u8, out: *u8, maxout: i64) -> i64
309func es_nxr1_field(rec: *u8, reclen: i64, key: *u8, out: *u8) -> i64
312func es_atoi(s: *u8) -> i64
319func es_csv_has(csv: *u8, needle: *u8) -> i64
called by 1: es_dress calls 1: es_len
338func es_find_outfit(target: *u8, loctags: *u8, nsfw: *u8, name: *u8, desc: *u8) -> i64
415func es_dress(session: *u8, outfit_key: *u8, location: *u8, has_loc: i64) -> i64
455func es_selftest() -> i64
569func es_context(session: *u8) -> i64
627func es_cpz(dst: *u8, src: *u8) -> i64 { var i: i64=0; while src[i]!=(0 as u8){ dst[i]=src[i]; i=i+1 } dst[i]=0 as u8; return i }
632func es_daystate(epoch: i64, stage_out: *u8, energy_out: *u8, act_out: *u8, mood_out: *u8) -> i64
called by 1: es_tick calls 1: es_cpz
647func es_field_epoch(session: *u8, field: *u8) -> i64
called by 1: es_tick calls 3: sys_mmapes_keyreg_get
671func es_tick(session: *u8) -> i64
692func main(argc: i64, argv: *i64) -> i64