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
//! Machine-tier detection and the proportional memory budget every trusty-*
//! daemon sizes itself from (#6820).
//!
//! Why: the suite's supported-hardware bar is "24 GB supported, 16 GB minimum,
//! documented degrade below" (epic #6802). Enforcing that needs ONE place that
//! answers "how much RAM is really available here" and "how many MB may I hold".
//! `trusty-search` had that code privately in `core::memory_policy`;
//! `trusty-memory` had none of it and sized its palace cap off a fixed 64
//! regardless of the host, so the two daemons could not agree on the machine
//! they shared. A second copy of these formulas is a defect — see CLAUDE.md,
//! "Common entry point, clean domain demarcation".
//! What: `detect_total_ram_mb` (the cgroup-aware RAM read), `MemoryTier`
//! (the 16/32/64 GB bands plus the new sub-16 GB `MemoryTier::Degraded`
//! posture), the four proportional formulas, and `MachineBudget` which ties
//! them together. Every number is moved verbatim from `trusty-search`, so a
//! 16/32/64/128 GB host resolves exactly as it did before; the only behaviour
//! change is that below 16 GB now names a tier instead of aborting startup.
//! What this module is NOT: per-daemon tunables. Chunk caps, embedding caches,
//! palace caps, and their env-var overrides stay in the daemon that owns them —
//! `trusty-search`'s `MemoryPolicy` layers on top of `MachineBudget`.
//! Nor is it live telemetry: `host_metrics` samples current CPU/memory
//! pressure through `sysinfo` and applies no cgroup clamp, which is a different
//! question from the one-shot startup budget answered here.
//! Test: `cargo test -p trusty-common --features machine-tier --no-fail-fast`.
pub use MachineBudget;
pub use ;
pub use ;
pub use detect_total_ram_mb;
pub use MemoryTier;