Skip to content

Conversation

@ccamel
Copy link
Member

@ccamel ccamel commented Jan 24, 2026

Governance attached to an Abstract Account is unique by nature. An account must not host multiple axone-gov instances because that would create ambiguity about which constitution and which decision space is authoritative.

Truns out that Abstract already enforces a single module address per module id. This PR makes that constraint explicit in axone-gov to fail early with a domain specific error and to protect against non standard deployment flows or misconfiguration.

Summary by CodeRabbit

  • New Features

    • Governance module installations are now validated to enforce single installation per account, with proper error handling for duplicate installation attempts.
  • Tests

    • Added integration tests covering governance module installation validation scenarios, including both successful installations and appropriate error responses.

✏️ Tip: You can customize this high-level summary in your review settings.

@ccamel ccamel self-assigned this Jan 24, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 24, 2026

Walkthrough

This PR introduces module installation uniqueness enforcement for the AXONE_GOV_ID module within Abstract accounts. A pre-check during instantiation prevents duplicate installations by detecting existing module registrations and returning a domain-specific error. Supporting changes include a new error variant, comprehensive integration tests, and minor refactoring in prolog utilities.

Changes

Cohort / File(s) Summary
Module Installation Validation
contracts/axone-gov/src/error.rs, contracts/axone-gov/src/handlers/instantiate.rs
Added ModuleAlreadyInstalled error variant with module_id, account, and address fields. Integrated uniqueness check (ensure_gov_uniqueness) at instantiation start to prevent duplicate AXONE_GOV_ID installations per Abstract account.
Integration Testing
contracts/axone-gov/tests/integration.rs
Added two new tests: instantiate_succeeds_without_registered_gov (success path) and instantiate_fails_when_gov_already_registered (error path validating duplicate installation rejection). Imported AXONE_GOV_ID constant.
Configuration & Utility Refactoring
contracts/axone-gov/pyproject.toml, contracts/axone-gov/src/prolog/ast.rs, contracts/axone-gov/src/prolog/lexer.rs
Reformatted dist_glob_patterns to multi-line array. Refactored Term::List groundness condition check. Updated Tok impl block lifetime parameter from named ('a) to placeholder ('_).

Sequence Diagram(s)

sequenceDiagram
    participant Test
    participant InstantiateHandler as Instantiate Handler
    participant ModuleRegistry as Module Registry (Deps)
    participant AxoneGov as AxoneGov Instance

    Test->>InstantiateHandler: call instantiate(env, module)
    InstantiateHandler->>ModuleRegistry: query existing AXONE_GOV_ID<br/>for account
    alt Module Already Installed
        ModuleRegistry-->>InstantiateHandler: existing address found
        InstantiateHandler-->>Test: error: ModuleAlreadyInstalled
    else First Installation
        ModuleRegistry-->>InstantiateHandler: no existing module
        InstantiateHandler->>AxoneGov: proceed with initialization<br/>(constitution setup, save state)
        AxoneGov-->>InstantiateHandler: instantiate response<br/>(revision, hash)
        InstantiateHandler-->>Test: success response
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title uses an emoji and vague phrasing ('Feat/gov uniqueness') that obscures the specific intent—enforcing singleton governance instances per Abstract account. Revise to a concrete, descriptive title such as 'Enforce singleton governance instance per Abstract account' or 'Add early validation for duplicate governance module installation'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/gov-uniqueness

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.

@codecov
Copy link

codecov bot commented Jan 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
contracts/axone-gov/src/handlers/instantiate.rs 100.00% <100.00%> (ø)
contracts/axone-gov/src/prolog/ast.rs 98.71% <100.00%> (-0.01%) ⬇️
contracts/axone-gov/src/prolog/lexer.rs 79.31% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bot-anik
Copy link
Member

bot-anik commented Jan 24, 2026

size-limit report 📦

Path Size
target/wasm32-unknown-unknown/release/axone_gov.wasm 775.89 KB (+0.77% 🔺)

@ccamel ccamel force-pushed the feat/gov-uniqueness branch from 28640ca to 49ccdad Compare January 24, 2026 17:37
@ccamel ccamel marked this pull request as ready for review January 24, 2026 17:40
@ccamel ccamel merged commit 7b57dde into main Jan 24, 2026
23 checks passed
@ccamel ccamel deleted the feat/gov-uniqueness branch January 24, 2026 17:45
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.

3 participants