code wiki / (root) / nx_apimcp_research_fetch.nx

nx_apimcp_research_fetch.nx source

↩ module page · 61 lines · 5124 B

1// nx_apimcp_research_fetch.nx -- SOVEREIGN researcher for the 2025/26 API + MCP SOTA re-census (operator 2// 2026-07-10: "we want our apis and mcp state of the art ... i dont think we are 1000 percent"). The prior 3// union (api_sota_features.conf, fetched 2026-07-06) was live-proven at creation but its DENOMINATOR is 4// stale: MCP-spec depth (streamable HTTP, elicitation, sampling, roots), AsyncAPI, OpenTelemetry, 5// deprecation/sunset lifecycle, GraphQL/OData query surfaces never entered it. Banks apim_*.raw for the 6// depth re-census. Same proven pattern as nx_adnet_research_fetch (own TLS-1.3 + Mozilla CA, have-skip). 7// expect_exit: 0 license_tier: ORIGINAL 8import "nx_syscalls.nx" 9import "nx_x509_trust_store.nx" 10import "nx_trust_store_load_from_certdata.nx" 11import "nx_https_fetch_follow.nx" 12const K_MAGIC_4194304: i64 = 4194304 13 14func af_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 15func af_putn(v: i64) -> i64 { if v==0 { sys_write(1,"0" as *u8,1); return 0 } var m: i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m} let d:*u8=sys_mmap(24); var k:i64=0; while m>0{d[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i:i64=k-1; while i>=0{let o:*u8=sys_mmap(1);o[0]=d[i];sys_write(1,o,1);i=i-1} return 0 } 16func af_have(path: *u8) -> i64 { let fd: i64=sys_openat_rd(path); if fd<0{return 0} sys_close(fd); return 1 } 17func af_fetch(url: *u8, opath: *u8, store: *TrustStore, out: *u8, cap: i64) -> i64 { 18 if af_have(opath)==1 { af_puts(opath); af_puts(" [have-skip]\n" as *u8); return 1 } 19 let status: *i64=sys_mmap(8) as *i64 20 let n: i64=nx_https_fetch_follow(url, store, out, cap, 6, status) 21 af_puts(url); af_puts(" status=" as *u8); af_putn(status[0]); af_puts(" bytes=" as *u8); af_putn(n) 22 if n<=0 { af_puts(" FETCH-FAIL\n" as *u8); return 0 } 23 var gz: i64=0; if n>=2 { if out[0]==0x1f as u8 { if out[1]==0x8b as u8 { gz=1 } } } 24 if gz==1 { af_puts(" [GZIP-skip]\n" as *u8); return 0 } 25 let fd: i64=sys_openat_wr(opath, 0x1a4); if fd<0 { af_puts(" SAVE-FAIL\n" as *u8); return 0 } 26 sys_write(fd, out, n); sys_close(fd); af_puts(" SAVED\n" as *u8); return 1 27} 28 29func main() -> i64 { 30 let r: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt" as *u8, 512, K_MAGIC_4194304) 31 if r<=0 { af_puts("APIM: certdata load failed\n" as *u8); return 1 } 32 let store: *TrustStore = r as *TrustStore 33 af_puts("CA roots=" as *u8); af_putn(trust_store_count(store)); af_puts("\n" as *u8) 34 let cap: i64=K_MAGIC_4194304 35 let out: *u8=sys_mmap(cap) 36 var ok: i64=0 37 38 af_puts("== A. MCP SPEC DEPTH (the agent-API frontier) ==\n" as *u8) 39 ok = ok + af_fetch("https://en.wikipedia.org/wiki/Model_Context_Protocol" as *u8, "knowledge/fetched/apim_a_mcp.raw" as *u8, store, out, cap) 40 ok = ok + af_fetch("https://modelcontextprotocol.io/specification/2025-06-18/basic/transports" as *u8, "knowledge/fetched/apim_a_mcp_transports.raw" as *u8, store, out, cap) 41 ok = ok + af_fetch("https://modelcontextprotocol.io/specification/2025-06-18/client/elicitation" as *u8, "knowledge/fetched/apim_a_mcp_elicitation.raw" as *u8, store, out, cap) 42 ok = ok + af_fetch("https://modelcontextprotocol.io/specification/2025-06-18/client/sampling" as *u8, "knowledge/fetched/apim_a_mcp_sampling.raw" as *u8, store, out, cap) 43 ok = ok + af_fetch("https://modelcontextprotocol.io/specification/2025-06-18/client/roots" as *u8, "knowledge/fetched/apim_a_mcp_roots.raw" as *u8, store, out, cap) 44 45 af_puts("== B. EVENT/ASYNC + QUERY SURFACES ==\n" as *u8) 46 ok = ok + af_fetch("https://en.wikipedia.org/wiki/AsyncAPI" as *u8, "knowledge/fetched/apim_b_asyncapi.raw" as *u8, store, out, cap) 47 ok = ok + af_fetch("https://en.wikipedia.org/wiki/Webhook" as *u8, "knowledge/fetched/apim_b_webhook.raw" as *u8, store, out, cap) 48 ok = ok + af_fetch("https://en.wikipedia.org/wiki/GraphQL" as *u8, "knowledge/fetched/apim_b_graphql.raw" as *u8, store, out, cap) 49 ok = ok + af_fetch("https://en.wikipedia.org/wiki/Open_Data_Protocol" as *u8, "knowledge/fetched/apim_b_odata.raw" as *u8, store, out, cap) 50 ok = ok + af_fetch("https://en.wikipedia.org/wiki/GRPC" as *u8, "knowledge/fetched/apim_b_grpc.raw" as *u8, store, out, cap) 51 52 af_puts("== C. LIFECYCLE + OPERABILITY (the depth axes) ==\n" as *u8) 53 ok = ok + af_fetch("https://en.wikipedia.org/wiki/OpenTelemetry" as *u8, "knowledge/fetched/apim_c_otel.raw" as *u8, store, out, cap) 54 ok = ok + af_fetch("https://www.rfc-editor.org/rfc/rfc8594.html" as *u8, "knowledge/fetched/apim_c_sunset.raw" as *u8, store, out, cap) 55 ok = ok + af_fetch("https://www.rfc-editor.org/rfc/rfc9745.html" as *u8, "knowledge/fetched/apim_c_deprecation.raw" as *u8, store, out, cap) 56 ok = ok + af_fetch("https://en.wikipedia.org/wiki/Rate_limiting" as *u8, "knowledge/fetched/apim_c_ratelimit.raw" as *u8, store, out, cap) 57 ok = ok + af_fetch("https://en.wikipedia.org/wiki/Software_development_kit" as *u8, "knowledge/fetched/apim_c_sdk.raw" as *u8, store, out, cap) 58 59 af_puts("READABLE SOURCES SAVED: " as *u8); af_putn(ok); af_puts(" / 15\n" as *u8) 60 return 0 61}