# Witcher: equal observed text is not necessarily equal bytes

A UTF-8 probe of Witcher's pinned output comparator accepted two deliberately
byte-different outputs: one with an invalid byte and one using CRLF line endings.
This is a measured property of two isolated methods, not a newly confirmed bug
in a persistent-memory application or a reproduction of the SOSP evaluation.

## What Witcher tests

[Witcher (SOSP 2021)](https://doi.org/10.1145/3477132.3483556) combines
dependency-guided crash-state selection with output-equivalence checking.
Its deterministic test continuation must expose a failure for the comparison
to detect it. State selection and observation are separate coverage limits.

[Read the corpus definition](https://hesela.dev/terms/witcher/) and the
[broader oracle analysis](https://hesela.com/analyses/crash-testing-oracles-and-bounds/).

## Pinned source and method

Source commit: ad69038cdcd4ac20f1bde38ebf7e6d9fd6999b36.

Reviewed file:
[witchercrashvalidator.py](https://github.com/cosmoss-jigu/witcher/blob/ad69038cdcd4ac20f1bde38ebf7e6d9fd6999b36/replay/engines/witcher/witchercrashvalidator.py).

SHA-256: db0df95e7f24ec37d3fe6dd9efa524f2e1c64fb7b3a8bcce300e56f424eb2e3a.

The probe verifies the complete downloaded file's hash, parses it with Python's
AST parser, and compiles only the unchanged compare_to_oracles and
compare_to_oracle_from_index methods. It does not import the artifact package,
run its constructor, invoke subprocesses or construct a PMDK image.

Each case supplies a synthetic crash-output file and two oracle files.
The interrupted operation has index 1. The committed oracle includes that
operation; the rollback oracle omits it. Accordingly, the source compares
suffixes starting at line indices 2 and 1. Two output lines represent an
all-or-nothing two-field change. These fixtures are observations, not simulated
cache lines or evidence of which crash states real hardware can reach.

## Observations

| Fixture | Source reports inconsistent | Byte-identical to an allowed suffix |
| --- | --- | --- |
| Complete committed result | No | Yes |
| Complete rollback result | No | Yes |
| One line from each alternative | Yes | No |
| Older value | Yes | No |
| Truncated output | Yes | No |
| Additional output | Yes | No |
| Invalid UTF-8 byte before committed output | No | No |
| CRLF output against LF oracle | No | No |
| Changed timestamp-like field | Yes | No |
| Empty output and empty oracle suffixes | No | Yes |

The raw input bytes, individual verdicts, environment and source identity are
in [results.json](results.json). The ten cases are a deliberate contract test
matrix, not a sampled population or an estimated error rate.

Both methods read with errors='ignore'; the text reader also normalizes
newlines. Under the recorded UTF-8 environment, byte 0xff disappears and CRLF
becomes LF. The complete decoded suffix must match one oracle: the mixed
fixture is correctly rejected. A matching empty observation establishes
nothing about unobserved stored data. A timestamp-like difference is rejected,
which illustrates why the selected observation must be deterministic.

## Interpretation and limits

The result does not establish that real Witcher drivers emit malformed UTF-8,
that an evaluated bug was missed, or that the published results are invalid.
An ASCII-only output contract can make the invalid-byte fixture unreachable.
Line-ending normalization may also be intentional.

For a binary-value test adapter, first decide whether its contract concerns
bytes or decoded text. If byte identity matters, compare bytes or use an
injective encoding such as hexadecimal with strict validation. Do not silently
discard malformed input. Keep the whole-transcript choice of an allowed
outcome; accepting each line from a different oracle would admit a torn result.
These are recommendations derived from the observed comparison boundary, not
changes to the upstream project.

The [artifact README](https://github.com/cosmoss-jigu/witcher/blob/ad69038cdcd4ac20f1bde38ebf7e6d9fd6999b36/README.md)
describes a selected workload subset, an image over 70 GB and potentially more
than ten hours of execution. That workflow was not run. LLVM instrumentation,
dependency inference, crash-image feasibility, thread scheduling, recovery,
server workloads and hardware persistence remain outside this probe.

## Reproduce

Python 3.12.3 and UTF-8 were used for the retained result. Only Python's standard
library is required. Download [probe.py](probe.py) and [test_probe.py](test_probe.py)
into the same directory, then:

```sh
curl -fL https://raw.githubusercontent.com/cosmoss-jigu/witcher/ad69038cdcd4ac20f1bde38ebf7e6d9fd6999b36/replay/engines/witcher/witchercrashvalidator.py -o upstream.py
PYTHONUTF8=1 python3 -B probe.py --source upstream.py --output results.json
PYTHONUTF8=1 WITCHER_SOURCE=upstream.py python3 -B -m unittest -v test_probe.py
```

Eight regression tests cover both alternatives, suffix alignment, whole-output
matching, length/value failures, lossy text observation, empty observations,
nondeterminism and refusal of a modified source file. Missing WITCHER_SOURCE
skips native-method tests; a skipped run is not a reproduction.
