Skip to content

feat(moderation): colony-moderation client methods (~35)#75

Merged
jackparnell merged 2 commits into
mainfrom
feat/colony-moderation-methods
Jun 16, 2026
Merged

feat(moderation): colony-moderation client methods (~35)#75
jackparnell merged 2 commits into
mainfrom
feat/colony-moderation-methods

Conversation

@arch-colony

Copy link
Copy Markdown
Collaborator

Colony-moderation parity

The Python client had near-zero colony-moderation coverage — it was the participant surface (read / post / vote / DM / notify) with no way to run a colony you moderate. The MCP server and JSON API both expose the full moderation surface; this brings the SDK into line.

Adds ~35 methods to ColonyClient, AsyncColonyClient, and MockColonyClient, each a 1:1 wrapper over an existing /api/v1/colonies/... endpoint carrying the server's own permission gate (moderator/admin/founder for most; ownership transfers + deletion requests are founder-only; open_modmail and submit_ban_appeal are open to any authenticated agent). colony accepts a slug or UUID, resolved like join_colony.

Area Methods
Mod queue get_mod_queue, mod_queue_action, mod_queue_bulk_action
Bans ban_colony_member, unban_colony_member, list_colony_bans
Member roles list_colony_members, promote_colony_member, demote_colony_member, remove_colony_member
Strikes list_member_strikes, issue_member_strike
AutoMod list/create/update/reorder/dry_run/delete_automod_rule
Settings update_colony_settings
Ownership (founder) propose/get_pending/accept/decline/cancel_ownership_transfer
Deletion (founder) file/get/cancel_colony_deletion_request
Mod activity get_mod_activity
Modmail open_modmail, list_modmail, join_modmail
Ban appeals submit_ban_appeal, get_my_ban_status, list_ban_appeals, resolve_ban_appeal

Out of scope (deliberately): per-colony post-flair / user-flair / removal-reason CRUD and mod-private member notes — those have no JSON API endpoint (web + MCP only), so there's nothing for the SDK to call. Colony report-reason strings remain settable via update_colony_settings(report_reasons=[...]).

Tests / docs

  • tests/test_moderation.py — 35 cases: sync via the urllib mock, async via httpx.MockTransport; each asserts exact method + resolved path + JSON body.
  • README "Colony moderation" API-reference table + a usage example.
  • CHANGELOG entry under Unreleased (no version bump — holding for more before the next release).

ruff check + ruff format --check + mypy src/ clean; 879 passed, 147 skipped.

Non-breaking, additive. Refs THECOLONYC-373.

🤖 Generated with Claude Code

The Python client had near-zero colony-moderation coverage — it was the
participant surface (read/post/vote/DM/notify) with no way to run a
colony you moderate. Adds the full moderator-facing surface to
ColonyClient, AsyncColonyClient, and MockColonyClient, each a 1:1
wrapper over an existing /api/v1/colonies/... endpoint that carries the
server's own permission gate:

- mod queue: get_mod_queue, mod_queue_action, mod_queue_bulk_action
- bans: ban_colony_member, unban_colony_member, list_colony_bans
- member roles: list_colony_members, promote/demote/remove_colony_member
- strikes: list_member_strikes, issue_member_strike
- automod: list/create/update/reorder/dry_run/delete_automod_rule
- settings: update_colony_settings
- ownership (founder): propose/get_pending/accept/decline/cancel
- deletion (founder): file/get/cancel_colony_deletion_request
- mod-activity: get_mod_activity
- modmail: open/list/join_modmail
- ban appeals: submit_ban_appeal, get_my_ban_status, list_ban_appeals,
  resolve_ban_appeal

colony args accept a slug or UUID (resolved like join_colony). Not
included: post-flair / user-flair / removal-reason CRUD and mod-private
member notes — those have no JSON API endpoint (web + MCP only).

Tests: tests/test_moderation.py (35 cases, sync via urllib mock + async
via httpx.MockTransport). README API-reference table + CHANGELOG
(Unreleased) updated. ruff + mypy clean; 879 passed.

Refs THECOLONYC-373.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

The first cut left the ~30 async wrappers, all 35 MockColonyClient
stubs, and the reason_id branches in the sync mod-queue methods
unexercised — codecov/patch flagged the diff. Adds:

- a data-driven async test driving every async moderation method
  through httpx.MockTransport (method + resolved path)
- a MockColonyClient test calling all 35 moderation stubs and
  asserting each records a call
- reason_id args on the sync mod_queue_action / bulk_action tests

client.py, async_client.py, testing.py now 100% covered; 881 passed,
ruff + mypy clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jackparnell jackparnell merged commit 06ddfe9 into main Jun 16, 2026
7 checks passed
@jackparnell jackparnell deleted the feat/colony-moderation-methods branch June 16, 2026 05:58
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.

2 participants