# Post-Phase 1 Forensic Analysis & Cleanup Report

## Phase 1 Results (Executed)

| Action | Space Freed | Status |
|--------|------------|--------|
| VACUUM state.db (DB+WAL) | ~171MB effective | ✅ Done |
| Delete state-snapshots/ | 153MB | ✅ Done |
| Delete stale config backups (7 files) | 112KB | ✅ Done |
| Delete stale model cache | 2.4MB | ✅ Done (silent) |
| Rotate old logs (10 files) | 7.0MB | ✅ Done |
| Delete stale top-level docs (2 files) | 19KB | ✅ Done |
| Delete llama.cpp/backups-sm61/ (4 binaries) | 475MB | ✅ Done |
| `sudo apt autoremove --purge -y` | Residual packages | ✅ Done |
| `sudo apt clean` | APT cache | ✅ Done |
| **Total Phase 1** | **~809MB** | |

---

## Phase 2: Deep Directory Forensics

### 1. ~/Bonsai-Image-Demo (13,538MB — 13.5GB)

| Attribute | Detail |
|-----------|--------|
| **Purpose** | ML image generation demo for Bonsai-4B ternary model |
| **Source** | Git clone of `https://github.com/PrismML-Eng/Bonsai-Image-Demo.git` |
| **Created** | Jun 5 2026 (13 days ago) |
| **Last Modified** | Jun 5 2026 |
| **Local Changes** | 1 file modified (uv.lock) — trivially replaceable |
| **Model Weights** | 4.3GB in `models/bonsai-image-4B-ternary-gemlite/` |
| **Vendor Dependencies** | 1GB (`image-studio`, `mflux-prism`) |
| **Notebooks** | Jupyter notebooks in `notebooks/` |
| **Git Remote** | `https://github.com/PrismML-Eng/Bonsai-Image-Demo.git` |
| **Docker Usage** | None |
| **Active Processes** | None |

**Verdict: SAFE TO DELETE.** It's a cloned repo that can be re-cloned at any time. Only 1 trivial local modification. The 4.3GB model weights are re-downloadable from Hugging Face (the Bonsai model). No active workflows depend on it.

**Recommended Action:** `rm -rf ~/Bonsai-Image-Demo/` 
**Rollback:** `git clone https://github.com/PrismML-Eng/Bonsai-Image-Demo.git`
**Risk:** Low (100% recoverable)

---

### 2. ~/rescue-ultra (9,700MB — 9.7GB)

| Attribute | Detail |
|-----------|--------|
| **Purpose** | Custom Debian-based live ISO rescue system (like SystemRescue/MediCat) |
| **Source** | NOT a git repo — custom local build |
| **Created** | Unknown (no README timestamp, no git history) |
| **Build Directory** | 5.6GB in `build/` (contains live-build chroot with broken symlinks) |
| **Active Status** | Appears to be a one-off build that was never deployed |
| **Documentation** | README.md describes it as "Modern Technician Rescue System" |
| **Broken Symlinks** | Yes — `build/live-build/chroot/` has broken symlinks to system libraries |

**Verdict: SAFE TO ARCHIVE.** This is a custom build artifact, not recoverable from a remote. Not actively used (no README suggests current development). The 5.6GB chroot build directory is the main space consumer.

**Recommended Action:** `tar -czf ~/archive/rescue-ultra.tar.gz -C ~ rescue-ultra && rm -rf ~/rescue-ultra/`
**Rollback:** `tar -xzf ~/archive/rescue-ultra.tar.gz -C ~`
**Risk:** Low (archived before removal, full recoverability)

---

### 3. ~/apk-analysis (1,016MB — 1GB)

| Attribute | Detail |
|-----------|--------|
| **Purpose** | Decompiled APK reference materials (Netfly, STRMR, ONstreamz, Streamflix, NuvioTV, Lumera, JetStreamCompose) |
| **Created** | Jun 13 (5 days ago) |
| **Last Modified** | Jun 14 (4 days ago) |
| **Active Status** | Likely active — FULL_AUDIT.md was written Jun 13, patterns extracted for Unspooled |
| **Relationship** | Source material for `scraper-debrid-engine-reference` skill |

**Verdict: KEEP.** This is active reference material for ongoing Unspooled development. The decompiled APKs contain UI patterns, scraper logic, and architecture patterns being reverse-engineered. Only delete after the scraper-debrid-engine-reference skill has fully captured all patterns.

**Recommended Action:** KEEP for now. Add a note: "Review after Unspooled scraper extraction complete"
**Risk:** High if deleted prematurely — patterns would need re-extraction

---

### 4. ~/Android (1.6GB)

| Attribute | Detail |
|-----------|--------|
| **Purpose** | Android SDK for Unspooled builds |
| **Components** | emulator (819MB), build-tools (298MB), cmdline-tools (295MB), platforms (142MB), platform-tools (22MB) |
| **Active Status** | Required for `./gradlew assembleDebug` in Unspooled project |

**Verdict: KEEP.** Required for Android TV app builds. The emulator (819MB) is optional — remove only if builds are always run on real devices.

**Recommended Action:** KEEP. Optional: `rm -rf ~/Android/emulator/` saves 819MB if device-only testing.
**Risk:** Medium — removing emulator breaks `./gradlew` if connected device testing uses it

---

### 5. ~/src/ (3.7GB total — 3 llm.cpp build trees)

| Build | Size | Status |
|-------|------|--------|
| llama.cpp (base) | 839MB | Original repo — may be symlinked to |
| llama.cpp-upstream | 1.5GB | Active — ac4cdde build |
| llama.cpp-mtp-turbo | 1.4GB | Active — b9341 MTP-Turbo build |

**Verdict:** 2 of 3 builds are actively used per server-models memory. The third (base) may be the original clone. Verify which build is actually referenced by systemd services.

**Recommended Action:** Investigate whether the base `llama.cpp/` can be removed if upstream and mtp-turbo cover all active builds. Deferred for now.
**Risk:** Medium — need to verify systemd unit paths first

---

### 6. Duplicate Files Found

| File Pattern | Copies | Total Waste | Action |
|-------------|--------|-------------|--------|
| ggml-vocab-*.gguf (18 patterns × 3 trees) | 54 files | ~<1MB (tiny files) | Consolidate to 1 copy, symlink or delete |
| uv binary (2 copies) | 2 | ~120MB | Keep — different locations |
| llama-server binary (2 copies) | 2 | ~274MB | ALREADY DELETED in Phase 1 |

**Verdict:** No significant duplicate files remain after Phase 1. The vocab files are tiny — consolidating them saves negligible space but improves organization.

---

### 7. Stale Environments Found

| Environment | Location | Size | Action |
|------------|----------|------|--------|
| Python .venv | ~/Bonsai-Image-Demo/.venv | TBD | Will be deleted with Bonsai dir |
| npm npx caches (7) | ~/.npm/_npx/* | TBD | Clean with `npm cache clean` |
| opencode node_modules | ~/.config/opencode/node_modules | TBD | KEEP — active dependency |

---

### 8. Remaining Hermes Cleanup Items

| Item | Size | Action | Risk |
|------|------|--------|------|
| kanban.db (unused) | 115KB | DELETE (recreated by `hermes kanban init`) | None |
| Stale gateway tmp files (2) | 1KB | DELETE | None |
| `.hermes_history` | 2KB | KEEP — shell history | None |

---

## Prioritized Cleanup Roadmap

### Phase 1: ✅ DONE (809MB freed)

### Phase 2: Immediate — Additional Safe Items (<5 min)

```bash
rm -f ~/.hermes/.gateway_state_*.tmp          # Stale temp files
rm -f ~/.hermes/kanban.db                     # Unused kanban DB
npm cache clean --force                        # Stale npm caches
```

**Estimated savings:** ~1MB + npm cache

### Phase 3: Bonsai-Image-Demo Cleanup (13GB — 2 min)

```bash
rm -rf ~/Bonsai-Image-Demo/
# OR if unsure:
# tar -czf ~/archive/bonsai-image-demo-backup.tar.gz -C ~ Bonsai-Image-Demo && rm -rf ~/Bonsai-Image-Demo/
```

**Estimated savings:** 13,538MB
**Restore:** `git clone https://github.com/PrismML-Eng/Bonsai-Image-Demo.git`
**Risk:** Low — 100% recoverable from GitHub

### Phase 4: rescue-ultra Archive (9.7GB — 3 min)

```bash
mkdir -p ~/archive
tar -czf ~/archive/rescue-ultra-2026-06-18.tar.gz -C ~ rescue-ultra
rm -rf ~/rescue-ultra/
```

**Estimated savings:** 9,700MB
**Restore:** `tar -xzf ~/archive/rescue-ultra-2026-06-18.tar.gz -C ~`
**Risk:** Low — full archive preserved

### Phase 5: Vocab File Consolidation (54 files — 5 min)

```bash
# Keep one copy at canonical location, remove from other build trees
mkdir -p ~/src/llama.cpp/models/vocab
cp ~/src/llama.cpp/models/ggml-vocab-*.gguf ~/src/llama.cpp/models/vocab/
rm -f ~/src/llama.cpp/models/ggml-vocab-*.gguf
rm -f ~/src/llama.cpp-upstream/models/ggml-vocab-*.gguf
rm -f ~/src/llama.cpp-mtp-turbo/models/ggml-vocab-*.gguf
```

**Estimated savings:** Negligible (~<1MB) but improves organization
**Risk:** Very Low — vocab files are build-time only

### Phase 6: Hermes Folder Reorganization (15 min)

```
Before:                                 After:
~/.hermes/                              ~/.hermes/
  config/                                 -- new --
    config.yaml
    SOUL.md
    AGENTS.md
    auth.json
    backups/                              -- new --
      config.yaml.audit-backup-
  scripts/                              scripts/
    repo-map.py                           (active only)
    models.py
    auto-model-switch.py
    model-health-watchdog.py
    archive/                              -- new --
      benchmark_*.py
      token-usage-report.py
  research/                             research/
    hermes-comprehensive-audit-...         (current reports)
    benchmark-report-...
    adversarial-benchmark-...
    complete-cleanup-audit-...
    archive/                              -- new --
      prompt-optimization-research.md
  state/                                  -- new --
    state.db
    kanban.db (or deleted)
    response_store.db
  logs/                                 logs/
    agent.log                             (current only)
    agent.log.1
    gateway.log
    errors.log
  cache/                                cache/
  cron/                                 cron/
  memories/                             memories/
  skills/                               skills/
  profiles/                             profiles/
```

---

## Risk Assessment Matrix

| Item | Space | Risk | Recoverable? | Action |
|------|-------|------|-------------|--------|
| Phase 1 actions | 809MB | ✅ None | Not needed | ✅ Done |
| Stale tmp files | 1KB | ✅ None | Generated fresh | APPROVE |
| kanban.db | 115KB | ✅ None | `hermes kanban init` | APPROVE |
| Bonsai-Image-Demo | 13.5GB | 🟢 Low | `git clone <url>` | APPROVE |
| rescue-ultra archive | 9.7GB | 🟢 Low | `tar -xzf archive` | APPROVE |
| ~/Android/emulator/ | 819MB | 🟡 Medium | `sdkmanager` reinstall | REVIEW NEEDED |
| ~/apk-analysis/ | 1GB | 🔴 High for now | Re-extract APKs | KEEP |
| ~/src/llama.cpp/ (base) | 839MB | 🟡 Medium | `git clone` | DEFER |
| Vocab file consolidation | <1MB | 🟢 Low | Restore from copy | APPROVE |

---

## Summary

| Phase | Status | Space |
|-------|--------|-------|
| Phase 1 (safe cleanup) | ✅ DONE | 809MB |
| Phase 2 (tmp files, kanban) | ⏳ Awaiting approval | ~1MB |
| Phase 3 (Bonsai-Image-Demo) | ⏳ Awaiting approval | 13.5GB |
| Phase 4 (rescue-ultra archive) | ⏳ Awaiting approval | 9.7GB |
| Phase 5 (vocab consolidation) | ⏳ Awaiting approval | <1MB |
| Phase 6 (folder reorg) | ⏳ Awaiting approval | 0 (org only) |
| **Total remaining** | | **~23.3GB** |
| **Grand total with Phase 1** | | **~24.1GB** |

**Next steps:** Awaiting approval for Phase 2 through Phase 6. The 3 biggest remaining items (Bonsai, rescue-ultra, emulator) total 23.3GB — 96% of remaining waste.
