From 15ba153672ba3e92949459dd9ffdd0f2158f96dd Mon Sep 17 00:00:00 2001 From: BMX Date: Thu, 1 Oct 2026 08:57:40 +0000 Subject: [PATCH] Upload files to "/" Gemmini critiqe or how tf you spell critoiq --- ..._v3_architectural_critique_action_items.md | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 pithos_v3_architectural_critique_action_items.md diff --git a/pithos_v3_architectural_critique_action_items.md b/pithos_v3_architectural_critique_action_items.md new file mode 100644 index 0000000..dc0ecb1 --- /dev/null +++ b/pithos_v3_architectural_critique_action_items.md @@ -0,0 +1,66 @@ +# Pithos v3 Design Critique & Architectural Risk Report + +**Target Document:** Pithos - Planning Report v3 (1 October 2026) +**Purpose:** Technical assessment of architecture, edge cases, and failure modes prior to implementation. Pass this document to your AI editor / lead architect to guide the v4 plan revision. + +--- + +## Executive Summary + +While Pithos v3 introduces significant improvements over v2 (such as global job locks, improved snapshot logic, and resumable restores), deep technical evaluation reveals **6 critical architectural risks**. Left unaddressed, these issues can lead to unrecoverable server boot loops, extreme disk space exhaustion, registry/world corruption, or I/O timeouts during backup windows. + +--- + +## Key Risk Areas & Detailed Findings + +### 1. The Bootstrap Paradox in Restore Rollbacks +* **Issue:** Relying on Pithos (a mod running inside the JVM) to perform crash recovery or finish directory rollbacks during server startup creates a circular dependency. +* **Mechanism:** If power is lost or a process crashes mid-swap while `mods/` or `config/` is half-renamed to `.pithos-old`, the server will attempt to boot with corrupted core files. +* **Impact:** NeoForge or Pithos itself will fail to load. Because the mod never reaches initialization, the pre-world boot logic (Steps 7–8 in v3) never runs, leaving the server permanently broken without automatic recovery. +* **Action Required:** Decouple swap/rollback recovery from the mod runtime. Move recovery checks to an external wrapper/loop script (`start-loop.sh` / `start-loop.bat`) prior to `java -jar` execution, or ensure atomic directory renames. + +### 2. The 4x Disk Space Multiplier During Restore +* **Issue:** The cumulative disk footprint during the restore lifecycle peaks significantly higher than estimated by the pre-restore space check. +* **Mechanism:** During a restore, the disk simultaneously holds: + 1. Active Live Directory ($1\times$) + 2. Uncompressed Staging Directory `.pithos-restore/` ($1\times$) + 3. Renamed Old State Directory `.pithos-old/` ($1\times$) + 4. In-Progress `pre-restore_.tar.gz` Safety Archive ($0.5\times$ to $1\times$) + 5. Required Safety Buffer (`min_free_space_mb`) +* **Impact:** A 30 GB modpack requires 100–120 GB of free space. On budget hosts, panel-managed nodes, or VPS setups with strict disk quotas, restores will consistently fail or run out of space mid-operation during the startup safety tar phase. +* **Action Required:** Stream `.pithos-old` directly into the `pre-restore` compressed archive before applying staged files, or allow admins to make the safety backup optional/configurable. + +### 3. Windows Partial Restore Corruption Trap +* **Issue:** Skipping `mods/` and `libraries/` during a Windows restore (due to open JVM file locks) introduces silent world/registry corruption. +* **Mechanism:** Restoring a 2-week-old `world/` and `config/` while leaving today's active `mods/` intact causes severe ID map and registry desynchronization. +* **Impact:** Mismatched Block/Item IDs, corrupted entity payloads, missing mod blocks, or fatal startup crashes. +* **Action Required:** Do not allow partial restores. Treat locked `mods/` / `libraries/` on Windows as a hard block that aborts the restore and prompts the admin to execute an out-of-band swap via a batch script while the JVM is completely stopped. + +### 4. `Runtime.halt()` Hazards vs. Socket Cleansing +* **Issue:** Bypassing vanilla shutdown hooks via `Runtime.halt(code)` avoids thread deadlocks but introduces severe network and database side effects. +* **Mechanism:** + 1. *Database/IO State:* Mods utilizing SQLite, H2, LevelDB, or async I/O workers (e.g., Dynmap, BlueMap, LuckPerms) fail to flush or release database locks. + 2. *Socket Binding:* Standard TCP socket cleanup is bypassed, leaving port `25565` bound in a `TIME_WAIT` state for 30–60 seconds. +* **Impact:** Rapid-restart supervisors (systemd, Pterodactyl, loop scripts) immediately attempt to restart the server, encounter a `java.net.BindException: Address already in use` error, and crash out. +* **Action Required:** Dispatch custom mod teardown events or provide a short grace window before calling `Runtime.halt()`. Add a configurable sleep delay in loop scripts prior to re-invoking Java. + +### 5. Double-Read I/O Bottlenecks in `SAVE_PAUSE` +* **Issue:** The `StabilityReader` performing double-read validation (before and after) on every world file during world pause causes extreme I/O contention. +* **Mechanism:** Large modded worlds contain tens of thousands of region files and data structures. Synchronous double-reads over Java NIO during the save-pause window generate heavy disk queues. +* **Impact:** On HDDs or network storage (NFS/SMB), stability checking pushes backup durations beyond `max_pause_seconds` (300s), causing frequent backup aborts and server lag spikes on active servers. +* **Action Required:** Restrict stability double-reads strictly to active region files (`world/region/*.mca`, `world/entities/*.mca`) or files modified within the last $N$ seconds, rather than reading every static file twice. + +### 6. External Symlink Root Escalation +* **Issue:** Following top-level symlinks by default creates data leak risks and archive bloat. +* **Mechanism:** If an admin or mod creates a top-level symlink pointing to an external path (e.g., `/var/log` or `/`), Pithos will recursively follow and package external file trees into the tar archive. +* **Impact:** Potential leakage of sensitive host system files, massive unexpected archive growth, or infinite recursion loops if a symlink loops back to a parent root. +* **Action Required:** Require symlink target paths to be explicitly validated against a whitelist in `pithos.toml`, or require `follow_symlinks = true` to explicitly list allowed target directories. + +--- + +## Suggested Topics for Next Planning Iteration (v4) + +1. **Bootstrap Recovery:** How should external script wrappers (`start-loop.sh`) inspect `pithos-restore.json` before Java launches? +2. **Restore Footprint Reduction:** How can we restructure the staged-swap-safety sequence to keep space requirements closer to $1.5\times$ world size? +3. **Windows Safety:** Standardizing the process for generating an out-of-band `.bat` script when open jars prevent inline folder swapping. +4. **Selective Stability Check Policy:** Defining exact glob patterns for files requiring double-read stability checks vs. single-read streaming. \ No newline at end of file