code wiki / _hdl_build / nx_sovgit_git.nx
nx_sovgit_git.nx
buildroot/runtime/_hdl_build/nx_sovgit_git.nx
about
nx_sovgit_git.nx -- ★SOVGIT X2: SOVEREIGN MULTI-REPO SMART-HTTP git host on nx_http_server sockets,
NO nginx/framework. v0 smart protocol (pkt-line advert + upload-pack pack stream + receive-pack push),
multi-repo routed by path (/git/<repo>/...), push-to-create, multi-ref push, HEAD symref advert.
Legacy single-repo paths (/git/info/refs) keep serving knowledge/_sovgit_repo (back-compat, X1 demo).
SCALE ENVELOPE (declared in banner, guarded in code -- fail LOUD, never a corrupt pack):
push request <= REQ cap (128 MiB buffer; the TLS edge proxies bodies <= ~2 MiB today = the wire cap,
so an over-edge push must stay small -- incremental packs keep beats tiny; big seeds go loopback)
clone pack <= PACK cap (128 MiB; overflow -> 500, never truncated silently)
one object <= 64 MiB inflated
branch names: single-level refs/heads/<name> (no '/' subdirs yet); ref deletes: unsupported (ng)
Buffers are allocated ONCE in main and reused per request (bounded-VSZ discipline).
Reuses X0 (objects/sha/zlib) + X1b/X1d (pack gen/parse). license_tier: ORIGINAL
dependencies 3 imports · 0 importers
imports: nx_sovgit_obj.nxnx_http_server.nxnx_login_gate.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 16 | const K_MAGIC_65536: i64 = 65536 |
| 17 | const K_MAGIC_4096: i64 = 4096 |
| 18 | const K_MAGIC_1024: i64 = 1024 |
| 19 | const K_MAGIC_2048: i64 = 2048 |
| 20 | const K_MAGIC_8192: i64 = 8192 |
| 21 | const K_MAGIC_18691: i64 = 18691 |
| 26 | const CH_LF: i64 = 10 |
| 27 | const CH_SP: i64 = 32 |
| 28 | const CH_DQUOTE: i64 = 34 |
| 29 | const CH_PCT: i64 = 37 |
| 30 | const CH_AMP: i64 = 38 |
| 31 | const CH_STAR: i64 = 42 |
| 32 | const CH_PLUS: i64 = 43 |
| 33 | const CH_DOT: i64 = 46 |
| 34 | const CH_SLASH: i64 = 47 |
| 35 | const CH_0: i64 = 48 |
| 36 | const CH_9: i64 = 57 |
| 37 | const CH_COLON: i64 = 58 |
| 38 | const CH_LT: i64 = 60 |
| 39 | const CH_GT: i64 = 62 |
| 40 | const CH_QUERY: i64 = 63 |
| 41 | const CH_A_UP: i64 = 65 |
| 42 | const CH_F_UP: i64 = 70 |
| 43 | const CH_Z_UP: i64 = 90 |
| 44 | const CH_BSLASH: i64 = 92 |
| 45 | const CH_A_LO: i64 = 97 |
| 46 | const CH_F_LO: i64 = 102 |
| 47 | const CH_PIPE: i64 = 124 |
| 48 | const CH_DEL: i64 = 127 |
| 49 | const HEX_BASE: i64 = 16 |
| 50 | const CASE_DELTA: i64 = 32 |
| 51 | const HEXA_LO_ADJ: i64 = 87 |
| 52 | const HEXA_UP_ADJ: i64 = 55 |
| 53 | const NAME_MAX: i64 = 255 |
functions
| 55 | func lg(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(2, s, n); return 0 } |
| 56 | func lgn(v: i64) -> i64 |
| 69 | func sstrlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 70 | func scopy(dst: *u8, at: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[at + i] = s[i]; i = i + 1 } return at + i } |
| 71 | func udec(out: *u8, at: i64, v: i64) -> i64 |
| 77 | func wfile(path: *u8, buf: *u8, n: i64) -> i64 { let fd: i64 = sys_openat_wr(path, 0x1a4); if fd < 0 { return 0 - 1 } sys_write(fd, buf, n); sys_close(fd); return 0 } |
| 78 | func wstr(path: *u8, s: *u8) -> i64 { return wfile(path, s, sstrlen(s)) } |
| 80 | func pcontains(p: *u8, plen: i64, needle: *u8) -> i64 |
| 93 | func seq(a: *u8, alen: i64, b: *u8) -> i64 |
| 102 | func hex4(out: *u8, at: i64, v: i64) -> i64 |
| 112 | func pkt(out: *u8, at: i64, payload: *u8, plen: i64) -> i64 |
| 117 | func pkts(out: *u8, at: i64, s: *u8) -> i64 { return pkt(out, at, s, sstrlen(s)) } |
| 118 | func pktflush(out: *u8, at: i64) -> i64 { out[at] = 48 as u8; out[at + 1] = 48 as u8; out[at + 2] = 48 as u8; out[at + 3] = 48 as u8; return at + 4 } |
| 120 | func rd_hex4(b: *u8, at: i64) -> i64 called by 1: serve_receivepack |
| 134 | func be32w(out: *u8, at: i64, v: i64) -> i64 { out[at] = ((v >> 24) & 255) as u8; out[at + 1] = ((v >> 16) & 255) as u8; out[at + 2] = ((v >> 8) & 255) as u8; out[at + 3] = (v & 255) as u8; return at + 4 } called by 1: pack_disk |
| 135 | func pk_objhdr(out: *u8, at: i64, typ: i64, size: i64) -> i64 called by 1: pk_object |
| 140 | func pk_object(out: *u8, at: i64, typ: i64, content: *u8, clen: i64) -> i64 |
| 154 | func sg_lc(c: i64) -> i64 { if c >= CH_A_UP { if c <= CH_Z_UP { return c + CASE_DELTA } } return c } |
| 155 | func sg_ieq(nm: *u8, nl: i64, lit: *u8) -> i64 |
| 162 | func sg_name_portable(nm: *u8, nl: i64) -> i64 |
| 210 | func sg_tree_names_ok(t: *u8, tlen: i64, oidlen: i64) -> i64 |
| 240 | func unpack_into(objroot: *u8, pack: *u8, plen: i64) -> i64 |
| 290 | func sg_ishex(c: i64) -> i64 |
| 296 | func sg_namelen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 297 | func repo_char_ok(c: i64) -> i64 |
| 306 | func ref_ok(r: *u8) -> i64 |
| 330 | func parse_repo(path: *u8, plen: i64, segout: *u8, rest_off: *i64) -> i64 |
| 377 | func repo_root(dst: *u8, seg: *u8, seglen: i64) -> i64 |
| 386 | func rr_path(dst: *u8, root: *u8, rel: *u8) -> i64 |
| 393 | func repo_exists(root: *u8) -> i64 called by 1: serve |
| 400 | func ensure_repo(root: *u8) -> i64 |
| 419 | func read_ref_at(root: *u8, refrel: *u8, hexout: *u8) -> i64 |
| 440 | func head_target(root: *u8, tgt: *u8) -> i64 |
| 478 | func walk_depth(root: *u8, tip: *u8, depth: i64, out: *u8, content: *u8) -> i64 |
| 506 | func pack_disk(root: *u8, out: *u8, outcap: i64, content: *u8, noblob: i64, allow: *u8, nallow: i64) -> i64 called by 3: serve_uploadpack_resultserve_bundleserve_v2_fetch calls 11: be32wrr_pathsys_getdents64dirent_namesg_namelensg_ishex+5 |
| 601 | func advert_body(body: *u8, bcap: i64, root: *u8, svc: i64) -> i64 |
| 686 | func resp_hdr(resp: *u8, ctype: *u8, blen: i64) -> i64 called by 14: serve_staticserve_advertserve_uploadpack_resultserve_v2_capsserve_bundleserve_v2_bundleuri+8 calls 2: scopyudec |
| 695 | func send_txt(cfd: i64, resp: *u8, status: *u8, msg: *u8) -> i64 |
| 708 | func serve_static(cfd: i64, root: *u8, relpath: *u8, rlen: i64, resp: *u8) -> i64 |
| 735 | func serve_advert(cfd: i64, resp: *u8, root: *u8, svc: i64) -> i64 |
| 747 | func serve_uploadpack_result(cfd: i64, resp: *u8, root: *u8, pack: *u8, packcap: i64, pbody: *u8, content: *u8) -> i64 |
| 768 | func v2_caps_body(body: *u8, bcap: i64) -> i64 |
| 779 | func serve_v2_caps(cfd: i64, resp: *u8) -> i64 |
| 788 | func v2_lsrefs_body(body: *u8, bcap: i64, root: *u8) -> i64 |
| 841 | func sb_chunk(out: *u8, at: i64, band: i64, data: *u8, dlen: i64) -> i64 |
| 852 | func serve_bundle(cfd: i64, resp: *u8, root: *u8, pack: *u8, packcap: i64, pbody: *u8, content: *u8) -> i64 |
| 875 | func serve_v2_bundleuri(cfd: i64, resp: *u8, pbody: *u8, seg: *u8, sl: i64) -> i64 |
| 912 | func serve_openapi(cfd: i64, resp: *u8, pbody: *u8) -> i64 |
| 933 | func serve_oplog(cfd: i64, resp: *u8, pbody: *u8) -> i64 |
| 963 | func serve_ci(cfd: i64, resp: *u8, pbody: *u8) -> i64 |
| 996 | func hexv1(c: i64) -> i64 |
| 1004 | func ui_row(pbody: *u8, b0: i64, buf: *u8, st: i64, en: i64) -> i64 |
| 1027 | func serve_forge_log(cfd: i64, resp: *u8, root: *u8, pbody: *u8, body: *u8, blen: i64, fname: *u8, heading: *u8, rowtag: *u8, formhtml: *u8) -> i64 |
| 1086 | func serve_issues(cfd: i64, resp: *u8, root: *u8, pbody: *u8, seg: *u8, sl: i64, body: *u8, blen: i64) -> i64 |
| 1139 | func ui_esc(pbody: *u8, b: i64, c: i64) -> i64 |
| 1146 | func serve_ui(cfd: i64, resp: *u8, root: *u8, pbody: *u8, seg: *u8, sl: i64, rest: *u8, rlen: i64) -> i64 |
| 1295 | func serve_v2_lsrefs(cfd: i64, resp: *u8, root: *u8, pbody: *u8) -> i64 |
| 1302 | func serve_v2_fetch(cfd: i64, resp: *u8, root: *u8, pack: *u8, packcap: i64, pbody: *u8, content: *u8, noblob: i64, body: *u8, blen: i64) -> i64 |
| 1378 | func serve_receivepack(cfd: i64, body: *u8, blen: i64, resp: *u8, root: *u8) -> i64 |
| 1552 | func ch_decode(src: *u8, n: i64, out: *u8, outcap: i64) -> i64 |
| 1599 | func serve(cfd: i64, path: *u8, plen: i64, body: *u8, blen: i64, resp: *u8, pack: *u8, packcap: i64, pbody: *u8, content: *u8, v2: i64) -> i64 |
| 1644 | func assemble_repo(chex_out: *u8) -> i64 |
| 1675 | func send_401(cfd: i64, resp: *u8) -> i64 |
| 1693 | func pg_case(nm: *u8, nl: i64, want: i64, label: *u8, fails: *i64) -> i64 |
| 1699 | func pg_lit(s: *u8, want: i64, fails: *i64) -> i64 { return pg_case(s, sstrlen(s), want, s, fails) } |
| 1700 | func sg_pathgate_selftest() -> i64 |
| 1756 | func main(argc: i64, argv: *i64) -> i64 |