Skip to main content

Crate oomtop_core

Crate oomtop_core 

Source
Expand description

§oomtop-core

Pure core of oomtop (SPEC §6): the data model, units, Measured<T>, attribution matching, headroom, can_fit, model-load estimates, OOM forecast, throttle, why, redaction, query understanding, ranking, headline generation and situation modes. No I/O — everything is a pure function over snapshots, so it is fully unit-testable with fixtures and golden files.

Module ↔ spec map:

modulespec
modelSPEC §5 (FROZEN)
measured, unitsSPEC §5, UX §12.5
headroomSPEC §8.1
can_fitSPEC §8.2
model_estimateSPEC §8.2 (GGUF header parser)
history, forecastSPEC §6.2, §8.3
attributionSPEC §7
idleSPEC §7 (idle/orphan)
stalenessSPEC §5 (time fields), §7 (staleness, cohorts, duplicates)
netSPEC §5 (network), §13 (ports, links, exposure)
pivotSPEC §7 (pivot grouping)
limits, cluster, namespacesSPEC §8.3 (per-limit forecast), §11 (containers, clusters, VM slack, namespaces)
fingerprintUX §4
throttle, whySPEC §9
redactSPEC §13
actionsSPEC §7, §13
queryUX §5.2
rankingUX §5.4
headlineUX §9
machineUX §2 (machine display name)
modesUX §3
providerfrontend contracts (docs/CONTRACTS.md)

Re-exports§

pub use model::*;

Modules§

actions
Action planning and protection rules (SPEC §7 “actions target group roots”, §13 safety). Pure: the frontends build an ActionPlan; an Actuator (implemented in the CLI from oomtop-collect::signal and oomtop-adapters gentle actions) executes it after explicit confirmation.
attribution
Attribution (SPEC §7): group every process under the agent session, app, sandbox, model server, build daemon or system component that owns it. Pure: works over a Snapshot, compiled rules and lineage data.
can_fit
can_fit(need) → yes | yes_after_reclaim(list, gain) | no(shortfall), plus CLI exit codes (SPEC §8.2).
cluster
Containers, local Kubernetes and VM slack (SPEC §8.3, §11). Pure: inputs come from the snapshot (processes and their cgroup paths, Snapshot::cgroups, sandboxes) and from the adapters (Isolation::containers from the container engines, Isolation::kube / Isolation::kube_contexts from the optional Kubernetes adapter); IsolationTracker::update derives everything else:
fingerprint
Entity fingerprints (UX §4): hash(kind, exe_basename, cmdline_template, project_root?, bundle_id?).
forecast
OOM forecast (SPEC §8.3): which killer applies, its thresholds, a linear-trend ETA, the likely victim and recent kills — all pure functions over history, config text and snapshots.
headline
Headline sentence (UX §9): template-based, deterministic, one line, with the one best action key.
headroom
Headroom (SPEC §8.1): headroom = available_now − safety_margin, GPU budget, reclaim gain.
history
In-memory history ring buffer (SPEC §6.2): last 10 minutes, compact, for sparklines, trends and the OOM forecast. Pure data structure; the sampler owner pushes one point per host sample.
idle
Idle and orphan detection (SPEC §7).
limits
Per-limit OOM forecast (SPEC §8.3 “Per-limit forecast”): every container, pod, cgroup or engine VM that has a memory limit gets usage, limit, percent, growth, an ETA with confidence and its OOM kills.
machine
Human machine names (UX §2 “MacBook Air M5 · 24 GB unified”): the collector reports the raw hardware identifier (hw.model, e.g. Mac17,3), which is not what people call their machine.
measured
Helpers for Measured<T> and Quality (SPEC §5: every number carries source + quality).
model
The oomtop data model (SPEC §5). FROZEN: additive changes only.
model_estimate
Model-load estimate (SPEC §8.2): pure parsers for GGUF headers, safetensors headers/indexes and Hugging Face config.json, and the estimate formulas.
modes
Situation modes (UX §3): Calm · Pressure · Throttle · Working · Leftovers. Adaptive, not personalized.
namespaces
Linux namespace sets (SPEC §11 “Namespaces”): processes grouped by the namespaces they live in, relative to oomtop’s own. Any process that does not share oomtop’s pid / net / mount / user / uts / ipc / cgroup namespaces is in some kind of sandbox — a container, bwrap/Flatpak, unshare, a browser renderer sandbox — so a sandbox that no engine rule knows still shows up, with its member count, memory and owner. Identities are the inode numbers of the /proc/<pid>/ns/* links (net:[4026531840]), readable for the user’s own processes without privileges. macOS has no namespaces.
net
Ports and “who talks to whom” (SPEC §5 “Network”, §13). Pure: everything here is computed from the sockets the collectors recorded (Snapshot::net.sockets) plus the attributed groups.
pivot
Pivot grouping (SPEC §7): regroup a snapshot’s groups by owner, project, kind, sandbox or cohort and total each bucket. Pure — the project of a group is whatever the collectors resolved (Group::project: git root of the cwd, else the cwd); nothing here walks the filesystem.
provider
Frontend-facing traits. Frontends (tui, mcp, serve) never touch OS APIs: they receive a SnapshotProvider (and optionally an crate::actions::Actuator) built by oomtop-cli.
query
Query understanding (UX §5.2): one engine for / filters, : commands and the Ctrl-K palette.
ranking
Ranking (UX §5.4) and frecency (UX §5.1).
redact
Privacy (SPEC §13): command-line redaction for exports, the marker-key allowlist, and marker hashing.
staleness
“How long, how stale” (SPEC §5 time fields, §7 staleness). Pure: everything here is a function of one Snapshot, a StalenessConfig and what the caller knows about ended agent sessions.
throttle
Throttle factor (SPEC §9): observed ÷ max frequency per cluster/GPU, computed only while that unit is busy (active residency ≥ 50 %); otherwise n/a (idle). Blended by utilization (residency-weighted mean over busy units). Apple Silicon down-clocks at idle, so idle must never read as throttling.
units
Units: parsing and formatting of sizes, durations and percentages (SPEC §12.2, UX §5.2, UX §12.5).
why
oomtop why / MCP explain_slowdown (SPEC §9): ranked likely causes of slowness / memory trouble, each with evidence lines (“swap in +600M/min for 5m”, “GPU at 42% of max clock with thermal pressure heavy”, “Low Power Mode on”, “on battery at 29%”) and, where there is one, a concrete fix.

Constants§

VERSION
Crate version (also the oomtop --version).