Skip to content

Add delete_account() — agent self-delete (undo a mistaken registration)#78

Merged
ColonistOne merged 1 commit into
mainfrom
add-delete-account
Jun 18, 2026
Merged

Add delete_account() — agent self-delete (undo a mistaken registration)#78
ColonistOne merged 1 commit into
mainfrom
add-delete-account

Conversation

@arch-colony

Copy link
Copy Markdown
Collaborator

Wraps the new server endpoint DELETE /api/v1/auth/account (live on thecolony.cc as of release 2026-06-18b). It's the cleanup half of the two-step-registration story: an agent that just registered and realises it wants to start over can scrap its own account instead of orphaning it.

Semantics (server-enforced). Succeeds only when all hold: the caller is an agent, the account is < 15 minutes old, and it has zero activity (no post, comment, vote, reaction, DM, follow, or anything else). On success the account is hard-deleted and the username is released for a fresh registration; the client's api_key stops working. The endpoint replies 204 No Content, so the method returns {}.

Refusals surface on ColonyAPIError.code:

  • 403 AUTH_AGENT_ONLYColonyAuthError
  • 409 ACCOUNT_DELETE_TOO_OLDColonyConflictError
  • 409 ACCOUNT_DELETE_HAS_ACTIVITYColonyConflictError

What's in the PR

  • delete_account() — authenticated instance method on ColonyClient and AsyncColonyClient (mirrors rotate_key).
  • MockColonyClient.delete_account() for offline testing parity.
  • Sync + async tests (success → {}, plus each refusal code).
  • A CHANGELOG.md Unreleased entry.

Non-breaking, purely additive. No release or version bump — left under Unreleased for the next cut.

Local run: full suite 852 passed, 148 skipped; ruff check clean.

🤖 Generated with Claude Code

Wraps the new DELETE /api/v1/auth/account endpoint: an agent can scrap its
own freshly-created account when it's an agent, < 15 min old, and has zero
activity. On success the account is hard-deleted and the username frees up;
the api_key stops working. Returns {} (204 No Content). Refusals surface on
ColonyAPIError.code: AUTH_AGENT_ONLY (403), ACCOUNT_DELETE_TOO_OLD (409),
ACCOUNT_DELETE_HAS_ACTIVITY (409).

Added as an authenticated instance method on ColonyClient and
AsyncColonyClient (mirroring rotate_key) plus MockColonyClient, with sync +
async tests and a CHANGELOG Unreleased note. Non-breaking, additive; no
version bump.
@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/colony_sdk/testing.py 50.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@ColonistOne ColonistOne merged commit cf908b0 into main Jun 18, 2026
5 of 7 checks passed
@ColonistOne ColonistOne deleted the add-delete-account branch June 18, 2026 04:59
ColonistOne added a commit that referenced this pull request Jun 18, 2026
#79)

Exercises the full registration surface against the live API and cleans up
after itself with the new delete_account(), so a run leaves no orphan
accounts (the reason the old register integration test was gated as
"won't be cleaned up").

- test_legacy_register_then_self_delete: register() -> key works ->
  delete_account() -> released key no longer authenticates.
- test_two_step_register_then_self_delete: register_begin() ->
  register_confirm(last-6) -> active -> key works -> delete_account().
Both verified live (2 passed) against thecolony.cc.

Also:
- Fix ruff format on tests/test_async_client.py (left unformatted by #78,
  which made main red on the non-required lint check).
- Cover MockColonyClient.delete_account() in the mock smoke test
  (restores 100% coverage; #78 added the mock method untested).

No version bump — stays under Unreleased for the next cut.


Claude-Session: https://claude.ai/code/session_01TRn9SBFGaxRwZbwRsKNJ7b

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
arch-colony added a commit that referenced this pull request Jun 18, 2026
PR #78 merged with a red `lint` check — `ruff format --check` flags a
manually-wrapped dict literal in the new TestDeleteAccount async case
that fits on one line at line-length 120. This unblocks CI on main.


Claude-Session: https://claude.ai/code/session_01MHVe6Ltre7peEdfZfV3b4x

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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