Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .zed/rules
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ Developer, November 12, 2026 (ITL-981); see `docs/concepts/arrays.md` and
- The hash is strict by default: every property of a value that storage keeps is part of
its identity. A property storage does not restore never counts and has no option name,
because `hash(read(write(v)))` must equal `hash(v)`.
- The float rule (section "Float rule in hashing") does not apply to library values:
`-0.0` and NaN payloads stay part of a library value's hash.
- What the hash may ignore is a closed set of property names per type (`OPTIONS`). The names
a data context ignores are declared once, in `hash_ignore` of
`contexts/logical_types.json`, and referred to as `hash_ignore:<extension name>` by the
Expand Down Expand Up @@ -478,6 +480,22 @@ A class a user defines is one of two kinds (developer, November 12, 2026, ITL-97
- Arrow-backed data carries the identifier, not a class object: the registry binds an
identifier to the newest class object with that identity, and data is read as that class.

## Float rule in hashing

Developer, November 19, 2026 (ITL-1179, ITL-1251); see `docs/reference/hashing.md` section 9.
Orcapod hashes with starfix 0.6.0 or newer, with `normalize_negative_zero` and
`normalize_nan` explicitly on (starfix's own default is off, and the options are not in the
digest), for the Arrow tables Orcapod itself builds only: streams, rows, tag and data
datagrams, preimages, the tables behind default source ids (`StarfixArrowHasher.hash_table`,
`arrow_v1`). There `-0.0` hashes as `0.0` and every NaN as the ordinary NaN, as Polars
matching treats them. Out of scope, strict (every bit counts): library values (numpy, torch,
pandas, Polars, a pyarrow `Table` or `RecordBatch` given as a value: `arrow_strict_v1`) and
the semantic hasher's Python floats. Stored values are never rewritten. Every starfix call
goes through `hashing/starfix_digest.py`, which passes both options on every call;
`tests/test_hashing/test_starfix_calls.py` fails on a call that bypasses it or takes the
wrong options. A table Orcapod builds enters an identity structure as `OrcapodTable`, never
as a bare `pa.Table` (which the semantic hasher hashes as a value).

## Golden hash values

Hash values must stay identical across releases (developer, November 10, 2026). Not covered:
Expand Down
18 changes: 18 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ Developer, November 12, 2026 (ITL-981); see `docs/concepts/arrays.md` and
- The hash is strict by default: every property of a value that storage keeps is part of
its identity. A property storage does not restore never counts and has no option name,
because `hash(read(write(v)))` must equal `hash(v)`.
- The float rule (section "Float rule in hashing") does not apply to library values:
`-0.0` and NaN payloads stay part of a library value's hash.
- What the hash may ignore is a closed set of property names per type (`OPTIONS`). The names
a data context ignores are declared once, in `hash_ignore` of
`contexts/logical_types.json`, and referred to as `hash_ignore:<extension name>` by the
Expand Down Expand Up @@ -489,6 +491,22 @@ A class a user defines is one of two kinds (developer, November 12, 2026, ITL-97
- Arrow-backed data carries the identifier, not a class object: the registry binds an
identifier to the newest class object with that identity, and data is read as that class.

## Float rule in hashing

Developer, November 19, 2026 (ITL-1179, ITL-1251); see `docs/reference/hashing.md` section 9.
Orcapod hashes with starfix 0.6.0 or newer, with `normalize_negative_zero` and
`normalize_nan` explicitly on (starfix's own default is off, and the options are not in the
digest), for the Arrow tables Orcapod itself builds only: streams, rows, tag and data
datagrams, preimages, the tables behind default source ids (`StarfixArrowHasher.hash_table`,
`arrow_v1`). There `-0.0` hashes as `0.0` and every NaN as the ordinary NaN, as Polars
matching treats them. Out of scope, strict (every bit counts): library values (numpy, torch,
pandas, Polars, a pyarrow `Table` or `RecordBatch` given as a value: `arrow_strict_v1`) and
the semantic hasher's Python floats. Stored values are never rewritten. Every starfix call
goes through `hashing/starfix_digest.py`, which passes both options on every call;
`tests/test_hashing/test_starfix_calls.py` fails on a call that bypasses it or takes the
wrong options. A table Orcapod builds enters an identity structure as `OrcapodTable`, never
as a bare `pa.Table` (which the semantic hasher hashes as a value).

## Golden hash values

Hash values must stay identical across releases (developer, November 10, 2026). Not covered:
Expand Down
39 changes: 39 additions & 0 deletions changelog.d/ITL-1179.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
### Breaking changes and migration

- In the Arrow tables Orcapod builds (streams, rows, tag and data datagrams, preimages, the
tables behind default source ids), `-0.0` now hashes as `0.0` and every NaN (any sign or
payload, quiet or signalling) as the ordinary NaN, as Orcapod already matches float keys
(ITL-1251, ITL-1179). A row that differs from a stored one only in the sign of a zero or
the bits of a NaN has the same hash and reuses the stored result. Stored values keep
their bits.
- What changes, exactly (ITL-1179):
- The hash of an Arrow table Orcapod builds that holds `-0.0` or a NaN other than the
ordinary one, and every hash built on it (two golden values moved, both of a
signalling-NaN `GroupBy` key).
- The hash of a pyarrow `Table` or `RecordBatch` given as a value (a function default,
an operator argument, a field of a user class), and of every structure that contains
one: it now carries the label `arrow_strict_v1` instead of `arrow_v1`, with the same
digest bytes, and the enclosing hash embeds the label. No golden value holds one.
- The digests of the two dictionary inputs listed under "Changed" below.

Every other hash is unchanged: the hashes of Orcapod's tables without `-0.0` or a
non-ordinary NaN, and every hash that contains no pyarrow table given as a value.

### Changed

- Orcapod requires `starfix>=0.6.0,<0.7`, the Rust implementation of starfix (wheels for
Python 3.10 and later on macOS, Linux x86_64 and aarch64, and Windows x86_64), in place of
the pure-Python starfix-python 0.5.0 (ITL-1179). With the float options off, its digests
are byte-identical to 0.5.0's, except two inputs starfix-python 0.5.0 hashed wrongly or
refused: a dictionary over a sliced nested fixed-size list (ITL-1223) and a
dictionary whose empty dictionary has no offsets buffer. Hashing a flat table is about
eight times faster.
- Orcapod hashes with starfix's `normalize_negative_zero` and `normalize_nan` explicitly on
for its own tables and explicitly off for library values, through one module
(`hashing/starfix_digest.py`). Library values (numpy, torch, pandas, Polars) and the
semantic hasher's Python floats keep the strict rule: `-0.0` and NaN payloads count.
- A pyarrow `Table` or `RecordBatch` given as a value is hashed strictly under its own label,
`arrow_strict_v1` (it was `arrow_v1`, with the same digest).
- A null in a top-level column declared non-nullable is still refused with `ValueError`; the
message is now starfix 0.6's ("Column 'x' is declared as non-nullable but contains null
values").
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Orcapod on starfix 0.6 (Rust) with float normalization: plan

Issues: ITL-1179 (move to the Rust starfix), ITL-1251 stage 2 (hash -0.0 as 0.0 and every NaN
as the ordinary NaN). Branch `eywalker/itl-1179-orcapod-040-migrate-from-starfix-python-to`.

The developer's three requirements (2026-11-19): use the latest starfix; test -0.0 against 0.0
and NaN specifically; every other hash stays exactly what it was under starfix 0.5.0.

Three stages, one commit (or a small group of commits) each; the coordinator reviews stage 1
before stage 2 starts.

## Stage 1: switch the implementation, float options off, prove nothing moved

1. `pyproject.toml`: `starfix>=0.6.0,<0.7`; `uv lock --upgrade-package starfix` (only starfix
changes in `uv.lock`); `contexts/data/v1.json` `libraries.starfix` names 0.6.0.
2. Call sites (`hashing/arrow_hashers.py`, `logical_types/polars_type.py`,
`core/sources/stream_builder.py` comment): the 0.6.0 package keeps starfix-python's
interface (`ArrowDigester.hash_schema`, `hash_table` with the same keywords), so only
docstrings and comments that name the implementation change.
3. Proof A: `generate_golden_hashes.py --check` (every group) reports nothing moved, and the
full `--stdout` dump (every computed entry, pinned or not) is identical under 0.5.0 and
0.6.0; the test files that pin digests outside the golden folder pass.
4. Proof B: `docs/dev/scripts/starfix_differential_corpus.py` builds a broad deterministic
corpus of Arrow tables and schemas and hashes each through starfix directly (every option
combination Orcapod uses) and through Orcapod's `StarfixArrowHasher`; it writes
`name -> digest or error class`. Run once with starfix 0.5.0, once with 0.6.0, and diff.
The only acceptable differences are the ones starfix 0.6.0 documents against 0.5.0
(`python/tests/_harness.py` `EXPECTED_DIFFERENCES`: ITL-1223 and two invalid or
bufferless dictionary inputs).
5. Proof C: refusals keep their class and the messages Orcapod matches ("Ambiguous node
path", null-typed data, `list_view`, map); `hash_table` timing on a 1e6-row table under
each version.
6. Proof D: the 0.6.0 wheel list against Orcapod's matrix.
7. Report to the coordinator and wait.

## Stage 2: float normalization on, for Orcapod's own tables only

Scope as decided by the developer on 2026-11-19 (it replaces the first draft of this stage,
which also normalized library values and the semantic hasher's Python floats):

1. `hashing/starfix_digest.py` is the one module that calls starfix. It passes both float
options on every call: on for the Arrow tables Orcapod builds (`digest_orcapod_table`),
off for a library value's digest (`digest_library_value`); schemas take the own-table
options (no effect).
2. `StarfixArrowHasher.hash_table` (own tables, `arrow_v1`): options on.
`hash_table_ordered` (pandas values, `arrow_ordered_v1`) and the Polars value digest:
off, as on main. A pyarrow table given as a value: `hash_table_strict`, label
`arrow_strict_v1` (the developer's name). Datagrams and raw streams put their table in
their identity as `OrcapodTable`, hashed by `hash_table`; a bare `pa.Table` is a value.
3. numpy, torch and the semantic hasher are unchanged.
4. Tests: the guard (`test_starfix_calls.py`, both directions), the rule at Orcapod level
(`test_float_rule.py`, every width and layout, a property against a reference
normalization, stored bits, rows, default source ids, the value boundary), matching
agrees with hashing (`test_float_key_hashes.py`, Join, MergeJoin, SemiJoin, GroupBy, sync
and async, two tags and two data columns in both orders and both roles).
5. Golden: exactly the two approved entries move; the `arrow.float_rule` case adds pins.

## Stage 3: docs and wrap-up

Hashing reference (the float rule with byte patterns, the manifest line), `CLAUDE.md` and
`.zed/rules`, design issue entries, `changelog.d/ITL-1179.md`, CI, review, `worker_done`.
133 changes: 133 additions & 0 deletions docs/dev/scripts/itl_1179/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# ITL-1179: Orcapod on starfix 0.6.0 (the Rust implementation): evidence

Stage 1 moves Orcapod from starfix 0.5.0 (the pure-Python starfix-python) to starfix 0.6.0
(the Rust crate's PyO3 binding) with the float options off, and shows that no hash Orcapod
produces moved. Measured on 2026-11-18, macOS arm64, Python 3.12, pyarrow 23.0.1.

## A. Golden values

- `generate_golden_hashes.py --check` under 0.6.0: "golden values of semantic, schema, arrow,
datagram, pipeline, torch match". Nothing moved.
- `generate_golden_hashes.py --stdout` (every computed entry, pinned or not; 1,565 values in
six groups) is byte-identical under 0.5.0 and 0.6.0.
- The tests that pin digests outside the golden folder pass under 0.6.0 (`tests/test_hashing`,
`tests/test_contexts`, `tests/test_logical_types`, `tests/test_arrays`, `tests/test_torch` and
the twelve other test files that hold a 64-hex literal): 6,111 passed, 33 skipped, 2 xfailed.

## B. Differential corpus

`starfix_differential_corpus.py` builds 4,400 deterministic calls: every primitive width;
floats with subnormals, infinities and the ordinary NaN (no -0.0, no other NaN); decimals,
dates, times, timestamps of every unit with and without zones, durations; strings and binary,
large and not; fixed-size binary (also of size 0); nulls at every level; lists, large lists and
fixed-size lists, nested; structs, nested, in both field orders; dictionaries of every value
kind under four index types, nested, sliced, in lists and structs; slices with offsets; zero
rows and zero columns; six chunkings of one column; pyarrow's canonical extension types; every
Orcapod logical type (path, UUID, file, directory, numpy, pandas, polars, torch, structural and
exact classes, `set[int]`, `list[Path]`); schema and field metadata; the inputs starfix
refuses. Each table goes through `ArrowDigester.hash_table` under all eight option
combinations, `hash_schema` with and without metadata, and Orcapod's `StarfixArrowHasher`
(`hash_table`, `hash_table_ordered` with and without struct field order, `hash_schema`); library
values go through the semantic hasher.

Run once per version (`uv run --with "starfix==0.5.0" ...` for the old one; on a checkout
after stage 1, `_starfix_compat.py` drops the float options 0.5.0 does not have, which change
nothing for these inputs) and compared with `compare_corpus_runs.py`. A known-defect call
counts as documented only when it makes its exact transition: 0.5.0 raises `TypeError` or
gives another digest, and 0.6.0 gives the digest of the same values built fresh (the
`twin.*` cases); anything else is unexpected. Result (4,428 calls with the twins): 4,395
equal, 0 unexpected, and

- 22 documented differences, the two inputs starfix 0.6.0 lists against 0.5.0
(`python/tests/_harness.py` `EXPECTED_DIFFERENCES` in the 0.6.0 sdist; `README.md`, "known
exception"):
- ITL-1223: a dictionary over a sliced `fixed_size_list<fixed_size_list<int64, 1>, 2>`.
0.5.0 decodes it with pyarrow's `take`, which returns wrong values on pyarrow >= 17; its
digest differs from that of the same values built fresh. 0.6.0's digest equals the
fresh build's (checked), so 0.6.0 is the correct one.
- A dictionary whose empty string dictionary has no offsets buffer (valid Arrow): 0.5.0
raises `TypeError`; 0.6.0 hashes it as the allocated equivalent.
- 11 message-only differences: a null in a TOP-LEVEL column declared non-nullable still raises
`ValueError`, now with the import check's wording ("Invalid argument error: Column 'x' is
declared as non-nullable but contains null values"; 0.5.0: "Non-nullable field 'x' contains
nulls"). A nested field keeps 0.5.0's wording ("Non-nullable field 's/a' contains nulls").
No Orcapod code reads this message; one test matched it and now matches the column name and
"non-nullable".

## C. Behaviour

- Every refusal keeps its class (`ValueError`) and message, apart from the one above:
"Ambiguous node path '<path>': two schema nodes share one path ..." (which
`logical_types/polars_type.py` matches), "Hashing data of type null (node 'c') is not
supported", "Unsupported Arrow type for hashing: list_view<item: int64>", map, interval,
view, union and run-end-encoded types.
- `hash_table_timing.py`, 1e6 rows, best of three (taken at commit 937a68f7; on a later
checkout the 0.5.0 run goes through `_starfix_compat.py`):

| | 0.5.0 | 0.6.0 |
|---|---|---|
| starfix `hash_table`, int64 + float64 + large_string | 0.746 s | 0.087 s |
| starfix `hash_table`, `large_list<int64>` | 0.019 s | 0.065 s |
| Orcapod `hash_table`, flat | 0.713 s | 0.078 s |
| Orcapod `hash_table`, `large_list<int64>` | 5.870 s | 6.972 s |

The list column's time in Orcapod is its semantic preprocessing (a Python round trip of
every nested column), not starfix.

## D. Wheels

starfix 0.6.0 on PyPI: `cp310-abi3` wheels for macOS `universal2` (x86_64 and arm64, macOS
10.12 / 11.0 and later), manylinux2014 x86_64 and aarch64, musllinux 1.2 x86_64 and aarch64,
and Windows amd64, plus the sdist. abi3 covers Python 3.11, 3.12 and 3.13, so Orcapod's matrix
installs from wheels with no Rust toolchain. No wheel: Windows on ARM64, 32-bit platforms, other
Linux architectures, and free-threaded CPython builds (abi3 does not cover them): those build
from the sdist and need Rust.

# Stage 2: the float rule, for the Arrow tables Orcapod builds

Scope (developer, November 19, 2026): starfix's `normalize_negative_zero` and
`normalize_nan` are explicitly on only for the Arrow tables Orcapod builds
(`StarfixArrowHasher.hash_table`, `arrow_v1`); library values (numpy, torch, pandas, Polars,
a pyarrow table given as a value: `arrow_strict_v1`) and the semantic hasher's Python floats
stay strict. `hashing/starfix_digest.py` is the one module that calls starfix.

## Golden values

`float_rule_golden_proof.py` computes every golden value with the own-table options as
shipped and with them off: outside the new `arrow.float_rule` case (which pins the rule
itself), exactly two values differ, both approved by the developer (November 19, 2026):

- `pipeline:group_by_nan_keys.data_tag_key.row[{"k":NaN}].tag_hash`
- `pipeline:group_by_nan_keys.data_tag_key.row[{"k":NaN}].data_hash`

The float32 data-tag key of that case is the signalling NaN `0x7F800001` (the group's
smallest NaN bits, PR 441); under the rule it hashes as the ordinary NaN `0x7FC00000`. With
the options off every computed value equals main's pin, so routing datagram and stream
tables through `OrcapodTable` / `hash_table` changes no digest and no label. The two
entries were regenerated with `generate_golden_hashes.py --remove` and the generator; a
union comparison of every pinned entry against `origin/main` differs in these two only.

The `arrow.float_rule` case adds 84 pins (no value changed): for 0.0, -0.0 and four NaN
patterns, a column of each width, a list, a struct, a dictionary, and a source's tag and
data hashes. Every `-0` pin equals its `0` twin and every NaN pin equals the `nan` one.

## The final round: frozen and provisional golden files

Since ITL-1266 the golden folder has two kinds of file: frozen files (`<group>-NN.json`)
and provisional files (`provisional/<group>.json`, the entries of cases that depend on a
provisional operator, source or library value type). The two approved `group_by_nan_keys`
entries are provisional (GroupBy is). The final round reads both kinds:

- `golden_with_options.py off|on <args>` runs `generate_golden_hashes.py --check` or
`--stdout` with the own-table float options forced off or on, under the installed starfix
(0.5.0 through `_starfix_compat.py`). Step A: `off --check` (nothing moved) and
`off --stdout --allow-errors` under 0.5.0 and 0.6.0 (byte-identical). Step B:
`on --check` (the two approved entries move; the 84 `arrow.float_rule` values are not
pinned yet).
- `float_rule_golden_proof.py` marks each differing entry with the kind of file its case
pins it in.
- After `--remove` of the two entries and the generator, `golden_union_compare.py <base>`
compares every pin of the base revision with the working tree over both kinds of file
(`store.load_folder`, which refuses an entry pinned twice). It passes only when exactly the
`--approved` entries changed, nothing was removed, every addition starts with an
`--added-prefix` and is in a frozen file, and no entry changed its kind of file.
Loading
Loading