nx_apertus_tree_fetch.nx source
↩ module page · 35 lines · 2291 B
1// nx_apertus_tree_fetch.nx -- ORGAN A of the sovereign enumerate (SRP: TLS/transport only). Fetches the HF repo
2// tree API for the ungated Apertus-8B-Instruct over our own TLS-1.3 and writes the RAW response to
3// knowledge/fetched/apertus_tree.raw for ORGAN B (nx_apertus_tree_parse) to decode+parse. Kept SEPARATE from the
4// parser because the TLS stack + nx_hf_tree_parse in one compilation unit clash in nx_cc (empty .s); splitting the
5// concerns compiles cleanly (this unit imports exactly what the proven config.json fetch does). license_tier: ORIGINAL
6import "nx_syscalls.nx"
7import "nx_x509_trust_store.nx"
8import "nx_trust_store_load_from_certdata.nx"
9import "nx_https_fetch_follow.nx"
10const K_MAGIC_4194304: i64 = 4194304
11
12func w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
13func wn(v: i64) -> i64 { var m: i64=v; if m<0{w("-" as *u8);m=0-m} let t:*u8=sys_mmap(24); 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; let o:*u8=sys_mmap(24); while i<k{o[i]=t[k-1-i];i=i+1} sys_write(1,o,k); return 0 }
14
15func main() -> i64 {
16 w("=== nx_apertus_tree_fetch (organ A): fetch HF tree -> knowledge/fetched/apertus_tree.raw ===\n" as *u8)
17 let r: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt" as *u8, 512, K_MAGIC_4194304)
18 if r <= 0 { w("certdata load FAILED\n" as *u8); sys_exit(1); return 1 }
19 let store: *TrustStore = r as *TrustStore
20 let cap: i64 = K_MAGIC_4194304
21 let out: *u8 = sys_mmap(cap)
22 let status: *i64 = sys_mmap(8) as *i64
23
24 let url: *u8 = "https://huggingface.co/api/models/adamo1139/Apertus-8B-Instruct-2509-ungated/tree/main?recursive=1" as *u8
25 let n: i64 = nx_https_fetch_follow(url, store, out, cap, 6, status)
26 w(" fetch status=" as *u8); wn(status[0]); w(" bytes=" as *u8); wn(n); w("\n" as *u8)
27 if n <= 0 { w(" tree fetch FAILED\n" as *u8); sys_exit(1); return 1 }
28
29 let fd: i64 = sys_openat_wr("knowledge/fetched/apertus_tree.raw" as *u8, 0x1a4)
30 if fd < 0 { w(" write FAILED\n" as *u8); sys_exit(1); return 1 }
31 sys_write(fd, out, n)
32 sys_close(fd)
33 w(" wrote " as *u8); wn(n); w(" bytes -> knowledge/fetched/apertus_tree.raw (run organ B to parse)\n" as *u8)
34 sys_exit(0); return 0
35}