switchyard/constants.rs
1//! Shared crate-wide constants for Switchyard.
2//!
3//! Centralizes magic values and default labels used across modules.
4//! Adjusting these here will propagate through the crate.
5
6/// Default logical tag used for naming backup artifacts and sidecar files.
7/// Example filenames: `.<name>.<tag>.<millis>.bak` and `.<name>.<tag>.<millis>.bak.meta.json`.
8pub const DEFAULT_BACKUP_TAG: &str = "switchyard";
9
10/// Temporary filename suffix used for atomic symlink swap staging within a directory.
11/// The temporary name is constructed as `.{{fname}}{TMP_SUFFIX}`; e.g., `.ls.switchyard.tmp`.
12pub const TMP_SUFFIX: &str = ".switchyard.tmp";
13
14/// Threshold in milliseconds above which an fsync duration is annotated with a WARN severity
15/// in Audit v2. See `api/apply.rs`.
16pub const FSYNC_WARN_MS: u64 = 50;
17
18/// Poll interval in milliseconds for the file-backed lock manager (see `adapters/lock_file.rs`).
19pub const LOCK_POLL_MS: u64 = 25;
20
21/// Default lock timeout used by `Switchyard::new()` unless overridden by `with_lock_timeout_ms()`.
22pub const DEFAULT_LOCK_TIMEOUT_MS: u64 = 5_000;
23
24/// `UUIDv5` namespace tag for deterministic plan/action IDs.
25/// Derived from SPEC Reproducible v1.1 guidance; see `SPEC/SPEC.md` ยง Determinism.
26pub const NS_TAG: &str = "https://oxidizr-arch/switchyard";
27
28/// Heuristic for rescue tool availability when `BusyBox` is not present.
29/// At least `RESCUE_MIN_COUNT` of the `RESCUE_MUST_HAVE` tools must be found on PATH.
30pub const RESCUE_MUST_HAVE: &[&str] = &[
31 "cp",
32 "mv",
33 "rm",
34 "ln",
35 "stat",
36 "readlink",
37 "sha256sum",
38 "sort",
39 "date",
40 "ls",
41];
42pub const RESCUE_MIN_COUNT: usize = 6;