# HDF5: unchanged chunks, changed strings

Original code and observations: CC0-1.0. Libraries and linked sources retain their licenses.
This is a controlled synthetic native-library experiment, not a new vulnerability,
a field failure rate, a power-loss test or a reproduction of a published paper.

## Reproduce
Use an isolated Python 3.12 environment with requirements.txt. Run without -O:
```sh
PYTHONDONTWRITEBYTECODE=1 python test_observe.py
PYTHONDONTWRITEBYTECODE=1 python observe.py --output replay.json
```
The runner refuses an existing output path. Compare replay rows, creationProbe,
environment and sourceSha256 with observations.json; generatedAt is actual run time.
Package pins do not fix every platform's HDF5/zlib build. A differing outcome must be
investigated, not relabelled as agreement. No production paths are accepted: all
HDF5 images are created and mutated in memory, only the requested JSON is written.

## Design and expected result
Three independently specified ASCII records in one complete chunk; target index 1.
Four representations: variable-length strings with gzip level 6 or no filter,
and fixed-width strings with Fletcher32 or no filter. Fixed width is the maximum
input byte length, so these fixtures contain no truncation.
Nine cases x three repeats = 27 observations; repeats are not independent samples.
The separate ordinary fletcher32=True creation probe rejects VLEN strings on this
build. No Fletcher32-protected VLEN dataset is claimed, and no fallback is installed.

For heap cases, a restricted parser follows the target's 16-byte descriptor to its
global-heap collection and object index. It checks GCOL/version, 8-byte address and
length fields, bounds, original object bytes, and separation from the raw chunk.
It is not a general HDF5 parser. One payload bit is changed in a closed file image.
A fresh file open reads all three strings with default h5py policy.
For the compressed-chunk control, the changed bit is in the zlib trailer, not a
heap pointer. Fixed-width controls change the first payload byte of record 1.

All intact controls return the expected bytes. Both heap mutations return exactly
the independently predicted changed string, with all raw chunk bytes unchanged.
The fixed unfiltered control also returns changed data. Compressed-chunk trailer
damage and fixed-width Fletcher32 payload damage raise read errors.
All populated chunks have filter mask zero; that fact does not extend filter
coverage to referenced heaps. The VLEN gzip pipeline contains deflate, not Fletcher32.

## Evidence and acceptance
Each row retains before/after whole-image and raw-chunk SHA-256, filter IDs/mask,
mutation offset, XOR mask, exact changed-byte count, heap location and returned
record hex or error. The independent record digest frames each value with an
8-byte little-endian length. Controls never learn their expected values from a
read of the mutated file. Fresh readers avoid the separate cache-history issue.

A whole-file digest compared with a trusted pre-mutation value detects all these
byte mutations. A raw-chunk digest alone misses both heap mutations. An independently
preserved content manifest also rejects returned altered records. These statements
do not prove authenticity, freshness, metadata completeness or repair.
Use suitable full-file verification for immutable archives, or define application
record identity, framing and transaction semantics for content manifests.
Do not infer that every HDF5 datatype, filter, VOL connector or future version has
the same behavior. The tests cover h5py 3.15.0 / HDF5 1.14.6 and the native format.
