Expand description
Filesystem helpers for temp directories, atomic writes, path normalization, and safeguard dumps.
Responsibilities:
- Create and clean Ralph temp directories.
- Write files atomically and sync parent directories best-effort.
- Persist safeguard dumps for troubleshooting output.
- Redact sensitive data in safeguard dumps by default (secrets, API keys, tokens).
- Expand tilde (
~) to the user’s home directory for Unix-style paths.
Not handled here:
- Directory locks or lock ownership metadata (see
crate::lock). - Cross-device file moves or distributed filesystem semantics.
- Retry/backoff behavior beyond the current best-effort operations.
- Redaction logic itself (see
crate::redaction).
Invariants/assumptions:
- Callers provide valid paths;
write_atomicrequires a parent directory. - Temp cleanup is best-effort and may skip entries on IO errors.
safeguard_text_dumprequires explicit opt-in (env var or debug mode) to write raw content.safeguard_text_dump_redactedis the default and safe choice for error dumps.expand_tildeonly handles leading~or~/..., not~user/...or nested tildes.
Re-exports§
pub use crate::constants::paths::RALPH_TEMP_PREFIX;
Functions§
- cleanup_
default_ temp_ dirs - cleanup_
stale_ temp_ dirs - cleanup_
stale_ temp_ entries - create_
ralph_ temp_ dir - create_
ralph_ temp_ file - Creates a NamedTempFile in the ralph temp directory with the ralph_ prefix. This ensures the file will be caught by cleanup_default_temp_dirs().
- expand_
tilde - Expands a leading
~to the user’s home directory ($HOME) for Unix-style paths. - ralph_
temp_ root - safeguard_
text_ dump - Writes a safeguard dump with raw (non-redacted) content.
- safeguard_
text_ dump_ redacted - Writes a safeguard dump with redaction applied to sensitive content.
- write_
atomic