# ECC operation order: a reproducible counterexample

An error-correcting code protects a representation, not an arbitrary computation.
A bitwise operation on encoded operands need not produce a valid encoding of
the intended result. This executable mathematical illustration connects the
ParaBit and Flash-Cosmos discussion to a small example that can be checked by hand.

## Result

For the specified systematic Hamming(7,4) decoder, fault-free AND returns a wrong
payload after decoding in 96 of 256 ordered input pairs. Before that decoding,
all 256 systematic payloads are correct. The specified extended Hamming(8,4)
decoder instead rejects 168 pairs and returns the other 88 correctly.
Rejection and an accepted wrong answer are different outcomes.

XOR preserves these linear encodings, but input error masks combine. One
correctable flipped bit in each operand becomes two errors when positions differ,
or cancels when they coincide. Decoding the operands first succeeds for every
event in this bounded model. That is not an end-to-end hardware guarantee.

## Run offline

Python 3.10+; standard library only. Extract the ZIP, enter its directory, then:

```sh
python3 -B verify.py
python3 -B -m unittest test_model.py test_verify.py
python3 -B -O -m unittest test_model.py test_verify.py
```

The verifier checks the exact file inventory, manifest schema and hashes before
running the mathematics. Hashes detect changes relative to the manifest, not
authorship or malicious replacement of both code and manifest.
The full table is RESULTS.md; machine-readable results are in results.json.

## Layout and decoder

Code positions are numbered from 1; integer bit 0 stores position 1.
The four payload bits, least significant first, occupy positions 3, 5, 6, 7.
Even-parity positions 1, 2, 4 cover positions whose binary index has that bit set.
Position 8, when present, adds overall even parity.

The seven-bit decoder flips the position named by a nonzero syndrome.
The eight-bit decoder rejects a nonzero syndrome with even total parity;
with odd parity it corrects the syndrome-named position, or position 8 for
a zero syndrome. Otherwise it passes the word unchanged.

For Hamming(7,4), payload 1 encodes as 0000111 and payload 8 as 1001011.
Strings put position 7 on the left. Their AND is 0000011, with correct raw
payload 0. Its syndrome is 1 XOR 2 = 3. The decoder flips position 3 and returns
payload 1, although 1 AND 8 = 0. There was no medium error.

## Method and denominators

The model enumerates every ordered pair of four-bit payloads, three operators
(AND, OR, XOR), two code lengths and four fault regimes: no flipped bits,
one on the left, one on the right, and one on each operand.
For code length n their populations per operator are 256, 256n, 256n and 256n^2.
There are 111,360 events in 24 strata. These are exhaustive finite populations,
not samples of physical failures; a statistical confidence interval is inapplicable.

For XOR with one fault per operand, n same-position pairs cancel and n(n-1)
distinct-position pairs produce two errors. This gives 10,752 accepted wrong
outputs out of 12,544 events for seven bits; eight bits reject 14,336 out of
16,384. Independent parity-check codebooks and nearest-codeword decoding
cross-check the implementation for every received word.

## Relation to research

ParaBit applies ECC during operand relocation, while later sensing remains a
separate exposure. Flash-Cosmos section 3.2 identifies the incompatibility of
ordinary ECC with arbitrary AND/OR on stored representations, then addresses
raw-error exposure through enhanced programming. These papers study different
physical mechanisms; the small codes here are an illustration, not their
implementation or a reproduction of their hardware results.

Primary references and inspected-section provenance are in SOURCES.json.
Its CrossBit entry is explicitly provisional and is not evidence for any result
in this packet. Original papers and figures are not redistributed.

## Limits

Ideal Boolean logic, fixed bit layout and at most one injected fault per operand.
No NAND measurements, fault correlations, wear, read disturb, encryption,
randomization, address errors, later logic faults or performance model.
The results do not establish a commercial SSD defect, a new coding theorem,
all-code AND/OR impossibility, or an NVMe feature requirement.

Original mathematical source: Hesela research commit
efe23211e8cd04f718c47545106121bda1f75aaa, 18 November 2026.
The model, model tests, result JSON and generated table are unchanged.
