Add Guardian catalog diagnostics metadata (#27109)

## Why

We need request-level evidence for Guardian cases where
`codex-auto-review` is missing from the client-side model catalog and
the review falls back to the parent model.

## What changed

- Add `guardian_catalog_contains_auto_review` to Guardian Responses API
client metadata.
- Add `guardian_model_provider_id` to Guardian Responses API client
metadata.
- Keep review-session metadata optional so callers without metadata
preserve the existing `None` path.
- Add tests for override, normal preferred-model, and
missing-auto-review-catalog behavior.

## Validation

- `just test -p codex-core
guardian_review_records_missing_auto_review_model_in_request_metadata`
- `just test -p codex-core
guardian_review_uses_model_catalog_override_when_preferred_review_model_exists`
- `just test -p codex-core
guardian_review_uses_preferred_review_model_without_model_catalog_override`
- `git diff --check origin/main`
This commit is contained in:
Won Park authored and GitHub committed 2026-06-12 15:50:30 -07:00
1 parent c0f1ec5afd
commit 0605f9c14f
6 files changed
+239 -34

No files matched your search

@@ -1987,6 +1987,11 @@ async fn guardian_review_event_ingests_custom_fact_with_optional_target_item() {
guardian_session_kind: None,
guardian_model: None,
guardian_reasoning_effort: None,
guardian_default_review_model_id: Some("codex-auto-review".to_string()),
guardian_catalog_contains_auto_review: Some(false),
guardian_review_model_overridden: Some(false),
guardian_review_model_override: None,
guardian_model_provider_id: Some("openai".to_string()),
had_prior_review_context: None,
review_timeout_ms: 90_000,
tool_call_count: None,
@@ -2053,6 +2058,26 @@ async fn guardian_review_event_ingests_custom_fact_with_optional_target_item() {
assert_eq!(payload[0]["event_params"]["failure_reason"], "timeout");
assert_eq!(payload[0]["event_params"]["attempt_count"], 1);
assert_eq!(payload[0]["event_params"]["review_timeout_ms"], 90_000);
assert_eq!(
payload[0]["event_params"]["guardian_default_review_model_id"],
"codex-auto-review"
);
assert_eq!(
payload[0]["event_params"]["guardian_catalog_contains_auto_review"],
false
);
assert_eq!(
payload[0]["event_params"]["guardian_review_model_overridden"],
false
);
assert_eq!(
payload[0]["event_params"]["guardian_review_model_override"],
json!(null)
);
assert_eq!(
payload[0]["event_params"]["guardian_model_provider_id"],
"openai"
);
}
#[tokio::test]