Skip to content

Fix scan I/O safety and incomplete-scan exit status - #14

Merged
script3r merged 2 commits into
mainfrom
codex/fix-scan-io
Sep 5, 2026
Merged

Fix scan I/O safety and incomplete-scan exit status#14
script3r merged 2 commits into
mainfrom
codex/fix-scan-io

Conversation

@script3r

@script3r script3r commented Sep 5, 2026

Copy link
Copy Markdown
Owner

A nonexistent scan root previously returned exit code 0, and passing the input as --output truncated 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: --output requires 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.

@script3r
script3r merged commit 8aea4d8 into main Sep 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant