Skip to content

docs(agent-vault): decide and enforce non-Active agent exit paths (#865) - #896

Open
huangji6693-max wants to merge 1 commit into
ExcelDsigN-tech:mainfrom
huangji6693-max:docs/agent-vault-non-active-exit-paths-865
Open

huangji6693-max wants to merge 1 commit into
ExcelDsigN-tech:mainfrom
huangji6693-max:docs/agent-vault-non-active-exit-paths-865

Conversation

@huangji6693-max

Copy link
Copy Markdown

Closes #865

Summary

Decides, documents, and enforces which agent_vault exit paths remain open to non-Active agents (Pending, Suspended, Expired, or unregistered) after the registry status gates introduced in #788 / #835:

  1. Liability-Reducing Unwind Paths Stay Open (burn_float, withdraw_collateral, and settle_net with delta <= 0):
    • agent_registry::withdraw_bond explicitly rejects Active agents (BondFrozen) and requires an agent to be non-Active while relying on agent_vault to enforce float == 0 before releasing USDC collateral.
    • Gating burn_float, withdraw_collateral, or negative settle_net adjustments behind assert_agent_active would strand a suspended or expired agent's float and collateral forever.
    • withdraw_collateral remains protected by the solvency invariant (float <= (collateral - amount) * haircut_bps / 10_000) and the minimum collateral floor (collateral - amount == 0 || collateral - amount >= min_collateral).
  2. Peer-to-Peer Float Routing Requires Both from and to to Be Active (transfer_float / transfer_to_agent):
    • Enforces Self::assert_agent_active(&env, &from)?; in transfer_float alongside Self::assert_agent_active(&env, &to)?; so suspended/expired agents cannot route float to peers and must unwind directly via burn_float or operator settlement (settle_net with delta < 0).
  3. Documentation & Unit Tests:
    • Documented the complete per-status matrix and unwind invariant in CONTRACTS.md under ### Registry Status Gate & Exit Paths (Issues #788, #835, #865).
    • Added unit tests in contracts/agent_vault/src/test.rs covering every non-Active status (None/unregistered, Pending, Suspended, Expired) across all four exit paths (test_transfer_float_rejects_non_active_sender, test_settle_net_allows_non_active_negative_delta, test_burn_float_allows_non_active_agents, test_withdraw_collateral_allows_non_active_agents).

Verification

  • CARGO_BUILD_JOBS=2 cargo test -p agent_vault — 55 passed (51 unit + 4 doc-tests)
  • CARGO_BUILD_JOBS=2 cargo clippy -p agent_vault --all-targets -- -D warnings — 0 warnings
  • CARGO_BUILD_JOBS=2 cargo build -p agent_vault --target wasm32v1-none --release — 40.7 KiB (< 256 KiB ceiling)

@coderabbitai

coderabbitai Bot commented Oct 26, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7277b242-4927-477e-b916-4b15868f4699
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

This branch has not been deployed

No deployments
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.

Decide and document which agent_vault exit paths a non-Active agent keeps

1 participant