Watch
0
0
Fork
You've already forked hyperhive
0

drop the hive-side matrix code: sweep, hivectl matrix and the apiUrl option

This commit is contained in:
damocles 2026-10-28 22:16:16 +01:00 • committed by mara
commit 6dbb18b6d4

View file

@ -11,12 +11,11 @@ use hive_jobq::NodeId;
use hive_jobq::scheduler::Scheduler;
use super::{
Host, dispatch, drift, matrix_sweep_warning, run_create, run_destroy_bookkeeping,
run_destroy_container, run_drain, run_emit_rebuilt, run_forge_sweep, run_knowledge_pull,
run_matrix_sweep, run_meta_sync, run_pause_drain, run_pause_signal, run_prebuild,
run_provision, run_purge_state, run_rebuild_bookkeeping, run_reconcile, run_set_wanted,
run_signal, run_start, run_stop, run_stop_for_update, run_swap, run_wanted_pull,
run_write_dropin, substitute,
Host, dispatch, drift, run_create, run_destroy_bookkeeping, run_destroy_container, run_drain,
run_emit_rebuilt, run_forge_sweep, run_knowledge_pull, run_meta_sync, run_pause_drain,
run_pause_signal, run_prebuild, run_provision, run_purge_state, run_rebuild_bookkeeping,
run_reconcile, run_set_wanted, run_signal, run_start, run_stop, run_stop_for_update, run_swap,
run_wanted_pull, run_write_dropin, substitute,
};
use crate::coordinator::{AgentPaths, Coordinator, HiveEnv};
use crate::job_queue::model::NodeKind;
@ -43,8 +42,7 @@ struct FakeHost {
/// Store paths a prebuild had to build because the store lacked them.
builds: Mutex<Vec<String>>,
/// Names of the calls that fail (`kill`, `realise`, `prebuild`, `swap_update`,
/// `set_paused`, ...). `recorded_build` fails by finding nothing and
/// `matrix_ensure_all` by reporting false.
/// `set_paused`, ...). `recorded_build` fails by finding nothing.
failing: Vec<&'static str>,
/// The sweeps and pulls never finish, so only a deadline ends them.
hang: bool,
@ -277,14 +275,6 @@ impl Host for FakeHost {
self.record("forge_ensure_all".to_owned());
}
async fn matrix_ensure_all(&self) -> bool {
self.record("matrix_ensure_all".to_owned());
if self.hang {
std::future::pending::<()>().await;
}
!self.fails("matrix_ensure_all")
}
async fn knowledge_pull(&self, _coord: &Arc<Coordinator>) -> anyhow::Result<()> {
if self.hang {
std::future::pending::<()>().await;
@ -1088,31 +1078,6 @@ async fn forge_sweep_runs_once_and_never_fails() {
assert_eq!(host.calls(), ["forge_ensure_all"]);
}
#[tokio::test]
async fn matrix_sweep_fails_the_node_when_an_agent_failed_sync() {
run_matrix_sweep(&FakeHost::up(), Duration::from_secs(5))
.await
.expect("ok");
let err = run_matrix_sweep(
&FakeHost::up().failing("matrix_ensure_all"),
Duration::from_secs(5),
)
.await
.expect_err("failed sync");
assert!(format!("{err:#}").contains("failed sync"), "{err:#}");
}
#[tokio::test]
async fn matrix_sweep_past_its_deadline_fails_instead_of_hanging() {
let host = FakeHost {
hang: true,
..FakeHost::up()
};
run_matrix_sweep(&host, Duration::from_millis(50))
.await
.expect_err("deadline");
}
#[tokio::test]
async fn knowledge_pull_passes_the_result_through_and_times_out() {
let (_dir, coord) = coordinator();
@ -1274,7 +1239,6 @@ async fn dispatch_routes_the_agentless_and_hostless_kinds() {
NodeKind::ForgeSweep,
NodeKind::WantedPull,
NodeKind::KnowledgePull,
NodeKind::MatrixSweep,
alice(|agent| NodeKind::AgentWindow { agent }),
alice(|agent| NodeKind::Signal { agent }),
alice(|agent| NodeKind::Drain { agent }),
@ -1292,12 +1256,7 @@ async fn dispatch_routes_the_agentless_and_hostless_kinds() {
);
}
let calls = host.calls();
for want in [
"forge_ensure_all",
"wanted_pull",
"knowledge_pull",
"matrix_ensure_all",
] {
for want in ["forge_ensure_all", "wanted_pull", "knowledge_pull"] {
assert!(calls.iter().any(|c| c == want), "{want} in {calls:?}");
}
}
@ -1511,22 +1470,3 @@ async fn purge_keeps_going_past_a_dir_it_cannot_remove() {
assert!(stuck.exists(), "remove_dir_all refuses a plain file");
assert!(!applied.exists());
}
#[test]
fn matrix_sweep_warning_says_how_long_it_has_been_failing() {
use crate::stats::sweep_health::SweepFailure;
let never = matrix_sweep_warning(SweepFailure {
consecutive: 3,
since_last_ok: None,
});
assert!(
never.contains("3 consecutive, no success this session"),
"{never}"
);
let after_ok = matrix_sweep_warning(SweepFailure {
consecutive: 2,
since_last_ok: Some(Duration::from_secs(90)),
});
assert!(after_ok.contains("2 consecutive, last ok "), "{after_ok}");
assert!(!after_ok.contains("no success"), "{after_ok}");
}