keep-enclave: extract enforce_destination_policies from handle_sign_psbt#822
Conversation
|
Warning Review limit reached
Next review available in: 21 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
handle_sign_psbtinlined a per-destination policy-evaluation loop between PSBT analysis and signing. This extracts that loop intoenforce_destination_policies, isolating the policy-enforcement boundary into a named unit.Changes
enforce_destination_policies(&mut self, analysis, key_id, total_spend, timestamp) -> Option<EnclaveResponse>evaluates the policy engine against each non-change destination and returns the error response to send back on the firstDeny/RequireApproval, orNonewhen all destinations are allowed.handle_sign_psbt(81 → 57 lines) now delegates to it:if let Some(denied) = self.enforce_destination_policies(...) { return denied; }.Behavior
Pure code motion. The loop body is unchanged (same change-output skip, same
SigningContext, sameDeny/RequireApprovalerror codes and messages). The method takes&mut selfbecausePolicyEngine::evaluatemutates rate-limiter state, matching the original&mut selfreceiver.Verification
Note:
keep-enclave-binis excluded from the Cargo workspace, so the standardcargo test --workspaceCI does not build it. Verified standalone instead:cargo check --manifest-path keep-enclave/enclave/Cargo.toml: clean.cargo clippy --manifest-path keep-enclave/enclave/Cargo.toml --all-targets: no new warnings.cargo test --manifest-path keep-enclave/enclave/Cargo.toml: 12 passed.