code wiki / (root) / nx_trace_query.nx

nx_trace_query.nx

buildroot/runtime/nx_trace_query.nx

9107 B221 linesdepth 4pulls 6 transitivereach 3 importersview sourcekind librarytopic trace
docsdependenciesstructsconstsfunctions

about

nx_trace_query.nx -- filter / count / project over CBOR span streams. Layer 3 of the sovereign-log roadmap. Operates on a raw CBOR span buffer (n bytes of back-to-back nx_cbor_emit_span output). The caller decides the source: live in-memory chunk_buf, a flushed nx_log_chunked chunk's bytes, a memory-mapped on-disk file, or a concatenated multi-chunk read. Query layer doesn't care about storage layout -- it walks bytes. Design rationale: stream-walk per query keeps the primitive small (no internal indexing) and avoids the LSM-tree compaction problem for v1. When a query becomes hot, an index can land at Layer 4 (bloom filter + segment summary) without changing this API. Per the build-the-engine-not-instances cardinal: this primitive scales any future projection without per-projection code. genealogy_id: cqrs_event_sourcing + opentelemetry_query lineage_id: substrate_trace_query_v1

dependencies 5 imports · 2 importers

nx_syscalls.nx nx_tier.nx nx_cbor.nx nx_cbor_decode.nx nx_trace_emit.nx nx_trace_query.nx nx_dashboard.nx nx_trace_query_test.nx

imports: nx_syscalls.nxnx_tier.nxnx_cbor.nxnx_cbor_decode.nxnx_trace_emit.nx

imported by: nx_dashboard.nxnx_trace_query_test.nx

structs

none

consts

39const NX_TQ_MAX_ATTRS_PER_SPAN: nx_int = 32
116const NX_TQ_SUMMARY_HDR_FIELDS: nx_int = 2 // trace_id + n_attrs
117const NX_TQ_SUMMARY_STRIDE: nx_int = 66 // 2 + 2 * 32

functions

41func nx_tq_count_kinds(buf: *u8, n_bytes: nx_int, counts_out: *i64) -> nx_int
80func nx_tq_count_for_trace(buf: *u8, n_bytes: nx_int, trace_id: nx_int) -> nx_int
called by 1: main calls 2: sys_mmapnx_cbor_read_span
119func nx_tq_extract_batch_summaries(buf: *u8, n_bytes: nx_int,
172func nx_tq_distinct_attr_values(buf: *u8, n_bytes: nx_int,
called by 1: main calls 2: sys_mmapnx_cbor_read_span