Fix scan I/O safety and incomplete-scan exit status - #14
Merged
Conversation
This was referenced Sep 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A nonexistent scan root previously returned exit code 0, and passing the input as
--outputtruncated the source before discovery. Concurrent edits could also invalidate the file-backed memory map.This change reports discovery/read/parse failures through the exit status, uses bounded owned reads, and stages file output beside its destination until all scanning and writing succeeds. Existing source files, explicit inputs, custom pattern files, and symlink destinations are protected. Writer errors cancel discovery and scanning; redirected stdout is excluded from discovery.
Behavior change:
--outputrequires a writable destination directory and a regular-file destination. Stdout can still contain partial findings when a scan fails. Staged replacement protects against failed scans, but does not promise crash durability or a filesystem-wide snapshot during concurrent source edits.Evidence: reproduced missing-root success and source truncation on
a659f1c; memmap2's safety contract explicitly identifies concurrent modification as a potential source of undefined behavior.Validation:
cargo fmt --all -- --check; Clippy with warnings denied for all targets under both all features and no default features; all-feature and minimal-feature test suites. Added regression coverage for input preservation, invalid options, partial stdout, symlink output, read bounds, and flush failures. Existing patterns and fixture files are unchanged.Part 1 of a review series; independently based on
main.