# Ultimate Safe Cleaner 1.0.0 A Windows duplicate-file cleaner built around proof, review, quarantine, restoration, and complete audit records. The user-facing entry point is: `ULTIMATE-SAFE-CLEANER.bat` The batch file launches the packaged PowerShell and C# engine. Keep the entire folder together. ## First run 1. Extract the complete folder. 2. Run `RUN-SELF-TEST.bat`. 3. Confirm that the self-test says `SELF-TEST PASSED`. 4. Drag a folder onto `ULTIMATE-SAFE-CLEANER.bat`, or open the batch file and choose a folder. 5. Run a scan. 6. Open `SUMMARY.html` from the generated run folder. 7. Review candidates interactively or through `REVIEW-ACTIONS.csv`. 8. Apply approved quarantine actions. 9. Restore any quarantined run whenever needed. 10. Move an entire quarantine run to the Windows Recycle Bin only after review. Run the cleaner as your normal Windows account. The engine blocks elevated administrator sessions so ordinary personal-folder cleanup keeps the narrowest available access. ## Safety boundary The cleaner performs a read-only scan first. It changes no user files during scanning. A duplicate group must pass all four stages: 1. Same byte length 2. Same partial SHA-256 sample 3. Same full SHA-256 hash 4. Independent byte-for-byte comparison A matching filename, date, extension, or copy-like suffix never proves duplication. Before quarantine, the engine verifies the candidate and keeper again. It checks current file identity, timestamps, attributes, access-control fingerprints, byte equality, size, and SHA-256. It then moves the approved candidate into a quarantine folder on the same volume. It never overwrites a destination. ## Risk classes ### GREEN An exact byte duplicate in the same folder where a clean base filename remains and the candidate has a strict copy suffix such as `(1)` or `Copy`. Example: `photo.jpg` `photo (1).jpg` Both files still require explicit approval. ### YELLOW An exact byte duplicate whose placement may carry meaning. Common examples include duplicates in different folders, renamed copies, downloads beside organized files, and ambiguous keeper choices. ### RED A locked report-only candidate. Red protection includes: - Project trees detected through package and build markers - Backup, archive, version, snapshot, and recovery trees - Cloud-sync roots - Hidden, system, encrypted, sparse, reparse, and offline files - Files with alternate data streams or failed stream enumeration - Scripts, executables, libraries, configuration files, databases, manifests, shortcuts, and package files - Windows, Program Files, ProgramData, AppData, and the cleaner package - Paths listed in `NEVER_TOUCH.txt` - Paths containing protected project terms configured in `SafeCleaner-Config.json` ## Quarantine model Quarantine is a same-volume move. It preserves the file and its original path in a recovery manifest. Disk space remains allocated while the file stays in quarantine. Every quarantine run contains: - `QUARANTINE.json` - `QUARANTINE-MANIFEST.csv` - `QUARANTINE-IMMUTABLE.json` - `TRANSACTIONS.jsonl` - `RESTORE-INSTRUCTIONS.txt` - A flat `Files` store with collision-resistant names The recovery manifest preserves each original full path. The flat store avoids recreating very deep directory trees and reduces long-path failures during quarantine. The immutable recovery manifest receives its own SHA-256 fingerprint. Restore is blocked when that manifest changes. ## Interruption recovery Before every file move, the cleaner writes a pending transaction record through a write-through temporary file and filesystem-level atomic replacement. After a crash, forced close, or restart, the next run distinguishes among these states: - Source exists and destination is absent, meaning the move never committed - Source is absent and destination exists, meaning the move likely committed - Both exist, meaning the state is ambiguous and human review is required - Both are absent, meaning the state is ambiguous and human review is required The surviving file must match the recorded SHA-256 and size before recovery proceeds. ## Restore model Restore verifies the quarantine manifest and file hash before moving anything. When the original path is occupied, the cleaner preserves the existing file and restores the quarantined file with a name such as: `filename.RESTORED-CONFLICT-20260710-013500.ext` Restore never overwrites an existing file. ## Releasing quarantine The cleaner contains no direct permanent deletion of user files. The final release option moves the complete quarantine run into the Windows Recycle Bin. Windows can restore it until the Recycle Bin is emptied. Actual free space returns after the Recycle Bin is emptied. ## Reports Each scan creates a timestamped folder inside `CleanerRuns` containing: - `SUMMARY.html` - `REVIEW-ACTIONS.csv` - `EXACT-DUPLICATES.csv` - `IMMUTABLE-CANDIDATES.json` - `INVENTORY.csv` - `HARDLINKS.csv` - `SAME-NAME-DIFFERENT-CONTENT.csv` - `COPY-NAME-DIFFERENT-CONTENT.csv` - `LARGE-FILES.csv` - `ZERO-BYTE-FILES.csv` - `EMPTY-FOLDERS.csv` - `STALE-DOWNLOADS.csv` - `ARCHIVES-AND-INSTALLERS.csv` - `SKIPPED.csv` - `ERRORS.csv` - `RUN.json` - `RUN.log` Secondary reports are informational. The cleaner moves files only from explicitly approved exact-duplicate rows. ## Interactive review Choose `Review duplicate candidates interactively` from the menu. Available actions: - Approve the displayed candidate for quarantine - Keep it - Leave it unchanged - Open both containing folders - Approve all remaining GREEN copy-suffix candidates - Clear every approval - Save and exit The apply stage still requires an exact confirmation phrase. ## Manual CSV review Open `REVIEW-ACTIONS.csv` and enter exactly `QUARANTINE` in the `Action` column for approved rows. Values such as `delete`, `yes`, `remove`, `q`, or `1` have no effect. RED rows remain locked even when the CSV is edited. ## Protected paths Add one full path per line to `NEVER_TOUCH.txt`. Environment variables are supported: `%USERPROFILE%\Documents\Critical Project` Everything under a listed path is excluded from scans and actions. ## Configuration `SafeCleaner-Config.json` controls: - Hash cache, with fresh authoritative SHA-256 rechecks for every reported duplicate - Sample size - Minimum duplicate size - Large-file threshold - Stale-download age - Full inventory output - Drive-root and network scanning - Reparse and offline-file handling - Project markers - Protected extensions - Archive and installer extensions - Backup-folder patterns - Canonical roots - Extra excluded paths Conservative defaults are enabled. Drive-root and network scans begin disabled. The menu can clear the hash cache and force full recomputation on the next scan. ## Hard links Hard-linked paths point to the same physical file data. Removing one hard-link name normally recovers zero space while another link remains. The cleaner separates discovered hard-link paths into `HARDLINKS.csv`, assigns zero recoverable space, and locks any file whose Windows link count exceeds one. This also protects links whose other names sit outside the selected scan tree. ## Alternate data streams Two NTFS files can have identical visible main data while carrying different named streams. Every detected alternate stream locks the file as RED. A stream-enumeration failure also locks the file. ## Windows-native cleanup The menu opens Microsoft Storage settings and interactive Disk Cleanup for Windows-managed temporary and system files. The cleaner does not recreate those system-cleanup rules itself. ## Requirements - Windows 10 or Windows 11 - Windows PowerShell 5.1 or PowerShell 7 - A local folder with ordinary read and move permissions - NTFS recommended for full file-identity and stream protection ## Scope Version 1.0.0 handles exact byte duplicates. It reports large files, empty files, empty folders, old downloads, and archives without moving them. It does not decide whether visually similar images, transcoded videos, retagged music, resized pictures, or edited documents are interchangeable. Those cases require semantic review outside exact deduplication. ## Verification `RUN-SELF-TEST.bat` builds a temporary test tree, validates GREEN, YELLOW, and RED classification, quarantines one generated duplicate, restores it, compares the restored bytes, and removes only its generated test tree. Cross-platform reference and static tests are included under `Tests`. They cover exact duplicates, different-content copy names, project and backup protection, hard links inside and outside the scan tree, changed-file rejection, quarantine and restore, restore conflicts, and interrupted states. See `BUILD-VERIFICATION.txt`, `SAFETY-MODEL.md`, and `RESEARCH-SYNTHESIS.md`.