fix(agent-vault): add no-op rotation rejection for admin and orchestr… - #80
fix(agent-vault): add no-op rotation rejection for admin and orchestr…#80SudiptaPaul-31 wants to merge 10 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe Agent Vault adds ChangesAgent Vault rotation guards
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@contracts/agent-vault/src/lib.rs`:
- Around line 602-605: The orchestrator rotation flow must reject same-address
requests before any TTL refresh or persistent-state mutation. In the relevant
rotation method, preserve the existing validation and ownership-check order,
move the user-configuration and reverse-lookup TTL extensions to after the no-op
guard comparing new_orchestrator with old_orchestrator, and retain
VaultError::NoChange for identical addresses.
In `@contracts/agent-vault/src/tests.rs`:
- Around line 2663-2679: The no-op admin rotation test should not inspect
Events::all() after the failed invocation, since that collection cannot prove
event absence. In contracts/agent-vault/src/tests.rs:2663-2679, retain the
NoChange error assertion and remove the post-failure zero-event assertion; in
contracts/agent-vault/src/tests.rs:2681-2707, update the successful rotation
tests to assert that exactly one event is emitted.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: ae688896-462b-4541-8824-6bf6d58203e9
📒 Files selected for processing (2)
contracts/agent-vault/src/lib.rscontracts/agent-vault/src/tests.rs
|
@SudiptaPaul-31 fix failing CI |
…to fix-no-op-admin
|
fix formatting and clippy errors @SudiptaPaul-31 |
Summary
Reject no-op admin and orchestrator rotations in CleverVault. Both
update_admin()andupdate_orchestrator()now validate that the new value differs from the current value before emitting state changes or events. This prevents phantom "rotations" from polluting the on-chain event stream and surfaces client bugs (e.g., forms submitted without changes) instead of silently accepting no-ops.Related issue
Closes #70
Changes
VaultError::NoChange = 19to the error enum for explicit no-op rejection feedbackupdate_admin()to reject rotations wherenew_admin == stored_admin, after all security checks (auth, authorization)update_orchestrator()to reject rotations wherenew_orchestrator == old_orchestrator, after all security checks (auth, active tasks, ownership validation)Testing
All tests written in standard Soroban test framework format using
soroban-sdk 25.3.0:Test coverage includes:
test_update_admin_rejects_no_op_rotation— verifies admin cannot rotate to selftest_update_orchestrator_rejects_no_op_rotation— verifies orchestrator cannot be updated to current valuetest_update_admin_legitimate_rotation_still_works— confirms legitimate chained rotations succeedtest_update_orchestrator_legitimate_rotation_still_works— confirms legitimate chained rotations succeedtest_update_admin_no_op_emits_no_event— verifies no event emitted on rejectiontest_update_orchestrator_no_op_emits_no_event— verifies no event emitted on rejectionOrchestratorNotRegisteredandActiveTaskExistserrors take precedence over no-op checkChecklist
npm run lintpassesnpm run typecheckpassesnpm testpassesnpm run format:checkpassescargo fmt --check,cargo clippy,cargo testpass incontracts/agent-vault✓CONTRACT_VERSIONwas bumped — no interface/layout changes, only validation addedSummary by CodeRabbit