The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(config): make the autonomy allowlist widening visible, and stop promising otherwise\n\nA hand-written `config.toml` with a deliberately narrow\n`autonomy.allowed_commands` is silently widened by 28 commands on first launch,\nfive of which mutate the filesystem (`mkdir`, `touch`, `cp`, `mv`, `ln`). The\nfile on disk still shows the narrow list, so nothing surfaces it.\n\n`schema_version` is `#[serde(default)]`, so a file without the field loads as\nversion 0 and `run_pending` runs the whole 0->10 chain — including the v3->v4\n`expand_autonomy_defaults` migration — against a config that was never at v3.\nA config this code writes is already stamped `CURRENT_SCHEMA_VERSION` on\ncreation (`schema/load/impl_load.rs:491`), so the fresh-install path is fine.\nThe hand-written one is the gap.\n\nThis does NOT change the migration's behaviour, deliberately. Deciding whether\na v0 config carrying an explicit allowlist should migrate at all is a product\nruling: an additive merge has no record of the v3 default, so it cannot\ndistinguish "absent because the user removed it" from "absent because it\npost-dates this config", and both answers break somebody. What this does is\nstop the situation being invisible and stop the code claiming otherwise.\n\n1. The module doc promised removals were "fully preserved". That is false in\n the one direction that matters for an allowlist, and it is what makes the\n code read as safe. Corrected, with the v0 mechanism spelled out and the\n `schema_version` opt-out named.\n\n2. The widening was logged at DEBUG — invisible at a default log level, and\n invisible on disk. Now WARN, naming the commands added, and only when the\n list being widened was non-empty: an empty list never expressed an opinion,\n a non-empty one is a list somebody chose.\n\n3. Two tests for the case nothing covered. Existing tests start at v3 (a real\n migration) or a fresh install (already stamped); neither is what a user\n hits. One pins today's behaviour so a future ruling must walk past it; the\n other proves setting `schema_version` is a working opt-out.\n\nFault-injected: neutering the merge fails the new test at mod_tests.rs:538.\nRestored; `config::migrations` green, 105 passed.\n
M3gA-Mindd8921b2de35d
diff --git a/src/openhuman/config/migrations/expand_autonomy_defaults.rs b/src/openhuman/config/migrations/expand_autonomy_defaults.rsindex c24145fb93..3b9d4a957b 100644--- a/src/openhuman/config/migrations/expand_autonomy_defaults.rs+++ b/src/openhuman/config/migrations/expand_autonomy_defaults.rs@@ -10,8 +10,24 @@//! ## What this migration does//!//! 1. **Merges new commands** into `config.autonomy.allowed_commands`. Only-//! commands not already present are added, so any user customisation-//! (e.g. additional entries, deliberate removals) is fully preserved.+//! commands not already present are added, so additional entries a user has+//! made are preserved.+//!+//! ⚠️ **A deliberate removal is NOT preserved, and cannot be.** The merge is+//! additive and has no record of what the v3 default contained, so it cannot+//! tell "absent because the user removed it" from "absent because it+//! post-dates this config". A narrowed `allowed_commands` is therefore+//! widened back. This doc previously claimed removals were "fully+//! preserved"; that was false in the one direction that matters for a+//! command allowlist.+//!+//! This bites hardest on a **hand-written** `config.toml`: `schema_version`+//! is `#[serde(default)]`, so a file without the field loads as version `0`+//! and runs the whole 0→10 chain including this migration — even though it+//! was never a v3 config. A config this code writes is stamped with+//! `CURRENT_SCHEMA_VERSION` on creation (`schema/load/impl_load.rs`), so the+//! fresh-install path is unaffected. Set `schema_version` explicitly to opt+//! out.//! 2. **Merges new auto-approve tools** into `config.autonomy.auto_approve`//! with the same additive-only merge logic.//! 3. **Bumps `max_actions_per_hour`** from 20 (the old hard-coded default)@@ -78,6 +94,8 @@ pub fn run(config: &mut Config) -> anyhow::Result<MigrationStats> {);// Merge new commands (additive only — never remove user entries).+ let commands_before = config.autonomy.allowed_commands.clone();+ let mut added_commands: Vec<&str> = Vec::new();for &cmd in NEW_COMMANDS {if !config.autonomy.allowed_commands.iter().any(|c| c == cmd) {log::debug!(@@ -85,10 +103,29 @@ pub fn run(config: &mut Config) -> anyhow::Result<MigrationStats> {cmd);config.autonomy.allowed_commands.push(cmd.to_string());+ added_commands.push(cmd);stats.commands_added += 1;}}+ // Widening a command allowlist is a security-relevant change, and until now+ // it happened at DEBUG — invisible on a default log level, and invisible in+ // the file on disk, which still shows the narrow list the user wrote. Say it+ // at WARN, and name what was added, whenever the list being widened was not+ // empty: an empty list is a config that never expressed an opinion, but a+ // non-empty one is a list somebody chose.+ if !added_commands.is_empty() && !commands_before.is_empty() {+ log::warn!(+ "[migrations][expand-autonomy-defaults] widened a non-empty allowed_commands \+ from {} to {} entries; added: {}. If this list was curated deliberately, the \+ removals are NOT preserved — set `schema_version` in config.toml to opt out \+ of this migration.",+ commands_before.len(),+ config.autonomy.allowed_commands.len(),+ added_commands.join(", ")+ );+ }+// Merge new auto-approve tools (additive only).for &tool in NEW_AUTO_APPROVE_TOOLS {if !config.autonomy.auto_approve.iter().any(|t| t == tool) {diff --git a/src/openhuman/config/migrations/mod_tests.rs b/src/openhuman/config/migrations/mod_tests.rsindex 0862c38954..591fa2fb20 100644--- a/src/openhuman/config/migrations/mod_tests.rs+++ b/src/openhuman/config/migrations/mod_tests.rs@@ -492,3 +492,77 @@ async fn run_pending_v3_to_v4_preserves_custom_max_actions() {"user-customised max_actions_per_hour must not be overwritten");}++/// The coverage gap that let the allowlist-widening ship unnoticed.+///+/// Existing tests start at v3 (a real migration) or at a fresh install (already+/// stamped `CURRENT_SCHEMA_VERSION`). Neither covers the case a user actually+/// hits: a **hand-written** `config.toml` with a deliberately narrow+/// `allowed_commands` and no `schema_version` field, which `#[serde(default)]`+/// loads as version `0`.+///+/// This test documents what happens today rather than what should. It is not an+/// endorsement: an additive merge structurally cannot tell "absent because the+/// user removed it" from "absent because it post-dates this config", so+/// deciding whether a v0 config with an explicit allowlist should be migrated at+/// all is a product ruling, not a refactor. Pinning current behaviour means that+/// ruling, when it comes, has to walk past this assertion.+#[tokio::test]+async fn run_pending_widens_a_hand_written_v0_allowlist_and_that_is_visible() {+ let tmp = TempDir::new().unwrap();+ fs::create_dir_all(tmp.path().join("workspace")).unwrap();++ let mut config = config_in(&tmp);+ // A hand-written file: no `schema_version` key at all -> serde default 0.+ config.schema_version = 0;+ config.autonomy.allowed_commands = vec!["ls".to_string(), "cat".to_string()];++ run_pending(&mut config).await;++ assert_eq!(+ config.schema_version, CURRENT_SCHEMA_VERSION,+ "the whole 0 -> current chain runs against a config that was never at v3"+ );++ // The user's own entries survive — the merge is additive.+ for kept in &["ls", "cat"] {+ assert!(+ config.autonomy.allowed_commands.iter().any(|c| c == kept),+ "{kept} was configured explicitly and must survive"+ );+ }++ // …and so do 28 commands the user never asked for, five of which mutate the+ // filesystem. This is the security-relevant half.+ for added in &["mkdir", "touch", "cp", "mv", "ln"] {+ assert!(+ config.autonomy.allowed_commands.iter().any(|c| c == added),+ "current behaviour: the v3->v4 migration adds {added} to a hand-written \+ allowlist that never contained it"+ );+ }+ assert!(+ config.autonomy.allowed_commands.len() > 2,+ "the configured list of 2 is widened, not preserved: {:?}",+ config.autonomy.allowed_commands+ );+}++/// Setting `schema_version` explicitly is the documented opt-out, and it works.+#[tokio::test]+async fn an_explicit_schema_version_stops_the_allowlist_being_widened() {+ let tmp = TempDir::new().unwrap();+ fs::create_dir_all(tmp.path().join("workspace")).unwrap();++ let mut config = config_in(&tmp);+ config.schema_version = CURRENT_SCHEMA_VERSION;+ config.autonomy.allowed_commands = vec!["ls".to_string(), "cat".to_string()];++ run_pending(&mut config).await;++ assert_eq!(+ config.autonomy.allowed_commands,+ vec!["ls".to_string(), "cat".to_string()],+ "with the gate satisfied no migration runs, so the curated list is untouched"+ );+}