Skip to content

Merge /purge regions into /purge; drop status/stop; simplify /purge unowned#2949

Merged
tastybento merged 3 commits intodevelopfrom
feature/merge-purge-regions
Apr 18, 2026
Merged

Merge /purge regions into /purge; drop status/stop; simplify /purge unowned#2949
tastybento merged 3 commits intodevelopfrom
feature/merge-purge-regions

Conversation

@tastybento
Copy link
Copy Markdown
Member

Summary

  • Merges /purge regions into the top-level /purge <days> so a single command now both flags islands and frees the .mca files on disk (old /purge only soft-flagged).
  • Drops /purge regions (merged in), /purge status, and /purge stop — the regions approach is fast enough that the iterative-state subcommands are no longer useful.
  • Simplifies /purge unowned to flag orphans via IslandsManager.deleteIsland(island, true, null), logging each orphan's location; admin runs /purge deleted afterwards to reap.
  • Every affected island's coordinates are logged (Util.xyz) before confirmation so admins can audit what a purge will touch.

Why

Prior to PR #2933 the old /purge hard-deleted islands synchronously. Since #2933 it only soft-flagged them and left region files on disk until HousekeepingManager's next sweep (or a manual /purge regions). Admins running /purge 30 reasonably expected disk to be freed. This realigns behaviour with expectation and collapses the duplicate entry points.

Subcommand surface after this PR

Subcommand Action
/purge <days> Scans for region files older than N days whose islands aren't protected/spawn/unowned; lists each; reaps on confirm.
/purge unowned Flags orphan islands as deletable; lists each; run /purge deleted afterwards to reap.
/purge deleted Reaps region files for every island already flagged deletable, regardless of age.
/purge protect Toggles purge-protection on the island at the admin's current location.

Test plan

  • ./gradlew test — BUILD SUCCESSFUL (full suite)
  • AdminPurgeCommandTest rewritten end-to-end against a real PurgeRegionsService with a tempDir region layout
  • AdminPurgeUnownedCommandTest gains testNoPurgeIfIslandAlreadyDeletable
  • AdminPurgeRegionsCommandTest removed (command merged)
  • Manual smoke test on a live server: run /bsb purge 30, confirm region files are removed and island locations are logged
  • Manual smoke test: /bsb purge unowned lists orphan coords, flags them; /bsb purge deleted reaps

🤖 Generated with Claude Code

tastybento and others added 3 commits April 18, 2026 06:11
…y /purge unowned

The old /purge command only soft-flagged islands as deletable and left the
.mca region files in place. Disk wasn't freed until the next housekeeping
sweep (or a manual /purge regions). This merges the region-file deletion
directly into /purge <days> so admins get the full reap in one step, and
removes now-redundant subcommands.

Changes:
- /purge <days> now delegates to PurgeRegionsService: scans for region files
  older than N days whose islands aren't protected/spawn/unowned, lists each
  island location to the log, and reaps the .mca files on confirm.
- Dropped /purge regions (merged in), /purge status, /purge stop (regions
  approach is synchronous from the admin's POV — no state to supervise).
- /purge unowned: simplified to flag orphan islands deletable via
  IslandsManager.deleteIsland(island, true, null); logs each orphan's
  location; tells the admin to run /purge deleted to reap.
- /purge deleted unchanged — still reaps anything already flagged.
- Locale cleanup: removed keys for the dropped subcommands; updated
  description to reflect disk-freeing behavior; added unowned.flagged.
- Tests: AdminPurgeCommandTest rewritten end-to-end against a real
  PurgeRegionsService with a tempDir region layout; AdminPurgeRegionsCommandTest
  removed; AdminPurgeUnownedCommandTest gains coverage for already-deletable
  islands.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Drop always-true `this.user.equals(user)` guards in AdminPurgeCommand
  and AdminPurgeDeletedCommand — `this.user = user` was assigned on the
  prior line, so the check could never fail.
- Parameterize the three days-validation tests (notanumber / 0 / -3) as
  a single @ParameterizedTest.
- Extract `wireIsland(id, deletable, purgeProtected, spawn)`,
  `wireEmptyGrid()`, and `createRegionFile()` helpers in
  AdminPurgeCommandTest to collapse ~15-line setup blocks duplicated
  across the 8 scenario tests.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ommands

AdminPurgeCommand and AdminPurgeDeletedCommand each carried their own
inPurge/toBeConfirmed/lastScan state machine and near-identical
canExecute / scan-and-prompt / deleteEverything bodies (~75 lines apiece,
diverging only in scan source, log prefix, confirm message and an optional
chunk-evict step). Pull the shared scaffolding into a package-private
AbstractPurgeCommand, with subclasses supplying:

- logPrefix() — log line prefix
- successMessageKey() — locale key sent on a successful delete
- sendConfirmPrompt() — main-thread prompt(s) before user types confirm
- beforeDelete(scan) — optional pre-delete hook (used by /purge deleted to
  evict in-memory chunks before the async file delete)
- logScanContents(islands, scan) — optional scan-time logging

Behaviour is preserved: same locale keys, same log prefixes, same async
threading. The "after a non-empty scan" tail on the failed-delete log line
in /purge deleted is dropped — it was always true (we'd already returned
on empty) and made the message harder to share.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

@tastybento tastybento merged commit 3a280a2 into develop Apr 18, 2026
3 checks passed
@tastybento tastybento deleted the feature/merge-purge-regions branch April 18, 2026 20:24
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.

1 participant