# SQLite serialization: a valid image is not a commit receipt

Research packet, 3 November 2026. Synthetic native API experiment plus primary-source
synthesis. This is not a newly discovered SQLite defect or an application incident.

## Result

On the two tested builds, `sqlite3_serialize` captured the calling connection's
uncommitted writes. After the source transaction was rolled back, a detached
copy still returned those values and passed `PRAGMA integrity_check`.
The copy was structurally readable, but it was not a copy of committed source
history. A fresh independent reader and a completed backup through that reader
retained only committed data.

There is a separate destination issue: all nine WAL-header images in each
capture returned success from `sqlite3_deserialize`, then failed the first
query with `SQLITE_CANTOPEN`. The documented two-byte header conversion enabled
queries. It did not make uncommitted data committed, refresh a retained reader,
or recover omitted WAL content.

## What is here

- `REPORT.md`: bounded conclusions, mechanism, limitations and connection to existing Hesela research.
- `publication.md`: concise insertion proposed for the existing backup analysis, not a new article.
- `observe.py`: standard-library Python/ctypes driver calling the native SQLite C API directly.
- `observations-{system,upstream}-{a,b}.json`: four original captures, 16 images and three restore paths each.
- `image-replay-*.json` and `images/`: two additional matching replays and 32 retained 8 KiB input images.
- `sources.json`, `source-pins.json`, `sources/`: retrieval receipts and retained public-domain upstream implementation.
- `test_observe.py`: fixed value oracles, native replay, detached recovery and deliberately wrong-evidence controls.
- `validate.py`, `validation.json`: repeatable test matrix and captured test output.
- `summarize.py`, `summary.json`, `results.md`: generated observations for human/machine reuse.
- `SHA256SUMS`: content hashes, not a claim of trusted origin or committed provenance.

## Reproduce

From this directory, on Linux with Python 3 and a shared SQLite library exposing
serialize/deserialize and txn_state:

```sh
python3 observe.py --output /tmp/hesela-serialize.json
python3 -m unittest -v test_observe.py
python3 -O -m unittest -v test_observe.py
python3 observe.py --library /absolute/path/to/libsqlite3.so --output /tmp/hesela-serialize-other.json
```

Use `HESELA_SQLITE_LIBRARY=/absolute/path/to/libsqlite3.so` for the test suite's
native replay on an alternate build. The four recorded results stay frozen.
If the library has an unrecorded source ID, fixed semantic tests still run but
the exact-build replay test explicitly skips. Required symbols must exist;
missing functionality is a failure, not an invented result.

The fixture uses one two-column table, explicit transaction order, 4096-byte
pages, private caches, no auto-checkpoint, and disabled writer cache spilling.
No timing assumptions or concurrent threads are needed. It touches only its
temporary directory, never a supplied production database. `--images-dir`
may retain copies in a newly created directory; it refuses an existing directory.

A Python sqlite3-wrapper attempt with the existing alternate library failed
because that library omits extension loading. The final experiment avoids that
binding incompatibility by invoking the C API with ctypes. Both tested native
libraries and their compile options/source IDs are recorded; they are different
build configurations, not a controlled estimate of a version effect.

## Reuse boundaries

The original input images are synthetic and intentionally include data that
was never committed. They are test fixtures, not example production backups.
Do not apply the header conversion to a live database or treat it as WAL repair.
This packet has no destructive database command, cloud dependency, new package
installation, site deployment or independent external replication.

Raw rows and image byte hashes replay exactly within each recorded build.
Cross-build logical results agree; byte hashes differ. Header bytes 96-99
record the SQLite library version and are distinct from mode bytes 18-19.
