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
25 changes: 21 additions & 4 deletions .zed/rules
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,8 @@ A class a user defines is one of two kinds (developer, November 12, 2026, ITL-97

## Golden hash values

Hash values must stay identical across releases (developer, November 10, 2026). Every hash
Hash values must stay identical across releases (developer, November 10, 2026). Not covered:
a provisional operator's identity and every hash downstream of it (ITL-1266, below). Every hash
Orcapod stores or embeds in a name is pinned in the golden folder of the current data context,
`tests/test_hashing/golden/data/<folder>/<group>-NN.json`, and checked by
`tests/test_hashing/golden/test_golden_hashes.py`. The mechanism is
Expand All @@ -496,6 +497,20 @@ Orcapod stores or embeds in a name is pinned in the golden folder of the current
generator writes the new value. `--release 0.4.0` freezes v1. Any version published
before it, a pre-release included, would freeze v1 there: the Release workflow requires
the release step for every version. A withdrawn version is never released again.
- Provisional operators are outside the freeze (developer, November 18, 2026, ITL-1266):
`orcapod.operators.PROVISIONAL_OPERATORS` (`core/operators/provisional.py`) is the one
list (name to the issue deciding its identity; today `PolarsFilter`), and each listed class
sets `PROVISIONAL = True` (a test checks they agree). Building one issues
`ProvisionalHashWarning` once per operator per process. A golden case that depends on one
declares it (`@case(..., provisional=("PolarsFilter",))`; `compute_group_kinds` refuses a
case that builds an undeclared one); its entries live in
`data/<folder>/provisional/<group>.json`, listed in `golden.provisional` of the manifest,
outside the history, so no release freezes them. They are checked like every other value
and change only with the developer's approval of the exact list, without a new data
context. `generate_golden_hashes.py --relocate` moves entries, values unchanged, between
frozen and provisional files; an operator leaving the group has its entries relocated into
a frozen file before the release step. Never put a value that depends on a provisional
operator in a frozen file.
- The unit of immutability is the golden file. The manifest's `golden.history`
(`src/orcapod/contexts/data/<version>.json`) lists every file with the sha256 of its bytes;
a release appends a revision with `added: {}`, pinned in
Expand Down Expand Up @@ -904,9 +919,11 @@ generation of hashing; rows of the current data context are the current entries.
- A released data context manifest (contexts/data/<version>.json) is frozen: the digest of
its canonical JSON without golden is pinned in contexts/released_manifests.json
(manifest), with one releases line per library release (ITL-946). Only its golden
history grows, by appending. A change that moves a released golden hash value, for any
reason (a logical type's own change included), needs a new data context version with its
own manifest file, never an edit of a released one. A withdrawn release freezes nothing:
section changes: the history grows, by appending, and the provisional listing follows the
provisional files, which no release freezes (ITL-1266). A change that moves a released
golden hash value, for any reason (a logical type's own change included), needs a new data
context version with its own manifest file, never an edit of a released one. A withdrawn
release freezes nothing:
its pins move to a withdrawn record (0.3.0, ITL-1255: v1 is open until 0.4.0).
- In memory the data context column is still _context_key (ColumnConfig context).
- A writer refuses an input of another data context than its own
Expand Down
25 changes: 21 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ A class a user defines is one of two kinds (developer, November 12, 2026, ITL-97

## Golden hash values

Hash values must stay identical across releases (developer, November 10, 2026). Every hash
Hash values must stay identical across releases (developer, November 10, 2026). Not covered:
a provisional operator's identity and every hash downstream of it (ITL-1266, below). Every hash
Orcapod stores or embeds in a name is pinned in the golden folder of the current data context,
`tests/test_hashing/golden/data/<folder>/<group>-NN.json`, and checked by
`tests/test_hashing/golden/test_golden_hashes.py`. The mechanism is
Expand All @@ -507,6 +508,20 @@ Orcapod stores or embeds in a name is pinned in the golden folder of the current
generator writes the new value. `--release 0.4.0` freezes v1. Any version published
before it, a pre-release included, would freeze v1 there: the Release workflow requires
the release step for every version. A withdrawn version is never released again.
- Provisional operators are outside the freeze (developer, November 18, 2026, ITL-1266):
`orcapod.operators.PROVISIONAL_OPERATORS` (`core/operators/provisional.py`) is the one
list (name to the issue deciding its identity; today `PolarsFilter`), and each listed class
sets `PROVISIONAL = True` (a test checks they agree). Building one issues
`ProvisionalHashWarning` once per operator per process. A golden case that depends on one
declares it (`@case(..., provisional=("PolarsFilter",))`; `compute_group_kinds` refuses a
case that builds an undeclared one); its entries live in
`data/<folder>/provisional/<group>.json`, listed in `golden.provisional` of the manifest,
outside the history, so no release freezes them. They are checked like every other value
and change only with the developer's approval of the exact list, without a new data
context. `generate_golden_hashes.py --relocate` moves entries, values unchanged, between
frozen and provisional files; an operator leaving the group has its entries relocated into
a frozen file before the release step. Never put a value that depends on a provisional
operator in a frozen file.
- The unit of immutability is the golden file. The manifest's `golden.history`
(`src/orcapod/contexts/data/<version>.json`) lists every file with the sha256 of its bytes;
a release appends a revision with `added: {}`, pinned in
Expand Down Expand Up @@ -934,9 +949,11 @@ current data context are the current entries.
- A released data context manifest (`contexts/data/<version>.json`) is frozen: the digest of
its canonical JSON without `golden` is pinned in `contexts/released_manifests.json`
(`manifest`), with one `releases` line per library release (ITL-946). Only its `golden`
history grows, by appending. A change that moves a released golden hash value, for any
reason (a logical type's own change included), needs a new data context version with its
own manifest file, never an edit of a released one. A withdrawn release freezes nothing:
section changes: the history grows, by appending, and the `provisional` listing follows the
provisional files, which no release freezes (ITL-1266). A change that moves a released
golden hash value, for any reason (a logical type's own change included), needs a new data
context version with its own manifest file, never an edit of a released one. A withdrawn
release freezes nothing:
its pins move to a `withdrawn` record (0.3.0, ITL-1255: v1 is open until 0.4.0).
- In memory the data context column is still `_context_key` (`ColumnConfig(context=True)`).
- A writer refuses an input of another data context than its own
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,12 @@ Orcapod is before version 1.0. In the development version (0.4.0 is next):
- **Hash values of data context v1 freeze at 0.4.0.** Hashes name stored tables and find
stored results again, so a hash value released in 0.4.0 will not change in a later release
of the same data context; CI checks this. Until 0.4.0 a v1 hash may still change, only by
an approved and explained change (0.3.0, which first shipped v1, was withdrawn). See
[Golden hashes](https://github.com/metamorphic-labs/orcapod-python/blob/main/docs/reference/golden-hashes.md).
an approved and explained change (0.3.0, which first shipped v1, was withdrawn). This
does not cover a provisional operator (today `PolarsFilter`): its identity, and every hash
downstream of it, may still change in a later release of v1. See
[Golden hashes](https://github.com/metamorphic-labs/orcapod-python/blob/main/docs/reference/golden-hashes.md)
and
[Provisional operators](https://github.com/metamorphic-labs/orcapod-python/blob/main/docs/concepts/operators.md#provisional-operators).
- **Library value types are provisional.** The hashes of `numpy.ndarray`, `torch.Tensor`, and
pandas and polars `DataFrame` and `Series` values are provisional until the library value
type audit (after 0.4.0rc1) and may change then; results computed from them may then be
Expand Down
7 changes: 7 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ against are in `docs/reference/golden-hashes.md`.
step of `0.4.0` freezes v1. Every published version needs the release step, a pre-release
included (the gate below refuses to tag one without it), so **publishing `0.4.0rc1` would
freeze v1 at the release candidate**: plan the release around it.
- Provisional operators (`orcapod.operators.PROVISIONAL_OPERATORS`, ITL-1266) are outside
the freeze: the golden values of the cases that depend on one are in
`tests/test_hashing/golden/data/v1/provisional/`, which no release step lists or pins. An
operator that stops being provisional in a release leaves the list (with its `PROVISIONAL`
marker and its golden cases' declarations) before the release step, and
`generate_golden_hashes.py --relocate` moves its golden values, unchanged, into a frozen
file, so that the release step freezes them.
- Release tags are protected on `metamorphic-labs/orcapod-python` (and on
`nauticalab/orcapod-python`, the release repository up to `0.3.0`): the repository ruleset
`protect-release-tags` (target `refs/tags/v*`; rules deletion, update and non-fast-forward;
Expand Down
11 changes: 11 additions & 0 deletions changelog.d/ITL-1266.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### Added

- Provisional operators: `orcapod.operators.PROVISIONAL_OPERATORS` lists the operators whose
identity is not frozen with data context v1 (ITL-1266). Today it holds only `PolarsFilter`
(its identity is decided under ITL-1247). Building a provisional operator, directly or
through a stream method such as `polars_filter`, issues `ProvisionalHashWarning` once per
operator per process. A later release may change its identity, and with it the stored
paths and record ids of its results and of every step downstream of it; those results are
then computed again (nothing stored is lost or wrong). The hash stability that data context
v1 promises from 0.4.0 holds for a pipeline only when it contains no provisional operator.
See "Provisional operators" in `docs/concepts/operators.md`.
43 changes: 43 additions & 0 deletions docs/concepts/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,11 @@ A new name already taken by a column that is not renamed is refused too.

### PolarsFilter

!!! warning "Provisional"
`PolarsFilter` is a [provisional operator](#provisional-operators): its identity is not
frozen with data context v1 and may change in a later release (ITL-1247). Building one
issues `ProvisionalHashWarning` once per process.

Filter rows using Polars expressions:

```python
Expand Down Expand Up @@ -764,6 +769,44 @@ large variants as described in [Arrow types of operator outputs](#arrow-types-of
that is `None` raises `ValueError` naming the operator, the column and the row's tag, whatever
`fail_on_miss` is.

## Provisional operators

Data context v1 freezes the hashes of Orcapod at the 0.4.0 release: from then on a pipeline
keeps its stored paths, record ids and default source ids from one release to the next. A
provisional operator is outside that freeze. Its identity is still being decided, so a later
release may change it, and with it the content and pipeline hashes, stored paths and record
ids of its results and of every step downstream of it. A pipeline that contains one keeps its
hashes across releases only until such a change: after it, those steps compute their results
again instead of reusing them. Nothing stored is lost or wrong; the earlier rows stay where
they are.

The provisional operators are listed in one place:

```python
from orcapod.operators import PROVISIONAL_OPERATORS

print(sorted(PROVISIONAL_OPERATORS))
# ['PolarsFilter']
```

Each name maps to the issue that decides the operator's identity (`PolarsFilter`: whether
the order of its predicates belongs to it). Building a provisional operator, directly or
through a stream method such as `polars_filter`, issues `orcapod.errors.ProvisionalHashWarning`
once per operator per process. To silence it once you have taken note, filter its class after
importing Orcapod:

```python
import warnings

from orcapod.errors import ProvisionalHashWarning

warnings.filterwarnings("ignore", category=ProvisionalHashWarning)
```

An operator leaves the group at a release: from that release on its identity is frozen like
every other operator's. Its golden values then move into the frozen golden files (see
[Golden hashes](../reference/golden-hashes.md#provisional-files)).

## Arrow types of operator outputs

`output_schema()` reports Python types, but every column also has an Arrow type, and
Expand Down
78 changes: 78 additions & 0 deletions docs/dev/scripts/itl_1266_moved_entries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
"""Prove that ITL-1266 only moved golden entries between files, values unchanged.

Usage::

uv run python docs/dev/scripts/itl_1266_moved_entries.py <base revision>

Reads every golden file of data context v1 (frozen and provisional) at the base revision
(git) and in the working tree, and compares: the same entry names, the same values, and
the list of entries whose file changed. Exits 1 on any other difference.
"""

from __future__ import annotations

import json
import subprocess
import sys
from pathlib import Path

FOLDER = "tests/test_hashing/golden/data/v1"


def _at(revision: str) -> dict[str, tuple[str, object]]:
names = subprocess.run(
["git", "ls-tree", "-r", "--name-only", revision, FOLDER],
check=True,
capture_output=True,
text=True,
).stdout.split()
out: dict[str, tuple[str, object]] = {}
for name in names:
text = subprocess.run(
["git", "show", f"{revision}:{name}"],
check=True,
capture_output=True,
text=True,
).stdout
for entry, value in json.loads(text).items():
assert entry not in out, entry
out[entry] = (name.removeprefix(FOLDER + "/"), value)
return out


def _tree() -> dict[str, tuple[str, object]]:
out: dict[str, tuple[str, object]] = {}
for path in sorted(Path(FOLDER).rglob("*.json")):
for entry, value in json.loads(path.read_text()).items():
assert entry not in out, entry
out[entry] = (path.relative_to(FOLDER).as_posix(), value)
return out


def main() -> int:
before, after = _at(sys.argv[1]), _tree()
failures = 0
if set(before) != set(after):
print("entry names differ:", sorted(set(before) ^ set(after)))
failures += 1
changed_value = sorted(
e for e in set(before) & set(after) if before[e][1] != after[e][1]
)
if changed_value:
print("values differ:", changed_value)
failures += 1
moved: dict[tuple[str, str], list[str]] = {}
for entry in sorted(set(before) & set(after)):
if before[entry][0] != after[entry][0]:
moved.setdefault((before[entry][0], after[entry][0]), []).append(entry)
print(f"entries before: {len(before)}, after: {len(after)}")
print(f"values changed: {len(changed_value)}")
for (source, target), entries in sorted(moved.items()):
cases = sorted({e.split(".", 1)[0] for e in entries})
print(f"moved {len(entries)}: {source} -> {target}; cases {cases}")
print(f"moved in all: {sum(len(e) for e in moved.values())}")
return 1 if failures else 0


if __name__ == "__main__":
raise SystemExit(main())
Loading
Loading