[{"data":1,"prerenderedAt":2906},["ShallowReactive",2],{"sidebar-pages":3,"doc-/l4-apps":20},[4,8,12,16],{"_path":5,"title":6,"order":7},"/abi","ABI & boundary",2,{"_path":9,"title":10,"order":11},"/architecture","Architecture",1,{"_path":13,"title":14,"order":15},"/l3-modules","L3 — Provider SDK",3,{"_path":17,"title":18,"order":19},"/l4-apps","L4 — App SDK",4,{"_path":17,"_dir":21,"_draft":22,"_partial":22,"_locale":21,"title":18,"description":21,"order":19,"body":23,"_type":2899,"_id":2900,"_source":2901,"_file":2902,"_stem":2903,"_extension":2904,"sitemap":2905},"",false,{"type":24,"children":25,"toc":2882},"root",[26,35,101,108,164,198,231,265,271,276,452,464,476,635,641,757,850,856,875,1767,1772,1867,1873,1887,2220,2226,2231,2555,2568,2602,2608,2821,2827,2860,2876],{"type":27,"tag":28,"props":29,"children":31},"element","h1",{"id":30},"legion-l4-application-consumer-sdk-building-apps",[32],{"type":33,"value":34},"text","Legion L4 — Application / Consumer SDK (building apps)",{"type":27,"tag":36,"props":37,"children":38},"blockquote",{},[39],{"type":27,"tag":40,"props":41,"children":42},"p",{},[43,49,51,56,58,69,71,80,82,88,90,99],{"type":27,"tag":44,"props":45,"children":46},"strong",{},[47],{"type":33,"value":48},"Status: DRAFT",{"type":33,"value":50}," (Foundation 09). The first visible cut of the L4\napplication API. A ",{"type":27,"tag":44,"props":52,"children":53},{},[54],{"type":33,"value":55},"draft, not a release candidate",{"type":33,"value":57}," — names and signatures\nmay change. Start with ",{"type":27,"tag":59,"props":60,"children":61},"a",{"href":9},[62],{"type":27,"tag":63,"props":64,"children":66},"code",{"className":65},[],[67],{"type":33,"value":68},"architecture.md",{"type":33,"value":70}," (the layer model)\nand ",{"type":27,"tag":59,"props":72,"children":73},{"href":5},[74],{"type":27,"tag":63,"props":75,"children":77},{"className":76},[],[78],{"type":33,"value":79},"abi.md",{"type":33,"value":81}," (the exported ABI). The L3 side — ",{"type":27,"tag":83,"props":84,"children":85},"em",{},[86],{"type":33,"value":87},"providing",{"type":33,"value":89}," a\ncapability — is in ",{"type":27,"tag":59,"props":91,"children":92},{"href":13},[93],{"type":27,"tag":63,"props":94,"children":96},{"className":95},[],[97],{"type":33,"value":98},"l3_modules.md",{"type":33,"value":100},".",{"type":27,"tag":102,"props":103,"children":105},"h2",{"id":104},"what-l4-is",[106],{"type":33,"value":107},"What L4 is",{"type":27,"tag":40,"props":109,"children":110},{},[111,113,118,120,125,127,132,134,139,141,147,149,155,157,162],{"type":33,"value":112},"L4 is the ",{"type":27,"tag":44,"props":114,"children":115},{},[116],{"type":33,"value":117},"consumer",{"type":33,"value":119}," surface: you build an ",{"type":27,"tag":44,"props":121,"children":122},{},[123],{"type":33,"value":124},"app",{"type":33,"value":126}," that runs a Legion node,\n",{"type":27,"tag":44,"props":128,"children":129},{},[130],{"type":33,"value":131},"discovers",{"type":33,"value":133}," capabilities the cohort advertises, and ",{"type":27,"tag":44,"props":135,"children":136},{},[137],{"type":33,"value":138},"consumes",{"type":33,"value":140}," them — calling\na remote ",{"type":27,"tag":63,"props":142,"children":144},{"className":143},[],[145],{"type":33,"value":146},"ai.stt.transcribe",{"type":33,"value":148},", a peer's ",{"type":27,"tag":63,"props":150,"children":152},{"className":151},[],[153],{"type":33,"value":154},"display.gui",{"type":33,"value":156},", a storage cap, etc. Apps\nnever ",{"type":27,"tag":83,"props":158,"children":159},{},[160],{"type":33,"value":161},"advertise",{"type":33,"value":163}," capabilities (that's L3); they consume.",{"type":27,"tag":40,"props":165,"children":166},{},[167,179,181,187,189,197],{"type":27,"tag":44,"props":168,"children":169},{},[170,172,177],{"type":33,"value":171},"L4 ",{"type":27,"tag":83,"props":173,"children":174},{},[175],{"type":33,"value":176},"is",{"type":33,"value":178}," the dynamic ABI",{"type":33,"value":180}," — the ~131 exported ",{"type":27,"tag":63,"props":182,"children":184},{"className":183},[],[185],{"type":33,"value":186},"legion_*",{"type":33,"value":188}," symbols. It is the\nnative-C surface any consumer links against: native desktop apps, embedded /\nmicrocontroller targets, and language bindings alike (the Android NDK voice-loop\napp was the first proof-of-concept, not a constraint). See ",{"type":27,"tag":59,"props":190,"children":191},{"href":5},[192],{"type":27,"tag":63,"props":193,"children":195},{"className":194},[],[196],{"type":33,"value":79},{"type":33,"value":100},{"type":27,"tag":199,"props":200,"children":204},"pre",{"className":201,"code":202,"language":203,"meta":21,"style":21},"language-c shiki shiki-themes github-dark github-dark","#include \u003Clegion/legion.h>   /* umbrella — pulls the whole L4 surface */\n","c",[205],{"type":27,"tag":63,"props":206,"children":207},{"__ignoreMap":21},[208],{"type":27,"tag":209,"props":210,"children":212},"span",{"class":211,"line":11},"line",[213,219,225],{"type":27,"tag":209,"props":214,"children":216},{"style":215},"--shiki-default:#F97583;--shiki-dark:#F97583",[217],{"type":33,"value":218},"#include",{"type":27,"tag":209,"props":220,"children":222},{"style":221},"--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF",[223],{"type":33,"value":224}," \u003Clegion/legion.h>",{"type":27,"tag":209,"props":226,"children":228},{"style":227},"--shiki-default:#6A737D;--shiki-dark:#6A737D",[229],{"type":33,"value":230},"   /* umbrella — pulls the whole L4 surface */\n",{"type":27,"tag":40,"props":232,"children":233},{},[234,240,242,248,250,256,258,264],{"type":27,"tag":63,"props":235,"children":237},{"className":236},[],[238],{"type":33,"value":239},"legion.h",{"type":33,"value":241}," transitively includes the library base, ",{"type":27,"tag":63,"props":243,"children":245},{"className":244},[],[246],{"type":33,"value":247},"l4_node.h",{"type":33,"value":249},", the\n",{"type":27,"tag":63,"props":251,"children":253},{"className":252},[],[254],{"type":33,"value":255},"legion_ffi_*.h",{"type":33,"value":257}," family, and (for convenience) ",{"type":27,"tag":63,"props":259,"children":261},{"className":260},[],[262],{"type":33,"value":263},"sdk.h",{"type":33,"value":100},{"type":27,"tag":102,"props":266,"children":268},{"id":267},"two-flavors-of-the-l4-surface",[269],{"type":33,"value":270},"Two flavors of the L4 surface",{"type":27,"tag":40,"props":272,"children":273},{},[274],{"type":33,"value":275},"L4 exposes the same node two ways; pick by how you're building:",{"type":27,"tag":277,"props":278,"children":279},"table",{},[280,324],{"type":27,"tag":281,"props":282,"children":283},"thead",{},[284],{"type":27,"tag":285,"props":286,"children":287},"tr",{},[288,292,309],{"type":27,"tag":289,"props":290,"children":291},"th",{},[],{"type":27,"tag":289,"props":293,"children":294},{},[295,300,302,307],{"type":27,"tag":44,"props":296,"children":297},{},[298],{"type":33,"value":299},"Native C API",{"type":33,"value":301}," (",{"type":27,"tag":63,"props":303,"children":305},{"className":304},[],[306],{"type":33,"value":247},{"type":33,"value":308},")",{"type":27,"tag":289,"props":310,"children":311},{},[312,317,318,323],{"type":27,"tag":44,"props":313,"children":314},{},[315],{"type":33,"value":316},"Binding / FFI API",{"type":33,"value":301},{"type":27,"tag":63,"props":319,"children":321},{"className":320},[],[322],{"type":33,"value":255},{"type":33,"value":308},{"type":27,"tag":325,"props":326,"children":327},"tbody",{},[328,359,385,434],{"type":27,"tag":285,"props":329,"children":330},{},[331,337,348],{"type":27,"tag":332,"props":333,"children":334},"td",{},[335],{"type":33,"value":336},"Handle",{"type":27,"tag":332,"props":338,"children":339},{},[340,342],{"type":33,"value":341},"typed ",{"type":27,"tag":63,"props":343,"children":345},{"className":344},[],[346],{"type":33,"value":347},"legion_node_t *",{"type":27,"tag":332,"props":349,"children":350},{},[351,353],{"type":33,"value":352},"opaque ",{"type":27,"tag":63,"props":354,"children":356},{"className":355},[],[357],{"type":33,"value":358},"intptr_t",{"type":27,"tag":285,"props":360,"children":361},{},[362,367,376],{"type":27,"tag":332,"props":363,"children":364},{},[365],{"type":33,"value":366},"Create",{"type":27,"tag":332,"props":368,"children":369},{},[370],{"type":27,"tag":63,"props":371,"children":373},{"className":372},[],[374],{"type":33,"value":375},"legion_node_create_from_file(\u003CJSON config>)",{"type":27,"tag":332,"props":377,"children":378},{},[379],{"type":27,"tag":63,"props":380,"children":382},{"className":381},[],[383],{"type":33,"value":384},"legion_ffi_node_start(node_id, cohort, master_pk, seed, cert, cert_len, multicast)",{"type":27,"tag":285,"props":386,"children":387},{},[388,393,423],{"type":27,"tag":332,"props":389,"children":390},{},[391],{"type":33,"value":392},"Consume a cap",{"type":27,"tag":332,"props":394,"children":395},{},[396,398,404,406,412,414,422],{"type":33,"value":397},"via the plugin manager + L3 dispatch (",{"type":27,"tag":63,"props":399,"children":401},{"className":400},[],[402],{"type":33,"value":403},"legion_node_get_plugins",{"type":33,"value":405}," → ",{"type":27,"tag":63,"props":407,"children":409},{"className":408},[],[410],{"type":33,"value":411},"legion_module_dispatch_to_cap_async",{"type":33,"value":413},", see ",{"type":27,"tag":59,"props":415,"children":416},{"href":13},[417],{"type":27,"tag":63,"props":418,"children":420},{"className":419},[],[421],{"type":33,"value":98},{"type":33,"value":308},{"type":27,"tag":332,"props":424,"children":425},{},[426,428],{"type":33,"value":427},"self-contained ",{"type":27,"tag":63,"props":429,"children":431},{"className":430},[],[432],{"type":33,"value":433},"legion_ffi_call_cap(...)",{"type":27,"tag":285,"props":435,"children":436},{},[437,442,447],{"type":27,"tag":332,"props":438,"children":439},{},[440],{"type":33,"value":441},"Best for",{"type":27,"tag":332,"props":443,"children":444},{},[445],{"type":33,"value":446},"native apps that want typed pointers + config files",{"type":27,"tag":332,"props":448,"children":449},{},[450],{"type":33,"value":451},"language bindings, embedding, simple consumers",{"type":27,"tag":40,"props":453,"children":454},{},[455,457,462],{"type":33,"value":456},"Both are L4 (both exported). Don't mix handles between the two. The worked\nexample below uses the ",{"type":27,"tag":44,"props":458,"children":459},{},[460],{"type":33,"value":461},"FFI flavor",{"type":33,"value":463}," because it's the most self-contained and is\nexactly what the voice-loop app does.",{"type":27,"tag":102,"props":465,"children":467},{"id":466},"library-base-legionh",[468,470,475],{"type":33,"value":469},"Library base (",{"type":27,"tag":63,"props":471,"children":473},{"className":472},[],[474],{"type":33,"value":239},{"type":33,"value":308},{"type":27,"tag":277,"props":477,"children":478},{},[479,495],{"type":27,"tag":281,"props":480,"children":481},{},[482],{"type":27,"tag":285,"props":483,"children":484},{},[485,490],{"type":27,"tag":289,"props":486,"children":487},{},[488],{"type":33,"value":489},"Function",{"type":27,"tag":289,"props":491,"children":492},{},[493],{"type":33,"value":494},"Purpose",{"type":27,"tag":325,"props":496,"children":497},{},[498,537,554,571,603],{"type":27,"tag":285,"props":499,"children":500},{},[501,532],{"type":27,"tag":332,"props":502,"children":503},{},[504,510,512,518,519,525,526],{"type":27,"tag":63,"props":505,"children":507},{"className":506},[],[508],{"type":33,"value":509},"legion_version",{"type":33,"value":511}," / ",{"type":27,"tag":63,"props":513,"children":515},{"className":514},[],[516],{"type":33,"value":517},"_version_major",{"type":33,"value":511},{"type":27,"tag":63,"props":520,"children":522},{"className":521},[],[523],{"type":33,"value":524},"_minor",{"type":33,"value":511},{"type":27,"tag":63,"props":527,"children":529},{"className":528},[],[530],{"type":33,"value":531},"_patch",{"type":27,"tag":332,"props":533,"children":534},{},[535],{"type":33,"value":536},"Version string + components.",{"type":27,"tag":285,"props":538,"children":539},{},[540,549],{"type":27,"tag":332,"props":541,"children":542},{},[543],{"type":27,"tag":63,"props":544,"children":546},{"className":545},[],[547],{"type":33,"value":548},"legion_build_id",{"type":27,"tag":332,"props":550,"children":551},{},[552],{"type":33,"value":553},"Git hash + build metadata.",{"type":27,"tag":285,"props":555,"children":556},{},[557,566],{"type":27,"tag":332,"props":558,"children":559},{},[560],{"type":27,"tag":63,"props":561,"children":563},{"className":562},[],[564],{"type":33,"value":565},"legion_free(ptr)",{"type":27,"tag":332,"props":567,"children":568},{},[569],{"type":33,"value":570},"Free a buffer the library allocated and handed back.",{"type":27,"tag":285,"props":572,"children":573},{},[574,590],{"type":27,"tag":332,"props":575,"children":576},{},[577,583,584],{"type":27,"tag":63,"props":578,"children":580},{"className":579},[],[581],{"type":33,"value":582},"legion_log_set_callback(fn, ud)",{"type":33,"value":511},{"type":27,"tag":63,"props":585,"children":587},{"className":586},[],[588],{"type":33,"value":589},"legion_log_set_level(lvl)",{"type":27,"tag":332,"props":591,"children":592},{},[593,595,601],{"type":33,"value":594},"Logging sink ",{"type":27,"tag":63,"props":596,"children":598},{"className":597},[],[599],{"type":33,"value":600},"(level, component, msg, ud)",{"type":33,"value":602}," + minimum level.",{"type":27,"tag":285,"props":604,"children":605},{},[606,615],{"type":27,"tag":332,"props":607,"children":608},{},[609],{"type":27,"tag":63,"props":610,"children":612},{"className":611},[],[613],{"type":33,"value":614},"legion_config_find(cli_path, …)",{"type":27,"tag":332,"props":616,"children":617},{},[618,620,626,627,633],{"type":33,"value":619},"Resolve a config file: CLI path → ",{"type":27,"tag":63,"props":621,"children":623},{"className":622},[],[624],{"type":33,"value":625},"$LEGION_CONFIG",{"type":33,"value":405},{"type":27,"tag":63,"props":628,"children":630},{"className":629},[],[631],{"type":33,"value":632},"./",{"type":33,"value":634}," → user dir → system dir.",{"type":27,"tag":102,"props":636,"children":638},{"id":637},"node-lifecycle",[639],{"type":33,"value":640},"Node lifecycle",{"type":27,"tag":40,"props":642,"children":643},{},[644,656,658,664,666,671,673,679,681,687,689,695,697,703,705,711,713,719,720,726,727,733,734,740,742,748,749,755],{"type":27,"tag":44,"props":645,"children":646},{},[647,649,654],{"type":33,"value":648},"Native (",{"type":27,"tag":63,"props":650,"children":652},{"className":651},[],[653],{"type":33,"value":247},{"type":33,"value":655},"):",{"type":33,"value":657}," ",{"type":27,"tag":63,"props":659,"children":661},{"className":660},[],[662],{"type":33,"value":663},"legion_node_create_from_file",{"type":33,"value":665}," (read a JSON config →\n",{"type":27,"tag":63,"props":667,"children":669},{"className":668},[],[670],{"type":33,"value":347},{"type":33,"value":672},") → ",{"type":27,"tag":63,"props":674,"children":676},{"className":675},[],[677],{"type":33,"value":678},"legion_node_start",{"type":33,"value":680}," → … → ",{"type":27,"tag":63,"props":682,"children":684},{"className":683},[],[685],{"type":33,"value":686},"legion_node_stop",{"type":33,"value":688}," →\n",{"type":27,"tag":63,"props":690,"children":692},{"className":691},[],[693],{"type":33,"value":694},"legion_node_destroy",{"type":33,"value":696},". Plus ",{"type":27,"tag":63,"props":698,"children":700},{"className":699},[],[701],{"type":33,"value":702},"legion_node_reload",{"type":33,"value":704}," and read-only getters:\n",{"type":27,"tag":63,"props":706,"children":708},{"className":707},[],[709],{"type":33,"value":710},"get_node_id",{"type":33,"value":712},", ",{"type":27,"tag":63,"props":714,"children":716},{"className":715},[],[717],{"type":33,"value":718},"get_pk_hex",{"type":33,"value":712},{"type":27,"tag":63,"props":721,"children":723},{"className":722},[],[724],{"type":33,"value":725},"get_epoch",{"type":33,"value":712},{"type":27,"tag":63,"props":728,"children":730},{"className":729},[],[731],{"type":33,"value":732},"get_cohort_name",{"type":33,"value":712},{"type":27,"tag":63,"props":735,"children":737},{"className":736},[],[738],{"type":33,"value":739},"get_peers",{"type":33,"value":741},",\n",{"type":27,"tag":63,"props":743,"children":745},{"className":744},[],[746],{"type":33,"value":747},"get_plugins",{"type":33,"value":712},{"type":27,"tag":63,"props":750,"children":752},{"className":751},[],[753],{"type":33,"value":754},"format_status",{"type":33,"value":756}," (a human-readable status report).",{"type":27,"tag":40,"props":758,"children":759},{},[760,772,773,779,781,786,788,794,796,802,804,810,812,818,820,826,827,833,835,841,842,848],{"type":27,"tag":44,"props":761,"children":762},{},[763,765,771],{"type":33,"value":764},"FFI (",{"type":27,"tag":63,"props":766,"children":768},{"className":767},[],[769],{"type":33,"value":770},"legion_ffi_node.h",{"type":33,"value":655},{"type":33,"value":657},{"type":27,"tag":63,"props":774,"children":776},{"className":775},[],[777],{"type":33,"value":778},"legion_ffi_node_start(node_id, cohort_name, master_pk_hex, seed_hex, service_cert, service_cert_len, multicast_enabled)",{"type":33,"value":780},"\nreturns an ",{"type":27,"tag":63,"props":782,"children":784},{"className":783},[],[785],{"type":33,"value":358},{"type":33,"value":787}," handle (0 on failure) with discovery / heartbeat /\ntransport threads already running; ",{"type":27,"tag":63,"props":789,"children":791},{"className":790},[],[792],{"type":33,"value":793},"legion_ffi_node_stop(handle)",{"type":33,"value":795},";\n",{"type":27,"tag":63,"props":797,"children":799},{"className":798},[],[800],{"type":33,"value":801},"legion_ffi_node_is_running(handle)",{"type":33,"value":803},". All FFI calls are thread-safe. The\nmember-enrolment params anchor the cohort for a member device: ",{"type":27,"tag":63,"props":805,"children":807},{"className":806},[],[808],{"type":33,"value":809},"master_pk_hex",{"type":33,"value":811}," +\n",{"type":27,"tag":63,"props":813,"children":815},{"className":814},[],[816],{"type":33,"value":817},"seed_hex",{"type":33,"value":819}," identify the cohort, and ",{"type":27,"tag":63,"props":821,"children":823},{"className":822},[],[824],{"type":33,"value":825},"service_cert",{"type":33,"value":511},{"type":27,"tag":63,"props":828,"children":830},{"className":829},[],[831],{"type":33,"value":832},"_len",{"type":33,"value":834}," is an optional\nmaster-issued member certificate (pass ",{"type":27,"tag":63,"props":836,"children":838},{"className":837},[],[839],{"type":33,"value":840},"NULL",{"type":33,"value":511},{"type":27,"tag":63,"props":843,"children":845},{"className":844},[],[846],{"type":33,"value":847},"0",{"type":33,"value":849}," for a self-master node).",{"type":27,"tag":102,"props":851,"children":853},{"id":852},"worked-example-discover-consume-a-remote-capability",[854],{"type":33,"value":855},"Worked example — discover + consume a remote capability",{"type":27,"tag":40,"props":857,"children":858},{},[859,861,866,868,873],{"type":33,"value":860},"This is the pattern the voice-loop app uses to drive a remote ",{"type":27,"tag":63,"props":862,"children":864},{"className":863},[],[865],{"type":33,"value":146},{"type":33,"value":867},"\nprovider, using the real, verified ",{"type":27,"tag":63,"props":869,"children":871},{"className":870},[],[872],{"type":33,"value":770},{"type":33,"value":874}," surface.",{"type":27,"tag":199,"props":876,"children":878},{"className":201,"code":877,"language":203,"meta":21,"style":21},"#include \u003Clegion/legion.h>\n#include \u003Cstring.h>\n#include \u003Cstdio.h>\n\n/* 1. Start an in-process node (discovery + transport threads run in the bg).\n *    master_pk_hex + seed_hex anchor the cohort for a member device; the cert\n *    is an optional master-issued member cert (NULL/0 for a self-master node). */\nintptr_t node = legion_ffi_node_start(\"my-app\", \"personal\",\n            /*master_pk_hex=*/ NULL, /*seed_hex=*/ NULL,\n            /*service_cert=*/  NULL, /*service_cert_len=*/ 0,\n            /*multicast=*/     1);\nif (!node) return 1;\n\n/* 2. DISCOVER — what peers are visible, and what caps do they advertise?\n *    JSON: [{\"node_id\":\"...\",\"did\":\"...\",\"caps\":[\"ai.stt.transcribe\"],\"trust\":0.9}, ...] */\nchar peers[8192];\nif (legion_ffi_node_get_peers_json(node, peers, sizeof(peers)) > 0)\n    printf(\"peers: %s\\n\", peers);\n\n/* 3. (LEGACY FALLBACK — usually NOT needed.) A full cohort member catches up\n *    via consensus sync (cert-validated discovery) and resolves any_one caps on\n *    its own, so skip this. Only a device that can't converge on consensus needs\n *    to pin a module's delegation to a provider discovered in step 2. */\n/* legion_ffi_node_delegate_pin(node, \"stt\", \"balrog-ai-node\"); */\n\n/* 4. CONSUME — call `transcribe` on ANY live provider of `ai.stt.transcribe`\n *    (fungible any_one delegation). The single binary param carries the audio. */\nuint8_t  out[64 * 1024];\nsize_t   out_len = 0;\nint rc = legion_ffi_call_cap(node,\n            /*cap=*/    \"ai.stt.transcribe\",\n            /*module=*/ \"stt\",\n            /*method=*/ \"transcribe\",\n            /*param_key=*/  \"audio\",\n            /*param_data=*/ pcm_bytes, pcm_len,\n            /*timeout_ms=*/ 15000,\n            out, sizeof(out), &out_len);\n\nif (rc == LEGION_OK) {\n    fwrite(out, 1, out_len, stdout);                 /* the transcript */\n} else if (rc == LEGION_ERR_NOMEM && out_len > sizeof(out)) {\n    /* out_len is the FULL result size — grow the buffer and retry. */\n} else if (rc == LEGION_ERR_NO_DELEGATE) {\n    /* No live provider of the cap (loud, never silently swallowed). */\n}\n\n/* 5. Done. */\nlegion_ffi_node_stop(node);\n",[879],{"type":27,"tag":63,"props":880,"children":881},{"__ignoreMap":21},[882,894,906,918,927,936,945,954,1002,1035,1067,1086,1123,1131,1140,1149,1179,1225,1258,1266,1275,1284,1293,1302,1311,1319,1328,1337,1374,1400,1428,1446,1464,1482,1500,1514,1532,1564,1572,1595,1624,1680,1689,1718,1727,1736,1744,1753],{"type":27,"tag":209,"props":883,"children":884},{"class":211,"line":11},[885,889],{"type":27,"tag":209,"props":886,"children":887},{"style":215},[888],{"type":33,"value":218},{"type":27,"tag":209,"props":890,"children":891},{"style":221},[892],{"type":33,"value":893}," \u003Clegion/legion.h>\n",{"type":27,"tag":209,"props":895,"children":896},{"class":211,"line":7},[897,901],{"type":27,"tag":209,"props":898,"children":899},{"style":215},[900],{"type":33,"value":218},{"type":27,"tag":209,"props":902,"children":903},{"style":221},[904],{"type":33,"value":905}," \u003Cstring.h>\n",{"type":27,"tag":209,"props":907,"children":908},{"class":211,"line":15},[909,913],{"type":27,"tag":209,"props":910,"children":911},{"style":215},[912],{"type":33,"value":218},{"type":27,"tag":209,"props":914,"children":915},{"style":221},[916],{"type":33,"value":917}," \u003Cstdio.h>\n",{"type":27,"tag":209,"props":919,"children":920},{"class":211,"line":19},[921],{"type":27,"tag":209,"props":922,"children":924},{"emptyLinePlaceholder":923},true,[925],{"type":33,"value":926},"\n",{"type":27,"tag":209,"props":928,"children":930},{"class":211,"line":929},5,[931],{"type":27,"tag":209,"props":932,"children":933},{"style":227},[934],{"type":33,"value":935},"/* 1. Start an in-process node (discovery + transport threads run in the bg).\n",{"type":27,"tag":209,"props":937,"children":939},{"class":211,"line":938},6,[940],{"type":27,"tag":209,"props":941,"children":942},{"style":227},[943],{"type":33,"value":944}," *    master_pk_hex + seed_hex anchor the cohort for a member device; the cert\n",{"type":27,"tag":209,"props":946,"children":948},{"class":211,"line":947},7,[949],{"type":27,"tag":209,"props":950,"children":951},{"style":227},[952],{"type":33,"value":953}," *    is an optional master-issued member cert (NULL/0 for a self-master node). */\n",{"type":27,"tag":209,"props":955,"children":957},{"class":211,"line":956},8,[958,962,968,973,979,984,989,993,998],{"type":27,"tag":209,"props":959,"children":960},{"style":215},[961],{"type":33,"value":358},{"type":27,"tag":209,"props":963,"children":965},{"style":964},"--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8",[966],{"type":33,"value":967}," node ",{"type":27,"tag":209,"props":969,"children":970},{"style":215},[971],{"type":33,"value":972},"=",{"type":27,"tag":209,"props":974,"children":976},{"style":975},"--shiki-default:#B392F0;--shiki-dark:#B392F0",[977],{"type":33,"value":978}," legion_ffi_node_start",{"type":27,"tag":209,"props":980,"children":981},{"style":964},[982],{"type":33,"value":983},"(",{"type":27,"tag":209,"props":985,"children":986},{"style":221},[987],{"type":33,"value":988},"\"my-app\"",{"type":27,"tag":209,"props":990,"children":991},{"style":964},[992],{"type":33,"value":712},{"type":27,"tag":209,"props":994,"children":995},{"style":221},[996],{"type":33,"value":997},"\"personal\"",{"type":27,"tag":209,"props":999,"children":1000},{"style":964},[1001],{"type":33,"value":741},{"type":27,"tag":209,"props":1003,"children":1005},{"class":211,"line":1004},9,[1006,1011,1017,1022,1027,1031],{"type":27,"tag":209,"props":1007,"children":1008},{"style":227},[1009],{"type":33,"value":1010},"            /*master_pk_hex=*/",{"type":27,"tag":209,"props":1012,"children":1014},{"style":1013},"--shiki-default:#79B8FF;--shiki-dark:#79B8FF",[1015],{"type":33,"value":1016}," NULL",{"type":27,"tag":209,"props":1018,"children":1019},{"style":964},[1020],{"type":33,"value":1021},",",{"type":27,"tag":209,"props":1023,"children":1024},{"style":227},[1025],{"type":33,"value":1026}," /*seed_hex=*/",{"type":27,"tag":209,"props":1028,"children":1029},{"style":1013},[1030],{"type":33,"value":1016},{"type":27,"tag":209,"props":1032,"children":1033},{"style":964},[1034],{"type":33,"value":741},{"type":27,"tag":209,"props":1036,"children":1038},{"class":211,"line":1037},10,[1039,1044,1049,1053,1058,1063],{"type":27,"tag":209,"props":1040,"children":1041},{"style":227},[1042],{"type":33,"value":1043},"            /*service_cert=*/",{"type":27,"tag":209,"props":1045,"children":1046},{"style":1013},[1047],{"type":33,"value":1048},"  NULL",{"type":27,"tag":209,"props":1050,"children":1051},{"style":964},[1052],{"type":33,"value":1021},{"type":27,"tag":209,"props":1054,"children":1055},{"style":227},[1056],{"type":33,"value":1057}," /*service_cert_len=*/",{"type":27,"tag":209,"props":1059,"children":1060},{"style":1013},[1061],{"type":33,"value":1062}," 0",{"type":27,"tag":209,"props":1064,"children":1065},{"style":964},[1066],{"type":33,"value":741},{"type":27,"tag":209,"props":1068,"children":1070},{"class":211,"line":1069},11,[1071,1076,1081],{"type":27,"tag":209,"props":1072,"children":1073},{"style":227},[1074],{"type":33,"value":1075},"            /*multicast=*/",{"type":27,"tag":209,"props":1077,"children":1078},{"style":1013},[1079],{"type":33,"value":1080},"     1",{"type":27,"tag":209,"props":1082,"children":1083},{"style":964},[1084],{"type":33,"value":1085},");\n",{"type":27,"tag":209,"props":1087,"children":1089},{"class":211,"line":1088},12,[1090,1095,1099,1104,1109,1114,1119],{"type":27,"tag":209,"props":1091,"children":1092},{"style":215},[1093],{"type":33,"value":1094},"if",{"type":27,"tag":209,"props":1096,"children":1097},{"style":964},[1098],{"type":33,"value":301},{"type":27,"tag":209,"props":1100,"children":1101},{"style":215},[1102],{"type":33,"value":1103},"!",{"type":27,"tag":209,"props":1105,"children":1106},{"style":964},[1107],{"type":33,"value":1108},"node) ",{"type":27,"tag":209,"props":1110,"children":1111},{"style":215},[1112],{"type":33,"value":1113},"return",{"type":27,"tag":209,"props":1115,"children":1116},{"style":1013},[1117],{"type":33,"value":1118}," 1",{"type":27,"tag":209,"props":1120,"children":1121},{"style":964},[1122],{"type":33,"value":795},{"type":27,"tag":209,"props":1124,"children":1126},{"class":211,"line":1125},13,[1127],{"type":27,"tag":209,"props":1128,"children":1129},{"emptyLinePlaceholder":923},[1130],{"type":33,"value":926},{"type":27,"tag":209,"props":1132,"children":1134},{"class":211,"line":1133},14,[1135],{"type":27,"tag":209,"props":1136,"children":1137},{"style":227},[1138],{"type":33,"value":1139},"/* 2. DISCOVER — what peers are visible, and what caps do they advertise?\n",{"type":27,"tag":209,"props":1141,"children":1143},{"class":211,"line":1142},15,[1144],{"type":27,"tag":209,"props":1145,"children":1146},{"style":227},[1147],{"type":33,"value":1148}," *    JSON: [{\"node_id\":\"...\",\"did\":\"...\",\"caps\":[\"ai.stt.transcribe\"],\"trust\":0.9}, ...] */\n",{"type":27,"tag":209,"props":1150,"children":1152},{"class":211,"line":1151},16,[1153,1158,1164,1169,1174],{"type":27,"tag":209,"props":1154,"children":1155},{"style":215},[1156],{"type":33,"value":1157},"char",{"type":27,"tag":209,"props":1159,"children":1161},{"style":1160},"--shiki-default:#FFAB70;--shiki-dark:#FFAB70",[1162],{"type":33,"value":1163}," peers",{"type":27,"tag":209,"props":1165,"children":1166},{"style":964},[1167],{"type":33,"value":1168},"[",{"type":27,"tag":209,"props":1170,"children":1171},{"style":1013},[1172],{"type":33,"value":1173},"8192",{"type":27,"tag":209,"props":1175,"children":1176},{"style":964},[1177],{"type":33,"value":1178},"];\n",{"type":27,"tag":209,"props":1180,"children":1182},{"class":211,"line":1181},17,[1183,1187,1191,1196,1201,1206,1211,1216,1220],{"type":27,"tag":209,"props":1184,"children":1185},{"style":215},[1186],{"type":33,"value":1094},{"type":27,"tag":209,"props":1188,"children":1189},{"style":964},[1190],{"type":33,"value":301},{"type":27,"tag":209,"props":1192,"children":1193},{"style":975},[1194],{"type":33,"value":1195},"legion_ffi_node_get_peers_json",{"type":27,"tag":209,"props":1197,"children":1198},{"style":964},[1199],{"type":33,"value":1200},"(node, peers, ",{"type":27,"tag":209,"props":1202,"children":1203},{"style":215},[1204],{"type":33,"value":1205},"sizeof",{"type":27,"tag":209,"props":1207,"children":1208},{"style":964},[1209],{"type":33,"value":1210},"(peers)) ",{"type":27,"tag":209,"props":1212,"children":1213},{"style":215},[1214],{"type":33,"value":1215},">",{"type":27,"tag":209,"props":1217,"children":1218},{"style":1013},[1219],{"type":33,"value":1062},{"type":27,"tag":209,"props":1221,"children":1222},{"style":964},[1223],{"type":33,"value":1224},")\n",{"type":27,"tag":209,"props":1226,"children":1228},{"class":211,"line":1227},18,[1229,1234,1238,1243,1248,1253],{"type":27,"tag":209,"props":1230,"children":1231},{"style":975},[1232],{"type":33,"value":1233},"    printf",{"type":27,"tag":209,"props":1235,"children":1236},{"style":964},[1237],{"type":33,"value":983},{"type":27,"tag":209,"props":1239,"children":1240},{"style":221},[1241],{"type":33,"value":1242},"\"peers: ",{"type":27,"tag":209,"props":1244,"children":1245},{"style":1013},[1246],{"type":33,"value":1247},"%s\\n",{"type":27,"tag":209,"props":1249,"children":1250},{"style":221},[1251],{"type":33,"value":1252},"\"",{"type":27,"tag":209,"props":1254,"children":1255},{"style":964},[1256],{"type":33,"value":1257},", peers);\n",{"type":27,"tag":209,"props":1259,"children":1261},{"class":211,"line":1260},19,[1262],{"type":27,"tag":209,"props":1263,"children":1264},{"emptyLinePlaceholder":923},[1265],{"type":33,"value":926},{"type":27,"tag":209,"props":1267,"children":1269},{"class":211,"line":1268},20,[1270],{"type":27,"tag":209,"props":1271,"children":1272},{"style":227},[1273],{"type":33,"value":1274},"/* 3. (LEGACY FALLBACK — usually NOT needed.) A full cohort member catches up\n",{"type":27,"tag":209,"props":1276,"children":1278},{"class":211,"line":1277},21,[1279],{"type":27,"tag":209,"props":1280,"children":1281},{"style":227},[1282],{"type":33,"value":1283}," *    via consensus sync (cert-validated discovery) and resolves any_one caps on\n",{"type":27,"tag":209,"props":1285,"children":1287},{"class":211,"line":1286},22,[1288],{"type":27,"tag":209,"props":1289,"children":1290},{"style":227},[1291],{"type":33,"value":1292}," *    its own, so skip this. Only a device that can't converge on consensus needs\n",{"type":27,"tag":209,"props":1294,"children":1296},{"class":211,"line":1295},23,[1297],{"type":27,"tag":209,"props":1298,"children":1299},{"style":227},[1300],{"type":33,"value":1301}," *    to pin a module's delegation to a provider discovered in step 2. */\n",{"type":27,"tag":209,"props":1303,"children":1305},{"class":211,"line":1304},24,[1306],{"type":27,"tag":209,"props":1307,"children":1308},{"style":227},[1309],{"type":33,"value":1310},"/* legion_ffi_node_delegate_pin(node, \"stt\", \"balrog-ai-node\"); */\n",{"type":27,"tag":209,"props":1312,"children":1314},{"class":211,"line":1313},25,[1315],{"type":27,"tag":209,"props":1316,"children":1317},{"emptyLinePlaceholder":923},[1318],{"type":33,"value":926},{"type":27,"tag":209,"props":1320,"children":1322},{"class":211,"line":1321},26,[1323],{"type":27,"tag":209,"props":1324,"children":1325},{"style":227},[1326],{"type":33,"value":1327},"/* 4. CONSUME — call `transcribe` on ANY live provider of `ai.stt.transcribe`\n",{"type":27,"tag":209,"props":1329,"children":1331},{"class":211,"line":1330},27,[1332],{"type":27,"tag":209,"props":1333,"children":1334},{"style":227},[1335],{"type":33,"value":1336}," *    (fungible any_one delegation). The single binary param carries the audio. */\n",{"type":27,"tag":209,"props":1338,"children":1340},{"class":211,"line":1339},28,[1341,1346,1351,1355,1360,1365,1370],{"type":27,"tag":209,"props":1342,"children":1343},{"style":215},[1344],{"type":33,"value":1345},"uint8_t",{"type":27,"tag":209,"props":1347,"children":1348},{"style":1160},[1349],{"type":33,"value":1350},"  out",{"type":27,"tag":209,"props":1352,"children":1353},{"style":964},[1354],{"type":33,"value":1168},{"type":27,"tag":209,"props":1356,"children":1357},{"style":1013},[1358],{"type":33,"value":1359},"64",{"type":27,"tag":209,"props":1361,"children":1362},{"style":215},[1363],{"type":33,"value":1364}," *",{"type":27,"tag":209,"props":1366,"children":1367},{"style":1013},[1368],{"type":33,"value":1369}," 1024",{"type":27,"tag":209,"props":1371,"children":1372},{"style":964},[1373],{"type":33,"value":1178},{"type":27,"tag":209,"props":1375,"children":1377},{"class":211,"line":1376},29,[1378,1383,1388,1392,1396],{"type":27,"tag":209,"props":1379,"children":1380},{"style":215},[1381],{"type":33,"value":1382},"size_t",{"type":27,"tag":209,"props":1384,"children":1385},{"style":964},[1386],{"type":33,"value":1387},"   out_len ",{"type":27,"tag":209,"props":1389,"children":1390},{"style":215},[1391],{"type":33,"value":972},{"type":27,"tag":209,"props":1393,"children":1394},{"style":1013},[1395],{"type":33,"value":1062},{"type":27,"tag":209,"props":1397,"children":1398},{"style":964},[1399],{"type":33,"value":795},{"type":27,"tag":209,"props":1401,"children":1403},{"class":211,"line":1402},30,[1404,1409,1414,1418,1423],{"type":27,"tag":209,"props":1405,"children":1406},{"style":215},[1407],{"type":33,"value":1408},"int",{"type":27,"tag":209,"props":1410,"children":1411},{"style":964},[1412],{"type":33,"value":1413}," rc ",{"type":27,"tag":209,"props":1415,"children":1416},{"style":215},[1417],{"type":33,"value":972},{"type":27,"tag":209,"props":1419,"children":1420},{"style":975},[1421],{"type":33,"value":1422}," legion_ffi_call_cap",{"type":27,"tag":209,"props":1424,"children":1425},{"style":964},[1426],{"type":33,"value":1427},"(node,\n",{"type":27,"tag":209,"props":1429,"children":1431},{"class":211,"line":1430},31,[1432,1437,1442],{"type":27,"tag":209,"props":1433,"children":1434},{"style":227},[1435],{"type":33,"value":1436},"            /*cap=*/",{"type":27,"tag":209,"props":1438,"children":1439},{"style":221},[1440],{"type":33,"value":1441},"    \"ai.stt.transcribe\"",{"type":27,"tag":209,"props":1443,"children":1444},{"style":964},[1445],{"type":33,"value":741},{"type":27,"tag":209,"props":1447,"children":1449},{"class":211,"line":1448},32,[1450,1455,1460],{"type":27,"tag":209,"props":1451,"children":1452},{"style":227},[1453],{"type":33,"value":1454},"            /*module=*/",{"type":27,"tag":209,"props":1456,"children":1457},{"style":221},[1458],{"type":33,"value":1459}," \"stt\"",{"type":27,"tag":209,"props":1461,"children":1462},{"style":964},[1463],{"type":33,"value":741},{"type":27,"tag":209,"props":1465,"children":1467},{"class":211,"line":1466},33,[1468,1473,1478],{"type":27,"tag":209,"props":1469,"children":1470},{"style":227},[1471],{"type":33,"value":1472},"            /*method=*/",{"type":27,"tag":209,"props":1474,"children":1475},{"style":221},[1476],{"type":33,"value":1477}," \"transcribe\"",{"type":27,"tag":209,"props":1479,"children":1480},{"style":964},[1481],{"type":33,"value":741},{"type":27,"tag":209,"props":1483,"children":1485},{"class":211,"line":1484},34,[1486,1491,1496],{"type":27,"tag":209,"props":1487,"children":1488},{"style":227},[1489],{"type":33,"value":1490},"            /*param_key=*/",{"type":27,"tag":209,"props":1492,"children":1493},{"style":221},[1494],{"type":33,"value":1495},"  \"audio\"",{"type":27,"tag":209,"props":1497,"children":1498},{"style":964},[1499],{"type":33,"value":741},{"type":27,"tag":209,"props":1501,"children":1503},{"class":211,"line":1502},35,[1504,1509],{"type":27,"tag":209,"props":1505,"children":1506},{"style":227},[1507],{"type":33,"value":1508},"            /*param_data=*/",{"type":27,"tag":209,"props":1510,"children":1511},{"style":964},[1512],{"type":33,"value":1513}," pcm_bytes, pcm_len,\n",{"type":27,"tag":209,"props":1515,"children":1517},{"class":211,"line":1516},36,[1518,1523,1528],{"type":27,"tag":209,"props":1519,"children":1520},{"style":227},[1521],{"type":33,"value":1522},"            /*timeout_ms=*/",{"type":27,"tag":209,"props":1524,"children":1525},{"style":1013},[1526],{"type":33,"value":1527}," 15000",{"type":27,"tag":209,"props":1529,"children":1530},{"style":964},[1531],{"type":33,"value":741},{"type":27,"tag":209,"props":1533,"children":1535},{"class":211,"line":1534},37,[1536,1541,1545,1550,1555,1560],{"type":27,"tag":209,"props":1537,"children":1538},{"style":964},[1539],{"type":33,"value":1540},"            out, ",{"type":27,"tag":209,"props":1542,"children":1543},{"style":215},[1544],{"type":33,"value":1205},{"type":27,"tag":209,"props":1546,"children":1547},{"style":964},[1548],{"type":33,"value":1549},"(out), ",{"type":27,"tag":209,"props":1551,"children":1552},{"style":215},[1553],{"type":33,"value":1554},"&",{"type":27,"tag":209,"props":1556,"children":1557},{"style":1160},[1558],{"type":33,"value":1559},"out_len",{"type":27,"tag":209,"props":1561,"children":1562},{"style":964},[1563],{"type":33,"value":1085},{"type":27,"tag":209,"props":1565,"children":1567},{"class":211,"line":1566},38,[1568],{"type":27,"tag":209,"props":1569,"children":1570},{"emptyLinePlaceholder":923},[1571],{"type":33,"value":926},{"type":27,"tag":209,"props":1573,"children":1575},{"class":211,"line":1574},39,[1576,1580,1585,1590],{"type":27,"tag":209,"props":1577,"children":1578},{"style":215},[1579],{"type":33,"value":1094},{"type":27,"tag":209,"props":1581,"children":1582},{"style":964},[1583],{"type":33,"value":1584}," (rc ",{"type":27,"tag":209,"props":1586,"children":1587},{"style":215},[1588],{"type":33,"value":1589},"==",{"type":27,"tag":209,"props":1591,"children":1592},{"style":964},[1593],{"type":33,"value":1594}," LEGION_OK) {\n",{"type":27,"tag":209,"props":1596,"children":1598},{"class":211,"line":1597},40,[1599,1604,1609,1614,1619],{"type":27,"tag":209,"props":1600,"children":1601},{"style":975},[1602],{"type":33,"value":1603},"    fwrite",{"type":27,"tag":209,"props":1605,"children":1606},{"style":964},[1607],{"type":33,"value":1608},"(out, ",{"type":27,"tag":209,"props":1610,"children":1611},{"style":1013},[1612],{"type":33,"value":1613},"1",{"type":27,"tag":209,"props":1615,"children":1616},{"style":964},[1617],{"type":33,"value":1618},", out_len, stdout);",{"type":27,"tag":209,"props":1620,"children":1621},{"style":227},[1622],{"type":33,"value":1623},"                 /* the transcript */\n",{"type":27,"tag":209,"props":1625,"children":1627},{"class":211,"line":1626},41,[1628,1633,1638,1643,1647,1651,1656,1661,1666,1670,1675],{"type":27,"tag":209,"props":1629,"children":1630},{"style":964},[1631],{"type":33,"value":1632},"} ",{"type":27,"tag":209,"props":1634,"children":1635},{"style":215},[1636],{"type":33,"value":1637},"else",{"type":27,"tag":209,"props":1639,"children":1640},{"style":215},[1641],{"type":33,"value":1642}," if",{"type":27,"tag":209,"props":1644,"children":1645},{"style":964},[1646],{"type":33,"value":1584},{"type":27,"tag":209,"props":1648,"children":1649},{"style":215},[1650],{"type":33,"value":1589},{"type":27,"tag":209,"props":1652,"children":1653},{"style":964},[1654],{"type":33,"value":1655}," LEGION_ERR_NOMEM ",{"type":27,"tag":209,"props":1657,"children":1658},{"style":215},[1659],{"type":33,"value":1660},"&&",{"type":27,"tag":209,"props":1662,"children":1663},{"style":964},[1664],{"type":33,"value":1665}," out_len ",{"type":27,"tag":209,"props":1667,"children":1668},{"style":215},[1669],{"type":33,"value":1215},{"type":27,"tag":209,"props":1671,"children":1672},{"style":215},[1673],{"type":33,"value":1674}," sizeof",{"type":27,"tag":209,"props":1676,"children":1677},{"style":964},[1678],{"type":33,"value":1679},"(out)) {\n",{"type":27,"tag":209,"props":1681,"children":1683},{"class":211,"line":1682},42,[1684],{"type":27,"tag":209,"props":1685,"children":1686},{"style":227},[1687],{"type":33,"value":1688},"    /* out_len is the FULL result size — grow the buffer and retry. */\n",{"type":27,"tag":209,"props":1690,"children":1692},{"class":211,"line":1691},43,[1693,1697,1701,1705,1709,1713],{"type":27,"tag":209,"props":1694,"children":1695},{"style":964},[1696],{"type":33,"value":1632},{"type":27,"tag":209,"props":1698,"children":1699},{"style":215},[1700],{"type":33,"value":1637},{"type":27,"tag":209,"props":1702,"children":1703},{"style":215},[1704],{"type":33,"value":1642},{"type":27,"tag":209,"props":1706,"children":1707},{"style":964},[1708],{"type":33,"value":1584},{"type":27,"tag":209,"props":1710,"children":1711},{"style":215},[1712],{"type":33,"value":1589},{"type":27,"tag":209,"props":1714,"children":1715},{"style":964},[1716],{"type":33,"value":1717}," LEGION_ERR_NO_DELEGATE) {\n",{"type":27,"tag":209,"props":1719,"children":1721},{"class":211,"line":1720},44,[1722],{"type":27,"tag":209,"props":1723,"children":1724},{"style":227},[1725],{"type":33,"value":1726},"    /* No live provider of the cap (loud, never silently swallowed). */\n",{"type":27,"tag":209,"props":1728,"children":1730},{"class":211,"line":1729},45,[1731],{"type":27,"tag":209,"props":1732,"children":1733},{"style":964},[1734],{"type":33,"value":1735},"}\n",{"type":27,"tag":209,"props":1737,"children":1739},{"class":211,"line":1738},46,[1740],{"type":27,"tag":209,"props":1741,"children":1742},{"emptyLinePlaceholder":923},[1743],{"type":33,"value":926},{"type":27,"tag":209,"props":1745,"children":1747},{"class":211,"line":1746},47,[1748],{"type":27,"tag":209,"props":1749,"children":1750},{"style":227},[1751],{"type":33,"value":1752},"/* 5. Done. */\n",{"type":27,"tag":209,"props":1754,"children":1756},{"class":211,"line":1755},48,[1757,1762],{"type":27,"tag":209,"props":1758,"children":1759},{"style":975},[1760],{"type":33,"value":1761},"legion_ffi_node_stop",{"type":27,"tag":209,"props":1763,"children":1764},{"style":964},[1765],{"type":33,"value":1766},"(node);\n",{"type":27,"tag":40,"props":1768,"children":1769},{},[1770],{"type":33,"value":1771},"Notes:",{"type":27,"tag":1773,"props":1774,"children":1775},"ul",{},[1776,1842],{"type":27,"tag":1777,"props":1778,"children":1779},"li",{},[1780,1786,1788,1793,1795,1801,1803,1809,1811,1816,1818,1824,1826,1832,1834,1840],{"type":27,"tag":63,"props":1781,"children":1783},{"className":1782},[],[1784],{"type":33,"value":1785},"legion_ffi_call_cap",{"type":33,"value":1787}," targets ",{"type":27,"tag":44,"props":1789,"children":1790},{},[1791],{"type":33,"value":1792},"any",{"type":33,"value":1794}," provider of the cap (",{"type":27,"tag":63,"props":1796,"children":1798},{"className":1797},[],[1799],{"type":33,"value":1800},"any_one",{"type":33,"value":1802},"\nsemantic); ",{"type":27,"tag":63,"props":1804,"children":1806},{"className":1805},[],[1807],{"type":33,"value":1808},"*out_len",{"type":33,"value":1810}," is always set to the ",{"type":27,"tag":83,"props":1812,"children":1813},{},[1814],{"type":33,"value":1815},"full",{"type":33,"value":1817}," result size, so\n",{"type":27,"tag":63,"props":1819,"children":1821},{"className":1820},[],[1822],{"type":33,"value":1823},"LEGION_ERR_NOMEM",{"type":33,"value":1825}," with ",{"type":27,"tag":63,"props":1827,"children":1829},{"className":1828},[],[1830],{"type":33,"value":1831},"*out_len > out_cap",{"type":33,"value":1833}," means \"grow and retry,\" and\n",{"type":27,"tag":63,"props":1835,"children":1837},{"className":1836},[],[1838],{"type":33,"value":1839},"LEGION_ERR_NO_DELEGATE",{"type":33,"value":1841}," means no provider is live.",{"type":27,"tag":1777,"props":1843,"children":1844},{},[1845,1851,1853,1858,1860,1865],{"type":27,"tag":63,"props":1846,"children":1848},{"className":1847},[],[1849],{"type":33,"value":1850},"legion_ffi_node_delegate_pin",{"type":33,"value":1852}," is a ",{"type":27,"tag":44,"props":1854,"children":1855},{},[1856],{"type":33,"value":1857},"legacy fallback",{"type":33,"value":1859},", not the current\nclass-B path: a class-B device now catches up via consensus sync (cert-validated\ndiscovery), so a full member resolves ",{"type":27,"tag":63,"props":1861,"children":1863},{"className":1862},[],[1864],{"type":33,"value":1800},{"type":33,"value":1866}," caps without pinning. It still\nexists for a device that can't converge on consensus — pin the call to a peer\ndiscovered via the beacon — but a full cohort member should skip it.",{"type":27,"tag":102,"props":1868,"children":1870},{"id":1869},"reference",[1871],{"type":33,"value":1872},"Reference",{"type":27,"tag":1874,"props":1875,"children":1877},"h3",{"id":1876},"node-consume-legion_ffi_nodeh-24-fns",[1878,1880,1885],{"type":33,"value":1879},"Node + consume (",{"type":27,"tag":63,"props":1881,"children":1883},{"className":1882},[],[1884],{"type":33,"value":770},{"type":33,"value":1886},", 24 fns)",{"type":27,"tag":277,"props":1888,"children":1889},{},[1890,1906],{"type":27,"tag":281,"props":1891,"children":1892},{},[1893],{"type":27,"tag":285,"props":1894,"children":1895},{},[1896,1901],{"type":27,"tag":289,"props":1897,"children":1898},{},[1899],{"type":33,"value":1900},"Group",{"type":27,"tag":289,"props":1902,"children":1903},{},[1904],{"type":33,"value":1905},"Functions",{"type":27,"tag":325,"props":1907,"children":1908},{},[1909,1940,1964,1983,2032,2065,2103,2128,2147,2182,2201],{"type":27,"tag":285,"props":1910,"children":1911},{},[1912,1917],{"type":27,"tag":332,"props":1913,"children":1914},{},[1915],{"type":33,"value":1916},"Lifecycle",{"type":27,"tag":332,"props":1918,"children":1919},{},[1920,1926,1927,1933,1934],{"type":27,"tag":63,"props":1921,"children":1923},{"className":1922},[],[1924],{"type":33,"value":1925},"legion_ffi_node_start",{"type":33,"value":712},{"type":27,"tag":63,"props":1928,"children":1930},{"className":1929},[],[1931],{"type":33,"value":1932},"_stop",{"type":33,"value":712},{"type":27,"tag":63,"props":1935,"children":1937},{"className":1936},[],[1938],{"type":33,"value":1939},"_is_running",{"type":27,"tag":285,"props":1941,"children":1942},{},[1943,1948],{"type":27,"tag":332,"props":1944,"children":1945},{},[1946],{"type":33,"value":1947},"Discovery",{"type":27,"tag":332,"props":1949,"children":1950},{},[1951,1957,1958],{"type":27,"tag":63,"props":1952,"children":1954},{"className":1953},[],[1955],{"type":33,"value":1956},"legion_ffi_node_peer_count",{"type":33,"value":712},{"type":27,"tag":63,"props":1959,"children":1961},{"className":1960},[],[1962],{"type":33,"value":1963},"_get_peers_json",{"type":27,"tag":285,"props":1965,"children":1966},{},[1967,1972],{"type":27,"tag":332,"props":1968,"children":1969},{},[1970],{"type":33,"value":1971},"Caps introspection",{"type":27,"tag":332,"props":1973,"children":1974},{},[1975,1981],{"type":27,"tag":63,"props":1976,"children":1978},{"className":1977},[],[1979],{"type":33,"value":1980},"legion_ffi_node_provided_caps",{"type":33,"value":1982}," (enumerate the caps THIS build would provide, without starting a node — so a joining device can declare its own caps)",{"type":27,"tag":285,"props":1984,"children":1985},{},[1986,1993],{"type":27,"tag":332,"props":1987,"children":1988},{},[1989],{"type":27,"tag":44,"props":1990,"children":1991},{},[1992],{"type":33,"value":392},{"type":27,"tag":332,"props":1994,"children":1995},{},[1996,2001,2003,2009,2010,2016,2018,2023,2025,2030],{"type":27,"tag":63,"props":1997,"children":1999},{"className":1998},[],[2000],{"type":33,"value":1785},{"type":33,"value":2002}," (any provider), ",{"type":27,"tag":63,"props":2004,"children":2006},{"className":2005},[],[2007],{"type":33,"value":2008},"legion_ffi_node_delegate",{"type":33,"value":511},{"type":27,"tag":63,"props":2011,"children":2013},{"className":2012},[],[2014],{"type":33,"value":2015},"_delegate_async",{"type":33,"value":2017}," (a ",{"type":27,"tag":83,"props":2019,"children":2020},{},[2021],{"type":33,"value":2022},"specific",{"type":33,"value":2024}," peer), ",{"type":27,"tag":63,"props":2026,"children":2028},{"className":2027},[],[2029],{"type":33,"value":1850},{"type":33,"value":2031}," (legacy fallback — pin to a discovered peer; superseded by consensus-sync catch-up)",{"type":27,"tag":285,"props":2033,"children":2034},{},[2035,2040],{"type":27,"tag":332,"props":2036,"children":2037},{},[2038],{"type":33,"value":2039},"Liveness",{"type":27,"tag":332,"props":2041,"children":2042},{},[2043,2049,2050,2056,2057,2063],{"type":27,"tag":63,"props":2044,"children":2046},{"className":2045},[],[2047],{"type":33,"value":2048},"legion_ffi_node_ping_peer_start",{"type":33,"value":511},{"type":27,"tag":63,"props":2051,"children":2053},{"className":2052},[],[2054],{"type":33,"value":2055},"_poll",{"type":33,"value":511},{"type":27,"tag":63,"props":2058,"children":2060},{"className":2059},[],[2061],{"type":33,"value":2062},"_cancel",{"type":33,"value":2064}," (non-blocking)",{"type":27,"tag":285,"props":2066,"children":2067},{},[2068,2073],{"type":27,"tag":332,"props":2069,"children":2070},{},[2071],{"type":33,"value":2072},"Byte streams",{"type":27,"tag":332,"props":2074,"children":2075},{},[2076,2082,2083,2089,2090,2096,2097],{"type":27,"tag":63,"props":2077,"children":2079},{"className":2078},[],[2080],{"type":33,"value":2081},"legion_ffi_node_stream_open",{"type":33,"value":511},{"type":27,"tag":63,"props":2084,"children":2086},{"className":2085},[],[2087],{"type":33,"value":2088},"_status",{"type":33,"value":511},{"type":27,"tag":63,"props":2091,"children":2093},{"className":2092},[],[2094],{"type":33,"value":2095},"_write",{"type":33,"value":511},{"type":27,"tag":63,"props":2098,"children":2100},{"className":2099},[],[2101],{"type":33,"value":2102},"_close",{"type":27,"tag":285,"props":2104,"children":2105},{},[2106,2111],{"type":27,"tag":332,"props":2107,"children":2108},{},[2109],{"type":33,"value":2110},"Events",{"type":27,"tag":332,"props":2112,"children":2113},{},[2114,2120,2122,2127],{"type":27,"tag":63,"props":2115,"children":2117},{"className":2116},[],[2118],{"type":33,"value":2119},"legion_ffi_node_poll_events",{"type":33,"value":2121}," (drain focus/content events — ",{"type":27,"tag":44,"props":2123,"children":2124},{},[2125],{"type":33,"value":2126},"poll, not callback",{"type":33,"value":308},{"type":27,"tag":285,"props":2129,"children":2130},{},[2131,2136],{"type":27,"tag":332,"props":2132,"children":2133},{},[2134],{"type":33,"value":2135},"OS process",{"type":27,"tag":332,"props":2137,"children":2138},{},[2139,2145],{"type":27,"tag":63,"props":2140,"children":2142},{"className":2141},[],[2143],{"type":33,"value":2144},"legion_ffi_osp_activate",{"type":33,"value":2146}," (ask a peer to launch a signed app)",{"type":27,"tag":285,"props":2148,"children":2149},{},[2150,2155],{"type":27,"tag":332,"props":2151,"children":2152},{},[2153],{"type":33,"value":2154},"Transport",{"type":27,"tag":332,"props":2156,"children":2157},{},[2158,2164,2166,2172,2174,2180],{"type":27,"tag":63,"props":2159,"children":2161},{"className":2160},[],[2162],{"type":33,"value":2163},"legion_ffi_node_attach_mobile_bridge",{"type":33,"value":2165}," (class-B WAN tunnel), ",{"type":27,"tag":63,"props":2167,"children":2169},{"className":2168},[],[2170],{"type":33,"value":2171},"legion_ffi_node_network_changed",{"type":33,"value":2173}," (signal an OS network change to drive reconnect — Spec 34), ",{"type":27,"tag":63,"props":2175,"children":2177},{"className":2176},[],[2178],{"type":33,"value":2179},"legion_ffi_node_transport_status",{"type":33,"value":2181}," (poll mesh link-state — Spec 34)",{"type":27,"tag":285,"props":2183,"children":2184},{},[2185,2190],{"type":27,"tag":332,"props":2186,"children":2187},{},[2188],{"type":33,"value":2189},"Routing",{"type":27,"tag":332,"props":2191,"children":2192},{},[2193,2199],{"type":27,"tag":63,"props":2194,"children":2196},{"className":2195},[],[2197],{"type":33,"value":2198},"legion_ffi_node_route_query",{"type":33,"value":2200}," (resolve a multi-hop route to a target node before delegating — Spec 33.04)",{"type":27,"tag":285,"props":2202,"children":2203},{},[2204,2209],{"type":27,"tag":332,"props":2205,"children":2206},{},[2207],{"type":33,"value":2208},"Storage",{"type":27,"tag":332,"props":2210,"children":2211},{},[2212,2218],{"type":27,"tag":63,"props":2213,"children":2215},{"className":2214},[],[2216],{"type":33,"value":2217},"legion_ffi_node_enable_persistent_store",{"type":33,"value":2219}," (turn the objectstore file-backed)",{"type":27,"tag":1874,"props":2221,"children":2223},{"id":2222},"ffi-subsystem-families",[2224],{"type":33,"value":2225},"FFI subsystem families",{"type":27,"tag":40,"props":2227,"children":2228},{},[2229],{"type":33,"value":2230},"Each FFI header bridges one subsystem to apps/bindings (opaque handles, explicit\nmemory ownership). Consume what your app needs:",{"type":27,"tag":277,"props":2232,"children":2233},{},[2234,2255],{"type":27,"tag":281,"props":2235,"children":2236},{},[2237],{"type":27,"tag":285,"props":2238,"children":2239},{},[2240,2245,2250],{"type":27,"tag":289,"props":2241,"children":2242},{},[2243],{"type":33,"value":2244},"Header",{"type":27,"tag":289,"props":2246,"children":2247},{},[2248],{"type":33,"value":2249},"Fns",{"type":27,"tag":289,"props":2251,"children":2252},{},[2253],{"type":33,"value":2254},"What it's for",{"type":27,"tag":325,"props":2256,"children":2257},{},[2258,2294,2332,2361,2441,2469,2498,2527],{"type":27,"tag":285,"props":2259,"children":2260},{},[2261,2270,2275],{"type":27,"tag":332,"props":2262,"children":2263},{},[2264],{"type":27,"tag":63,"props":2265,"children":2267},{"className":2266},[],[2268],{"type":33,"value":2269},"legion_ffi_audio.h",{"type":27,"tag":332,"props":2271,"children":2272},{},[2273],{"type":33,"value":2274},"12",{"type":27,"tag":332,"props":2276,"children":2277},{},[2278,2280,2286,2287,2293],{"type":33,"value":2279},"Mic capture + playback: ",{"type":27,"tag":63,"props":2281,"children":2283},{"className":2282},[],[2284],{"type":33,"value":2285},"audio_in_start/_stop/_get_utterance/_poll_events",{"type":33,"value":712},{"type":27,"tag":63,"props":2288,"children":2290},{"className":2289},[],[2291],{"type":33,"value":2292},"audio_out_play/_poll_events",{"type":33,"value":100},{"type":27,"tag":285,"props":2295,"children":2296},{},[2297,2306,2311],{"type":27,"tag":332,"props":2298,"children":2299},{},[2300],{"type":27,"tag":63,"props":2301,"children":2303},{"className":2302},[],[2304],{"type":33,"value":2305},"legion_ffi_focus.h",{"type":27,"tag":332,"props":2307,"children":2308},{},[2309],{"type":33,"value":2310},"4",{"type":27,"tag":332,"props":2312,"children":2313},{},[2314,2316,2322,2324,2330],{"type":33,"value":2315},"Follow-focus targeting: ",{"type":27,"tag":63,"props":2317,"children":2319},{"className":2318},[],[2320],{"type":33,"value":2321},"focus_get/_set/_set_for/_clear",{"type":33,"value":2323}," (which node a ",{"type":27,"tag":63,"props":2325,"children":2327},{"className":2326},[],[2328],{"type":33,"value":2329},"follow_focus",{"type":33,"value":2331}," cap routes to).",{"type":27,"tag":285,"props":2333,"children":2334},{},[2335,2344,2349],{"type":27,"tag":332,"props":2336,"children":2337},{},[2338],{"type":27,"tag":63,"props":2339,"children":2341},{"className":2340},[],[2342],{"type":33,"value":2343},"legion_ffi_display.h",{"type":27,"tag":332,"props":2345,"children":2346},{},[2347],{"type":33,"value":2348},"11",{"type":27,"tag":332,"props":2350,"children":2351},{},[2352,2354,2360],{"type":33,"value":2353},"GUI surface: ",{"type":27,"tag":63,"props":2355,"children":2357},{"className":2356},[],[2358],{"type":33,"value":2359},"display_create/_destroy/_get_html/_open_shell/_pop_event/_pop_handoff",{"type":33,"value":100},{"type":27,"tag":285,"props":2362,"children":2363},{},[2364,2373,2378],{"type":27,"tag":332,"props":2365,"children":2366},{},[2367],{"type":27,"tag":63,"props":2368,"children":2370},{"className":2369},[],[2371],{"type":33,"value":2372},"legion_ffi_identity.h",{"type":27,"tag":332,"props":2374,"children":2375},{},[2376],{"type":33,"value":2377},"17",{"type":27,"tag":332,"props":2379,"children":2380},{},[2381,2383,2389,2390,2396,2397,2403,2404,2410,2411,2417,2418,2424,2426,2432,2433,2439],{"type":33,"value":2382},"Keys + certs: ",{"type":27,"tag":63,"props":2384,"children":2386},{"className":2385},[],[2387],{"type":33,"value":2388},"generate_seed",{"type":33,"value":712},{"type":27,"tag":63,"props":2391,"children":2393},{"className":2392},[],[2394],{"type":33,"value":2395},"derive_did",{"type":33,"value":712},{"type":27,"tag":63,"props":2398,"children":2400},{"className":2399},[],[2401],{"type":33,"value":2402},"derive_master_pk",{"type":33,"value":712},{"type":27,"tag":63,"props":2405,"children":2407},{"className":2406},[],[2408],{"type":33,"value":2409},"did_to_pk_hex",{"type":33,"value":712},{"type":27,"tag":63,"props":2412,"children":2414},{"className":2413},[],[2415],{"type":33,"value":2416},"issue_auth_cert",{"type":33,"value":712},{"type":27,"tag":63,"props":2419,"children":2421},{"className":2420},[],[2422],{"type":33,"value":2423},"issue_service_cert",{"type":33,"value":2425},"; plus device enrolment — ",{"type":27,"tag":63,"props":2427,"children":2429},{"className":2428},[],[2430],{"type":33,"value":2431},"enroll_request_build",{"type":33,"value":511},{"type":27,"tag":63,"props":2434,"children":2436},{"className":2435},[],[2437],{"type":33,"value":2438},"_open",{"type":33,"value":2440}," (a joining device self-signs an enrolment request with proof-of-possession; the master verifies it before issuing a cert — channel-agnostic, QR or file).",{"type":27,"tag":285,"props":2442,"children":2443},{},[2444,2453,2457],{"type":27,"tag":332,"props":2445,"children":2446},{},[2447],{"type":27,"tag":63,"props":2448,"children":2450},{"className":2449},[],[2451],{"type":33,"value":2452},"legion_ffi_js.h",{"type":27,"tag":332,"props":2454,"children":2455},{},[2456],{"type":33,"value":2348},{"type":27,"tag":332,"props":2458,"children":2459},{},[2460,2462,2468],{"type":33,"value":2461},"JS app runtime: ",{"type":27,"tag":63,"props":2463,"children":2465},{"className":2464},[],[2466],{"type":33,"value":2467},"js_create/_destroy/_eval/_eval_string/_deliver_event",{"type":33,"value":100},{"type":27,"tag":285,"props":2470,"children":2471},{},[2472,2481,2486],{"type":27,"tag":332,"props":2473,"children":2474},{},[2475],{"type":27,"tag":63,"props":2476,"children":2478},{"className":2477},[],[2479],{"type":33,"value":2480},"legion_ffi_objectstore.h",{"type":27,"tag":332,"props":2482,"children":2483},{},[2484],{"type":33,"value":2485},"13",{"type":27,"tag":332,"props":2487,"children":2488},{},[2489,2491,2497],{"type":33,"value":2490},"Content store: ",{"type":27,"tag":63,"props":2492,"children":2494},{"className":2493},[],[2495],{"type":33,"value":2496},"objectstore_create/_get/_get_bytes/_fetch_bytes/_list/_delete/_gc_cid",{"type":33,"value":100},{"type":27,"tag":285,"props":2499,"children":2500},{},[2501,2510,2515],{"type":27,"tag":332,"props":2502,"children":2503},{},[2504],{"type":27,"tag":63,"props":2505,"children":2507},{"className":2506},[],[2508],{"type":33,"value":2509},"legion_ffi_bridge.h",{"type":27,"tag":332,"props":2511,"children":2512},{},[2513],{"type":33,"value":2514},"8",{"type":27,"tag":332,"props":2516,"children":2517},{},[2518,2520,2526],{"type":33,"value":2519},"Class-B WAN transport: ",{"type":27,"tag":63,"props":2521,"children":2523},{"className":2522},[],[2524],{"type":33,"value":2525},"mobile_bridge_connect/_connect_with_seed/_send/_recv/_add_route/_close/_is_connected",{"type":33,"value":100},{"type":27,"tag":285,"props":2528,"children":2529},{},[2530,2539,2543],{"type":27,"tag":332,"props":2531,"children":2532},{},[2533],{"type":27,"tag":63,"props":2534,"children":2536},{"className":2535},[],[2537],{"type":33,"value":2538},"legion_ffi_connection.h",{"type":27,"tag":332,"props":2540,"children":2541},{},[2542],{"type":33,"value":1613},{"type":27,"tag":332,"props":2544,"children":2545},{},[2546,2548,2554],{"type":33,"value":2547},"Connection hints: ",{"type":27,"tag":63,"props":2549,"children":2551},{"className":2550},[],[2552],{"type":33,"value":2553},"connection_manager_resume_hint",{"type":33,"value":100},{"type":27,"tag":1874,"props":2556,"children":2558},{"id":2557},"ffi-helpers-legion_ffih",[2559,2561,2567],{"type":33,"value":2560},"FFI helpers (",{"type":27,"tag":63,"props":2562,"children":2564},{"className":2563},[],[2565],{"type":33,"value":2566},"legion_ffi.h",{"type":33,"value":308},{"type":27,"tag":40,"props":2569,"children":2570},{},[2571,2577,2579,2585,2587,2593,2595,2601],{"type":27,"tag":63,"props":2572,"children":2574},{"className":2573},[],[2575],{"type":33,"value":2576},"legion_result_t",{"type":33,"value":2578}," + ",{"type":27,"tag":63,"props":2580,"children":2582},{"className":2581},[],[2583],{"type":33,"value":2584},"legion_result_free",{"type":33,"value":2586},"; the params builder\n",{"type":27,"tag":63,"props":2588,"children":2590},{"className":2589},[],[2591],{"type":33,"value":2592},"legion_params_create/_destroy/_set_string/_set_int/_set_bytes",{"type":33,"value":2594}," (for languages\nwithout native maps); ",{"type":27,"tag":63,"props":2596,"children":2598},{"className":2597},[],[2599],{"type":33,"value":2600},"legion_string_len",{"type":33,"value":100},{"type":27,"tag":102,"props":2603,"children":2605},{"id":2604},"key-rules-gotchas",[2606],{"type":33,"value":2607},"Key rules & gotchas",{"type":27,"tag":1773,"props":2609,"children":2610},{},[2611,2629,2691,2714,2766,2790],{"type":27,"tag":1777,"props":2612,"children":2613},{},[2614,2619,2621,2627],{"type":27,"tag":44,"props":2615,"children":2616},{},[2617],{"type":33,"value":2618},"Apps consume, never advertise.",{"type":33,"value":2620}," Advertising is purely a provider (L3)\nconcern — a certified module declaring ",{"type":27,"tag":63,"props":2622,"children":2624},{"className":2623},[],[2625],{"type":33,"value":2626},"provided_caps",{"type":33,"value":2628},". The L4 surface has no\nadvertise call.",{"type":27,"tag":1777,"props":2630,"children":2631},{},[2632,2637,2638,2643,2644,2648,2650,2655,2657,2662,2664,2669,2671,2676,2678,2682,2684,2689],{"type":27,"tag":44,"props":2633,"children":2634},{},[2635],{"type":33,"value":2636},"Three ways to invoke:",{"type":33,"value":657},{"type":27,"tag":63,"props":2639,"children":2641},{"className":2640},[],[2642],{"type":33,"value":1785},{"type":33,"value":405},{"type":27,"tag":83,"props":2645,"children":2646},{},[2647],{"type":33,"value":1792},{"type":33,"value":2649}," live provider\n(",{"type":27,"tag":63,"props":2651,"children":2653},{"className":2652},[],[2654],{"type":33,"value":1800},{"type":33,"value":2656},"); ",{"type":27,"tag":63,"props":2658,"children":2660},{"className":2659},[],[2661],{"type":33,"value":2008},{"type":33,"value":2663}," → a ",{"type":27,"tag":83,"props":2665,"children":2666},{},[2667],{"type":33,"value":2668},"named",{"type":33,"value":2670}," peer; ",{"type":27,"tag":63,"props":2672,"children":2674},{"className":2673},[],[2675],{"type":33,"value":1850},{"type":33,"value":2677},"\n→ pin a module to a discovered peer (",{"type":27,"tag":44,"props":2679,"children":2680},{},[2681],{"type":33,"value":1857},{"type":33,"value":2683}," — superseded by\nconsensus-sync catch-up; a full member needn't pin). ",{"type":27,"tag":63,"props":2685,"children":2687},{"className":2686},[],[2688],{"type":33,"value":1839},{"type":33,"value":2690},"\nis the loud \"no provider\" signal.",{"type":27,"tag":1777,"props":2692,"children":2693},{},[2694,2699,2700,2705,2706,2712],{"type":27,"tag":44,"props":2695,"children":2696},{},[2697],{"type":33,"value":2698},"Events are polled, not pushed.",{"type":33,"value":657},{"type":27,"tag":63,"props":2701,"children":2703},{"className":2702},[],[2704],{"type":33,"value":2119},{"type":33,"value":741},{"type":27,"tag":63,"props":2707,"children":2709},{"className":2708},[],[2710],{"type":33,"value":2711},"legion_ffi_audio_*_poll_events",{"type":33,"value":2713},", etc. return pending events on your cadence —\nthere is no C callback fired into your runtime (a deliberate choice; a blocking\ncallback once stalled a cellular isolate).",{"type":27,"tag":1777,"props":2715,"children":2716},{},[2717,2722,2723,2728,2730,2734,2736,2741,2743,2749,2751,2757,2759,2765],{"type":27,"tag":44,"props":2718,"children":2719},{},[2720],{"type":33,"value":2721},"Result buffers:",{"type":33,"value":657},{"type":27,"tag":63,"props":2724,"children":2726},{"className":2725},[],[2727],{"type":33,"value":1808},{"type":33,"value":2729}," is the ",{"type":27,"tag":83,"props":2731,"children":2732},{},[2733],{"type":33,"value":1815},{"type":33,"value":2735}," size; ",{"type":27,"tag":63,"props":2737,"children":2739},{"className":2738},[],[2740],{"type":33,"value":1823},{"type":33,"value":2742}," means\ngrow and retry. Free library-allocated buffers with ",{"type":27,"tag":63,"props":2744,"children":2746},{"className":2745},[],[2747],{"type":33,"value":2748},"legion_free",{"type":33,"value":2750}," /\n",{"type":27,"tag":63,"props":2752,"children":2754},{"className":2753},[],[2755],{"type":33,"value":2756},"legion_pal->free",{"type":33,"value":2758},", never libc ",{"type":27,"tag":63,"props":2760,"children":2762},{"className":2761},[],[2763],{"type":33,"value":2764},"free",{"type":33,"value":100},{"type":27,"tag":1777,"props":2767,"children":2768},{},[2769,2774,2776,2781,2783,2788],{"type":27,"tag":44,"props":2770,"children":2771},{},[2772],{"type":33,"value":2773},"Don't mix flavors:",{"type":33,"value":2775}," a ",{"type":27,"tag":63,"props":2777,"children":2779},{"className":2778},[],[2780],{"type":33,"value":347},{"type":33,"value":2782}," (native) and an ",{"type":27,"tag":63,"props":2784,"children":2786},{"className":2785},[],[2787],{"type":33,"value":358},{"type":33,"value":2789}," (FFI)\nhandle are not interchangeable.",{"type":27,"tag":1777,"props":2791,"children":2792},{},[2793,2798,2799,2804],{"type":27,"tag":44,"props":2794,"children":2795},{},[2796],{"type":33,"value":2797},"Native apps invoke caps via the plugin manager",{"type":33,"value":301},{"type":27,"tag":63,"props":2800,"children":2802},{"className":2801},[],[2803],{"type":33,"value":403},{"type":27,"tag":1773,"props":2805,"children":2806},{},[2807],{"type":27,"tag":1777,"props":2808,"children":2809},{},[2810,2812,2820],{"type":33,"value":2811},"L3 dispatch) — see ",{"type":27,"tag":59,"props":2813,"children":2814},{"href":13},[2815],{"type":27,"tag":63,"props":2816,"children":2818},{"className":2817},[],[2819],{"type":33,"value":98},{"type":33,"value":100},{"type":27,"tag":102,"props":2822,"children":2824},{"id":2823},"status",[2825],{"type":33,"value":2826},"Status",{"type":27,"tag":40,"props":2828,"children":2829},{},[2830,2832,2840,2841,2849,2850,2858],{"type":33,"value":2831},"DRAFT — surfaced for review; expect changes. With this, the API-doc series is\n",{"type":27,"tag":59,"props":2833,"children":2834},{"href":9},[2835],{"type":27,"tag":63,"props":2836,"children":2838},{"className":2837},[],[2839],{"type":33,"value":68},{"type":33,"value":405},{"type":27,"tag":59,"props":2842,"children":2843},{"href":5},[2844],{"type":27,"tag":63,"props":2845,"children":2847},{"className":2846},[],[2848],{"type":33,"value":79},{"type":33,"value":688},{"type":27,"tag":59,"props":2851,"children":2852},{"href":13},[2853],{"type":27,"tag":63,"props":2854,"children":2856},{"className":2855},[],[2857],{"type":33,"value":98},{"type":33,"value":2859}," → this. Next phase: build real Legion apps on\nthis surface.",{"type":27,"tag":36,"props":2861,"children":2862},{},[2863],{"type":27,"tag":40,"props":2864,"children":2865},{},[2866,2868,2874],{"type":33,"value":2867},"Note: the ",{"type":27,"tag":63,"props":2869,"children":2871},{"className":2870},[],[2872],{"type":33,"value":2873},"examples/*.c",{"type":33,"value":2875}," tree predates this L4 surface and needs a refresh to\nmatch it; treat the docs above (not those examples) as canonical for now.",{"type":27,"tag":2877,"props":2878,"children":2879},"style",{},[2880],{"type":33,"value":2881},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":21,"searchDepth":7,"depth":7,"links":2883},[2884,2885,2886,2888,2889,2890,2897,2898],{"id":104,"depth":7,"text":107},{"id":267,"depth":7,"text":270},{"id":466,"depth":7,"text":2887},"Library base (legion.h)",{"id":637,"depth":7,"text":640},{"id":852,"depth":7,"text":855},{"id":1869,"depth":7,"text":1872,"children":2891},[2892,2894,2895],{"id":1876,"depth":15,"text":2893},"Node + consume (legion_ffi_node.h, 24 fns)",{"id":2222,"depth":15,"text":2225},{"id":2557,"depth":15,"text":2896},"FFI helpers (legion_ffi.h)",{"id":2604,"depth":7,"text":2607},{"id":2823,"depth":7,"text":2826},"markdown","content:l4-apps.md","content","l4-apps.md","l4-apps","md",{"loc":17},1784532242628]