code wiki / (root) / nx_klipper_gcode_validator.nx

nx_klipper_gcode_validator.nx

buildroot/runtime/nx_klipper_gcode_validator.nx

9222 B267 linesdepth 2pulls 2 transitivereach 3 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_klipper_gcode_validator.nx -- Phase B1 of S-class hardening. Real-input validation that the substrate's emitted G-code parses as syntactically valid Klipper commands. Walks the emitted byte stream + verifies every non-comment line follows G/M/T + space- separated letter+number parameters. Per [[feedback-no-false-ok-substrate-honesty-audit]] + the S-class honest audit: emitted G-code MUST be parseable by Klipper before we send it to the Qidi. If our slicer emits something Klipper rejects mid-job, that's a half-print failure (operator's "spaghetti or where it prints halfway" failure class). This validator is the substrate-side guarantee that emitted bytes ARE valid before any filament moves. Validates: - Non-empty + non-comment lines must start with G/M/T - Command (after G/M/T) must be a decimal number - Parameters: letter (A-Z) followed by signed numeric value - No control bytes (< 0x09) outside CR/LF/TAB - F (feedrate) parameter, when present, must be positive Does NOT validate: - Command semantics (G99 wouldn't be flagged even though Klipper might reject it; substrate trusts caller's command set) - Numeric ranges (axes within build volume = simulator's job) - Klipper extended commands (SET_*, BED_MESH_*, etc.) license_tier: ORIGINAL

dependencies 1 imports · 3 importers

nx_syscalls.nx nx_klipper_gcode_validator.nx nx_christus_integration_test.nx nx_klipper_gcode_validator_test.nx nx_mushroom_overhang_test.nx

imports: nx_syscalls.nx

imported by: nx_christus_integration_test.nxnx_klipper_gcode_validator_test.nxnx_mushroom_overhang_test.nx

structs

none

consts

33const NX_KGV_OK: i64 = 0
34const NX_KGV_BAD_LINE: i64 = 1
35const NX_KGV_BAD_PARAM: i64 = 2
36const NX_KGV_BAD_CONTROL_CHAR: i64 = 3
37const NX_KGV_BAD_FEEDRATE: i64 = 4
38const NX_KGV_BAD_INPUT: i64 = 5
39const NX_KGV_N: i64 = 6

functions

41func nx_kgv_is_valid(v: i64) -> i64
48func kgv_is_digit(b: i64) -> i64
called by 1: kgv_validate_line
55func kgv_is_upper(b: i64) -> i64
called by 1: kgv_validate_line
63func kgv_validate_line(buf: *u8, start: i64, end: i64) -> i64
235func nx_klipper_gcode_validate(buf: *u8, len: i64,
called by 3: mainmainmain calls 1: kgv_validate_line