feat(execpolicy): expose matched approval rule metadata#2971
feat(execpolicy): expose matched approval rule metadata#2971greyfreedom wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
Thanks @greyfreedom for taking the time to contribute. This repository is observing a maintainer-managed PR intake gate in dry-run mode, so this pull request is staying open. This note helps maintainers prepare the allowlist before any enforcement is considered. Please read |
There was a problem hiding this comment.
Code Review
This pull request boxes EventFrame inside HookEvent::GenericEventFrame and introduces a matched_rule field to ExecApprovalRequestEvent to capture the matched execution-policy rule in approval requests. The review feedback suggests optimizing the conversion of matched_rule to a boxed string by using Box::from directly, which avoids an unnecessary intermediate String allocation.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| command, | ||
| cwd, | ||
| reason: reason.clone(), | ||
| matched_rule: matched_rule.map(|rule| rule.to_string().into_boxed_str()), |
There was a problem hiding this comment.
You can simplify this conversion and avoid an intermediate String allocation by using Box::from directly. Since Box<str> implements From<&str>, matched_rule.map(Box::from) is more efficient and idiomatic.
| matched_rule: matched_rule.map(|rule| rule.to_string().into_boxed_str()), | |
| matched_rule: matched_rule.map(Box::from), |
Summary
Builds on
17dbed13(feat(execpolicy): wire permissions.toml ask-rules into runtime) by exposing the matched execution-policy rule on approval request events.This is an explainability-only slice. It does not change approval semantics, does not persist permissions, and does not add typed allow/deny behavior.
What changed
matched_rulemetadata toExecApprovalRequestEvent.ExecPolicyDecision::matched_ruleinto approval request frames.approval.required.matched_rulefield.GenericEventFramepayloads to keep clippy happy after extending the protocol event shape.Non-goals
Related discussion:
Validation
cargo fmt --all --checkcargo test -p codewhale-hooks -p codewhale-core -p codewhale-protocol --all-features --lockedcargo clippy -p codewhale-hooks -p codewhale-core -p codewhale-protocol --all-targets --all-features --locked -- -D warningscargo check --lockedNote: I also tried
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings, but it currently stops on an unrelated upstream lint incrates/tui/src/client/responses.rs:327(clippy::collapsible_match).