nx_hr_sov.nx
buildroot/runtime/nx_hr_sov.nx
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
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
| 15 | const HRS_MAGIC_4096: i64 = 4096 |
| 17 | const HRS_OWNER: i64 = 3 |
| 18 | const HRS_MEMBER: i64 = 1 |
| 19 | const HRS_NONE: i64 = 0 |
| 20 | const HRS_ST_NONE: i64 = 0 |
| 21 | const HRS_ST_ACTIVE: i64 = 1 |
| 22 | const HRS_ST_SUSPENDED: i64 = 2 |
| 23 | const HRS_ST_INVITED: i64 = 3 |
functions
| 25 | func 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 } |
| 26 | func 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 |
| 27 | func 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 } |
| 28 | func 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 } |
| 31 | func hrs_cred_id(realm: *u8, realm_n: i64, handle: *u8, hn: i64, out_hex: *u8) -> i64 |
| 37 | func 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 |
| 41 | func hrs_segid(cred_id: *u8, status: *u8, ts: i64) -> i64 called by 5: hrs_enrollhrs_invitehrs_suspendhrs_set_rolehrs_migrate calls 3: sys_mmaphrs_itoasha256_digest |
| 53 | func hrs_encode_rec(handle: *u8, level: i64, family: *u8, status: *u8, ts: i64, actor: *u8, out: *u8) -> i64 |
| 68 | func hrs_seg_committed(prefix: *u8, segid: i64) -> i64 |
| 76 | func hrs_put(prefix: *u8, cred_id: *u8, handle: *u8, level: i64, family: *u8, status: *u8, ts: i64, actor: *u8, segid: i64) -> i64 called by 2: hrs_suspendhrs_set_role calls 6: hrs_seg_committedsys_mmaphrs_encode_recss_beginss_addss_commit |
| 84 | func 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 } |
| 85 | func hrs_index_count(prefix: *u8) -> i64 called by 4: hap_emithau_emithrs_put_indexedhrs_roster_count calls 4: ss_opensys_mmapss_hgethrs_atoi_n |
| 91 | func hrs_index_get_cred(prefix: *u8, i: i64, out64: *u8) -> i64 |
| 100 | func hrs_put_indexed(prefix: *u8, cred_id: *u8, handle: *u8, level: i64, family: *u8, status: *u8, ts: i64, actor: *u8, segid: i64) -> i64 |
| 117 | func hrs_get(prefix: *u8, cred_id: *u8, out_keys: *i64, out_vals: *i64, maxf: i64) -> i64 called by 4: hap_emithrs_claimhrs_status_codehrs_resolve_level calls 4: ss_opensys_mmapss_hgetcanon_decode |
| 123 | func 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 } |
| 126 | func 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 |
| 130 | func 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 |
| 134 | func 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)) } |
| 135 | func 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)) } |
| 139 | func hrs_migrate(prefix: *u8, cred_id: *u8, handle: *u8, level: i64, family: *u8, status: *u8, ts: i64, actor: *u8) -> i64 |
| 144 | func hrs_claim(prefix: *u8, realm: *u8, realm_n: i64, handle: *u8, hn: i64, family: *u8, ts: i64, actor: *u8) -> i64 |
| 159 | func hrs_status_code(prefix: *u8, cred_id: *u8) -> i64 called by 4: hrs_put_indexedhrs_is_invitedhrs_roster_countmain calls 4: sys_mmaphrs_gethrs_fieldhrs_streq |
| 171 | func hrs_resolve_level(prefix: *u8, cred_id: *u8) -> i64 called by 4: hra_resolve_levelmainhrs_is_superadminmain calls 5: sys_mmaphrs_gethrs_fieldhrs_streqhrs_atoi |
| 182 | func hrs_is_superadmin(prefix: *u8, cred_id: *u8) -> i64 { if hrs_resolve_level(prefix, cred_id) >= HRS_OWNER { return 1 } return 0 } |
| 183 | func hrs_is_invited(prefix: *u8, realm: *u8, realm_n: i64, handle: *u8, hn: i64) -> i64 |
| 189 | func hrs_roster_count(prefix: *u8, want_status: i64) -> i64 called by 3: hra_roster_countmainmain calls 4: hrs_index_countsys_mmaphrs_index_get_credhrs_status_code |