code wiki / _hdl_build / nx_connect_serve.nx

nx_connect_serve.nx

buildroot/runtime/_hdl_build/nx_connect_serve.nx

116720 B2082 linesdepth 3pulls 12 transitivereach 8 importersview sourcekind librarytopic connect
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_mt_multi.nx nx_connect_ui.nx nx_connect_lds_reconnect_lib.nx nx_connect_match_lib.nx nx_connect_youth_lib.nx nx_connect_wards_lib.nx nx_connect_lanes_lib.nx nx_connect_events_lib.nx nx_connect_polls_lib.nx nx_connect_serve.nx nx_connect_accounts.nx nx_connect_app_gate.nx nx_connect_auth_gate.nx nx_connect_pubkey_bind_gate.nx

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

39const CS_MSGCAP: i64 = 32
40const CS_TXT: i64 = 128
41const CS_SLOTS: i64 = 32 // ctx slots (was 16; grown for the reconnect + community state)
45const CS_NMSG: i64 = 0
46const CS_SPK: i64 = 1
47const CS_TXTA: i64 = 2
48const CS_CORR: i64 = 3
49const CS_EV1_GOING: i64 = 4
50const CS_EV2_ADULTS: i64 = 5
51const CS_EV2_MINORS: i64 = 6
52const CS_BANNER: i64 = 7
54const CS_POLL: i64 = 8
55const CS_RC_CONSENT: i64 = 9 // reconnection discovery opt-in (Art.9-style; 0 = surface nothing)
56const CS_RC_MISSION: i64 = 10
57const CS_RC_AREA: i64 = 11
58const CS_RC_FROM: i64 = 12 // year
59const CS_RC_TO: i64 = 13 // year
60const CS_RC_DONE: i64 = 14 // a search has been run in this session
61const CS_WARD: i64 = 15 // joined the ward/branch community group
62const CS_FAITH_CONSENT: i64 = 16 // explicit faith consent (Art.9) -- ward membership is faith-revealing
63const CS_LANE_ME: i64 = 17 // the lane I have opted into for this relationship
64const CS_LANE_THEM: i64 = 18 // the lane they have opted into
65const CS_BLOCKED: i64 = 19 // either side may block, unilaterally
66const CS_CT: i64 = 20 // POINTER to the content-blind ciphertext log (set in world_new, not a data slot)
67const CS_NCT: i64 = 21 // count of stored ciphertexts (data slot; persisted)
68const CS_CTHEX: i64 = 256 // max ciphertext-hex length per sealed message
76const SH_PUBCAP: i64 = 64 // bounded + declared: directory capacity
77const SH_MSGCAP: i64 = 128 // bounded + declared: routed ciphertext capacity
78const SH_NAME: i64 = 32 // stored name bytes (z-term inside)
79const SH_PUBHEX: i64 = 68 // 64 hex chars + z
80const SH_SEQ: i64 = 24 // decimal per-message nonce seq (z-term)
81const SH_PUBSTRIDE: i64 = 100 // SH_NAME + SH_PUBHEX
82const SH_MSGSTRIDE: i64 = 344 // from(32) + to(32) + seq(24) + ct(CS_CTHEX)
83const SH_PUB0: i64 = 512 // pub arena byte offset inside the shared block
84const SH_MSG0: i64 = 6912 // SH_PUB0 + SH_PUBCAP*SH_PUBSTRIDE
85const SH_DEL0: i64 = 51072 // SH_MSG0 + SH_MSGCAP*SH_MSGSTRIDE (6912 + 128*344); 1 delivered-flag per msg
89const SH_OWN0: i64 = 51200
90const SH_OWNSTRIDE: i64 = 40
93const CS_B_NONE: i64 = 0
94const CS_B_RSVP_NO: i64 = 1
95const CS_B_RSVP_OK: i64 = 2
96const CS_B_VOTE_OK: i64 = 3
97const CS_B_CONSENT_ON: i64 = 4
98const CS_B_CONSENT_OFF: i64 = 5
99const CS_B_SEARCHED: i64 = 6
100const CS_B_JOINED: i64 = 7
101const CS_B_JOIN_NO: i64 = 8 // join refused: no faith consent
102const CS_B_FAITH_ON: i64 = 9
103const CS_B_FAITH_OFF: i64 = 10
104const CS_B_ALREADY: i64 = 11 // idempotent re-join
105const CS_B_LANE: i64 = 12
106const CS_B_BLOCK: i64 = 13
107const CS_B_UNBLOCK: i64 = 14
108const CS_B_RSVP_FULL: i64 = 15 // engine returned -2: at capacity
109const CS_B_RSVP_ADULTONLY: i64 = 16 // engine returned -4: a minor on a non-youth event
110const CS_B_RSVP_NOTMEMBER: i64 = 17 // engine returned -1: not in the event's group (never silently ignored)
111const CS_B_SEALED: i64 = 18 // a client-encrypted ciphertext was received + stored (server never saw plaintext)
112const CS_B_SEAL_BAD: i64 = 19 // rejected: not valid ciphertext hex
113const CS_B_CONTACT_ADDED: i64 = 25
114const CS_B_CONTACT_DUP: i64 = 26
115const CS_B_CONTACT_BAD: i64 = 27
116const CS_B_CONTACT_SELF: i64 = 28
117const CS_B_CONTACT_FULL: i64 = 29
118const CS_B_CONTACT_RM: i64 = 30
121const CS_P_HOME: i64 = 0
122const CS_P_PARTNERS: i64 = 1
123const CS_P_CHAT: i64 = 2
124const CS_P_RECON: i64 = 3
125const CS_P_COMMUNITY: i64 = 4
126const CS_P_EVENTS: i64 = 5
127const CS_P_SECURE: i64 = 6 // the content-blind inbox: ciphertext the server received but cannot read
128const CS_P_LOGIN: i64 = 7 // sign in (OPAQUE aPAKE form)
129const CS_P_REGISTER: i64 = 8 // create an account
130const CS_P_ACCOUNT: i64 = 9 // signed-in identity home (sign out lives here)
131const CS_P_CONTACTS: i64 = 10 // the signed-in contact list
136const CS_AUTH: i64 = 24 // 0 = anonymous, 1 = an OPAQUE session validated this request
137const CS_HANDLE: i64 = 25 // pointer to the authenticated handle z-string (0 when anonymous)
138const CS_AUTH_EVENT: i64 = 26 // survives cs_handle2's banner reset -> mapped to a banner just before render
139const CS_MNEMONIC: i64 = 27 // ptr to the 24-word recovery phrase, set ONCE right after register (else 0)
140const CS_CONTACTS: i64 = 28 // ptr to the per-account contact-handle buffer (mmap in cs_world_new)
141const CS_NCONTACTS: i64 = 29 // number of contacts (persisted with the world)
142const CS_SH: i64 = 30 // ptr to the shared plane (daemon-set per request; 0 in offline gates)
143const CS_UID: i64 = 31 // ptr to the authenticated 32-byte user-id (daemon-set; 0 when anonymous)
144const CS_CONTACT_MAX: i64 = 128 // bounded + declared: max contacts per account
145const CS_CONTACT_LEN: i64 = 32 // stored bytes per contact handle (z-term inside)
147const CS_AE_NONE: i64 = 0
148const CS_AE_SIGNED_IN: i64 = 1
149const CS_AE_REGISTERED: i64 = 2
150const CS_AE_SIGNED_OUT: i64 = 3
151const CS_AE_LOGIN_FAIL: i64 = 4 // wrong handle OR passphrase -- deliberately indistinguishable
152const CS_AE_REG_TAKEN: i64 = 5 // handle already exists
153const CS_AE_REG_BAD: i64 = 6 // handle/passphrase failed the input rules
156const CS_EPOCH_YEAR: i64 = 2010
876const CS_ME_AGE: i64 = 30
877const CS_ME_LEARN: i64 = 16
878const CS_ME_TEACH: i64 = 1
879const CS_ME_INT: i64 = 5
880const CS_NCAND: i64 = 4
1333const CS_EV_PICNIC: i64 = 0
1334const CS_EV_YOUTH: i64 = 1
1335const CS_EV_PICNIC_CAP: i64 = 6
1336const CS_EV_YOUTH_CAP: i64 = 8
1337const CS_EV_GROUP: i64 = 1
1340const CS_EV_NEW_ADULT: i64 = 30
1341const CS_EV_NEW_MINOR: i64 = 130
1342const CS_EV_ROSTER: i64 = 30 // adults 1..30, youth 101..130 (must stay <= MB_MAX/UA_MAX halves)

functions

160func cs_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
161func 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 }
162func cs_catn(dst: *u8, off: i64, v: i64) -> i64 { return cu_putn(dst, off, v) }
163func cs_esc(dst: *u8, off: i64, s: *u8) -> i64 { return cu_esc(dst, off, s) }
calls 1: cu_esc
164func cs_seq(a: *u8, b: *u8) -> i64
170func 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
171func cs_hexval(c: i64) -> i64
178func cs_atoi(s: *u8, def: i64) -> i64
called by 1: cs_handle2
191func cs_year_to_month(y: i64) -> i64 { return (y - CS_EPOCH_YEAR) * 12 }
called by 1: cs_page_reconnect
194func cs_form_get(body: *u8, blen: i64, key: *u8, out: *u8, cap: i64) -> i64
called by 1: cs_handle2 calls 2: cs_slencs_hexval
230func cs_write_all(fd: i64, buf: *u8, n: i64) -> i64
calls 1: sys_write
236func cs_read_req(fd: i64, buf: *u8, cap: i64) -> i64
calls 1: sys_read
287func cs_world_reset(ctx: *i64) -> i64
called by 2: cs_world_newmain calls 1: cs_cat
326func cs_world_new() -> *i64
343func cs_contact_at(ctx: *i64, i: i64) -> *u8 { return (ctx[CS_CONTACTS] + i*CS_CONTACT_LEN) as *u8 }
344func cs_contact_find(ctx: *i64, name: *u8) -> i64
350func cs_contact_add(ctx: *i64, name: *u8) -> i64
364func cs_contact_remove(ctx: *i64, name: *u8) -> i64
381func cs_shared_new() -> *i64
called by 4: mainmainmainmain calls 1: sys_mmap
391func sh_pub_at(sh: *i64, i: i64) -> *u8 { return (sh as i64 + SH_PUB0 + i*SH_PUBSTRIDE) as *u8 }
392func sh_msg_at(sh: *i64, i: i64) -> *u8 { return (sh as i64 + SH_MSG0 + i*SH_MSGSTRIDE) as *u8 }
393func sh_del_at(sh: *i64, i: i64) -> *u8 { return (sh as i64 + SH_DEL0 + i) as *u8 } // 1 = delivered/tombstoned
395func sh_own_at(sh: *i64, i: i64) -> *u8 { return (sh as i64 + SH_OWN0 + i*SH_OWNSTRIDE) as *u8 }
397func 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
398func 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 }
called by 2: maincs_sh_pub_put2
400func cs_hex_emit(dst: *u8, off: i64, raw: *u8, nbytes: i64) -> i64
called by 1: cs_sh_emit_pub
413func cs_hex_to_raw32(hex: *u8, out: *u8) -> i64
called by 1: cs_sh_replay calls 1: cs_hexval
431func cs_lower_ascii(s: *u8) -> i64
called by 1: cs_handle2
437func cs_name_ok(s: *u8) -> i64
453func cs_hex_len(s: *u8) -> i64
466func cs_digits_ok(s: *u8) -> i64
478func cs_sh_copyz(dst: *u8, src: *u8, cap: i64) -> i64
488func cs_sh_pub_find(sh: *i64, name: *u8) -> i64
497func cs_sh_pub_put(sh: *i64, name: *u8, pub: *u8) -> i64
524func cs_sh_pub_put2(sh: *i64, name: *u8, pub: *u8, owner: *u8, is_auth: i64) -> i64
555func cs_sh_msg_add(sh: *i64, from: *u8, to: *u8, seq: *u8, ct: *u8) -> i64
575func cs_sh_msg_find(sh: *i64, from: *u8, to: *u8, seq: *u8) -> i64
590func cs_sh_msg_ack(sh: *i64, from: *u8, to: *u8, seq: *u8) -> i64
603func cs_sh_emit_pub(sh: *i64, i: i64, dst: *u8, off: i64) -> i64
617func cs_sh_emit_msg(sh: *i64, i: i64, dst: *u8, off: i64) -> i64
631func cs_sh_emit_tomb(sh: *i64, i: i64, dst: *u8, off: i64) -> i64
called by 1: main calls 2: sh_msg_atcs_cat
647func cs_sh_compact_emit(sh: *i64, dst: *u8) -> i64
660func cs_sh_tomb_count(sh: *i64) -> i64
called by 1: main calls 1: sh_del_at
667func sh_field(buf: *u8, i: i64, n: i64, out: *u8, cap: i64) -> i64
called by 1: cs_sh_replay
686func cs_sh_replay(sh: *i64, buf: *u8, n: i64) -> i64
749func cs_catsn(dst: *u8, off: i64, v: i64) -> i64
called by 1: cs_handle2 calls 2: cs_catcs_catn
757func cs_json_resp(body: *u8, bn: i64, out: *u8, cap: i64) -> i64
called by 1: cs_handle2 calls 2: cs_catcs_catn
768func cs_shell_open(ctx: *i64, bp: *u8, dst: *u8, off: i64, page: i64, title: *u8) -> i64
801func cs_banner(ctx: *i64, dst: *u8, off: i64) -> i64
840func cs_foot(dst: *u8, off: i64) -> i64
846func cs_page_home(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64
882func cs_cand_name(i: i64) -> *u8
called by 1: cs_page_partners
888func cs_cand_meta(i: i64) -> *u8
called by 1: cs_page_partners
894func 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
895func 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
896func cs_cand_teach(i: i64) -> i64 { return 16 } // all four can teach Russian
called by 1: cs_page_partners
897func 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
899func cs_page_partners(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64
964func cs_msg_render(ctx: *i64, i: i64, dst: *u8, off: i64) -> i64
984func cs_page_chat(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64
1072func cs_recon_person(dst: *u8, off: i64, me: *i64, name: *u8, meta: *u8, p: *i64, why: *u8) -> i64
1088func cs_page_reconnect(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64
1192func cs_page_community(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64
1344func cs_ev_world(ctx: *i64) -> *i64
called by 1: cs_handle2 calls 1: sys_mmap
1397func cs_grp_seed(gmeta: *i64, gmem: *i64, mode: i64) -> i64
1407func cs_role_row(dst: *u8, off: i64, label: *u8, ok: i64) -> i64
called by 1: cs_page_community calls 2: cu_putscu_badge
1416func cs_wall_row(dst: *u8, off: i64, label: *u8, a: i64, b: i64, guardian: i64, ctxk: i64, adults: i64) -> i64
1425func cs_page_events(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64
1489func cs_page_secure(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64
1520func cs_page_login(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64
1540func cs_page_register(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64
1569func cs_page_account(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64
1608func cs_page_contacts(ctx: *i64, bp: *u8, dst: *u8, off: i64) -> i64
1653func cs_render(ctx: *i64, bp: *u8, page: i64, dst: *u8, off: i64) -> i64
1667func cs_resp(ctx: *i64, bp: *u8, page: i64, out: *u8, cap: i64) -> i64
1679func cs_route(p: *u8) -> i64
called by 1: cs_handle2 calls 1: cs_seq
1711func cs_handle2(ctx: *i64, sh: *i64, req: *u8, reqlen: i64, out: *u8, cap: i64) -> i64
2080func cs_handle(ctx: *i64, req: *u8, reqlen: i64, out: *u8, cap: i64) -> i64
called by 2: mainmain calls 1: cs_handle2