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:
- global config —
<config_dir>/zenith/config.kdl - local config — the nearest
.zenith.kdlfound by walking up from the document’s directory to the filesystem root - in-file policy — the document’s own
diagnostics { … }block - 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:
- global config —
brand { … }block in<config_dir>/zenith/config.kdl - local config —
brand { … }block in the nearest.zenith.kdl - 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§
- CliPolicy
Flags - CLI-supplied policy adjustments, one bucket per verb. Each
Stringis 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_dirto the filesystem root, loading thebrand { … }block from the first.zenith.kdlfound. If none is found, or the found file has nobrandnode, returnsBrandContract::default. - find_
local_ policy - Walk up from
start_dirto the filesystem root, loading the first.zenith.kdlfound. If none is found, returnsDiagnosticPolicy::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.