From 6d7f6dcd2285de70a3892d4f05b2a8ff44aa3350 Mon Sep 17 00:00:00 2001 From: felixxia-oai Date: Thu, 3 Sep 2026 14:24:03 +0000 Subject: [PATCH] Register the Guardian thread context feature flag (#42529) ## What changed - Add the disabled, under-development `guardian_thread_context` feature flag for selecting thread-owned context for Guardian reviewers. - Expose the boolean setting in the generated configuration schema. - Verify default, base configuration, and profile override resolution. GitOrigin-RevId: c4878be96d12f4ccd84356df15d3e55f13ac141f --- codex-rs/core/config.schema.json | 6 +++++ codex-rs/features/src/lib.rs | 9 ++++++++ codex-rs/features/src/tests.rs | 38 ++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/codex-rs/core/config.schema.json b/codex-rs/core/config.schema.json index d2bd3b9db0..5fc55ff225 100644 --- a/codex-rs/core/config.schema.json +++ b/codex-rs/core/config.schema.json @@ -774,6 +774,9 @@ "guardian_reuse_parent_compaction": { "type": "boolean" }, + "guardian_thread_context": { + "type": "boolean" + }, "guardianv2": { "$ref": "#/definitions/FeatureToml_for_GuardianV2ConfigToml" }, @@ -6122,6 +6125,9 @@ "guardian_reuse_parent_compaction": { "type": "boolean" }, + "guardian_thread_context": { + "type": "boolean" + }, "guardianv2": { "$ref": "#/definitions/FeatureToml_for_GuardianV2ConfigToml" }, diff --git a/codex-rs/features/src/lib.rs b/codex-rs/features/src/lib.rs index 6c307e4362..4bc7df19ce 100644 --- a/codex-rs/features/src/lib.rs +++ b/codex-rs/features/src/lib.rs @@ -299,6 +299,9 @@ pub enum Feature { SendAsyncMessage, /// Enable automatic review for approval prompts. GuardianApproval, + /// Select thread-owned context for both Guardian reviewers. + /// Config-only until reviewer wiring lands; read from the thread's fixed feature set. + GuardianThreadContext, /// Reuse encrypted parent compaction when restarting Guardian review sessions. GuardianReuseParentCompaction, /// Include completed node_repl or cua_repl Code Mode responses in Guardian reviews. @@ -1519,6 +1522,12 @@ pub const FEATURES: &[FeatureSpec] = &[ stage: Stage::Stable, default_enabled: true, }, + FeatureSpec { + id: Feature::GuardianThreadContext, + key: "guardian_thread_context", + stage: Stage::UnderDevelopment, + default_enabled: false, + }, FeatureSpec { id: Feature::GuardianReuseParentCompaction, key: "guardian_reuse_parent_compaction", diff --git a/codex-rs/features/src/tests.rs b/codex-rs/features/src/tests.rs index 5ad5132a2e..93ab6dc6d7 100644 --- a/codex-rs/features/src/tests.rs +++ b/codex-rs/features/src/tests.rs @@ -162,6 +162,44 @@ fn guardian_v2_feature_config_preserves_boolean_toggle() { ); } +#[test] +fn guardian_thread_context_resolves_boolean_config_and_profile_overrides() { + for (base, profile, enabled) in [ + ("", "", false), + ("guardian_thread_context = false", "", false), + ("guardian_thread_context = true", "", true), + ( + "guardian_thread_context = true", + "guardian_thread_context = false", + false, + ), + ( + "guardian_thread_context = false", + "guardian_thread_context = true", + true, + ), + ] { + let base = toml::from_str::(base).expect("base features"); + let profile = toml::from_str::(profile).expect("profile features"); + let features = Features::from_sources( + FeatureConfigSource { + features: Some(&base), + ..Default::default() + }, + FeatureConfigSource { + features: Some(&profile), + ..Default::default() + }, + FeatureOverrides::default(), + ); + let mut expected = Features::with_defaults(); + if enabled { + expected.enable(Feature::GuardianThreadContext); + } + assert_eq!(features.enabled_features(), expected.enabled_features()); + } +} + #[test] fn guardian_v2_feature_config_deserializes_classifier_and_transcript_settings() { let features: FeaturesToml = toml::from_str(