nx_pe_job_self_test.nx
buildroot/runtime/nx_pe_job_self_test.nx
about
nx_pe_job_self_test.nx -- W2a: sovereign Windows Job Object, native, no HCS.
Docker-replacement ladder rung W2a (isolation model = sovereign Job Objects,
operator decision 2026-06-13). The substrate emits a native Windows PE that:
1. CreateJobObjectW(NULL, NULL) -> hJob (our sovereign control boundary)
2. AssignProcessToJobObject(hJob, self) -> put THIS process under the job
3. IsProcessInJob(self, hJob, &inJob) -> VERIFY membership (no-false-green)
4. ExitProcess(inJob ? 42 : 99)
self = GetCurrentProcess() = (HANDLE)-1 (constant pseudo-handle, no import needed).
PROOF: exit 42 iff the process is genuinely inside OUR job (governed). If the
assignment did not take (e.g. nesting unavailable), inJob=FALSE -> exit 99 -> RED.
This is the cgroups-analog BOUNDARY on Windows -- the thing Docker needs a Linux
VM (WSL2/Hyper-V) for. We do it as a native NT process. No HCS daemon, no MinGW,
no MSVC, no VM. 4 kernel32 imports.
HONEST SCOPE: this proves Job CREATION + MEMBERSHIP (the boundary exists & governs).
It does NOT yet enforce a resource LIMIT -- that is W2b (SetInformationJobObject
memory.max/ActiveProcessLimit + tamper proof). Child-spawn-into-job = W2c (reuse
nx_pe_emit_spawn42 machinery). Founded on nx_pe_writer.nx (hand-authored byte-layout,
tutor-scaffold lineage); back-fill = nxc2 PE/MS-x64 backend (W3).
genealogy_id: win32_job_objects_2000 + lmctfy_2013 + runc_cgroups_2016
lineage_id: substrate_pe_jobself_v1
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_hal.nxnx_pe_writer.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 30 | const PE_JOBSELF_FILE_SIZE: i64 = 0x600 // 1536 bytes: headers + .text + .idata |
functions
| 38 | func nx_pe_emit_job_self(buf: *u8) -> i64 |
| 254 | func main() -> i64 |