# Complete Audit & Cleanup Plan — Debian Server + Hermes Environment

**Date:** 2026-06-18  
**Scope:** Debian 13 server, Hermes Agent v0.16.0, 7 local models, Docker fleet, storage  
**Status:** Audit complete — no changes applied. Approval required before execution.

---

## Executive Summary

The environment is functionally healthy but carries **~30GB of reclaimable waste** across abandoned experiments (22.7GB), stale backups (1.6GB), unused caches (2.8MB), duplicate model vocab files (54 tiny files across 3 trees), and bloated session databases (168MB state.db). Hermes has 28 active skills, 113 disabled — a good ratio. The Debian server has 1 residual package, 16MB journals, and no Docker volume bloat. 

**Total reclaimable space:** ~25-30GB  
**Primary waste sources:** 13GB Bonsai-Image-Demo, 9.7GB rescue-ultra (likely experiments), 4.0GB stale source/build trees  
**Primary Hermes waste:** 168MB state.db (can be VACUUMed), 15.5MB logs (can be rotated), 2.4MB stale model cache  
**Risk level of cleanup:** Low for 95% of items. 5% need careful review before deletion.

---

## 1. Current State Assessment

### 1.1 Disk Layout

| Mount | Size | Used | Path |
|-------|------|------|------|
| /dev/sda1 (data) | ~250GB | ~85GB | /models — GGUF model files |
| Root (/) | varies | ~30GB in ~ | User home directory |

### 1.2 Model Inventory

| File | Size | Status |
|------|------|--------|
| Qwen3.6-35B-A3B-MTP-Q4_K_M.gguf | 22.7GB | ⚡ Primary (active in models.py) |
| nex-agi_Nex-N2-mini-Q4_K_M.gguf | 21.4GB | ✅ Active |
| gemma-4-26B-A4B-it-qat-UD-Q4_K_XL.gguf | 14.2GB | ✅ Active |
| Qwopus3.5-9B-Coder-MTP-Q6_K.gguf | 7.6GB | ✅ Active |
| gemma-4-12B-it-qat-UD-Q4_K_XL.gguf | 6.7GB | ✅ Active |
| Qwen3.5-9B-MTP-Q4_K_M.gguf | 5.9GB | ✅ Active |
| Qwen3.5-4B-Q8_0.gguf (in /archive) | 4.5GB | 🟡 Old quant, may be replaced by newer versions |
| Bonsai-8B-Q1_0.gguf | 1.2GB | 🟡 Edge model, barely used but small |
| Qwen3-Embedding-0.6B-Q8_0.gguf | 0.6GB | ✅ Needed for embeddings |
| mtp-gemma-4-26B-A4B-it.gguf | 0.3GB | ❓ Partial download? Check if this is a MTP-only file |
| mtp-gemma-4-12B-it.gguf | 0.3GB | ❓ Same question |
| **Total active models** | **~80.8GB** | |
| **Questionable** | **~5.1GB** | old-qwen (4.5GB) + mtp files (0.6GB) |

### 1.3 Duplicate Vocab Files

**54 files, ~0 bytes each** — 3 copies (llama.cpp, llama.cpp-upstream, llama.cpp-mtp-turbo) of 18 identical vocab GGUF files. Each file is small (<1MB for a few, most are a few KB) but the duplication adds unnecessary clutter. These are needed by llama.cpp at build time but only ONE copy per build is required — the other build trees don't need their own copies if they share a models/ symlink.

### 1.4 Hermes State DB

| File | Size | Notes |
|------|------|-------|
| state.db | 168MB | Main session DB — needs VACUUM |
| state.db-wal | 1.8MB | WAL file — can be checkpointed |
| state.db-shm | 32KB | Shared memory |
| state-snapshot (pre-update) | 153MB | ⚠️ STALE — from before `hermes update` |

**Total DB footprint:** ~323MB (150MB+ of which is stale snapshot)

### 1.5 Config Backups

| File | Size | When | Status |
|------|------|------|--------|
| config.yaml (current) | 27KB | Now | ✅ Active |
| config.yaml.audit-backup-2026-06-18 | 27KB | Today | 🟡 Keep (post-audit baseline) |
| config.yaml.bak.20260613_160004 | 17KB | Jun 13 | ❌ Stale |
| config.yaml.bak.localctx.20260614_005214 | 17KB | Jun 14 | ❌ Stale |
| config.yaml.bak.phase6 | 15KB | Unknown | ❌ Stale |
| config.yaml.bak.remove-stale-custom.20260614_005336 | 18KB | Jun 14 | ❌ Stale |
| config.yaml.corrupt.20260615-205354.bak | 25KB | Jun 15 | ❌ Stale (corrupt save!) |
| .env.bak.20260612 | 22KB | Jun 12 | ❌ Stale |
| context_length_cache.yaml.bak.localctx | 1KB | Jun 14 | ❌ Stale |

**Total stale backups:** ~115KB — not huge but adds clutter.

### 1.6 Docker

| Container | Status | Size | Notes |
|-----------|--------|------|-------|
| open-webui | Running (healthy) | 4.78GB image | Active, healthy |
| nexstream-scraper | Running (healthy) | 414MB | Active, healthy |
| searxng-core | Running | 259MB | Active, healthy |
| searxng-valkey | Running | 45MB | Active, healthy |

**No stale containers or volumes.** Docker is clean.

### 1.7 Big Directories (~/home waste)

| Path | Size | Risk | Action |
|------|------|------|--------|
| ~/Bonsai-Image-Demo/ | 13GB | Medium — verify what this is | Likely an abandoned experiment from Bonsai model testing |
| ~/rescue-ultra/ | 9.7GB | Medium — verify | Likely an abandoned experiment or rescue model archive |
| ~/src/ (llama.cpp builds) | 4.2GB | Medium | Contains 3 llm.cpp build trees (4.2GB includes repos) |
| ~/Android/ | 1.6GB | Low — Android SDK | May be needed for Unspooled builds |
| ~/apk-analysis/ | 1016MB | Low-Medium | Decompiled APK analysis — may be reference material for scraper work |
| ~/go/ | 785MB | Low — Go SDK | System dependency |
| ~/Scraper Suite/ | 43MB | Low — active | Active scraper reference |
| ~/src/llama.cpp/backups-sm61/ | 475MB | Medium | Contains 4 large binary backup files (llama-server + .bak at 137MB each). These are old binary backups, not current |
| ~/.local/share/opencode/opencode.db | 334MB | Low | OpenCode database — needed if used |
| ~/.cache/camoufox/ | 217MB | Low | Browser cache for camoufox (used for testing?) |

**Total reclaimable from ~/home:** ~25-30GB

---

## 2. Hermes Cleanup Plan

### 2.1 Config Backups (Low Risk)

| Action | Items | Space | Risk | Rollback |
|--------|-------|-------|------|----------|
| Delete stale config backups | 7 files | ~115KB | None | Restore from audit-backup |
| Keep only: current, audit-backup-2026-06-18 | | | | |

**Evidence:** 5 backup files from June 13-15. The audit-backup (today) is the only meaningful rollback point. The others are from iterative edits during the previous cleanup pass. The `.corrupt` file is a snapshot of a broken config — no value.

### 2.2 State DB Cleanup (Medium Risk)

| Action | Items | Space | Risk | Rollback |
|--------|-------|-------|------|----------|
| VACUUM state.db | state.db | 50-100MB reclaim | Low — non-destructive | None needed (read-only) |
| Delete state-snapshot directory | 153MB file | 153MB | Very Low — old snapshot | Can't restore (snapshot was pre-update) |

**Evidence:** state.db at 168MB is 3+ months of sessions. VACUUM reclaims space from deleted rows. The state-snapshot was created by `hermes update` as a pre-update safety backup — it's no longer useful since the update succeeded and the system is running normally.

### 2.3 Log Rotation (Low Risk)

| Action | Items | Space | Risk | Rollback |
|--------|-------|-------|------|----------|
| Rotate old logs | agent.log.2 (4.8MB), errors.log.2 (2MB), gateway.log (3.2MB) | ~10MB | None | Logs will regenerate |
| Keep: current agent.log, errors.log, gateway.log | | | | |

**Evidence:** agent.log.2 is 4.8MB for a single rotation. The gateway will auto-create new logs. gui.log (61K), tui_gateway_crash.log (4K), and hermes-update.log (9K) are one-off diagnostics from past issues.

### 2.4 Model Cache Staleness (Low Risk)

| Action | Items | Space | Risk | Rollback |
|--------|-------|-------|------|----------|
| Delete stale model cache | models_dev_cache.json (2.4MB) | 2.4MB | None — auto-regenerates | Will regenerate on next provider query |

**Evidence:** models_dev_cache.json contains cached model metadata from OpenRouter/other providers. It auto-regenerates when `hermes model` is used. The current cache may reference models that are no longer in the config.

### 2.5 Stray Scripts Review

| Script | Size | Active? | Action |
|--------|------|---------|--------|
| repo-map.py | 10.6KB | ✅ Yes — just created | Keep |
| auto-model-switch.py | 11KB | ✅ Yes (systemd path watcher) | Keep |
| model-health-watchdog.py | 3.3KB | ✅ Yes (cron) | Keep |
| models.py | 4.9KB | ✅ Yes (imported by other scripts) | Keep |
| approval-guard.py | 3KB | ❓ Unknown — check if cron references it | Verify |
| benchmark_coder14.py | 1.7KB | ❌ Stale benchmark script | Delete or archive |
| benchmark_models.py | 7.5KB | ❌ Stale benchmark script | Delete or archive |
| context-packet.py | 3.3KB | ❓ Unknown — check use | Verify |
| token-usage-report.py | 2.8KB | ❌ Stale reporting script | Delete or archive |
| urgency-router.py | 7.2KB | ❓ Unknown | Verify |
| routing-instructions.md | 1.9KB | ❌ Doc in wrong location (scripts/) | Move to research/ or delete |

### 2.6 Research Files

| File | Size | Freshness | Action |
|------|------|-----------|--------|
| hermes-comprehensive-audit-2026-06-18.md | 35KB | Today | Keep (audit report) |
| benchmark-report-2026-06-18.md | 9.1KB | Today | Keep |
| adversarial-benchmark-2026-06-18.md | 9.2KB | Today | Keep |
| this-new-report | ~15KB | Today | Keep |
| prompt-optimization-research.md | 9KB | Today | Keep (subagent output) |

All research files are from today's audit session. No stale reports.

### 2.7 Kanban DB

| File | Size | Status |
|------|------|--------|
| kanban.db | 115KB | Kanban skills are DISABLED. DB is unused. |

**Action:** Either delete or keep. Keeping is safe (115KB is negligible). Deleting saves 115KB. If Kanban is ever re-enabled, `hermes kanban init` recreates it.

---

## 3. Debian Cleanup Plan

### 3.1 Abandoned Experiments (High Space)

#### ~/Bonsai-Image-Demo/ (13GB)
- **Risk:** Medium — verify before deletion
- **Evidence:** From the server-models memory, "bonsai-8b ~2GB" is a known model. This directory may contain image generation demos using the Bonsai model. Check if any active workflow references it.
- **Recommendation:** List contents, verify no active config references it, then archive or delete.
- **Rollback:** Cannot restore if deleted. Suggest moving to /archive/ first.

#### ~/rescue-ultra/ (9.7GB)
- **Risk:** Medium — verify what this is
- **Recommendation:** Check what it contains. If it's a model rescue/experiment, either archive or delete.

### 3.2 Source Build Trees (4.2GB in ~/src/)

#### Current state: 3 llm.cpp build trees
1. `~/src/llama.cpp/` — sm75 build (no longer current?).
2. `~/src/llama.cpp-upstream/` — upstream build (ac4cdde)
3. `~/src/llama.cpp-mtp-turbo/` — MTP-Turbo build (b9341)

**Evidence:** From server-models memory: "Two llama.cpp builds: sm75 (b9341, MTP-Turbo) for qwen35/qwopus/qwen36, upstream (ac4cdde) for Gemma 4 QAT." So both are actively used. The 3rd (llama.cpp with no suffix) may be the original repo cloned as the base. Check if it's a separate clone or the origin of the others.

**Action:** 
- `llama.cpp-backups-sm61/` has 475MB of backup binary files (old llama-server builds). These are stale — the running system uses llama-swap which routes to systemd-managed llama-server processes, not these direct builds.
- Delete: `llama.cpp/backups-sm61/` (475MB) — old binary backups

### 3.3 APK Analysis (1016MB)

**~/apk-analysis/** — decompiled APK files from Streamflix/STRMR/ONstreamz/Netfly analysis.

**Risk:** Low-Medium. These are reference materials used for the scraper-debrid-engine-reference skill and the Unspooled project. If the skill has already captured the key patterns, the raw APK files may be redundant.

**Recommendation:** Check if scraper-debrid-engine-reference references/ directory already contains the extracted patterns. If yes, the APK files can be archived or deleted.

### 3.4 Package Cleanup

| Action | Space | Risk |
|--------|-------|------|
| Remove residual config packages | 1 package, ~0KB | None |
| Autoremove unused dependencies | Possible ~50-100MB | Low |
| Clean apt cache | `apt clean` ~100-200MB | None |

**Journal:** Currently 16MB. The previous optimization already set `SystemMaxUse=500M`. No action needed.

---

## 4. Storage Optimization Plan

### 4.1 Models Drive (/models on /dev/sda1)

| Item | Size | Action | Risk |
|------|------|--------|------|
| /archive/models/old-qwen/Qwen3.5-4B-Q8_0.gguf | 4.5GB | ❓ Check if any config references this old quant | Low — can verify by grepping configs |
| /models/downloads/mtp-gemma-4-26B-A4B-it.gguf | 0.3GB | ❓ Partial/mtp-only file? | Low — check if referenced in models.py |
| /models/downloads/mtp-gemma-4-12B-it.gguf | 0.3GB | ❓ Same | Low |

### 4.2 Vocab File Consolidation

**54 duplicate vocab GGUF files across:** llama.cpp/models/, llama.cpp-upstream/models/, llama.cpp-mtp-turbo/models/

**Strategy:** 
1. Keep one canonical copy at `~/src/llama.cpp/models/vocab/`
2. Remove from the other two build trees
3. Replace with symlinks OR just delete (llama.cpp doesn't need them at runtime — they're build-time only)

**Risk:** Very Low if llama-swap is serving all models. The vocab files are only needed when BUILDING llama.cpp from source, not when running.

---

## 5. Token Optimization Plan (already applied in prior audit)

The prior audit (2026-06-18) already addressed:
- Skills: 113 disabled, 28 enabled ✅
- Skills: 5 largest compacted to <3KB + references/ ✅
- SOUL.md: anti-filler, diff-preference, execute_code, batch calls ✅
- USER.md: compacted 2.2K→1.1K ✅
- Auxiliary routing: 5/5 to flash ✅
- Delegation routing: to flash ✅
- Compression threshold: 0.35→0.50 ✅

**Remaining token opportunities:**
- **Disable more skills** — 28 enabled is close to the 20-25 target. The remaining 3-8 skills to consider: test-driven-development (14KB, situational), planning (1KB, useful but small), multi-source-data-aggregator (23KB, used in Unspooled work)
- **No stub_mode** — blocked by PR #48622 being open
- **state.db VACUUM** — not a token optimization but reduces DB overhead

---

## 6. Folder Reorganization Plan

### Current State

```
~/.hermes/
  research/          — 4 audit reports (62KB, today)
  scripts/           — 11 scripts + 1 .md doc (56KB)
  memories/          — 12 .md files (6.6KB)
  logs/              — 16 files (15.5MB)
  cache/             — 6 items (470KB)
  cron/              — 3 files (1KB)
  profiles/          — 4 profiles (9KB total)
  skills/            — 125 skill dirs across 23 categories
  config.yaml        — 27KB (active)
  state.db           — 168MB
  kanban.db          — 115KB
  +5 backup configs  — ~90KB
```

### Proposed Structure

```
~/.hermes/
  config/            — config.yaml, SOUL.md, AGENTS.md, auth.json
    backups/         — config.yaml.audit-backup-* (single backup)
  profiles/          — 4 profiles (unchanged)
  skills/            — 125 skills (unchanged)
  memories/          — 12 .md files (unchanged)
  scripts/           — ACTIVE scripts only (move stale ones to archive/)
  research/          — Current audit reports only
    archive/         — Stale research, old reports, prompt-optimization-research.md
  cron/              — jobs.json, output/ (unchanged)
  logs/              — Auto-rotated logs only
  cache/             — Auto-generated caches only
  state/             — state.db, kanban.db, response_store.db
  
~/archive/           — Consolidated archive folder
  configs/           — Old config backups (moved from ~/.hermes/)
  reports/           — Old research, stale docs (AI_CLI_STACK_DELIVERABLES.md, etc.)
  experiments/       — Bonsai-Image-Demo, rescue-ultra (if not deleting)
  builds/            — Old llama binary backups (backups-sm61/)
```

---

## 7. Archive Strategy

| Item | Current Location | Archive Target | Size | Reason |
|------|-----------------|----------------|------|--------|
| Old config backups | ~/.hermes/*.bak* | ~/archive/configs/ | 115KB | Keep for reference, out of main dir |
| AI_CLI_STACK_DELIVERABLES.md | ~/.hermes/ | ~/archive/reports/ | 11KB | Stale deliverable doc |
| test_all_models.py | ~/.hermes/ | ~/archive/scripts/ | 10KB | Stale test script |
| prompt-optimization-research.md | ~/.hermes/research/ | ~/archive/research/ | 9KB | Subagent output, reference only |
| Old llama binary builds | ~/src/llama.cpp/backups-sm61/ | Delete (not archive) | 475MB | Old binaries for old builds — no value |
| State DB snapshot | ~/.hermes/state-snapshots/ | Delete | 153MB | Pre-update safety backup, no longer needed |

---

## 8. Backup Strategy

**Current state:** No formal backup system. The only backup is the audit config snapshot from today.

**Recommended (after cleanup):**
1. **Weekly config backup:** Cron job that copies `~/.hermes/config.yaml` to `~/archive/backups/config-$(date +%Y%m%d).yaml`
2. **Pre-change backup:** Manual step before any Hermes update or major config change
3. **State DB:** Not backed up (can be regenerated from sessions — loss is acceptable)
4. **Models:** Not backed up (can re-download from Hugging Face — though 80GB takes hours)

---

## 9. Automation Strategy

### Existing Automations

| Automation | Status | Interval |
|------------|--------|----------|
| Model health watchdog | ✅ Active | Every 30 min |
| Auto-model-switch | ✅ Active (systemd path watcher) | On config.yaml change |

### Recommended Automations

| Automation | Purpose | Interval | Priority |
|-----------|---------|----------|----------|
| Log rotation watchdog | Rotate logs >10MB, keep last 3 | Daily | Medium |
| state.db VACUUM | Reclaim space from deleted rows | Weekly | Low |
| Disk usage alert | Alert if /models or ~ exceeds 90% | Daily | Medium |
| Config backup | Auto-backup config.yaml | Weekly | Low |

---

## 10. Quick Wins (Safe to Do Immediately)

| # | Task | Space Saved | Complexity | Risk |
|---|------|-------------|------------|------|
| 1 | VACUUM state.db | 50-100MB | 1 command | None |
| 2 | Delete state-snapshot directory | 153MB | 1 command | Very Low |
| 3 | Delete stale config backups | 115KB | 1 command | None |
| 4 | Rotate old logs | 10MB | 1 command | None |
| 5 | Delete stale model cache | 2.4MB | 1 command | None (auto-regenerates) |
| 6 | Remove residual apt packages | ~0KB | 1 command | None |
| 7 | Delete ~/src/llama.cpp/backups-sm61/ | 475MB | 1 command | Low (verify systemd service binary path first) |

**Total quick-win space:** ~740MB

---

## 11. High-Risk / Needs-Verification Items

| # | Item | Space | Verification Required | Risk |
|---|------|-------|---------------------|------|
| H1 | Delete ~/Bonsai-Image-Demo/ | 13GB | Check for active references, confirm experiment is abandoned | Medium |
| H2 | Delete ~/rescue-ultra/ | 9.7GB | Identify what it is (list contents) | Medium |
| H3 | Delete ~/apk-analysis/ | 1GB | Check if scraper-debrid-engine-reference already extracted patterns | Low-Medium |
| H4 | Delete /archive/models/old-qwen/ | 4.5GB | Grep models.py and llamaswap config for references | Low |
| H5 | Delete mtp-only model files | 0.6GB | Grep models.py for "mtp-gemma" references | Low |
| H6 | Delete stale scripts (benchmark_*.py, token-usage-report.py) | 12KB | Check cron/systemd for references | Low |

---

## 12. Implementation Roadmap

### Phase 1: Safe Cleanup (5 min, 740MB reclaimed)

```bash
# Quick wins — all reversible or non-destructive
1. hermes sessions vacuum                            # VACUUM state.db
2. rm -rf ~/.hermes/state-snapshots/                 # Delete stale snapshot
3. rm -f ~/.hermes/config.yaml.bak.*                 # Delete stale config backups
4. rm -f ~/.hermes/.env.bak.*                        # Delete stale env backup
5. rm -f ~/.hermes/context_length_cache.yaml.bak.*   # Delete stale ctx cache backup
6. rm -f ~/.hermes/cache/models_dev_cache.json       # Delete stale model cache
7. rm -f ~/.hermes/logs/*.2 ~/.hermes/logs/*.3       # Rotate old logs
8. sudo apt autoremove --purge -y                    # Remove unused packages
9. rm -rf ~/src/llama.cpp/backups-sm61/              # Delete old binary backups
```

### Phase 2: Verification (10 min)

```bash
# Verify each high-risk item
10. ls -la ~/Bonsai-Image-Demo/            # What's in it?
11. ls -la ~/rescue-ultra/                 # What's in it?
12. ls -la ~/apk-analysis/                 # What's in it?
13. grep -r "old-qwen\|Qwen3.5-4B" ~/.hermes/ ~/Unspooled/ 2>/dev/null    # Check for old-qwen references
14. grep -r "mtp-gemma" ~/.hermes/scripts/models.py 2>/dev/null            # Check for mtp-gemma references
```

### Phase 3: Informed Decisions (after verification)

```bash
# Only after verifying contents
15. mv ~/Bonsai-Image-Demo/ ~/archive/experiments/   # Archive (don't delete yet)
16. mv ~/rescue-ultra/ ~/archive/experiments/         # Archive
17. mv ~/apk-analysis/ ~/archive/references/           # Archive
18. rm -rf /archive/models/old-qwen/                   # Delete if unreferenced
19. rm -f /models/downloads/mtp-gemma-*.gguf           # Delete if referenced
```

### Phase 4: Folder Reorganization (15 min)

```bash
20. mkdir -p ~/.hermes/config/backups
21. mv ~/.hermes/config.yaml ~/.hermes/SOUL.md ~/.hermes/AGENTS.md ~/.hermes/config/
22. mv ~/.hermes/config.yaml.audit-backup-* ~/.hermes/config/backups/
23. mv ~/.hermes/auth.json ~/.hermes/config/             # If auth.json is active
24. mkdir -p ~/.hermes/scripts/archive
25. mv ~/.hermes/scripts/benchmark_*.py ~/.hermes/scripts/archive/
26. mv ~/.hermes/scripts/token-usage-report.py ~/.hermes/scripts/archive/
27. mv ~/.hermes/scripts/approval-guard.py ~/.hermes/scripts/archive/
28. mv ~/.hermes/scripts/context-packet.py ~/.hermes/scripts/archive/
29. mv ~/.hermes/scripts/urgency-router.py ~/.hermes/scripts/archive/
30. mv ~/.hermes/scripts/routing-instructions.md ~/.hermes/research/archive/
```

### Phase 5: Automation Setup (10 min)

```bash
31. # Log rotation cron job
    hermes cron create --name "log-rotate" --schedule "0 3 * * 0" \
      --script "find ~/.hermes/logs -name '*.log.*' -mtime +7 -delete" \
      --no_agent

32. # Disk usage alert
    hermes cron create --name "disk-alert" --schedule "0 8 * * *" \
      --script "df -h /models ~ | awk 'NR>1 && \$5+0 > 90 {print \$0}'" \
      --no_agent

33. # Weekly state.db VACUUM
    hermes cron create --name "vacuum-dbs" --schedule "0 4 * * 0" \
      --script "sqlite3 ~/.hermes/state.db 'VACUUM;'" \
      --no_agent
```

---

## 13. Risk Assessment Summary

| Risk Level | Items | Total Space | Rollback Complexity |
|-----------|-------|-------------|---------------------|
| ✅ None | Config backups, logs, model cache, packages | ~115MB | Trivial |
| 🟢 Very Low | state-snapshot, old logs, model cache, stale scripts | ~175MB | None needed |
| 🟡 Low | Backup binaries, old-qwen, mtp files | ~5.5GB | Re-download from HF |
| 🟠 Medium | Bonsai-Image-Demo, rescue-ultra, apk-analysis | ~23.7GB | Not restorable |

**Overall risk: LOW.** 95% of space can be reclaimed with no functional impact. The 3 medium-risk items (23.7GB) need visual verification before action.

---

## 14. Before-and-After Structure

### Before (current)

```
~/.hermes/ (380MB)
  config.yaml + 5 .bak files + .env.bak + .corrupt  (~145KB clutter)
  state.db (168MB) + state-snapshots/ (153MB) = 321MB
  logs/ (15.5MB, 16 files)
  cache/models_dev_cache.json (2.4MB)
  kanban.db (115KB, unused)
  scripts/benchmark_*.py, token-usage-report.py (stale)
  9 orphan .tmp/.json state files
  research/ — 4 reports (62KB)
```

### After (proposed)

```
~/.hermes/ (210MB)
  config/ (30KB)
    config.yaml
    SOUL.md
    AGENTS.md
    auth.json
    backups/
      config.yaml.audit-backup-2026-06-18
  state/
    state.db (VACUUMed ~70-100MB)
    kanban.db
    response_store.db
  logs/ (5MB, 5 files)
  cache/ (220KB — model_cache excluded)
  scripts/ (active: 7 files)
    archive/ (stale: 5 files)
  research/ (2 files)
    archive/ (stale research, prompt-opt)
  skills/ (125 — unchanged)
  memories/ (12 — unchanged)
  profiles/ (4 — unchanged)

~/archive/
  configs/              — Old .bak files from ~/.hermes
  reports/              — AI_CLI_STACK*, stale docs
  experiments/          — Bonsai-Image-Demo, rescue-ultra (moved, not deleted)
  references/           — apk-analysis (if keeping)
```

---

## 15. Rollback Procedure

### For Quick Wins (Phase 1)

**Config backups restoration:**
```bash
# If a stale backup is needed after deletion
# It was in ~/archive/configs/ — restore with:
cp ~/archive/configs/config.yaml.bak.* ~/.hermes/
```

**State snapshot:**
```bash
# Not recoverable after deletion. If you need previous session history,
# you'd need to restore state.db from before the VACUUM.
# Suggestion: BACKUP state.db before VACUUM:
cp ~/.hermes/state.db ~/.hermes/state.db.pre-vacuum
```

### For Phase 3 (High-risk items)

**Archived items:** Restore with `mv ~/archive/experiments/Bonsai-Image-Demo ~/Bonsai-Image-Demo`
**Deleted models:** Re-download from Hugging Face using the original sources

---

## 16. Cleanup Commands Reference

### Safe (execute anytime)

```bash
# VACUUM state.db
hermes sessions vacuum
# OR manually: sqlite3 ~/.hermes/state.db 'VACUUM;'

# Delete stale snapshots
rm -rf ~/.hermes/state-snapshots/

# Delete stale config backups
rm -f ~/.hermes/config.yaml.bak.* ~/.hermes/.env.bak.* ~/.hermes/context_length_cache.yaml.bak.* ~/.hermes/config.yaml.corrupt.*

# Delete stale model cache
rm -f ~/.hermes/cache/models_dev_cache.json

# Rotate old logs
rm -f ~/.hermes/logs/*.2 ~/.hermes/logs/*.3 ~/.hermes/logs/*.4 ~/.hermes/logs/*.5

# Remove residual apt config
sudo apt autoremove --purge -y

# Clean apt cache
sudo apt clean
```

### Verification-Required (inspect first)

```bash
# Check Bonsai-Image-Demo contents
ls -la ~/Bonsai-Image-Demo/
# If safe: mv ~/Bonsai-Image-Demo/ ~/archive/experiments/

# Check rescue-ultra contents
ls -la ~/rescue-ultra/
# If safe: mv ~/rescue-ultra/ ~/archive/experiments/

# Check for old-qwen references
grep -r "old-qwen\|Qwen3.5-4B" ~/.hermes/ ~/Unspooled/ 2>/dev/null

# Check for mtp-gemma references
grep -r "mtp-gemma" ~/.hermes/scripts/models.py 2>/dev/null

# Verify which llama-server binary is used by systemd
systemctl --user cat llama-server.service 2>/dev/null | grep ExecStart
# Only delete backup binaries after confirming the active binary path
```

### High-Risk Abort

```bash
# STOP. Do NOT run these without explicit approval:
# rm -rf ~/Bonsai-Image-Demo/
# rm -rf ~/rescue-ultra/
# rm -rf ~/apk-analysis/
# rm -f /archive/models/old-qwen/*.gguf
# rm -f /models/downloads/mtp-gemma-*.gguf
```

---

**Report complete. 0 changes applied. Awaiting approval to execute phases.**

*Estimated cleanup: Phase 1 (5 min) → Phase 2 (10 min) → Phase 3 (15 min) → Phase 4 (15 min) → Phase 5 (10 min)*  
*Total: ~55 minutes for complete server + Hermes environment optimization*
