# Reproduce the Cuckoo contract experiment

This is a controlled-collision execution of unmodified reference-library code,
not a workload sample, throughput benchmark or reproduction of the 2014 evaluation.
Hesela's harness and results are CC0-1.0; upstream source is Apache-2.0 and is
not redistributed here. Use a C++11 compiler, OpenSSL development headers, Git
and Node.js 22 or newer. Run these commands in a scratch directory:

```sh
git clone https://github.com/efficient/cuckoofilter.git cuckoofilter-reference
git -C cuckoofilter-reference checkout --detach 917583d6abef692dfa8e14453bd77d6e0b61eef3
curl -fLO https://hesela.dev/research/cuckoo-contract.cpp
curl -fLO https://hesela.dev/research/run-cuckoo-contract.mjs
node run-cuckoo-contract.mjs ./cuckoofilter-reference result.json
```

The runner requires the exact commit and a clean checkout, compiles only the
Hesela harness against its headers, runs assertions, and records source hashes,
compiler, flags, platform and generation time. No upstream build scripts execute.
A failed assertion or compilation exits nonzero instead of publishing a result.
Compare cases and capacity fields; timestamps and environment fields may differ.

## Fixture

The library's HashFamily template is replaced with an identity test hash.
A = 7 and B = 65543 have different full hashes but share index 0 and 16-bit tag 7.
Their alternate bucket is 1. C = 8 has a different tag. This intentionally
manufactures a collision; it says nothing about the default hasher's probability.
No key data, Redis deployment or storage device is involved.

The constructor argument 4 produces two four-slot buckets in this implementation.
Nine identical insertions are acknowledged: eight table entries plus a victim
entry. Size() counts eight table entries. The tenth Add returns NotEnoughSpace.
After one successful Delete, the victim can enter the freed slot, leaving Size()
at eight. These numbers are not general capacities of all Cuckoo filters.

The three unsafe traces deliberately violate application update contracts.
They are not a newly discovered library vulnerability. The safe two-insertion,
one-deletion trace demonstrates why retaining collision multiplicity matters.

## Environment used for the published result

GCC 13.3.0 on Linux x86-64; compiler flags are in the JSON receipt.
OpenSSL headers came from Ubuntu libssl-dev 3.0.13-0ubuntu3.16, extracted into
a workspace-only dependency directory. No host package installation was needed.
The tested code does not call OpenSSL, but the upstream header includes its headers.

The 16-bit table layout was also checked with AddressSanitizer and UndefinedBehaviorSanitizer.
An exploratory 8-bit fixture triggered the upstream implementation's unaligned
64-bit lookup load under UBSan; that variant is not used for published results.
No claim is made that all upstream layouts are sanitizer-clean.
