nx_preflight.nx
buildroot/runtime/nx_preflight.nx
about
nx_preflight.nx -- bulletproof pre-print orchestrator.
Composes every shipped pre-print sanity primitive into a single
SAFE / WARN / UNSAFE verdict that gates G-code emission. Per
NISHI_3D_PRINT_BULLETPROOF_PREFLIGHT_ROADMAP -- "push and play"
equivalent of Bambu LiDAR/AI/loadcell + Klipper KAMP + Prusa
loadcell preflight, sovereign substrate-native.
Checks performed (this primitive's contract):
1. nx_mesh_is_manifold (watertight geometry)
2. nx_mesh_fits_machine (bbox <= build volume)
3. nx_polymer_validate_profile (temps within polymer envelope)
4. nx_flow_envelope_check (slicer flow <= min(machine, material))
On any UNSAFE: refuse to emit print-start command. On WARN:
emit but surface the warning to operator.
Per cardinal feedback-no-false-ok-substrate-honesty-audit:
claiming "bulletproof" without ALL these checks IS the false-OK
class. Future versions add G-code structural sanity, Moonraker
ready-state, calibration freshness (queued P-BP-2..P-BP-6).
Per cardinal feedback-thymus-sovereignty-audit-soma-germline:
every check composes ONLY substrate primitives -- no Bambu/Prusa/
vendor APIs, no cloud lookups, no third-party services.
license_tier: ORIGINAL
dependencies 6 imports · 3 importers
imports: nx_syscalls.nxnx_mesh.nxnx_mesh_print_check.nxnx_machine_graph.nxnx_material_profile.nxnx_polymer_thermal.nx
imported by: nx_preflight_test.nxnx_print_session.nxnx_print_session_test.nx
structs
| 74 | struct NxPreflightResult |
consts
| 38 | const NX_PREFLIGHT_SAFE: i64 = 0 |
| 39 | const NX_PREFLIGHT_WARN: i64 = 1 |
| 40 | const NX_PREFLIGHT_UNSAFE: i64 = 2 |
| 44 | const NX_PFR_OK: i64 = 0 |
| 45 | const NX_PFR_NOT_MANIFOLD: i64 = 1 |
| 46 | const NX_PFR_MESH_TOO_LARGE: i64 = 2 |
| 47 | const NX_PFR_BAD_THERMAL: i64 = 3 |
| 48 | const NX_PFR_FLOW_EXCEEDED_MACHINE: i64 = 4 |
| 49 | const NX_PFR_FLOW_EXCEEDED_MATERIAL: i64 = 5 |
| 50 | const NX_PFR_BAD_LAYER_HEIGHT: i64 = 6 |
| 51 | const NX_PFR_NULL_INPUT: i64 = 7 |
| 52 | const NX_PFR_LAYER_TOO_THICK: i64 = 8 |
| 53 | const NX_PFR_LAYER_TOO_THIN: i64 = 9 |
| 54 | const NX_PFR_N: i64 = 10 |
| 81 | const NX_PREFLIGHT_BYTES: i64 = 32 |
| 89 | const NX_Q14_TO_MM: i64 = 16384 |
functions
| 56 | func nx_pfr_name(r: i64) -> *u8 called by 1: main |
| 91 | func nx_mesh_fits_machine(mesh: *NxMesh, machine: *NxMachineGraph) -> i64 |
| 122 | func nx_flow_envelope_check(line_width_q14: i64, layer_height_q14: i64, called by 1: nx_preflight_check |
| 157 | func nx_layer_envelope_check(layer_height_q14: i64, called by 1: nx_preflight_check |
| 178 | func nx_preflight_check(mesh: *NxMesh, |