Skip to content

feat(smart-contract): add agent governance and voting mechanism - #455

Merged
devJaja merged 2 commits into
Epta-Node:mainfrom
nasarajoe:feat/agent-governance
Aug 31, 2026
Merged

feat(smart-contract): add agent governance and voting mechanism#455
devJaja merged 2 commits into
Epta-Node:mainfrom
nasarajoe:feat/agent-governance

Conversation

@nasarajoe

Copy link
Copy Markdown
Contributor

Summary

Implements an on-chain governance system where registered agents vote on
protocol changes, parameter updates, and agent disputes. Adds a new
agent_governance Soroban contract crate.

Closes #253

What's implemented

New crate: smart-contracts/contracts/agent_governance/

File Contents
src/lib.rs Governance contract logic
src/types.rs Proposal, vote, and agent-stake types + event payloads
src/errors.rs 16 stable #[contracterror] codes
src/test.rs 23 unit tests covering the full lifecycle

smart-contracts/Cargo.toml gains contracts/agent_governance as a
workspace member.

Functionality

  • create_proposal — registered-agent–gated; three proposal types
    (ParameterChange, AgentDispute, ProtocolUpgrade); configurable
    voting period (default 7 days, bounded 1 h–30 days); snapshots the
    electorate's total voting power into the proposal so quorum has a
    stable denominator.
  • Voting power — weighted by both reputation score and stake amount:
    voting_power = stake + reputation * REPUTATION_POWER_UNIT. Tracked in
    aggregate across all registered agents and cached per agent.
  • register_agent / update_agent — agents join the electorate with
    a reputation score ([0, 100]) and stake; aggregate power is kept in
    sync on updates.
  • vote_on_proposal — options For, Against, Abstain; one vote
    per agent, weighted by current voting power; rejects votes after the
    deadline or on non-active proposals.
  • execute_proposal — callable by anyone after the deadline.
    • Quorum: cast power (For + Against + Abstain) ≥ 30 % of the
      snapshotted total voting power.
    • Majority: For power strictly > 50 % of decisive power
      (For + Against; abstentions excluded). Zero decisive votes → fails.
    • Marks the proposal Executed or Failed accordingly.
  • View functionsget_proposal, get_vote, get_agent,
    get_total_voting_power, get_proposal_count.

Events

ProposalCreated, VoteCast, ProposalExecuted, ProposalFailed
(plus agent_reg / agent_upd), all under the gov topic namespace.

Testing

  • cargo test -p agent-governance23 passed, 0 failed
    • proposal lifecycle across all three proposal types
    • voting-power weighting by stake + reputation
    • quorum failure (low turnout), majority failure (exact 50 % tie)
    • abstain counts toward quorum but not majority; all-abstain fails
    • double-vote, double-execute, vote-after-finalize, unregistered-voter guards
    • event emission on vote and execution
  • cargo clippy -p agent-governance --all-targets — clean, no warnings
  • cargo fmt applied

Acceptance criteria

  • create_proposal function for governance proposals
  • Voting power weighted by reputation score and stake amount
  • vote_on_proposal with options: For, Against, Abstain
  • Proposal types: parameter_change, agent_dispute, protocol_upgrade
  • Quorum requirement: minimum 30% of total voting power
  • Majority requirement: >50% of cast votes (excluding abstentions)
  • Time-limited voting periods (configurable, default 7 days)
  • Events: ProposalCreated, VoteCast, ProposalExecuted, ProposalFailed
  • Unit tests for proposal lifecycle, voting, and execution

@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

@nasarajoe is attempting to deploy a commit to the Jaja's projects Team on Vercel.

A member of the Team first needs to authorize it.

@devJaja
devJaja merged commit 5e473c3 into Epta-Node:main Aug 31, 2026
1 check failed
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.

feat(smart-contract): Add Agent Governance and Voting Mechanism

2 participants