code wiki / (root) / nx_time_quality.nx

nx_time_quality.nx

buildroot/runtime/nx_time_quality.nx

9987 B276 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic time
docsdependenciesstructsconstsfunctions

about

nx_time_quality.nx -- four-dimensional time classification primitive. Cardinal: feedback-time-quality-fourth-dimension-triangulation. Time in the substrate is 4-D by construction: (1) t (quantitative) -- wall-ns measured (2) phase (qualitative) -- which racing-crew bucket (3) budget (declared) -- caller's intent at start (4) norm (population) -- avg across history for this phase Three of those (measured + declared + norm) triangulate. When they agree -> confidence. When one disagrees -> signal worth surfacing to the kernel / racing crew / coach. API: nx_tq_record(work_tag, phase, declared_ns, measured_ns) -> 0 nx_tq_classify(work_tag) -> phase | -1 nx_tq_budget(work_tag) -> declared_ns | -1 nx_tq_history_norm(phase) -> avg_ns nx_tq_triangle(work_tag) -> OK | SLOW | FAST | DRIFT | UNKNOWN nx_tq_n_records() -> i64 Substrate-native: import syscalls.nx, mmap-backed ledger, sealed enum verdicts, --strip clean.

dependencies 1 imports · 0 importers

syscalls.nx nx_time_quality.nx

imports: syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nx_tq_init nx_tq_disable nx_tq_record nx_tq_init ↻ nx_tq_n_records nx_tq_init ↻ nx_tq_enable nx_tq_history_norm nx_tq_init ↻ nx_tq_triangle _nx_tq_latest_slot nx_tq_init ↻ nx_tq_history_norm ↻ nx_tq_classify _nx_tq_latest_slot ↻ nx_tq_budget _nx_tq_latest_slot ↻

structs

none

consts

27const NX_MAGIC_4096: i64 = 4096
28const NX_MAGIC_1024: i64 = 1024
31const NX_TQ_HOT_PATH: i64 = 1
32const NX_TQ_WARM_PATH: i64 = 2
33const NX_TQ_COLD_PATH: i64 = 3
34const NX_TQ_LEISURE: i64 = 4
35const NX_TQ_SETUP: i64 = 5
36const NX_TQ_TEARDOWN: i64 = 6
37const NX_TQ_DEADLINE: i64 = 7
38const NX_TQ_OPPORTUNISTIC: i64 = 8
39const NX_TQ_PHASE_N: i64 = 9
42const NX_TQ_TRIANGLE_OK: i64 = 0
43const NX_TQ_TRIANGLE_SLOW: i64 = 1
44const NX_TQ_TRIANGLE_FAST: i64 = 2
45const NX_TQ_TRIANGLE_DRIFT: i64 = 3
46const NX_TQ_TRIANGLE_UNKNOWN: i64 = 4
49const NX_TQ_DELTA_OK_BOUND: i64 = 256 // |delta| < 25% = OK
50const NX_TQ_DELTA_BIG_BOUND: i64 = 512 // |delta| > 50% = SLOW/FAST
61const NX_TQ_REC_SIZE: i64 = 40 // 5 i64: work_tag/phase/decl/meas/seq
62const NX_TQ_CHUNK_BYTES: i64 = 40960 // 1024 records

functions

64func nx_tq_init() -> i64
92func nx_tq_enable() -> i64 { NX_TQ_ACTIVE = 1; return 0 }
called by 1: main
93func nx_tq_disable() -> i64 { NX_TQ_ACTIVE = 0; return 0 }
called by 1: main
94func nx_tq_is_active() -> i64 { return NX_TQ_ACTIVE }
97func nx_tq_record(work_tag: i64, phase: i64,
called by 1: main calls 1: nx_tq_init
126func _nx_tq_latest_slot(work_tag: i64) -> i64
138func nx_tq_classify(work_tag: i64) -> i64
called by 1: main calls 1: _nx_tq_latest_slot
146func nx_tq_budget(work_tag: i64) -> i64
called by 1: main calls 1: _nx_tq_latest_slot
155func nx_tq_history_norm(phase: i64) -> i64
called by 2: nx_tq_trianglemain calls 1: nx_tq_init
173func nx_tq_triangle(work_tag: i64) -> i64
212func nx_tq_n_records() -> i64
called by 1: main calls 1: nx_tq_init
220func main() -> i64