Skip to content

keep-enclave: extract enforce_destination_policies from handle_sign_psbt#822

Merged
kwsantiago merged 1 commit into
mainfrom
refactor/enclave-handle-sign-psbt
Jul 16, 2026
Merged

keep-enclave: extract enforce_destination_policies from handle_sign_psbt#822
kwsantiago merged 1 commit into
mainfrom
refactor/enclave-handle-sign-psbt

Conversation

@kwsantiago

Copy link
Copy Markdown
Contributor

handle_sign_psbt inlined a per-destination policy-evaluation loop between PSBT analysis and signing. This extracts that loop into enforce_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 first Deny / RequireApproval, or None when 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, same Deny/RequireApproval error codes and messages). The method takes &mut self because PolicyEngine::evaluate mutates rate-limiter state, matching the original &mut self receiver.

Verification

Note: keep-enclave-bin is excluded from the Cargo workspace, so the standard cargo test --workspace CI 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.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@kwsantiago, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 21 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 081c16ee-74d3-48af-9549-fbd3cee32b75

📥 Commits

Reviewing files that changed from the base of the PR and between c77314b and 9a58af8.

📒 Files selected for processing (1)
  • keep-enclave/enclave/src/vsock_server.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/enclave-handle-sign-psbt

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kwsantiago kwsantiago merged commit 64c7c91 into main Jul 16, 2026
9 checks passed
@kwsantiago kwsantiago deleted the refactor/enclave-handle-sign-psbt branch July 16, 2026 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant