import json def _is_prefix(parent_path: str, child_path: str) -> bool: return child_path == parent_path or child_path.startswith(parent_path + "/") def normalize_deleted_paths(paths): normalized = [] for raw_path in sorted(set(paths)): if not raw_path: continue if any(_is_prefix(existing, raw_path) for existing in normalized): continue normalized = [existing for existing in normalized if not _is_prefix(raw_path, existing)] normalized.append(raw_path) return normalized def load_deleted_paths(raw_json: str): parsed = json.loads(raw_json) if not isinstance(parsed, list): raise ValueError("deletedPaths must be a JSON array.") return normalize_deleted_paths(parsed)