nx_proc_spawn.nx
buildroot/runtime/nx_proc_spawn.nx
about
nx_proc_spawn.nx -- HIGH-LEVEL spawn-with-capability-gate layer above
the FULLY_WIRED nx_proc.nx primitive (fork/exec/wait4 syscall wrappers).
AUDIT-FIRST CORRECTION (2026-05-20, post-creation): user caught that I
built this without checking for existing prior art. nx_proc.nx already
ships with nx_proc_fork / nx_proc_execve / nx_proc_wait4 / wait-status
inspectors. This primitive does NOT duplicate those -- it adds the
capability-token + priv-class + log-redirect layer ABOVE them. When
graduated, nx_proc_spawn_execute will CALL nx_proc_fork + nx_proc_execve
internally; it is the supervised wrapper, not a competing implementation.
Per feedback-no-temporary-third-party-scaffolding-when-substrate-arc-exists
audit-first rule: ls nxc2/runtime/ before authoring new primitives.
Composes with the existing nx_supervisor state-machine primitive (which
decides what to do); THIS primitive does the actual process management.
module: nishi-core.ops.proc_spawn
depends: nishi-core.perception.profile + nishi-core.ops.supervisor +
nishi-core.io.syscalls
disk_kb: 5
capability: OPS
wired_status: PARTIAL_WIRED
MISSING_CAPABILITIES:
- FORK_EXEC_SETSID (sys_fork + sys_execve + sys_setsid; sys_fork is
proven via nishi_video_room.nx, sys_execve glue needed)
- CAPABILITY_TOKEN_VERIFY (content-addressed capability proof that
replaces /etc/sudoers.d/* NOPASSWD entries with cryptographic
capability bearer tokens; composes with nx_ed25519 + nx_blake2b
which are FULLY_WIRED per status doc)
- PRIV_DROP (after fork, child drops privilege per NX_SUPV_PRIV_*
declared class before execve)
- FD_HYGIENE (close-on-exec all inherited fds except declared ones)
- STDIO_REDIRECT (per-child stdout/stderr to substrate-managed log files)
license_tier: PUBLIC_NISHI_SUBSTRATE
genealogy_id: feedback-no-temporary-third-party-scaffolding-when-substrate-arc-exists_2026 +
feedback-substrate-does-heavy-lifting-user-is-partner-not-gate +
nx_supervisor (existing state-machine primitive) +
nx_daemon_health_audit
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_perceptual_profile.nxnx_supervisor.nx
imported by: nobody (leaf or entry point)
structs
| 101 | struct NxPSpawnRequest |
consts
| 60 | const NX_PSPAWN_OK: i64 = 0 |
| 61 | const NX_PSPAWN_SPAWNED: i64 = 1 |
| 62 | const NX_PSPAWN_FAIL_FORK: i64 = 2 |
| 63 | const NX_PSPAWN_FAIL_EXEC: i64 = 3 |
| 64 | const NX_PSPAWN_FAIL_BAD_BINARY: i64 = 4 // path missing / not exec |
| 65 | const NX_PSPAWN_FAIL_CAPABILITY_REFUSED: i64 = 5 // requested priv exceeds |
| 67 | const NX_PSPAWN_FAIL_PRIV_DROP: i64 = 6 // child couldn't drop priv |
| 68 | const NX_PSPAWN_FAIL_DEPENDENCY_MISSING: i64 = 7 // PARTIAL_WIRED default |
| 84 | const NX_PSPAWN_PRIV_USER: i64 = 1 |
| 85 | const NX_PSPAWN_PRIV_NET_BIND_LOW_PORT: i64 = 2 |
| 86 | const NX_PSPAWN_PRIV_FS_WRITE_PROTECTED: i64 = 3 |
| 87 | const NX_PSPAWN_PRIV_DEVICE_ACCESS: i64 = 4 |
| 88 | const NX_PSPAWN_PRIV_ROOT_FULL: i64 = 5 // audit-gate |
functions
| 70 | func nx_pspawn_verdict_name(v: i64) -> *u8 |
| 90 | func nx_pspawn_priv_class_name(p: i64) -> *u8 |
| 125 | func nx_pspawn_execute(req_ptr: *NxPSpawnRequest) -> i64 |
| 134 | func nx_pspawn_kill_pid(pid: i64, grace_seconds: i64) -> i64 |
| 142 | func nx_pspawn_pid_is_alive(pid: i64) -> i64 |
| 151 | func nx_pspawn_verify_capability_token(token_ptr: *u8, token_len: i64, |
| 164 | func nx_pspawn_get_last_verdict() -> i64 |