Nathan Schneider a0785f09cf Implement platform skill execution system and fix message formatting
Major features:
- Added platform skill execution architecture allowing agent to invoke
  platform-specific actions (delete posts, update rules, announcements)
- Agent now receives available platform skills and can execute them with
  proper authorization checks via constitution

Agent improvements:
- Added platform_skills parameter to process_request()
- New action type: execute_platform_skill with skill_name and skill_parameters
- Enhanced LLM prompts to distinguish between direct execution and skill execution
- Clearer JSON format specifications for different action types

Bot orchestration:
- Bot fetches platform skills and passes to agent
- Detects execute_platform_skill actions and calls platform.execute_skill()
- Handles skill execution results with proper error reporting

Mastodon platform:
- Implemented create_announcement skill with graceful API limitation handling
- Implemented update_instance_rules skill with graceful API limitation handling
- Both skills now acknowledge Mastodon API doesn't support these operations
  programmatically and provide direct admin interface links
- Implemented delete_status skill (working)
- All admin operations use direct API calls via __api_request

Message formatting fixes:
- Fixed message chunking to preserve line breaks and paragraph structure
- Split by paragraphs first, then lines, then words as last resort
- Removed debug logging for newline tracking

Documentation:
- Updated .gitignore to exclude bot.log and nohup.out

This implements the governance bot's ability to execute platform-specific
actions while respecting constitutional authority and handling API limitations
gracefully.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-09 22:45:31 -07:00

Govbot

An agentic governance bot for democratic communities that interprets natural language constitutions and facilitates collective decision-making across social platforms.

Overview

Govbot is designed to:

  • Read and interpret governance constitutions written in natural language
  • Facilitate any governance process defined in your constitution (proposals, disputes, elections, discussions, etc.)
  • Execute administrative actions based on constitutional rules
  • Maintain an audit trail of all governance activities
  • Support both local (Ollama) and cloud AI models
  • Work across multiple platforms (Mastodon, Discord, Telegram, etc.)

Key Concept: Govbot uses "process" as the central abstraction - a generic container for any governance activity (proposals, disputes, elections, etc.). Process types are not hard-coded; the LLM interprets your constitution to understand what types exist and how they work.

Features

  • Pure LLM-Driven Governance: No hard-coded governance logic - the LLM interprets the constitution and makes all decisions
  • Structured Memory System: Tracks governance processes, events, and decisions in a queryable format
  • LLM Tools for Correctness: Deterministic tools for math, dates, and random selection ensure reliability
  • Complete Auditability: Every decision includes reasoning, constitutional citations, and calculation details
  • RAG-based Constitutional Reasoning: Uses retrieval-augmented generation to understand and apply governance rules
  • Template Flexibility: Works with diverse governance models (petition, consensus, do-ocracy, jury, circles)
  • Platform-Agnostic: Same governance logic works across Mastodon, Discord, Telegram, Matrix, and more
  • Reversible Actions: All actions are logged and can be reversed through constitutional processes
  • Temporal Awareness: Handles multi-day governance processes with deadlines and reminders

Supported Platforms

  • Mastodon - Full implementation with streaming, admin, and moderation
  • 🚧 Discord - Coming soon (see PLATFORMS.md for implementation guide)
  • 🚧 Telegram - Coming soon
  • 🚧 Matrix - Planned

Want to add a platform? See PLATFORMS.md for the implementation guide!

Architecture

┌─────────────────────────────────────────┐
│         Governance Request              │
│    (Natural Language from User)         │
└────────────────┬────────────────────────┘
                 │
                 ▼
┌─────────────────────────────────────────┐
│       Governance Agent (LLM)            │
│  • Interprets constitution (RAG)        │
│  • Queries structured memory            │
│  • Uses tools for calculations          │
│  • Makes decisions with reasoning       │
│  • Generates audit trails               │
└────────────────┬────────────────────────┘
                 │
       ┌─────────┼─────────┐
       │         │         │
       ▼         ▼         ▼
  ┌────────┐ ┌──────┐ ┌───────┐
  │ Memory │ │Tools │ │ Audit │
  │ System │ │      │ │ Trail │
  └────┬───┘ └──────┘ └───────┘
       │
       ▼
┌──────────────────────────────┐
│   Platform Adapter Layer     │
└──────────┬───────────────────┘
           │
  ┌────────┼────────┐
  │        │        │
┌─▼──┐  ┌─▼──┐  ┌─▼──┐
│Mast││Disc││Tele│
│odon││ord ││gram│
└────┘  └────┘  └────┘

For detailed architecture documentation, see ARCHITECTURE.md.

Installation

# Install dependencies (using uv for faster installation)
uv pip install -e .

# For development
uv pip install -e ".[dev]"

Quick Start

1. Install Dependencies (above)

2. Configure (Credentials Required)

# Copy the template
cp config/config.example.yaml config/config.yaml

# Edit with your credentials
nano config/config.yaml

⚠️ IMPORTANT: config/config.yaml contains your secrets and is automatically ignored by git. Never commit this file.

Configure:

  • Platform credentials (Mastodon access tokens, Discord bot tokens, etc.)
  • AI model settings (Ollama local models or cloud API keys)
  • Constitution path and database location

For detailed setup instructions:

3. Set AI API Keys (if using cloud models)

# For OpenAI
llm keys set openai

# For Anthropic Claude
llm keys set anthropic

These are stored securely in ~/.llm/keys.json (also gitignored)

Usage

# Run the bot
python -m src.govbot.bot

# Query the constitution
python -m src.govbot.governance.constitution "What are the rules for proposals?"

Constitution Format

Your constitution should be a markdown file that describes:

  • Governance processes (proposals, voting, etc.)
  • Decision-making thresholds
  • Member rights and responsibilities
  • Administrative procedures
  • Safety mechanisms (veto, appeals, etc.)

See constitution.md for an example based on Social.coop's bylaws.

Documentation

Core Documentation

Setup Guides

Templates

  • templates/ - Governance template library (petition, consensus, do-ocracy, jury, circles, dispute resolution)

Security

⚠️ Important: Never commit config/config.yaml or other files containing credentials. All sensitive files are automatically protected by .gitignore.

See SECURITY.md for:

  • Complete list of protected files
  • Where to store credentials
  • Best practices for development and production
  • What to do if secrets are accidentally committed

Development Status

This is early-stage software. Current phase: Core infrastructure and agentic reasoning engine.

License

[To be determined]

Contributing

This project is in early development. Contributions and feedback welcome!

For platform developers: See PLATFORMS.md to add support for Discord, Telegram, Matrix, or other platforms.

Description
An agentic bot that administers the governance of online communities.
Readme 240 KiB
Languages
Python 100%