nx_chat_ring.nx
buildroot/runtime/nx_chat_ring.nx
about
nx_chat_ring.nx -- bounded-ring chat buffer with sealed message slots.
Promoted from the nishi_video_room_synology.nx L77-L78 chat ring
(per [[project-nishifamily-video-l66-l75-2026-05-16]] commits 8406e7a9
+ 846fd399). Same wire format + same persistence semantics; new
home is the OOP layer so any consumer (video room, nx_call,
nx_cli_meet, nx_iot_intercom) can reuse it without re-implementing.
Ring contract:
- Sealed capacity at construction; full ring wraps oldest-first.
- Monotonic sequence numbers (consumers can ask "what's new since N?").
- Per-message metadata: seq, sender_peer_id, kind, byte_len, unix_ms.
- Pluggable persistence (disk / memory / future MLS-encrypted).
dependencies 1 imports · 3 importers
imports: nx_syscalls_x86_64.nx
imported by: nx_call.nxnx_chat_session.nxnx_cli_meet.nx
structs
| 51 | struct ChatSlot |
| 64 | struct nx_chat_ring |
consts
| 28 | const NX_CHAT_KIND_UNKNOWN: i64 = 0 |
| 29 | const NX_CHAT_KIND_TEXT: i64 = 1 // plain user text |
| 30 | const NX_CHAT_KIND_REACT: i64 = 2 // emoji/reaction |
| 31 | const NX_CHAT_KIND_PRESENCE: i64 = 3 // "alice joined / alice left" |
| 32 | const NX_CHAT_KIND_SYS: i64 = 4 // server status notice |
| 33 | const NX_CHAT_KIND_NAME: i64 = 5 // peer set display name |
| 34 | const NX_CHAT_KIND_HANDRAISE: i64 = 6 |
| 35 | const NX_CHAT_KIND_N: i64 = 7 |
| 39 | const NX_CHAT_RING_OK: i64 = 0 |
| 40 | const NX_CHAT_RING_ERR_FULL_TXT: i64 = -1 // body too big for ring text-arena |
| 41 | const NX_CHAT_RING_ERR_BAD_KIND: i64 = -2 |
| 42 | const NX_CHAT_RING_ERR_BAD_SEQ: i64 = -3 |
| 43 | const NX_CHAT_RING_ERR_TXT_CAP: i64 = -4 // requested single msg larger than ring text capacity |
| 60 | const NX_CHAT_SLOT_BYTES: i64 = 48 |
| 75 | const NX_CHAT_RING_BYTES: i64 = 64 |
functions
| 79 | func nx_chat_ring_new(r: *nx_chat_ring, cap_slots: i64, txt_cap: i64) -> i64 called by 1: nx_chat_session_new |
| 103 | func nx_chat_ring_append(r: *nx_chat_ring, called by 1: nx_chat_session_post |
| 144 | func nx_chat_ring_next_seq(r: *nx_chat_ring) -> i64 called by 1: nx_chat_session_next_seq |
| 148 | func nx_chat_ring_count(r: *nx_chat_ring) -> i64 |
| 155 | func nx_chat_ring_get_by_seq(r: *nx_chat_ring, seq: i64) -> *ChatSlot called by 1: nx_chat_session_get_by_seq |
| 167 | func nx_chat_ring_get_at(r: *nx_chat_ring, i: i64) -> *ChatSlot |
| 180 | func nx_chat_ring_copy_text(r: *nx_chat_ring, slot: *ChatSlot, called by 1: nx_chat_session_copy_text |