From 2da0944dada07eff67593502bc0498cef42974a4 Mon Sep 17 00:00:00 2001 From: Valeriy Selitskiy <239034+iamwavecut@users.noreply.github.com> Date: Fri, 13 Nov 2026 19:14:08 +0100 Subject: [PATCH 1/2] Keep stored workflow settings on a partial admin update update_workflow replaced omitted fields with 3 hops, 60 s, full routing and enabled, so a partial request could silently cut the dialog budget from 5 hops / 180 s and re-enable a disabled workflow. Omitted fields now keep their stored values (COALESCE in the UPDATE). --- crates/openplotva-app/src/http/routing.rs | 12 ++- crates/openplotva-storage/src/llm_routing.rs | 90 ++++++++++++++++++-- 2 files changed, 89 insertions(+), 13 deletions(-) diff --git a/crates/openplotva-app/src/http/routing.rs b/crates/openplotva-app/src/http/routing.rs index 4e0fa12..f13d69e 100644 --- a/crates/openplotva-app/src/http/routing.rs +++ b/crates/openplotva-app/src/http/routing.rs @@ -631,10 +631,14 @@ pub(crate) async fn admin_routing_apply_action( routing::update_workflow( pool, &key, - routing_json_bool(body, "full_routing", true), - routing_json_i32(body, "retry_max_hops").unwrap_or(3), - routing_json_i32(body, "retry_wall_ms").unwrap_or(60_000), - routing_json_bool(body, "enabled", true), + routing::WorkflowUpdate { + full_routing: body + .get("full_routing") + .and_then(serde_json::Value::as_bool), + retry_max_hops: routing_json_i32(body, "retry_max_hops"), + retry_wall_ms: routing_json_i32(body, "retry_wall_ms"), + enabled: body.get("enabled").and_then(serde_json::Value::as_bool), + }, ) .await .map_err(storage_err)?; diff --git a/crates/openplotva-storage/src/llm_routing.rs b/crates/openplotva-storage/src/llm_routing.rs index a3219ae..e5d3f38 100644 --- a/crates/openplotva-storage/src/llm_routing.rs +++ b/crates/openplotva-storage/src/llm_routing.rs @@ -427,7 +427,7 @@ const SQL_DELETE_POOL: &str = "DELETE FROM llm_capacity_pools WHERE id = $1"; const SQL_LIST_WORKFLOWS: &str = "SELECT key, kind, full_routing, retry_max_hops, retry_wall_ms, enabled, lane_priority, fallback_reserve_ms FROM workflows ORDER BY key ASC"; const SQL_INSERT_WORKFLOW_IF_MISSING: &str = "INSERT INTO workflows (key, kind, full_routing, retry_max_hops, retry_wall_ms, enabled) VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT (key) DO NOTHING"; -const SQL_UPDATE_WORKFLOW: &str = "UPDATE workflows SET full_routing = $2, retry_max_hops = $3, retry_wall_ms = $4, enabled = $5 WHERE key = $1"; +const SQL_UPDATE_WORKFLOW: &str = "UPDATE workflows SET full_routing = COALESCE($2, full_routing), retry_max_hops = COALESCE($3, retry_max_hops), retry_wall_ms = COALESCE($4, retry_wall_ms), enabled = COALESCE($5, enabled) WHERE key = $1"; const SQL_SET_WORKFLOW_ENABLED: &str = "UPDATE workflows SET enabled = $2 WHERE key = $1"; const SQL_LIST_ASSIGNMENTS: &str = "SELECT id, workflow_key, scope, role, provider_model_id, weight, fallback_order, canary_percent, enabled, inference_overrides::text AS inference_overrides, cb_failure_threshold, cb_cooldown_ms FROM workflow_assignments ORDER BY id ASC"; @@ -1358,20 +1358,26 @@ pub async fn insert_workflow_if_missing( Ok(()) } +/// Fields left `None` keep their stored values. +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] +pub struct WorkflowUpdate { + pub full_routing: Option, + pub retry_max_hops: Option, + pub retry_wall_ms: Option, + pub enabled: Option, +} + pub async fn update_workflow( pool: &PgPool, key: &str, - full_routing: bool, - retry_max_hops: i32, - retry_wall_ms: i32, - enabled: bool, + update: WorkflowUpdate, ) -> Result<(), StorageError> { sqlx::query(SQL_UPDATE_WORKFLOW) .bind(key) - .bind(full_routing) - .bind(retry_max_hops) - .bind(retry_wall_ms) - .bind(enabled) + .bind(update.full_routing) + .bind(update.retry_max_hops) + .bind(update.retry_wall_ms) + .bind(update.enabled) .execute(pool) .await?; Ok(()) @@ -1944,6 +1950,72 @@ mod tests { use super::*; use crate::database as sqlx; + #[tokio::test] + async fn partial_workflow_update_keeps_the_stored_retry_budget() + -> Result<(), Box> { + let Ok(dsn) = std::env::var("OPENPLOTVA_TEST_POSTGRES_DSN") else { + return Ok(()); + }; + let pool = sqlx::postgres::PgPoolOptions::new() + .max_connections(1) + .connect(&dsn) + .await?; + let mut transaction = pool.begin().await?; + sqlx::raw_sql( + r#" + CREATE TEMP TABLE workflows ( + key TEXT PRIMARY KEY, full_routing BOOLEAN NOT NULL, + retry_max_hops INTEGER NOT NULL, retry_wall_ms INTEGER NOT NULL, + enabled BOOLEAN NOT NULL + ) ON COMMIT DROP; + INSERT INTO workflows VALUES ('dialog', true, 5, 180000, true); + "#, + ) + .execute(&mut *transaction) + .await?; + + let enabled_only = WorkflowUpdate { + enabled: Some(false), + ..WorkflowUpdate::default() + }; + sqlx::query(SQL_UPDATE_WORKFLOW) + .bind("dialog") + .bind(enabled_only.full_routing) + .bind(enabled_only.retry_max_hops) + .bind(enabled_only.retry_wall_ms) + .bind(enabled_only.enabled) + .execute(&mut *transaction) + .await?; + let row: (bool, i32, i32, bool) = sqlx::query_as( + "SELECT full_routing, retry_max_hops, retry_wall_ms, enabled FROM workflows WHERE key = 'dialog'", + ) + .fetch_one(&mut *transaction) + .await?; + assert_eq!(row, (true, 5, 180_000, false)); + + let budget = WorkflowUpdate { + retry_max_hops: Some(3), + retry_wall_ms: Some(60_000), + ..WorkflowUpdate::default() + }; + sqlx::query(SQL_UPDATE_WORKFLOW) + .bind("dialog") + .bind(budget.full_routing) + .bind(budget.retry_max_hops) + .bind(budget.retry_wall_ms) + .bind(budget.enabled) + .execute(&mut *transaction) + .await?; + let row: (bool, i32, i32, bool) = sqlx::query_as( + "SELECT full_routing, retry_max_hops, retry_wall_ms, enabled FROM workflows WHERE key = 'dialog'", + ) + .fetch_one(&mut *transaction) + .await?; + assert_eq!(row, (true, 3, 60_000, false)); + transaction.rollback().await?; + Ok(()) + } + #[tokio::test] async fn live_admin_digest_correlates_models_without_counting_retries_as_incidents() -> Result<(), Box> { From 3bf77dc399d3e8881edad8c99d636d3c2a92d9ee Mon Sep 17 00:00:00 2001 From: Valeriy Selitskiy <239034+iamwavecut@users.noreply.github.com> Date: Fri, 13 Nov 2026 19:16:28 +0100 Subject: [PATCH 2/2] Update quinn-udp to 0.5.16 for RUSTSEC-2026-0538 --- Cargo.lock | 108 +++++++++-------------------------------------------- 1 file changed, 17 insertions(+), 91 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 74ae443..769df63 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1063,7 +1063,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -2685,16 +2685,16 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.14" +version = "0.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "addec6a0dcad8a8d96a771f815f0eaf55f9d1805756410b39f5fa81332574cbd" +checksum = "af66907df18639dcf4db56ca65490cabc4b27a97dbadd96f2926cca73298f016" dependencies = [ "cfg_aliases", "libc", "once_cell", "socket2", "tracing", - "windows-sys 0.60.2", + "windows-sys 0.52.0", ] [[package]] @@ -2922,7 +2922,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -2980,7 +2980,7 @@ dependencies = [ "security-framework", "security-framework-sys", "webpki-root-certs", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -3490,7 +3490,7 @@ dependencies = [ "getrandom 0.4.2", "once_cell", "rustix", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -4147,7 +4147,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -4162,16 +4162,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-sys" -version = "0.60.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" -dependencies = [ - "windows-targets 0.53.5", + "windows-targets", ] [[package]] @@ -4189,31 +4180,14 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm 0.52.6", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", -] - -[[package]] -name = "windows-targets" -version = "0.53.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" -dependencies = [ - "windows-link", - "windows_aarch64_gnullvm 0.53.1", - "windows_aarch64_msvc 0.53.1", - "windows_i686_gnu 0.53.1", - "windows_i686_gnullvm 0.53.1", - "windows_i686_msvc 0.53.1", - "windows_x86_64_gnu 0.53.1", - "windows_x86_64_gnullvm 0.53.1", - "windows_x86_64_msvc 0.53.1", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[package]] @@ -4222,96 +4196,48 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_aarch64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" - [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" -[[package]] -name = "windows_i686_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" - [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_i686_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "windows_x86_64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" - [[package]] name = "winnow" version = "1.0.3"