code wiki / _hdl_build / nx_connect_api_lib.nx
nx_connect_api_lib.nx
buildroot/runtime/_hdl_build/nx_connect_api_lib.nx
about
nx_connect_api_lib.nx -- the CONNECT FRONT DOOR: one stateless verb dispatcher over all 8 capability
engines, emitting versioned JSON. This is what makes CONNECT MCP-ready, API-ready, agent-ready,
workflow-ready, and horizontally scalable in ONE surface:
* OBJECT-ORIENTED: the 8 `nx_connect_*_lib.nx` organs ARE the objects -- each encapsulates one
capability's state contract and operations (single responsibility). THIS file is the facade/registry
over them; it owns no capability logic, only routing + serialization.
* MCP + API: a thin CLI (nx_connect_api.nx) wraps ca_dispatch and is registered via
POST /api/tools/register, so it appears as mcp__nishi__nx_connect and is drivable over the mgmt API.
* AGENTIC + WORKFLOW: the `help` verb returns a machine-readable catalog of every verb and its argument
shape, so an agent or a Workflow can DISCOVER the interface at runtime instead of being told it.
* SCALE: every verb is a PURE function of its arguments -- no shared mutable state, no session, no disk.
Any number of calls run independently and in parallel; the tool can be replicated with zero coordination.
* CONTRACT STABILITY (rule 19): every response carries {"v":1,...}; new fields are additive.
* STRUCTURED ERRORS (rule 6): a bad call returns {"ok":0,"error":<slug>,"detail":<human>}, never a crash.
PURE CORE: no main (so the gate imports it and drives ca_dispatch with synthetic argv). license_tier: ORIGINAL
dependencies 10 imports · 2 importers
imports: nx_connect_match_lib.nxnx_connect_lds_reconnect_lib.nxnx_connect_youth_lib.nxnx_connect_wards_lib.nxnx_connect_lanes_lib.nxnx_connect_events_lib.nxnx_connect_polls_lib.nxnx_connect_group_lib.nxnx_connect_graph_lib.nxnx_mt_multi.nx
imported by: nx_connect_api.nxnx_connect_api_gate.nx
structs
| none |
consts
| 28 | const CA_MAGIC_4096: i64 = 4096 |
| 29 | const CA_MAGIC_4095: i64 = 4095 |
| 31 | const CA_VER: i64 = 1 |
| 32 | const CA_LANG_MAX: i64 = 4 // MM_EN=0 MM_RU=1 MM_BE=2 MM_UK=3 MM_PL=4 |
functions
| 35 | func ca_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 36 | func ca_puts(o: *u8, off: i64, s: *u8) -> i64 { var p: i64=off; var i: i64=0; while s[i]!=(0 as u8){o[p]=s[i]; p=p+1; i=i+1} return p } |
| 38 | func ca_putn(o: *u8, off: i64, v: i64) -> i64 |
| 49 | func ca_streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8){ if a[i]!=b[i]{return 0} i=i+1 } if b[i]!=(0 as u8){return 0} return 1 } called by 1: ca_dispatch |
| 51 | func ca_atoi(s: *u8) -> i64 called by 1: ca_ia |
| 61 | func ca_ia(argv: *i64, argc: i64, i: i64) -> i64 { if i>=argc { return 0 } return ca_atoi(argv[i] as *u8) } called by 10: ca_v_graphca_v_translateca_v_matchca_v_reconnectca_v_laneca_v_youth+4 calls 1: ca_atoi |
| 64 | func ca_open(o: *u8, off: i64, verb: *u8) -> i64 called by 12: ca_errca_helpca_v_graphca_v_translateca_v_matchca_v_reconnect+6 calls 2: ca_putsca_putn |
| 73 | func ca_err(o: *u8, off: i64, verb: *u8, slug: *u8, detail: *u8) -> i64 called by 11: ca_v_graphca_v_translateca_v_matchca_v_reconnectca_v_laneca_v_youth+5 calls 2: ca_openca_puts |
| 86 | func ca_esc_json(o: *u8, off: i64, s: *u8) -> i64 called by 1: ca_v_translate |
| 100 | func ca_kv(o: *u8, off: i64, key: *u8, v: i64) -> i64 called by 9: ca_v_graphca_v_matchca_v_reconnectca_v_laneca_v_youthca_v_wards+3 calls 2: ca_putsca_putn |
| 109 | func ca_help(o: *u8, off: i64) -> i64 |
| 129 | func ca_v_graph(o: *u8, off: i64, argv: *i64, argc: i64) -> i64 |
| 147 | func ca_v_translate(o: *u8, off: i64, argv: *i64, argc: i64) -> i64 |
| 170 | func ca_v_match(o: *u8, off: i64, argv: *i64, argc: i64) -> i64 |
| 182 | func ca_v_reconnect(o: *u8, off: i64, argv: *i64, argc: i64) -> i64 |
| 198 | func ca_v_lane(o: *u8, off: i64, argv: *i64, argc: i64) -> i64 |
| 210 | func ca_v_youth(o: *u8, off: i64, argv: *i64, argc: i64) -> i64 |
| 220 | func ca_v_wards(o: *u8, off: i64, argv: *i64, argc: i64) -> i64 |
| 240 | func ca_v_events(o: *u8, off: i64, argv: *i64, argc: i64) -> i64 |
| 292 | func ca_v_poll(o: *u8, off: i64, argv: *i64, argc: i64) -> i64 |
| 327 | func ca_v_group(o: *u8, off: i64, argv: *i64, argc: i64) -> i64 |
| 352 | func ca_dispatch(argc: i64, argv: *i64, out: *u8) -> i64 |