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