code wiki / (root) / nx_relate_serve.nx

nx_relate_serve.nx

buildroot/runtime/nx_relate_serve.nx

73958 B1336 linesdepth 7pulls 9 transitivereach 4 importersview sourcekind librarytopic relate
docsdependenciesstructsconstsfunctions

about

nx_relate_serve.nx -- the INTERACTIVE handler for the Relationship OS (turns /relate from a static view into a live app). GET renders the PERSISTED graph (from seg_store); POST /add-entity + /add-edge parse a form, SAVE to the store, and the next GET shows the new record. Sovereign "pure core + deferred socket I/O" discipline (email-stack pattern): this organ gates the interactive CORE (parse request -> read/write the persisted store -> render) against a real store, NO sockets -- the accept-loop + public deploy (route /relate -> this daemon) is the ops shell after. Self-contained store (canon_cid + seg_store), same proven pattern as nx_relate_store. PURE CORE (no main): rv_handle (request->response), rv_read_req/rv_write_all (fd shells), store save/count, rv_selftest (the offline gate body). Consumers: _hdl_build/nx_relate_serve_gate (offline), nx_relate_live_gate (real loopback socket), nx_relate_daemon (deployable accept-loop). license_tier: ORIGINAL

dependencies 4 imports · 4 importers

nx_syscalls.nx nx_canon_cid.nx nx_seg_store.nx nx_rebac.nx nx_relate_serve.nx nx_relate_daemon.nx nx_relate_import.nx nx_relate_live_gate.nx nx_relate_serve_gate.nx

imports: nx_syscalls.nxnx_canon_cid.nxnx_seg_store.nxnx_rebac.nx

imported by: nx_relate_daemon.nxnx_relate_import.nxnx_relate_live_gate.nxnx_relate_serve_gate.nx

structs

none

consts

19const RV_BOOTSTRAP: *u8 = "<!DOCTYPE html><html lang='en'><head><meta charset='utf-8'><meta name='viewport' content='width=device-width, initial-scale=1'><title>Nishi Relationship OS</title></head><body><script>(function(){var t=sessionStorage.getItem('nsess');if(!t){location='/login?return=/relate';return}fetch(location.pathname,{headers:{'X-Nishi-Session':t}}).then(function(r){return r.ok?r.text():null}).then(function(x){if(x){document.open();document.write(x);document.close()}else{location='/login?return=/relate'}})})();</script></body></html>"

functions

21func p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 5: mainmainmainpnrv_selftest calls 1: sys_write
22func pn(v: i64) -> i64
called by 2: mainrv_selftest calls 3: psys_mmapsys_write
28func rv_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
29func rv_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 }
30func rv_catn(dst: *u8, off: i64, v: i64) -> i64
37func rv_kmemeq(b: *u8, off: i64, n: i64, s: *u8) -> i64
called by 2: rv_iskindrv_field calls 1: rv_slen
42func rv_iskind(b: *u8, koff: i64, kl: i64, pfx: *u8) -> i64 { if kl <= 4 { return 0 } return rv_kmemeq(b, koff, 4, pfx) }
45func rv_cat_esc(dst: *u8, off: i64, s: *u8) -> i64
called by 2: rv_disprv_render_tok calls 1: rv_cat
62func rv_sess_field(dst: *u8, off: i64, tok: *u8) -> i64
called by 1: rv_render_tok calls 1: rv_cat
71func rv_field(rec: *u8, rl: i64, want: *u8, out: *u8, cap: i64) -> i64
90func rv_has(buf: *u8, n: i64, needle: *u8) -> i64
99func rv_save_entity(w: *i64, etype: *u8, name: *u8, tenant: *u8) -> i64
108func rv_save_edge(w: *i64, from: *u8, rel: *u8, to: *u8, ctx: *u8, role: *u8) -> i64
118func rv_persist_entity(prefix: *u8, etype: *u8, name: *u8, tenant: *u8) -> i64
123func rv_atoi(s: *u8) -> i64
133func rv_seq(a: *u8, b: *u8) -> i64
141func rv_stage_prob(s: *u8) -> i64
called by 2: rv_save_dealrv_render_tok calls 1: rv_seq
150func rv_stage_open(s: *u8) -> i64
called by 1: rv_render_tok calls 1: rv_seq
157func rv_save_deal(w: *i64, name: *u8, account: *u8, amount: i64, stage: *u8, tenant: *u8) -> i64
179func rv_save_gift(w: *i64, donor: *u8, fund: *u8, amount: i64, gtype: *u8) -> i64
201func rv_persist_deal(prefix: *u8, name: *u8, account: *u8, amount: i64, stage: *u8, tenant: *u8) -> i64
207func rv_itype_ok(t: *u8) -> i64
called by 2: rv_save_sharerv_handle_auth calls 1: rv_seq
215func rv_save_share(w: *i64, a: *i64) -> i64
237func rv_save_acl(w: *i64, handle: *u8, tenant: *u8, role: i64, grantor: *u8) -> i64
261func rv_acl_any(prefix: *u8) -> i64
285func rv_acl_load(prefix: *u8, handle: *u8, tenants: *i64, roles: *i64) -> i64
338func rv_ten_default(t: *u8) -> i64
called by 2: rv_wcheckrv_render_tok calls 1: rv_cat
344func rv_role_of(gr: *i64, ten: *u8) -> i64
353func rv_vis(gr: *i64, ten: *u8) -> i64 { if rv_role_of(gr, ten) >= 2 { return 1 } return 0 }
called by 1: rv_render_tok calls 1: rv_role_of
354func rv_amt_ok(gr: *i64, ten: *u8) -> i64 { if rv_role_of(gr, ten) >= 3 { return 1 } return 0 }
called by 1: rv_render_tok calls 1: rv_role_of
356func rv_wcheck(gr: *i64, body: *u8, blen: i64, tb: *u8) -> i64
363func rv_emit_403(out: *u8) -> i64
called by 1: rv_handle_auth calls 3: rv_catrv_catnrv_slen
374func rv_count_ent(prefix: *u8) -> i64
393func rv_disp(dst: *u8, off: i64, s: *u8) -> i64
called by 1: rv_render_tok calls 1: rv_cat_esc
399func rv_userref(out: *u8, handle: *u8) -> i64
called by 2: rv_render_tokrv_handle_auth calls 1: rv_cat
408func rv_tok_ok(s: *u8) -> i64
called by 1: rv_handle_auth
426func rv_groupref(out: *u8, name: *u8) -> i64
called by 1: rv_handle_auth calls 1: rv_cat
441func rv_render_tok(prefix: *u8, out: *u8, cap: i64, tok: *u8, gr: *i64) -> i64
753func rv_render(prefix: *u8, out: *u8, cap: i64) -> i64
759func rv_hexval(c: i64) -> i64
called by 1: rv_form_get
765func rv_form_get(body: *u8, blen: i64, key: *u8, out: *u8, cap: i64) -> i64
799func rv_hdr_val(req: *u8, rn: i64, key: *u8, out: *u8, cap: i64) -> i64
called by 1: rv_get_sess calls 1: rv_slen
831func rv_get_sess(req: *u8, reqlen: i64, out: *u8, cap: i64) -> i64
called by 1: rv_selftest calls 2: rv_hdr_valrv_form_get
844func rv_emit_401(out: *u8) -> i64
called by 1: rv_handle_auth calls 3: rv_catrv_catnrv_slen
854func rv_hex(dst: *u8, src: *u8, n: i64) -> i64
868func rv_idx_lookup(idx: *u8, idxlen: i64, uidhex: *u8, uxn: i64, out_h: *u8, cap: i64) -> i64
899func rv_resolve_handle(idxpath: *u8, uid: *u8, uidn: i64, out_h: *u8, cap: i64) -> i64
909func rv_write_all(fd: i64, buf: *u8, n: i64) -> i64
called by 2: g_writesmain calls 1: sys_write
916func rv_read_req(fd: i64, buf: *u8, cap: i64) -> i64
called by 1: main calls 1: sys_read
973func rv_handle_auth(prefix: *u8, req: *u8, reqlen: i64, out: *u8, cap: i64, auth: *i64) -> i64
1133func rv_handle(prefix: *u8, req: *u8, reqlen: i64, out: *u8, cap: i64) -> i64
called by 2: mainrv_selftest calls 1: rv_handle_auth
1137func rv_selftest() -> i64