nx_5wh_log.nx
buildroot/runtime/nx_5wh_log.nx
about
nx_5wh_log.nx -- unified 5W+H+GLP ledger.
The bridge between top-down measurement (nx_monte_carlo,
nx_multivariate, nx_patch_attribution, nx_knn, nx_closed_loop,
nx_quality_grade) and bottom-up attribution (nx_attribution,
nx_activation_steer). Both axes emit Nx5whRecord into ONE
queryable causal DAG.
Schema (canonical 9-field tuple per COMPETITIVE_POSITION.md:60):
who -- actor id (caller / tensor / weight)
what -- sealed enum: MEASUREMENT / VERDICT / ATTRIBUTION ...
when -- monotonic step counter
where -- sealed where-kind + 3 indices (layer/head/pos)
why_parent -- record_id of the record this one was caused by
(or -1 for root); forms the causal DAG
how -- algorithm tag (FNV-1a of algo name)
genealogy -- research-paper id hash (Welford 1962 etc.)
lineage -- data-checkpoint id hash (W matrix hash etc.)
performance -- one numeric: latency_us | err_bound | share_q10
(interpretation depends on what_kind)
JPL Power of 10 Rule 2: bounded capacity; ring overflow drops
oldest with NX_5WH_DROPPED verdict returned on emit.
genealogy_id: substrate_5wh_log_v1
lineage_id: competitive_position_md_line_60
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_runtime.nxnx_tier.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| 89 | struct Nx5whRecord { |
| 108 | struct Nx5whLedger { |
consts
| 34 | const NX_5WH_WHAT_MEASUREMENT: nx_int = 0 |
| 35 | const NX_5WH_WHAT_VERDICT: nx_int = 1 |
| 36 | const NX_5WH_WHAT_ATTRIBUTION: nx_int = 2 |
| 37 | const NX_5WH_WHAT_CONTRIBUTION: nx_int = 3 |
| 38 | const NX_5WH_WHAT_OP_BEGIN: nx_int = 4 |
| 39 | const NX_5WH_WHAT_OP_END: nx_int = 5 |
| 40 | const NX_5WH_WHAT_ALLOC: nx_int = 6 |
| 41 | const NX_5WH_WHAT_STEER: nx_int = 7 |
| 42 | const NX_5WH_WHAT_ADJUST: nx_int = 8 |
| 43 | const NX_5WH_WHAT_REROLL: nx_int = 9 |
| 44 | const NX_5WH_WHAT_GATE: nx_int = 10 |
| 45 | const NX_5WH_WHAT_N_KINDS: nx_int = 11 |
| 55 | const NX_5WH_WHERE_NONE: nx_int = 0 |
| 56 | const NX_5WH_WHERE_TRANSFORMER_LAYER: nx_int = 1 |
| 57 | const NX_5WH_WHERE_ATTN_HEAD: nx_int = 2 |
| 58 | const NX_5WH_WHERE_MLP_BLOCK: nx_int = 3 |
| 59 | const NX_5WH_WHERE_EMBED: nx_int = 4 |
| 60 | const NX_5WH_WHERE_UNEMBED: nx_int = 5 |
| 61 | const NX_5WH_WHERE_UNET_BLOCK: nx_int = 6 |
| 62 | const NX_5WH_WHERE_VAE_BLOCK: nx_int = 7 |
| 63 | const NX_5WH_WHERE_SAMPLER: nx_int = 8 |
| 64 | const NX_5WH_WHERE_DECODER: nx_int = 9 |
| 65 | const NX_5WH_WHERE_RASTER: nx_int = 10 |
| 66 | const NX_5WH_WHERE_MESH: nx_int = 11 |
| 67 | const NX_5WH_WHERE_HARDWARE: nx_int = 12 |
| 68 | const NX_5WH_WHERE_EXTERNAL: nx_int = 13 |
| 69 | const NX_5WH_WHERE_N_KINDS: nx_int = 14 |
| 79 | const NX_5WH_OK: nx_int = 0 |
| 80 | const NX_5WH_DROPPED: nx_int = 1 |
| 81 | const NX_5WH_INVALID: nx_int = 2 |
| 85 | const NX_5WH_NO_PARENT: nx_int = -1 |
| 104 | const NX_5WH_RECORD_BYTES: nx_size = 96 // 12 fields x 8 bytes |
| 117 | const NX_5WH_LEDGER_BYTES: nx_size = 48 |
| 118 | const NX_5WH_DEFAULT_CAP: nx_int = 4096 |
| 119 | const NX_5WH_MAX_CAP: nx_int = 1048576 |
| 248 | const NX_5WH_MAX_WALK: nx_int = 1024 |
functions
| 47 | func nx_5wh_what_is_valid(k: nx_int) -> nx_int { |
| 71 | func nx_5wh_where_is_valid(k: nx_int) -> nx_int { |
| 123 | func nx_5wh_log_alloc(capacity: nx_int) -> *Nx5whLedger { |
| 142 | func _5wh_advance(ledger: *Nx5whLedger) -> nx_int {
called by 1: nx_5wh_emit |
| 154 | func nx_5wh_emit(ledger: *Nx5whLedger, |
| 184 | func nx_5wh_record_at(ledger: *Nx5whLedger, slot: nx_int) -> *Nx5whRecord { |
| 199 | func _5wh_bit_test(mask: nx_int, bit: nx_int) -> nx_int {
called by 1: nx_5wh_query |
| 209 | func nx_5wh_query(ledger: *Nx5whLedger, |
| 250 | func nx_5wh_walk_lineage(ledger: *Nx5whLedger, seed_id: nx_int, |
| 270 | func nx_5wh_count_by_what(ledger: *Nx5whLedger, what: nx_int) -> nx_int { |
| 286 | func nx_5wh_n_emitted(ledger: *Nx5whLedger) -> nx_int { |
| 290 | func nx_5wh_n_dropped(ledger: *Nx5whLedger) -> nx_int { |
| 304 | func main() -> nx_int { |