code wiki / (root) / sketch_types.nx

sketch_types.nx

buildroot/runtime/sketch_types.nx

3631 B86 linesdepth 3pulls 3 transitivereach 159 importersview sourcekind sketch/demotopic sketch
docsdependenciesstructsconstsfunctions

about

sketch_types.nx -- L-4 typed envelope scaffold for streaming sketches. Lossless-language discipline (per nishi-engine docs 17 + 20): every approximate primitive in the substrate ships its loss NAMED, BOUNDED, and QUERYABLE. Sketches are bounded-loss, not silent-loss. Mirrors nishi-engine/packages/core-sketch/src/types.ts so the TS reference layer and the NishiLang sovereign sibling carry identical envelope semantics. All-i64 representation (no f64 source-level types) for C-anchor compatibility. Floating-point quantities (stddev, eps, conf) are stored as fixed-point integers scaled by 10^9 (parts-per- billion). Caller decodes by dividing by 1_000_000_000. stddev_rel = 0.0162 -> stddev_rel_ppb = 16_200_000 conf = 0.6827 -> conf_ppb = 682_700_000

dependencies 1 imports · 140 importers

syscalls.nx sketch_types.nx bench_hll_vs_cpc.nx bench_hll_vs_cpcd.nx nx_lowrank_kv_gate.nx sketch_ams.nx sketch_ams_test.nx sketch_ams_vs_naive_bench.nx sketch_bit_vector.nx sketch_bit_vector_test.nx sketch_bloom.nx sketch_bloom_test.nx

diagram shows first 10 each side; +0 more imports, +130 more importers in the complete lists below.

imports: syscalls.nx

imported by: bench_hll_vs_cpc.nxbench_hll_vs_cpcd.nxnx_lowrank_kv_gate.nxsketch_ams.nxsketch_ams_test.nxsketch_ams_vs_naive_bench.nxsketch_bit_vector.nxsketch_bit_vector_test.nxsketch_bloom.nxsketch_bloom_test.nxsketch_buglog.nxsketch_buglog_test.nxsketch_cb_vs_cuckoo_delete_bench.nxsketch_cms.nxsketch_cms_test.nxsketch_comparator.nxsketch_comparator_test.nxsketch_correlation.nxsketch_correlation_test.nxsketch_count_sketch.nxsketch_count_sketch_negative_bench.nxsketch_count_sketch_test.nxsketch_count_sketch_vs_cms_bias_bench.nxsketch_counting_bloom.nxsketch_counting_bloom_test.nxsketch_cpc.nxsketch_cpc_dense.nxsketch_cpc_dense_test.nxsketch_cpc_test.nxsketch_cuckoo.nxsketch_cuckoo_delete_vs_bloom_bench.nxsketch_cuckoo_test.nxsketch_cusum.nxsketch_cusum_test.nxsketch_cusum_vs_threshold_bench.nxsketch_ddsketch.nxsketch_ddsketch_test.nxsketch_ddsketch_vs_tdigest_tail_bench.nxsketch_entropy.nxsketch_entropy_test.nxsketch_epsilon_greedy.nxsketch_epsilon_greedy_test.nxsketch_ewma.nxsketch_ewma_test.nxsketch_freq_directions.nxsketch_freq_directions_test.nxsketch_freq_directions_vs_topnorm_bench.nxsketch_geomean.nxsketch_geomean_test.nxsketch_hash_map.nxsketch_hash_map_test.nxsketch_histogram.nxsketch_histogram_test.nxsketch_hll.nxsketch_hll4.nxsketch_hll4_test.nxsketch_hll4_vs_hll8_bench.nxsketch_hll_lgk12_vs_lgk8_bench.nxsketch_hll_packed.nxsketch_hll_packed_test.nxsketch_hll_packed_vs_hll8_bench.nxsketch_hll_provenance.nxsketch_hll_provenance_v2.nxsketch_hll_test.nxsketch_hll_vs_materialized_set_bench.nxsketch_hllmap.nxsketch_hllmap_merge_capability_bench.nxsketch_hllmap_test.nxsketch_holt.nxsketch_holt_test.nxsketch_holt_vs_ewma_trended_bench.nxsketch_kll.nxsketch_kll_test.nxsketch_kll_vs_reservoir_bench.nxsketch_kmeans1d.nxsketch_kmeans1d_test.nxsketch_kmv.nxsketch_kmv_jaccard_vs_naive_bench.nxsketch_kmv_test.nxsketch_lc_vs_hll_small_n_bench.nxsketch_linear_counter.nxsketch_linear_counter_test.nxsketch_lossy_counting.nxsketch_lossy_counting_test.nxsketch_mann_kendall.nxsketch_mann_kendall_test.nxsketch_mann_kendall_vs_endpoint_bench.nxsketch_markov.nxsketch_markov_test.nxsketch_markov_vs_uniform_bench.nxsketch_mg_ss_bracket_bench.nxsketch_min_heap.nxsketch_misra_gries.nxsketch_misra_gries_test.nxsketch_moments.nxsketch_moments_test.nxsketch_naive_bayes.nxsketch_naive_bayes_test.nxsketch_naive_bayes_vs_majority_bench.nxsketch_observability_dashboard_bench.nx +40 more (shown cap 100 declared)

structs

65struct ApproxI64 {

consts

28const NX_MATURITY_THEORETICAL: i64 = 0
29const NX_MATURITY_REFERENCE_IMPL: i64 = 1
30const NX_MATURITY_PRODUCTION: i64 = 2
38const NX_ADV_HONEST: i64 = 0
39const NX_ADV_ADVERSARIAL: i64 = 1
52const NX_ENV_REL_STDDEV: i64 = 0
53const NX_ENV_RANK_ERROR: i64 = 1
54const NX_ENV_ABS: i64 = 2
55const NX_ENV_REL_RANK_ERROR: i64 = 3 // |rank_est - rank_true| <= eps * min(rank, N-rank)

functions

75func nx_approx_new(value: i64, envelope_kind: i64, param_a: i64,