Stops explicitly allowlisted systemd --user units when available memory drops below a threshold, so a heavy job (mutation testing, a push hook) doesn't have to compete with restartable background services for RAM. Allowlist-only, never a heuristic 'kill the top memory consumer' -- an unlisted process is never touched. Dry-run unless --apply is passed.
| Tier | operations |
| Role | unclassified (baselined) |
| Path | crates/operations/mem-reaper |
| Edition | 2021 |
| Targets | operations-mem-reaper, operations_mem_reaper |
| Public items | 5 across 0 modules |
| Tests | 7 |
What it is for
Pure decision logic for operations-mem-reaper: given an explicit allowlist and the current available-memory reading, decide which systemd --user units to stop. No process spawning here (Gate 2.1) -- main.rs is the only part that calls systemctl.
Safety model: allowlist-only. There is no "kill the top memory consumer" heuristic anywhere in this crate -- a unit not named in the config is never a candidate, full stop. The allowlist ships empty; the operator opts each unit in explicitly with a stated reason, because only the operator knows which of their own services are actually restartable without losing state.
Capabilities
crate root
Pure decision logic for operations-mem-reaper: given an explicit allowlist and the
| Item |
|---|
fn parse_mem_available_kb(meminfo_text : & str) -> Option <u64> |
fn units_to_stop(allowlist : & Allowlist, available_kb : u64, threshold_kb : u64,) -> Vec <AllowlistEntry> |
Allowlist
Pure decision logic for operations-mem-reaper: given an explicit allowlist and the
| Item |
|---|
pub struct Allowlist |
fn parse_allowlist(toml_text : & str) -> Result <Allowlist, String> |
AllowlistEntry
Pure decision logic for operations-mem-reaper: given an explicit allowlist and the
| Item |
|---|
pub struct AllowlistEntry |
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
No public modules: the crate root is its whole surface.
Public surface
`crate root`
| Item | What it is |
|---|---|
pub struct AllowlistEntry | — |
pub struct Allowlist | — |
fn parse_allowlist(toml_text : & str) -> Result <Allowlist, String> | — |
fn parse_mem_available_kb(meminfo_text : & str) -> Option <u64> | Parses the MemAvailable: line out of /proc/meminfo text (the kernel's own estimate of memory available for new allocations without swapping, which is what matters here -- not raw MemFree). |
fn units_to_stop(allowlist : & Allowlist, available_kb : u64, threshold_kb : u64,) -> Vec <AllowlistEntry> | Decides which allowlisted units to stop |
No pub use re-exports: every item above is declared in this crate.
Boundary
Depends on no other workspace tier.
Shares tier operations with 40 other crates: operations-approval-workflow, operations-assessments, operations-block-imaging, operations-boot-media, operations-browser-agent-worker, operations-camera-discovery, operations-camera-liveview, operations-camera-registry, … (40 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | operations |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/operations/mem-reaper |
| Vocabulary in force (lexicon) | current |
Dependencies
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
anyhow | ^1 | — | no | always |
serde | ^1 | derive | no | always |
toml | ^0.8 | — | no | always |
Development. None.
Build. None.
Depended on by. Nothing in this workspace.
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| bin | operations-mem-reaper | `src/main.rs` |
| lib | operations_mem_reaper | `src/lib.rs` |
Error model
No public error type was detected: no public item declares a type named *Error, and no public signature returns one.
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | none detected |
| database access | none detected |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | none detected |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.
Related capabilities
No workspace crate depends on this one.
Verification
| Kind | Count |
|---|---|
| Unit tests | 7 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
crate root | 5 | 0 | 0 |
What the tests establish, by name:
does_not_stop_when_above_threshold—src/lib.rsempty_allowlist_never_stops_anything_even_under_pressure—src/lib.rsmissing_mem_available_line_yields_none—src/lib.rsparses_allowlist_toml—src/lib.rsparses_mem_available_from_real_proc_meminfo_format—src/lib.rsrejects_entry_missing_required_reason—src/lib.rsstops_allowlisted_units_when_below_threshold—src/lib.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 2 | 5 |
Public modules with a //! block | 0 | 0 |
pie showData
title Public items with rustdoc
"Documented" : 2
"No rustdoc detected" : 3
Metrics
| Metric | Value |
|---|---|
| Rust source files | 2 |
| Source lines | 224 |
| Code lines | 176 |
| Public API items | 5 |
| Public modules | 0 |
| Tests | 7 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 3 |
| Workspace reverse dependencies | 0 |
pie showData
title Public API by kind
"function" : 3
"struct" : 2
pie showData
title Rust source composition
"Code" : 176
"Blank or comment" : 48
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.