Expand description
Global bhtune configuration, including the shared [tuning] timing policy and the
CLI flag > env var > TOML config file > built-in default precedence used by settings
that expose command-line or environment overrides.
Structs§
- Bhtune
Config - bhtune’s configuration, loaded from an optional TOML file. Every field is optional; a
value missing from the file (or the file itself missing) falls back to the env var / CLI
flag / built-in default resolution in the
resolve_*functions below. - Config
Path Resolution - Path-resolution result for the TOML config store: either an explicit
--configpath or the auto-discovered default, plus whether a missing file is acceptable at that tier. - Config
Policy Update - Config-page-owned settings that can be patched in place while preserving every unrelated key and comment in the source TOML.
- Config
Save Result - Result of safely saving a patched TOML config file.
- Demo
Policy - Limits applied to the public simulator-only demo surface.
- Demo
Policy Config - Optional declarations of the fixed
DemoPolicycontract. - Effective
Tuning Config - Concrete tuning timing policy after absent TOML keys have received built-in defaults.
- Loaded
Config Store - A path-aware TOML config snapshot suitable for server-side read/modify/write flows.
- LogConfig
- Logging configuration keys (a
[log]table inbhtune.toml), consumed bycrate::logging::resolve_log_settings. Every field is optional and falls back through the sameCLI flag > env var > config file > defaultprecedence as the rest ofBhtuneConfig. - Tuning
Config - Optional values authored in the
[tuning]table. - Tuning
Config Sources - Per-field provenance for the effective
[tuning]policy.
Enums§
- Config
Store Error - Typed errors for the path-aware TOML config store used by the server config page.
- Server
Mode - Runtime server exposure mode. Full mode preserves the normal live-plant API; Demo mode is an explicitly restricted, simulator-only surface intended for public demonstrations.
- Tuning
Config Error - Validation error for concrete tuning timing values.
- Tuning
Config Source - Origin of one effective tuning value.
Constants§
- DEFAULT_
BIND_ ADDR - Default address
bhtune-serverbinds to when nothing else specifies one – loopback only, matching the “v1 binds to127.0.0.1by default” decision in AGENTS.md. Lives alongsideDEFAULT_BRIDGE_HOSTin this shared config module (rather than inbhtune-serveritself) even though only the server binary ever callsresolve_bind_addr, the same waytemplates/logbelow are settings only some commands consume – onebhtune.tomlfile and one precedence chain for every bhtune setting, CLI or server. - DEFAULT_
BRIDGE_ HOST - Default opcda-bridge gateway address bhtune connects to when nothing else specifies one.
- DEFAULT_
TUNING_ MRFT_ DELAY_ SECS - Built-in pre/post-MRFT recording padding when
[tuning].mrft_delay_secsis absent. - DEFAULT_
TUNING_ OP_ TIMEOUT_ SECS - Built-in per-driver-operation timeout when
[tuning].op_timeout_secsis absent. - DEFAULT_
TUNING_ POLL_ INTERVAL_ MS - Built-in driver polling interval when
[tuning].poll_interval_msis absent. - DEFAULT_
TUNING_ RESTORE_ TIMEOUT_ SECS - Built-in post-run restoration timeout when
[tuning].restore_timeout_secsis absent. - DEFAULT_
TUNING_ TIMEOUT_ SECS - Built-in whole-run timeout when
[tuning].timeout_secsis absent. - DEMO_
ACCEPTED_ STARTS_ PER_ CLIENT_ IP - Accepted Demo tune starts allowed for one client IP in a quota window.
- DEMO_
ACCEPTED_ STARTS_ PER_ TOKEN - Accepted Demo tune starts allowed for one session token in a quota window.
- DEMO_
ACCEPTED_ START_ WINDOW_ SECS - Fixed window used by the accepted-start quotas.
- DEMO_
CLEANUP_ INTERVAL_ SECS - Interval between expired-session and excess-history cleanup passes.
- DEMO_
COOKIE_ NAME - Name of the host-only anonymous Demo session cookie.
- DEMO_
CYCLES_ COUNT_ DEFAULT - Default relay-cycle count used by the Demo form.
- DEMO_
CYCLES_ COUNT_ MAX - Maximum relay-cycle count accepted by the public Demo.
- DEMO_
CYCLES_ COUNT_ MIN - Minimum relay-cycle count accepted by the public Demo.
- DEMO_
CYCLES_ SKIP_ DEFAULT - Default relay-cycle skip count used by the Demo form.
- DEMO_
CYCLES_ SKIP_ MAX - Maximum relay-cycle skip count accepted by the public Demo.
- DEMO_
CYCLES_ SKIP_ MIN - Minimum relay-cycle skip count accepted by the public Demo.
- DEMO_
MAX_ ACTIVE_ RUNS_ GLOBAL - Maximum number of Demo tunes that may be active across all visitors.
- DEMO_
MAX_ ACTIVE_ RUNS_ PER_ VISITOR - Maximum number of Demo tunes that may be active for one visitor.
- DEMO_
MAX_ JSON_ BODY_ BYTES - Maximum JSON request-body size accepted by the Demo API.
- DEMO_
MAX_ RUNS_ PER_ SESSION - Maximum accepted demo runs retained per session, independent of active-run concurrency.
- DEMO_
MAX_ SSE_ GLOBAL - Maximum number of simultaneous Demo SSE streams across all visitors.
- DEMO_
MAX_ SSE_ PER_ VISITOR - Maximum number of simultaneous SSE streams for one visitor.
- DEMO_
MAX_ TUNE_ RUN_ ROWS_ GLOBAL - Maximum number of current Demo-owned
tune_runsrows in the database. - DEMO_
NOISE_ PROTECTION_ SECS_ DEFAULT - Default switch noise-protection delay used by the Demo form.
- DEMO_
NOISE_ PROTECTION_ SECS_ MAX - Maximum switch noise-protection delay accepted by the public Demo.
- DEMO_
NOISE_ PROTECTION_ SECS_ MIN - Minimum switch noise-protection delay accepted by the public Demo.
- DEMO_
ORDINARY_ REQUEST_ CONCURRENCY - Maximum number of ordinary Demo API requests processed concurrently.
- DEMO_
ORDINARY_ REQUEST_ TIMEOUT_ SECS - Timeout applied to an ordinary, non-streaming Demo API request.
- DEMO_
POLL_ INTERVAL_ MS - Fixed simulator polling interval used by public Demo tunes.
- DEMO_
RANGE_ ENDPOINT_ MAX - Maximum PV/MV range endpoint accepted by the public Demo.
- DEMO_
RANGE_ ENDPOINT_ MIN - Minimum PV/MV range endpoint accepted by the public Demo.
- DEMO_
RANGE_ HIGH - Default PV and MV upper bound used by public Demo runs.
- DEMO_
RANGE_ LOW - Default PV and MV lower bound used by public Demo runs.
- DEMO_
RANGE_ SPAN_ MAX - Maximum PV/MV span accepted by the public Demo.
- DEMO_
RANGE_ SPAN_ MIN - Minimum PV/MV span accepted by the public Demo.
- DEMO_
RELAY_ AMP_ DEFAULT - Default relay amplitude used by the Demo form.
- DEMO_
RELAY_ AMP_ MAX - Maximum relay amplitude accepted by the public Demo.
- DEMO_
RELAY_ AMP_ MIN - Minimum relay amplitude accepted by the public Demo.
- DEMO_
RETAINED_ RUNS_ PER_ VISITOR - Maximum number of completed Demo runs retained for one visitor.
- DEMO_
RUN_ TIMEOUT_ SECS - Fixed whole-run timeout used by public Demo tunes.
- DEMO_
SESSION_ TTL_ SECS - Fixed lifetime of an anonymous public Demo visitor session.
- DEMO_
SIM_ DEAD_ TIME_ DEFAULT - Default simulator dead time used by the Demo form.
- DEMO_
SIM_ DEAD_ TIME_ MAX - Maximum simulator dead time accepted by the public Demo.
- DEMO_
SIM_ DEAD_ TIME_ MIN - Minimum simulator dead time accepted by the public Demo.
- DEMO_
SIM_ GAIN_ ABS_ MIN - Minimum non-zero process-gain magnitude accepted by the public Demo.
- DEMO_
SIM_ GAIN_ DEFAULT - Default simulator process gain used by the Demo form.
- DEMO_
SIM_ GAIN_ MAX - Maximum process-gain magnitude accepted by the public Demo.
- DEMO_
SIM_ INITIAL_ VALUE_ DEFAULT - Default simulator PV and MV starting value used by the Demo form.
- DEMO_
SIM_ NOISE_ DEFAULT - Default simulator noise amplitude used by the Demo form.
- DEMO_
SIM_ NOISE_ MAX_ PV_ SPAN_ FRACTION - Maximum simulator noise amplitude as a fraction of the configured PV span.
- DEMO_
SIM_ NOISE_ MIN - Minimum simulator noise amplitude accepted by the public Demo.
- DEMO_
SIM_ SEED_ DEFAULT - Default simulator random seed used by the Demo form.
- DEMO_
SIM_ SEED_ MAX - Largest simulator seed accepted by the public Demo.
- DEMO_
SIM_ TAU_ DEFAULT - Default simulator time constant used by the Demo form.
- DEMO_
SIM_ TAU_ MAX - Maximum simulator time constant accepted by the public Demo.
- DEMO_
SIM_ TAU_ MIN - Minimum simulator time constant accepted by the public Demo.
- DEMO_
SSE_ LIFETIME_ SECS - Absolute lifetime of one Demo SSE stream.
- DEMO_
TAG_ NAME - Fixed persisted/display label used by public Demo runs.
- DEMO_
TEMPLATE_ NAME - Built-in template exposed by the public Demo.
- MAX_
TUNING_ MRFT_ DELAY_ SECS - Largest supported pre/post-MRFT recording delay.
- MIN_
OPC_ RESTORE_ TIMEOUT_ SECS - Minimum restoration timeout for OPC DA runs.
Functions§
- config_
path_ from - Derive bhtune’s config file location from raw environment values rather than reading
std::envdirectly – keeps discovery fully unit-testable across every permutation without mutating real process environment variables. - default_
allow_ uncertain_ quality - The default configuration-page quality policy: absent
allow_uncertain_qualityresolves totruerather thanbool’s usualfalse. - default_
db_ path_ from - Derive bhtune’s default database location the same way config files are discovered, but under the platform’s data directory rather than its config directory – a database is persistent user data, not settings, per the XDG base directory specification.
- default_
log_ dir_ from - Derive bhtune’s default log directory the same way the database path is derived (see
default_db_path_from) – under the platform data directory, not next to the compiled binary. Unlikeopcda-bridge-gateway’s equivalent (log_dir_from_exe), acargo installed binary’s own directory (e.g.~/.cargo/bin/) isn’t a sensible place to write logs, and bhtune already has this exact precedence machinery for the database, so the log directory reuses it rather than inventing a second convention. - load_
config - Resolve and load the bhtune config: an explicit
--configpath if given, otherwise the platform’s auto-discovered path (silently falls back to defaults if none of the relevant environment variables are set, or if the discovered file doesn’t exist). - load_
config_ file - Load a bhtune config from
path. - load_
config_ store - Load the path-aware TOML config store using real environment-based auto-discovery.
- load_
config_ store_ from - Load the path-aware TOML config store using injected path-discovery inputs so every resolution branch stays unit-testable without mutating process-global environment variables.
- load_
user_ templates - Resolve and load the user-supplied DCS/PLC template catalog (
template-user-catalog):--templates/BHTUNE_TEMPLATES(already folded intocli_templatesby clap’senvattribute) / the config file’stemplateskey, or else the platform’s auto-discoveredtemplates.tomlnext tobhtune.toml(seetemplates_path_from) –CLI flag > env var > config file > platform default, the same precedence chain as every other bhtune setting. - parse_
config_ contents - Parses the in-memory TOML representation of a config file.
- patch_
allow_ uncertain_ quality - Patch only
allow_uncertain_qualitywhile preserving every unrelated key, comment, and formatting detail the source document already had. - patch_
retention_ days - Patch only
retention_dayswhile preserving every unrelated key, comment, and formatting detail the source document already had.Noneremoves the key entirely. - patch_
tuning_ config - Patch all five
[tuning]values while preserving unrelated keys, comments, and formatting. ANonevalue removes only that key. - resolve_
and_ validate_ tuning_ config - Resolve and validate a raw
[tuning]table in one step. - resolve_
bind_ addr - Resolve
bhtune-server’s bind address withCLI flag > env var > config file > defaultprecedence, matchingresolve_bridge_host’s shape exactly.bhtune-serverhas noclapdependency (see AGENTS.md’s “Deferred setup”), so unlikeresolve_bridge_hostthe env var isn’t folded in by a derive attribute upstream – callers passstd::env::var("BHTUNE_BIND").ok()(or a real CLI flag, if one is ever added) directly ascli_bind. - resolve_
bridge_ host - Resolve the opcda-bridge gateway address with
CLI flag > env var > config file > defaultprecedence. The env var is already folded intocli_hostby clap’senvattribute onTuneArgs::bridge_host/OpcCommand’s per-variantbridge_host. - resolve_
config_ store_ path - Resolve which path the TOML config store should use: an explicit
--configpath if one was provided, otherwise the platform-defaultbhtune.tomllocation fromconfig_path_from. Explicit paths must already exist; an auto-discovered missing file is acceptable and can be created on first save. - resolve_
db_ path - Resolve the database path with
CLI flag > env var > config file > platform defaultprecedence. The env var is already folded intocli_dbby clap’senvattribute onCli::db; the platform-default tier takes its own raw environment values (rather than readingstd::envinternally, likedefault_db_path_from) so this stays fully unit-testable without touching real process environment variables. - resolve_
demo_ policy - resolve_
demo_ policy_ from_ config - resolve_
origin - resolve_
retention_ days - Resolve the history retention policy (
history-retention) withCLI flag > env var > config file > defaultprecedence, matchingresolve_bridge_host’s shape. The env var is already folded intocli_daysby clap’senvattribute onCli::retention_days.Nonemeans retain forever – there is no built-in default number of days; seeBhtuneConfig::retention_daysfor why. - resolve_
server - Resolve the OPC DA server ProgID with
CLI flag > config fileprecedence, erroring if neither is set – there’s no sensible default for which OPC server to talk to. - resolve_
server_ mode - resolve_
tuning_ config - Resolve optional
[tuning]values against the built-in defaults. - save_
config_ store - Safely save the two config-page-managed settings with optimistic-concurrency checks.
- templates_
path_ from - Derive bhtune’s default user template catalog location the same way
config_path_fromderivesbhtune.toml’s – deliberately the same directory, since both are per-user settings a site admin edits by hand, not persistent application data (contrastdefault_db_path_from/default_log_dir_from, which live under the platform data directory instead). Seeload_user_templatesfor how this default fits into the fulltemplate-user-catalogprecedence chain. - tuning_
config_ sources - Report whether each effective tuning value came from TOML or a built-in default.
- validate_
demo_ origin - Validates the exact browser origin used by a public Demo deployment.
- validate_
demo_ trusted_ proxy - Validates a trusted reverse-proxy address before Demo requests may use forwarded client IPs.
- validate_
tuning_ config - Validate concrete tuning timing values.