code wiki / _hdl_build / nx_seg_schema.nx
nx_seg_schema.nx
buildroot/runtime/_hdl_build/nx_seg_schema.nx
about
nx_seg_schema.nx -- CAP-SEG-SCHEMA: a self-describing schema + typing + backward/forward EVOLUTION layer for the
sovereign store (Avro-class). A schema = ordered fields {name, type, required}. It is SELF-DESCRIBING (sc_encode
packs it to bytes storable as a store record; sc_decode reads it back). Evolution safety is MECHANIZED and matches
the API-contract-stability doctrine: a new schema is a SAFE evolution of the old iff it (a) keeps every old field
with the same type -- no remove/rename/retype -- and (b) adds only OPTIONAL fields (a new REQUIRED field breaks old
records). A LIBRARY (no main -> run its _gate). license_tier: ORIGINAL
dependencies 1 imports · 1 importers
imports: nx_syscalls.nx
imported by: nx_seg_schema_gate.nx
structs
| none |
consts
| 9 | const SC_STR: i64 = 1 |
| 10 | const SC_INT: i64 = 2 |
| 11 | const SC_BYTES: i64 = 3 |
| 12 | const SC_OPT: i64 = 0 |
| 13 | const SC_REQ: i64 = 1 |
| 14 | const SC_SAFE: i64 = 0 |
| 15 | const SC_REMOVED: i64 = 1 |
| 16 | const SC_RETYPED: i64 = 2 |
| 17 | const SC_NEWREQ: i64 = 3 |
functions
| 19 | func sc_streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8) { if a[i]!=b[i] { return 0 } i=i+1 } if b[i]!=(0 as u8) { return 0 } return 1 } |
| 20 | func sc_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } called by 1: sc_encode |
| 21 | func sc_w32(p: *u8, o: i64, v: i64) -> i64 { p[o]=((v>>24)&0xff) as u8; p[o+1]=((v>>16)&0xff) as u8; p[o+2]=((v>>8)&0xff) as u8; p[o+3]=(v&0xff) as u8; return o+4 } called by 1: sc_encode |
| 22 | func sc_r32(p: *u8, o: i64) -> i64 { let a: i64=p[o]; let b: i64=p[o+1]; let c: i64=p[o+2]; let d: i64=p[o+3]; return (((((a<<8)|b)<<8)|c)<<8)|d } called by 1: sc_decode |
| 23 | func sc_find(name: *u8, names: *i64, n: i64) -> i64 { var i: i64=0; while i<n { if sc_streq((names[i]) as *u8, name)==1 { return i } i=i+1 } return 0-1 } |
| 26 | func sc_encode(n: i64, names: *i64, types: *i64, req: *i64, out: *u8) -> i64 |
| 40 | func sc_decode(b: *u8, out_names: *i64, out_types: *i64, out_req: *i64) -> i64 |
| 54 | func sc_compat(n1: i64, names1: *i64, types1: *i64, n2: i64, names2: *i64, types2: *i64, req2: *i64) -> i64 |