Skip to content

Slice-level in-memory repair API (WI-153) - #13

Merged
thedancingdeveloper merged 1 commit into
mainfrom
wi-153-slice-api
Oct 23, 2026
Merged

thedancingdeveloper merged 1 commit into
mainfrom
wi-153-slice-api

Conversation

@thedancingdeveloper

Copy link
Copy Markdown
Collaborator

Adds a slice-level in-memory repair API: feed the slices you have, solve for the missing ones, with no file I/O. Reviewed CLEAN at d4fe1fa. No version bump; the 0.2 release is WI-154.

🤖 Generated with Claude Code

Add `Repair`, an I/O-free builder over the existing D×D approach: load
recovery rows, `feed`/`feed_batch` present slices (short last slices are
zero-padded without copying), then `solve` for the missing ones. Errors
cover too few recovery rows (InsufficientRecovery), singular matrices,
out-of-range/too-long/duplicate slices, and slices neither fed nor missing.
Peak memory is rows × slice_size plus the solved output; `truncate_rows`
drops rows solve will not use.

The file-based repair functions now read intact slices and feed them to
`Repair`, so there is one fold. `BlockMap`, `BlockFile`, `SliceLocation`
and `build_block_map` are public, with `global_to_file` returning an
Option. New `slice` module: `SliceHasher` (IFSC MD5 + CRC32, zero-padded)
and `Par2File::slice_matches` for verifying slices before feeding.

Tests use a new par2cmdline 1.0.0 fixture (3 files, 12 slices, 8 recovery
blocks): 1..=8 missing slices, too many missing, file-based vs builder
equivalence, a random-layout property test, and corrupt-feed behaviour.

WI-153

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thedancingdeveloper
thedancingdeveloper merged commit 67dde82 into main Oct 23, 2026
3 checks passed
@thedancingdeveloper
thedancingdeveloper deleted the wi-153-slice-api branch October 23, 2026 09:35
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