code wiki / (root) / nx_hr_sov.nx

nx_hr_sov.nx

buildroot/runtime/nx_hr_sov.nx

13688 B197 linesdepth 10pulls 20 transitivereach 35 importersview sourcekind librarytopic hr
docsdependenciesstructsconstsfunctions

about

nx_hr_sov.nx -- the SOVEREIGN-STORED HR directory: the same access-SSOT semantics as nx_hr (cred_id-keyed, invited/active/suspended lifecycle, deny-by-default, append-only history) but persisted on nx_seg_store + canon records instead of a TAB-delimited log (operator NO-TSV doctrine [[feedback-no-3rd-party-tsv-sovereign-store]]). This is the ADOPTABLE FOUNDATION for the HR team's migration (filed via the coord queue): a drop-in proven core, so the cutover is "point nx_hr at this + switch callers' store path together" -- NOT a risky unilateral rewrite of the shared organ (torrent/gallery/hub depend on nx_hr's path). seg_store gives latest-wins (resolve), additive history (audit), crash-safe commit -- for free. cred_id = SHA-256(realm|||handle) (same derivation as nx_hr/whoami). record (keyed by cred_id): handle, level, family, status, ts, actor status: invited|active|suspended

dependencies 6 imports · 7 importers

nx_no_cookie_session.nx nx_seg_store.nx nx_canon_cid.nx nx_uxf_decode.nx nx_sha256.nx nx_syscalls.nx nx_hr_sov.nx nx_account_admin_exceed_gate.nx nx_hr_admin.nx nx_hr_admin_page.nx nx_hr_audit.nx nx_hr_migrate.nx nx_hr_migrate_gate.nx nx_hr_sov_gate.nx

imports: nx_no_cookie_session.nxnx_seg_store.nxnx_canon_cid.nxnx_uxf_decode.nxnx_sha256.nxnx_syscalls.nx

imported by: nx_account_admin_exceed_gate.nxnx_hr_admin.nxnx_hr_admin_page.nxnx_hr_audit.nxnx_hr_migrate.nxnx_hr_migrate_gate.nxnx_hr_sov_gate.nx

structs

none

consts

15const HRS_MAGIC_4096: i64 = 4096
17const HRS_OWNER: i64 = 3
18const HRS_MEMBER: i64 = 1
19const HRS_NONE: i64 = 0
20const HRS_ST_NONE: i64 = 0
21const HRS_ST_ACTIVE: i64 = 1
22const HRS_ST_SUSPENDED: i64 = 2
23const HRS_ST_INVITED: i64 = 3

functions

25func hrs_streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while 1==1 { let ca: i64=a[i] as i64; let cb: i64=b[i] as i64; if ca!=cb {return 0} if ca==0 {return 1} i=i+1 } return 1 }
26func hrs_hexenc(inp: *u8, n: i64, out: *u8) -> i64 { let hx: *u8="0123456789abcdef" as *u8; var i: i64=0; while i<n { out[i*2]=hx[((inp[i] as i64)>>4)&15]; out[i*2+1]=hx[(inp[i] as i64)&15]; i=i+1 } out[n*2]=0 as u8; return n*2 }
called by 1: hrs_cred_id
27func hrs_itoa(v: i64, out: *u8) -> i64 { let t: *u8=sys_mmap(28); var m: i64=v; var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{out[i]=t[k-1-i];i=i+1} out[k]=0 as u8; return k }
28func hrs_atoi(s: *u8) -> i64 { var v: i64=0; var i: i64=0; while s[i]!=(0 as u8){ let c: i64=s[i] as i64; if c>=48 { if c<=57 { v=v*10+(c-48) } } i=i+1 } return v }
31func hrs_cred_id(realm: *u8, realm_n: i64, handle: *u8, hn: i64, out_hex: *u8) -> i64
37func hrs_atoi_n(s: *u8, n: i64) -> i64 { var v: i64=0; var i: i64=0; while i<n { let c: i64=s[i] as i64; if c>=48 { if c<=57 { v=v*10+(c-48) } } i=i+1 } return v }
called by 1: hrs_index_count
41func hrs_segid(cred_id: *u8, status: *u8, ts: i64) -> i64
53func hrs_encode_rec(handle: *u8, level: i64, family: *u8, status: *u8, ts: i64, actor: *u8, out: *u8) -> i64
68func hrs_seg_committed(prefix: *u8, segid: i64) -> i64
76func hrs_put(prefix: *u8, cred_id: *u8, handle: *u8, level: i64, family: *u8, status: *u8, ts: i64, actor: *u8, segid: i64) -> i64
84func hrs_idx_key(i: i64, out: *u8) -> i64 { let p: *u8="idx:" as *u8; var o: i64=0; while p[o]!=(0 as u8){out[o]=p[o];o=o+1} let k: i64=hrs_itoa(i, (out as i64 + o) as *u8); return o+k }
85func hrs_index_count(prefix: *u8) -> i64
91func hrs_index_get_cred(prefix: *u8, i: i64, out64: *u8) -> i64
100func hrs_put_indexed(prefix: *u8, cred_id: *u8, handle: *u8, level: i64, family: *u8, status: *u8, ts: i64, actor: *u8, segid: i64) -> i64
117func hrs_get(prefix: *u8, cred_id: *u8, out_keys: *i64, out_vals: *i64, maxf: i64) -> i64
123func hrs_field(ok: *i64, ov: *i64, nf: i64, name: *u8) -> *u8 { var i: i64=0; while i<nf { if hrs_streq(ok[i] as *u8, name)==1 { return ov[i] as *u8 } i=i+1 } return 0 as *u8 }
126func hrs_enroll(prefix: *u8, realm: *u8, realm_n: i64, handle: *u8, hn: i64, level: i64, family: *u8, ts: i64, actor: *u8, out_cid: *u8) -> i64
130func hrs_invite(prefix: *u8, realm: *u8, realm_n: i64, handle: *u8, hn: i64, level: i64, family: *u8, ts: i64, actor: *u8, out_cid: *u8) -> i64
134func hrs_suspend(prefix: *u8, cred_id: *u8, handle: *u8, family: *u8, ts: i64, actor: *u8) -> i64 { return hrs_put(prefix, cred_id, handle, 0, family, "suspended" as *u8, ts, actor, hrs_segid(cred_id, "suspended" as *u8, ts)) }
called by 2: hra_suspendmain calls 2: hrs_puthrs_segid
135func hrs_set_role(prefix: *u8, cred_id: *u8, handle: *u8, level: i64, family: *u8, ts: i64, actor: *u8) -> i64 { return hrs_put(prefix, cred_id, handle, level, family, "active" as *u8, ts, actor, hrs_segid(cred_id, "active" as *u8, ts)) }
called by 3: mainhrs_claimmain calls 2: hrs_puthrs_segid
139func hrs_migrate(prefix: *u8, cred_id: *u8, handle: *u8, level: i64, family: *u8, status: *u8, ts: i64, actor: *u8) -> i64
144func hrs_claim(prefix: *u8, realm: *u8, realm_n: i64, handle: *u8, hn: i64, family: *u8, ts: i64, actor: *u8) -> i64
159func hrs_status_code(prefix: *u8, cred_id: *u8) -> i64
171func hrs_resolve_level(prefix: *u8, cred_id: *u8) -> i64
182func hrs_is_superadmin(prefix: *u8, cred_id: *u8) -> i64 { if hrs_resolve_level(prefix, cred_id) >= HRS_OWNER { return 1 } return 0 }
183func hrs_is_invited(prefix: *u8, realm: *u8, realm_n: i64, handle: *u8, hn: i64) -> i64
189func hrs_roster_count(prefix: *u8, want_status: i64) -> i64