Skip to content

Improve PAR2 create and verify/repair parity#8

Open
mjc wants to merge 30 commits into
mainfrom
t3code/verify-repair-parity
Open

Improve PAR2 create and verify/repair parity#8
mjc wants to merge 30 commits into
mainfrom
t3code/verify-repair-parity

Conversation

@mjc
Copy link
Copy Markdown
Owner

@mjc mjc commented Apr 22, 2026

Summary

  • add PAR2 creation support, volume file splitting, create CLI wiring, and create benchmarks/scripts
  • align verify and repair CLI behavior with par2cmdline-turbo for quiet output, base paths, extra files, purge behavior, and exit codes
  • improve repair reporting/progress and share verification logic for repair parity cases
  • add integration, binary, parity, and create/repair regression coverage

Tests

  • nix develop -c cargo test --all-targets

Copilot AI review requested due to automatic review settings April 22, 2026 03:09
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

❌ Patch coverage is 84.19839% with 137 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@f8b33d3). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/reporters/console.rs 44.66% 83 Missing ⚠️
src/repair/mod.rs 90.95% 19 Missing ⚠️
src/par2_files.rs 93.28% 10 Missing ⚠️
src/verify/config.rs 80.00% 7 Missing ⚠️
src/create/context.rs 16.66% 5 Missing ⚠️
src/repair/context.rs 86.48% 5 Missing ⚠️
src/repair/progress.rs 87.80% 5 Missing ⚠️
src/bin/par2repair.rs 77.77% 2 Missing ⚠️
src/packets/mod.rs 95.83% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main       #8   +/-   ##
=======================================
  Coverage        ?   92.89%           
=======================================
  Files           ?       72           
  Lines           ?    17781           
  Branches        ?        0           
=======================================
  Hits            ?    16517           
  Misses          ?     1264           
  Partials        ?        0           
Flag Coverage Δ
unittests 92.89% <84.19%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/bin/par2.rs 98.67% <100.00%> (ø)
src/bin/par2verify.rs 100.00% <100.00%> (ø)
src/create/backend.rs 91.09% <100.00%> (ø)
src/create/file_naming.rs 99.34% <100.00%> (ø)
src/par1/verify.rs 95.62% <100.00%> (ø)
src/reed_solomon/codec.rs 88.57% <100.00%> (ø)
src/repair/types.rs 100.00% <100.00%> (ø)
src/verify/global_engine.rs 98.39% <100.00%> (ø)
src/verify/mod.rs 96.49% <100.00%> (ø)
src/verify/types.rs 97.05% <100.00%> (ø)
... and 9 more

Impacted file tree graph

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds PAR2 creation support and aligns verify/repair behavior and output closer to par2cmdline-turbo, along with a large expansion of regression/integration coverage and benchmarking scripts.

Changes:

  • Implement PAR2 creation pipeline (config/builder, file planning, progress reporting, encoder plumbing) and wire a par2create CLI.
  • Update verify/repair parsing, output/reporters, purge behavior, and exit codes to better match par2cmdline-turbo.
  • Add/expand extensive tests, benchmarks, and helper scripts for create/verify/repair equivalence and regressions.

Reviewed changes

Copilot reviewed 67 out of 69 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/verification/test_global.rs New integration tests for global block table verification paths
tests/test_verify_types_comprehensive.rs Update verification type tests for new fields/output
tests/test_verify.rs Update verification tests for new block_sources field
tests/test_verification_equivalence.rs Extend config setup for new extra_files/base_path
tests/test_turbo_verify_repair_parity.rs New tests matching turbo behaviors for extra files & repair parity
tests/test_silent_verification_reporter.rs Update reporter tests for new block_sources field
tests/test_repair_types.rs Update repair type tests to use new domain newtypes
tests/test_repair_progress_comprehensive.rs Add coverage for new progress reporter methods
tests/test_repair_context.rs Update purge semantics tests to match turbo behavior
tests/test_repair_bugs.rs Fix slice size arithmetic with new BlockSize type
tests/test_packet_edges.rs Update edge tests for new domain newtypes
tests/test_multifile_repair_bug.rs Update formatting/math using BlockCount newtype
tests/test_mixed_recovery_sets.rs New integration test ensuring mixed sets are ignored via base-stem filtering
tests/test_file_verifier.rs Extend config construction for new fields
tests/test_console_verification_reporter.rs Update console reporter tests for new block_sources field
tests/debug_repair_issue.rs Update debug test code to use new newtypes
tests/create_hot_path_allocations.rs New allocation-scaling regression test for create hot path
src/verify/types.rs Add BlockSource tracking and adjust Display output
src/verify/mod.rs Export BlockSource, relax reporter generic to support trait objects
src/verify/config.rs Add extra_files and base_path CLI/config support
src/reporters/mod.rs Export new concise verification reporter
src/reporters/console.rs Add thread-safe console output + concise reporter mode
src/repair/types.rs Introduce exit_code() and migrate fields to newtypes
src/repair/slice_provider.rs Make error module public; factor IO error mapping into helpers
src/repair/progress.rs Add new progress events and refine quiet/format behavior
src/repair/error_helpers.rs New shared IO error mapping helpers (repair path)
src/repair/context.rs Rework purge logic to match turbo-style purge semantics
src/reed_solomon/mod.rs Export encoder module for creation
src/reed_solomon/codec.rs Add explicit SIMD init + controllable low-level progress output
src/par2_files.rs Prevent mixed recovery-set loading; add progress locking and ordering
src/packets/recovery_slice_packet.rs Remove stray println on MD5 verification failure
src/packets/mod.rs Add resync scanning and stronger recovery-packet validation path
src/lib.rs Export new create module
src/domain.rs Add newtype wrappers for sizes/counts used across create/repair
src/create/types.rs New creation config/types
src/create/source_file.rs New source-file metadata + checksum structs
src/create/progress.rs New create progress reporter traits/impls
src/create/mod.rs New create module entrypoints and exports
src/create/file_naming.rs New recovery volume planning and allocation logic
src/create/error_helpers.rs New shared IO error mapping helpers (create path)
src/create/error.rs New create error types
src/create/cli.rs New CLI parsing helpers for create redundancy/file expansion
src/create/builder.rs New CreateContextBuilder fluent API
src/checksum/md5_reader.rs New streaming MD5 reader wrapper
src/checksum.rs Export Md5Reader from checksum module
src/bin/par2verify.rs Rework verify CLI behavior for quiet/basepath/extra files/purge
src/bin/par2repair.rs Rework repair CLI behavior for quiet modes/purge/exit codes
src/bin/par2create.rs Implement par2create CLI using new creation module
src/args.rs Split verify args; add flags consistent with turbo-like interfaces
scripts/stress_test_create.sh New stress script for create reliability
scripts/debug_create.sh New debugging script for intermittent create failures
scripts/benchmark_create.sh New averaged benchmark script for create performance & validation
rust-analyzer.toml Add rust-analyzer config
flake.nix Add sccache/mold/linker env wiring for dev shell
docs/par2_parsing.md Remove outdated parsing doc
docs/BENCHMARK_RESULTS.md Add creation benchmark section + analysis
benches/create_benchmark.rs Add Criterion benches for create performance
README.md Document creation performance status and bottlenecks
Cargo.toml Add create benchmark; tweak dev/release profile settings

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/packets/mod.rs
Comment thread src/repair/context.rs Outdated
Comment thread src/create/file_naming.rs Outdated
@mjc mjc force-pushed the t3code/verify-repair-parity branch from 3c6d9c6 to 867504a Compare April 24, 2026 16:48
@mjc mjc requested a review from Copilot April 24, 2026 16:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 27 out of 27 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/repair/types.rs Outdated
Comment thread src/verify/global_engine.rs
Comment thread src/verify/global_engine.rs Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 29 out of 29 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/bin/par2verify.rs Outdated
Comment thread src/bin/par2.rs Outdated
Comment thread src/repair/mod.rs Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 29 out of 29 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/repair/mod.rs:430

  • When missing_slices.is_empty(), the current logic can classify a non-Present file as verified unless it has noncanonical block sources, which can lead to files_to_repair staying empty and returning NoRepairNeeded even though verification flagged the file as Corrupted/Missing. This can happen for canonical-offset corruption detectable only via full-file checks (e.g., size/hash mismatch with extra trailing data). Consider ensuring that a non-Present status with zero missing slices is either (a) revalidated with full-file criteria before treating as verified, or (b) scheduled for rewrite/repair based on the verification status, so repair does not incorrectly report "already intact".
            if missing_slices.is_empty() {
                if *status != FileStatus::Present
                    && self.has_noncanonical_block_sources(file_info, block_sources_map)
                {
                    debug!(
                        "File {} has all valid slices from noncanonical sources; rewriting",
                        file_info.file_name
                    );
                    files_to_repair.push((file_info, missing_slices));
                } else {
                    verified_files.push(file_info.file_name.clone());
                }
                continue;
            }

            debug!(
                "File {} needs {} missing slices repaired",
                file_info.file_name,
                missing_slices.len()
            );
            files_to_repair.push((file_info, missing_slices));
        }

        if files_to_repair.is_empty() {
            return Ok(RepairResult::NoRepairNeeded {
                files_verified: verified_files.len(),
                verified_files,
                message: "All files are already intact".to_string(),
            });

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/reporters/console.rs Outdated
@mjc mjc force-pushed the t3code/verify-repair-parity branch from ea3e30e to 42142b3 Compare April 24, 2026 18:50
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.

2 participants