Source Guardian REPL policy from model metadata (#41919)

## What changed

- Add `auto_review.node_repl_policy` to model messages for `node_repl` and `cua_repl` reviews.
- Use the reviewer model's configured policy, falling back to the bundled policy when the field is absent and skipping injection when it is explicitly empty.
- Include the effective policy in Guardian session reuse checks and reject unsafe parent-model fallback transitions that would change it.

## Testing

- Cover catalog, bundled, and explicitly empty policies across Node and CUA review paths.
- Verify that policy changes invalidate cached reviewer sessions and incompatible fallback transitions.

GitOrigin-RevId: 51c0bdfed9b464091b6eb47d91ca5a0990d7a315
This commit is contained in:
olliem-oai authored and copyberry committed 2026-08-31 22:08:44 +00:00
1 parent 746798b2f7
commit 865bbf9a69
11 files changed
+144 -24

No files matched your search

+7
View File
@@ -623,6 +623,9 @@ pub struct CollaborationModeMessages {
pub struct AutoReviewMessages {
pub policy: Option<String>,
pub policy_template: Option<String>,
/// Extra developer policy for `node_repl` and `cua_repl` reviews.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub node_repl_policy: Option<String>,
pub rejection_instructions: Option<String>,
pub timeout_instructions: Option<String>,
}
@@ -1139,6 +1142,7 @@ mod tests {
"auto_review": {
"policy": "policy",
"policy_template": "",
"node_repl_policy": "",
"rejection_instructions": "",
"timeout_instructions": ""
}
@@ -1151,6 +1155,7 @@ mod tests {
Some(AutoReviewMessages {
policy: Some("policy".to_string()),
policy_template: None,
node_repl_policy: None,
rejection_instructions: None,
timeout_instructions: None,
})
@@ -1160,6 +1165,7 @@ mod tests {
Some(AutoReviewMessages {
policy: Some("policy".to_string()),
policy_template: Some(String::new()),
node_repl_policy: Some(String::new()),
rejection_instructions: Some(String::new()),
timeout_instructions: Some(String::new()),
})
@@ -1559,6 +1565,7 @@ mod tests {
auto_review: Some(AutoReviewMessages {
policy: Some("policy".to_string()),
policy_template: None,
node_repl_policy: None,
rejection_instructions: Some("rejection instructions".to_string()),
timeout_instructions: Some("timeout instructions".to_string()),
}),