code wiki / (root) / nx_actor.nx

nx_actor.nx

buildroot/runtime/nx_actor.nx

12036 B341 linesdepth 2pulls 2 transitivereach 39 importersview sourcekind librarytopic actor
docsdependenciesstructsconstsfunctions

about

nx_actor.nx -- cooperative green-thread driver for differentiated cells. Per CARDINAL [[feedback-parallel-companion-multimodal-dnd-real-time]]: LLM streaming + image gen + video + audio TTS + game actions all need to RUN CONCURRENT. This primitive is the cooperative scheduler -- each actor is a runnable unit with state (READY/RUNNING/WAITING) and a current step. V1 ships pure cooperative scheduling (call ac_step to drive); preemptive scheduling layers on top via [[nx_interrupt_ broker]] checkpoint-yield gates. Composes [[nx_meristem]] (cells differentiate into roles; actors wrap roles into runnable units) + [[nx_resource_arbiter]] (actors compete for cycles via the arbiter's CPU_MICROSECONDS resource) + [[nx_stream_ multiplexer]] (actor output enters the mux as chunks).

dependencies 2 imports · 34 importers

nx_syscalls.nx nx_tier.nx nx_actor.nx nx_actor_role_audio_grader.nx nx_actor_role_audio_grader_test.nx nx_actor_role_game_logic.nx nx_actor_role_game_logic_test.nx nx_actor_role_image_grader.nx nx_actor_role_image_grader_test.nx nx_actor_role_llm.nx nx_actor_role_llm_test.nx nx_actor_role_llm_v2.nx nx_actor_role_llm_v2_autoreg_test.

diagram shows first 10 each side; +0 more imports, +24 more importers in the complete lists below.

imports: nx_syscalls.nxnx_tier.nx

imported by: nx_actor_role_audio_grader.nxnx_actor_role_audio_grader_test.nxnx_actor_role_game_logic.nxnx_actor_role_game_logic_test.nxnx_actor_role_image_grader.nxnx_actor_role_image_grader_test.nxnx_actor_role_llm.nxnx_actor_role_llm_test.nxnx_actor_role_llm_v2.nxnx_actor_role_llm_v2_autoreg_test.nxnx_actor_role_llm_v2_real_autoreg_test.nxnx_actor_role_llm_v2_real_test.nxnx_actor_role_llm_v2_test.nxnx_actor_test.nxnx_bench_companion.nxnx_bench_companion_test.nxnx_bench_companion_timed_test.nxnx_bench_dist_emit_test.nxnx_bench_dist_persist_test.nxnx_bench_scale_dist_emit_test.nxnx_bench_scale_test.nxnx_bench_stress_autoreg_test.nxnx_bench_stress_emit_test.nxnx_bench_v1_vs_v2_test.nxnx_companion_compose_test.nxnx_dual_companion_compose_test.nxnx_dual_real_llm_compose_test.nxnx_dual_real_llm_emit_test.nxnx_quad_companion_compose_test.nxnx_quad_real_emit_test.nxnx_session.nxnx_session_real_llm_compose_test.nxnx_session_test.nxnx_triple_companion_compose_test.nx

structs

52struct NxActor
67struct NxActorScheduler

consts

21const NX_AC_STATE_READY: nx_int = 0 // can run on next step
22const NX_AC_STATE_RUNNING: nx_int = 1 // currently executing
23const NX_AC_STATE_WAITING: nx_int = 2 // blocked on dependency
24const NX_AC_STATE_COMPLETED: nx_int = 3 // finished normally
25const NX_AC_STATE_FAILED: nx_int = 4 // unrecoverable error
26const NX_AC_STATE_PAUSED: nx_int = 5 // operator-initiated pause
27const NX_AC_STATE_N: nx_int = 6
31const NX_AC_WAIT_NONE: nx_int = 0
32const NX_AC_WAIT_RESOURCE: nx_int = 1 // arbiter denied
33const NX_AC_WAIT_MESSAGE: nx_int = 2 // peer actor input
34const NX_AC_WAIT_IO: nx_int = 3 // file / network
35const NX_AC_WAIT_TIMER: nx_int = 4
36const NX_AC_WAIT_OPERATOR: nx_int = 5 // human input
37const NX_AC_WAIT_N: nx_int = 6
41const NX_AC_V_STEPPED: nx_int = 0
42const NX_AC_V_YIELDED: nx_int = 1
43const NX_AC_V_BLOCKED: nx_int = 2
44const NX_AC_V_COMPLETED: nx_int = 3
45const NX_AC_V_FAILED: nx_int = 4
46const NX_AC_V_INVALID: nx_int = 5
47const NX_AC_V_NULL: nx_int = 6
48const NX_AC_V_N: nx_int = 7
65const NX_AC_BYTES: nx_int = 80
78const NX_AC_S_BYTES: nx_int = 56

functions

82func nx_ac_state_is_valid(s: nx_int) -> nx_int
called by 1: main
88func nx_ac_wait_is_valid(w: nx_int) -> nx_int
94func nx_ac_v_is_valid(v: nx_int) -> nx_int
called by 1: main
100func nx_ac_state_is_runnable(s: nx_int) -> nx_int
106func nx_ac_state_is_terminal(s: nx_int) -> nx_int
114func nx_ac_sched_new(capacity: nx_int,
called by 14: mainmainmainmainmainmain+8 calls 1: sys_mmap
133func _ac_at(s: *NxActorScheduler, idx: nx_int) -> *NxActor
142func nx_ac_spawn(s: *NxActorScheduler,
called by 13: mainmainmainmainmainmain+7
167func nx_ac_find(s: *NxActorScheduler, actor_id: nx_int) -> *NxActor
180func nx_ac_set_waiting(s: *NxActorScheduler,
193func nx_ac_wake(s: *NxActorScheduler, actor_id: nx_int) -> nx_int
called by 1: main calls 1: nx_ac_find
203func nx_ac_pause(s: *NxActorScheduler, actor_id: nx_int) -> nx_int
212func nx_ac_resume(s: *NxActorScheduler, actor_id: nx_int) -> nx_int
called by 1: main calls 1: nx_ac_find
221func nx_ac_complete(s: *NxActorScheduler, actor_id: nx_int) -> nx_int
229func nx_ac_fail(s: *NxActorScheduler, actor_id: nx_int) -> nx_int
243func nx_ac_step(s: *NxActorScheduler,
277func nx_ac_pick_next(s: *NxActorScheduler) -> *NxActor
299func nx_ac_epoch_tick(s: *NxActorScheduler, now_us: nx_size) -> nx_int
called by 2: mainmain calls 1: _ac_at
314func nx_ac_count_by_state(s: *NxActorScheduler, state: nx_int) -> nx_int
called by 2: mainnx_bc_capture calls 1: _ac_at
326func nx_ac_total_runtime_us(s: *NxActorScheduler) -> nx_size
called by 3: mainnx_bc_capturemain calls 1: _ac_at
338func nx_ac_actor_count(s: *NxActorScheduler) -> nx_int