huskies: merge 1180 story Sled↔gateway goes WS-only: remove the deprecated HTTP fallback paths

This commit is contained in:
Huskies Agent
2026-07-16 18:10:14 +00:00
parent 0e684fb06f
commit de7d22cb9f
13 changed files with 203 additions and 1053 deletions
+2 -29
View File
@@ -190,21 +190,6 @@ pub async fn run_bot(
let notif_room_ids = target_room_ids.clone();
let notif_project_root = project_root.clone();
let announce_room_ids = target_room_ids.clone();
// Clone values needed by the gateway notification poller (only used in gateway mode).
let poller_room_ids: Vec<String> = target_room_ids.iter().map(|r| r.to_string()).collect();
let poller_project_urls: std::collections::BTreeMap<String, String> =
if let Some(ref store) = gateway_projects_store {
store
.read()
.await
.iter()
.filter_map(|(name, entry)| entry.url.clone().map(|url| (name.clone(), url)))
.collect()
} else {
std::collections::BTreeMap::new()
};
let poller_poll_interval = config.aggregated_notifications_poll_interval_secs;
let poller_enabled = config.aggregated_notifications_enabled;
let persisted = load_history(project_root);
slog!(
@@ -371,21 +356,9 @@ pub async fn run_bot(
notif_project_root,
);
// In gateway mode, spawn the cross-project notification poller.
// It polls every registered project's `/api/events` endpoint and forwards
// new events to the configured gateway rooms with a `[project-name]` prefix.
// The poller is controlled by the gateway-level `aggregated_notifications_enabled`
// flag in bot.toml — set it to `false` to disable without touching per-project configs.
if !poller_project_urls.is_empty() && poller_enabled {
crate::gateway::spawn_gateway_notification_poller(
Arc::clone(&transport),
poller_room_ids,
poller_project_urls,
poller_poll_interval,
);
}
// Forwarder task: post gateway events to Matrix rooms with `[project-name]` prefix.
// Project nodes push events over the WS uplink (story 899/1179); the
// gateway no longer polls per-project `/api/events` over HTTP (story 1180).
if let Some(event_rx) = gateway_event_rx_for_forwarder {
let broadcast_room_ids: Vec<String> =
announce_room_ids.iter().map(|r| r.to_string()).collect();
@@ -282,47 +282,6 @@ require_verified_devices = true
);
}
#[test]
fn aggregated_notifications_enabled_defaults_to_true() {
let tmp = tempfile::tempdir().unwrap();
let sk = tmp.path().join(".huskies");
fs::create_dir_all(&sk).unwrap();
fs::write(
sk.join("bot.toml"),
r#"
homeserver = "https://matrix.example.com"
username = "@bot:example.com"
password = "secret"
room_ids = ["!abc:example.com"]
enabled = true
"#,
)
.unwrap();
let config = BotConfig::load(tmp.path()).unwrap();
assert!(config.aggregated_notifications_enabled);
}
#[test]
fn aggregated_notifications_enabled_can_be_set_to_false() {
let tmp = tempfile::tempdir().unwrap();
let sk = tmp.path().join(".huskies");
fs::create_dir_all(&sk).unwrap();
fs::write(
sk.join("bot.toml"),
r#"
homeserver = "https://matrix.example.com"
username = "@bot:example.com"
password = "secret"
room_ids = ["!abc:example.com"]
enabled = true
aggregated_notifications_enabled = false
"#,
)
.unwrap();
let config = BotConfig::load(tmp.path()).unwrap();
assert!(!config.aggregated_notifications_enabled);
}
#[test]
fn load_reads_ambient_rooms() {
let tmp = tempfile::tempdir().unwrap();
@@ -9,14 +9,6 @@ pub(super) fn default_permission_timeout_secs() -> u64 {
120
}
pub(super) fn default_aggregated_notifications_poll_interval_secs() -> u64 {
5
}
pub(super) fn default_aggregated_notifications_enabled() -> bool {
true
}
/// Default coalesce window for the chat dispatcher (1 500 ms).
pub(super) fn default_coalesce_window_ms() -> u64 {
1_500
@@ -173,26 +165,6 @@ pub struct BotConfig {
#[serde(default)]
pub discord_allowed_users: Vec<String>,
/// How often (in seconds) the gateway polls each project server's
/// `/api/events` endpoint to aggregate cross-project notifications.
///
/// Only used when the gateway's bot is enabled. Defaults to 5 seconds.
#[serde(default = "default_aggregated_notifications_poll_interval_secs")]
pub aggregated_notifications_poll_interval_secs: u64,
/// Whether the gateway-level aggregated cross-project notification stream
/// is enabled. When `false`, the gateway will not poll per-project
/// servers for events even if the bot is otherwise enabled.
///
/// Set this in the **gateway's** `bot.toml` (not in per-project configs).
/// Adding a new project to `projects.toml` never requires touching
/// per-project bot configs — the aggregated stream picks it up
/// automatically once this flag is `true` (the default).
///
/// Defaults to `true`.
#[serde(default = "default_aggregated_notifications_enabled")]
pub aggregated_notifications_enabled: bool,
/// Duration in milliseconds of the chat dispatcher's coalesce window.
///
/// Messages for the same session arriving within this window are