Improve code quality, reliability, and data safety - #2
Draft
aidenfarley wants to merge 1 commit into
Draft
Conversation
Refactor state ownership and persistence, harden backup/restore and networking lifecycles, and add regression coverage and architecture documentation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request completes the staged code-quality and reliability plan for ServerUtilities. It separates domain state from persistence and scheduling, hardens backup/restore behavior against partial writes and unsafe archive paths, improves runtime resource cleanup, preserves compatibility boundaries, and adds focused regression coverage.
Motivation
The previous implementation had several recurring maintenance and reliability risks:
The goal of this work is not to redesign gameplay. It is to make the existing behavior easier to reason about, safer under failure, and more testable while retaining established data and protocol compatibility.
What changed
1. Domain state ownership and persistence boundaries
UniverseRepository,UniversePersistence, andUniverseTaskSchedulerfromUniverseso lookup, disk I/O, and scheduled work have explicit responsibilities.ForgeTeamMembershipandForgeTeamPersistencefromForgeTeamto isolate membership rules and NBT serialization.ForgeTeamequality/hash-code behavior so equality is symmetric and includes universe scope.These changes reduce hidden coupling and make invariants enforceable at a small number of domain entry points.
2. Persistence and data-integrity hardening
level.datatomically while preservinglevel.dat_old.HALF_EVENrounding and existingStringUtilsedge cases.3. Backup lifecycle and restore safety
AbstractZipCompressor.BackupArchivePathPolicy.$WORLDNAMEsubstitutions literally when generating glob patterns.RestoreTransaction, which stages extraction before replacement and can roll back a partially applied restore.RestoreRecoveryfrom client pre-initialization.The resulting restore sequence is transactional at the application level: validate, stage, journal, replace, and either commit or recover/roll back.
4. Networking, HTTP, and runtime cleanup
HttpDataReader; normal JVM certificate validation is now used.FullHttpRequestobjects, calculate response lengths from UTF-8 bytes, close error/non-keepalive connections, and clean up event loops after bind/start failures.IconRendererrestores OpenGL state on all exits and reports queued callback failures accurately.5. Public APIs and compatibility contracts
serverutils.api.ServerUtilitiesRegistryfacade in the main artifact.6. Documentation and tests
ARCHITECTURE.mddescribing ownership, persistence, backup/restore, networking, and API boundaries.CONTRIBUTING.mdwith build, formatting, testing, and compatibility guidance.level.datcheat changes;Intentional behavior changes
Compatibility
Validation
\.\gradlew.bat spotlessCheck— passed\.\gradlew.bat build— passedgit diff --check/ staged whitespace validation — passedSuggested review order
RestoreTransaction,RestoreRecovery, andBackupArchivePathPolicyfor failure and path-safety semantics.Universe,UniverseRepository,UniversePersistence,ForgeTeam, and the extracted team helpers for ownership and compatibility.BackupTask,ThreadBackup, and lifecycle/snapshot classes for cancellation and save-state restoration.AuroraServer,HttpDataReader, andIconRendererfor resource lifecycle changes.Risk and rollback notes
This is a broad internal refactor, so the PR remains a draft for focused review and any additional integration testing. The highest-risk areas are restore replacement ordering, startup recovery, persistence failure handling, and compatibility call-site updates. The added tests concentrate on those boundaries.
There are no schema migrations. Rolling back consists of deploying the prior build. If a process terminates during a restore, the new journal is intentionally retained so the same build can recover the operation on startup.
Non-goals
masterbranch.Review checklist