Documentation
¶
Overview ¶
Package safety provides safe deletion operations that protect user configuration.
Index ¶
- func IsAllowed(policy Policy, target string) bool
- func IsProtected(policy Policy, target string) bool
- func MustRemoveAll(policy Policy, target string)
- func RemoveAll(policy Policy, target string) error
- func RemoveAllUnsafe(target string) error
- func RemoveChainConfig(baseDir, chainName string) error
- type Policy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsProtected ¶
IsProtected checks if a path is protected by the given policy.
func MustRemoveAll ¶
MustRemoveAll is like RemoveAll but panics on policy violation. Use only in tests or when you're absolutely sure the path is safe.
func RemoveAll ¶
RemoveAll safely removes a directory or file, respecting the policy. It returns an error if the target is protected or not in an allowed path.
func RemoveAllUnsafe ¶
RemoveAllUnsafe removes a path without policy checks. This should ONLY be used in very specific cases with explicit user confirmation. The caller is responsible for ensuring safety.
func RemoveChainConfig ¶
RemoveChainConfig removes a specific chain configuration directory. This is a special-case function for user-confirmed chain deletion. It requires that the target is a direct subdirectory of the chains directory, NOT the chains directory itself. The caller must ensure user confirmation. baseDir is the Lux base directory (e.g., ~/.lux)
Types ¶
type Policy ¶
type Policy struct {
BaseDir string // The Lux base directory (e.g., ~/.lux)
AllowPrefixes []string // absolute paths allowed to delete under
DenyPrefixes []string // absolute paths never deletable
}
Policy defines which paths are allowed or denied for deletion.
func DefaultPolicy ¶
DefaultPolicy returns the standard safety policy for the CLI. It allows deletion of ephemeral runtime state but protects user configuration. baseDir is the Lux base directory (e.g., ~/.lux)