Repository navigation
fix(contracts): enforce and document agent_vault exit paths (#865) - #909
Open
jeffrey-graham wants to merge 1 commit into
Open
jeffrey-graham wants to merge 1 commit into
jeffrey-graham wants to merge 1 commit into
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Defines, documents, and enforces the
agent_vaultexit paths perAgentStatus(follow-up to #835):SuspendedandExpiredagents keep safe unwind/exit paths (burn_float,withdraw_collateral, and non-positivesettle_netdeltasdelta <= 0) so customer cash-outs, end-of-day net-downs, and collateral recovery (withdraw_collateral+agent_registry::withdraw_bondoncefloat == 0) are never trapped.transfer_float/transfer_to_agent) require bothfromandtoto beActive(VaultError::AgentNotFoundotherwise).Pendingand unregistered agents are rejected across all issuance and exit paths (VaultError::AgentNotFound) when a registry is configured.Closes #865
Technical Implementation
contracts/agent_vault/src/lib.rs:assert_agent_can_exit(env, agent)requiringAgentStatus::Active | AgentStatus::Suspended | AgentStatus::Expiredwhen a registry is wired viaset_registry.assert_agent_activeonfromintransfer_float(alongsideto).assert_agent_can_exitonburn_float,withdraw_collateral, and non-positivesettle_netentries (delta <= 0).CONTRACTS.md:### Registry Status Gate & Exit Paths (Issues #788, #835, #865)documenting the rationale and per-status entry/exit matrix.contracts/agent_vault/src/test.rs:MockRegistrywith per-agent status overrides (set_agent_status) so two-agent calls can isolate sender vs. recipient statuses.test_transfer_float_rejects_non_active_sender,test_burn_float_exit_paths_by_status,test_withdraw_collateral_exit_paths_by_status, andtest_settle_net_negative_delta_exit_paths_by_status.Test Coverage
cargo fmt --all -- --check: passedcargo clippy -p agent_vault --all-targets -- -D warnings: 0 warningscargo test -p agent_vault -- --test-threads=1: 55 passedwasm32-unknown-unknown --release):agent_vault.wasm41,937 bytes (< 256 KiB budget).Checklists
Issue Definition of Done
CONTRACTS.mddocuments the allowed exit paths per status-D warnings, every wasm under 256 KiB