Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(scheduler-gate): delegate battery sampling to tinymemory-gate

Steven Enamakelf9f87c341ed4
diff --git a/Cargo.lock b/Cargo.lock
index f2fa9e109d..bcd91982e8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4027,7 +4027,6 @@ dependencies = [
"serde_repr",
"serde_yaml",
"sha2 0.10.9",
- "starship-battery",
"sysinfo 0.33.1",
"tar",
"tempfile",
@@ -4070,6 +4069,7 @@ dependencies = [
"tinymemory-bus",
"tinymemory-conformance",
"tinymemory-conversations",
+ "tinymemory-gate",
"tinymemory-guard",
"tinymemory-safety",
"tinymemory-sources",
@@ -7028,6 +7028,18 @@ dependencies = [
"uuid",
]
+[[package]]
+name = "tinymemory-gate"
+version = "0.1.0"
+dependencies = [
+ "log",
+ "parking_lot",
+ "starship-battery",
+ "sysinfo 0.33.1",
+ "tinymemory-api",
+ "tokio",
+]
+
[[package]]
name = "tinymemory-guard"
version = "0.1.0"
@@ -7073,6 +7085,7 @@ dependencies = [
"async-trait",
"chrono",
"futures",
+ "log",
"regex",
"reqwest",
"schemars",
diff --git a/crates/openhuman-core/Cargo.toml b/crates/openhuman-core/Cargo.toml
index eca0ee5525..5b5a169031 100644
--- a/crates/openhuman-core/Cargo.toml
+++ b/crates/openhuman-core/Cargo.toml
@@ -518,11 +518,12 @@ tempfile = "3"
enigo = { version = "0.3", optional = true }
arboard = { version = "3", optional = true }
fs2 = "0.4"
-# Cross-platform battery probe for the scheduler gate. Maintained fork of
-# the abandoned `battery` crate; same `use battery::*;` API surface. Used
-# only by `openhuman::scheduler_gate::signals` to decide when to throttle
-# background LLM work on laptops.
-starship-battery = { version = "0.10", optional = true }
+# The scheduler gate: host power/CPU sampling and the cooperative wait that
+# keeps background LLM work from lagging a laptop. The cross-platform battery
+# probe (`starship-battery`) is its `battery` feature, forwarded by this crate's
+# `scheduler-gate` feature. The process-wide wiring stays in
+# `cron::scheduler_gate`.
+tinymemory-gate = { path = "../../vendor/tinymemory/crates/tinymemory-gate" }
# Multi-chain wallet signing.
# - bitcoin: P2WPKH PSBT build/sign/broadcast (includes secp256k1).
# - ed25519-dalek: Solana transaction signing.
@@ -1250,7 +1251,7 @@ rss-bench = []
# `tracing` and `tracing-subscriber` are NOT part of this gate and stay always-on.
file-logging = ["dep:tracing-appender", "dep:tracing-log"]
-scheduler-gate = ["dep:starship-battery"]
+scheduler-gate = ["tinymemory-gate/battery"]
[lints.rust]
diff --git a/crates/openhuman-core/src/cron/scheduler_gate/gate_tests.rs b/crates/openhuman-core/src/cron/scheduler_gate/gate_tests.rs
index cf9990a9c9..69e38df5c8 100644
--- a/crates/openhuman-core/src/cron/scheduler_gate/gate_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler_gate/gate_tests.rs
@@ -5,7 +5,7 @@
//! `available_permits` reads.
use super::*;
use std::sync::Mutex;
-use std::time::Instant;
+use std::time::{Duration, Instant};
use tokio::time::{timeout, Duration as TokioDuration};
static GATE_TEST_LOCK: Mutex<()> = Mutex::new(());
@@ -243,13 +243,8 @@ async fn resume_transitions_fire_the_notify() {
mode: SchedulerGateMode::Off,
..Default::default()
};
- let signals = signals::sample();
- let policy = decide(&signals, &cfg);
- let _ = STATE.set(Arc::new(RwLock::new(State {
- cfg,
- signals,
- policy,
- })));
+ let signals = tinymemory_gate::sample(&SIGNAL_ENV);
+ let _ = STATE.set(Arc::new(RwLock::new(GateCore::new(cfg, signals))));
// --- update_config: Paused -> running fires the notify ---
let waiter = resume_notify();