Skip to content

feat: bump metagame_extensions to v0.1.3 (per-context bannable)#103

Merged
starknetdev merged 1 commit intomainfrom
feat/per-context-bannable
Apr 21, 2026
Merged

feat: bump metagame_extensions to v0.1.3 (per-context bannable)#103
starknetdev merged 1 commit intomainfrom
feat/per-context-bannable

Conversation

@starknetdev
Copy link
Copy Markdown
Member

@starknetdev starknetdev commented Apr 20, 2026

Summary

  • Bumps metagame_extensions_interfaces from v0.1.2 to v0.1.3
  • Adapts mocks and tests to the renamed bannable(context_id) interface (formerly registration_only())

Context

metagame_extensions v0.1.3 made the bannable flag per-context rather than a global validator setting (Provable-Games/metagame_extensions#17). This requires interface implementers to update their mock signatures.

Changes

  • 5 mocks: registration_only: bool storage → bannable: Map<u64, bool>, removed from constructor
  • 1 test file: removed registration_only from deploy helpers and call sites

Test plan

  • scarb build passes
  • snforge test --workspace passes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Dependencies

    • Updated metagame extension interfaces dependency to v0.1.3.
  • Updates

    • Enhanced entry requirement validation system to support context-specific configuration instead of global settings.
    • Updated all test utilities and mock validator contracts to align with the revised requirement interface.

Adapts mocks and tests to the new IEntryRequirementExtension interface:
- registration_only() removed; replaced with bannable(context_id) -> bool
- Mock constructors no longer take registration_only parameter
- Test deploy helpers updated accordingly

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

📝 Walkthrough

Walkthrough

The pull request updates the metagame_extensions_interfaces dependency to version v0.1.3 and refactors all mock contract implementations to align with the new interface version. Storage fields transition from a single registration_only: bool flag to a per-context bannable: Map<u64, bool> mapping, and corresponding interface methods now accept a context_id parameter. Constructor signatures are simplified by removing the registration_only parameter.

Changes

Cohort / File(s) Summary
Dependency Update
Scarb.toml
Updated metagame_extensions_interfaces workspace dependency from git tag v0.1.2 to v0.1.3.
Metagame Mock Contracts
packages/metagame/src/entry_requirement/tests/mocks/accepting_limited_entry_validator_mock.cairo, entry_validator_mock.cairo, rejecting_entry_validator_mock.cairo
Storage schema changed from registration_only: bool to bannable: Map<u64, bool>. Constructor signatures updated to remove registration_only parameter. Interface method registration_only() replaced with bannable(context_id: u64) that reads per-context ban status. Storage imports updated to include Map and StorageMapReadAccess.
Metagame Test Helpers
packages/metagame/src/entry_requirement/tests/test_entry_requirement_component.cairo
Removed registration_only boolean argument from local deployment helper functions: deploy_entry_validator_mock, deploy_rejecting_entry_validator_mock, and deploy_accepting_limited_entry_validator_mock. Adjusted all test call sites accordingly.
Test Common Mock Contracts
packages/test_common/src/mocks/mock_entry_validator.cairo, mock_rejecting_entry_validator.cairo
Storage schema changed from registration_only: bool to bannable: Map<u64, bool>. Constructor signatures updated to remove registration_only parameter. Interface method registration_only() replaced with bannable(context_id: u64) for per-context lookups. Storage imports updated to support mapped storage access.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Poem

🐰 A mapping blooms where booleans once stood,
Per-context wisdom now understood—
No single flag, but many keys,
Mock contracts dance in harmony!
Version bumped, the interfaces align,
The warren's tests now feel so fine! 🌟

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: bumping metagame_extensions to v0.1.3 with the key feature change (per-context bannable). It is concise and specific to the primary change.
Description check ✅ Passed The description covers most template sections including Summary, Context, Changes, and Test plan with specific commands run. However, several sections are missing: Scope checkboxes, Change Type selection, full Validation details, Risk level, Rollout plan, Breaking Changes declaration, Assumptions, Exceptions, Workarounds, and Linked Issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/per-context-bannable

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 and usage tips.

@github-actions
Copy link
Copy Markdown

Codex Review - General Engineering Review

Review process failed to complete.

@claude
Copy link
Copy Markdown

claude Bot commented Apr 20, 2026

Claude finished @starknetdev's task —— View job


Claude Review - General Engineering Review

run=24693726927 attempt=1 sha=3850f52fb1c5afb397e2a725d4f8c303884b2479 scope=general

Todo List

  • Read changed files and analyze scope
  • Review Scarb.toml dependency version bump
  • Check for CI/CD configuration impacts
  • Verify documentation consistency
  • Post final review findings

Review Findings

After analyzing the targeted diff outside the packages/ directory, there is only one change in scope: the version bump in Scarb.toml.

Change Analysis:

  • File: Scarb.toml:40
  • Change: metagame_extensions_interfaces dependency updated from v0.1.2 to v0.1.3
  • Impact: This is a standard dependency version bump that aligns with the PR's stated goal

Infrastructure Impact Assessment:
✅ No CI/CD configuration changes needed - this is a dependency version bump that doesn't affect build matrix or workflow configuration
✅ No documentation updates required - the change is self-explanatory and covered in the PR description
✅ Version format is correct (v0.1.3 follows semantic versioning)
✅ Git reference format is consistent with other dependencies in the workspace

No actionable findings inside the scoped diff.

The dependency version bump in Scarb.toml is correct, properly formatted, and consistent with the project's dependency management patterns. The change supports the interface evolution described in the PR without requiring any infrastructure modifications.

Summary: 0 CRITICAL, 0 HIGH, 0 MEDIUM, 0 LOW, 0 INFO


@claude
Copy link
Copy Markdown

claude Bot commented Apr 20, 2026

Claude finished @starknetdev's task —— View job


Claude Review - Cairo/Starknet Contract Review

run=24693726927 attempt=1 sha=3850f52fb1c5afb397e2a725d4f8c303884b2479 scope=packages

Todo List

  • Read and analyze changed files
  • Review security implications of interface changes
  • Check Cairo idioms compliance
  • Verify testing approach and coverage
  • Look for gas optimization opportunities
  • Provide comprehensive review findings

Review Findings

[MEDIUM] packages/test_common/src/mocks/mock_entry_validator.cairo:47 - Missing setter function for bannable storage
Impact: The bannable Map storage was added but there's no way to set values in it. Tests cannot configure per-context bannable behavior, making the new interface non-functional in test scenarios.
Fix: Add a setter function like fn set_bannable(ref self: ContractState, context_id: u64, value: bool) { self.bannable.entry(context_id).write(value); }

[MEDIUM] packages/test_common/src/mocks/mock_rejecting_entry_validator.cairo:47 - Missing setter function for bannable storage
Impact: Same as above - no way to configure the bannable Map.
Fix: Add a setter function like fn set_bannable(ref self: ContractState, context_id: u64, value: bool) { self.bannable.entry(context_id).write(value); }

[MEDIUM] packages/metagame/src/entry_requirement/tests/mocks/*.cairo - All mock files missing setter functions
Impact: All 5 mock contracts have the same issue - bannable storage exists but cannot be configured.
Fix: Add setter functions to all mock contracts to enable proper testing of the per-context bannable functionality.

[LOW] packages/metagame/src/entry_requirement/tests/test_entry_requirement_component.cairo - Missing test coverage for bannable functionality
Impact: No tests verify the new per-context bannable behavior, reducing confidence in the interface migration.
Fix: Add test cases that set bannable flags for specific contexts and verify the behavior is context-specific (e.g., context 1 bannable=true, context 2 bannable=false).

[INFO] All files - Proper Cairo idiom usage
Impact: None - the changes correctly use Map<u64, bool> with proper imports and follow Cairo 2.16.1 conventions.

[INFO] All files - Constructor signature change is correct
Impact: None - removing registration_only parameter from constructors is appropriate since the flag is now per-context rather than global.

Summary: 0 CRITICAL, 0 HIGH, 3 MEDIUM, 1 LOW, 2 INFO

Key Issue: The interface migration is incomplete. While the storage and function signatures were updated correctly, the mock contracts lack the ability to actually configure the bannable values for testing. This makes the new per-context functionality untestable and effectively non-functional in test scenarios.

Recommendation: Add setter functions to all mock contracts and create test cases that verify per-context bannable behavior works correctly.

@github-actions
Copy link
Copy Markdown

Codex Review - Cairo/Starknet Contract Review

Review process failed to complete.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the metagame_extensions_interfaces dependency to v0.1.3 and refactors several entry validator mocks. The registration_only boolean has been replaced with a bannable storage map across multiple mock contracts, and the corresponding constructors and test deployment functions have been updated. Feedback focuses on the fact that the new bannable storage maps are never written to, causing them to always return false. This is inconsistent with the intended behavior of mocks like the rejecting validator, which should return true for bannable. It is recommended to remove the unused storage variables and return constant values directly to simplify the code.

Comment on lines +22 to 23
bannable: Map<u64, bool>,
#[substorage(v0)]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The bannable map is added to storage but never written to, meaning it will always return false for any context_id. In this specific mock, should_ban returns true (line 67), which is inconsistent with a non-bannable validator. Since this is a mock that always rejects and supports banning, it should return true for bannable. You can simplify this by removing the storage variable and returning a constant in the function, which also avoids the need for the new Map and StorageMapReadAccess imports.

        #[substorage(v0)]

Comment on lines +47 to 48
self.bannable.read(context_id)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This should return true to be consistent with the mock's purpose and its should_ban implementation. Returning false (the default for an uninitialized map) might cause the system to skip the ban check entirely.

            true
        }

Comment on lines +22 to 23
bannable: Map<u64, bool>,
#[substorage(v0)]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The bannable map is uninitialized and never written to. For a mock with fixed behavior, it's better to remove this from storage and return a constant in the implementation.

        #[substorage(v0)]

Comment on lines +47 to 48
self.bannable.read(context_id)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This mock's should_ban returns true (line 67), so bannable should also return true to be consistent. Returning false (the default for an uninitialized map) might cause the system to skip the ban check entirely.

            true
        }

Comment on lines +23 to 24
bannable: Map<u64, bool>,
#[substorage(v0)]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The bannable map is added to storage but never written to. Since this mock is intended to always return a fixed value (false), you can simplify it by removing the storage variable and returning false directly in the function.

        #[substorage(v0)]

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/metagame/src/entry_requirement/tests/mocks/rejecting_entry_validator_mock.cairo (1)

22-48: ⚠️ Potential issue | 🟠 Major

Add a setter to allow the bannable state to be configured in the rejecting mock.

The bannable map is declared but never written, causing bannable(context_id) to always return false while should_ban() always returns true. This creates a logical inconsistency where tests gating the ban path behind a bannable check won't exercise rejection. Add StorageMapWriteAccess to imports and provide a mock setter or initialization path to configure this state during test setup.

Example: add a setter function
 use starknet::storage::{
-    Map, StorageMapReadAccess, StoragePointerReadAccess, StoragePointerWriteAccess,
+    Map, StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess,
+    StoragePointerWriteAccess,
 };

@@ -36,6 +36,11 @@ pub mod RejectingEntryValidatorMock {
     #[constructor]
     fn constructor(ref self: ContractState, owner: ContractAddress) {
         self.owner_address.write(owner);
         self.src5.register_interface(IENTRY_REQUIREMENT_EXTENSION_ID);
     }
+
+    #[external(v0)]
+    fn set_bannable(ref self: ContractState, context_id: u64, value: bool) {
+        self.bannable.write(context_id, value);
+    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/metagame/src/entry_requirement/tests/mocks/rejecting_entry_validator_mock.cairo`
around lines 22 - 48, The rejecting_entry_validator_mock defines a read-only
bannable: Map<u64, bool> but never writes to it, so bannable(context_id) always
returns false; add StorageMapWriteAccess to the imports and implement a setter
(e.g., set_bannable or set_bannable_state) on the mock contract that writes into
the bannable map so tests can configure bannable per context_id; update the
mock's ABI/impl (EntryValidatorImpl/IEntryRequirementExtension) to expose the
setter and ensure tests call it during setup so should_ban() and
bannable(context_id) behave consistently.
packages/test_common/src/mocks/mock_rejecting_entry_validator.cairo (1)

22-48: ⚠️ Potential issue | 🟠 Major

Add a setter to configure bannable for test scenarios.

The bannable map is never written, so bannable(context_id) always returns false regardless of context. Although should_ban() returns true, tests cannot exercise per-context bannable rejection behavior. Add a test-only setter to make the mock configurable.

Suggested implementation
 use starknet::storage::{
-    Map, StorageMapReadAccess, StoragePointerReadAccess, StoragePointerWriteAccess,
+    Map, StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess,
+    StoragePointerWriteAccess,
 };

@@
     #[constructor]
     fn constructor(ref self: ContractState, owner: ContractAddress) {
         self.owner_address.write(owner);
         self.src5.register_interface(IENTRY_REQUIREMENT_EXTENSION_ID);
     }
+
+    #[external(v0)]
+    fn set_bannable(ref self: ContractState, context_id: u64, value: bool) {
+        self.bannable.write(context_id, value);
+    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/test_common/src/mocks/mock_rejecting_entry_validator.cairo` around
lines 22 - 48, The bannable Map<u64, bool> is never written so
bannable(context_id) always returns false; add a test-only setter method (e.g.,
fn set_bannable(self: `@ContractState`, context_id: u64, value: bool)) on the
EntryValidatorImpl or as an extra #[external] test helper that writes to
self.bannable.write(context_id, value) so tests can configure per-context
bannable values; reference the bannable field, the existing bannable(self:
`@ContractState`, context_id: u64) accessor, and add the new setter to the same
impl block so test code can toggle rejection behavior.
🧹 Nitpick comments (1)
packages/metagame/src/entry_requirement/tests/test_entry_requirement_component.cairo (1)

406-421: Add coverage for per-context bannable behavior.

The helper updates keep deployments compiling, but the new v0.1.3 behavior isn’t asserted: no test configures different bannable values for different context_ids or verifies the ban path. Please add a focused test once the mocks expose a way to set bannable(context_id).

As per coding guidelines, **/*test*.cairo: “Achieve and maintain 90% line coverage for tests; edge cases must be fuzzed” and “Track test coverage; coverage must not decrease after changes.”

Also applies to: 627-634

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/metagame/src/entry_requirement/tests/test_entry_requirement_component.cairo`
around lines 406 - 421, The tests lack coverage for per-context bannable
behavior; add a new focused test that uses the entry validator mocks (targeting
deploy_entry_validator_mock and deploy_rejecting_entry_validator_mock) to set
different bannable(context_id) values for at least two context IDs, exercise
both the accept and ban paths (e.g., attempt entry where bannable=false and
where bannable=true leading to ban), and assert expected outcomes (success vs.
ban event/state) and any expected error messages; if the current mocks do not
expose a setter for bannable(context_id), extend the mocks to provide a method
to set bannable per context and then use that in the new test so the behavior
for v0.1.3 is covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In
`@packages/metagame/src/entry_requirement/tests/mocks/rejecting_entry_validator_mock.cairo`:
- Around line 22-48: The rejecting_entry_validator_mock defines a read-only
bannable: Map<u64, bool> but never writes to it, so bannable(context_id) always
returns false; add StorageMapWriteAccess to the imports and implement a setter
(e.g., set_bannable or set_bannable_state) on the mock contract that writes into
the bannable map so tests can configure bannable per context_id; update the
mock's ABI/impl (EntryValidatorImpl/IEntryRequirementExtension) to expose the
setter and ensure tests call it during setup so should_ban() and
bannable(context_id) behave consistently.

In `@packages/test_common/src/mocks/mock_rejecting_entry_validator.cairo`:
- Around line 22-48: The bannable Map<u64, bool> is never written so
bannable(context_id) always returns false; add a test-only setter method (e.g.,
fn set_bannable(self: `@ContractState`, context_id: u64, value: bool)) on the
EntryValidatorImpl or as an extra #[external] test helper that writes to
self.bannable.write(context_id, value) so tests can configure per-context
bannable values; reference the bannable field, the existing bannable(self:
`@ContractState`, context_id: u64) accessor, and add the new setter to the same
impl block so test code can toggle rejection behavior.

---

Nitpick comments:
In
`@packages/metagame/src/entry_requirement/tests/test_entry_requirement_component.cairo`:
- Around line 406-421: The tests lack coverage for per-context bannable
behavior; add a new focused test that uses the entry validator mocks (targeting
deploy_entry_validator_mock and deploy_rejecting_entry_validator_mock) to set
different bannable(context_id) values for at least two context IDs, exercise
both the accept and ban paths (e.g., attempt entry where bannable=false and
where bannable=true leading to ban), and assert expected outcomes (success vs.
ban event/state) and any expected error messages; if the current mocks do not
expose a setter for bannable(context_id), extend the mocks to provide a method
to set bannable per context and then use that in the new test so the behavior
for v0.1.3 is covered.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 184518ad-5e94-4f49-a640-3af619c379a7

📥 Commits

Reviewing files that changed from the base of the PR and between ffbb576 and 3850f52.

📒 Files selected for processing (7)
  • Scarb.toml
  • packages/metagame/src/entry_requirement/tests/mocks/accepting_limited_entry_validator_mock.cairo
  • packages/metagame/src/entry_requirement/tests/mocks/entry_validator_mock.cairo
  • packages/metagame/src/entry_requirement/tests/mocks/rejecting_entry_validator_mock.cairo
  • packages/metagame/src/entry_requirement/tests/test_entry_requirement_component.cairo
  • packages/test_common/src/mocks/mock_entry_validator.cairo
  • packages/test_common/src/mocks/mock_rejecting_entry_validator.cairo

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@starknetdev starknetdev merged commit 2a45189 into main Apr 21, 2026
24 of 27 checks passed
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.

1 participant