code wiki / (root) / nx_tools_api_exec_gate.nx

nx_tools_api_exec_gate.nx

buildroot/runtime/nx_tools_api_exec_gate.nx

16447 B256 linesdepth 9pulls 25 transitivereach 0 importersview sourcekind gate/prooftopic tools
docsdependenciesstructsconstsfunctions

about

nx_tools_api_exec_gate.nx -- GATE for R2: the /mcp tools/call STUB is now REAL execution. Drives the live pure router ta_handle_pfx IN-PROCESS (no socket) and proves, end-to-end, that a capability-authorized tools/call for a GREEN-allowlisted tool actually FORKS the organ and returns its real stdout -- with the two never-brick negative controls that make this safe: (T2) no capability -> JSON-RPC -32001 (nothing runs), (T3) a valid capability for a tool that is NOT on the GREEN execution allowlist -> tool-level error, NOT executed. Composes R0 (nx_tool_run) + R1 (nx_tool_exec_allow) + the cap-token ocap layer. PREREQ: build nx_tool_ping FIRST (produces _offc/nx_tool_ping.elf, the allowlisted target). This gate writes the real allowlist file (tool_allowlist.conf) in the server CWD, since ta_mcp_call resolves through the production TEA_CONF path -- proving the ACTUAL wired path, not a test shim. license_tier: ORIGINAL expect_exit: 0

dependencies 2 imports · 0 importers

nx_tools_api.nx nx_gate.nx nx_tools_api_exec_gate.nx

imports: nx_tools_api.nxnx_gate.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main gw sys_write tool_register_pfx tr_cat tr_tab reg_put reg_put_x sts_lock sts_mm sys_mmap sts_werr sys_exit ss_cat sys_openat_append sts_werr ↻ sys_flock reg_key reg_cat ss_get sys_mmap ↻ ss_scan sys_mmap ↻ ss_manifest_dyn ss_scan_seglist reg_strlen reg_id_present sts_unlock sys_flock ↻ sys_close ss_next_segid sys_mmap ↻ ss_cat ↻ ss_readall sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close ↻ ss_segid_ok

structs

none

consts

15const EG_CONF: *u8 = "tool_allowlist.conf" as *u8
16const EG_PINGELF: *u8 = "_offc/nx_tool_ping.elf" as *u8

functions

18func eg_cat(d: *u8, o: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){ d[o+i]=s[i]; i=i+1 } return o+i }
19func eg_catb(d: *u8, o: i64, s: *u8, n: i64) -> i64 { var i: i64=0; while i<n { d[o+i]=s[i]; i=i+1 } return o+n }
20func eg_has(out: *u8, n: i64, needle: *u8) -> i64 { if ta_indexof(out, n, needle) >= 0 { return 1 } return 0 }
called by 1: main calls 1: ta_indexof
21func eg_write_file(path: *u8, content: *u8) -> i64
called by 1: main
30func eg_write_conf() -> i64
called by 1: main
40func eg_build_call(req: *u8, tool: *u8, tok: *u8, tlen: i64) -> i64
called by 1: main calls 2: eg_categ_catb
52func eg_build_call_argv(req: *u8, tool: *u8, tok: *u8, tlen: i64, argvj: *u8) -> i64
called by 1: main calls 2: eg_categ_catb
66func eg_build_call_bearer(req: *u8, tool: *u8, tok: *u8, tlen: i64) -> i64
called by 1: main calls 2: eg_categ_catb
76func main() -> i64