nx_time_quality.nx
buildroot/runtime/nx_time_quality.nx
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
imports: syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 27 | const NX_MAGIC_4096: i64 = 4096 |
| 28 | const NX_MAGIC_1024: i64 = 1024 |
| 31 | const NX_TQ_HOT_PATH: i64 = 1 |
| 32 | const NX_TQ_WARM_PATH: i64 = 2 |
| 33 | const NX_TQ_COLD_PATH: i64 = 3 |
| 34 | const NX_TQ_LEISURE: i64 = 4 |
| 35 | const NX_TQ_SETUP: i64 = 5 |
| 36 | const NX_TQ_TEARDOWN: i64 = 6 |
| 37 | const NX_TQ_DEADLINE: i64 = 7 |
| 38 | const NX_TQ_OPPORTUNISTIC: i64 = 8 |
| 39 | const NX_TQ_PHASE_N: i64 = 9 |
| 42 | const NX_TQ_TRIANGLE_OK: i64 = 0 |
| 43 | const NX_TQ_TRIANGLE_SLOW: i64 = 1 |
| 44 | const NX_TQ_TRIANGLE_FAST: i64 = 2 |
| 45 | const NX_TQ_TRIANGLE_DRIFT: i64 = 3 |
| 46 | const NX_TQ_TRIANGLE_UNKNOWN: i64 = 4 |
| 49 | const NX_TQ_DELTA_OK_BOUND: i64 = 256 // |delta| < 25% = OK |
| 50 | const NX_TQ_DELTA_BIG_BOUND: i64 = 512 // |delta| > 50% = SLOW/FAST |
| 61 | const NX_TQ_REC_SIZE: i64 = 40 // 5 i64: work_tag/phase/decl/meas/seq |
| 62 | const NX_TQ_CHUNK_BYTES: i64 = 40960 // 1024 records |
functions
| 64 | func nx_tq_init() -> i64 |
| 92 | func nx_tq_enable() -> i64 { NX_TQ_ACTIVE = 1; return 0 } called by 1: main |
| 93 | func nx_tq_disable() -> i64 { NX_TQ_ACTIVE = 0; return 0 } called by 1: main |
| 94 | func nx_tq_is_active() -> i64 { return NX_TQ_ACTIVE } |
| 97 | func nx_tq_record(work_tag: i64, phase: i64, |
| 126 | func _nx_tq_latest_slot(work_tag: i64) -> i64 |
| 138 | func nx_tq_classify(work_tag: i64) -> i64 |
| 146 | func nx_tq_budget(work_tag: i64) -> i64 |
| 155 | func nx_tq_history_norm(phase: i64) -> i64 |
| 173 | func nx_tq_triangle(work_tag: i64) -> i64 |
| 212 | func nx_tq_n_records() -> i64 |
| 220 | func main() -> i64 |