nx_elara_state.nx
buildroot/runtime/nx_elara_state.nx
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
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
structs
| none |
consts
| 35 | const ES_MAGIC_4096: i64 = 4096 |
| 36 | const ES_MAGIC_4194304: i64 = 4194304 |
| 37 | const ES_MAGIC_8192: i64 = 8192 |
| 38 | const ES_MAGIC_1024: i64 = 1024 |
| 39 | const ES_MAGIC_16384: i64 = 16384 |
| 40 | const ES_MAGIC_3600: i64 = 3600 |
| 42 | const ES_STORE: *u8 = "knowledge/store/elarastate-" as *u8 |
| 43 | const ES_GRAM: *u8 = "knowledge/store/elaragram-" as *u8 // the wardrobe grammar plane (nx_sqlite_rows) |
| 44 | const ES_NFIELD: i64 = 8 |
| 625 | const ES_TZ_OFFSET_SEC: i64 = 0 - 18000 |
functions
| 46 | func 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 } |
| 47 | func es_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 48 | func es_eq(a: *u8, b: *u8) -> i64 |
| 57 | func 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 } |
| 58 | func es_ch(d: *u8, o: i64, c: i64) -> i64 { d[o] = c as u8; return o + 1 } |
| 59 | func es_udec(d: *u8, o: i64, v: i64) -> i64 |
| 70 | func es_jesc(d: *u8, o: i64, s: *u8, n: i64) -> i64 |
| 90 | func es_field_name(i: i64) -> *u8 |
| 101 | func es_field_default(i: i64) -> *u8 called by 1: es_get_field |
| 112 | func es_field_index(name: *u8) -> i64 |
| 119 | func es_key(kb: *u8, session: *u8, field: *u8) -> i64 |
| 130 | func es_timeline_append(session: *u8, field: *u8, value: *u8) -> i64 |
| 150 | func es_set_field(session: *u8, field: *u8, value: *u8) -> i64 called by 4: es_dresses_selftestes_tickmain calls 7: sys_mmapes_keyes_cates_udecsys_now_realtime_msreg_put+1 |
| 165 | func es_get_field(session: *u8, field: *u8, out: *u8) -> i64 called by 3: es_emit_statees_selftestes_context calls 5: sys_mmapes_keyreg_getes_field_defaultes_field_index |
| 192 | func es_timeline_emit(session: *u8, max: i64) -> i64 |
| 239 | func es_emit_state(session: *u8) -> i64 |
| 267 | func 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 } |
| 272 | func es_nxr1_field_cap(rec: *u8, reclen: i64, key: *u8, out: *u8, maxout: i64) -> i64 |
| 309 | func es_nxr1_field(rec: *u8, reclen: i64, key: *u8, out: *u8) -> i64 calls 1: es_nxr1_field_cap |
| 312 | func es_atoi(s: *u8) -> i64 |
| 319 | func es_csv_has(csv: *u8, needle: *u8) -> i64 |
| 338 | func es_find_outfit(target: *u8, loctags: *u8, nsfw: *u8, name: *u8, desc: *u8) -> i64 called by 3: es_dresses_selftestes_context calls 8: sys_mmapes_catsys_read_filesys_map_filees_r32es_nxr1_field_cap+2 |
| 415 | func es_dress(session: *u8, outfit_key: *u8, location: *u8, has_loc: i64) -> i64 |
| 455 | func es_selftest() -> i64 |
| 569 | func es_context(session: *u8) -> i64 |
| 627 | func 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 } |
| 632 | func es_daystate(epoch: i64, stage_out: *u8, energy_out: *u8, act_out: *u8, mood_out: *u8) -> i64 |
| 647 | func es_field_epoch(session: *u8, field: *u8) -> i64 |
| 671 | func es_tick(session: *u8) -> i64 |
| 692 | func main(argc: i64, argv: *i64) -> i64 |