code wiki / (root) / nx_chat_swipe_gate.nx

nx_chat_swipe_gate.nx

buildroot/runtime/nx_chat_swipe_gate.nx

10054 B166 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind gate/prooftopic chat
docsdependenciesstructsconstsfunctions

about

nx_chat_swipe_gate.nx -- the REFEREE for companionchat CC4 (the swipe loop in nx_companion_persona.nx): the chat log stays append-only and branch-aware -- a swipe is a SIBLING reply (never an overwrite) and shows by default, a select picks a sibling and persists, an edit overrides the displayed text while the original row remains, the regenerate path loads history WITHOUT the turn being re-answered, the partition (rows = users+assistants+swipes+selects+edits+other) sums and is printed, and a plain user/assistant log loads to the byte-identical legacy shape. GPU-free, in-process; the fixture log lives under /tmp/<gate>/ (the lib reads elara_mem.log from the cwd, so the gate chdirs into its scratch dir). license_tier: ORIGINAL expect_exit: 0

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_companion_persona.nx nx_chat_swipe_gate.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_companion_persona.nx

imported by: nobody (leaf or entry point)

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

main gv_head gv_puts sys_write gv_ctr sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_mkdir sys_chdir sys_mmap ↻ gv_check gv_puts ↻ sys_mmap ↻ sg_write sys_openat_wr sys_write ↻ sg_len sys_close go_mem_partition sys_mmap ↻ cm_load sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read

structs

none

consts

12const SG_DIR: *u8 = "/tmp/nx_chat_swipe_gate" as *u8
13const SG_LOG: *u8 = "/tmp/nx_chat_swipe_gate/elara_mem.log" as *u8
14const SG_MODE_DIR: i64 = 511
15const SG_MODE_FILE: i64 = 420
16const SG_OUT_CAP: i64 = 65536
17const SG_INFO_CAP: i64 = 64
18const SG_MAXLINES: i64 = 32
19const SG_PLAIN: *u8 = "user\thi elara\nassistant\they you, missed you\nuser\thow was the beach\nassistant\tgolden and warm, wish you were there\n" as *u8
20const SG_PLAIN_JSON: *u8 = ",{\"role\":\"user\",\"content\":\"hi elara\"},{\"role\":\"assistant\",\"content\":\"hey you, missed you\"},{\"role\":\"user\",\"content\":\"how was the beach\"},{\"role\":\"assistant\",\"content\":\"golden and warm, wish you were there\"}" as *u8
21const SG_T2_ORIG: *u8 = "golden and warm, wish you were there" as *u8
22const SG_T2_SWIPE: *u8 = "quiet today, I found a shell for you" as *u8
23const SG_T2_EDIT: *u8 = "golden and warm -- next time you come with me" as *u8
24const SG_T1_REPLY: *u8 = "hey you, missed you" as *u8
25const SG_T1_USER: *u8 = "hi elara" as *u8
26const SG_T2_USER: *u8 = "how was the beach" as *u8
27const SG_ORPHAN_LOG: *u8 = "assistant\ta reply with no turn\nuser\thello\nassistant\thi\n" as *u8
28const SG_OUT_OF_RANGE: *u8 = "7" as *u8
29const SG_SELECT_FIRST: *u8 = "0" as *u8

functions

31func sg_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
32func sg_eqn(a: *u8, an: i64, b: *u8) -> i64
called by 1: main calls 1: sg_len
38func sg_find(buf: *u8, n: i64, needle: *u8) -> i64
called by 2: sg_fieldmain calls 1: sg_len
52func sg_write(path: *u8, body: *u8) -> i64
60func sg_log_bytes(bp: *i64) -> i64
called by 1: main calls 2: sys_mmapsys_read_file
69func sg_is_prefix(a: *u8, an: i64, b: *u8, bn: i64) -> i64
called by 1: main
76func sg_field(buf: *u8, n: i64, key: *u8) -> i64
called by 1: main calls 2: sg_findsg_len
93func main() -> i64