Repository navigation
Keep a File Whose Repair Run a Signal Ended - #1112
Conversation
A repair tier killed by a signal, such as the out-of-memory killer during a long re-encode, never ran to a result. Count it with the tool runs that did not run, so the failed repair leaves the state unchanged, DeleteInvalidFiles keeps the file, and the next run repairs again. Fixes #1095 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FfMpeg overrides the shared check with its 255 exit, so the verify run and the buffered runs read a signal the same way. The FfProbe packet run records a signal too, so the docs' claim holds for every tool run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
A recorded local strict-review pass covers head |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Signal detection and tool error recording PlexCleaner/MediaTool.cs, PlexCleaner/FfMpegTool.cs, PlexCleaner/FfProbeTool.cs, PlexCleaner/ToolErrorScope.cs, PlexCleanerTests/VerifyToolErrorTests.cs |
MediaTool adds EndedBySignal and records an error when a completed command exits by signal. FFmpeg extends signal classification for exit code 255, and FFprobe records errors for signal-ended packet analysis. Tests cover signal classification for FFmpeg and MkvMerge. |
Incomplete-run state and file handling PlexCleanerTests/VerifyToolErrorTests.cs, ARCHITECTURE.md, HISTORY.md |
Tests cover signal exits during repair and packet analysis, including tool-error counts, unchanged state, and retained files. The architecture and history descriptions cover incomplete tool runs and their effects on repair state and file handling. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related issues
- Decide How a Signal-Killed Repair Run Affects DeleteInvalidFiles #1095: The changes record signal-ended repair runs as tool errors and preserve state and files.
- Session Handoff [process-findings]: Promote and Release 3.23 #1085: The changes update the repair-path behavior and its architecture description.
- Clear BitrateExceeded and Handle Failed Bitrate and Packet Analysis #1078: The changes record signal-ended FFprobe packet-analysis runs as tool errors and preserve state and files.
Possibly related PRs
- ptr727/PlexCleaner#1093: This PR extends signal-exit handling from FFmpeg verification to repair and packet-analysis runs.
- ptr727/PlexCleaner#1091: This PR applies the existing tool-error and unchanged-state rules to signal-ended runs.
- ptr727/PlexCleaner#1089: This PR extends the non-completion handling for FFmpeg verification to signal-ended tool runs.
Merge Risk: 
Minimal · up to 4df2c
-
No merge-blocking issue is established for the signal-handling change. Merge readiness remains subject to normal build and test checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Linked Issues check
-
Explanation
Issue
#1095selects choice 1. The reviewed code records non-Windows signal exits inToolErrorScope.Countfor the shared buffered path.FfMpegalso recognizes exit 255.FfProbe.GetPacketsAsync()records signal-ended packet analysis. The tests cover all four repair tiers and packet analysis. They verify unchanged state, retained media and sidecar files, and no modification. The existing state and count checks allow a later run to retry repair. The reported test result is 338 passed and 0 failed.
Full details: Out of Scope Changes check
-
Explanation
The changes stay connected to issue
#1095. The sharedMediaTool.Execute()change covers the repair tools through their common execution path. TheFfProbechange covers packet analysis in the repair ladder. TheFfMpegoverride, tests, and documentation define and verify the required signal exit behavior. No unrelated change is demonstrated.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 5 files. (2 skipped: 2 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
PR Summary by QodoKeep files when a repair tool is terminated by a signal
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
Code Review by Qodo
1.
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The repair-state branch condition remains incorrect because a signal-ended FfProbe run during verification is included in the baseline, causing failed repairs to persist failure states even when the file is retained.
1 open issue
What changed in this PR
This pull request updates tool-error handling so signal-terminated repair and packet-analysis runs are treated as incomplete, preserving affected files and allowing later retries. It also adds regression coverage and updates project documentation.
Changes:
- Detects signal-ended buffered tool executions and packet-analysis runs, including FFmpeg exit code 255.
- Preserves media and sidecar files when interrupted repair operations produce no trusted result.
- Adds signal-boundary, repair-tier, and packet-analysis tests.
- Updates the architecture documentation and unreleased history.
This pull request requires changes.
| File | Description |
|---|---|
PlexCleanerTests/VerifyToolErrorTests.cs |
Tests signal classification and preservation behavior across repair and packet-analysis paths. |
PlexCleaner/ToolErrorScope.cs |
Updates the scope documentation for incomplete tool runs. |
PlexCleaner/MediaTool.cs |
Records signal-ended buffered tool executions as tool errors. |
PlexCleaner/FfProbeTool.cs |
Records signal-ended packet-analysis executions. |
PlexCleaner/FfMpegTool.cs |
Adds FFmpeg-specific signal handling, including exit code 255. |
HISTORY.md |
Documents file preservation and retry behavior for incomplete tool runs. |
ARCHITECTURE.md |
Updates the repair and deletion flow documentation. |
Review effort: Lite
|
A recorded local strict-review pass covers head |

Summary
Fixes #1095.
A repair tool run that a signal kills never runs to a result. The out-of-memory killer during a long re-encode is one example. Such a run used to read as a genuine failure.
VerifyAndRepair()then setVerifyFailedandRepairFailed, and withDeleteInvalidFileson,DeleteFailedFile()deleted the file. The maintainer chose choice 1 on #1095: count a signal-ended repair run with the tool runs that did not run.MediaTool.Execute(), the shared buffered path, records a run that a signal ended inToolErrorScope.Count.EndedBySignal()reads 129 to 159 outside Windows. FfMpeg overrides it to add 255, the exit FFmpeg gives once it handles a signal.ToolErrorScope.Countis read only byDeleteFailedFile()and by the two repair paths' before-and-after comparisons, so the wider reach only keeps files.FfProbe.GetPacketsAsync()has its own execution path and records a signal-ended packet analysis the same way.SignalCount, so a killed verify still runs the repair ladder.ARCHITECTURE.md"Verify and Repair" says so.ARCHITECTURE.mdand the unreleased 3.23HISTORY.mdentry are updated to match.The
commentslabel covers the editedToolErrorScopesummary comment and the new comment explaining the signal exit range.Tests
VerifyAndRepair_RepairSignalExit_KeepsStateAndFileskills each repair tier in turn. It also includes FFmpeg's 255 exit. Each case leaves the state unchanged and keeps the file. All four cases fail without the fix.VerifyAndRepair_PacketAnalysisSignalExit_KeepsStateAndFileskills the FfProbe packet analysis in the timestamp ladder. It fails without the FfProbe record.EndedBySignal_FfMpeg_MatchesSignalExitCodesandEndedBySignal_OtherTool_MatchesSignalExitCodescheck the exit code boundaries.dotnet test: 338 passed, 0 failed.Local review
Four recorded
local-strict-reviewpasses, the last over the current head with no findings.Fixed after the local passes
ARCHITECTURE.md:707(introduced, wording): theRFnode claimed any tool run that did not finish leads to a failure with the state unchanged. The code comparesToolErrorScope.Countonly against a value taken just before the repair starts. The node now reads "a tool run during the repair failed to launch, threw, or was ended by a signal, or a signal ended a verify", fixed in 4df2c42. Qodo raised the same point.Declined with evidence
🤖 Generated with Claude Code
Summary by CodeRabbit