polydat_core/library/mod.rs
1// Copyright 2024-2026 Jonathan Shook
2// SPDX-License-Identifier: Apache-2.0
3
4//! Standard Polydat function-node library + sampling primitives + library-internal support.
5//!
6//! - Function-node modules (`arithmetic`, `string`, `hash`, …):
7//! the 250+ built-in [`crate::ast::PolydatNode`] implementations
8//! workload authors compose into kernels.
9//! - `polydat_nodes::sampling`: alias tables, LUT interpolation, ICD —
10//! variate-sampling building blocks consumed by
11//! distribution-emitting nodes (weighted, probability, etc.).
12//! - [`support`]: library-internal infrastructure
13//! ([`support::cache`], [`support::audit`]) used by nodes
14//! like `vectors` for caching dataset handles and
15//! diagnosing data-source mismatches.
16
17pub mod support;
18
19pub mod assertions;
20pub mod context;
21pub mod convert;
22pub mod datafile;
23pub mod diagnostic;
24pub mod exactly_one;
25pub mod fixed;
26pub mod format;
27pub mod identity;
28pub mod json;
29pub mod log_levels;
30pub mod polyfill;
31pub mod polyfill_128;
32pub mod polyfill_complete;
33pub mod polyfill_narrow;
34pub mod register_view;
35#[cfg(test)]
36mod test_nodes;
37pub mod tile_render;
38#[cfg(feature = "vectordata")]
39pub mod vectors;
40
41/// Env-gated debug-level diagnostic for selection / matching nodes.
42///
43/// Returns true when `NBRS_DEBUG_NODES` is set to a non-empty,
44/// non-`"0"` value. Cached on first read so the variable can be set
45/// once at process start and the per-cycle check is a load.
46///
47/// Used by `regex_match`, `exactly_one_value`, and `pick` to emit
48/// pre-eval / pre-panic context (input shape, match result, selector
49/// states) when probe phases produce surprising values. The user's
50/// expected workflow:
51///
52/// ```sh
53/// NBRS_DEBUG_NODES=1 nbrs run my-workload …
54/// ```
55///
56/// then read the stderr trace to see what each matching node saw.
57pub fn debug_nodes_enabled() -> bool {
58 use std::sync::OnceLock;
59 static ENABLED: OnceLock<bool> = OnceLock::new();
60 *ENABLED.get_or_init(|| {
61 std::env::var("NBRS_DEBUG_NODES")
62 .map(|v| !v.is_empty() && v != "0")
63 .unwrap_or(false)
64 })
65}