code wiki / (root) / nx_pe_job_self_test.nx

nx_pe_job_self_test.nx

buildroot/runtime/nx_pe_job_self_test.nx

13154 B278 linesdepth 4pulls 4 transitivereach 0 importersview sourcekind gate/prooftopic pe
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_hal.nx nx_pe_writer.nx nx_pe_job_self_test.nx

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

main nx_hal_alloc_pages nx_hal_active_shim nx_hal_alloc_pages_linux sys_mmap nx_hal_alloc_pages_bare_me nx_hal_alloc_pages_nishi_s nx_pe_emit_job_self _w16 _w32 _w8 _w64 _w32 ↻ _emit_section_header _w8 ↻ _w32 ↻ _w16 ↻ nx_pe_write_to_file sys_openat_wr sys_write sys_close sys_write ↻

structs

none

consts

30const PE_JOBSELF_FILE_SIZE: i64 = 0x600 // 1536 bytes: headers + .text + .idata

functions

38func nx_pe_emit_job_self(buf: *u8) -> i64
254func main() -> i64