Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7091585
feat(identity): compute structure, source and name chains
eywalker Nov 28, 2026
a629f2b
Merge remote-tracking branch 'origin/main' into eywalker/itl-1559-thr…
eywalker Nov 28, 2026
4b21055
fix(identity): preserve chains across binding and persistence
eywalker Nov 28, 2026
5da977a
Merge remote-tracking branch 'origin/main' into eywalker/itl-1559-thr…
eywalker Nov 28, 2026
f393077
fix(identity): address three-chain review findings
eywalker Nov 28, 2026
bd7ac08
chore: merge origin/main into three-chain step 1
eywalker Nov 28, 2026
12c6d38
fix(identity): preserve saved job bytes and chain inputs
eywalker Nov 28, 2026
3bb81bf
fix(identity): reject combined hashes for collapsed symmetry
eywalker Nov 28, 2026
a3e9a92
fix(identity): resolve live bindings and canonical chain order
eywalker Nov 28, 2026
d7512fa
fix(identity): guard row reads and unbound derived origins
eywalker Nov 28, 2026
c49e36e
fix(identity): preserve safe polling and loaded Index chains
eywalker Nov 28, 2026
0d2bb9a
fix(identity): keep step-one chain reads callback-free
eywalker Nov 28, 2026
3e4f03e
fix(identity): reuse polling digests through source wrappers
eywalker Nov 28, 2026
060f54a
fix(identity): restore chains for saved single-input built-ins
eywalker Nov 28, 2026
6c4accb
docs(identity): clarify saved single-input operator chains
eywalker Nov 28, 2026
824f370
chore(pipeline): merge main into three-chain step 1
eywalker Nov 28, 2026
31136af
docs(identity): clarify step-one hash limits and review coverage
eywalker Nov 28, 2026
86a8a43
chore(pipeline): merge main after declared provenance fixes
eywalker Nov 28, 2026
54692cd
chore(pipeline): merge main after context hashing and job resave fixes
eywalker Nov 28, 2026
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
15 changes: 15 additions & 0 deletions changelog.d/ITL-1559.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,22 @@
previously processed inputs are acceptable.
(ITL-1559)

### Added

- Streams, recorded invocations, and job nodes expose `source_chain()`, `name_chain()`, and `node_hash()`. The node hash identifies a computation by its structure and input slot names, so it is available on an unbound pipeline. A polling source can report its node hash before its first batch supplies the schema. Existing pipeline and content hashes keep their values.

- A job loaded without an operator implementation still exposes its saved hashes. A loaded built-in with one input can also report the new chains from its saved structure and its input's chains. Operators whose input symmetry is unavailable report an error for the new chains.

### Fixed

- Loading a saved job restores context-taking function nodes, their stored results,
and their downstream dependencies. (ITL-1559)

- Source chains follow rebindings inside composite input bindings. Name chains can be read without fetching a polling source's rows, and downstream identities that need its missing schema report that they are undefined. Nested commutative groups use the pipeline hash's canonical input order.
- Identity accessors reuse a memoized raw Arrow stream's legacy digest and report an undefined identity when they would have to materialize a lazy upstream or hash Arrow rows. Plain derived sources, including cached bindings, report no source chain while an origin slot is unbound.
- Polling source chain reads reuse a memoized legacy content hash from the polling source, a cache at any level of wrapping, or a bound job slot. A plain `DerivedSource` can use that digest without calling the polling implementation. A cold polling identity remains undefined.
- Custom operators report an undefined identity for the new accessors without calling their argument symmetry method.

### Known limitations

- The new combined hashes raise an error when a commutative group drops content-equal inputs from its argument symmetry (ITL-1590). The legacy pipeline and content hashes remain available.
37 changes: 37 additions & 0 deletions docs/dev/design_issues/ITL-1559-TC1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Pipeline identity

### TC1 — Graph identity and source binding share one key
**Status:** in progress
**Severity:** high
**Issue:** ITL-1559

A graph key derived from bound data cannot distinguish two slots bound to one source.
It also cannot follow a slot through a rebind while identifying the same computation
(ITL-1442, ITL-1427).

Step 1 computes separate structure, source and name chains. The new node hash is
available even when no source is bound. The graph and persistence still use their
existing hashes. ITL-1590 tracks the remaining structural dependency on source equality
when a commutative operator receives equal-structure inputs.

The step 1 follow-up serializes binding and chain reads. Saved jobs retain the
existing file format. An unavailable built-in with one input uses its saved structure
and that input's chains. An unavailable operator with multiple inputs needs its input
symmetry to report the new chains. Schema-less polling sources report a node hash
before their first batch, including when wrapped in a cache.

**Fix:** The execution protocols require both combined identity accessors. The
combined hashes raise when the legacy commutative grouping drops content-equal
arguments, including in downstream nodes. Recovering the lost order remains ITL-1590.
Source chains follow rebindings inside composite bindings and source wrappers.
Downstream chain reads never poll for a missing schema. Mixed nested input groups
use the pipeline hash's canonical ordering.
Polling source chain reads reuse a memoized legacy content hash or report that the
identity is undefined if the implementation's callback would have to run.
The polling digest can come from the polling source, any enclosing cache, or a bound
job slot. A plain derived source can resolve its origin using that digest. A warm
Arrow stream can reuse its legacy digest. The new accessors refuse to build lazy
upstream rows or hash cold raw Arrow rows. Custom operators report that the new
identities are undefined in this step without calling their symmetry method.
Plain derived source chains, including cached bindings, are absent while an origin
slot is unbound.
61 changes: 58 additions & 3 deletions docs/reference/hashing.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The container cell keeps its element count prefix, so it is self-contained and d
depend on the cell boundary. `tests/test_hashing/test_hash_grammar.py` fails if any of these
stops holding.

The labels of v0.3:
Hash labels:

| Label | Names | Defined in |
|---|---|---|
Expand All @@ -93,6 +93,11 @@ The labels of v0.3:
| `batch_v1` | the folded source id and record id of `Batch` (site 6b) | `BATCH_FOLD_LABEL`, `core/operators/batch.py` |
| `group_v1` | the folded source id and record id of `GroupBy` (site 6b), and the merged source-info token of a data-tag group key | `GROUP_BY_FOLD_LABEL`, `core/operators/group_by.py` |
| `join_v1` | the merged source-info token of a key that is a data-tag on several inputs of a `Join` (site 6b) | `JOIN_FOLD_LABEL`, `core/operators/join.py` |
| `slot_name_v1` | SHA-256 of the canonical tuple `("slot", name)` | `SLOT_NAME_HASH_LABEL`, `core/identity_chains.py` |
| `source_chain_v1` | SHA-256 of the canonical tuple of upstream source chains, with any local contribution | `SOURCE_CHAIN_HASH_LABEL`, `core/identity_chains.py` |
| `name_chain_v1` | SHA-256 of the canonical tuple of upstream name chains, with any local contribution | `NAME_CHAIN_HASH_LABEL`, `core/identity_chains.py` |
| `content_hash_v1` | SHA-256 of the canonical tuple of the pipeline hash and source chain | `CONTENT_HASH_LABEL`, `core/identity_chains.py` |
| `node_hash_v1` | SHA-256 of the canonical tuple of the pipeline hash and name chain | `NODE_HASH_LABEL`, `core/identity_chains.py` |
| `sha256` | the file content hash: SHA-256 of the file's bytes | `SHA256_ALGORITHM`, `hashing/hash_utils.py` |

Where a hash appears, and in which form:
Expand Down Expand Up @@ -291,6 +296,54 @@ reusable as its data changes: a default in-memory source id is the hash of the w
key order with `hash_in_key_order=True`), and a position moves when rows are inserted or
reordered.

## Structure, source and name chains

A stream, invocation or job node carries three chains. `pipeline_hash()` describes the
structure. `source_chain()` starts at each slot with the bound source's own content hash.
`name_chain()` starts with the slot's name. A raw stream outside a slot contributes
an anonymous name term. Display labels do not participate. A single-input step passes both chains
through unchanged unless the step contributes a term of its own. Ordered groups pool
inputs in argument order. Commutative groups use the pipeline hash's canonical order,
including when a group contains other groups. Within a tie the source and name chains
each sort their own values. Repeated inputs contribute at every position.

`node_hash()` combines the pipeline hash and the name chain. The chain-based content
hash combines the pipeline hash and the source chain and is undefined while any
contributing slot is unbound. The chain-based content hash is available internally as
`_chain_content_hash()` until the switch to `content_hash()`. Orcapod continues to use
the existing hashes for graph keys and persistence. ITL-1590 tracks cases where the
existing pipeline hash depends on source equality within a commutative input tie.
The saved job format does not carry input symmetry yet. A loaded built-in with one
input uses the saved pipeline hash and passes through that input's chains, even when
its operator implementation is unavailable. An unavailable operator with multiple
inputs needs its input symmetry and reports an undefined identity for either chain
or combined hash.
Custom operators also report an undefined identity for all four new accessors in
step 1. Legacy hashing can still call their argument symmetry method.
The legacy pipeline and content hashes are available from the descriptor.

A polling source, including one wrapped in a cache, can report its source chain,
name chain, and node hash before it knows its schema. The node hash combines a
pending polling-source structure term with the name chain without polling. Once a batch
supplies the schema, the node hash combines the pipeline hash with the same name
chain. The chain-based content hash requires the schema. Downstream identities that
need the pipeline hash report that it is undefined until the schema is known.
Polling source chain reads use the memoized legacy content hash when available,
including when only the wrapped polling source has memoized it.
If computing that hash would call the polling implementation, the identity read
raises an undefined-identity error. This includes `name_chain()` and
`node_hash()` on a `Join` over a cold polling stream, even with a declared
schema. The legacy symmetry check uses the inputs' content digests to form a
set. The step 1 accessors report an undefined identity when that check needs
the polling implementation.

A plain derived source, including one wrapped in a cache, has no source chain while
a contributing slot of its origin is unbound. Chain accessors report an undefined
identity when they would have to build a lazy upstream from rows or hash a raw
Arrow stream's rows. A raw Arrow stream can report its node hash from its schema
and anonymous name. Once the raw stream has memoized its legacy content hash,
the new chains can reuse that digest.

## Hash site inventory

Every place Orcapod produces a digest, and every place it reads one, with its class
Expand All @@ -316,6 +369,7 @@ test session with `-p tests.test_hashing.hash_site_trace`.
| Location | What is hashed | Algorithm / label | Used as | Call sites |
|---|---|---|---|---|
| structure hasher | a Python value as a tagged JSON tree | SHA-256 of canonical JSON, `semantic_v1` | every `content_hash()` / `pipeline_hash()`, type and function hash; the names built on schema hashes | `hashing/semantic_hashing/semantic_hasher.py:SemanticAwarePythonHasher._hash_to_content_hash` |
| three-chain hashes | a slot name, a pool of upstream chains, or the pipeline hash paired with one chain | SHA-256 of canonical JSON, with the corresponding chain or combined-hash label | into a hash for chain pooling and combining, or returned by an identity accessor | `core/identity_chains.py:_hash`, `core/identity_chains.py:_pool`, `core/identity_chains.py:IdentityChainsMixin._identity_hash`, `core/identity_chains.py:IdentityChainsMixin._compute_identity_chains.<locals>.<genexpr>`, `core/identity_chains.py:IdentityChainsMixin._chain_content_hash`, `core/identity_chains.py:IdentityChainsMixin.node_hash`, `core/sources/polling_source.py:PollingSource._identity_node_pipeline_hash` |
| Arrow hasher | a table after the semantic visitor | starfix, `arrow_v1` (a table Orcapod built: float rule on); `hash_table_strict`: `arrow_strict_v1` (a pyarrow table given as a value: every bit counts); `hash_table_ordered`: `arrow_ordered_v1` (a library value's digest: every bit counts); `hash_schema`: `arrow_schema_v1` | row data hashes, entry ids, row keys, default source ids, table values; every schema in an identity | `hashing/arrow_hashers.py:StarfixArrowHasher.hash_table`, `hashing/arrow_hashers.py:StarfixArrowHasher.hash_table_strict`, `hashing/arrow_hashers.py:StarfixArrowHasher.hash_table_ordered`, `hashing/arrow_hashers.py:StarfixArrowHasher.hash_schema`, `hashing/arrow_hashers.py:StarfixArrowHasher._digest`, `hashing/starfix_digest.py:_digest_table`, `hashing/starfix_digest.py:digest_schema` |
| file hasher | a file's bytes | SHA-256 of the bytes, label `sha256`. Hashers, cache writes, and data context loading reject other algorithms. Direct cache lookups for other labels miss (ITL-1155). Custom file hasher results are verified against SHA-256 of the file bytes. | `File` value hash | `hashing/hash_utils.py:hash_file`, `hashing/semantic_hashing/builtin_handlers.py:FileHandler.handle`, `hashing/file_hashers.py:verified_file_hash`, `hashing/file_hashers.py:canonical_file_hash`, `hashing/file_hashers.py:_validated_file_digest`, `hashing/hash_cachers.py:InMemoryHashCacher.put`, `hashing/hash_cachers.py:SqliteHashCacher.get`, `hashing/hash_cachers.py:SqliteHashCacher.put`, `hashing/postgres_hash_cacher.py:PostgresHashCacher.get`, `hashing/postgres_hash_cacher.py:PostgresHashCacher.put` |
| directory hasher | a directory tree | Merkle tree of SHA-256 entries, `directory_v1`; file leaves taken with their label. The handler verifies custom directory hashes against the library Merkle procedure. | `Directory` value hash | `hashing/directory_hashers.py:BasicDirectoryHasher.hash_directory`, `hashing/directory_hashers.py:_hash_dir`, `hashing/semantic_hashing/builtin_handlers.py:DirectoryHandler.handle`, `hashing/directory_hashers.py:verified_directory_hash`, `hashing/directory_hashers.py:canonical_directory_hash` |
Expand All @@ -340,7 +394,7 @@ test session with `-p tests.test_hashing.hash_site_trace`.

| Location | Hash consumed | Into | Form | Call sites |
|---|---|---|---|---|
| nested hash in a structure | any nested hash: types, schemas, upstream streams, value hashes | the enclosing structure hash | `{"__type__": "hash", "label": ..., "digest": ...}` | `hashing/semantic_hashing/semantic_hasher.py:_nested_hash` |
| nested hash in a structure | any nested hash: types, schemas, upstream streams, value hashes | the enclosing structure hash | `{"__type__": "hash", "label": ..., "digest": ...}` | `hashing/semantic_hashing/semantic_hasher.py:nested_hash` |
| schema identity | the `arrow_schema_v1` hashes of a source's or slot's Arrow tag and data schemas, or of a function's output Arrow schema | a source's content and pipeline identity, system-tag column names, the function `uri` | the `ContentHash` objects, nested | `utils/schema_utils.py:arrow_schema_identity`, `utils/schema_utils.py:compute_schema_hash`, `core/data_function.py:DataFunctionBase.output_data_schema_hash` |
| union and generic alias arguments | argument type hashes, sorted by digest, then label (ordering only) | the type hash, via the nested form | as above | `hashing/semantic_hashing/builtin_handlers.py:_sorted_hashes`, `hashing/semantic_hashing/builtin_handlers.py:_sorted_hashes.<locals>.<lambda>` |
| logical-type cell, scalar and container | a value-hashed cell's value hash | the Arrow table hash | `<identifier>::<label>:<digest>`; a container cell: count, then per element a marker, a u64 length and the element token | `hashing/visitors.py:SemanticHashingVisitor.visit_extension` |
Expand Down Expand Up @@ -376,7 +430,7 @@ test session with `-p tests.test_hashing.hash_site_trace`.
| function `uri` (output-schema digest) | `core/data_function.py:DataFunctionBase.output_data_schema_hash` |
| operator `uri` | `core/operators/static_output_pod.py:StaticOutputOperatorPod.uri` |
| `schema:` / `instance:` / `node:` path components | `core/nodes/function_node.py:FunctionNodeBase.node_identity_path`, `core/nodes/operator_node.py:OperatorNodeBase.node_identity_path`, `side_effects.py:SideEffectJobNode.attach_databases`, `core/sources/cached_source.py:CachedSource._unversioned_cache_path` |
| source-node slot names | `core/nodes/source_node.py:SourceNode.from_stream`, `core/nodes/source_node.py:SourceJobNode.from_stream` |
| implicit source-node slot names for streams with no source name | `core/nodes/source_node.py:slot_name_for` |
| source system-tag column name (schema digest) | `utils/schema_utils.py:compute_schema_hash` |
| system-tag suffixes of `Join`, `MergeJoin`, `Batch`, `GroupBy` | `core/operators/join.py:Join._compute_system_tag_suffixes`, `core/operators/join.py:Join._predict_system_tag_schema`, `core/operators/join.py:Join.static_process`, `core/operators/merge_join.py:MergeJoin._system_tag_suffix`, `core/operators/batch.py:Batch.unary_output_schema`, `core/operators/batch.py:Batch.unary_static_process`, `core/operators/group_by.py:GroupBy.unary_output_schema`, `core/operators/group_by.py:GroupBy.unary_static_process` |
| a saved hash shown as a digest | `core/nodes/function_node.py:_bare_digest` |
Expand All @@ -403,6 +457,7 @@ A record id is the row identifier (rule 8), built from row positions or key valu
| in-memory lookup keys for a validated operator input or input pair (ITL-1358) | `core/operators/index.py:Index.validate_unary_input`, `core/operators/index.py:Index.async_execute`, `core/operators/pick.py:Pick.validate_unary_input`, `core/operators/pick.py:Pick.async_execute`, `core/operators/semijoin.py:SemiJoin.validate_binary_inputs`, `core/operators/semijoin.py:SemiJoin.async_execute` |
| in-memory topological sort of compiled and restored nodes, using the pipeline hash to order ready invocations | `pipeline/base.py:AbstractPipelineBase._ordered_node_map.<locals>.order_key` |
| canonical input order (sort by digest). Inputs with equal pipeline hashes (developer decision, November 16, 2026, ITL-1154: kept as it is): system-tag column names follow the stable pipeline-hash sort; each row's values are sorted by (source id, record id) by `sort_system_tag_values`, so the result does not depend on argument order; the operator's identity holds its inputs as a frozenset | `core/operators/join.py:Join.order_input_streams.<locals>.<lambda>` |
| canonical input order for source and name chains (pipeline inputs' canonical JSON, then each chain's labelled hash within a tie) | `core/identity_chains.py:_pool_group` |
| in-memory identity and repr | `core/base.py:ContentIdentifiableBase.__hash__`, `hashing/semantic_hashing/content_identifiable_mixin.py:ContentIdentifiableMixin.__hash__`, `hashing/semantic_hashing/content_identifiable_mixin.py:ContentIdentifiableMixin.__eq__`, `hashing/semantic_hashing/content_identifiable_mixin.py:ContentIdentifiableMixin.__repr__` |
| comparing a stored hash with the computed one; comparing two schema hashes (bind, a stored read, a polled batch); error text | `core/nodes/source_node.py:SourceNodeBase._arrow_type_issue`, `core/sources/derived_source.py:DerivedSource._require_origin_types`, `core/sources/polling_source.py:PollingSource._require_declared_types`, `core/nodes/operator_node.py:OperatorJobNode._read_run_records`, `core/sources/source_proxy.py:SourceProxy.bind`, `core/data_function_proxy.py:DataFunctionProxy.bind`, `pipeline/job.py:PipelineJob.bind`, `errors.py:EphemeralResultMissingError.__init__` |

Expand Down
Loading
Loading