Enforce exact values from managed config requirements (#34597)

## What changed

- Apply managed values for `sqlite_home`, `log_dir`, `model_catalog_json`,
  `check_for_update_on_startup`, `allow_login_shell`, the report-submission
  opt-in, and `windows.sandbox_private_desktop` to the runtime configuration,
  with source-aware warnings when they override configured values.
- Expose these values through `configRequirements/read`, return them from
  `config/read`, include them in session config locks, and show their sources in
  the TUI config debug view.
- Reject app-server writes that overlap an exact managed requirement with
  `configRequirementReadonly` while leaving unrelated sibling keys writable.

## Testing

- Cover runtime overrides, requirement API mapping, config reads and writes,
  session lock serialization, cross-platform path URIs, and debug output.

GitOrigin-RevId: d4e23b6fd7775c1a6dfe2eab313cdcee50b07081
This commit is contained in:
Abhinav authored and copyberry committed 2026-07-21 19:08:58 +00:00
1 parent 7442f5f932
commit ee71c4a90f
34 files changed
+1566 -71

No files matched your search

@@ -130,19 +130,31 @@ impl ConfigManager {
};
let effective = layers.effective_config();
let effective_config_toml: ConfigToml = effective
let mut effective_config_toml: ConfigToml = effective
.try_into()
.map_err(|err| ConfigManagerError::toml("invalid configuration", err))?;
layers
.requirements_toml()
.apply_exact_to_config(&mut effective_config_toml);
effective_config_toml.allow_login_shell.get_or_insert(true);
let json_value = serde_json::to_value(&effective_config_toml)
.map_err(|err| ConfigManagerError::json("failed to serialize configuration", err))?;
let config: ApiConfig = serde_json::from_value(json_value)
.map_err(|err| ConfigManagerError::json("failed to deserialize configuration", err))?;
let mut origins = layers.origins();
origins.retain(|path, _| {
let segments = path.split('.').map(str::to_string).collect::<Vec<_>>();
layers
.requirements_toml()
.exact_requirement_for_config_path(&segments)
.is_none()
});
Ok(ConfigReadResponse {
config,
origins: layers
.origins()
origins: origins
.into_iter()
.map(|(path, metadata)| (path, config_layer_metadata_to_api(metadata)))
.collect(),
@@ -283,6 +295,15 @@ impl ConfigManager {
let mut segments = parse_key_path(&key_path).map_err(|message| {
ConfigManagerError::write(ConfigWriteErrorCode::ConfigValidationError, message)
})?;
if let Some(field) = layers
.requirements_toml()
.exact_requirement_for_config_path(&segments)
{
return Err(ConfigManagerError::write(
ConfigWriteErrorCode::ConfigRequirementReadonly,
format!("`{field}` is managed by requirements and cannot be changed"),
));
}
if (value.is_null() || matches!(strategy, MergeStrategy::Upsert))
&& let Some(pattern) = shell_environment_filter_entry(&user_config, &segments)
.map(|(pattern, _)| pattern.clone())