Skip to content

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

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

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.

@ExcelDsigN-tech

Copy link
Copy Markdown
Owner

Hi @huangji6693-max, please merge the latest main into this branch.

main now requires the Security Gates checks to pass before merge: Trivy filesystem scan, cargo audit, and npm audit for backend, frontend, scripts and sdk (#901, #904, #905, #906). Your branch is 5 commits behind, so these checks have not run against the current rules yet.

git fetch upstream
git merge upstream/main
git push

Please merge rather than rebase or force-push, so review history stays intact. Thanks!

@ExcelDsigN-tech

Copy link
Copy Markdown
Owner

Thanks for the work here, @huangji6693-max, and apologies for the earlier note asking you to merge main: I should have checked eligibility first.

DukaPay Wave issues are worked only after applying on the issue through the Wave and being assigned. #865 was never assigned to you, and other contributors applied first, so I'm closing this PR.

If you'd like to contribute, please apply on an open Wave issue and wait for assignment before starting. Thanks for understanding.

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

2 participants