#!/usr/bin/env bash# A folder a script deletes FROM must never be the home folder or anything# above it. On 4 Oct 2026 a prune pointed at a folder directly under $HOME# deleted most of a home folder; every script whose deletable root can be# moved by an environment variable or a flag asks this first.## refuse_wide_root <what the folder is> <path>## Exits 2 with a sentence when <path> is empty, relative, `/`, has a `.` or `..`# in it, or is the home folder or a folder the home folder is inside — each as# written or as it resolves through symlinks. Sourced, never run.refuse_wide_root() {local what="$1" path="${2%/}" home="${HOME:-}" real="" home_real="" why="" home="${home%/}"if [ -z "$path" ]; then why="it is empty or /"elsecase"$path"in /*) ;; *) why="it is not an absolute path" ;;esaccase"$path/"in */../* | */./*) why="it has a . or .. in it" ;;esacfiif [ -z "$why" ] && [ -n "$home" ]; thenif [ -d "$path" ]; then real="$(cd "$path" 2>/dev/null && pwd -P)" || real=""; fiif [ -d "$home" ]; then home_real="$(cd "$home" 2>/dev/null && pwd -P)" || home_real=""; fi [ "$real" != "/" ] || why="it is /"local candidate insidefor candidate in"$path""$real"; do [ -n "$candidate" ] || continuefor inside in"$home""$home_real"; do [ -n "$inside" ] || continuecase"$inside/"in"${candidate%/}"/*) why="it is the home folder or a folder the home folder is inside" ;;esacdonedonefi [ -z "$why" ] && return0 echo "REFUSED: $what is '${2-}' — $why. This script deletes inside that folder, so it will not run there." >&2exit2}# A missing protection helper is never permission to delete review evidence.evidence_kept() {local helper="$(dirname "${BASH_SOURCE[0]}")/evidence.py" statusif python3 "$helper" keep "$1"; thenreturn0; else status=$?; fi [ "$status" -eq 1 ] && return1 echo "kept $1 — EVIDENCE protection could not be inspected" >&2return0}