nx_substrate_tier_audit.nx
buildroot/runtime/nx_substrate_tier_audit.nx
about
nx_substrate_tier_audit.nx -- the FOUR-PILLAR DETECT layer for the
tier-cardinal violations that required two retroactive sweeps in
the 2026-05-15 session.
User cardinals reinforced:
- feedback-scale-agnostic-tier-locks: "bare i64 in substrate code
= tier-lock defect; use nx_int / nx_size / nx_idx / nx_byte
from nx_tier.nx"
- feedback-stop-and-build-upward: when a defect class is found,
close it at the substrate level so future occurrences are
compile-time errors, not human-audit catches.
- the four-pillar preventative layer (user-named 2026-05-15):
DETECT / PREVENT / DIAGNOSE / REPAIR. This file is DETECT.
Scans a source-text byte buffer for FIVE violation axes; emits a
typed report + sealed-enum verdict. Same dual-reading shape as
nx_code_quality.nx (per-axis Q10 + composite + worst-axis name).
VIOLATION AXES (each maps to a Q10 score; HIGH = CLEAN):
1. BARE_I64 occurrences of `: i64` in arithmetic
contexts (type annotation on let/var/const/
struct field/param/return). EXCLUDES `*i64`
(pointer; storage shape is platform-fixed)
and comments.
2. MISSING_TIER file uses nx_int / nx_size / NX_SIZEOF_NX_INT
/ NX_BUF_* but does NOT import "nx_tier.nx".
3. HARDCODED_BYTES `* 8` / `* 4` / `* 2` literals inside
sys_mmap calls -- should be NX_SIZEOF_NX_INT
or NX_SIZEOF_NX_SIZE.
4. BARE_MMAP_LITERAL `sys_mmap(N)` with N a small literal (16
to 4096) that should be NX_BUF_TINY /
SMALL / MEDIUM / LARGE / HUGE.
5. LITERAL_SIZEOF bare numeric struct-size literals in
allocations (sys_mmap(96) for a 12-field
struct should be 12 * NX_SIZEOF_NX_INT).
Sealed-enum verdict:
NX_TIERAUDIT_CLEAN 0 violations
NX_TIERAUDIT_MINOR 1-2 violations
dependencies 2 imports · 1 importers
imports: nx_syscalls.nxnx_tier.nx
imported by: nx_substrate_tier_audit_test.nx
structs
| 86 | struct TierAuditReport |
consts
| 69 | const NX_TIERAUDIT_Q: nx_int = 1024 |
| 72 | const NX_TIERAUDIT_CLEAN: nx_int = 0 |
| 73 | const NX_TIERAUDIT_MINOR: nx_int = 1 |
| 74 | const NX_TIERAUDIT_MODERATE: nx_int = 2 |
| 75 | const NX_TIERAUDIT_NEEDS_REFACTOR: nx_int = 3 |
| 76 | const NX_TIERAUDIT_N_VERDICTS: nx_int = 4 |
| 79 | const NX_TIERAUDIT_AXIS_BARE_I64: nx_int = 0 |
| 80 | const NX_TIERAUDIT_AXIS_MISSING_TIER: nx_int = 1 |
| 81 | const NX_TIERAUDIT_AXIS_HARDCODED_BYTES: nx_int = 2 |
| 82 | const NX_TIERAUDIT_AXIS_BARE_MMAP: nx_int = 3 |
| 83 | const NX_TIERAUDIT_AXIS_LITERAL_SIZEOF: nx_int = 4 |
| 84 | const NX_TIERAUDIT_N_AXES: nx_int = 5 |
functions
| 104 | func _ta_match_at(buf: *u8, len: nx_int, pos: nx_int, lit: *u8, n: nx_int) -> nx_int called by 1: nx_substrate_tier_audit |
| 114 | func _ta_in_comment(buf: *u8, pos: nx_int) -> nx_int called by 1: nx_substrate_tier_audit |
| 130 | func _ta_is_word_char(c: u8) -> nx_int |
| 145 | func _ta_is_boundary(buf: *u8, len: nx_int, p: nx_int) -> nx_int |
| 154 | func nx_substrate_tier_audit(buf: *u8, len: nx_int, report: *TierAuditReport) -> nx_int |
| 393 | func nx_substrate_tier_audit_verdict_is_valid(v: nx_int) -> nx_int called by 1: main |
| 399 | func nx_substrate_tier_audit_axis_is_valid(a: nx_int) -> nx_int called by 1: main |