1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//! Config loading entry point.
//!
//! See [`spec/crates/core.md` § _Config layers_](../../../../spec/crates/core.md#config-layers).
//! Module responsibilities:
//!
//! 1. Best-effort `dotenvy` load of `<config_dir>/.env`. **OS env wins**
//! — `dotenvy::from_path` does not override pre-existing keys, which
//! matches operator expectations (systemd / supervisor unit files
//! are authoritative).
//! 2. Scan `<config_dir>/rules/*.json` for [`RawRuleFile`]s.
//! 3. Read every `VANE_*` deployment constant into a typed [`Env`]
//! snapshot.
//!
// TODO(config-json): parse `<config_dir>/config.json` (global daemon
// settings — listeners, management, wasm pool config). Today this file
// is silently ignored; the daemon's startup wires those values directly
// from the env layer instead.
pub use ;
pub use scan_rules_dir;
use Path;
use crateRawRuleFile;
use crateError;
/// Result of [`load`]: rule files (unmerged) plus the typed `Env`
/// snapshot. Downstream callers thread `files` into
/// [`crate::compile::compile`] and read `env` for deployment constants.
/// Load a vane config directory.
///
/// Order of operations:
///
/// 1. If `<config_dir>/.env` exists, run `dotenvy::from_path` on it.
/// **Pre-existing OS env keys win** — operators who set values via
/// systemd / `EnvironmentFile=` / docker `-e` flag override what's
/// in `.env`. A missing `.env` is not an error; many deployments
/// rely entirely on OS-level env.
/// 2. Scan `<config_dir>/rules/*.json` via [`scan_rules_dir`].
/// 3. Read `VANE_*` deployment constants into [`Env`].
///
/// # Errors
/// - `<config_dir>/rules/` does not exist or is not a directory
/// (propagated from [`scan_rules_dir`]).
/// - Any `.json` under `rules/` fails to parse as `RawRuleFile`.
/// - Any `VANE_*` env var has an invalid value (non-integer, not
/// `"0"`/`"1"` for booleans, malformed `SocketAddr`, etc.).
///
/// **Not** an error:
/// - `.env` file is missing.
/// - `<config_dir>/config.json` is missing or malformed (it is not
/// parsed at this stage).