Clarify config layer iteration APIs (#36774)

## What changed

- Replace the ordering enum and `include_disabled` boolean with named
  `ConfigLayerStack` iterators for each precedence direction.
- Keep enabled-only iteration separate from `all_layers_*` iteration, which
  includes disabled layers.
- Update config consumers to use the iterator matching their precedence and
  disabled-layer requirements without allocating an intermediate `Vec`.

## Testing

- Add coverage that verifies ordering and disabled-layer filtering for all four
  iterators.

GitOrigin-RevId: d14df3db4a2eae80ba97cdec246bff405e6c5f3d
This commit is contained in:
jif authored and copyberry committed 2026-08-03 17:29:42 +00:00
1 parent 224ea64cdc
commit 78306a32af
32 files changed
+150 -309

No files matched your search

+1 -5
View File
@@ -2,7 +2,6 @@ use std::collections::HashSet;
use codex_config::ConfigLayerSource;
use codex_config::ConfigLayerStack;
use codex_config::ConfigLayerStackOrdering;
use codex_config::SkillConfig;
use codex_config::SkillsConfig;
pub use codex_skills::SkillConfigRule;
@@ -15,10 +14,7 @@ use crate::SkillMetadata;
pub fn skill_config_rules_from_stack(config_layer_stack: &ConfigLayerStack) -> SkillConfigRules {
let mut entries = Vec::new();
for layer in config_layer_stack.get_layers(
ConfigLayerStackOrdering::LowestPrecedenceFirst,
/*include_disabled*/ true,
) {
for layer in config_layer_stack.all_layers_low_to_high() {
if !matches!(
layer.name,
ConfigLayerSource::User { .. } | ConfigLayerSource::SessionFlags
+2 -9
View File
@@ -19,7 +19,6 @@ use crate::model::SkillToolDependency;
use crate::system::system_cache_root_dir;
use codex_config::ConfigLayerSource;
use codex_config::ConfigLayerStack;
use codex_config::ConfigLayerStackOrdering;
use codex_config::default_project_root_markers;
use codex_config::merge_toml_values;
use codex_config::project_root_markers_from_config;
@@ -296,10 +295,7 @@ fn skill_roots_from_layer_stack_inner(
) -> Vec<SkillRoot> {
let mut roots = Vec::new();
for layer in config_layer_stack.get_layers(
ConfigLayerStackOrdering::HighestPrecedenceFirst,
/*include_disabled*/ true,
) {
for layer in config_layer_stack.all_layers_high_to_low() {
let Some(config_folder) = layer.config_folder() else {
continue;
};
@@ -429,10 +425,7 @@ async fn repo_agents_skill_roots(
fn project_root_markers_from_stack(config_layer_stack: &ConfigLayerStack) -> Vec<String> {
let mut merged = TomlValue::Table(toml::map::Map::new());
for layer in config_layer_stack.get_layers(
ConfigLayerStackOrdering::LowestPrecedenceFirst,
/*include_disabled*/ false,
) {
for layer in config_layer_stack.layers_low_to_high() {
if matches!(layer.name, ConfigLayerSource::Project { .. }) {
continue;
}