Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ jobs:
test -x "$APP/Contents/MacOS/Mac Cleaner"
N=$(nm -U "$APP/Contents/MacOS/Mac Cleaner" | grep -c MacCleanerCore || true); [ "$N" -gt 0 ] || { echo "::error::MacCleanerCore is not linked into the app"; exit 1; }; echo "MacCleanerCore linked ($N symbols)"

# The budget only goes down: any Swift warning not in scripts/warnings-baseline.txt fails the build.
- name: Warning budget
run: |
scripts/test-check-warnings.sh
scripts/check-warnings.sh

- name: Safety self-test (throwaway home folder)
run: scripts/selftest.sh "$APP"

Expand Down
8 changes: 5 additions & 3 deletions docs/architecture/CURRENT_STATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ There is no separate menu-bar helper process; the menu bar panel (`MenuBarPopove
| Storage Map | `DiskMap*.swift`, `Treemap.swift`, `DirSize.swift` | `DiskScanner` (getattrlistbulk), `DirSize`, `SizeCache`, `WalkPool` |
| System Data (TM snapshots, iOS backups, Messages attachments, Mail) | `SystemData.swift` | `SysItem`, `SysReport` |
| Startup & Extensions (login items, launch agents/daemons, pref panes, plug-ins) | `SystemItems.swift` | `AppEngine.removeSystemItems` |
| Shredder | `Shredder.swift` | `ShredEngine` |
| Shredder | `Shredder.swift`, `ShredReview.swift` | `CleanupExecutor` (`overwriteThenDelete`); `ShredEngine` was removed in M01-04c (#46) |
| Trash + Put Back | `Trash.swift`, `TrashView.swift` | `TrashLog`, `TrashOps` |
| Review sheet (all destructive UI flows) | `Review.swift`, `ReviewBuilders.swift` | `ReviewCenter`, `ReviewRequest`, `ReviewBuild` |
| History | `History.swift`, `SharedFile.swift` | `HistoryStore` (JSON file under a lock file) |
Expand All @@ -88,8 +88,10 @@ There is no separate menu-bar helper process; the menu bar panel (`MenuBarPopove
`mv -n`, chowns only the staging dir (#16).
* **Shell** — every subprocess has a time limit and process-group kill (#18).

*Status at the audit.* M01-04 has since put Trash moves and the Shredder on `CleanupExecutor` (#35–#46); `ShredEngine` and `AppEngine.trash` are gone. The modules still on their own loop are listed in `ROADMAP_V2.md` (M01-06…11). The paragraph below describes the audited baseline.

There is **no shared cleanup executor**: each module (`Cleaner.run`, `SDKEngine.remove`, `ProjectEngine`,
`AppEngine`, `ShredEngine`, `DupFinder`, `TrashOps`) implements its own revalidate/execute/record loop.
`AppEngine`, `ShredEngine` (since removed), `DupFinder`, `TrashOps`) implements its own revalidate/execute/record loop.
There is **no `ScanOutcome`/completeness model**: enumerators in `Scanner.swift`, `Projects.swift`,
`Duplicates.swift`, `Shredder.swift` use `errorHandler: { _, _ in true }`, so unreadable folders are skipped
silently.
Expand Down Expand Up @@ -125,7 +127,7 @@ Swift 6 diagnostics already emitted in Swift 5 mode (baseline build): `Insights.
| Measure | Value | How |
|---|---|---|
| Clean Release build | 73.7 s wall | `xcodebuild … -configuration Release CODE_SIGN_IDENTITY=- build` into a scratch SYMROOT |
| Compiler warnings | 4 unique Swift warnings (+1 AppIntents notice) | build log |
| Compiler warnings | 4 unique Swift warnings (+1 AppIntents notice) | build log. Re-measured on main `800c3cd` (M01-04d): the same 4, now enforced by `scripts/check-warnings.sh` and `scripts/warnings-baseline.txt` |
| Self-test (real home not touched) | 197 passed / 2 failed, ~7 s | `CFFIXED_USER_HOME=<tmp>` with `Documents`, `Library/Caches`, `.cache`, `.Trash` pre-created |

The two failures under a relocated home are fixture-environment issues, not product regressions:
Expand Down
1 change: 1 addition & 0 deletions docs/architecture/MIGRATION_PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ Re-run the Stage A measurements after Stage C and after Stage D. A change that r
| M01-03 | Core contracts: `FileIdentity` (value + match rule), `CleanupRisk`, `Disposition`, `CleanupTarget`, `CleanupCandidate`, `CleanupPlan` (+ identity digest incl. risk and command consequence), `CleanupApproval` + `ApprovalLedger` (single use), `ScanOutcome`, `ItemOutcome`, `CleanupReport`, `ProgressEvent`. Not used by the app yet | package tests |
| M01-04a | `MacCleanerPlatform` (`LocalFileSystem`: identity capture, staged descriptor-relative removal, checked Trash moves) and `MacCleanerFeatures` (`CleanupExecutor`). The app doesn't use them yet | fake-file-system and real-disk adversarial tests |
| M01-04b | `AppEngine.trash` callers and the Shredder go through the executor | self-test, CLI/MCP checks |
| M01-04d | Simplification and quality gate, one reviewed PR per slice, no behavior change: warning budget and stale docs; Trash-named review plumbing renamed; legacy `perform` fallback audited; async bridges and the `trashMover` seam (separate PRs) | package + self-test + approval-site + no-test-hooks + warning-budget checks green |
| after M01-04 | `Persistence`: `HistoryStore` → sessions | migration test from v1 `history.json` |
| M01-06… | One module per PR onto the executor: caches, projects, SDKs, apps, duplicates, system data | per-module tests |
2 changes: 1 addition & 1 deletion docs/architecture/RISK_REGISTER.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ safety guarantee weaker than stated · **Low** = inconsistency with no known los
| TrashGuard case/symlink bypass | #15 | `TrashGuard.key` lower-cases and resolves parent symlinks |
| Weekly clean runs simulator commands | #15 | `AutoClean.select` only accepts file/folder actions |
| MCP confirm without preview | #15 | `MCPServer.approve` single-use id, tool + digest bound (see RISK-004 for what remains) |
| Shredder hard links / locked files | #15 | `ShredEngine.shred` refuses items with `st_nlink > 1` or unwritable files (see RISK-001 for what remains) |
| Shredder hard links / locked files | #15 | `ShredEngine.shred` refused items with `st_nlink > 1` or unwritable files; `ShredEngine` is removed and the executor's `overwriteThenDelete` now applies the checks (M01-04c, #45/#46; see RISK-001 for what remains) |
| Unsigned updates | #15 | `Updater.offerable` requires `.sig`; `prepare` checks SHA-256, Ed25519, bundle id, version, `codesign --verify --deep --strict`; swap with restore on failure |
| Review runs live selection | #18 | `ReviewRequest.perform` receives reviewed ids |
| Concurrent history/Trash log writes | #18 | `SharedFile` lock + re-read + write |
Expand Down
46 changes: 46 additions & 0 deletions scripts/check-warnings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/zsh
# Warning budget: fails on any Swift compiler warning that is not listed in scripts/warnings-baseline.txt.
# scripts/check-warnings.sh [LOG] LOG defaults to build/xcodebuild.log (written by scripts/xcbuild.sh)
# scripts/check-warnings.sh --list [LOG] prints the current warnings in baseline format (to refresh the file)
# The baseline lists every accepted warning as "<file>: <message>" (no line numbers, so edits that move code
# don't break it; a message that repeats in a file is listed once per occurrence; a line may give alternative
# wordings from different Xcode versions as "<file>: <msg> || <file>: <msg>"). New warnings fail the check.
# A baseline entry whose warning no longer occurs also fails: remove it in the same PR, so a warning that is
# fixed and later reintroduced fails instead of being waved through by a stale entry.
# Never add a line to make a new warning pass: fix the warning, or record why in the PR and docs/architecture/DECISIONS.md.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
LIST=0; [[ "${1:-}" == "--list" ]] && { LIST=1; shift; }
LOG="${1:-$ROOT/build/xcodebuild.log}"
BASE="${WARNINGS_BASELINE:-$ROOT/scripts/warnings-baseline.txt}" # the override is for scripts/test-check-warnings.sh
[[ -f "$LOG" ]] || { echo "no build log at $LOG (run scripts/xcbuild.sh first)" >&2; exit 2; }
CURRENT="$(mktemp)"; trap 'rm -f "$CURRENT" "$CURRENT".base "$CURRENT".raw "$CURRENT".canon' EXIT
# Compiler warnings only; the AppIntents metadata notice is not a Swift diagnostic.
# (grep exits 1 on no match; that is the goal state once every warning is fixed, so it must not abort the script.)
{ grep -E '^/.*\.swift:[0-9]+:[0-9]+: warning: ' "$LOG" || true; } | sort -u \
| sed -E 's|^.*/(Packages/.*\.swift):[0-9]+:[0-9]+: warning: |\1: |; s|^.*/(MacCleaner/.*\.swift):[0-9]+:[0-9]+: warning: |\1: |' \
| sort > "$CURRENT"
if (( LIST )); then cat "$CURRENT"; exit 0; fi
{ grep -v -E '^\s*(#|$)' "$BASE" || true; } > "$CURRENT.raw"
# A baseline line may list the same warning as worded by different compilers: "<key> || <key>". CI (Xcode 16.x)
# and local builds (Xcode 26.x) word a few diagnostics differently. The first form is the canonical one.
awk -F' \\|\\| ' '{print $1}' "$CURRENT.raw" | sort > "$CURRENT.base"
# FILENAME, not NR==FNR: with an empty baseline NR==FNR also holds for the log, which would swallow every warning.
awk -F' \\|\\| ' 'FILENAME == ARGV[1] { for (i=2;i<=NF;i++) alias[$i]=$1; next } { print (($0 in alias) ? alias[$0] : $0) }' "$CURRENT.raw" "$CURRENT" | sort > "$CURRENT.canon"
NEW="$(comm -13 "$CURRENT.base" "$CURRENT.canon")"
GONE="$(comm -23 "$CURRENT.base" "$CURRENT.canon")"
TOTAL=$(wc -l < "$CURRENT" | tr -d ' ')
FAIL=0
if [[ -n "$GONE" ]]; then
echo "Baseline warnings that no longer occur (remove these lines from scripts/warnings-baseline.txt in this PR):" >&2
echo "$GONE" | sed 's/^/ - /' >&2
echo "A stale entry would let the same warning come back unnoticed, so the budget must shrink with the code." >&2
FAIL=1
fi
if [[ -n "$NEW" ]]; then
echo "NEW compiler warnings (not in scripts/warnings-baseline.txt):" >&2; echo "$NEW" | sed 's/^/ + /' >&2
echo "Fix them; the warning budget only goes down." >&2
FAIL=1
fi
(( FAIL == 0 )) || exit 1
echo "Warning budget OK: $TOTAL warning(s), all in the baseline, none stale."
33 changes: 33 additions & 0 deletions scripts/test-check-warnings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/zsh
# Synthetic tests for scripts/check-warnings.sh (no build needed). Run in CI before the real check.
# scripts/test-check-warnings.sh
set -uo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
CHECK="$ROOT/scripts/check-warnings.sh"
D="$(mktemp -d)"; trap 'rm -rf "$D"' EXIT
P=/Users/runner/work/MacCleaner/MacCleaner
A="main actor-isolated static property 'k' can not be referenced from a nonisolated context"
B16="capture of 'b' with non-sendable type 'T' in a '@Sendable' closure" # Xcode 16.x wording
B26="capture of 'b' with non-Sendable type 'T' in a '@Sendable' closure" # Xcode 26.x wording
FAILS=0
log() { for w in "$@"; do print -r -- "$P/MacCleaner/${w%%|*}.swift:1:1: warning: ${w#*|}"; done > "$D/log"; }
base() { { print "# test baseline"; for l in "$@"; do print -r -- "$l"; done; } > "$D/base"; }
run() { WARNINGS_BASELINE="$D/base" "$CHECK" "$D/log" >/dev/null 2>&1; }
expect() { # expect <pass|fail> <name>
run; local rc=$?
if [[ $1 == pass && $rc == 0 ]] || [[ $1 == fail && $rc == 1 ]]; then print "ok $2"; else print "FAIL $2 (rc=$rc, wanted $1)"; FAILS=$((FAILS+1)); fi
}
ENTRY_A="MacCleaner/A.swift: $A"
ENTRY_B="MacCleaner/B.swift: $B26 || MacCleaner/B.swift: $B16"
base "$ENTRY_A" "$ENTRY_B"
log "A|$A" "B|$B26"; expect pass "Xcode 26 wording passes"
log "A|$A" "B|$B16"; expect pass "Xcode 16 wording passes"
log "A|$A" "B|$B16" "C|new"; expect fail "a new warning fails"
log "B|$B26"; expect fail "a fixed warning with a stale baseline entry fails"
base "$ENTRY_B"; expect pass "removing the fixed warning from the baseline passes"
log "A|$A" "B|$B26"; expect fail "reintroducing the warning later fails"
log "B|$B26" "B2|$B26"; expect fail "an unlisted warning with the same text in another file fails"
: > "$D/log"; base "$ENTRY_A"; expect fail "no warnings at all while the baseline still lists one fails"
: > "$D/log"; base; expect pass "no warnings and an empty baseline passes"
log "C|new"; base; expect fail "a new warning with an empty baseline fails"
(( FAILS == 0 )) && print "check-warnings tests passed" || { print "$FAILS check-warnings test(s) failed" >&2; exit 1; }
8 changes: 8 additions & 0 deletions scripts/warnings-baseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Accepted Swift compiler warnings (M01-04d), from clean Release builds of main 800c3cd (Xcode 26.x locally,
# Xcode 16.x in CI; " || " separates the two wordings of the same warning). All four are
# Swift 6 language-mode diagnostics that M01-05 / M01-12 (strict concurrency, Swift 6 mode) remove.
# The budget only goes down: delete a line when its warning is fixed; never add one. See scripts/check-warnings.sh.
MacCleaner/Insights.swift: main actor-isolated static property 'keepDays' can not be referenced from a nonisolated context; this is an error in the Swift 6 language mode
MacCleaner/Overview.swift: capture of 'buf' with non-Sendable type 'UnsafeMutableBufferPointer<Int64>' in a '@Sendable' closure || MacCleaner/Overview.swift: capture of 'buf' with non-sendable type 'UnsafeMutableBufferPointer<Int64>' in a '@Sendable' closure
MacCleaner/Overview.swift: capture of 'buf' with non-Sendable type 'UnsafeMutableBufferPointer<Int64>' in a '@Sendable' closure || MacCleaner/Overview.swift: capture of 'buf' with non-sendable type 'UnsafeMutableBufferPointer<Int64>' in a '@Sendable' closure
MacCleaner/Updates.swift: main actor-isolated static property 'repo' cannot be accessed from outside of the actor; this is an error in the Swift 6 language mode || MacCleaner/Updates.swift: expression is 'async' but is not marked with 'await'; this is an error in the Swift 6 language mode
Loading