nx_trace_query.nx
buildroot/runtime/nx_trace_query.nx
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
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
| 39 | const NX_TQ_MAX_ATTRS_PER_SPAN: nx_int = 32 |
| 116 | const NX_TQ_SUMMARY_HDR_FIELDS: nx_int = 2 // trace_id + n_attrs |
| 117 | const NX_TQ_SUMMARY_STRIDE: nx_int = 66 // 2 + 2 * 32 |
functions
| 41 | func nx_tq_count_kinds(buf: *u8, n_bytes: nx_int, counts_out: *i64) -> nx_int |
| 80 | func nx_tq_count_for_trace(buf: *u8, n_bytes: nx_int, trace_id: nx_int) -> nx_int |
| 119 | func nx_tq_extract_batch_summaries(buf: *u8, n_bytes: nx_int, |
| 172 | func nx_tq_distinct_attr_values(buf: *u8, n_bytes: nx_int, |