code wiki / (root) / nx_5wh_log.nx

nx_5wh_log.nx

buildroot/runtime/nx_5wh_log.nx

14964 B402 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_runtime.nx nx_tier.nx nx_5wh_log.nx

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

main nx_5wh_log_alloc sys_mmap nx_5wh_emit nx_5wh_what_is_valid nx_5wh_where_is_valid _5wh_advance nx_5wh_record_at sys_mmap ↻ nx_5wh_query nx_5wh_record_at ↻ _5wh_bit_test nx_5wh_walk_lineage nx_5wh_record_at ↻ nx_5wh_count_by_what nx_5wh_what_is_valid ↻ nx_5wh_record_at ↻ nx_5wh_what_is_valid ↻ nx_5wh_where_is_valid ↻

structs

89struct Nx5whRecord {
108struct Nx5whLedger {

consts

34const NX_5WH_WHAT_MEASUREMENT: nx_int = 0
35const NX_5WH_WHAT_VERDICT: nx_int = 1
36const NX_5WH_WHAT_ATTRIBUTION: nx_int = 2
37const NX_5WH_WHAT_CONTRIBUTION: nx_int = 3
38const NX_5WH_WHAT_OP_BEGIN: nx_int = 4
39const NX_5WH_WHAT_OP_END: nx_int = 5
40const NX_5WH_WHAT_ALLOC: nx_int = 6
41const NX_5WH_WHAT_STEER: nx_int = 7
42const NX_5WH_WHAT_ADJUST: nx_int = 8
43const NX_5WH_WHAT_REROLL: nx_int = 9
44const NX_5WH_WHAT_GATE: nx_int = 10
45const NX_5WH_WHAT_N_KINDS: nx_int = 11
55const NX_5WH_WHERE_NONE: nx_int = 0
56const NX_5WH_WHERE_TRANSFORMER_LAYER: nx_int = 1
57const NX_5WH_WHERE_ATTN_HEAD: nx_int = 2
58const NX_5WH_WHERE_MLP_BLOCK: nx_int = 3
59const NX_5WH_WHERE_EMBED: nx_int = 4
60const NX_5WH_WHERE_UNEMBED: nx_int = 5
61const NX_5WH_WHERE_UNET_BLOCK: nx_int = 6
62const NX_5WH_WHERE_VAE_BLOCK: nx_int = 7
63const NX_5WH_WHERE_SAMPLER: nx_int = 8
64const NX_5WH_WHERE_DECODER: nx_int = 9
65const NX_5WH_WHERE_RASTER: nx_int = 10
66const NX_5WH_WHERE_MESH: nx_int = 11
67const NX_5WH_WHERE_HARDWARE: nx_int = 12
68const NX_5WH_WHERE_EXTERNAL: nx_int = 13
69const NX_5WH_WHERE_N_KINDS: nx_int = 14
79const NX_5WH_OK: nx_int = 0
80const NX_5WH_DROPPED: nx_int = 1
81const NX_5WH_INVALID: nx_int = 2
85const NX_5WH_NO_PARENT: nx_int = -1
104const NX_5WH_RECORD_BYTES: nx_size = 96 // 12 fields x 8 bytes
117const NX_5WH_LEDGER_BYTES: nx_size = 48
118const NX_5WH_DEFAULT_CAP: nx_int = 4096
119const NX_5WH_MAX_CAP: nx_int = 1048576
248const NX_5WH_MAX_WALK: nx_int = 1024

functions

47func nx_5wh_what_is_valid(k: nx_int) -> nx_int {
71func nx_5wh_where_is_valid(k: nx_int) -> nx_int {
called by 2: nx_5wh_emitmain
123func nx_5wh_log_alloc(capacity: nx_int) -> *Nx5whLedger {
called by 1: main calls 1: sys_mmap
142func _5wh_advance(ledger: *Nx5whLedger) -> nx_int {
called by 1: nx_5wh_emit
154func nx_5wh_emit(ledger: *Nx5whLedger,
184func nx_5wh_record_at(ledger: *Nx5whLedger, slot: nx_int) -> *Nx5whRecord {
199func _5wh_bit_test(mask: nx_int, bit: nx_int) -> nx_int {
called by 1: nx_5wh_query
209func nx_5wh_query(ledger: *Nx5whLedger,
called by 1: main calls 2: nx_5wh_record_at_5wh_bit_test
250func nx_5wh_walk_lineage(ledger: *Nx5whLedger, seed_id: nx_int,
called by 1: main calls 1: nx_5wh_record_at
270func nx_5wh_count_by_what(ledger: *Nx5whLedger, what: nx_int) -> nx_int {
286func nx_5wh_n_emitted(ledger: *Nx5whLedger) -> nx_int {
290func nx_5wh_n_dropped(ledger: *Nx5whLedger) -> nx_int {
304func main() -> nx_int {