TWO-PASS BCH: SILENT FAILURES ARE DEAD, BUT DON'T EXPECT MIRACLES

muse.ai looks a two-pass system to reduce silent errors in BCH up to the theoretical information limts.

TWO-PASS BCH: SILENT FAILURES ARE DEAD, BUT DON'T EXPECT MIRACLES
Two-Pass BCH A Method of Handling them.

Two-pass BCH: silent failures are dead — but don't expect miracles

We just shipped a two-pass BCH decoder in lzply. The headline is honest, and it's two-sided: silent failures are now impossible by construction — but the second pass recovers 0% of random errors beyond t. That zero is a measured result, not a bug, and it comes from an information-theoretic limit. Here's what we built, what it proves, and what it doesn't.

UPDATE — Dec 2, 2026: the limit described below was real for the two-pass decoder — but it is no longer the end of the story. We shipped lzply_deep_repair, a Chase/list decoder that does recover past-t errors, and a CRC16 migration (LZPL v5) that makes candidate verification cheap. The measured numbers are at the bottom of this article; the original text below is unchanged, because it is still exactly true of the two-pass decoder itself.

What a silent failure is

A BCH code with correction capability t can fix up to t bit errors in a block. If a block picks up more than t errors, two things can happen:

  • Loud failure (good): the decoder realizes it can't fix the block and returns an error. You know the data is damaged.
  • Silent failure (bad): the decoder "miscorrects" — the corrupted block happens to sit within t errors of a different valid codeword, so the decoder "fixes" it into that wrong codeword and returns it as if it succeeded. The output is wrong, but nothing flags it.

That miscorrection is the silent failure. It's rare, but when it happens it's dangerous because nothing tells you the data is wrong.

Why lzply was already safe — and what we added

lzply never relied on BCH alone. Every entry stores a SHA-256 hash of the original data. After BCH decode, lzply hashes the decoded output and compares it to the stored hash. A miscorrection produces wrong bytes, so the hash mismatches and lzply returns an error instead of bad data. The miscorrection becomes a loud failure. That's why the earlier verification found 0 silent wrong outputs across 40,800 trials — the hash was already catching them.

What we just added is a second pass. The idea: if pass 1 fails the hash, don't give up immediately. Try alternative corrections and eliminate the wrong ones.

How the two-pass decoder works

Pass 1 — the fast path. Run the standard BCH decode (Berlekamp-Massey + Chien search), then the SHA-256 check. If the hash passes, return the data immediately. This is the common case, and it costs nothing extra — one decode, one hash, done.

Pass 2 — the elimination pass, only when pass 1 fails. A failed hash means the decoder miscorrected or couldn't correct. Now the decoder tries alternative corrections: it reconstructs candidate error patterns from the syndrome (residual Berlekamp-Massey) and tries a bounded set of flip-and-redecode candidates around the positions pass 1 found. Each candidate is BCH-decoded and hash-checked. The first candidate whose hash passes is returned. If none passes, it returns an error — loud failure, never wrong data.

The bound is small: at most 16 candidates. Pass 2 only runs on failure, so the common case stays fast.

The guarantee is structural: no data is ever returned unless it passes SHA-256, in either pass. A silent failure is impossible by construction.

The honest measured result: 0% recovery of random beyond-t errors

Here is where we have to be blunt. We tested pass 2 on random errors beyond t:

  • t=8, 9 errors (t+1): 0/100 recovered, 100 loud failures, 0 silent.
  • t=8, 10 errors (t+2): 0/100 recovered, 100 loud failures, 0 silent.
  • t=16, 17 errors (t+1): 0/200 recovered, 200 loud failures, 0 silent.
  • t=16, 18 errors (t+2): 0/200 recovered, 200 loud failures, 0 silent.
  • Bursts of 9, 12, and 16 bits: 0/50 recovered, 0 silent.
  • 900 trials total: 0 recovered, 900 loud failures, 0 silent wrong outputs.

Pass 2 guarantees zero silent failures — proven across 900 trials plus the full unit test (7,813 checks, 0 fails). But it recovers none of the random beyond-t errors. That zero is not a bug in the implementation. It's a limit.

Why recovery is 0% — the information-theoretic limit

A debug experiment proved the mechanism works if a true error position is known: flipping any single true error position (9 out of 9) and then running the standard decode recovers the data. The problem is purely locating one.

Measured: for random errors beyond t, the error positions returned by Berlekamp-Massey have 0 overlap with the true error positions (0 out of 200 trials; 84 positions found, 0 true). When there are more than t errors, the locator polynomial Berlekamp-Massey returns is spurious — it points at the wrong places.

The reason is fundamental: a binary BCH code with 2t syndromes cannot determine t+1 error positions. In characteristic 2, the even syndromes are redundant (Frobenius), so Newton's identities can't recover a degree-(t+1) locator polynomial from 2t syndromes. The information to locate that extra error simply isn't in the syndrome. No bounded search over the wrong positions can find it.

What this means in practice

The two-pass decoder is a real improvement, but you should understand exactly what it buys:

  • It eliminates silent failures. That's proven, and it matters — you will never get wrong data back silently. Every failure is loud.
  • It does not recover random errors beyond t. If a block has t+1 or more random errors, pass 2 will try its candidates, none will pass the hash, and you'll get a loud failure. The data is lost, but you know it's lost.
  • Pass 1 already fails loudly rather than miscorrecting in these trials. The hash gate is the backstop for the rarer miscorrection case.

If you need actual recovery of beyond-t errors, the options are: soft/reliability information (not available for plain file data), a stronger code (more parity, higher t), or list decoding (Chase / Guruswami-Sudan — complex and much slower). The two-pass decoder as built does not do those. It guarantees you will never be lied to silently, and that's what it was built to do.

UPDATE — Dec 2, 2026: deep repair recovers past-t errors after all

The limit above was about locating the extra error. Berlekamp-Massey can't find it, so pass 2 had nothing to try. The fix is to stop asking the decoder where the error is and try flips instead. That is Chase decoding, and it turns the 0% into real recovery.

The key fact is a theorem, not a heuristic. For a block with t+1 errors, flipping any single true error position leaves exactly t errors — and t errors are exactly what the standard decoder fixes. So a scan that tries every bit position as a flip is guaranteed to hit a true error position and recover the block. Chase-1 recovers t+1 errors by construction. The price is time: a full scan of a 524 KiB block is 4.19 million trials, about 471 seconds at ~8,900 trials/s. The tool reports per-level timing — when the repair landed and how long each level took — because at these sizes the answer to "can it be fixed" is really "how long are you willing to wait".

The tool is lzply_deep_repair, and it works in escalating levels:

  • L0 — standard decode to t. The fast path. 10/10 at t errors and below, in milliseconds.
  • L1 — Chase-1. Single-bit flips, suspects first, then a full scan. Recovers t+1 by the theorem above.
  • L2 — Chase-2. Pairs of flips. Bounded: 128 first elements, 64 candidates per block. A lottery that gets worse with block size.
  • L3 — two-block combine. Two failing blocks varied at once from the candidates L1/L2 retained. Bounded: 256 blob tries, 120 s default budget per entry.

Every beyond-t candidate is verified before acceptance — first against a new CRC16, then against SHA-256. The CRC16 is the migration that makes this practical: CRC-16/CCITT-FALSE (poly 0x1021, init 0xFFFF) of the compressed blob, one per entry, stored in the LZRS v1 header field that was reserved for exactly this, and in a new field in the LZPL header (LZPL v4 → v5, header 78 → 80 bytes). A candidate that fails the CRC is rejected without the cost of decompression. Expected residual false-accept is ~2^-16 per candidate at the CRC stage, and the SHA-256 stage gates acceptance after that. Measured across the corruption matrix: 1,162 candidates CRC-checked, 1,024 rejected by CRC, 0 false accepts.

Old archives without a valid CRC16 are rejected cleanly with a message telling you to re-create them — never misdecoded.

The measured corruption matrix (hot_newyork, tests/run_deep_repair_tests.sh, 47 checks, 0 failures):

FileErrorsRecoveredLevelMean time
512 B, t=88 (= t)10/10L00.00 s
512 B, t=89 (= t+1)10/10L10.04 s
512 B, t=810 (= t+2)3/10L24.4 s
512 B, t=811–120/10—4.4 s
512 B, t=45 (= t+1)10/10L10.04 s
512 B, t=46–80/5—1.0–1.3 s
2 KiB, t=89 (= t+1)5/5L10.17 s
2 KiB, t=810 (= t+2)0/5—20.8 s
600 KiB, pinned poly9 in one block2/2L10.13 s
600 KiB, pinned poly9+9 in two blocks2/2L316.7 s
512 B burst1 byte (8 bits)3/3L00.00 s
512 B burst2 bytes (16 bits)0/3—4.3 s
lz_rs -r 0, 512 B93/3L10.04 s
lz_rs -r 2, 512 B93/3L00.00 s

Two honest limits. First, L2 is a lottery that degrades with block size: 30% on 512-byte blocks at t+2, 0% on 2 KiB blocks. Second, time: a full Chase-1 scan of a 524 KiB block takes ~471 s, because the tool has to scan before it can try candidates — it has no oracle at the scan stage. Pinning a small polynomial (lzply -c poly=001a) makes the same 600 KiB file recover in 0.13 s, because the blocks are 1,010 bytes instead of 524,265. And L3 only works when L1/L2 retained per-block candidates — on large blocks the pools stay empty because the scans never finish in budget.

The measurements caught two bugs worth naming, because they are the kind of thing that only shows up when you measure. First, the trial flip wasn't being applied inside the chase trial — Chase-1 recovered 0/20 at t+1 until the flip was actually flipped. Second, the level-1 pool was truncating the candidate list before the genuine candidate arrived late in scan order — a 600 KiB file with 9 errors failed at a 60 s budget until candidates were tried directly in scan order. Both are fixed in commit b27b345; the details are in docs/deep-repair.md.

Cross-server verification on hot_chicago is in progress; the full numbers will appear in the hotconfig write-up.

Try it

The code is in lzply on GitHub (github.com/cnmcdee/lzply), commit b27b345 — "CRC16 migration (LZPL v5) + lzply_deep_repair past-t repair". The unit test now has phases 6 and 8 — two-pass silent repair and the Chase theorems — and the full BCH suite is 7,975 checks, 0 fails; the CRC16 vectors are a separate 530-check test, also 0 fails. Pass 1 is untouched (the diff to bch_decode_block is zero lines), so the fast path is exactly as fast as before. The deep-repair design, bounds and measured matrix are in docs/deep-repair.md; the test suite is tests/run_deep_repair_tests.sh (47 passed, 0 failed).

Linux Rocks Every Day