Problem
The .base-cli-log-index.json can contain paths for log files that no longer exist. prune_log_files() currently counts those stale entries when calculating excess_count, which can delete more real log files than max_log_files permits.
A concrete reproduction with three real logs, one phantom index entry, and max_log_files=3 deletes two real logs instead of one.
Scope
- Filter indexed paths to existing files before building pruning candidates and calculating
excess_count.
- Keep the current log file eligible for retention even before it exists on disk.
- Add a regression test covering a stale/phantom index entry and asserting the configured real-file limit.
Acceptance criteria
- Stale index entries never consume a retention slot.
- Pruning leaves at most the requested number of real log files, including the current log.
- Existing index-based retention behavior remains covered.
Problem
The
.base-cli-log-index.jsoncan contain paths for log files that no longer exist.prune_log_files()currently counts those stale entries when calculatingexcess_count, which can delete more real log files thanmax_log_filespermits.A concrete reproduction with three real logs, one phantom index entry, and
max_log_files=3deletes two real logs instead of one.Scope
excess_count.Acceptance criteria