RFC-004: Filesystem Layout & Run Management¶
- Status: Completed
- Authors: GPT-5 Codex (initial documentation)
- Stakeholders: Maintainers, operators concerned with storage hygiene
- Related PRDs:
docs/prd/PRD-001-transcript-pipeline.md,docs/prd/PRD-002-whisper-fallback.md - Related ADRs:
- ADR-003: Deterministic Feed Storage
- ADR-004: Flat Filesystem Archive Layout
Abstract¶
Define the rules governing output directories, filename sanitization, temporary storage, and run suffix semantics to guarantee deterministic, safe, and resumable filesystem interactions.
Problem Statement¶
Without consistent naming and directory policies, transcript archives become hard to diff, risk clobbering existing data, and may interact poorly with user environments. The system requires cross-platform-safe filenames, predictable run folders, and cleanup of temporary artifacts.
Constraints & Assumptions¶
- Target environments include macOS, Linux, and Windows; filenames must avoid reserved characters.
- Users may override output directories, but we encourage safe locations (home directory, platform data/cache roots).
- Whisper fallback stores intermediate media files that must be cleaned up to conserve disk.
Design & Implementation¶
- Base output directory
- Default:
output/rss_<sanitized_host>_<hash>where hash is first 8 chars of SHA-1 of the RSS URL. filesystem.derive_output_dirhandles overrides, invoking validation.- Validation
filesystem.validate_and_normalize_output_dirresolves paths, verifies they fall under safe roots (cwd, home, platform dirs), and warns otherwise.- Run suffixes
filesystem.setup_output_directoryderives optionalrun_suffixbased oncfg.run_idor Whisper usage.- Effective output path is
<output_dir>/run_<run_suffix>when suffix present. - Filename sanitization
filesystem.sanitize_filenamestrips control characters, collapses whitespace, and replaces unsafe characters with_.- Episode filenames follow
<idx:04d> - <title_safe>[ _<run_suffix>].<ext>. - Whisper outputs
filesystem.build_whisper_output_nametruncates titles (32 chars) and appends run suffix when available.- Temporary media stored in
<effective_output_dir>/.tmp_media/and removed post-transcription. - Run tracking files (Issue #379)
run.json- Top-level run summary combining run manifest and pipeline metrics (created at pipeline end)index.json- Episode index listing all processed episodes with status, paths, and error information (created at pipeline end)run_manifest.json- Comprehensive run manifest capturing system state for reproducibility (created at pipeline start, saved at pipeline end)metrics.json- Pipeline metrics including episode statuses, stage timings, and performance data (created at pipeline end)- All files are written to
<effective_output_dir>/and include schema versioning for forward compatibility. - Cleanup semantics
--clean-outputtriggers deletion of existing output directory if not in dry-run mode.- Best-effort removal of temp directories even on errors (warnings if removal fails).
Key Decisions¶
- Hash-based directory suffix avoids collisions between feeds hosted on same domain but different paths.
- Suffix semantics provide provenance (run ID, Whisper model) within output directories without complicating base naming.
- Sanitization policy prioritizes readability while remaining filesystem-safe across OSes.
Alternatives Considered¶
- Timestamped root directories: Rejected in favor of deterministic names; use
--run-id autowhen unique runs are desired. - Per-episode subdirectories: Rejected to keep archives flat and easy to diff.
Testing Strategy¶
- Unit tests cover sanitization edge cases and output derivation logic.
- Integration tests ensure
--clean-output,--skip-existing, and Whisper workflows interact correctly with directory management.
Rollout & Monitoring¶
- Warnings emitted when users choose "unsafe" directories (outside recommended roots) for observability.
- Future enhancements (checksums, subdirectory partitioning) can extend this RFC with backward compatibility.
References¶
- Source:
podcast_scraper/filesystem.py - Orchestrator usage:
docs/rfc/RFC-001-workflow-orchestration.md - Whisper specifics:
docs/rfc/RFC-005-whisper-integration.md