code wiki / _hdl_build / nx_connect_serve.nx
nx_connect_serve.nx
buildroot/runtime/_hdl_build/nx_connect_serve.nx
about
nx_connect_serve.nx -- the CONNECT interactive app, PURE CORE (no main).
2026-07-23 REWRITE (operator: "from the first byte up with a better ui emitter, then wire all the
capabilities together"): this was ONE page of hand-rolled inline CSS. It is now a MULTI-PAGE app
emitted entirely through nx_connect_ui -- the app-tier UI emitter that carries the canonical
nishi_ds design tokens -- with real cross-page navigation, and it surfaces capabilities that were
gate-proven but INVISIBLE to any actual user until now.
THE SURFACES (each one drives a gated organ, not a mock):
/ home: what this is, live counters, and a route into every capability
/partners reciprocal language exchange -- a one-sided pair renders 0 (the R1 harmonic-mean law)
/chat real inline translation through nx_mt_multi, unlimited BY CONSTRUCTION (no quota
state exists in this file), corrections attach without destroying the original
/reconnect *** the LDS signature, LIVE FOR THE FIRST TIME: member <-> missionary reconnection
through the SHARED library nx_connect_lds_reconnect_lib -- the same code the gate
verifies. Same mission AND shared area AND time overlap are all NECESSARY, and
discovery is consent-gated both ways, so the page can SHOW you why someone does
not surface. Nothing is surfaced at all until you opt in.
/community ward/branch COMMUNITY group (never congregation administration) + an honest poll
where a revote REPLACES, so a tally can never inflate
/events real-world meetups with the TWO-DEEP youth wall enforced live and the refusal
RENDERED, not hidden
Zero JS, render-on-POST, per-session isolated state (see nx_connect_accounts). All user text is escaped
on the way out. PURE CORE: cs_handle(ctx, req, reqlen, out, cap).
license_tier: ORIGINAL
dependencies 11 imports · 4 importers
diagram shows first 10 each side; +1 more imports, +0 more importers in the complete lists below.
imports: nx_syscalls.nxnx_mt_multi.nxnx_connect_ui.nxnx_connect_lds_reconnect_lib.nxnx_connect_match_lib.nxnx_connect_youth_lib.nxnx_connect_wards_lib.nxnx_connect_lanes_lib.nxnx_connect_events_lib.nxnx_connect_polls_lib.nxnx_connect_group_lib.nx
imported by: nx_connect_accounts.nxnx_connect_app_gate.nxnx_connect_auth_gate.nxnx_connect_pubkey_bind_gate.nx
structs
| none |
consts
| 39 | const CS_MSGCAP: i64 = 32 |
| 40 | const CS_TXT: i64 = 128 |
| 41 | const CS_SLOTS: i64 = 32 // ctx slots (was 16; grown for the reconnect + community state) |
| 45 | const CS_NMSG: i64 = 0 |
| 46 | const CS_SPK: i64 = 1 |
| 47 | const CS_TXTA: i64 = 2 |
| 48 | const CS_CORR: i64 = 3 |
| 49 | const CS_EV1_GOING: i64 = 4 |
| 50 | const CS_EV2_ADULTS: i64 = 5 |
| 51 | const CS_EV2_MINORS: i64 = 6 |
| 52 | const CS_BANNER: i64 = 7 |
| 54 | const CS_POLL: i64 = 8 |
| 55 | const CS_RC_CONSENT: i64 = 9 // reconnection discovery opt-in (Art.9-style; 0 = surface nothing) |
| 56 | const CS_RC_MISSION: i64 = 10 |
| 57 | const CS_RC_AREA: i64 = 11 |
| 58 | const CS_RC_FROM: i64 = 12 // year |
| 59 | const CS_RC_TO: i64 = 13 // year |
| 60 | const CS_RC_DONE: i64 = 14 // a search has been run in this session |
| 61 | const CS_WARD: i64 = 15 // joined the ward/branch community group |
| 62 | const CS_FAITH_CONSENT: i64 = 16 // explicit faith consent (Art.9) -- ward membership is faith-revealing |
| 63 | const CS_LANE_ME: i64 = 17 // the lane I have opted into for this relationship |
| 64 | const CS_LANE_THEM: i64 = 18 // the lane they have opted into |
| 65 | const CS_BLOCKED: i64 = 19 // either side may block, unilaterally |
| 66 | const CS_CT: i64 = 20 // POINTER to the content-blind ciphertext log (set in world_new, not a data slot) |
| 67 | const CS_NCT: i64 = 21 // count of stored ciphertexts (data slot; persisted) |
| 68 | const CS_CTHEX: i64 = 256 // max ciphertext-hex length per sealed message |
| 76 | const SH_PUBCAP: i64 = 64 // bounded + declared: directory capacity |
| 77 | const SH_MSGCAP: i64 = 128 // bounded + declared: routed ciphertext capacity |
| 78 | const SH_NAME: i64 = 32 // stored name bytes (z-term inside) |
| 79 | const SH_PUBHEX: i64 = 68 // 64 hex chars + z |
| 80 | const SH_SEQ: i64 = 24 // decimal per-message nonce seq (z-term) |
| 81 | const SH_PUBSTRIDE: i64 = 100 // SH_NAME + SH_PUBHEX |
| 82 | const SH_MSGSTRIDE: i64 = 344 // from(32) + to(32) + seq(24) + ct(CS_CTHEX) |
| 83 | const SH_PUB0: i64 = 512 // pub arena byte offset inside the shared block |
| 84 | const SH_MSG0: i64 = 6912 // SH_PUB0 + SH_PUBCAP*SH_PUBSTRIDE |
| 85 | const SH_DEL0: i64 = 51072 // SH_MSG0 + SH_MSGCAP*SH_MSGSTRIDE (6912 + 128*344); 1 delivered-flag per msg |
| 89 | const SH_OWN0: i64 = 51200 |
| 90 | const SH_OWNSTRIDE: i64 = 40 |
| 93 | const CS_B_NONE: i64 = 0 |
| 94 | const CS_B_RSVP_NO: i64 = 1 |
| 95 | const CS_B_RSVP_OK: i64 = 2 |
| 96 | const CS_B_VOTE_OK: i64 = 3 |
| 97 | const CS_B_CONSENT_ON: i64 = 4 |
| 98 | const CS_B_CONSENT_OFF: i64 = 5 |
| 99 | const CS_B_SEARCHED: i64 = 6 |
| 100 | const CS_B_JOINED: i64 = 7 |
| 101 | const CS_B_JOIN_NO: i64 = 8 // join refused: no faith consent |
| 102 | const CS_B_FAITH_ON: i64 = 9 |
| 103 | const CS_B_FAITH_OFF: i64 = 10 |
| 104 | const CS_B_ALREADY: i64 = 11 // idempotent re-join |
| 105 | const CS_B_LANE: i64 = 12 |
| 106 | const CS_B_BLOCK: i64 = 13 |
| 107 | const CS_B_UNBLOCK: i64 = 14 |
| 108 | const CS_B_RSVP_FULL: i64 = 15 // engine returned -2: at capacity |
| 109 | const CS_B_RSVP_ADULTONLY: i64 = 16 // engine returned -4: a minor on a non-youth event |
| 110 | const CS_B_RSVP_NOTMEMBER: i64 = 17 // engine returned -1: not in the event's group (never silently ignored) |
| 111 | const CS_B_SEALED: i64 = 18 // a client-encrypted ciphertext was received + stored (server never saw plaintext) |
| 112 | const CS_B_SEAL_BAD: i64 = 19 // rejected: not valid ciphertext hex |
| 113 | const CS_B_CONTACT_ADDED: i64 = 25 |
| 114 | const CS_B_CONTACT_DUP: i64 = 26 |
| 115 | const CS_B_CONTACT_BAD: i64 = 27 |
| 116 | const CS_B_CONTACT_SELF: i64 = 28 |
| 117 | const CS_B_CONTACT_FULL: i64 = 29 |
| 118 | const CS_B_CONTACT_RM: i64 = 30 |
| 121 | const CS_P_HOME: i64 = 0 |
| 122 | const CS_P_PARTNERS: i64 = 1 |
| 123 | const CS_P_CHAT: i64 = 2 |
| 124 | const CS_P_RECON: i64 = 3 |
| 125 | const CS_P_COMMUNITY: i64 = 4 |
| 126 | const CS_P_EVENTS: i64 = 5 |
| 127 | const CS_P_SECURE: i64 = 6 // the content-blind inbox: ciphertext the server received but cannot read |
| 128 | const CS_P_LOGIN: i64 = 7 // sign in (OPAQUE aPAKE form) |
| 129 | const CS_P_REGISTER: i64 = 8 // create an account |
| 130 | const CS_P_ACCOUNT: i64 = 9 // signed-in identity home (sign out lives here) |
| 131 | const CS_P_CONTACTS: i64 = 10 // the signed-in contact list |
| 136 | const CS_AUTH: i64 = 24 // 0 = anonymous, 1 = an OPAQUE session validated this request |
| 137 | const CS_HANDLE: i64 = 25 // pointer to the authenticated handle z-string (0 when anonymous) |
| 138 | const CS_AUTH_EVENT: i64 = 26 // survives cs_handle2's banner reset -> mapped to a banner just before render |
| 139 | const CS_MNEMONIC: i64 = 27 // ptr to the 24-word recovery phrase, set ONCE right after register (else 0) |
| 140 | const CS_CONTACTS: i64 = 28 // ptr to the per-account contact-handle buffer (mmap in cs_world_new) |
| 141 | const CS_NCONTACTS: i64 = 29 // number of contacts (persisted with the world) |
| 142 | const CS_SH: i64 = 30 // ptr to the shared plane (daemon-set per request; 0 in offline gates) |
| 143 | const CS_UID: i64 = 31 // ptr to the authenticated 32-byte user-id (daemon-set; 0 when anonymous) |
| 144 | const CS_CONTACT_MAX: i64 = 128 // bounded + declared: max contacts per account |
| 145 | const CS_CONTACT_LEN: i64 = 32 // stored bytes per contact handle (z-term inside) |
| 147 | const CS_AE_NONE: i64 = 0 |
| 148 | const CS_AE_SIGNED_IN: i64 = 1 |
| 149 | const CS_AE_REGISTERED: i64 = 2 |
| 150 | const CS_AE_SIGNED_OUT: i64 = 3 |
| 151 | const CS_AE_LOGIN_FAIL: i64 = 4 // wrong handle OR passphrase -- deliberately indistinguishable |
| 152 | const CS_AE_REG_TAKEN: i64 = 5 // handle already exists |
| 153 | const CS_AE_REG_BAD: i64 = 6 // handle/passphrase failed the input rules |
| 156 | const CS_EPOCH_YEAR: i64 = 2010 |
| 876 | const CS_ME_AGE: i64 = 30 |
| 877 | const CS_ME_LEARN: i64 = 16 |
| 878 | const CS_ME_TEACH: i64 = 1 |
| 879 | const CS_ME_INT: i64 = 5 |
| 880 | const CS_NCAND: i64 = 4 |
| 1333 | const CS_EV_PICNIC: i64 = 0 |
| 1334 | const CS_EV_YOUTH: i64 = 1 |
| 1335 | const CS_EV_PICNIC_CAP: i64 = 6 |
| 1336 | const CS_EV_YOUTH_CAP: i64 = 8 |
| 1337 | const CS_EV_GROUP: i64 = 1 |
| 1340 | const CS_EV_NEW_ADULT: i64 = 30 |
| 1341 | const CS_EV_NEW_MINOR: i64 = 130 |
| 1342 | const CS_EV_ROSTER: i64 = 30 // adults 1..30, youth 101..130 (must stay <= MB_MAX/UA_MAX halves) |
functions
| 160 | func cs_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 161 | func cs_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){dst[off+i]=s[i]; i=i+1} return off+i } |
| 162 | func cs_catn(dst: *u8, off: i64, v: i64) -> i64 { return cu_putn(dst, off, v) } |
| 163 | func cs_esc(dst: *u8, off: i64, s: *u8) -> i64 { return cu_esc(dst, off, s) } calls 1: cu_esc |
| 164 | func cs_seq(a: *u8, b: *u8) -> i64 |
| 170 | func cs_starts(s: *u8, pfx: *u8) -> i64 { var i: i64=0; while pfx[i]!=(0 as u8){ if s[i]!=pfx[i] { return 0 } i=i+1 } return 1 } called by 1: cs_handle2 |
| 171 | func cs_hexval(c: i64) -> i64 |
| 178 | func cs_atoi(s: *u8, def: i64) -> i64 called by 1: cs_handle2 |
| 191 | func cs_year_to_month(y: i64) -> i64 { return (y - CS_EPOCH_YEAR) * 12 } called by 1: cs_page_reconnect |
| 194 | func cs_form_get(body: *u8, blen: i64, key: *u8, out: *u8, cap: i64) -> i64 |
| 230 | func cs_write_all(fd: i64, buf: *u8, n: i64) -> i64 calls 1: sys_write |
| 236 | func cs_read_req(fd: i64, buf: *u8, cap: i64) -> i64 calls 1: sys_read |
| 287 | func cs_world_reset(ctx: *i64) -> i64 |
| 326 | func cs_world_new() -> *i64 |
| 343 | func cs_contact_at(ctx: *i64, i: i64) -> *u8 { return (ctx[CS_CONTACTS] + i*CS_CONTACT_LEN) as *u8 } |
| 344 | func cs_contact_find(ctx: *i64, name: *u8) -> i64 |
| 350 | func cs_contact_add(ctx: *i64, name: *u8) -> i64 |
| 364 | func cs_contact_remove(ctx: *i64, name: *u8) -> i64 |
| 381 | func cs_shared_new() -> *i64 |
| 391 | func sh_pub_at(sh: *i64, i: i64) -> *u8 { return (sh as i64 + SH_PUB0 + i*SH_PUBSTRIDE) as *u8 } |
| 392 | func sh_msg_at(sh: *i64, i: i64) -> *u8 { return (sh as i64 + SH_MSG0 + i*SH_MSGSTRIDE) as *u8 } |
| 393 | func sh_del_at(sh: *i64, i: i64) -> *u8 { return (sh as i64 + SH_DEL0 + i) as *u8 } // 1 = delivered/tombstoned |
| 395 | func sh_own_at(sh: *i64, i: i64) -> *u8 { return (sh as i64 + SH_OWN0 + i*SH_OWNSTRIDE) as *u8 } |
| 397 | func cs_copy32(dst: *u8, src: *u8) -> i64 { var i: i64=0; while i<32 { dst[i]=src[i]; i=i+1 } return 32 } called by 1: cs_sh_pub_put2 |
| 398 | func cs_eq32(a: *u8, b: *u8) -> i64 { var i: i64=0; while i<32 { if a[i]!=b[i] { return 0 } i=i+1 } return 1 } |
| 400 | func cs_hex_emit(dst: *u8, off: i64, raw: *u8, nbytes: i64) -> i64 called by 1: cs_sh_emit_pub |
| 413 | func cs_hex_to_raw32(hex: *u8, out: *u8) -> i64 |
| 431 | func cs_lower_ascii(s: *u8) -> i64 called by 1: cs_handle2 |
| 437 | func cs_name_ok(s: *u8) -> i64 |
| 453 | func cs_hex_len(s: *u8) -> i64 |
| 466 | func cs_digits_ok(s: *u8) -> i64 |
| 478 | func cs_sh_copyz(dst: *u8, src: *u8, cap: i64) -> i64 |
| 488 | func cs_sh_pub_find(sh: *i64, name: *u8) -> i64 called by 7: mainmaincs_sh_pub_putcs_sh_pub_put2cs_sh_msg_addcs_page_contacts+1 calls 2: cs_seqsh_pub_at |
| 497 | func cs_sh_pub_put(sh: *i64, name: *u8, pub: *u8) -> i64 |
| 524 | func cs_sh_pub_put2(sh: *i64, name: *u8, pub: *u8, owner: *u8, is_auth: i64) -> i64 called by 3: maincs_sh_replaycs_handle2 calls 8: cs_name_okcs_hex_lencs_sh_pub_findsh_own_atcs_eq32sh_pub_at+2 |
| 555 | func cs_sh_msg_add(sh: *i64, from: *u8, to: *u8, seq: *u8, ct: *u8) -> i64 called by 3: maincs_sh_replaycs_handle2 calls 7: cs_name_okcs_digits_okcs_hex_lencs_sh_pub_findsh_msg_atcs_sh_copyz+1 |
| 575 | func cs_sh_msg_find(sh: *i64, from: *u8, to: *u8, seq: *u8) -> i64 |
| 590 | func cs_sh_msg_ack(sh: *i64, from: *u8, to: *u8, seq: *u8) -> i64 |
| 603 | func cs_sh_emit_pub(sh: *i64, i: i64, dst: *u8, off: i64) -> i64 |
| 617 | func cs_sh_emit_msg(sh: *i64, i: i64, dst: *u8, off: i64) -> i64 |
| 631 | func cs_sh_emit_tomb(sh: *i64, i: i64, dst: *u8, off: i64) -> i64 |
| 647 | func cs_sh_compact_emit(sh: *i64, dst: *u8) -> i64 |
| 660 | func cs_sh_tomb_count(sh: *i64) -> i64 |
| 667 | func sh_field(buf: *u8, i: i64, n: i64, out: *u8, cap: i64) -> i64 called by 1: cs_sh_replay |
| 686 | func cs_sh_replay(sh: *i64, buf: *u8, n: i64) -> i64 called by 3: mainmainmain calls 7: sys_mmapsh_fieldcs_sh_pub_putcs_hex_to_raw32cs_sh_pub_put2cs_sh_msg_add+1 |
| 749 | func cs_catsn(dst: *u8, off: i64, v: i64) -> i64 |
| 757 | func cs_json_resp(body: *u8, bn: i64, out: *u8, cap: i64) -> i64 |
| 768 | func cs_shell_open(ctx: *i64, bp: *u8, dst: *u8, off: i64, page: i64, title: *u8) -> i64 |
| 801 | func cs_banner(ctx: *i64, dst: *u8, off: i64) -> i64 called by 11: cs_page_homecs_page_partnerscs_page_chatcs_page_reconnectcs_page_communitycs_page_events+5 calls 1: cu_banner |
| 840 | func cs_foot(dst: *u8, off: i64) -> i64 called by 11: cs_page_homecs_page_partnerscs_page_chatcs_page_reconnectcs_page_communitycs_page_events+5 calls 1: cu_foot |
| 846 | func cs_page_home(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64 |
| 882 | func cs_cand_name(i: i64) -> *u8 called by 1: cs_page_partners |
| 888 | func cs_cand_meta(i: i64) -> *u8 called by 1: cs_page_partners |
| 894 | func cs_cand_age(i: i64) -> i64 { if i==0 { return 27 } if i==1 { return 34 } if i==2 { return 29 } return 14 } called by 1: cs_page_partners |
| 895 | func cs_cand_learn(i: i64) -> i64 { if i==2 { return 4 } return 1 } // Lena wants FRENCH, the others English called by 1: cs_page_partners |
| 896 | func cs_cand_teach(i: i64) -> i64 { return 16 } // all four can teach Russian called by 1: cs_page_partners |
| 897 | func cs_cand_int(i: i64) -> i64 { if i==0 { return 9 } if i==1 { return 13 } if i==2 { return 1 } return 5 } called by 1: cs_page_partners |
| 899 | func cs_page_partners(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64 |
| 964 | func cs_msg_render(ctx: *i64, i: i64, dst: *u8, off: i64) -> i64 called by 1: cs_page_chat calls 7: cu_bubble_opensys_mmapnx_multi_translatecs_slencu_bubble_trcu_bubble_corr+1 |
| 984 | func cs_page_chat(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64 called by 1: cs_render calls 26: cs_shell_opencs_bannercu_h1cu_thread_opencs_msg_rendercu_thread_close+20 |
| 1072 | func cs_recon_person(dst: *u8, off: i64, me: *i64, name: *u8, meta: *u8, p: *i64, why: *u8) -> i64 |
| 1088 | func cs_page_reconnect(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64 |
| 1192 | func cs_page_community(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64 |
| 1344 | func cs_ev_world(ctx: *i64) -> *i64 |
| 1397 | func cs_grp_seed(gmeta: *i64, gmem: *i64, mode: i64) -> i64 |
| 1407 | func cs_role_row(dst: *u8, off: i64, label: *u8, ok: i64) -> i64 |
| 1416 | func cs_wall_row(dst: *u8, off: i64, label: *u8, a: i64, b: i64, guardian: i64, ctxk: i64, adults: i64) -> i64 |
| 1425 | func cs_page_events(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64 |
| 1489 | func cs_page_secure(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64 |
| 1520 | func cs_page_login(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64 |
| 1540 | func cs_page_register(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64 |
| 1569 | func cs_page_account(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64 |
| 1608 | func cs_page_contacts(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64 |
| 1653 | func cs_render(ctx: *i64, bp: *u8, page: i64, dst: *u8, off: i64) -> i64 called by 1: cs_resp calls 11: cs_page_logincs_page_registercs_page_accountcs_page_contactscs_page_partnerscs_page_chat+5 |
| 1667 | func cs_resp(ctx: *i64, bp: *u8, page: i64, out: *u8, cap: i64) -> i64 |
| 1679 | func cs_route(p: *u8) -> i64 |
| 1711 | func cs_handle2(ctx: *i64, sh: *i64, req: *u8, reqlen: i64, out: *u8, cap: i64) -> i64 |
| 2080 | func cs_handle(ctx: *i64, req: *u8, reqlen: i64, out: *u8, cap: i64) -> i64 |