Warn for structured feature toggles (#27076)

## Summary
Startup warnings for under-development features only recognized bare
boolean toggles like `features.foo = true`. An upcoming feature will use
table-format config, so `features.foo = { enabled = true, ... }` needs
to count as an explicit opt-in too.

This updates the warning predicate to recognize structured tables with
`enabled = true`, while leaving tables without that field unwarned.

## Testing
- `just fmt`
- `just test -p codex-features
unstable_warning_event_mentions_enabled_structured_under_development_feature`
This commit is contained in:
canvrno-oai
2026-06-12 14:52:07 -07:00
committed by GitHub
Unverified
parent 56c97e3b5c
commit 4d1702586a
2 changed files with 39 additions and 1 deletions
+8 -1
View File
@@ -1281,7 +1281,13 @@ pub fn unstable_features_warning_event(
let mut under_development_feature_keys = Vec::new();
if let Some(table) = effective_features {
for (key, value) in table {
if value.as_bool() != Some(true) {
let is_enabled = value.as_bool() == Some(true)
|| value
.as_table()
.and_then(|table| table.get("enabled"))
.and_then(toml::Value::as_bool)
== Some(true);
if !is_enabled {
continue;
}
let Some(spec) = FEATURES.iter().find(|spec| spec.key == key.as_str()) else {
@@ -1300,6 +1306,7 @@ pub fn unstable_features_warning_event(
return None;
}
under_development_feature_keys.sort();
let under_development_feature_keys = under_development_feature_keys.join(", ");
let message = format!(
"Under-development features enabled: {under_development_feature_keys}. Under-development features are incomplete and may behave unpredictably. To suppress this warning, set `suppress_unstable_features_warning = true` in {config_path}."
+31
View File
@@ -712,3 +712,34 @@ fn unstable_warning_event_only_mentions_enabled_under_development_features() {
assert!(!message.contains("personality"));
assert!(message.contains("/tmp/config.toml"));
}
#[test]
fn unstable_warning_event_mentions_enabled_structured_under_development_feature() {
let configured_features: Table = toml::from_str(
r#"
multi_agent_v2 = { enabled = true, tool_namespace = "agents" }
code_mode = true
"#,
)
.expect("features table should deserialize");
let mut features = Features::with_defaults();
features.enable(Feature::MultiAgentV2);
features.enable(Feature::CodeMode);
let warning = unstable_features_warning_event(
Some(&configured_features),
/*suppress_unstable_features_warning*/ false,
&features,
"/tmp/config.toml",
)
.expect("warning event");
let EventMsg::Warning(WarningEvent { message }) = warning.msg else {
panic!("expected warning event");
};
assert_eq!(
"Under-development features enabled: code_mode, multi_agent_v2. Under-development features are incomplete and may behave unpredictably. To suppress this warning, set `suppress_unstable_features_warning = true` in /tmp/config.toml.".to_string(),
message
);
}