Reed-Solomon on Top of Two-Pass BCH: Archives That Survive Byte Errors, Deep Repair That Hunts Past the Limit — and the Honest Gaps

This research was conducted and done by AI and is quickly eclipsing the ability of humans.

That is the disclaimer, up front, in the exact words it was given — because what follows was not hand-built by a human engineer iterating in an editor. It was researched, implemented, measured, and broken and fixed by AI, across two servers, and the numbers below are the receipts. This article documents the completed lz/rs work: Reed-Solomon layered on top of lzply's two-pass BCH, a deep-repair tool that hunts for data past the theoretical correction limit, and a CRC16 migration that changes the archive format. Every number here was measured on hot_newyork on December 2, 2026. Where verification is incomplete, this article says so plainly instead of letting a hot_newyork-only number wear a cross-server badge it did not earn.

The idea in one paragraph

lzply already compresses with lzip and protects the stream with two-pass BCH plus a SHA-256 oracle. BCH is superb at scattered bit errors and useless at byte and burst errors — flip a whole byte and the bit-error machinery is fighting the wrong enemy. The new work adds Reed-Solomon on top: RS(255,255-p) over GF(28) handles byte and burst errors, BCH stays responsible for scattered bit errors, and SHA-256 remains the final oracle that decides whether anything recovered is actually right. On top of that, a new tool, lzply_deep_repair, goes looking for data that is past BCH's correction limit — bounded search, not magic — and a CRC16 per entry gives the search a fast oracle so it does not have to decompress and hash every candidate.

lz_rs: Reed-Solomon archives

Commit 679d1a194f98bcb13bb1a5827c6deabd851a631c (parent 8dbb8d03). The RS implementation is self-contained — no external RS library. RS(255,255-p) over GF(28), primitive polynomial 0x11D, primitive element α=2, systematic encoding, Berlekamp-Massey plus Chien search plus Forney decode, with a syndrome re-check after decoding.

The -r levels set the parity symbols per 255-byte block, and therefore the correctable byte errors per block:

LevelParity symbols / blockCorrectable byte errors / block
-r 000
-r 184
-r 2 (default)168
-r 32412
-r 43216

The LZRS v1 format has a 16-byte global header (magic LZRS, version 1) and an 82-byte entry header. Format discipline was verified, not assumed: lz_rs rejects LZPL archives and lzply rejects LZRS archives. And at -r 0 the stored bytes are byte-identical to lzply -e 0 — the RS layer at zero parity is a no-op, exactly as it should be.

Measured cost of the parity

Benchmarks on a mixed set — 2,387,757 bytes in, 13 entries:

LevelArchive bytesCompressExtract
r01,065,039772 ms92 ms
r11,099,551754 ms143 ms
r21,136,367811 ms191 ms
r31,175,727819 ms252 ms
r41,217,903872 ms307 ms

On a random 1 MiB incompressible file: r0 1,048,752 bytes → r4 1,199,248 bytes — roughly 3.2–3.9% per level, r4 about +14.3% over r0. Compress time barely moves; extract time roughly triples from r0 to r4, because decoding is where the work is. That is the honest price of 16 correctable byte errors per block: about a seventh more space, about three times the extraction time.

Test suites for lz_rs

rs_test: 6,243 checks, 0 failures. tests/run_rs_tests.sh: 59 passed, 0 failed (61/0 after the CRC16 migration below). bch_test passes. run_hyper_tests.sh: 56/0.

Deep repair + CRC16 migration

Commit b27b3455c1f040f998ae00461938ee0c17e5fe4f. Two things landed together, because the second exists to make the first fast enough to matter.

CRC-16/CCITT-FALSE per entry

Polynomial 0x1021, init 0xFFFF, refin/refout false, xorout 0x0000. Check values verified against the standard vectors: "123456789" → 0x29B1, "" → 0xFFFF, "A" → 0xB915. One CRC is stored per entry, computed over the blob — the compressed stream before BCH/RS parity is applied. The LZRS v1 reserved crc16 field is now filled; LZPL moves v4 → v5, with the entry header growing 78 → 80 bytes. Old files are rejected cleanly with a clear message, never misdecoded. SHA-256 remains the final oracle; CRC16 is the fast gate in front of it.

lzply_deep_repair

lzply_deep_repair [-l 0..3] [--time-budget s] [-v] works in levels. L0 is standard decode up to t. L1 is Chase-1 single-bit flips — recovering t+1 errors this way is a theorem, not a hope. L2 is Chase-2 pairs. L3 combines two blocks. The bounds are explicit: 64 Chase-1 candidates, 128 first elements, 256 blob tries, 120 s default budget per entry, 128 MiB pool. Every level reports its own timing — “time of arrival”: which level landed the recovery and how many seconds each level took. CRC16 is the oracle for the search: every beyond-t candidate is CRC-checked before decompression and SHA-256. Residual false-accept is about 2-16 per candidate at the CRC stage — and the SHA-256 check behind it makes a false accept reaching the user effectively impossible.

The corruption matrix — the numbers that matter

tests/run_deep_repair_tests.sh: 47 passed, 0 failed. Each cell is ten trials unless stated otherwise.

CaseResult
512 B, t=8: 0 / 4 / 8 errors10/10 at L0 (0.00 s)
512 B, t=8: 9 errors10/10 at L1 (0.04 s)
512 B, t=8: 10 errors3/10 at L2 (4.4 s)
512 B, t=8: 11–12 errors0/10
512 B, t=4: 5 errors10/10 at L1
512 B, t=4: 6–8 errors0/5
2 KiB, t=8: 9 errors5/5 at L1 (0.17 s)
2 KiB, t=8: 10 errors0/5 (20.8 s)
600 KiB: 9 errors in one block2/2 at L1 (0.13 s)
600 KiB: 9+9 errors in two blocks2/2 at L3 (16.7 s)
1-byte burst3/3 at L0
2-byte burst0/3 — not recovered

Read the shape of that table, not just the wins. One error past the limit: recovered, fast, every time. Two past the limit: sometimes, slowly. Three past the limit: not at all. An unpinned m=22 full Chase-1 scan measured about 471 seconds — 4.19 million trials at roughly 8,900 per second. Past-t repair is bounded search, not magic, and the bounds bite hard as files grow: the 2 KiB case spent 20.8 seconds finding nothing at 10 errors.

Clean round-trips are bit-identical at every level across empty, one-byte, 512 B, 2 KiB, text, 600 KiB and 1 MiB files, with lzply -e 0/4/7 and lz_rs -r 0/2/4.

False accepts: measured, not asserted

1,162 candidates were CRC-checked during the measurement runs. 1,024 were rejected by CRC. Zero false accepts. The oracle works as designed.

Two bugs found by measurement, fixed

The matrix earned its keep twice. First, a trial flip was not applied inside chase_trial — Chase-1 went from 0/20 to 20/20 at t+1 once the flip actually happened. Second, L1 pooled candidates before trying them, and the pool cap truncated the list — switching to direct-try in scan order fixed the 600 KiB 9-error case. Both bugs were invisible to the unit suites and obvious to the corruption matrix. That is why the matrix exists.

Full suite results after the migration

bch_test 7,975 checks, 0 fails. rs_test 6,243/0. crc16_test 530/0. run_rs_tests.sh 61/0. run_tests.sh 149/0 in /tmp — and 146/3 under /opt, where the 3 failures are the known pre-existing FUSE mount failures, proved pre-existing. run_deep_repair_tests.sh 47/0. run_hyper_tests.sh 56/0.

The verification gap — stated openly

Not everything verified. The hot_chicago cross-server check is partial: the baseline (8dbb8d03) went GREEN there (202 PASS, 0 FAIL), the lz_rs build went GREEN there, and a partial suite passed there (bch_test 7,813/0, rs_test 6,243/0, run_rs_tests 59/0). But the full-suite exit, the corruption matrix, and the benchmarks against plain lzply were not run on hot_chicago, because the box went unresponsive mid-run at about 10:27 UTC on December 2 — sshd never sends a banner, and a restart was approved but there is no live path in to perform it. Snapshot zips exist on hot_newyork; the hot_chicago copies are queued for the retry prober. Every number in this article is a hot_newyork number until that verification completes, and this article will be updated when it does.

Where to read more

The full write-ups live on lzply.com: the two-pass BCH article, updated with the deep-repair levels, the CRC16 migration, and the corruption matrix — Two-Pass BCH: Silent Failures Are Dead, But Don't Expect Miracles — and the lz_rs article — lz_rs: Reed-Solomon Archives, RS(255,223), r Levels, and Measured Numbers.

The bottom line: BCH for scattered bits, Reed-Solomon for bytes and bursts, CRC16 as the fast oracle, SHA-256 as the final word, and a repair tool that honestly tells you when the data is past saving. The cost is about 14% more space and three times the extraction time at the top parity level. The limit is two errors past t, sometimes — and a 2-byte burst still wins. Measured, committed, and pushed: 679d1a19 and b27b3455.

Linux Rocks Every Day