code wiki / (root) / nx_agentcap_sota_fetch.nx

nx_agentcap_sota_fetch.nx source

↩ module page · 46 lines · 3621 B

1// nx_agentcap_sota_fetch.nx -- SOVEREIGN researcher for the AGENT-CAPABILITY-API frontier (what "this" = the 2// X-Nishi-Cap object-capability tool-invocation system is measured against). The API-SOTA fetch banked MCP as a 3// 876B stub (dead README path); this fetches the REAL current MCP AUTHORIZATION + security-best-practices spec 4// (MCP's auth is the direct benchmark for our capability grant) + the object-capability / confused-deputy frontier 5// that our ocap model claims to beat. Over our own TLS + Mozilla CA -> knowledge/fetched/agentcap_*.raw. NOT memory. 6// license_tier: ORIGINAL depends: TLS stack + trust store 7import "nx_syscalls.nx" 8import "nx_x509_trust_store.nx" 9import "nx_trust_store_load_from_certdata.nx" 10import "nx_https_fetch_follow.nx" 11const K_MAGIC_8388608: i64 = 8388608 12const K_MAGIC_4194304: i64 = 4194304 13 14func ac_p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 15func ac_n(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 t: *u8=sys_mmap(28); var k: i64=0; while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } while k>0 { k=k-1; sys_write(1,(((t as i64)+k) as *u8),1) } return 0 } 16 17func ac_fetch(store: *TrustStore, url: *u8, outpath: *u8) -> i64 { 18 let cap: i64 = K_MAGIC_8388608; let buf: *u8 = sys_mmap(cap) 19 let status: *i64 = sys_mmap(8) as *i64 20 let n: i64 = nx_https_fetch_follow(url, store, buf, cap, 6, status) 21 ac_p(" " as *u8); ac_p(outpath); ac_p(" status=" as *u8); ac_n(status[0]); ac_p(" bytes=" as *u8); ac_n(n) 22 if n > 0 { 23 let fd: i64 = sys_openat_wr(outpath, 0x1a4) 24 if fd >= 0 { sys_write(fd, buf, n); sys_close(fd); ac_p(" SAVED\n" as *u8) } else { ac_p(" (write-fail)\n" as *u8) } 25 } else { ac_p(" FETCH-FAIL\n" as *u8) } 26 return n 27} 28 29func main() -> i64 { 30 ac_p("NX-AGENTCAP-SOTA-FETCH (MCP auth + ocap frontier over sovereign TLS)\n" as *u8) 31 let r: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt" as *u8, 512, K_MAGIC_4194304) 32 if r <= 0 { ac_p("CA load FAILED\n" as *u8); sys_exit(1); return 1 } 33 let store: *TrustStore = r as *TrustStore 34 // MCP AUTHORIZATION spec (2025-06-18) -- the direct benchmark: how MCP gates tool access (OAuth 2.1 + resource indicators) 35 ac_fetch(store, "https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization" as *u8, "knowledge/fetched/agentcap_mcp_authz.raw" as *u8) 36 // MCP SECURITY BEST PRACTICES -- MCP's own confused-deputy / token-passthrough warnings (what ocap forecloses) 37 ac_fetch(store, "https://modelcontextprotocol.io/specification/2025-06-18/basic/security_best_practices" as *u8, "knowledge/fetched/agentcap_mcp_security.raw" as *u8) 38 // MCP TOOLS spec -- tool discovery + call + input schemas (the completeness benchmark: schemas/annotations) 39 ac_fetch(store, "https://modelcontextprotocol.io/specification/2025-06-18/server/tools" as *u8, "knowledge/fetched/agentcap_mcp_tools.raw" as *u8) 40 // Confused-deputy problem (object-capability security frontier -- the class our authority-in-token structurally kills) 41 ac_fetch(store, "https://en.wikipedia.org/wiki/Confused_deputy_problem" as *u8, "knowledge/fetched/agentcap_confused_deputy.raw" as *u8) 42 // Capability-based security (the model our X-Nishi-Cap implements) 43 ac_fetch(store, "https://en.wikipedia.org/wiki/Capability-based_security" as *u8, "knowledge/fetched/agentcap_capability_security.raw" as *u8) 44 ac_p("NX-AGENTCAP-SOTA-FETCH done -> knowledge/fetched/agentcap_*.raw\n" as *u8) 45 sys_exit(0); return 0 46}