mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:50:52 +00:00
Cap evidence stored on Guardian v3 shadow boards (#64166)
## Why Shadow routing can store the same evidence in multiple channels. A per-root limit bounds how much evidence each shadow board accumulates. ## What changed - Default to 32 MiB of serialized evidence per root shadow board and count each stored channel copy. Allow users to set `features.guardianv3.shadow_board_limit_mib` in user config. Ignore project overrides of the limit and discard positional Guardian v3 project settings that could bypass filtering for user-only fields. - Reject batches that would exceed the limit before creating channels or appending posts. Skip the routing call when even one copy of the first source would exceed the remaining budget. - Signal root and child shadow reviewers when intake stops, independently of reviewer cancellation. Record channel counts, post counts, and evidence bytes after successful batches, and tag worker failures by stage. ## Testing Tests cover byte accounting across distinct destinations, overflow before and after routing, an unchanged board after a rejected batch, intake stop signals for root and child reviewers, and project config filtering. GitOrigin-RevId: 9d908ceb6f33ba69eed2a07223b3f9177afbe11e
This commit is contained in:
@@ -1375,18 +1375,30 @@ fn sanitize_project_config(
|
||||
{
|
||||
ignored_keys.push("features.shell_snapshot".to_string());
|
||||
}
|
||||
// Serde also accepts positional arrays for these structs. Project overrides
|
||||
// must use named settings so the user-only fields below can be filtered.
|
||||
if features.get("guardianv3").is_some_and(TomlValue::is_array) {
|
||||
features.remove("guardianv3");
|
||||
ignored_keys.push("features.guardianv3".to_string());
|
||||
}
|
||||
if let Some(guardian) = features
|
||||
.get_mut("guardianv3")
|
||||
.and_then(TomlValue::as_table_mut)
|
||||
{
|
||||
if guardian.remove("max_instruction_tokens").is_some() {
|
||||
ignored_keys.push("features.guardianv3.max_instruction_tokens".to_string());
|
||||
for key in ["max_instruction_tokens", "shadow_board_limit_mib"] {
|
||||
if guardian.remove(key).is_some() {
|
||||
ignored_keys.push(format!("features.guardianv3.{key}"));
|
||||
}
|
||||
}
|
||||
for (section, key) in [
|
||||
("housekeeper", "routing_instructions"),
|
||||
("reviewer", "retrieval_instructions"),
|
||||
] {
|
||||
if let Some(settings) = guardian.get_mut(section).and_then(TomlValue::as_table_mut)
|
||||
if guardian.get(section).is_some_and(TomlValue::is_array) {
|
||||
guardian.remove(section);
|
||||
ignored_keys.push(format!("features.guardianv3.{section}"));
|
||||
} else if let Some(settings) =
|
||||
guardian.get_mut(section).and_then(TomlValue::as_table_mut)
|
||||
&& settings.remove(key).is_some()
|
||||
{
|
||||
ignored_keys.push(format!("features.guardianv3.{section}.{key}"));
|
||||
|
||||
@@ -1310,10 +1310,11 @@ async fn local_layers_keep_raw_paths_order_and_legacy_requirements() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_config_cannot_supply_guardian_v3_prompts_or_their_cap() {
|
||||
fn project_config_cannot_override_guardian_v3_prompts_or_limits() {
|
||||
let mut project: TomlValue = toml::toml! {
|
||||
[features.guardianv3]
|
||||
max_instruction_tokens = 1
|
||||
shadow_board_limit_mib = 512
|
||||
[features.guardianv3.housekeeper]
|
||||
routing_instructions = "Use project routing"
|
||||
batch_timeout_ms = 15000
|
||||
@@ -1340,6 +1341,7 @@ fn project_config_cannot_supply_guardian_v3_prompts_or_their_cap() {
|
||||
ignored,
|
||||
[
|
||||
"features.guardianv3.max_instruction_tokens",
|
||||
"features.guardianv3.shadow_board_limit_mib",
|
||||
"features.guardianv3.housekeeper.routing_instructions",
|
||||
"features.guardianv3.reviewer.retrieval_instructions",
|
||||
]
|
||||
@@ -1358,6 +1360,36 @@ fn project_config_cannot_supply_guardian_v3_prompts_or_their_cap() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_config_ignores_positional_guardian_v3_settings() {
|
||||
let mut project: TomlValue =
|
||||
toml::from_str("features.guardianv3 = [512, true, true, {}, {}, 1]").unwrap();
|
||||
let sanitize = |project: &mut TomlValue| {
|
||||
sanitize_project_config(project, CredentialBrokerProjectState::Unconfigured, &[])
|
||||
};
|
||||
assert_eq!(sanitize(&mut project), ["features.guardianv3"]);
|
||||
assert!(project["features"].get("guardianv3").is_none());
|
||||
|
||||
let mut project: TomlValue = toml::toml! {
|
||||
[features.guardianv3]
|
||||
enabled = true
|
||||
housekeeper = ["Use project routing", 15000]
|
||||
reviewer = ["Use project retrieval"]
|
||||
}
|
||||
.into();
|
||||
assert_eq!(
|
||||
sanitize(&mut project),
|
||||
[
|
||||
"features.guardianv3.housekeeper",
|
||||
"features.guardianv3.reviewer"
|
||||
]
|
||||
);
|
||||
assert_eq!(
|
||||
project,
|
||||
toml::toml! { [features.guardianv3] enabled = true }.into()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_config_cannot_change_protected_features() {
|
||||
for key in [
|
||||
|
||||
Reference in New Issue
Block a user