# Reproduce the bounded 3R comparison

This bundle rebuilds **readout aggregation only**: it does not implement the complete prior audit or the fly neural model. Both programs read the same 24 saved Parquet spike tables and corresponding JSON readouts, then write deterministic TSV. `evidence/python-reference.tsv` and `evidence/rust-native.tsv` are the two saved outputs; their SHA-256 values match. The `manifest.json` hashes the public files. The benchmark JSON is a public copy whose original absolute runtime paths have been removed; the private original remains preserved.

## Inputs

Create a fresh `RUNS_ROOT` and reconstruct these directories from the linked public bundles. For each input in `evidence/2026-10-31_input_manifest.tsv`, copy the named Parquet file into the appropriate `results-v01/` directory and verify its SHA-256. Copy its corresponding `<seed>-<pattern>_<side>.json` readout alongside it. Also copy `protocol.json` into the reverse-assignment run directory; the input manifest records its hash.

- `2026-10-29/paired-hemisphere-v01/results-v01/`: [previous matched-hemisphere bundle](https://dropkit-contents.pages.dev/research/fly-paired-hemisphere-v01/manifest.json), under `results-v01/`.
- `2026-10-30/paired-selection-reverse-assignment-v01/`: [previous selection bundle](https://dropkit-contents.pages.dev/research/fly-t4-selection-v01/manifest.json), under `reverse-assignment/`.
- `2026-10-30/paired-selection-rotate-right-27-v01/`: same selection bundle under `rotate-right-27/`.

The previous bundle manifests include the exact relative file paths and hashes. See the [selection note](https://dropkit-contents.pages.dev/posts/fly-t4-selection/) for the input provenance and experimental limitations.

## Build and compare

The executed Linux environment used x86_64 Linux 6.8.0-146, Python 3.12.3, pandas 3.1.0, pyarrow 26.0.0, rustc/cargo 1.99.1, and Rust Parquet 57.3.2, pinned with transitive dependencies in `source/Cargo.lock`. Use a Python environment with matching pandas and pyarrow. Set `RUNS_ROOT` to the reconstructed directory and `WORK` to a fresh writable directory; use the Python executable of that environment.

```sh
cd source
cargo build --release --locked
python reference_aggregate.py "$RUNS_ROOT" "$WORK/python.tsv" 1
target/release/fly-readout-aggregator "$RUNS_ROOT" "$WORK/rust.tsv" 1
cmp "$WORK/python.tsv" "$WORK/rust.tsv"
sha256sum "$WORK/python.tsv" "$WORK/rust.tsv"
```

Both result files are expected to have SHA-256 `15852b74a7741541046b3dd5e35c9454003ec22938a56a0c1c8e0ac5b8c9a1a7`. This verifies the recorded fixture, not all possible inputs. To reproduce the benchmark, set `PYTHON` to the exact Python interpreter path and run from `source/`:

```sh
"$PYTHON" peak_rss_benchmark.py --runs "$RUNS_ROOT" --python "$PYTHON" \
  --reference "$PWD/reference_aggregate.py" --rust "$PWD/target/release/fly-readout-aggregator" \
  --out "$WORK/benchmark" --repetitions 9 --iterations 10
```

The benchmark fixes CPU 0 with `taskset`, uses nice +15, alternates implementation order, reports fresh-process wall time, and records Linux `wait4().ru_maxrss`; CPU 0 must be permitted by the host affinity mask. It includes interpreter/process startup, file decoding, counts, JSON comparison, and TSV output; compilation and installation are excluded. Files were warm in the OS cache. Results depend on hardware, load, cache and the different library implementations. The 18 output hashes from the measured wait4 runs are in `evidence/wait4-output-sha256.txt`; paths in the published raw metrics were removed, not treated as source data.
