diff --git a/.zed/rules b/.zed/rules index b7066de3a..1ebebefc1 100644 --- a/.zed/rules +++ b/.zed/rules @@ -931,9 +931,9 @@ keeps its old identity; do not change it (ITL-956). The tags_as_data argument is provisional and may be removed (ITL-1020), so when in doubt start with a data-tag, or start with data and promote it to a data-tag if needed. -### Two identity chains +### Three identity chains -Every pipeline element has two parallel hashes: +Pipeline structure, bound sources, and slot names contribute to three hashes: 1. content_hash() — the pipeline bound to its named sources: schema, topology and source identity. For a source it is a stable address, not a digest of its rows (developer, @@ -950,9 +950,9 @@ Every pipeline element has two parallel hashes: in the order given, or sorted by the key columns with hash_in_key_order=True, ITL-1272). A ListSource has no rule of its own (developer, November 21, 2026, ITL-1272): its elements and tag function enter only through that default and its output schema (their types), and - with a given source_id it is an address like every other source (the review of every source's identity is ITL-1311). A downstream stream or node hashes its - pod's identity plus its upstreams' content hashes; a function pod's identity is its uri, - not its body. The uri holds the hash of the output schema, a set of named, typed outputs + with a given source_id it is an address like every other source (the review of every source's identity is ITL-1311). A downstream stream or node hashes the pair of its pipeline hash and + source chain under the label defined in `core/identity_chains.py`. A function pod's + identity is its uri, not its body. The uri holds the hash of the output schema, a set of named, typed outputs in no order (developer, November 17, 2026, ITL-1244): reordering output_keys changes it only when a key's type changes; when a name now receives another value (same-typed keys reordered without the returned values, or the reverse), what the function computes @@ -964,6 +964,9 @@ Every pipeline element has two parallel hashes: pipelines bound to different sources (__node_content_hash). 2. pipeline_hash() — schema + topology only. Ignores data content. Used for DB path scoping so that different sources with identical Arrow schemas share database tables. +3. node_hash() — the pipeline hash with its name chain. The name chain still exists + when a contributing slot is unbound. Bound graph keys use content identity while + unbound graph declarations use name-based identity. Base case: RootSource.pipeline_identity_structure() returns the Arrow schema identity of its tag and data schemas (below, "Schemas are hashed as Arrow schemas"). diff --git a/CLAUDE.md b/CLAUDE.md index 45f17444d..1304ed83d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -951,9 +951,9 @@ keeps its old identity; do not change it (ITL-956). The `tags_as_data` argument is provisional and may be removed (ITL-1020), so when in doubt start with a data-tag, or start with data and promote it to a data-tag if needed. -### Two identity chains +### Three identity chains -Every pipeline element has two parallel hashes: +Pipeline structure, bound sources, and slot names contribute to three hashes: 1. **`content_hash()`** — the pipeline bound to its named sources: schema, topology and source identity. For a source it is a stable *address*, not a digest of its rows (developer, @@ -970,9 +970,9 @@ Every pipeline element has two parallel hashes: in the order given, or sorted by the key columns with `hash_in_key_order=True`, ITL-1272). A `ListSource` has no rule of its own (developer, November 21, 2026, ITL-1272): its elements and tag function enter only through that default and its output schema (their types), and - with a given `source_id` it is an address like every other source (the review of every source's identity is ITL-1311). A downstream stream or node hashes its - pod's identity plus its upstreams' content hashes; a function pod's identity is its uri, - not its body. The uri holds the hash of the output schema, a set of named, typed outputs + with a given `source_id` it is an address like every other source (the review of every source's identity is ITL-1311). A downstream stream or node hashes the pair of its pipeline hash and + source chain under the label defined in `core/identity_chains.py`. A function pod's + identity is its uri, not its body. The uri holds the hash of the output schema, a set of named, typed outputs in no order (developer, November 17, 2026, ITL-1244): reordering `output_keys` changes it only when a key's type changes; when a name now receives another value (same-typed keys reordered without the returned values, or the reverse), what the function computes @@ -984,6 +984,9 @@ Every pipeline element has two parallel hashes: pipelines bound to different sources (`__node_content_hash`). 2. **`pipeline_hash()`** — schema + topology only. Ignores data content. Used for DB path scoping so that different sources with identical Arrow schemas share database tables. +3. **`node_hash()`** — the pipeline hash with its name chain. The name chain still + exists when a contributing slot is unbound. Bound graph keys use content identity + while unbound graph declarations use name-based identity. Base case: `RootSource.pipeline_identity_structure()` returns the Arrow schema identity of its tag and data schemas (below, "Schemas are hashed as Arrow schemas"). diff --git a/changelog.d/ITL-1559.md b/changelog.d/ITL-1559.md index 6004cfe2e..a2b462c8e 100644 --- a/changelog.d/ITL-1559.md +++ b/changelog.d/ITL-1559.md @@ -17,23 +17,51 @@ previously processed inputs are acceptable. (ITL-1559) +- Streams, invocations, and bound nodes now combine the pipeline hash and source + chain in `content_hash()`. Bound nodes write new record ids and new + `__node_content_hash` values. Pipeline-scoped table paths stay the same. An + upgraded job computes its pipeline records again because the new ids do not + match rows written at those paths by the earlier development version. + Unbound slots and their live downstream nodes raise `UnboundSourceError` when + asked for a content hash, also in a loaded job whose saved run recorded no hash + for them; once bound they return the live content hash. Steps that share a name + and have no label are numbered in the order of this hash, so a saved job can + give `x_1` and `x_2` to the other step than before. The hash segment of a run's + pipeline URI, which observers receive and the status observer stores, moves. + Implicit input slots for prebuilt streams without a root source name now end in + the new content hash's hex digest, so rebinds of upgraded jobs must use the new + slot key (ITL-1700 tracks content-independent slot names). + (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. +- 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. - 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 +- Retained outputs from source slots raise `StaleOutputError` after a contributing + slot is rebound. Read the node again for the current binding. This prevents + downstream operator logs from recording old rows under the new binding's hash. + Buffered batches and retained iterators check for rebinding at the end of a read + as well. A node that refuses stale input clears the rows from its previous run. + - 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. +- Source chains follow rebindings inside composite input bindings. Name chains can be read without fetching a polling source's rows, and a standalone node hash that needs its missing schema reports that it is undefined. Live content hashing and job capture can obtain the schema from the first batch. 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. +- Standalone chain and node identity reads report an undefined identity for custom operators without calling their argument symmetry method. - The source and name chains hash a typed entry at every node, preserving the position of each contribution and the pairing of upstream branches. An unbound slot leaves its node hash available and raises an undefined-identity error when its source chain is requested. +- Lazy operators and function pods refresh their rows after an upstream job + slot is rebound. Sources over another job's stored results, including cached + sources, refresh for the new binding and mark downstream job nodes stale. +- Derived sources track slots added by upstream replacement and preview the + origin's stored rows once its run with the replacement binding completes. + ### 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. +- Standalone node hashing raises an error when a commutative group drops content-equal inputs from its argument symmetry. Live content hashing and job capture still accept those inputs (ITL-1590). diff --git a/docs/api/errors.md b/docs/api/errors.md index 9be9f78e3..860739d66 100644 --- a/docs/api/errors.md +++ b/docs/api/errors.md @@ -90,6 +90,8 @@ These exceptions and warnings report problems running pipelines, processing rows ::: orcapod.errors.UpstreamFailedError +::: orcapod.errors.StaleOutputError + ::: orcapod.errors.EmptyDataAccessError ::: orcapod.errors.EmptyDataHashMissingError diff --git a/docs/concepts/identity.md b/docs/concepts/identity.md index 9e4c95e95..f0a9c4c83 100644 --- a/docs/concepts/identity.md +++ b/docs/concepts/identity.md @@ -1,17 +1,22 @@ # Identity & Hashing Every pipeline element in Orcapod -- [sources](sources.md), [streams](streams.md), -[operators](operators.md), and [function pods](function-pods.md) -- carries two parallel -identity hashes. These hashes enable Orcapod to deduplicate computations, scope database +[operators](operators.md), and [function pods](function-pods.md) -- has identities for its structure, source bindings and slot names. These hashes enable Orcapod to deduplicate computations, scope database storage, and detect when a pipeline's structure or data has changed. -## Two identity chains +## Three identity chains -### `content_hash()` -- recursive source-inclusive identity +### `content_hash()` — source-inclusive identity The content hash captures schema, topology, and the **identity of the sources** feeding the -pipeline. It is computed recursively: each element's content hash depends on its own identity -plus the content hashes of all its upstream elements, all the way back to the sources. +pipeline. A stream, invocation, or node combines its pipeline hash with its source chain. +The source chain follows the input tree and includes each bound source’s address. An unbound +slot leaves the content hash undefined. + +When a job captures a prebuilt stream without a root source name as an implicit input +slot, the slot name is `