# Self-Maintenance Cycle Results (2026-05-29)

## Dead Code Removed (5 files, 442 lines)

All had zero external references. Build verified clean after removal.

| File | Lines | Why dead |
|------|-------|----------|
| `ui/screens/intro/UnspooledIntroScreen.kt` | 139 | Never called from NavHost or any other screen |
| `ui/screens/home/HomeScreenShell.kt` | 83 | Never called (NetflixHomeScreen uses its own layout) |
| `ui/screens/home/HomeScreenTopBar.kt` | 111 | Never called (NetflixHomeScreen has its own top bar) |
| `ui/screens/home/HomeScreenFocusState.kt` | 30 | Never referenced outside its own definition |
| `ui/screens/settings/NetworkSettingsViewModel.kt` | 79 | Zero external references (no screen injects it) |

**Also removed:** `ui/screens/intro/` directory (empty after file removal).

**KT file count:** 283 → 278.

## Known Test Failures (6/131 SourceRanker)

Pre-existing, not caused by cleanup. Implementation drift from test expectations:

1. `regex combined BOOST and PENALIZE — net score determines rank` — HEVC should beat XVID but XVID wins
2. `Nuvio filters — preferred release group wins tie` — GROUPB should beat GROUPA but GROUPA wins
3. `Speed First — H264 preferred over HEVC on weak devices` — H264 should beat HEVC but HEVC wins
4. `regex BOOST — boosts matching streams above non-matching` — Atmos should beat stereo but AAC wins
5. `Unsupported AV1 ranks lower than supported H264` — H264 should beat AV1 but AV1 wins
6. `speed first with isEpisode = true prefers episode-sized files` — small episode should beat big but big wins

**Root cause:** SourceRanker scoring logic diverged from test spec during implementation iterations.

## Profile ID Hardcoding (8 stale TODOs)

ProfileManager exists and is wired in ViewModels but 3 data-layer files still use `profileId = 1`:

- `WatchedSeriesStateHolder.kt:55` — TODO: replace with active profile ID
- `ContinueWatchingEnrichmentCache.kt:99` — TODO: replace with actual active profile ID
- `ContinueWatchingEnrichmentCache.kt:103` — TODO: use proper activeProfile flow
- `ContinueWatchingEnrichmentCache.kt:117` — `profileId = 1` (TODO comment)
- `ContinueWatchingEnrichmentCache.kt:163` — `profileId = 1` (TODO comment)
- `SearchHistoryDataStore.kt:34` — TODO: replace with actual active profile ID
- `AndroidTvChannelSyncService.kt:44` — TODO: add settings stores
- `AllSourcesViewModel.kt:127` — TODO: expose resolution cutoff & quality mode in settings UI

## Hermes Environment Cleanup

Removed stale artifacts from `.hermes/`:

- `projects/streaming-app/` — 494MB Python backend (superseded by nexstream Android)
- `projects/streaming-app-*.md` — 56KB stale research docs
- `audit/AIOStreams/` — 12MB completed audit
- `archived-routing-scripts/` — 24KB superseded routing
- Old session files (>2 weeks) — 114MB (356 files pruned)
- Archived old trailer implementation plans

**Disk freed:** ~620MB (9.2G → 8.5G)

## Memory Consolidation

- MEMORY.md: 2017 → 447 chars (78% reduction) — moved project details to PROJECT_STATE.md
- USER.md: 1233 → 674 chars (45% reduction) — removed redundant separators and verbose phrasing

## New Documentation Files

Created in `~/nexstream/`:

- `PROJECT_STATE.md` — 5853 chars (reduced from ~8400)
- `CURRENT_TASKS.md` — 1144 chars
- `ARCHITECTURE.md` — 2421 chars
- `KNOWN_ISSUES.md` — 1480 chars
- `TECH_DEBT.md` — 1789 chars

## Dead Code Detection Method

1. List all Screen/ViewModel files in `ui/screens/`
2. For each file, grep its composable/class name across entire codebase
3. Exclude self-references (the file defining it)
4. If zero external references → file is dead code
5. Remove, rebuild, verify tests still pass

## Next Actions

1. Fix SourceRanker (6 failing tests, estimated 2-4h)
2. Wire ProfileManager into data layer (replace 5 profileId=1 hardcodes, estimated 1-2h)
3. Real-device QA (Fire TV/Shield)
4. Add PlayerViewModel + DetailsViewModel tests
5. Configure release signing