Skip to main content

Module config

Module config 

Source
Expand description

Diagnostic-policy and brand-contract resolution from config files and command-line flags.

§Diagnostic policy

The effective diagnostic policy for a validate run is assembled from four sources, in increasing precedence:

  1. global config<config_dir>/zenith/config.kdl
  2. local config — the nearest .zenith.kdl found by walking up from the document’s directory to the filesystem root
  3. in-file policy — the document’s own diagnostics { … } block
  4. CLI flags--allow / --deny / --warn

Because policy resolution is last-wins (see zenith_core::DiagnosticPolicy::verb_for), the four sources are simply concatenated low→high into one policy and applied ONCE. The highest- precedence entry for any given code wins, yielding CLI > in-file > local > global.

§Brand contract

The effective brand contract is merged with per-category override semantics from three sources, in increasing precedence:

  1. global configbrand { … } block in <config_dir>/zenith/config.kdl
  2. local configbrand { … } block in the nearest .zenith.kdl
  3. in-file brand — the document’s own brand { … } block

For each category (colors, fonts, weights), the highest-precedence source that declares the category wins. Absent categories in a higher- precedence source do not erase the same category from a lower-precedence source. See zenith_core::merge_brand_contract.

All loaders are path-injectable so tests can point them at temp directories without mutating process-global state ($HOME, cwd). The production load_global_policy resolves the config directory from $HOME exactly as crate::commands resolves user-scope paths elsewhere in the CLI.

Structs§

CliPolicyFlags
CLI-supplied policy adjustments, one bucket per verb. Each String is a diagnostic code. Order within a bucket and across buckets is allow → warn → deny so a later flag of a different verb for the same code still wins via last-wins resolution; entries are appended at the highest precedence.

Functions§

find_local_brand
Walk up from start_dir to the filesystem root, loading the brand { … } block from the first .zenith.kdl found. If none is found, or the found file has no brand node, returns BrandContract::default.
find_local_policy
Walk up from start_dir to the filesystem root, loading the first .zenith.kdl found. If none is found, returns DiagnosticPolicy::default.
load_brand_file
Load a brand contract from a KDL config file.
load_global_and_local
Load the global and local policies and brand contracts for a command run.
load_global_brand
Load the global brand contract from $HOME/.config/zenith/config.kdl.
load_global_brand_in
Load the global brand contract from <config_dir>/zenith/config.kdl.
load_global_policy
Load the global policy from $HOME/.config/zenith/config.kdl.
load_global_policy_in
Load the global policy from <config_dir>/zenith/config.kdl.
load_policy_file
Load a diagnostic policy from a KDL config file.
merge_policy
Merge the four policy tiers into one DiagnosticPolicy.