code wiki / _hdl_build / nx_card_compile.nx
nx_card_compile.nx
buildroot/runtime/_hdl_build/nx_card_compile.nx
about
nx_card_compile.nx -- CompanionCard COMPILER (F917 rung-1, "first byte up"): elara_card.json (the character
sheet SSOT) compiles DOWNWARD into elara_persona.txt, which the live gen daemon re-reads per request = the
card becomes the byte-one source of who she is, no daemon deploy needed. Fail-closed: age < 18 REFUSES
(adult-companion invariant enforced at the compiler, not by convention). Rule-13: the pre-card persona is
banked ONCE to elara_persona.txt.bak-precard. Write is ATOMIC (tmp + rename; the daemon never sees a torn
file). Composition keeps the battle-tested persona laws VERBATIM (never-AI, sends pics, EN-lock, first
person, no stage directions) -- the card supplies the variable identity/personality half.
usage: nx_card_compile [dir] (dir default /volume1/ai/gen; reads elara_card.json, writes elara_persona.txt)
license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
dependencies 1 imports · 0 importers
imports: nx_syscalls.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
| 11 | const CC_MAGIC_1024: i64 = 1024 |
| 13 | const CC_OUTCAP: i64 = 16384 |
| 14 | const CC_STRCAP: i64 = 2048 |
| 15 | const CC_PATHCAP: i64 = 512 |
| 16 | const CC_MODE: i64 = 420 |
functions
| 18 | func ccm_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 } |
| 19 | func ccm_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 20 | func ccm_catn(d: *u8, o: i64, v: i64) -> i64 { let t: *u8 = sys_mmap(28); var m: i64 = v; if m < 0 { m = 0 } 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 i: i64 = 0; while i < k { d[o] = t[k-1-i]; o = o + 1; i = i + 1 } return o } |
| 21 | func ccm_puts(s: *u8) -> i64 { sys_write(1, s, ccm_len(s)); return 0 } |
| 23 | func ccm_pathjoin(dst: *u8, dir: *u8, name: *u8) -> i64 |
| 33 | func ccm_find(b: *u8, n: i64, pat: *u8) -> i64 |
| 49 | func ccm_key_at(b: *u8, n: i64, key: *u8) -> i64 |
| 61 | func ccm_json_str(b: *u8, n: i64, key: *u8, out: *u8, cap: i64) -> i64 |
| 91 | func ccm_json_int(b: *u8, n: i64, key: *u8) -> i64 |
| 113 | func ccm_json_arr(b: *u8, n: i64, key: *u8, out: *u8, cap: i64) -> i64 |
| 151 | func ccm_first_seg(s: *u8, out: *u8, cap: i64) -> i64 called by 1: main |
| 164 | func ccm_age_words(age: i64, d: *u8, off: i64) -> i64 |
| 176 | func main(argc: i64, argv: *i64) -> i64 |