feat: add per-agent blocklist with precedence over the allowlist#64
Merged
mikewheeleer merged 1 commit intoJun 24, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Adds a per-agent blocklist (deny list) to the escrow contract, independent of the existing allowlist. The admin can deny specific agents regardless of whether the allowlist is enabled.
DataKey::AgentBlocked(Address)persistent flag (defaults to not-blocked when absent).AgentBlocked = 15(append-only; no existing codes renumbered).set_agent_blocked(agent, blocked)(admin-auth) and readeris_agent_blocked(agent) -> bool.record_usagerejects a blocked agent withAgentBlocked.Closes #36
Precedence
The blocklist check runs immediately before the allowlist check and takes precedence over it: an agent that is both allow-listed and blocked is still rejected with
AgentBlocked. The fullrecord_usagerejection precedence is now:paused (#4) -> zero requests (#2) -> max (#8) -> min (#9) -> registration (#7) -> disabled (#12) -> blocklist (#15) -> allowlist (#10)
Default behaviour is unchanged when the feature is unused: an absent
AgentBlockedentry reads asfalse.Security notes
set_agent_blockedis admin-gated via the standardDataKey::Admin+require_auth()pattern (panicsNotInitializedif uninitialized); a non-admin caller is rejected as unauthorized.15is append-only, keeping client SDK error mappings stable.Tests
Added: blocked agent -> #15; block beats allowlist (allowlist enabled + agent allowed + blocked) -> #15; blocked while allowlist disabled -> #15; unblock then record succeeds;
is_agent_blockedround-trip (default false); non-adminset_agent_blockedrejected (unauthorized).cargo fmt --all -- --check,cargo build, andcargo testall pass:🤖 Generated with Claude Code