From 4e0cb9eaad165569cfee60ac4fd22a9b15bf88d8 Mon Sep 17 00:00:00 2001 From: "Edgar Y. Walker" Date: Sat, 28 Nov 2026 01:56:59 -0800 Subject: [PATCH 1/5] docs(dev): three-chain hash design for slot identity (ITL-1559) Inventory, golden move list, implementation plan and open questions for the structure, source and name chains. No production code changes. Co-Authored-By: Claude Fable 5.2 --- docs/dev/specs/itl-1559-three-chain-hash.md | 864 ++++++++++++++++++++ 1 file changed, 864 insertions(+) create mode 100644 docs/dev/specs/itl-1559-three-chain-hash.md diff --git a/docs/dev/specs/itl-1559-three-chain-hash.md b/docs/dev/specs/itl-1559-three-chain-hash.md new file mode 100644 index 000000000..683debffa --- /dev/null +++ b/docs/dev/specs/itl-1559-three-chain-hash.md @@ -0,0 +1,864 @@ +# Three-chain hash design for slot identity (ITL-1559) + +Status: draft for the developer's review. No production code is changed by this document. +Measured on `main` at `c1040ffa` (2026-11-28). Related: ITL-1442, ITL-1427, ITL-1470, +ITL-1506, ITL-1472, ITL-1553, ITL-1554, ITL-1560, ITL-1590. + +## 1. Summary + +The developer decided (2026-11-28) that every node of a pipeline has three parallel chains, +computed separately and combined only where a hash is needed. + +| Chain | Leaf (a source slot) | Any other node, operation `op`, upstreams `u1..uk` | Combined | +|---|---|---|---| +| `P` structure | `H(schema)` | `H(op, P(u1)..P(uk))`: today's pipeline hash, unchanged in value | stored table paths, system-tag column names, as today | +| `C` sources | the bound source's identity | the upstreams' `C`, pooled in `P`'s input order | content identity `H(P, C)` | +| `I` names | the slot's name | the upstreams' `I`, pooled in the same order | semantic identity `H(P, I)` | + +- **Content identity** is what storage sees. It replaces today's content hash recursion. + Every node content hash value changes; slot names never reach storage. +- **Semantic identity** is the node as an object of the pipeline: graph keys, `job.nodes`, + edges, restrictions, the run plan. It holds no source, so it survives a rebind and an + unbound slot has it. + +What this document found, in short: + +1. The design holds. A read-only prototype over all 2,504 golden entries moves exactly 104 + of them: 102 content hashes of derived streams and nodes, and 2 default source ids of + derived sources. No pipeline hash, stored path, system-tag column name, record id, data + hash, instance id or result-table key moves (section 7). +2. Six points contradict the design as it is worded, or need a decision before it is + built (section 3). Two are counterexamples measured on `main`: + - Two inputs with equal `P` DO reach a commutative operator today: `Join` and `Rejoin` + accept two same-schema inputs when every data column is a data-tag. There the + pipeline hash itself depends on whether the two inputs are equal by content + (`Join(A, B)` and `Join(A, A)` have different pipeline hashes). So "`P` unchanged in + value" and "`P` holds no source" cannot both hold for that case (3.5). + - Today's content hash distinguishes a context-taking function pod from a plain pod + of the same uri, and `P` does not, so `H(P, C)` and `H(P, I)` would merge two nodes + that are two today (3.1). +3. Entry ids and instance ids do not contain the node content hash. They do not change. + Only record ids and the operator cache's row key do, and no golden entry pins either. +4. Most of the work is not hashing. It is moving about 40 places that use the content hash + as node identity onto semantic identity (section 5). + +## 2. Definitions + +### 2.1 Notation and labels + +`P(x)` is `x.pipeline_hash()` exactly as today. No definition in this document changes it, +except the proposal in 3.1, which the developer must approve. + +Each new hash is defined in one module, proposed `src/orcapod/core/identity_chains.py`, and +carries its own label, defined there as a constant and written nowhere else (the hash label +rule): + +| Hash | Proposed label | Preimage | +|---|---|---| +| name leaf | `slot_name_v1` | `("slot", )` | +| pooled sources at a multi-input node | `source_chain_v1` | the ordered upstream `C` values | +| pooled names at a multi-input node | `name_chain_v1` | the ordered upstream `I` values | +| content identity | `content_identity_v1` | `(P, C)` | +| semantic identity | `node_identity_v1` | `(P, I)` | + +The procedure for all five is the semantic hasher's canonical form of the tuple (nested +hashes embedded with their labels), digested with SHA-256. Only the label differs. + +An alternative is to give all five the existing `semantic_v1` label, because the procedure +is the semantic hasher's. I recommend the new labels for one reason: a stored +`__node_content_hash` then says which rule produced it. A row written under today's +recursion carries `semantic_v1:`, a row written under this design carries +`content_identity_v1:`, and the two can never be confused or matched by accident. + +### 2.2 Leaves + +A leaf is anything with no producer. Its `P` is unchanged. Its `C` is its content hash as +it is computed today, unchanged (see 3.3 for why this is a recommendation and not a given). + +| Leaf | `P` | `C` | Notes | +|---|---|---|---| +| Root source (`ArrowTableSource`, `DictSource`, `ListSource`, `DataFrameSource`, `CSVSource`, `DeltaTableSource`, `SQLiteTableSource`, `PostgreSQLTableSource`, `DBTableSource`) | Arrow schema identity (`sources/base.py:481`) | `content_hash()`: `(source_id, schema identity, key columns)` (`sources/base.py:419`) | unchanged | +| `SpiralDBTableSource` | as above | root rule, then `tags_as_data` items when given (`spiraldb_table_source.py:693`) | a restriction is in no identity | +| `PollingSource` | schema | `(source_id, impl.identity(), sorted tag columns, key columns)` (`polling_source.py:430`) | provisional (ITL-1316) | +| `CachedSource` | the wrapped source's | the wrapped source's (`cached_source.py:258`) | transparent; its cache path keeps the source's content hash (`cached_source.py:292`) | +| `DerivedSource`, plain | schema | `H((content identity of the origin node,))` (`derived_source.py:325`) | the value moves, because the origin's content identity moves. It reads stored rows, so it takes the origin's CONTENT identity, never its semantic identity | +| `DerivedSource` with `tags_as_data` | schema | root rule, then the sorted mapping (`derived_source.py:326`) | unchanged; requires a `source_id` | +| `SourceProxy` | the saved pipeline hash (`source_proxy.py:215`) | the saved content hash (`source_proxy.py:197`) | unchanged; a delegate is accepted only with both equal (`source_proxy.py:125`) | +| Raw `ArrowTableStream` | schema identity (`arrow_table_stream.py:276`) | its table in canonical row order (`arrow_table_stream.py:223`) | unchanged; PR 613 refuses it as a job leaf | +| Slot, bound (`SourceJobNode` with a source) | the slot's declared schema | the bound source's `C` | today the slot already delegates (`source_node.py:1830`) | +| Slot, unbound (`SourceNode`, or `SourceJobNode` with none) | the slot's declared schema | none (3.4) | today its content hash is `("source_node", name, schema)` (`source_node.py:824`); that hash is retired | + +`I` of a leaf is `H(("slot", name))` where `name` is the slot's name. A source has an `I` +only through a slot. How a plain stream outside a job gets one is open question Q2. + +### 2.3 Other nodes + +The three chains are computed together, in one walk of the graph (developer, +2026-11-28). At each node the order of its upstreams is fixed once, by `P`, and `C` and +`I` are pooled in that same order, so that names and sources stay aligned position by +position. The only exception is a group of inputs with equal `P` at a commutative +operator (2.4). + +For a node with producer `op` and upstreams `u1..uk`: + +- `P` = today's `pipeline_hash()`. +- `k = 1`: `C(node) = C(u1)` and `I(node) = I(u1)`, passed through unchanged. +- `k > 1`: `C(node) = H(source_chain_v1; C(u_π(1)), ..., C(u_π(k)))` and + `I(node) = H(name_chain_v1; I(u_π(1)), ..., I(u_π(k)))`, where `π` is the one input + order of 2.4. Repeats are kept: `[A, A]` differs from `[A]`. +- content identity = `H(content_identity_v1; P(node), C(node))`. +- semantic identity = `H(node_identity_v1; P(node), I(node))`. + +The pooled value is a hash of the upstream values, not a flat list of leaves. Section 3.2 +says why; the two are equivalent in what they tell apart. + +A node whose ancestry holds an unbound slot has no `C` and no content identity (3.4). It +always has `P`, `I` and a semantic identity. + +### 2.4 Input order, by operator + +`argument_symmetry` decides the order (measured, every definition on `main`): + +| Producer | `argument_symmetry` | Order of `C` and `I` | +|---|---|---| +| Every `UnaryOperator` (`Batch`, `GroupBy`, `TagBy`, `AddTags`, the Select/Drop column operators, `MapTags`, `MapData`, `MapColumns`, `PolarsFilter`, `Filter`, `DropNulls`, `Pick`, `Index`) | one-tuple (`operators/base.py:233`) | pass-through | +| `SemiJoin`, `MergeJoin`, any non-commutative `BinaryOperator` | tuple (`operators/base.py:343`) | argument order | +| `Join`, `Rejoin`, any commutative `BinaryOperator` | frozenset (`join.py:217`, `operators/base.py:343`) | canonical order, below | +| `FunctionPod`, `FallThroughPod`, a function node | the multi-stream handler's, a `Join` (`function_pod.py:861`, `:1957`); the pod stream itself has one input | pass-through. The join in front of a pod is its own node | +| `SideEffectPod`, a side-effect node | tuple of one (`side_effects.py:665`) | pass-through | + +No operator on `main` returns a nested or partly symmetric group; the only example is in +a docstring (`static_output_pod.py:259`, `:267`). The rule below extends to one: each +nested group is ordered by its own kind. + +Canonical order at a commutative operator: + +1. Inputs are ordered by `P` (hex text), as `Join` already orders them (`join.py:215`). + `C` and `I` both use this order. +2. Only inside a group of inputs with equal `P`: the `C` chain orders the group by `C` + and the `I` chain orders it by `I`. Each uses its own order and never the other's. + +**Can a tie of equal `P` occur on `main`? Yes.** The belief was that it cannot, because +`Join` refuses inputs that share a data column, which two same-schema inputs always do. +Measured, it can: + +- Commutative operators: `Join` and `Rejoin` only. `MergeJoin` and `SemiJoin` are ordered + (`is_commutative` is `False`, `merge_join.py:169`, `semijoin.py:322`). A function pod + over several inputs goes through a `Join`. +- Two same-schema inputs with a plain data column are refused by both + (`InputValidationError`, "Datas should not have overlapping keys"), also when the + inputs additionally have data-tags. +- Two same-schema inputs whose every data column is a data-tag (a source with + `tag_columns` naming every column and `tag_only_columns=False`) are **accepted** by + both, as plain streams and in a job: `Join(A, B)`, `Join(A, A)`, `Rejoin(A, B)`, + `Rejoin(A, A)`. A shared data-tag is a join key, not a collision. + +So the per-chain tie rule is needed for an exported operator now, not only for a future +one. The test that pins the state of `main` is in 9.1. + +How `main` places two inputs with equal pipeline hash in system-tag column names: + +- `Join` sorts its inputs by pipeline hash (`join.py:215`) with a stable sort, so tied + inputs take canonical positions `:0` and `:1` in argument order + (`_tag_source_id::::

:0` and `...:1`, `join.py:432`). The names are the same + for either argument order, since both inputs give the same text. The VALUES are then + sorted per row across the tied columns, so `Join(A, B)` and `Join(B, A)` give identical + tables (`dict_v1:A` in `:0`, `dict_v1:B` in `:1` both ways; measured) and identical + content and pipeline hashes. +- `Rejoin` keeps the system-tag columns unchanged, so there is one pair and no position. +- `MergeJoin` uses the argument index (`merge_join.py:348`): `MergeJoin(A, B)` has `A` in + `:0`, `MergeJoin(B, A)` has `B` in `:0`, and nothing is sorted. + +The per-chain tie rule agrees with what `Join` already does to values: within a tie it +sorts the sources by value, without regard to which argument they came from. + +### 2.5 Job nodes against plain streams + +- A plain stream and the job node made from it have equal `P` (today's rule, and the + subject of ITL-1470) and equal `C`, so equal content identity. The node additionally + has `I`. +- `PodInvocation` (`pipeline/pod_invocation.py:73`) mirrors the stream's identity + structure and has no `pipeline_hash()` of its own today. It needs `P`, `C` and `I` like + a node, since the graph is keyed by invocations. +- A loaded node with no pod keeps returning its saved `P` (`function_node.py:574`, + `operator_node.py:320`). Its `C` comes from its upstream nodes, so its content identity + can be recomputed without the pod (section 11.3). + +### 2.6 What each identity is used for + +| Use | Identity | +|---|---| +| Table paths, system-tag column names, `invocation_hash`, layout scoping | `P` | +| `__node_content_hash`, record id, operator cache row key, `as_source()` default id, stored views, run URI | content identity | +| Graph keys, `job.nodes`, edges, restrictions, run plan, held rows, staleness, saved-file node keys, diagram, observers' node key | semantic identity | +| A source as a dataset: registration, one-object rule, cache path | the leaf's `C` | + +## 3. Points that contradict the wording, or need a decision + +### 3.1 `P` does not hold everything today's content hash holds about the operation + +A function pod's content identity is `(data_function, ctx_arg_name)` when it takes the +invocation context, and its pipeline identity is `data_function` alone +(`function_pod.py:178`, `:183`). Two pods can share one uri and differ in that +(`tests/test_hashing/test_wrong_hash_findings.py:759` pins that a +`side_effect_function_pod` and `function_pod(ctx_arg=...)` give one uri). + +Counterexample, measured: a plain pod and a context-taking pod with one function name, +one output schema and one major version, over one source. + +| | plain | context-taking | +|---|---|---| +| pod pipeline hash | equal | equal | +| pod content hash | differs | differs | +| stream `P` | equal | equal | +| stream content hash today | differs | differs | +| pipeline table path | `shared_name/.../schema:c481…` | `side_effect_function/shared_name/.../schema:c481…` | + +Today a job holds two nodes. Under the design both `H(P, C)` and `H(P, I)` are equal, so +the graph would keep one node and drop the other, and every node below them merges too. +Storage does not collide, because the node kind puts the two in different tables. + +This is the only such case. Every operator and `SideEffectPod` uses one structure for both +hashes (`static_output_pod.py:223`, `side_effects.py:657`), and a data function's two +structures are both its uri (`data_function.py:241`). + +Options: + +- (a) Put `ctx_arg_name` into the pod's pipeline identity when it is set. `P` then moves + for every node at or below a context-taking pod, and with it their `schema:

` path + component. No golden entry holds such a pod (`cases.py` has no `ctx_arg`), so no golden + value moves. `P` stays unchanged everywhere else. **Recommended**: `P` should name the + operation completely, and the chains then need no fourth term. +- (b) Refuse two pods of one uri that differ in `ctx_arg_name` in one job. +- (c) Carry the difference in both `C` and `I`. This makes neither chain what its name + says. + +### 3.2 A flat pooled list grows exponentially + +The table says "pooled `C` of the upstreams". As a flat list of leaves with repeats, a +node's `C` has one entry per path to a root. `k` diamonds in sequence (split, two +branches, rejoin, repeated) give `2^k` entries: 20 diamonds give 1,048,576 entries at +every node below. The diamond over one slot is the case this design is for. + +Proposal: pool by hashing (2.3). Given `P`, which fixes the shape of the graph and so the +number of leaves under each input, the hash of the ordered upstream values tells apart +exactly what the flat list does, and each node holds one fixed-size value. I treat this +as part of the design unless the developer objects. + +### 3.3 The `C` leaf: reuse the source's content hash + +The table gives the leaf as "source id, key columns". A source's content hash today also +holds its Arrow schema identity. I recommend the leaf be that existing hash, unchanged: + +- no root source content hash moves (165 golden entries stay; section 7); +- `CachedSource` paths, `SourceProxy` checks and the one-object rule of PR 577 keep + working on the value they use now; +- it stays what ITL-1506 calls the reading: source id, schema, key columns. + +The schema is then in both `P` (the slot's declared schema) and `C` (the source's own). +They can differ: a source with a non-null column bound to a slot that declares it +nullable. That is a different reading and should give a different `C`, which it does. + +### 3.4 An unbound slot has no content identity + +Today an unbound slot's content hash is `("source_node", name, schema)`, so the slot name +is in a content hash, and PR 613 keeps that ("the slot name contributes to the content +hash of an unbound slot"). Under the design the name belongs to `I` only. + +Proposal: `C` of an unbound slot does not exist, and neither does the content identity of +any node below it. Asking for it raises a dedicated error naming the unbound slots. A run +never needs it, because a run leaves out everything below an unbound slot +(`job.py:1313`). A saved file writes `null` for it. I recommend against a placeholder +value: a placeholder could reach storage, and a name in a content identity is what the +design removes. + +### 3.5 `P` depends on content equality at a commutative operator (measured on `main`) + +Filed as ITL-1590. + +A commutative operator returns `frozenset(streams)` (`join.py:217`, +`operators/base.py:346`). A Python frozenset drops equal members, and streams are equal +by content. So the pipeline hash of a commutative operator over two inputs with equal +`P` holds two items when their content differs and one when it is equal. + +Measured, with sources `A` and `B` of one schema whose data columns are all data-tags +(2.4), and `A'` a second object equal to `A`: + +| | pipeline hash | content hash | system-tag columns | +|---|---|---|---| +| `Join(A, B)`, `Join(B, A)` | `6b73c2cd…` | `a6438908…` | `…:0`, `…:1` | +| `Join(A, A)`, `Join(A, A')` | `407cfb1d…` | `b4179856…` | `…:0`, `…:1` | +| `Rejoin(A, B)`, `Rejoin(B, A)` | `89d2805a…` | `d09a5c5a…` | one pair | +| `Rejoin(A, A)`, `Rejoin(A, A')` | `384d909d…` | `dd773c9f…` | one pair | + +Two pipelines with one structure and one schema get two pipeline hashes, so two table +paths, depending only on whether the two slots hold the same source. That breaks the +rule that the pipeline hash ignores data content, on `main`, today. It is also exactly +the case of this design: two slots of one schema bound to one source, then joined. + +Under the design it cannot stand: `P` must hold no source, and when nodes stop being +equal by content the set would drop members by some other equality. `P`, `C` and `I` must +each be built from the inputs as a list (a multiset), never from a set of stream objects. +PR 587's positioned edges (`pipeline/edges.input_positions`) give that list. + +Consequence the developer must accept: "`P` unchanged in value" cannot hold for this one +case. With a multiset, `Join(A, A)` takes the value `Join(A, B)` has today (two items), +so the pipeline hash, and the table path, of a commutative operator over inputs that are +equal by content AND have equal `P` moves, with everything below it. Every other +pipeline hash is unchanged, because inputs with distinct `P` are never dropped. No golden +entry holds such a case (all 179 golden pipeline hashes stay). It is a hash change and +needs the developer's approval as one. + +### 3.6 Entry ids and instance ids are not content identity + +The task statement lists entry ids among what `H(P, C)` feeds. They are not fed by it. An +entry id is the hash of the user tags, system tags and input data hash +(`row_ids.py:60`); an instance id adds the source-info tokens (`row_ids.py:95`). Neither +holds the node content hash, so neither changes. The node content hash enters the record +id (`row_ids.py:136`), the `__node_content_hash` column, and the operator cache's row +key (`operator_node.py:1455`). That is consistent with the design; only the wording +differs. + +## 4. Worked examples + +Mock values. `P:`, `C:`, `I:` are the three chains; `ci:` is content identity and `ni:` +semantic identity. `S` is a schema, `f`, `g` are function pods. + +### 4.1 A chain + +Slot `x` bound to source `A`; `x -> f -> g`. + +| Node | `P` | `C` | `I` | `ci` | `ni` | +|---|---|---|---|---|---| +| `x` | `P:11` = `H(S)` | `C:aa` (source `A`) | `I:x1` = `H("slot","x")` | the source's own | `ni:01` = `H(P:11, I:x1)` | +| `f` | `P:22` = `H(f, P:11)` | `C:aa` | `I:x1` | `ci:c2` = `H(P:22, C:aa)` | `ni:02` = `H(P:22, I:x1)` | +| `g` | `P:33` = `H(g, P:22)` | `C:aa` | `I:x1` | `ci:c3` = `H(P:33, C:aa)` | `ni:03` = `H(P:33, I:x1)` | + +`C` and `I` pass through unchanged; `P` alone tells `f` from `g`. + +### 4.2 A diamond over one slot + +`x` (source `A`) feeds `f` and `h`; `Rejoin(f, h)`. + +| Node | `P` | `C` | `I` | +|---|---|---|---| +| `f` | `P:22` | `C:aa` | `I:x1` | +| `h` | `P:44` | `C:aa` | `I:x1` | +| `Rejoin` | `P:55` = `H(Rejoin, {P:22, P:44})` | `C:d1` = `H([C:aa, C:aa])` | `I:d1` = `H([I:x1, I:x1])` | + +The repeat is kept: `C:d1` differs from `C:aa`. The order is by `P` (`P:22` before +`P:44`); no tie. + +### 4.3 Two slots with one schema over one source + +Slots `x` and `y`, both bound to `A`; `x -> f -> g` and `y -> f -> g`. This is ITL-1442. + +| Node | `P` | `C` | `I` | `ci` | `ni` | +|---|---|---|---|---|---| +| `f` under `x` | `P:22` | `C:aa` | `I:x1` | `ci:c2` | `ni:02` | +| `f` under `y` | `P:22` | `C:aa` | `I:y1` | `ci:c2` | `ni:12` | +| `g` under `x` | `P:33` | `C:aa` | `I:x1` | `ci:c3` | `ni:03` | +| `g` under `y` | `P:33` | `C:aa` | `I:y1` | `ci:c3` | `ni:13` | + +Two `f` nodes and two `g` nodes with distinct edges. Equal content identity: both write +the same table under the same `__node_content_hash`, so the same stored rows. How the +second node avoids a second write is Q3. + +### 4.4 The same over two sources + +`x` bound to `A`, `y` bound to `B`. + +| Node | `C` | `ci` | `ni` | +|---|---|---|---| +| `f` under `x` | `C:aa` | `ci:c2` | `ni:02` | +| `f` under `y` | `C:bb` | `ci:e2` | `ni:12` | + +Same `P`, so one table; different `__node_content_hash`, so the rows are told apart, as +today. The semantic identities are those of 4.3: the graph did not change. + +### 4.5 A commutative join of two inputs with equal `P` + +`Join` over slots `x` and `y` of one schema whose data columns are all data-tags (the +case of 2.4), `x` bound to `B`, `y` to `A`. Take `C:aa < C:bb` and `I:x1 < I:y1`. + +- `P(K) = H(Join, [P:11, P:11])`, two items whatever the slots hold (3.5). +- `C(K) = H([C:aa, C:bb])`: ordered by `C`, so `y`'s source comes first. +- `I(K) = H([I:x1, I:y1])`: ordered by `I`, so `x` comes first. + +The two chains order the group differently, and that is intended: swapping which slot +holds which source changes neither `C(K)` nor `I(K)`, which is what commutative means. +What it costs is 10.1. + +### 4.6 A rebind + +4.1, then `job.bind(sources={"x": B})`. + +| Node | before | after | +|---|---|---| +| `f` `ci` | `ci:c2` = `H(P:22, C:aa)` | `ci:e2` = `H(P:22, C:bb)` | +| `f` `ni` | `ni:02` | `ni:02` | +| `f` table path | `.../schema:22` | `.../schema:22` | + +Graph keys, `job.nodes`, edges and restrictions keep their keys. The content identity +follows the bind at every depth, which is the goal of ITL-1427. Rows stored before keep +`ci:c2`; rows stored after carry `ci:e2`. + +### 4.7 An unbound blueprint + +4.1 with `x` unbound: every node has `P` and `ni` as in 4.1, and no `C` or `ci`. The +blueprint's node keys equal the job's node keys, so the remapping between the two that +`as_pipeline` does today (`job.py:816` to `:841`) is no longer needed. + +## 5. Inventory + +Every line is `src/orcapod/` at `c1040ffa`. + +### 5.1 Content hash used as node identity: moves to semantic identity + +| Place | What it does | +|---|---| +| `core/base.py:178`, `:189` | `__hash__` and `__eq__` of every stream, node and invocation: content hash and identity structure. Every node-keyed dict and set below goes through these | +| `pipeline/base.py:341`, `:344` | `_record_invocation`: the invocation's key and its upstream keys in `_hash_graph`, `_invocation_lut`, `_source_streams` | +| `pipeline/base.py:360` | `_remember_invocation`: two invocations with one key become one node, keeping the smallest label (Q1) | +| `pipeline/base.py:519`, `:522` | compile: leaves found and ordered by hash key | +| `pipeline/base.py:578` | compile: a node's upstream nodes looked up by the input's content hash | +| `pipeline/base.py:611` | compile: equal labels numbered in content hash order | +| `pipeline/base.py:622` to `:637`, `:656` to `:662` | `_persistent_node_map`, `_node_graph`, `_node_lut`, `_upstreams`, `_graph_edges`, all keyed by the hash key | +| `pipeline/base.py:667` | `_ordered_node_map`: ties broken by the key | +| `pipeline/base.py:727`, `:805`, `:809` | `to_invocations` and `from_invocations` rebuild the graph by content hash | +| `pipeline/dag.py:116` to `:121` | `OrcaDAG` keeps nodes as dict keys (`__hash__`); `networkx_backend.py` the same | +| `pipeline/job.py:192` to `:197`, `:255` to `:264`, `:548` to `:555` | `_sources_by_hash`, and the second index by the schema-based hash of `as_node()` | +| `pipeline/job.py:769` to `:846` | `as_pipeline`: maps job keys to blueprint keys, because the two differ today | +| `pipeline/job.py:953` to `:970` | `is_runnable`: walks `_hash_graph`, with a comment that the object graph breaks after `bind()` because `SourceJobNode.__hash__` changes | +| `pipeline/job.py:1305` to `:1368` | the run: the hash-keyed DAG, the excluded set and the execution DAG of node objects. Equal nodes collapse here (ITL-1442) | +| `pipeline/job.py:2006` to `:2149` | `load`: node map, predecessors and node graph by saved key | +| `pipeline/graph.py:174`, `:175`, `:293`, `:300` | save: nodes keyed by content hash, edges as pairs of those keys | +| `pipeline/graph.py:356` to `:652` | load: nodes and upstream map by saved key | +| `pipeline/sync_orchestrator.py:108`, `:109`, `:114` | `outputs`, `processed` and `held_streams` keyed by node | +| `pipeline/async_orchestrator.py:230` to `:274` | edge maps, output channels, edge readers, collectors, held rows keyed by node | +| `pipeline/node_run.py:276` to `:280` | `RunPlan.held`, `held_counts`, `held_rows` keyed by node | +| `core/nodes/source_node.py:1534`, `:2187` | a leaf that is not a source is named `

` component of pipeline, operator cache and side-effect log paths | +| `join.py:215`, `:432`, `:485`, `:496`; `streaming_joins.py:691`, `:716`, `:1525`; `merge_join.py:348`; `batch.py:198`, `:232`; `group_by.py:555`, `:731`; `operator_node.py:2391` | canonical input order and system-tag column names | +| `side_effects.py:208`, `:989`, `:1288`, `:1543`; `function_pod.py:218` | `invocation_hash` (`P :: entry id`) | +| `static_output_pod.py:991`, `:1924`; `semijoin.py:319`; `index.py:140`; `pick.py:151` | per-input caches and declared forms keyed by `P` | +| `pipeline/provenance.py:447`, `:479`, `:516`, `:1198` | finding an input's system-tag columns | +| `pipeline/graph.py:227`, `pipeline/base.py:653`, `:680`; `sources/base.py:462`; `source_proxy.py:131` | saved and compared as is | + +## 6. The stopgap refusals of PRs 577, 608 and 613 + +PRs 608 and 613 are each stacked on 577. + +| Refusal | PR | Under this design | +|---|---|---| +| Two different source objects with one content hash in a job (`InconsistentSourceError`) | 577 | **Stays**, reworded: one object per source identity (leaf `C`). Equal `C` must mean the same rows, and nothing in the chains checks that. What changes is that the one object may fill several slots. Relaxing it is ITL-1553 | +| One source id with different Arrow schemas or key columns | 577 | **Unnecessary once each reading has its own slot name**: the readings differ in `C` and in `I`. Stays for two readings that would share a slot name (ITL-1506) | +| Capture refused once any slot is re-bound or unbound | 577 | **Unnecessary**. A recorded step's key is `H(P, I)`, which a bind does not touch, so capture after a bind is well defined | +| A prebuilt stream over the job's own slot refused | 577 | **Unnecessary if Q2 is answered so that a plain stream and the job agree on the slot**; otherwise stays | +| A slot object of another job, or a standalone one, refused | 577 | **Stays**. It is about who owns a mutable slot object (questions 9 to 11 of ITL-1559), which no hash answers. The design makes the remedy possible: a slot is a name and a schema, so the receiving job can make its own | +| Capture into, or recompiling, a loaded job refused | 608 | **Stays**. A loaded job has no recorded invocations; that is ITL-1560. Section 11.3 says what the saved file should hold so that this can be lifted later | +| Two slots reading one source identity refused (`_require_distinct_slot_bindings`), and "one source identity would fill slots X and Y" at capture | 613 | **Unnecessary**. This is the case the design exists for | +| A captured slot cannot be renamed | 613 | **Stays for now**. The name is the `I` leaf; a rename re-keys every node below. Possible later as an explicit graph operation | +| Duplicate slot labels, and a slot label equal to a step label, refused | 613 | **Stays, and becomes load-bearing**: two slots with one name and one schema would have one semantic identity | +| A leaf that is not a source (a raw stream, a joined stream) refused | 613 | **Stays** (ITL-1127); such a leaf has no name | + +Build on: PR 577 (the prepare phase that lets every tracker refuse before any records; +`source_consistency.py`; the one-object registration) and PR 613 (slot names from labels, +`as_slot`, label-keyed `bind`, `job.nodes` and saved jobs, ordered inputs in saved +files). PR 613's slot name is exactly the `I` leaf. PR 587 (positioned edges, ITL-1419) +gives the input list that 3.5 needs. PR 608 is independent of the hashing and can land +before or after. + +Take out when building: `_require_distinct_slot_bindings` and the capture-time slot +collision of 613, the "slots are not as captured" check of 577, and 613's rule that an +unbound slot's content hash holds its name. + +## 7. Golden entries + +Derived by reading the golden folder and the manifest, and confirmed with a read-only +prototype kept outside the repository: it computes every golden case twice, once as on +`main` (2,504 entries, none differing from the files) and once with the content hash of +every derived stream, node and invocation replaced by `H(P, C)` as in section 2, and +compares. The generator was not run and no golden file was touched. + +### 7.1 What moves: 104 entries + +| File | Entries | Class | Reason | +|---|---|---|---| +| `pipeline-02.json` (open revision, frozen at 0.4.0) | 25 | `content_hash` of a derived stream or job node | the definition is replaced | +| `provisional/pipeline.json` | 77 | the same, in cases that use a provisional operator | the same | +| `provisional/pipeline.json` | 2 | default source id of `node.as_source()` | it holds the origin node's content identity | + +`pipeline-02.json`, 25 entries, all `.content_hash`: +`column_selection.drop_data`, `column_selection.drop_tag`, `column_selection.select_data`, +`column_selection.select_tag`, `drop_nulls.data`, `drop_nulls.data_many`, +`drop_nulls.tag`, `drop_nulls_all.all`, `drop_nulls_all.method`, +`drop_nulls_job.node[present]`, `drop_nulls_job.node[ratio]`, +`drop_nulls_job.node[renamed]`, `job.node[adjust]`, `job.node[joined]`, +`join_key_nullability.join`, `join_key_nullability.semi_join_left_nullable`, +`join_key_nullability.semi_join_right_nullable`, `join_pod.join`, `join_pod.pod`, +`map_data`, `pod`, `semi_join`, `tag_and_data_columns.drop`, +`tag_and_data_columns.select`, `tag_and_data_columns.select_tag_and_data`. + +`provisional/pipeline.json`, 77 entries, all `.content_hash`: + +- `add_tags.every_type`, `add_tags.method`, `batch`, `filter.keyword`, `filter.terms`, + `filter.tree`, `group_by`, `group_by_nan_keys`, `group_by_nan_keys.data_tag_key`, + `index_pick.index`, `index_pick.pick`, `join_key_nullability.merge_join`, + `map_columns.drop_unmapped`, `map_columns.rename`, `merge_join`, `polars_filter`, + `polars_filter_expr.expr`, `polars_filter_expr.mixed` (18); +- `filter_job.node[adjust]`, `filter_job.node[joined]`, `filter_job.node[older]`, + `polars_filter_expr_job.node[adjust]`, `polars_filter_expr_job.node[joined]`, + `polars_filter_expr_job.node[older]` (6); +- `group_by_arrangement.{default,grouped_again,member_order_y}.{interleaved,reversed,tags_first}` (9); +- `rejoin.filtered_branch`, `rejoin.method`, `rejoin.pod_branch`, `rejoin.three`, + `rejoin.three_reordered`, `rejoin.two`, `rejoin.two_reordered` (7); +- `rejoin_arrangement.{job_async,job_sync,stream}.{data_tags,mixed,plain}.{interleaved,reversed,tags_first}` (27); +- `rejoin_job.node[X]` and `rejoin_job_async.node[X]` for `X` in `SelectDataColumns`, + `ages`, `ratio`, `rejoined`, `weights` (10). + +`provisional/pipeline.json`, 2 entries: `default_source_ids.as_source[function_node].source_id` +and `default_source_ids.as_source[operator_node].source_id`. + +After PR 609 two more move with them: the two `content_hash` entries it adds for the +plain derived sources, which hold the origin's content identity. The list must be +computed again on the final base before it is put to the developer. + +Pairs that are equal today stay equal: `rejoin.two` and `rejoin.two_reordered`, +`rejoin.three` and `rejoin.three_reordered`, and the three arrangements of each +`group_by_arrangement` and `rejoin_arrangement` variant. + +### 7.2 What must not move, and does not + +Checked entry by entry in the prototype; no violation. + +| Class | Entries checked | +|---|---| +| Pipeline hashes (`*.pipeline_hash`) | 179 | +| System-tag column names (`*.system_tag_columns`) | 164 | +| Record id and source id values of rows (`_tag_record_id::*`, `_tag_source_id::*`) | 421 each | +| Row data hashes and tag hashes | 409 and 12 | +| Stored table paths (`*.table_paths`) and pipeline instance ids | 6 and 6 | +| Result-table keys (`*.input_data_hashes`) | 6 | +| Function uris, schema hashes, table hashes | 2, 38, 9 | +| Source ids of root sources (`schema-01.json`, `pipeline-02.json`) | 42 | +| Content hashes of root sources, raw streams and operators | 119 | +| Every entry of the `arrow`, `semantic`, `datagram`, `schema` and `torch` groups | all | + +Source-info tokens: no golden row sits below a default-named derived source, so no token +moves. Outside the golden files, a token that names such a source does move, with the +source id. + +Not pinned by any golden entry, and moving: record ids (they hold a random result id) and +the operator cache's `_record_hash`. + +### 7.3 Other hard-coded values + +Nine test files outside the golden folder hold 64-hex literals, and 184 test files call +`content_hash()`. Each must be read when the definition changes (grep `tests/` and +`test-specification/` for 64-hex literals and run those files before reporting). + +## 8. Implementation plan + +The developer wants this system built first and used for every slot, edge and +source-binding issue (2026-11-28). 8.1 is the steps, 8.2 what happens to the open PRs, +8.3 what each issue gets from the chains and what is left. + +### 8.1 Steps + +Each step keeps the suite green. Sizes are of the production diff. + +| Step | Content | Golden | Size | +|---|---|---|---| +| 0 | Merge PR 577, then 608 and 613 (8.2). PRs 607 and 615 can land at any time before step 5: their golden moves are disjoint from 7.1 (three root source content hashes in `schema-01.json`, instance ids and result paths) | theirs | none here | +| 1 | `core/identity_chains.py`: the five labelled hashes, the canonical order of 2.4, pooling over an input list. Streams, nodes and invocations get `source_chain()`, `name_chain()`, `content_identity()`, `node_identity()` beside the existing hashes. Nothing reads them yet. Tests compare `H(P, C)` across plain stream, invocation and job node | none | small, about 300 lines | +| 2 | Close 3.5: `P` at a commutative operator from an input list (a multiset), on PR 587's positioned inputs. Apply the decision on 3.1. Both are pipeline hash changes for one narrow case each, approved as such. Test that every other `P` is unchanged (the 179 golden pipeline hashes, and stored paths of a job) | no golden entry; stored paths move for a commutative operator over content-equal inputs of equal `P`, and with 3.1(a) for context-taking pods | small | +| 3 | Graph keys to semantic identity: `_hash_graph`, `_invocation_lut`, `_persistent_node_map`, `_sources_by_hash`, compile, `to_invocations`, `from_invocations`, `as_pipeline` (the remap goes), `is_runnable`, the run DAG. Job nodes stop being equal by content: node-keyed containers key by node object or by semantic identity. Observers get the semantic identity. Content hash still the old recursion | none | large: `pipeline/base.py`, `job.py`, `dag.py`, both orchestrators, `node_run.py` | +| 4 | Saved files: node keys become semantic identities; descriptors hold `node_identity` and `content_identity` (nullable). Loader reads the new form | none | medium: `graph.py`, `job.py`, `serialization.py`, the loaded node classes | +| 5 | The switch: `content_hash()` of every derived stream, node and invocation becomes `H(P, C)`; the unbound slot's name leaves the content hash (3.4); a bind invalidates content identity below it (ITL-1427). One golden regeneration, with the list of 7.1 approved entry by entry | 104 entries (106 after PR 609) | small in code, large in tests | +| 6 | Two slots on one source: remove the refusals named in section 6, implement the answer to Q3, tests of 9.2 | none | medium | +| 7 | Docs: `docs/concepts/identity.md`, `docs/reference/hashing.md` (the new labels and the hash site inventory), `CLAUDE.md` and `.zed/rules` ("Two identity chains" becomes three) | none | medium | + +Order against PRs 607, 615 and 609, so that each golden value is regenerated once: + +- 607 and 615 touch no entry of 7.1. They can land at any time before step 5. +- 609 changes the two `as_source[...]` source ids of 7.1 (it adds the job name to them) + and adds two entries that step 5 moves. To move those four once, step 5 should be + stacked on 609 and the two put to the developer as one list, or 609 should land first + with the four accepted as moving twice in the provisional file (no release freezes + it). I recommend stacking. +- Step 5 is the last golden-moving change of the series, on a base that holds all three. + +Steps 3 and 4 carry the risk and move no hash. Step 5 moves hashes and is mechanical. +Keeping them apart means a failure in step 5's golden check can only be a hash mistake. + +### 8.2 The open PRs + +| PR | Recommendation | Why | +|---|---|---| +| 577 (one source object per identity, ITL-1469) | **Merge first, as is** | It is ready and mergeable, it is the guard against wrong results on `main` while the steps are built, and its core rule stays (section 6). Its prepare phase and `source_consistency.py` are what steps 3 and 6 build on. Step 6 removes two of its refusals (capture after a rebind; a prebuilt stream over an own slot) | +| 608 (loaded job refuses graph changes, ITL-1560) | **Merge first, as is**, after 577 | Small, and the refusal stays under the design. Needs its conflicts with `main` resolved | +| 613 (slot names from labels, ITL-1565) | **Merge first**, after 577, once its conflicts are resolved | The slot name it defines is the `I` leaf, so step 1 needs it. It temporarily withdraws several slots on one source; step 6 removes that refusal and the two others named in section 6, and step 5 removes its rule that an unbound slot's content hash holds the name | +| 587 (positioned edges, ITL-1419) | **Rework on top of step 3** | Its edge is `(upstream key, node key, position)` with content-hash keys; the keys become semantic identities in step 3, and its dependence on 577 (one object per content hash, so that a key names one input) goes away. `pipeline/edges.py` (`input_positions`, `node_inputs`) is kept as it is and is what step 2 uses for the input list. If it is ready before step 3 starts, merging it first and re-keying it in step 3 is equally good | + +None is superseded. Nothing in them is thrown away except the refusals listed in +section 6. + +### 8.3 What each issue gets + +| Issue | Do the chains resolve it? | What remains | Step | +|---|---|---|---| +| ITL-1442, two slots on one source | Yes. The two branches have distinct semantic identities, so no node collapses; equal content identity, so one set of stored rows | The write rule for two nodes of one content identity (Q3), so that the async run stores one entry per row | 3 (nodes no longer collapse), 6 (Q3, refusals removed) | +| ITL-1427, hashes after a bind | Yes. Content identity is `H(P, C)` with `C` read from the slot, so it follows a bind at every depth, also on a loaded job without its pods (11.3) | Invalidating cached `C` and content identity below a slot when it is bound; the issue's tests | 5 | +| ITL-1204, slot lost from the run graph after a bind | Yes, outright. The slot's key is its semantic identity, which a bind does not change; today `SourceJobNode.__hash__` changes at a bind (`job.py:931`) | Nothing beyond step 3; `is_runnable`'s workaround goes | 3 | +| ITL-1470, a stream built before a job gets other system-tag names | No. It is a difference in `P`: the stream built outside becomes a leaf slot of its own, with its narrower schema, so the schema hash in the column names differs. No chain changes `P` | The capture rule: a stream brings its upstream steps down to its sources (ITL-1387), or is refused (PR 613 refuses a leaf that is not a source). The chains add the check: the job node's `P` must equal the plain stream's (9.1, PR 579) | 6, or its own PR after it | +| ITL-1506, one source id read with different key columns | Yes, once each reading has its own slot name: the readings differ in `C` (key columns are in the leaf) and in `I` | Removing the refusal for distinctly named slots; `bind` and the saved file address slots by name (PR 613) | 6 | +| One slot, two labels | By decision Q1. With (b) they are two nodes of one content identity, the same case as ITL-1442 | Q1; the label enters the `I` chain | 1 (definition), 3 (graph) | +| Binding a slot to something that depends on a slot (cycles; a stale slot-to-slot binding after recompiling) | No, and the chains say why it must stay refused: a slot's `C` is its bound leaf's `C`. If what is bound depends on a slot, `C` is defined through that slot, and through itself in a cycle; and what is bound holds a reference to a slot object that a recompile replaces | One rule at `bind` and at capture: what a slot holds is a leaf with a `C` of its own, with no slot beneath it (walk with `streams_beneath`). PR 577's foreign-slot refusal and PR 613's refusal of a leaf that is not a source already cover it; step 6 states it once and keeps it. Binding a composite properly is ITL-1127 | 6 | +| Edges carrying input position (PR 587) | Needed by the chains, not resolved by them: pooling and 3.5 need each node's inputs as an ordered list with repeats | Re-key its edges by semantic identity | 2 (the list), 3 (the keys) | +| Restrictions on edges (ITL-1472) | Made possible. An edge is `(upstream semantic identity, node semantic identity, position)`, which survives a rebind and exists for an unbound blueprint; two slots on one source are two edges and can carry two restrictions | The edge registry itself (PR 580's design), the rule for stored rows under a restriction (Q4), and Q3 for two restricted nodes of one content identity. Not part of this work | after 6 | +| Capture after a rebind (PR 577) | Yes. A recorded step's key holds no source | Passing a source opens its slot or matches it by object; passing the slot reads it (the developer's direction in ITL-1559). Remove the refusal | 6 | +| Capture into a loaded job (PR 608, ITL-1560) | No. A loaded job has no recorded invocations | The saved file gets semantic keys and ordered inputs (step 4), from which the graph could be rebuilt; lifting the refusal is its own work | 4 prepares; not lifted here | +| Slot names (PR 613, ITL-1565, ITL-1428) | They are the `I` leaf | Duplicate names stay refused; a rename after capture stays refused | 0 (merge), 1 | +| Several slots of one source fail to load (ITL-1554) | Yes. Saved node keys are semantic identities and no longer collide | The new file form | 4 | + +## 9. Tests the design needs + +All through the public interface, with sources of two or more tag columns and two or more +data columns, `tag_only_columns=True` unless the role is the subject, in more than one +arrangement, and on the sync and the async path. + +### 9.1 The chains + +- `P` unchanged: every golden pipeline hash, plus stored paths and system-tag column + names of a job, before and after each step. +- A plain stream, its invocation and its job node have equal `P` and equal content + identity, built before the job and inside it (with ITL-1470's test, PR 579). +- Pass-through at every unary operator, function pod and side-effect pod; argument order + at `SemiJoin` and `MergeJoin`; `P` order at `Join` and `Rejoin` with two and three + inputs in every argument order. +- Repeats kept: a diamond's `C` differs from its branch's `C`. +- The state of `main` on ties, pinned before anything changes: over two sources of one + schema, `Join` and `Rejoin` refuse the pair when a plain data column is shared and + accept it when every data column is a data-tag; `MergeJoin` and `SemiJoin` are + ordered; no exported operator returns a nested symmetry (a test over + `orcapod.operators` that fails when a new operator is commutative or partly symmetric + until it has a tie case). +- The equal-`P` group, with `Join` and `Rejoin` over two all-data-tag slots, with two + tags and two data-tags, plain and in a job, sync and async: `P` is the same whether + the two slots hold one source, two equal objects or two different sources (3.5); both + arrangements of two sources over the two slots give one `C`, one `I`, one table of + rows and the same system-tag column names and values. +- 3.1: a plain and a context-taking pod of one uri over one source are two nodes. +- Unbound: every node has a semantic identity; asking for content identity raises and + names the slots. +- The label rule: `tests/test_hashing/test_hash_label_rule.py` extended to the five + labels; `test_hash_grammar.py` and `test_hash_site_inventory.py` hold the new sites. +- Order invariance: `tests/test_core/test_order_invariance.py` gets a case per identity + (content and semantic) for every operator, source and stream kind, and for a job, so + that no arrangement of tags, columns or commutative inputs changes either. + +### 9.2 Two slots on one source (ITL-1442) + +- `A_x -> f -> g` and `A_y -> f -> g` bound to one source: four step nodes in `job.nodes` + and in the run summary, every node holds the full rows, one stored pipeline entry per + row and one result per input, sync and async, on a first run and a second. +- The same with a `Join` and with an operator node that caches. +- The same with one slot unbound: the bound branch runs, the other is left out. +- Bound to two sources, then rebound to one, then back: content identities follow at + every depth, semantic identities never change, rows stored earlier keep their node + content hash (ITL-1427's criteria, also for a loaded job). +- One dataset read with two key-column choices in two named slots (ITL-1506). +- Save and load of all of the above, including the case of ITL-1554 (one source in + several slots feeding one function pod). +- `as_source()` of each of two nodes with one content identity gives one source id. +- A side-effect node under each of two slots on one source: the decided number of + deliveries, with and without `track_completion`. + +## 10. Open questions for the developer + +### Q1. Is a node's own label part of its semantic identity? + +One slot feeding the same pod twice under labels `r1` and `r2`: one node or two? Today +they are one node and the smaller label is kept (`pipeline/base.py:360`). + +- (a) Not part: one node. `job.nodes["r2"]` does not exist, and a label the user wrote is + dropped without notice. +- (b) An explicitly assigned label is part: two nodes with one content identity. The + label must enter the `I` chain, not only the node's own hash, or the steps below `r1` + and `r2` would merge again: `I(node) = H(("label", label), pooled I)` when a label was + assigned, pass-through otherwise. A computed label never enters. + +Recommendation: (b). A slot's label is already its identity, so a step's assigned label +being identity is the same rule. Edges, restrictions and probes can then be attached to +`r1` and `r2` apart (ITL-1472). The cost is that a labelled step can no longer be renamed +after capture without re-keying what is below it, as for a slot, and that Q3's case +arises more often, which it must handle anyway. + +### Q2. A stream outside a job: how is its semantic identity formed? + +- (a) From the source's label by the one rule that names a slot (PR 613: the assigned + label, else the class name; `as_slot(name)` gives the name). A plain stream then has + the semantic identity its job node will have. +- (b) A plain stream has no semantic identity. It has `P` and content identity; the job + assigns `I` when it captures the stream, by walking to its roots. + +Recommendation: (a), under three conditions. One function derives the name for the plain +stream and for the job, so they cannot differ. `I` and semantic identity are never cached +on an object whose label can still change (the name is frozen at capture, as PR 613 +does); this answers question 10 of ITL-1559 for the name. And two different sources with +one default label (two `DictSource` objects) have one `I`: that is harmless outside a job +only if plain streams are not equal by semantic identity, so `__eq__` and `__hash__` of a +plain stream should stay content-based or become object identity, and only a graph +compares by semantic identity, where duplicate slot names are refused. + +### Q3. Two nodes with equal content identity in one job + +- (a) Write-if-missing on every pipeline and operator-cache write. +- (b) Compute once and feed both. + +Recommendation: (a) as the rule, (b) later as an optimisation. Reasons: + +- (b) is wrong when the two nodes sit below different restrictions (ITL-1472: equal + content identity, different rows), so it needs (a) underneath in any case. +- The pipeline table's key, the record id, holds a random result id. When two nodes + compute one instance at the same time (the async run of ITL-1442: 4 entries for 2 + rows), both miss the result store and write two results and two pipeline rows. So + write-if-missing must be keyed by the instance id within one node content hash, not by + the record id, and within one run the second node must wait for the first: a + single-flight map keyed by (table path, node content identity, instance id). The + operator cache's key (`_record_hash`) already covers the whole row, so there the rule + is the existing skip of a row passed again, made safe for two writers in one run. +- It also covers two jobs that share a database. + +To decide with it: whether two side-effect nodes with one content identity deliver once +or twice. The log is keyed by `P` and entry id, so with `track_completion` the second is +already skipped. I recommend once in every mode, by the same single-flight map. + +### Q4. What a restricted chain's `as_source()` shows without a membership table + +- (a) Every stored row of the node's content identity: a superset of the restricted view. +- (b) Refused, with the remedy to filter in the pipeline. +- (c) The stored rows filtered again by the restriction, where its columns survive. + +Recommendation: (b), as a caching operator node and a `CachedSource` over a restricted +source are refused today. (a) shows rows the user restricted away under a name that says +restricted; (c) works for some graphs and not others. + +## 11. Risks, cost, and loaded jobs + +### 11.1 What cannot be made to hold + +- **3.1** as stated: without a decision, two nodes merge (counterexample there). +- **"`P` unchanged in value" together with "`P` holds no source"** (3.5): on `main` the + pipeline hash of `Join` or `Rejoin` over two inputs of equal `P` depends on whether + they are equal by content. One of the two statements has to give for that case; I + recommend that the value moves. +- **An attribution limit at a commutative operator with equal-`P` inputs** (4.5). `C` and + `I` each order the group on their own, so the pair (`C`, `I`) does not say which slot + holds which source: `x=A, y=B` and `x=B, y=A` give the same `P`, `C` and `I`. This is + correct for the operator's output, and it is what the agreed condition asks for. The + consequence to accept: content and semantic identity together never identify a + binding. Anything that must know which source a slot holds (the membership table, a + saved job) records it per slot, and must not try to derive it from the two hashes. +- **Equal `C` means equal rows only by convention.** The chains cannot check that two + sources with one identity deliver the same data. The one-object rule of PR 577 stays + for that. +- **Rows stored before the change are orphaned in place.** Table paths do not move, so a + pipeline or operator cache table keeps rows whose `__node_content_hash` no node will + ever compute again. They are never returned and never counted. With the new labels + (2.1) they can be recognised by their `semantic_v1:` prefix. Nobody has such a store + before 0.4.0. I do not recommend a layout bump for it, because that would move stored + paths. + +### 11.2 Cost + +Measured on a 50-node chain (one source, 49 single-input operators), counting calls of +the semantic hasher's `hash_object` and wall time, caches cold: + +| | calls | time | +|---|---|---| +| Today, content hash of the last node | 197 | 0.9 ms | +| Today, pipeline hash of the last node | 197 | 0.8 ms | +| Today, both | 394 | 1.6 ms | +| Three chains: `P`, then `H(P, C)` and `H(P, I)` at every node | 297 | 1.2 ms | + +The three chains cost less than today's two, because `C` and `I` pass through +single-input nodes and the two combined hashes are flat: today's content hash walks the +pod and the upstream structure a second time. A multi-input node adds one pooled hash to +each of `C` and `I`. I did not get a clean number for a join-heavy graph: building a +`Join` already computes its inputs' pipeline hashes, so the caches are warm when the +measurement starts. With hashed pooling the cost is linear in nodes in every graph; with +a flat list it is exponential in nested diamonds (3.2). + +A bind today must clear cached content hashes below the slot and does not (ITL-1427). +Under the design a bind invalidates `C` and content identity below the slot and nothing +else: `P`, `I` and semantic identity are untouched. + +### 11.3 What a loaded job does + +Today a saved job keys nodes by content hash, stores each node's `content_hash` and +`pipeline_hash`, and stores the run's content hash per label +(`run.node_job_content_hashes`), because a node loaded without its pod cannot compute its +content hash again (`operator_node.py:305`). + +Under the design: + +- Node keys are semantic identities. The blueprint and the job share them, and several + slots of one source no longer collide in the file (ITL-1554). +- A loaded node keeps its saved `P`. Its `C` comes from its upstream nodes, so its + content identity is `H(saved P, C)` computed live whenever every slot above it is bound, + with no pod. A bind on a loaded job then moves the content identity of every node below + it correctly, which today it cannot. +- The file still records each node's content identity at the time of the run, for a slot + whose source cannot be rebuilt (an in-memory source): the node then reads its stored + rows by the recorded value until a source is bound. +- A saved slot records its name and its bound source's identity per slot (11.1, the + attribution limit). +- A file written before the change has other keys and content hashes that match no + stored row written after it. I recommend refusing such a file with a message that says + so, since no one has one. The developer may prefer a reader for it. +- Capture into and recompiling a loaded job stay refused (PR 608). With semantic keys + and saved ordered inputs the graph can be rebuilt without the invocations, which is + what lifting that refusal needs; it is not part of this work. + +### 11.4 The later membership table + +Nothing here blocks it. Its key would be a node's semantic identity (it survives a +rebind), its rows references by entry or instance id into the table at the node's `P` +path, scoped by the node's content identity. All three exist for every bound node. Since +semantic identity holds no source, the table must also hold the content identity it was +recorded under, or a rebind would show the old binding's members. From 2e7ed574c060bb854aa72c782ec0cc62ef0ff9e4 Mon Sep 17 00:00:00 2001 From: "Edgar Y. Walker" Date: Sat, 28 Nov 2026 02:10:02 -0800 Subject: [PATCH 2/5] docs(dev): record the decisions on ctx_arg_name in P and on node labels (ITL-1559) Co-Authored-By: Claude Fable 5.2 --- docs/dev/specs/itl-1559-three-chain-hash.md | 85 +++++++++++++-------- 1 file changed, 52 insertions(+), 33 deletions(-) diff --git a/docs/dev/specs/itl-1559-three-chain-hash.md b/docs/dev/specs/itl-1559-three-chain-hash.md index 683debffa..566105612 100644 --- a/docs/dev/specs/itl-1559-three-chain-hash.md +++ b/docs/dev/specs/itl-1559-three-chain-hash.md @@ -1,6 +1,7 @@ # Three-chain hash design for slot identity (ITL-1559) -Status: draft for the developer's review. No production code is changed by this document. +Status: draft for the developer's review. Decisions of 2026-11-28 are marked "decided" +where they apply (3.1, Q1, the single walk of 2.3). No production code is changed by this document. Measured on `main` at `c1040ffa` (2026-11-28). Related: ITL-1442, ITL-1427, ITL-1470, ITL-1506, ITL-1472, ITL-1553, ITL-1554, ITL-1560, ITL-1590. @@ -36,7 +37,8 @@ What this document found, in short: value" and "`P` holds no source" cannot both hold for that case (3.5). - Today's content hash distinguishes a context-taking function pod from a plain pod of the same uri, and `P` does not, so `H(P, C)` and `H(P, I)` would merge two nodes - that are two today (3.1). + that are two today (3.1). Decided: `ctx_arg_name` enters the pod's pipeline + identity. 3. Entry ids and instance ids do not contain the node content hash. They do not change. Only record ids and the operator cache's row key do, and no golden entry pins either. 4. Most of the work is not hashing. It is moving about 40 places that use the content hash @@ -46,8 +48,9 @@ What this document found, in short: ### 2.1 Notation and labels -`P(x)` is `x.pipeline_hash()` exactly as today. No definition in this document changes it, -except the proposal in 3.1, which the developer must approve. +`P(x)` is `x.pipeline_hash()` as today, with two changes, each for one narrow case: the +decision of 3.1 (a context-taking function pod) and the correction of 3.5 (a commutative +operator over inputs of equal `P`). Each new hash is defined in one module, proposed `src/orcapod/core/identity_chains.py`, and carries its own label, defined there as a constant and written nowhere else (the hash label @@ -222,16 +225,26 @@ This is the only such case. Every operator and `SideEffectPod` uses one structur hashes (`static_output_pod.py:223`, `side_effects.py:657`), and a data function's two structures are both its uri (`data_function.py:241`). -Options: +**Decided (developer, 2026-11-28): option (a).** `ctx_arg_name` enters the function +pod's pipeline identity when it is set, so that `P` describes the operation completely. +`P` then moves for every node at or below a context-taking pod, and with it their +`schema:

` path component. No golden entry holds such a pod (`cases.py` has no +`ctx_arg`), so no golden value moves. `P` is unchanged everywhere else. The two options +not taken were to refuse two pods of one uri that differ in `ctx_arg_name` in one job, +and to carry the difference in both `C` and `I`. -- (a) Put `ctx_arg_name` into the pod's pipeline identity when it is set. `P` then moves - for every node at or below a context-taking pod, and with it their `schema:

` path - component. No golden entry holds such a pod (`cases.py` has no `ctx_arg`), so no golden - value moves. `P` stays unchanged everywhere else. **Recommended**: `P` should name the - operation completely, and the chains then need no fourth term. -- (b) Refuse two pods of one uri that differ in `ctx_arg_name` in one job. -- (c) Carry the difference in both `C` and `I`. This makes neither chain what its name - says. +**General provision (developer, 2026-11-28).** A node MAY contribute a term of its own +to `C` or to `I`. No node does today: every node other than a leaf only pools its +upstreams' values. Two rules bound such a term: + +- Anything that tells apart two nodes that can sit in one graph must be in `P` or in + `I`. Semantic identity `H(P, I)` is the graph's key, so a difference held only in `C` + would leave two nodes with one key. +- A term in `C` only must be like a binding: one value per node at a time. It may change + (as a bind changes a slot's source), and the node stays the same node when it does. + +A node that contributes a term hashes it with its pooled value, also when it has one +input, so the pass-through of 2.3 holds only for a node with no term of its own. ### 3.2 A flat pooled list grows exponentially @@ -419,7 +432,7 @@ Every line is `src/orcapod/` at `c1040ffa`. |---|---| | `core/base.py:178`, `:189` | `__hash__` and `__eq__` of every stream, node and invocation: content hash and identity structure. Every node-keyed dict and set below goes through these | | `pipeline/base.py:341`, `:344` | `_record_invocation`: the invocation's key and its upstream keys in `_hash_graph`, `_invocation_lut`, `_source_streams` | -| `pipeline/base.py:360` | `_remember_invocation`: two invocations with one key become one node, keeping the smallest label (Q1) | +| `pipeline/base.py:360` | `_remember_invocation`: two invocations with one key become one node, keeping the smallest label. Under Q1 they stay one node and the most recent label is kept | | `pipeline/base.py:519`, `:522` | compile: leaves found and ordered by hash key | | `pipeline/base.py:578` | compile: a node's upstream nodes looked up by the input's content hash | | `pipeline/base.py:611` | compile: equal labels numbered in content hash order | @@ -605,7 +618,7 @@ Each step keeps the suite green. Sizes are of the production diff. |---|---|---|---| | 0 | Merge PR 577, then 608 and 613 (8.2). PRs 607 and 615 can land at any time before step 5: their golden moves are disjoint from 7.1 (three root source content hashes in `schema-01.json`, instance ids and result paths) | theirs | none here | | 1 | `core/identity_chains.py`: the five labelled hashes, the canonical order of 2.4, pooling over an input list. Streams, nodes and invocations get `source_chain()`, `name_chain()`, `content_identity()`, `node_identity()` beside the existing hashes. Nothing reads them yet. Tests compare `H(P, C)` across plain stream, invocation and job node | none | small, about 300 lines | -| 2 | Close 3.5: `P` at a commutative operator from an input list (a multiset), on PR 587's positioned inputs. Apply the decision on 3.1. Both are pipeline hash changes for one narrow case each, approved as such. Test that every other `P` is unchanged (the 179 golden pipeline hashes, and stored paths of a job) | no golden entry; stored paths move for a commutative operator over content-equal inputs of equal `P`, and with 3.1(a) for context-taking pods | small | +| 2 | Close 3.5: `P` at a commutative operator from an input list (a multiset), on PR 587's positioned inputs. Put `ctx_arg_name` into the function pod's pipeline identity (3.1, decided). Both are pipeline hash changes for one narrow case each, approved as such. Test that every other `P` is unchanged (the 179 golden pipeline hashes, and stored paths of a job) | no golden entry; stored paths move for a commutative operator over content-equal inputs of equal `P`, and for context-taking pods (3.1) | small | | 3 | Graph keys to semantic identity: `_hash_graph`, `_invocation_lut`, `_persistent_node_map`, `_sources_by_hash`, compile, `to_invocations`, `from_invocations`, `as_pipeline` (the remap goes), `is_runnable`, the run DAG. Job nodes stop being equal by content: node-keyed containers key by node object or by semantic identity. Observers get the semantic identity. Content hash still the old recursion | none | large: `pipeline/base.py`, `job.py`, `dag.py`, both orchestrators, `node_run.py` | | 4 | Saved files: node keys become semantic identities; descriptors hold `node_identity` and `content_identity` (nullable). Loader reads the new form | none | medium: `graph.py`, `job.py`, `serialization.py`, the loaded node classes | | 5 | The switch: `content_hash()` of every derived stream, node and invocation becomes `H(P, C)`; the unbound slot's name leaves the content hash (3.4); a bind invalidates content identity below it (ITL-1427). One golden regeneration, with the list of 7.1 approved entry by entry | 104 entries (106 after PR 609) | small in code, large in tests | @@ -646,7 +659,7 @@ section 6. | ITL-1204, slot lost from the run graph after a bind | Yes, outright. The slot's key is its semantic identity, which a bind does not change; today `SourceJobNode.__hash__` changes at a bind (`job.py:931`) | Nothing beyond step 3; `is_runnable`'s workaround goes | 3 | | ITL-1470, a stream built before a job gets other system-tag names | No. It is a difference in `P`: the stream built outside becomes a leaf slot of its own, with its narrower schema, so the schema hash in the column names differs. No chain changes `P` | The capture rule: a stream brings its upstream steps down to its sources (ITL-1387), or is refused (PR 613 refuses a leaf that is not a source). The chains add the check: the job node's `P` must equal the plain stream's (9.1, PR 579) | 6, or its own PR after it | | ITL-1506, one source id read with different key columns | Yes, once each reading has its own slot name: the readings differ in `C` (key columns are in the leaf) and in `I` | Removing the refusal for distinctly named slots; `bind` and the saved file address slots by name (PR 613) | 6 | -| One slot, two labels | By decision Q1. With (b) they are two nodes of one content identity, the same case as ITL-1442 | Q1; the label enters the `I` chain | 1 (definition), 3 (graph) | +| One slot, two labels | Decided (Q1): one node. Its key is `H(P, I)`, which holds no label, so the two declarations have one key | `_remember_invocation` keeps the most recent label instead of the smallest; `job.nodes` holds the node under that label only; tests | 3 | | Binding a slot to something that depends on a slot (cycles; a stale slot-to-slot binding after recompiling) | No, and the chains say why it must stay refused: a slot's `C` is its bound leaf's `C`. If what is bound depends on a slot, `C` is defined through that slot, and through itself in a cycle; and what is bound holds a reference to a slot object that a recompile replaces | One rule at `bind` and at capture: what a slot holds is a leaf with a `C` of its own, with no slot beneath it (walk with `streams_beneath`). PR 577's foreign-slot refusal and PR 613's refusal of a leaf that is not a source already cover it; step 6 states it once and keeps it. Binding a composite properly is ITL-1127 | 6 | | Edges carrying input position (PR 587) | Needed by the chains, not resolved by them: pooling and 3.5 need each node's inputs as an ordered list with repeats | Re-key its edges by semantic identity | 2 (the list), 3 (the keys) | | Restrictions on edges (ITL-1472) | Made possible. An edge is `(upstream semantic identity, node semantic identity, position)`, which survives a rebind and exists for an unbound blueprint; two slots on one source are two edges and can carry two restrictions | The edge registry itself (PR 580's design), the rule for stored rows under a restriction (Q4), and Q3 for two restricted nodes of one content identity. Not part of this work | after 6 | @@ -682,7 +695,11 @@ arrangement, and on the sync and the async path. the two slots hold one source, two equal objects or two different sources (3.5); both arrangements of two sources over the two slots give one `C`, one `I`, one table of rows and the same system-tag column names and values. -- 3.1: a plain and a context-taking pod of one uri over one source are two nodes. +- 3.1: a plain and a context-taking pod of one uri over one source have different `P` + and are two nodes; `P` of a pod that takes no context is unchanged. +- Q1: one slot feeding one pod under labels `r1` then `r2` is one node labelled `r2`, + in `job.nodes`, the run summary and a saved and loaded job; the reverse order gives + `r1`; neither changes any `P`, content identity or semantic identity. - Unbound: every node has a semantic identity; asking for content identity raises and names the slots. - The label rule: `tests/test_hashing/test_hash_label_rule.py` extended to the five @@ -708,25 +725,27 @@ arrangement, and on the sync and the async path. - A side-effect node under each of two slots on one source: the decided number of deliveries, with and without `track_completion`. -## 10. Open questions for the developer +## 10. Questions for the developer + +Q1 is decided. Q2, Q3 and Q4, and the PR recommendations of 8.2, are open. + +### Q1. Is a node's own label part of its semantic identity? DECIDED: no -### Q1. Is a node's own label part of its semantic identity? +Decided (developer, 2026-11-28). A node's label is not part of its semantic identity, +and no label enters the `I` chain. A node has one label. Declaring the same computation +again under another label replaces the earlier label: the most recent wins. -One slot feeding the same pod twice under labels `r1` and `r2`: one node or two? Today -they are one node and the smaller label is kept (`pipeline/base.py:360`). +So one slot feeding the same pod twice under labels `r1` and then `r2` is one node, +labelled `r2`; `job.nodes["r1"]` no longer exists. A label can be changed without +re-keying anything, because no identity holds it. Only a slot's name is identity (the +`I` leaf). -- (a) Not part: one node. `job.nodes["r2"]` does not exist, and a label the user wrote is - dropped without notice. -- (b) An explicitly assigned label is part: two nodes with one content identity. The - label must enter the `I` chain, not only the node's own hash, or the steps below `r1` - and `r2` would merge again: `I(node) = H(("label", label), pooled I)` when a label was - assigned, pass-through otherwise. A computed label never enters. +This changes `main`, where the smaller of two labels is kept whatever the order of +declaration (`pipeline/base.py:360`). One detail I assume and the developer should +confirm: a later declaration that gives no label leaves an assigned label in place. -Recommendation: (b). A slot's label is already its identity, so a step's assigned label -being identity is the same rule. Edges, restrictions and probes can then be attached to -`r1` and `r2` apart (ITL-1472). The cost is that a labelled step can no longer be renamed -after capture without re-keying what is below it, as for a slot, and that Q3's case -arises more often, which it must handle anyway. +The option not taken was to make an assigned label part of `I`, giving two nodes of one +content identity. ### Q2. A stream outside a job: how is its semantic identity formed? @@ -782,7 +801,7 @@ restricted; (c) works for some graphs and not others. ### 11.1 What cannot be made to hold -- **3.1** as stated: without a decision, two nodes merge (counterexample there). +- **3.1** held as first worded; it is settled by the decision there (`ctx_arg_name` in `P`). - **"`P` unchanged in value" together with "`P` holds no source"** (3.5): on `main` the pipeline hash of `Join` or `Rejoin` over two inputs of equal `P` depends on whether they are equal by content. One of the two statements has to give for that case; I From 78cfb1e925f2919b216a3ddff8dddacb4efa31a0 Mon Sep 17 00:00:00 2001 From: "Edgar Y. Walker" Date: Sat, 28 Nov 2026 13:42:53 -0800 Subject: [PATCH 3/5] docs(dev): record three-chain hash decisions (ITL-1559) --- docs/dev/specs/itl-1559-three-chain-hash.md | 1145 +++++++------------ 1 file changed, 414 insertions(+), 731 deletions(-) diff --git a/docs/dev/specs/itl-1559-three-chain-hash.md b/docs/dev/specs/itl-1559-three-chain-hash.md index 566105612..37ee58507 100644 --- a/docs/dev/specs/itl-1559-three-chain-hash.md +++ b/docs/dev/specs/itl-1559-three-chain-hash.md @@ -1,438 +1,230 @@ # Three-chain hash design for slot identity (ITL-1559) -Status: draft for the developer's review. Decisions of 2026-11-28 are marked "decided" -where they apply (3.1, Q1, the single walk of 2.3). No production code is changed by this document. -Measured on `main` at `c1040ffa` (2026-11-28). Related: ITL-1442, ITL-1427, ITL-1470, -ITL-1506, ITL-1472, ITL-1553, ITL-1554, ITL-1560, ITL-1590. +Design decisions recorded on 2026-11-28. Measurements in this document use `main` at +`c1040ffa` unless noted. Related work includes ITL-1442, ITL-1427, ITL-1470, ITL-1506, +ITL-1472, ITL-1553, ITL-1554, ITL-1560 and ITL-1590. ## 1. Summary -The developer decided (2026-11-28) that every node of a pipeline has three parallel chains, -computed separately and combined only where a hash is needed. +Every stream, invocation and node has three hashes. A node downstream of an unbound slot has +no usable content hash until the slot is bound. -| Chain | Leaf (a source slot) | Any other node, operation `op`, upstreams `u1..uk` | Combined | -|---|---|---|---| -| `P` structure | `H(schema)` | `H(op, P(u1)..P(uk))`: today's pipeline hash, unchanged in value | stored table paths, system-tag column names, as today | -| `C` sources | the bound source's identity | the upstreams' `C`, pooled in `P`'s input order | content identity `H(P, C)` | -| `I` names | the slot's name | the upstreams' `I`, pooled in the same order | semantic identity `H(P, I)` | - -- **Content identity** is what storage sees. It replaces today's content hash recursion. - Every node content hash value changes; slot names never reach storage. -- **Semantic identity** is the node as an object of the pipeline: graph keys, `job.nodes`, - edges, restrictions, the run plan. It holds no source, so it survives a rebind and an - unbound slot has it. - -What this document found, in short: - -1. The design holds. A read-only prototype over all 2,504 golden entries moves exactly 104 - of them: 102 content hashes of derived streams and nodes, and 2 default source ids of - derived sources. No pipeline hash, stored path, system-tag column name, record id, data - hash, instance id or result-table key moves (section 7). -2. Six points contradict the design as it is worded, or need a decision before it is - built (section 3). Two are counterexamples measured on `main`: - - Two inputs with equal `P` DO reach a commutative operator today: `Join` and `Rejoin` - accept two same-schema inputs when every data column is a data-tag. There the - pipeline hash itself depends on whether the two inputs are equal by content - (`Join(A, B)` and `Join(A, A)` have different pipeline hashes). So "`P` unchanged in - value" and "`P` holds no source" cannot both hold for that case (3.5). - - Today's content hash distinguishes a context-taking function pod from a plain pod - of the same uri, and `P` does not, so `H(P, C)` and `H(P, I)` would merge two nodes - that are two today (3.1). Decided: `ctx_arg_name` enters the pod's pipeline - identity. -3. Entry ids and instance ids do not contain the node content hash. They do not change. - Only record ids and the operator cache's row key do, and no golden entry pins either. -4. Most of the work is not hashing. It is moving about 40 places that use the content hash - as node identity onto semantic identity (section 5). - -## 2. Definitions - -### 2.1 Notation and labels - -`P(x)` is `x.pipeline_hash()` as today, with two changes, each for one narrow case: the -decision of 3.1 (a context-taking function pod) and the correction of 3.5 (a commutative -operator over inputs of equal `P`). - -Each new hash is defined in one module, proposed `src/orcapod/core/identity_chains.py`, and -carries its own label, defined there as a constant and written nowhere else (the hash label -rule): - -| Hash | Proposed label | Preimage | +| Hash | Definition | Use | |---|---|---| -| name leaf | `slot_name_v1` | `("slot", )` | -| pooled sources at a multi-input node | `source_chain_v1` | the ordered upstream `C` values | -| pooled names at a multi-input node | `name_chain_v1` | the ordered upstream `I` values | -| content identity | `content_identity_v1` | `(P, C)` | -| semantic identity | `node_identity_v1` | `(P, I)` | - -The procedure for all five is the semantic hasher's canonical form of the tuple (nested -hashes embedded with their labels), digested with SHA-256. Only the label differs. - -An alternative is to give all five the existing `semantic_v1` label, because the procedure -is the semantic hasher's. I recommend the new labels for one reason: a stored -`__node_content_hash` then says which rule produced it. A row written under today's -recursion carries `semantic_v1:`, a row written under this design carries -`content_identity_v1:`, and the two can never be confused or matched by accident. - -### 2.2 Leaves - -A leaf is anything with no producer. Its `P` is unchanged. Its `C` is its content hash as -it is computed today, unchanged (see 3.3 for why this is a recommendation and not a given). - -| Leaf | `P` | `C` | Notes | -|---|---|---|---| -| Root source (`ArrowTableSource`, `DictSource`, `ListSource`, `DataFrameSource`, `CSVSource`, `DeltaTableSource`, `SQLiteTableSource`, `PostgreSQLTableSource`, `DBTableSource`) | Arrow schema identity (`sources/base.py:481`) | `content_hash()`: `(source_id, schema identity, key columns)` (`sources/base.py:419`) | unchanged | -| `SpiralDBTableSource` | as above | root rule, then `tags_as_data` items when given (`spiraldb_table_source.py:693`) | a restriction is in no identity | -| `PollingSource` | schema | `(source_id, impl.identity(), sorted tag columns, key columns)` (`polling_source.py:430`) | provisional (ITL-1316) | -| `CachedSource` | the wrapped source's | the wrapped source's (`cached_source.py:258`) | transparent; its cache path keeps the source's content hash (`cached_source.py:292`) | -| `DerivedSource`, plain | schema | `H((content identity of the origin node,))` (`derived_source.py:325`) | the value moves, because the origin's content identity moves. It reads stored rows, so it takes the origin's CONTENT identity, never its semantic identity | -| `DerivedSource` with `tags_as_data` | schema | root rule, then the sorted mapping (`derived_source.py:326`) | unchanged; requires a `source_id` | -| `SourceProxy` | the saved pipeline hash (`source_proxy.py:215`) | the saved content hash (`source_proxy.py:197`) | unchanged; a delegate is accepted only with both equal (`source_proxy.py:125`) | -| Raw `ArrowTableStream` | schema identity (`arrow_table_stream.py:276`) | its table in canonical row order (`arrow_table_stream.py:223`) | unchanged; PR 613 refuses it as a job leaf | -| Slot, bound (`SourceJobNode` with a source) | the slot's declared schema | the bound source's `C` | today the slot already delegates (`source_node.py:1830`) | -| Slot, unbound (`SourceNode`, or `SourceJobNode` with none) | the slot's declared schema | none (3.4) | today its content hash is `("source_node", name, schema)` (`source_node.py:824`); that hash is retired | - -`I` of a leaf is `H(("slot", name))` where `name` is the slot's name. A source has an `I` -only through a slot. How a plain stream outside a job gets one is open question Q2. - -### 2.3 Other nodes - -The three chains are computed together, in one walk of the graph (developer, -2026-11-28). At each node the order of its upstreams is fixed once, by `P`, and `C` and -`I` are pooled in that same order, so that names and sources stay aligned position by -position. The only exception is a group of inputs with equal `P` at a commutative -operator (2.4). +| `pipeline_hash` | Schemas and steps, including each step's upstream structure | Stored paths and system-tag column names | +| `content_hash` | `H(pipeline_hash, source_chain)` | Stored rows, the `__node_content_hash` column, and record ids | +| `node_hash` | `H(pipeline_hash, name_chain)` | Graph keys, `job.nodes`, edges, restrictions, and execution bookkeeping | -For a node with producer `op` and upstreams `u1..uk`: +The switch replaces the existing node content hash values. Slot names never reach the +stored content hash. The node hash contains no source binding, survives a rebind, and +exists for an unbound slot. Two differently named slots can therefore feed separate +graph nodes that share stored rows. -- `P` = today's `pipeline_hash()`. -- `k = 1`: `C(node) = C(u1)` and `I(node) = I(u1)`, passed through unchanged. -- `k > 1`: `C(node) = H(source_chain_v1; C(u_π(1)), ..., C(u_π(k)))` and - `I(node) = H(name_chain_v1; I(u_π(1)), ..., I(u_π(k)))`, where `π` is the one input - order of 2.4. Repeats are kept: `[A, A]` differs from `[A]`. -- content identity = `H(content_identity_v1; P(node), C(node))`. -- semantic identity = `H(node_identity_v1; P(node), I(node))`. +In earlier notation, P meant pipeline structure, C meant the source chain, and I meant the name chain. -The pooled value is a hash of the upstream values, not a flat list of leaves. Section 3.2 -says why; the two are equivalent in what they tell apart. +## 2. How the chains are computed -A node whose ancestry holds an unbound slot has no `C` and no content identity (3.4). It -always has `P`, `I` and a semantic identity. +### 2.1 Hash labels and implementation -### 2.4 Input order, by operator +PR 633 puts the hashing and traversal in `src/orcapod/core/identity_chains.py`. +`IdentityChainsMixin` provides `source_chain()`, `name_chain()`, `node_hash()` and +the internal `_chain_content_hash()`. It is used by `StreamBase`, `SourceNodeBase` +and `PodInvocation`. `PodInvocation` also gains `pipeline_hash()`. +`IdentityWalk` visits upstreams and reuses per-element results. The `IdentityChains` +record in `protocols/hashing_protocols.py` stores the source and name chain results +as `sources` and `names` and defers evaluation of the structural hash when possible. +A walk for `name_chain()` or `node_hash()` can skip reading source bindings where +the structural order is available without them. -`argument_symmetry` decides the order (measured, every definition on `main`): +Each digest uses SHA-256 over the semantic hasher's canonical tuple, with nested +hashes embedded with their labels. The labels are defined in `core/identity_chains.py`. -| Producer | `argument_symmetry` | Order of `C` and `I` | +| Digest | Label | Preimage | |---|---|---| -| Every `UnaryOperator` (`Batch`, `GroupBy`, `TagBy`, `AddTags`, the Select/Drop column operators, `MapTags`, `MapData`, `MapColumns`, `PolarsFilter`, `Filter`, `DropNulls`, `Pick`, `Index`) | one-tuple (`operators/base.py:233`) | pass-through | -| `SemiJoin`, `MergeJoin`, any non-commutative `BinaryOperator` | tuple (`operators/base.py:343`) | argument order | -| `Join`, `Rejoin`, any commutative `BinaryOperator` | frozenset (`join.py:217`, `operators/base.py:343`) | canonical order, below | -| `FunctionPod`, `FallThroughPod`, a function node | the multi-stream handler's, a `Join` (`function_pod.py:861`, `:1957`); the pod stream itself has one input | pass-through. The join in front of a pod is its own node | -| `SideEffectPod`, a side-effect node | tuple of one (`side_effects.py:665`) | pass-through | - -No operator on `main` returns a nested or partly symmetric group; the only example is in -a docstring (`static_output_pod.py:259`, `:267`). The rule below extends to one: each -nested group is ordered by its own kind. - -Canonical order at a commutative operator: - -1. Inputs are ordered by `P` (hex text), as `Join` already orders them (`join.py:215`). - `C` and `I` both use this order. -2. Only inside a group of inputs with equal `P`: the `C` chain orders the group by `C` - and the `I` chain orders it by `I`. Each uses its own order and never the other's. - -**Can a tie of equal `P` occur on `main`? Yes.** The belief was that it cannot, because -`Join` refuses inputs that share a data column, which two same-schema inputs always do. -Measured, it can: - -- Commutative operators: `Join` and `Rejoin` only. `MergeJoin` and `SemiJoin` are ordered - (`is_commutative` is `False`, `merge_join.py:169`, `semijoin.py:322`). A function pod - over several inputs goes through a `Join`. -- Two same-schema inputs with a plain data column are refused by both - (`InputValidationError`, "Datas should not have overlapping keys"), also when the - inputs additionally have data-tags. -- Two same-schema inputs whose every data column is a data-tag (a source with - `tag_columns` naming every column and `tag_only_columns=False`) are **accepted** by - both, as plain streams and in a job: `Join(A, B)`, `Join(A, A)`, `Rejoin(A, B)`, - `Rejoin(A, A)`. A shared data-tag is a join key, not a collision. - -So the per-chain tie rule is needed for an exported operator now, not only for a future -one. The test that pins the state of `main` is in 9.1. - -How `main` places two inputs with equal pipeline hash in system-tag column names: - -- `Join` sorts its inputs by pipeline hash (`join.py:215`) with a stable sort, so tied - inputs take canonical positions `:0` and `:1` in argument order - (`_tag_source_id::::

:0` and `...:1`, `join.py:432`). The names are the same - for either argument order, since both inputs give the same text. The VALUES are then - sorted per row across the tied columns, so `Join(A, B)` and `Join(B, A)` give identical - tables (`dict_v1:A` in `:0`, `dict_v1:B` in `:1` both ways; measured) and identical - content and pipeline hashes. -- `Rejoin` keeps the system-tag columns unchanged, so there is one pair and no position. -- `MergeJoin` uses the argument index (`merge_join.py:348`): `MergeJoin(A, B)` has `A` in - `:0`, `MergeJoin(B, A)` has `B` in `:0`, and nothing is sorted. - -The per-chain tie rule agrees with what `Join` already does to values: within a tie it -sorts the sources by value, without regard to which argument they came from. - -### 2.5 Job nodes against plain streams - -- A plain stream and the job node made from it have equal `P` (today's rule, and the - subject of ITL-1470) and equal `C`, so equal content identity. The node additionally - has `I`. -- `PodInvocation` (`pipeline/pod_invocation.py:73`) mirrors the stream's identity - structure and has no `pipeline_hash()` of its own today. It needs `P`, `C` and `I` like - a node, since the graph is keyed by invocations. -- A loaded node with no pod keeps returning its saved `P` (`function_node.py:574`, - `operator_node.py:320`). Its `C` comes from its upstream nodes, so its content identity - can be recomputed without the pod (section 11.3). - -### 2.6 What each identity is used for - -| Use | Identity | -|---|---| -| Table paths, system-tag column names, `invocation_hash`, layout scoping | `P` | -| `__node_content_hash`, record id, operator cache row key, `as_source()` default id, stored views, run URI | content identity | -| Graph keys, `job.nodes`, edges, restrictions, run plan, held rows, staleness, saved-file node keys, diagram, observers' node key | semantic identity | -| A source as a dataset: registration, one-object rule, cache path | the leaf's `C` | - -## 3. Points that contradict the wording, or need a decision - -### 3.1 `P` does not hold everything today's content hash holds about the operation - -A function pod's content identity is `(data_function, ctx_arg_name)` when it takes the -invocation context, and its pipeline identity is `data_function` alone -(`function_pod.py:178`, `:183`). Two pods can share one uri and differ in that -(`tests/test_hashing/test_wrong_hash_findings.py:759` pins that a -`side_effect_function_pod` and `function_pod(ctx_arg=...)` give one uri). - -Counterexample, measured: a plain pod and a context-taking pod with one function name, -one output schema and one major version, over one source. - -| | plain | context-taking | +| Name leaf | `slot_name_v1` | `("slot", name)` | +| Multi-input source chain | `source_chain_v1` | Ordered upstream source chains | +| Multi-input name chain | `name_chain_v1` | Ordered upstream name chains | +| Content hash at the switch | `content_hash_v1` | `(pipeline_hash, source_chain)` | +| Node hash | `node_hash_v1` | `(pipeline_hash, name_chain)` | + +### 2.2 Leaves and node labels + +A slot contributes its declared Arrow schema to `pipeline_hash`, its bound source's +identity to `source_chain`, and its slot name to `name_chain`. PR 633 uses the +source's existing identity digest as the source-chain leaf. The declared slot schema +and the source's own schema can differ, for example when a non-nullable source is bound +to a nullable slot. A change in source schema or key columns can then distinguish two +readings of one dataset. + +| Leaf | Pipeline structure | Source-chain contribution | |---|---|---| -| pod pipeline hash | equal | equal | -| pod content hash | differs | differs | -| stream `P` | equal | equal | -| stream content hash today | differs | differs | -| pipeline table path | `shared_name/.../schema:c481…` | `side_effect_function/shared_name/.../schema:c481…` | - -Today a job holds two nodes. Under the design both `H(P, C)` and `H(P, I)` are equal, so -the graph would keep one node and drop the other, and every node below them merges too. -Storage does not collide, because the node kind puts the two in different tables. - -This is the only such case. Every operator and `SideEffectPod` uses one structure for both -hashes (`static_output_pod.py:223`, `side_effects.py:657`), and a data function's two -structures are both its uri (`data_function.py:241`). - -**Decided (developer, 2026-11-28): option (a).** `ctx_arg_name` enters the function -pod's pipeline identity when it is set, so that `P` describes the operation completely. -`P` then moves for every node at or below a context-taking pod, and with it their -`schema:

` path component. No golden entry holds such a pod (`cases.py` has no -`ctx_arg`), so no golden value moves. `P` is unchanged everywhere else. The two options -not taken were to refuse two pods of one uri that differ in `ctx_arg_name` in one job, -and to carry the difference in both `C` and `I`. - -**General provision (developer, 2026-11-28).** A node MAY contribute a term of its own -to `C` or to `I`. No node does today: every node other than a leaf only pools its -upstreams' values. Two rules bound such a term: - -- Anything that tells apart two nodes that can sit in one graph must be in `P` or in - `I`. Semantic identity `H(P, I)` is the graph's key, so a difference held only in `C` - would leave two nodes with one key. -- A term in `C` only must be like a binding: one value per node at a time. It may change - (as a bind changes a slot's source), and the node stays the same node when it does. - -A node that contributes a term hashes it with its pooled value, also when it has one -input, so the pass-through of 2.3 holds only for a node with no term of its own. - -### 3.2 A flat pooled list grows exponentially - -The table says "pooled `C` of the upstreams". As a flat list of leaves with repeats, a -node's `C` has one entry per path to a root. `k` diamonds in sequence (split, two -branches, rejoin, repeated) give `2^k` entries: 20 diamonds give 1,048,576 entries at -every node below. The diamond over one slot is the case this design is for. - -Proposal: pool by hashing (2.3). Given `P`, which fixes the shape of the graph and so the -number of leaves under each input, the hash of the ordered upstream values tells apart -exactly what the flat list does, and each node holds one fixed-size value. I treat this -as part of the design unless the developer objects. - -### 3.3 The `C` leaf: reuse the source's content hash - -The table gives the leaf as "source id, key columns". A source's content hash today also -holds its Arrow schema identity. I recommend the leaf be that existing hash, unchanged: - -- no root source content hash moves (165 golden entries stay; section 7); -- `CachedSource` paths, `SourceProxy` checks and the one-object rule of PR 577 keep - working on the value they use now; -- it stays what ITL-1506 calls the reading: source id, schema, key columns. - -The schema is then in both `P` (the slot's declared schema) and `C` (the source's own). -They can differ: a source with a non-null column bound to a slot that declares it -nullable. That is a different reading and should give a different `C`, which it does. - -### 3.4 An unbound slot has no content identity - -Today an unbound slot's content hash is `("source_node", name, schema)`, so the slot name -is in a content hash, and PR 613 keeps that ("the slot name contributes to the content -hash of an unbound slot"). Under the design the name belongs to `I` only. - -Proposal: `C` of an unbound slot does not exist, and neither does the content identity of -any node below it. Asking for it raises a dedicated error naming the unbound slots. A run -never needs it, because a run leaves out everything below an unbound slot -(`job.py:1313`). A saved file writes `null` for it. I recommend against a placeholder -value: a placeholder could reach storage, and a name in a content identity is what the -design removes. - -### 3.5 `P` depends on content equality at a commutative operator (measured on `main`) - -Filed as ITL-1590. - -A commutative operator returns `frozenset(streams)` (`join.py:217`, -`operators/base.py:346`). A Python frozenset drops equal members, and streams are equal -by content. So the pipeline hash of a commutative operator over two inputs with equal -`P` holds two items when their content differs and one when it is equal. - -Measured, with sources `A` and `B` of one schema whose data columns are all data-tags -(2.4), and `A'` a second object equal to `A`: - -| | pipeline hash | content hash | system-tag columns | -|---|---|---|---| -| `Join(A, B)`, `Join(B, A)` | `6b73c2cd…` | `a6438908…` | `…:0`, `…:1` | -| `Join(A, A)`, `Join(A, A')` | `407cfb1d…` | `b4179856…` | `…:0`, `…:1` | -| `Rejoin(A, B)`, `Rejoin(B, A)` | `89d2805a…` | `d09a5c5a…` | one pair | -| `Rejoin(A, A)`, `Rejoin(A, A')` | `384d909d…` | `dd773c9f…` | one pair | - -Two pipelines with one structure and one schema get two pipeline hashes, so two table -paths, depending only on whether the two slots hold the same source. That breaks the -rule that the pipeline hash ignores data content, on `main`, today. It is also exactly -the case of this design: two slots of one schema bound to one source, then joined. - -Under the design it cannot stand: `P` must hold no source, and when nodes stop being -equal by content the set would drop members by some other equality. `P`, `C` and `I` must -each be built from the inputs as a list (a multiset), never from a set of stream objects. -PR 587's positioned edges (`pipeline/edges.input_positions`) give that list. - -Consequence the developer must accept: "`P` unchanged in value" cannot hold for this one -case. With a multiset, `Join(A, A)` takes the value `Join(A, B)` has today (two items), -so the pipeline hash, and the table path, of a commutative operator over inputs that are -equal by content AND have equal `P` moves, with everything below it. Every other -pipeline hash is unchanged, because inputs with distinct `P` are never dropped. No golden -entry holds such a case (all 179 golden pipeline hashes stay). It is a hash change and -needs the developer's approval as one. - -### 3.6 Entry ids and instance ids are not content identity - -The task statement lists entry ids among what `H(P, C)` feeds. They are not fed by it. An -entry id is the hash of the user tags, system tags and input data hash -(`row_ids.py:60`); an instance id adds the source-info tokens (`row_ids.py:95`). Neither -holds the node content hash, so neither changes. The node content hash enters the record -id (`row_ids.py:136`), the `__node_content_hash` column, and the operator cache's row -key (`operator_node.py:1455`). That is consistent with the design; only the wording -differs. +| Root source, including Arrow, in-memory, file and database sources | Arrow schema | Source id, source schema identity, and record-id key columns | +| `SpiralDBTableSource` | Arrow schema | Root identity with the `tags_as_data` mapping when given. Restrictions are outside the hashes | +| `PollingSource` | Arrow schema when known | Source id, implementation identity, sorted tag columns, and key columns. Its identity is provisional (ITL-1316) | +| `CachedSource` | Wrapped source's structure | Wrapped source's identity. Its cache address follows the source identity | +| Plain `DerivedSource` | Arrow schema | Derived source identity uses the origin node's `content_hash`. An unbound origin leaves the source chain absent | +| `DerivedSource` with `tags_as_data` | Arrow schema | Root identity with the sorted mapping. This form requires a `source_id` | +| `SourceProxy` | Saved pipeline hash | Saved source identity. A delegate must match the saved source and pipeline identities | +| Raw `ArrowTableStream` | Arrow schema | Legacy digest of the canonically ordered table, when available | +| Unbound slot | Declared Arrow schema | Absent | + +**DQ2.** Outside a slot, the plain stream's name-chain leaf is the source's label. +A follow-up issue will re-evaluate this rule. PR 633 currently uses `RootSource.source_name` +for an uncaptured root source and an anonymous term for a raw Arrow stream. Its +`slot_name_for()` helper also uses `source_name` for an implicit root slot. +The slot's name, once assigned, is the slot's leaf. + +A node's display label enters none of its chains. A node has one label. Declaring the +same computation again with a label replaces the earlier label. A declaration that +omits a label preserves the most recently given label. For example, declaring the same +step as `r1`, then `r2`, then without a label leaves one node displayed as `r2`. +Slot names are separate from step labels. + +**BL16 (a).** In step 3, steps without labels that receive the same automatic name +are numbered in `node_hash` order. Add a sentence documenting that rule. + +An unbound slot and its downstream nodes have a name chain and a node hash. +`source_chain()` returns `None`. Asking for the combined content hash raises +`UnboundSourceError` naming the unbound slots. A run leaves those branches out. +The saved file can represent the absent current content hash as `null`. + +### 2.3 One walk and input order + +Compute the chains together in one graph walk. At a single-input node, both upstream +chains pass through unchanged. At a multi-input node, hash the upstream chains in the +order fixed by the pipeline hash. Keep every occurrence, including repeats. + +| Producer | Input order | +|---|---| +| Unary operators, function pods and side-effect pods | Pass through their one input. A function pod over several streams has a separate join node before it | +| Ordered operators, including `SemiJoin` and `MergeJoin` | Argument order | +| Commutative operators, including `Join` and `Rejoin` | Canonical structural order. Within a group of equal pipeline hashes, sort the source chains by their own values and the name chains by theirs | + +For nested symmetry, each group uses the rule for its own kind. PR 633 obtains the +grouping from `argument_symmetry` via `encode_input_symmetry()`, retains input +positions, and sorts structural keys in `_pool_group()` by the canonical JSON of +the nested pipeline hashes. Inside a structural tie the implementation sorts each +chain by its labelled hash value. In step 1 the old pipeline hash remains in use, +so a legacy set that collapses equal inputs makes the combined hashes undefined. +Step 2b replaces that dependency with the input list. + +Equal-pipeline-hash inputs occur on `main`. Two inputs of one schema can reach +`Join` or `Rejoin` when all their data columns are data-tags. A shared ordinary data +column causes both operators to refuse the pair. A shared data-tag acts as a join key. +`MergeJoin` uses the argument index in system-tag names. `Rejoin` retains the input +system-tag names. + +A node may contribute its own term to either chain. No node does so today. +`_identity_terms()` supplies those optional terms in PR 633. If supplied, the term +is hashed with the pooled value, including for a single input. Anything that +distinguishes nodes that can coexist in one graph must be represented in +`pipeline_hash` or `name_chain`. A term only in `source_chain` must behave like +a binding, with one value per node at a time and the freedom to change without re-keying +the graph. + +### 2.4 Step 1 limits in PR 633 + +- A name-only walk normally avoids reading source identities. Legacy commutative + symmetry can still require an input content digest. A cold polling source in + such a group, or a lazy input requiring a row build, can make the new accessors + fail in step 1. A raw Arrow leaf can return `node_hash()` from its schema and + anonymous name, and its source chain can reuse a previously memoized digest. +- A polling leaf or a cached polling leaf can use a pending-schema structural term + for `node_hash()` before its schema is known. This is an implementation exception + to the final formula. The combined content hash and downstream identities that need + its pipeline hash require the schema. Source-chain access reuses a warm source + digest and refuses to call the polling implementation to obtain a missing one. +- A loaded built-in operator with one input can use its saved pipeline hash and + pass through both chains even when the implementation is unavailable. An + unavailable operator with several inputs needs its input symmetry to reconstruct + the chains. The step 1 saved form does not carry that symmetry. Custom operators + also leave the new accessors undefined in step 1. +- Transparent wrappers and row builds representing an existing stream delegate to + the underlying stream for the chains. A plain stream and the job node compiled from + the same computation are intended to agree on structure and source chain, subject + to the capture and saved-form limits above (ITL-1470). + +## 3. Pipeline hash changes and row ids + +### 3.1 Context-taking function pods (D29) + +Step 2a (PR 634) gives a function pod that takes the invocation context its own +pipeline hash. `FunctionPod.pipeline_identity_structure()` uses +`(self.data_function, self._ctx_arg_name)` when the name is set and the data +function alone otherwise. This distinguishes two operations with the same underlying +function URI and propagates to the downstream `schema:` path +component, system-tag names that embed the affected hashes, and invocation keys. +The prototype held no context-taking pod golden case. + +**D29 (a)** is a breaking change. An upgraded live job does not detect the prior +completion and result stores and the pod delivers once more for previously processed +inputs whose completion or result was recorded there. The stored table format is +unchanged. PR 634 also scopes result cache paths by +the context parameter via `context_result_path()`. Its saved-job descriptor records +`result_record_path` for context-taking pods without changing the format marker. +Saved jobs can still read results at their recorded or legacy paths when those stores +are retained. This is separate from completion lookup by a live upgraded job. + +### 3.2 Commutative input lists and tied joins (D32) + +Step 2b computes a commutative operator's pipeline hash from the input **list**, +preserving multiplicity. It builds on the positioned inputs in PR 587 +(`pipeline/edges.py`, including `input_positions`). + +On the measured baseline, a commutative `argument_symmetry` returns a frozenset of +streams, which drops members equal by content. Two equal-pipeline-hash inputs can +therefore yield different pipeline hashes depending on whether the sources are equal +(ITL-1590). For the measured all-data-tag join, `Join(A, B)` and `Join(B, A)` +gave the same pipeline hash, while `Join(A, A)` and `Join(A, A')`, with `A'` an +equal object, gave another. With the input list, all four use the same structural +preimage with two occurrences of the input hash. The historical prototype pinned no +case with collapsed inputs. + +**D32 (a).** Fix the tied-join faults in step 2b because that step rewrites ordering +within an equal-pipeline-hash group: + +- A tied `Join` can pair a custom system tag with another input's ids by argument order. +- With three tied inputs, row channels and the sync table can disagree. +- Record-id nullability can differ between yielded rows and the table. + +The developer approves the exact list of values that move before any golden value is +regenerated for step 2b. + +### 3.3 Row identifiers + +The node content hash enters the record-id preimage (`core/row_ids.py`), the +`__node_content_hash` column, and the operator cache's row key. Entry ids are computed +from user tags, system tags and the input data hash. Instance ids add the source-info +tokens. Neither directly includes the node content hash. Changes to the inputs of +entry or instance ids, such as a changed system tag or derived source token, can still +affect them. ## 4. Worked examples -Mock values. `P:`, `C:`, `I:` are the three chains; `ci:` is content identity and `ni:` -semantic identity. `S` is a schema, `f`, `g` are function pods. - -### 4.1 A chain +Let `x` and `y` be slots with one declared schema, `A` and `B` be source +identities, and `f`, `g` and `h` be pods. -Slot `x` bound to source `A`; `x -> f -> g`. - -| Node | `P` | `C` | `I` | `ci` | `ni` | -|---|---|---|---|---|---| -| `x` | `P:11` = `H(S)` | `C:aa` (source `A`) | `I:x1` = `H("slot","x")` | the source's own | `ni:01` = `H(P:11, I:x1)` | -| `f` | `P:22` = `H(f, P:11)` | `C:aa` | `I:x1` | `ci:c2` = `H(P:22, C:aa)` | `ni:02` = `H(P:22, I:x1)` | -| `g` | `P:33` = `H(g, P:22)` | `C:aa` | `I:x1` | `ci:c3` = `H(P:33, C:aa)` | `ni:03` = `H(P:33, I:x1)` | - -`C` and `I` pass through unchanged; `P` alone tells `f` from `g`. - -### 4.2 A diamond over one slot - -`x` (source `A`) feeds `f` and `h`; `Rejoin(f, h)`. - -| Node | `P` | `C` | `I` | -|---|---|---|---| -| `f` | `P:22` | `C:aa` | `I:x1` | -| `h` | `P:44` | `C:aa` | `I:x1` | -| `Rejoin` | `P:55` = `H(Rejoin, {P:22, P:44})` | `C:d1` = `H([C:aa, C:aa])` | `I:d1` = `H([I:x1, I:x1])` | - -The repeat is kept: `C:d1` differs from `C:aa`. The order is by `P` (`P:22` before -`P:44`); no tie. - -### 4.3 Two slots with one schema over one source - -Slots `x` and `y`, both bound to `A`; `x -> f -> g` and `y -> f -> g`. This is ITL-1442. - -| Node | `P` | `C` | `I` | `ci` | `ni` | -|---|---|---|---|---|---| -| `f` under `x` | `P:22` | `C:aa` | `I:x1` | `ci:c2` | `ni:02` | -| `f` under `y` | `P:22` | `C:aa` | `I:y1` | `ci:c2` | `ni:12` | -| `g` under `x` | `P:33` | `C:aa` | `I:x1` | `ci:c3` | `ni:03` | -| `g` under `y` | `P:33` | `C:aa` | `I:y1` | `ci:c3` | `ni:13` | - -Two `f` nodes and two `g` nodes with distinct edges. Equal content identity: both write -the same table under the same `__node_content_hash`, so the same stored rows. How the -second node avoids a second write is Q3. - -### 4.4 The same over two sources - -`x` bound to `A`, `y` bound to `B`. - -| Node | `C` | `ci` | `ni` | -|---|---|---|---| -| `f` under `x` | `C:aa` | `ci:c2` | `ni:02` | -| `f` under `y` | `C:bb` | `ci:e2` | `ni:12` | - -Same `P`, so one table; different `__node_content_hash`, so the rows are told apart, as -today. The semantic identities are those of 4.3: the graph did not change. - -### 4.5 A commutative join of two inputs with equal `P` - -`Join` over slots `x` and `y` of one schema whose data columns are all data-tags (the -case of 2.4), `x` bound to `B`, `y` to `A`. Take `C:aa < C:bb` and `I:x1 < I:y1`. - -- `P(K) = H(Join, [P:11, P:11])`, two items whatever the slots hold (3.5). -- `C(K) = H([C:aa, C:bb])`: ordered by `C`, so `y`'s source comes first. -- `I(K) = H([I:x1, I:y1])`: ordered by `I`, so `x` comes first. - -The two chains order the group differently, and that is intended: swapping which slot -holds which source changes neither `C(K)` nor `I(K)`, which is what commutative means. -What it costs is 10.1. - -### 4.6 A rebind - -4.1, then `job.bind(sources={"x": B})`. - -| Node | before | after | -|---|---|---| -| `f` `ci` | `ci:c2` = `H(P:22, C:aa)` | `ci:e2` = `H(P:22, C:bb)` | -| `f` `ni` | `ni:02` | `ni:02` | -| `f` table path | `.../schema:22` | `.../schema:22` | - -Graph keys, `job.nodes`, edges and restrictions keep their keys. The content identity -follows the bind at every depth, which is the goal of ITL-1427. Rows stored before keep -`ci:c2`; rows stored after carry `ci:e2`. - -### 4.7 An unbound blueprint - -4.1 with `x` unbound: every node has `P` and `ni` as in 4.1, and no `C` or `ci`. The -blueprint's node keys equal the job's node keys, so the remapping between the two that -`as_pipeline` does today (`job.py:816` to `:841`) is no longer needed. +| Graph | Chain and hash result | +|---|---| +| `x -> f -> g`, with `x` bound to `A` | All three nodes share the source leaf for `A` and name leaf for `x`. The pipeline hash distinguishes each step | +| Diamond `x -> (f, h) -> Rejoin` | The join hashes both occurrences of the source leaf for `A` and both occurrences of the name leaf for `x`, in the order of the branches' pipeline hashes | +| `x -> f -> g` and `y -> f -> g`, both bound to `A` | Each pair of corresponding steps has equal pipeline and content hashes but distinct node hashes. Each pair shares stored rows | +| Same branches, `x` bound to `A` and `y` bound to `B` | Each pair still shares a pipeline hash and table path. Their content hashes distinguish the rows. Their node hashes are the same as before | +| `Join(x, y)` with equal structural inputs, `x` bound to `B`, `y` to `A` | The pipeline hash includes two equal input hashes. If the source hashes sort as `A, B` and the name hashes as `x, y`, the source chain orders `y` first and the name chain orders `x` first. Swapping the two bindings yields the same pair of chains | +| `x -> f -> g`, then `job.bind(sources={"x": B})` | The node hashes, graph edges, restrictions and default table paths stay stable. Each downstream content hash incorporates `B`, and earlier rows keep the content hash under which they were written | +| `x -> f -> g` in an unbound blueprint | Node keys match the bound graph's node keys. The source chain and the live content hash are absent | ## 5. Inventory Every line is `src/orcapod/` at `c1040ffa`. -### 5.1 Content hash used as node identity: moves to semantic identity +### 5.1 Graph keys move to `node_hash` | Place | What it does | |---|---| | `core/base.py:178`, `:189` | `__hash__` and `__eq__` of every stream, node and invocation: content hash and identity structure. Every node-keyed dict and set below goes through these | | `pipeline/base.py:341`, `:344` | `_record_invocation`: the invocation's key and its upstream keys in `_hash_graph`, `_invocation_lut`, `_source_streams` | -| `pipeline/base.py:360` | `_remember_invocation`: two invocations with one key become one node, keeping the smallest label. Under Q1 they stay one node and the most recent label is kept | +| `pipeline/base.py:360` | `_remember_invocation` used to keep the smallest label for one key. Keep the most recently given label under the new rule | | `pipeline/base.py:519`, `:522` | compile: leaves found and ordered by hash key | | `pipeline/base.py:578` | compile: a node's upstream nodes looked up by the input's content hash | | `pipeline/base.py:611` | compile: equal labels numbered in content hash order | @@ -450,17 +242,16 @@ Every line is `src/orcapod/` at `c1040ffa`. | `pipeline/sync_orchestrator.py:108`, `:109`, `:114` | `outputs`, `processed` and `held_streams` keyed by node | | `pipeline/async_orchestrator.py:230` to `:274` | edge maps, output channels, edge readers, collectors, held rows keyed by node | | `pipeline/node_run.py:276` to `:280` | `RunPlan.held`, `held_counts`, `held_rows` keyed by node | -| `core/nodes/source_node.py:1534`, `:2187` | a leaf that is not a source is named `

` component of pipeline, operator cache and side-effect log paths | +| `function_node.py:668`, `operator_node.py:534`, `side_effects.py:1203` | the `schema:` component of pipeline, operator cache and side-effect log paths | | `join.py:215`, `:432`, `:485`, `:496`; `streaming_joins.py:691`, `:716`, `:1525`; `merge_join.py:348`; `batch.py:198`, `:232`; `group_by.py:555`, `:731`; `operator_node.py:2391` | canonical input order and system-tag column names | -| `side_effects.py:208`, `:989`, `:1288`, `:1543`; `function_pod.py:218` | `invocation_hash` (`P :: entry id`) | -| `static_output_pod.py:991`, `:1924`; `semijoin.py:319`; `index.py:140`; `pick.py:151` | per-input caches and declared forms keyed by `P` | +| `side_effects.py:208`, `:989`, `:1288`, `:1543`; `function_pod.py:218` | `invocation_hash` combines the pipeline hash and entry id | +| `static_output_pod.py:991`, `:1924`; `semijoin.py:319`; `index.py:140`; `pick.py:151` | per-input caches and declared forms keyed by pipeline hash | | `pipeline/provenance.py:447`, `:479`, `:516`, `:1198` | finding an input's system-tag columns | -| `pipeline/graph.py:227`, `pipeline/base.py:653`, `:680`; `sources/base.py:462`; `source_proxy.py:131` | saved and compared as is | +| `pipeline/graph.py:227`, `pipeline/base.py:653`, `:680`; `sources/base.py:462`; `source_proxy.py:131` | saved and compared pipeline hashes | -## 6. The stopgap refusals of PRs 577, 608 and 613 +## 6. Source registration and shared storage -PRs 608 and 613 are each stacked on 577. +**D31 (a).** PR 577 introduced an interim rule that refuses a second source object +with the same content hash in one job (`InconsistentSourceError`). Step 6 lifts both +two-slot refusals: -| Refusal | PR | Under this design | -|---|---|---| -| Two different source objects with one content hash in a job (`InconsistentSourceError`) | 577 | **Stays**, reworded: one object per source identity (leaf `C`). Equal `C` must mean the same rows, and nothing in the chains checks that. What changes is that the one object may fill several slots. Relaxing it is ITL-1553 | -| One source id with different Arrow schemas or key columns | 577 | **Unnecessary once each reading has its own slot name**: the readings differ in `C` and in `I`. Stays for two readings that would share a slot name (ITL-1506) | -| Capture refused once any slot is re-bound or unbound | 577 | **Unnecessary**. A recorded step's key is `H(P, I)`, which a bind does not touch, so capture after a bind is well defined | -| A prebuilt stream over the job's own slot refused | 577 | **Unnecessary if Q2 is answered so that a plain stream and the job agree on the slot**; otherwise stays | -| A slot object of another job, or a standalone one, refused | 577 | **Stays**. It is about who owns a mutable slot object (questions 9 to 11 of ITL-1559), which no hash answers. The design makes the remedy possible: a slot is a name and a schema, so the receiving job can make its own | -| Capture into, or recompiling, a loaded job refused | 608 | **Stays**. A loaded job has no recorded invocations; that is ITL-1560. Section 11.3 says what the saved file should hold so that this can be lifted later | -| Two slots reading one source identity refused (`_require_distinct_slot_bindings`), and "one source identity would fill slots X and Y" at capture | 613 | **Unnecessary**. This is the case the design exists for | -| A captured slot cannot be renamed | 613 | **Stays for now**. The name is the `I` leaf; a rename re-keys every node below. Possible later as an explicit graph operation | -| Duplicate slot labels, and a slot label equal to a step label, refused | 613 | **Stays, and becomes load-bearing**: two slots with one name and one schema would have one semantic identity | -| A leaf that is not a source (a raw stream, a joined stream) refused | 613 | **Stays** (ITL-1127); such a leaf has no name | - -Build on: PR 577 (the prepare phase that lets every tracker refuse before any records; -`source_consistency.py`; the one-object registration) and PR 613 (slot names from labels, -`as_slot`, label-keyed `bind`, `job.nodes` and saved jobs, ordered inputs in saved -files). PR 613's slot name is exactly the `I` leaf. PR 587 (positioned edges, ITL-1419) -gives the input list that 3.5 needs. PR 608 is independent of the hashing and can land -before or after. - -Take out when building: `_require_distinct_slot_bindings` and the capture-time slot -collision of 613, the "slots are not as captured" check of 577, and 613's rule that an -unbound slot's content hash holds its name. +| Binding in one job | Step 6 result | +|---|---| +| One source object on two differently named slots | Both slots are accepted | +| Two equal source objects on two differently named slots | Both slots are accepted. This is a step 6 acceptance test | +| Two source objects that would take the same slot name | They refer to one slot | + +A later direction is to check equivalence between source objects within a job according +to the source kind. That work is separate from this series. Equal source identities +rely on the source's contract to identify the same reading. The chains cannot establish +row equivalence by themselves. + +**DQ1.** Two nodes with equal `content_hash` share stored tables. The second writer +finds the first writer's rows and writes only missing rows. Apply this to pipeline +writes and operator-cache writes, including concurrent writers. Pipeline writes +need to check for an existing instance within the table and node content hash. +The record id includes a result id, so a record-id uniqueness check alone can miss +duplicates from concurrent computation. The operator cache key `_record_hash` +already covers the row. The exact synchronization mechanism remains open. + +Other slot and capture behavior from PRs 577, 608 and 613: + +- Different readings of one source id, such as different key columns, can occupy + distinctly named slots. Readings that would take the same slot name still refer + to one slot (ITL-1506). +- A recorded step retains its key after a rebind. Step 6 can remove the capture-after-bind + refusal. Removing the refusal for a prebuilt stream over the job's own slot also + depends on capture matching the slot correctly. The capture rule for prebuilt + streams remains open (ITL-1470 and ITL-1387). +- Foreign or standalone mutable slot objects, captured slot renames, and a slot + label that collides with a step label remain subject to the existing refusals. + A rename changes the name chain and would require an explicit graph operation. +- A captured leaf must be a source, and a slot binding must have its own source + identity without depending on another slot. Composite bindings are separate work + (ITL-1127). +- Capture and recompilation of a loaded job remain separate work (ITL-1560). + Step 4 prepares the graph with stable keys and ordered inputs. ## 7. Golden entries -Derived by reading the golden folder and the manifest, and confirmed with a read-only -prototype kept outside the repository: it computes every golden case twice, once as on -`main` (2,504 entries, none differing from the files) and once with the content hash of -every derived stream, node and invocation replaced by `H(P, C)` as in section 2, and -compares. The generator was not run and no golden file was touched. +A read-only prototype computed all 2,504 golden entries on the measured baseline, +then recomputed them with `H(pipeline_hash, source_chain)` for derived streams, nodes, +and invocations. It retained the existing leaf digests and pipeline hashes for that +comparison. It neither ran the generator nor edited the golden files. -### 7.1 What moves: 104 entries +### 7.1 The prototype moved 104 entries | File | Entries | Class | Reason | |---|---|---|---| | `pipeline-02.json` (open revision, frozen at 0.4.0) | 25 | `content_hash` of a derived stream or job node | the definition is replaced | | `provisional/pipeline.json` | 77 | the same, in cases that use a provisional operator | the same | -| `provisional/pipeline.json` | 2 | default source id of `node.as_source()` | it holds the origin node's content identity | +| `provisional/pipeline.json` | 2 | default source id of `node.as_source()` | it holds the origin node's content hash | `pipeline-02.json`, 25 entries, all `.content_hash`: `column_selection.drop_data`, `column_selection.drop_tag`, `column_selection.select_data`, @@ -566,17 +372,14 @@ compares. The generator was not run and no golden file was touched. `provisional/pipeline.json`, 2 entries: `default_source_ids.as_source[function_node].source_id` and `default_source_ids.as_source[operator_node].source_id`. -After PR 609 two more move with them: the two `content_hash` entries it adds for the -plain derived sources, which hold the origin's content identity. The list must be -computed again on the final base before it is put to the developer. +After PR 609 two more move with them. These are the two `content_hash` entries it adds +for the plain derived sources, which use the origin node's content hash. Pairs that are equal today stay equal: `rejoin.two` and `rejoin.two_reordered`, `rejoin.three` and `rejoin.three_reordered`, and the three arrangements of each `group_by_arrangement` and `rejoin_arrangement` variant. -### 7.2 What must not move, and does not - -Checked entry by entry in the prototype; no violation. +### 7.2 Entries that stayed stable in the prototype | Class | Entries checked | |---|---| @@ -595,8 +398,8 @@ Source-info tokens: no golden row sits below a default-named derived source, so moves. Outside the golden files, a token that names such a source does move, with the source id. -Not pinned by any golden entry, and moving: record ids (they hold a random result id) and -the operator cache's `_record_hash`. +Record ids and the operator cache's `_record_hash` move at the switch. The golden +files do not pin those keys. The pinned `_tag_record_id` values above are system tags. ### 7.3 Other hard-coded values @@ -604,280 +407,160 @@ Nine test files outside the golden folder hold 64-hex literals, and 184 test fil `content_hash()`. Each must be read when the definition changes (grep `tests/` and `test-specification/` for 64-hex literals and run those files before reporting). -## 8. Implementation plan - -The developer wants this system built first and used for every slot, edge and -source-binding issue (2026-11-28). 8.1 is the steps, 8.2 what happens to the open PRs, -8.3 what each issue gets from the chains and what is left. +### 7.4 Approval and freeze -### 8.1 Steps +V1 hashes and stored layouts freeze with the 0.4.0 release on 2026-12-07, subject +to the repository's existing provisional identity rules. Step 5 requires the +developer's approval of the exact golden entries that move, each with an explanation. +Recompute the list on the final base after PR 609. The prototype moved 104 of 2,504 +entries, rising to 106 after the derived-source additions in PR 609. These counts +describe the prototype and do not substitute for the approval list. -Each step keeps the suite green. Sizes are of the production diff. +**BL13 (a).** Add golden pins for data-tag identities after step 5 and before the +0.4.0 freeze. -| Step | Content | Golden | Size | -|---|---|---|---| -| 0 | Merge PR 577, then 608 and 613 (8.2). PRs 607 and 615 can land at any time before step 5: their golden moves are disjoint from 7.1 (three root source content hashes in `schema-01.json`, instance ids and result paths) | theirs | none here | -| 1 | `core/identity_chains.py`: the five labelled hashes, the canonical order of 2.4, pooling over an input list. Streams, nodes and invocations get `source_chain()`, `name_chain()`, `content_identity()`, `node_identity()` beside the existing hashes. Nothing reads them yet. Tests compare `H(P, C)` across plain stream, invocation and job node | none | small, about 300 lines | -| 2 | Close 3.5: `P` at a commutative operator from an input list (a multiset), on PR 587's positioned inputs. Put `ctx_arg_name` into the function pod's pipeline identity (3.1, decided). Both are pipeline hash changes for one narrow case each, approved as such. Test that every other `P` is unchanged (the 179 golden pipeline hashes, and stored paths of a job) | no golden entry; stored paths move for a commutative operator over content-equal inputs of equal `P`, and for context-taking pods (3.1) | small | -| 3 | Graph keys to semantic identity: `_hash_graph`, `_invocation_lut`, `_persistent_node_map`, `_sources_by_hash`, compile, `to_invocations`, `from_invocations`, `as_pipeline` (the remap goes), `is_runnable`, the run DAG. Job nodes stop being equal by content: node-keyed containers key by node object or by semantic identity. Observers get the semantic identity. Content hash still the old recursion | none | large: `pipeline/base.py`, `job.py`, `dag.py`, both orchestrators, `node_run.py` | -| 4 | Saved files: node keys become semantic identities; descriptors hold `node_identity` and `content_identity` (nullable). Loader reads the new form | none | medium: `graph.py`, `job.py`, `serialization.py`, the loaded node classes | -| 5 | The switch: `content_hash()` of every derived stream, node and invocation becomes `H(P, C)`; the unbound slot's name leaves the content hash (3.4); a bind invalidates content identity below it (ITL-1427). One golden regeneration, with the list of 7.1 approved entry by entry | 104 entries (106 after PR 609) | small in code, large in tests | -| 6 | Two slots on one source: remove the refusals named in section 6, implement the answer to Q3, tests of 9.2 | none | medium | -| 7 | Docs: `docs/concepts/identity.md`, `docs/reference/hashing.md` (the new labels and the hash site inventory), `CLAUDE.md` and `.zed/rules` ("Two identity chains" becomes three) | none | medium | - -Order against PRs 607, 615 and 609, so that each golden value is regenerated once: - -- 607 and 615 touch no entry of 7.1. They can land at any time before step 5. -- 609 changes the two `as_source[...]` source ids of 7.1 (it adds the job name to them) - and adds two entries that step 5 moves. To move those four once, step 5 should be - stacked on 609 and the two put to the developer as one list, or 609 should land first - with the four accepted as moving twice in the provisional file (no release freezes - it). I recommend stacking. -- Step 5 is the last golden-moving change of the series, on a base that holds all three. - -Steps 3 and 4 carry the risk and move no hash. Step 5 moves hashes and is mechanical. -Keeping them apart means a failure in step 5's golden check can only be a hash mistake. - -### 8.2 The open PRs - -| PR | Recommendation | Why | -|---|---|---| -| 577 (one source object per identity, ITL-1469) | **Merge first, as is** | It is ready and mergeable, it is the guard against wrong results on `main` while the steps are built, and its core rule stays (section 6). Its prepare phase and `source_consistency.py` are what steps 3 and 6 build on. Step 6 removes two of its refusals (capture after a rebind; a prebuilt stream over an own slot) | -| 608 (loaded job refuses graph changes, ITL-1560) | **Merge first, as is**, after 577 | Small, and the refusal stays under the design. Needs its conflicts with `main` resolved | -| 613 (slot names from labels, ITL-1565) | **Merge first**, after 577, once its conflicts are resolved | The slot name it defines is the `I` leaf, so step 1 needs it. It temporarily withdraws several slots on one source; step 6 removes that refusal and the two others named in section 6, and step 5 removes its rule that an unbound slot's content hash holds the name | -| 587 (positioned edges, ITL-1419) | **Rework on top of step 3** | Its edge is `(upstream key, node key, position)` with content-hash keys; the keys become semantic identities in step 3, and its dependence on 577 (one object per content hash, so that a key names one input) goes away. `pipeline/edges.py` (`input_positions`, `node_inputs`) is kept as it is and is what step 2 uses for the input list. If it is ready before step 3 starts, merging it first and re-keying it in step 3 is equally good | - -None is superseded. Nothing in them is thrown away except the refusals listed in -section 6. - -### 8.3 What each issue gets +## 8. Implementation plan -| Issue | Do the chains resolve it? | What remains | Step | -|---|---|---|---| -| ITL-1442, two slots on one source | Yes. The two branches have distinct semantic identities, so no node collapses; equal content identity, so one set of stored rows | The write rule for two nodes of one content identity (Q3), so that the async run stores one entry per row | 3 (nodes no longer collapse), 6 (Q3, refusals removed) | -| ITL-1427, hashes after a bind | Yes. Content identity is `H(P, C)` with `C` read from the slot, so it follows a bind at every depth, also on a loaded job without its pods (11.3) | Invalidating cached `C` and content identity below a slot when it is bound; the issue's tests | 5 | -| ITL-1204, slot lost from the run graph after a bind | Yes, outright. The slot's key is its semantic identity, which a bind does not change; today `SourceJobNode.__hash__` changes at a bind (`job.py:931`) | Nothing beyond step 3; `is_runnable`'s workaround goes | 3 | -| ITL-1470, a stream built before a job gets other system-tag names | No. It is a difference in `P`: the stream built outside becomes a leaf slot of its own, with its narrower schema, so the schema hash in the column names differs. No chain changes `P` | The capture rule: a stream brings its upstream steps down to its sources (ITL-1387), or is refused (PR 613 refuses a leaf that is not a source). The chains add the check: the job node's `P` must equal the plain stream's (9.1, PR 579) | 6, or its own PR after it | -| ITL-1506, one source id read with different key columns | Yes, once each reading has its own slot name: the readings differ in `C` (key columns are in the leaf) and in `I` | Removing the refusal for distinctly named slots; `bind` and the saved file address slots by name (PR 613) | 6 | -| One slot, two labels | Decided (Q1): one node. Its key is `H(P, I)`, which holds no label, so the two declarations have one key | `_remember_invocation` keeps the most recent label instead of the smallest; `job.nodes` holds the node under that label only; tests | 3 | -| Binding a slot to something that depends on a slot (cycles; a stale slot-to-slot binding after recompiling) | No, and the chains say why it must stay refused: a slot's `C` is its bound leaf's `C`. If what is bound depends on a slot, `C` is defined through that slot, and through itself in a cycle; and what is bound holds a reference to a slot object that a recompile replaces | One rule at `bind` and at capture: what a slot holds is a leaf with a `C` of its own, with no slot beneath it (walk with `streams_beneath`). PR 577's foreign-slot refusal and PR 613's refusal of a leaf that is not a source already cover it; step 6 states it once and keeps it. Binding a composite properly is ITL-1127 | 6 | -| Edges carrying input position (PR 587) | Needed by the chains, not resolved by them: pooling and 3.5 need each node's inputs as an ordered list with repeats | Re-key its edges by semantic identity | 2 (the list), 3 (the keys) | -| Restrictions on edges (ITL-1472) | Made possible. An edge is `(upstream semantic identity, node semantic identity, position)`, which survives a rebind and exists for an unbound blueprint; two slots on one source are two edges and can carry two restrictions | The edge registry itself (PR 580's design), the rule for stored rows under a restriction (Q4), and Q3 for two restricted nodes of one content identity. Not part of this work | after 6 | -| Capture after a rebind (PR 577) | Yes. A recorded step's key holds no source | Passing a source opens its slot or matches it by object; passing the slot reads it (the developer's direction in ITL-1559). Remove the refusal | 6 | -| Capture into a loaded job (PR 608, ITL-1560) | No. A loaded job has no recorded invocations | The saved file gets semantic keys and ordered inputs (step 4), from which the graph could be rebuilt; lifting the refusal is its own work | 4 prepares; not lifted here | -| Slot names (PR 613, ITL-1565, ITL-1428) | They are the `I` leaf | Duplicate names stay refused; a rename after capture stays refused | 0 (merge), 1 | -| Several slots of one source fail to load (ITL-1554) | Yes. Saved node keys are semantic identities and no longer collide | The new file form | 4 | - -## 9. Tests the design needs - -All through the public interface, with sources of two or more tag columns and two or more -data columns, `tag_only_columns=True` unless the role is the subject, in more than one -arrangement, and on the sync and the async path. - -### 9.1 The chains - -- `P` unchanged: every golden pipeline hash, plus stored paths and system-tag column - names of a job, before and after each step. -- A plain stream, its invocation and its job node have equal `P` and equal content - identity, built before the job and inside it (with ITL-1470's test, PR 579). -- Pass-through at every unary operator, function pod and side-effect pod; argument order - at `SemiJoin` and `MergeJoin`; `P` order at `Join` and `Rejoin` with two and three - inputs in every argument order. -- Repeats kept: a diamond's `C` differs from its branch's `C`. -- The state of `main` on ties, pinned before anything changes: over two sources of one - schema, `Join` and `Rejoin` refuse the pair when a plain data column is shared and - accept it when every data column is a data-tag; `MergeJoin` and `SemiJoin` are - ordered; no exported operator returns a nested symmetry (a test over - `orcapod.operators` that fails when a new operator is commutative or partly symmetric - until it has a tie case). -- The equal-`P` group, with `Join` and `Rejoin` over two all-data-tag slots, with two - tags and two data-tags, plain and in a job, sync and async: `P` is the same whether - the two slots hold one source, two equal objects or two different sources (3.5); both - arrangements of two sources over the two slots give one `C`, one `I`, one table of - rows and the same system-tag column names and values. -- 3.1: a plain and a context-taking pod of one uri over one source have different `P` - and are two nodes; `P` of a pod that takes no context is unchanged. -- Q1: one slot feeding one pod under labels `r1` then `r2` is one node labelled `r2`, - in `job.nodes`, the run summary and a saved and loaded job; the reverse order gives - `r1`; neither changes any `P`, content identity or semantic identity. -- Unbound: every node has a semantic identity; asking for content identity raises and - names the slots. -- The label rule: `tests/test_hashing/test_hash_label_rule.py` extended to the five - labels; `test_hash_grammar.py` and `test_hash_site_inventory.py` hold the new sites. -- Order invariance: `tests/test_core/test_order_invariance.py` gets a case per identity - (content and semantic) for every operator, source and stream kind, and for a job, so - that no arrangement of tags, columns or commutative inputs changes either. - -### 9.2 Two slots on one source (ITL-1442) - -- `A_x -> f -> g` and `A_y -> f -> g` bound to one source: four step nodes in `job.nodes` - and in the run summary, every node holds the full rows, one stored pipeline entry per - row and one result per input, sync and async, on a first run and a second. -- The same with a `Join` and with an operator node that caches. -- The same with one slot unbound: the bound branch runs, the other is left out. -- Bound to two sources, then rebound to one, then back: content identities follow at - every depth, semantic identities never change, rows stored earlier keep their node - content hash (ITL-1427's criteria, also for a loaded job). -- One dataset read with two key-column choices in two named slots (ITL-1506). -- Save and load of all of the above, including the case of ITL-1554 (one source in - several slots feeding one function pod). -- `as_source()` of each of two nodes with one content identity gives one source id. -- A side-effect node under each of two slots on one source: the decided number of - deliveries, with and without `track_completion`. - -## 10. Questions for the developer - -Q1 is decided. Q2, Q3 and Q4, and the PR recommendations of 8.2, are open. - -### Q1. Is a node's own label part of its semantic identity? DECIDED: no - -Decided (developer, 2026-11-28). A node's label is not part of its semantic identity, -and no label enters the `I` chain. A node has one label. Declaring the same computation -again under another label replaces the earlier label: the most recent wins. - -So one slot feeding the same pod twice under labels `r1` and then `r2` is one node, -labelled `r2`; `job.nodes["r1"]` no longer exists. A label can be changed without -re-keying anything, because no identity holds it. Only a slot's name is identity (the -`I` leaf). - -This changes `main`, where the smaller of two labels is kept whatever the order of -declaration (`pipeline/base.py:360`). One detail I assume and the developer should -confirm: a later declaration that gives no label leaves an assigned label in place. - -The option not taken was to make an assigned label part of `I`, giving two nodes of one -content identity. - -### Q2. A stream outside a job: how is its semantic identity formed? - -- (a) From the source's label by the one rule that names a slot (PR 613: the assigned - label, else the class name; `as_slot(name)` gives the name). A plain stream then has - the semantic identity its job node will have. -- (b) A plain stream has no semantic identity. It has `P` and content identity; the job - assigns `I` when it captures the stream, by walking to its roots. - -Recommendation: (a), under three conditions. One function derives the name for the plain -stream and for the job, so they cannot differ. `I` and semantic identity are never cached -on an object whose label can still change (the name is frozen at capture, as PR 613 -does); this answers question 10 of ITL-1559 for the name. And two different sources with -one default label (two `DictSource` objects) have one `I`: that is harmless outside a job -only if plain streams are not equal by semantic identity, so `__eq__` and `__hash__` of a -plain stream should stay content-based or become object identity, and only a graph -compares by semantic identity, where duplicate slot names are refused. - -### Q3. Two nodes with equal content identity in one job - -- (a) Write-if-missing on every pipeline and operator-cache write. -- (b) Compute once and feed both. - -Recommendation: (a) as the rule, (b) later as an optimisation. Reasons: - -- (b) is wrong when the two nodes sit below different restrictions (ITL-1472: equal - content identity, different rows), so it needs (a) underneath in any case. -- The pipeline table's key, the record id, holds a random result id. When two nodes - compute one instance at the same time (the async run of ITL-1442: 4 entries for 2 - rows), both miss the result store and write two results and two pipeline rows. So - write-if-missing must be keyed by the instance id within one node content hash, not by - the record id, and within one run the second node must wait for the first: a - single-flight map keyed by (table path, node content identity, instance id). The - operator cache's key (`_record_hash`) already covers the whole row, so there the rule - is the existing skip of a row passed again, made safe for two writers in one run. -- It also covers two jobs that share a database. - -To decide with it: whether two side-effect nodes with one content identity deliver once -or twice. The log is keyed by `P` and entry id, so with `track_completion` the second is -already skipped. I recommend once in every mode, by the same single-flight map. - -### Q4. What a restricted chain's `as_source()` shows without a membership table - -- (a) Every stored row of the node's content identity: a superset of the restricted view. -- (b) Refused, with the remedy to filter in the pipeline. -- (c) The stored rows filtered again by the restriction, where its columns survive. - -Recommendation: (b), as a caching operator node and a `CachedSource` over a restricted -source are refused today. (a) shows rows the user restricted away under a name that says -restricted; (c) works for some graphs and not others. - -## 11. Risks, cost, and loaded jobs - -### 11.1 What cannot be made to hold - -- **3.1** held as first worded; it is settled by the decision there (`ctx_arg_name` in `P`). -- **"`P` unchanged in value" together with "`P` holds no source"** (3.5): on `main` the - pipeline hash of `Join` or `Rejoin` over two inputs of equal `P` depends on whether - they are equal by content. One of the two statements has to give for that case; I - recommend that the value moves. -- **An attribution limit at a commutative operator with equal-`P` inputs** (4.5). `C` and - `I` each order the group on their own, so the pair (`C`, `I`) does not say which slot - holds which source: `x=A, y=B` and `x=B, y=A` give the same `P`, `C` and `I`. This is - correct for the operator's output, and it is what the agreed condition asks for. The - consequence to accept: content and semantic identity together never identify a - binding. Anything that must know which source a slot holds (the membership table, a - saved job) records it per slot, and must not try to derive it from the two hashes. -- **Equal `C` means equal rows only by convention.** The chains cannot check that two - sources with one identity deliver the same data. The one-object rule of PR 577 stays - for that. -- **Rows stored before the change are orphaned in place.** Table paths do not move, so a - pipeline or operator cache table keeps rows whose `__node_content_hash` no node will - ever compute again. They are never returned and never counted. With the new labels - (2.1) they can be recognised by their `semantic_v1:` prefix. Nobody has such a store - before 0.4.0. I do not recommend a layout bump for it, because that would move stored - paths. - -### 11.2 Cost - -Measured on a 50-node chain (one source, 49 single-input operators), counting calls of -the semantic hasher's `hash_object` and wall time, caches cold: - -| | calls | time | +| Step | PR | What it changes | |---|---|---| -| Today, content hash of the last node | 197 | 0.9 ms | -| Today, pipeline hash of the last node | 197 | 0.8 ms | -| Today, both | 394 | 1.6 ms | -| Three chains: `P`, then `H(P, C)` and `H(P, I)` at every node | 297 | 1.2 ms | - -The three chains cost less than today's two, because `C` and `I` pass through -single-input nodes and the two combined hashes are flat: today's content hash walks the -pod and the upstream structure a second time. A multi-input node adds one pooled hash to -each of `C` and `I`. I did not get a clean number for a join-heavy graph: building a -`Join` already computes its inputs' pipeline hashes, so the caches are warm when the -measurement starts. With hashed pooling the cost is linear in nodes in every graph; with -a flat list it is exponential in nested diamonds (3.2). - -A bind today must clear cached content hashes below the slot and does not (ITL-1427). -Under the design a bind invalidates `C` and content identity below the slot and nothing -else: `P`, `I` and semantic identity are untouched. - -### 11.3 What a loaded job does - -Today a saved job keys nodes by content hash, stores each node's `content_hash` and -`pipeline_hash`, and stores the run's content hash per label -(`run.node_job_content_hashes`), because a node loaded without its pod cannot compute its -content hash again (`operator_node.py:305`). - -Under the design: - -- Node keys are semantic identities. The blueprint and the job share them, and several - slots of one source no longer collide in the file (ITL-1554). -- A loaded node keeps its saved `P`. Its `C` comes from its upstream nodes, so its - content identity is `H(saved P, C)` computed live whenever every slot above it is bound, - with no pod. A bind on a loaded job then moves the content identity of every node below - it correctly, which today it cannot. -- The file still records each node's content identity at the time of the run, for a slot - whose source cannot be rebuilt (an in-memory source): the node then reads its stored - rows by the recorded value until a source is bound. -- A saved slot records its name and its bound source's identity per slot (11.1, the - attribution limit). -- A file written before the change has other keys and content hashes that match no - stored row written after it. I recommend refusing such a file with a message that says - so, since no one has one. The developer may prefer a reader for it. -- Capture into and recompiling a loaded job stay refused (PR 608). With semantic keys - and saved ordered inputs the graph can be rebuilt without the invocations, which is - what lifting that refusal needs; it is not part of this work. - -### 11.4 The later membership table - -Nothing here blocks it. Its key would be a node's semantic identity (it survives a -rebind), its rows references by entry or instance id into the table at the node's `P` -path, scoped by the node's content identity. All three exist for every bound node. Since -semantic identity holds no source, the table must also hold the content identity it was -recorded under, or a rebind would show the old binding's members. +| spec | 632 | This document | +| 1 | 633 | Compute `source_chain`, `name_chain` and `node_hash` alongside the old hashes. Graph and storage consumers continue to use the old values. Saved files are byte-identical | +| 2a | 634 | Give a context-taking function pod its own pipeline hash | +| 2b | To be written, on PR 587's work | Compute a commutative operator's pipeline hash from the input list, retaining equal inputs. Fix the tied-join faults in D32 | +| 3 | To be written | Key graph state, `job.nodes`, edges and restrictions by `node_hash`. Number steps with the same automatic name by node hash and document the rule | +| 4 | To be written | Write the new hashes into saved job files. Reuse the PR 645 acceptance test | +| 5, the switch | To be written, after PR 609 | Switch `content_hash` to `H(pipeline_hash, source_chain)` for storage and record ids, and refresh the content hash after binding. Requires approval of the exact list of golden entries that move | +| 6 | To be written | Lift both two-slot refusals. Equal-content nodes write if missing | + +The bind refresh follows the source chain at every depth, including in a loaded job +(ITL-1427). Using stable graph keys also addresses the slot that becomes unreachable +in the run graph after a bind (ITL-1204). The positioned inputs from PR 587 supply the +list in step 2b and take node-hash keys in step 3. They make restrictions per edge +possible. The edge registry and how a restricted view is represented in storage remain +part of ITL-1472. Step 4 addresses the saved-key collision for several slots bound to +one source (ITL-1554). + +## 9. Acceptance tests + +### 9.1 Hashes, ordering, and labels + +- Through the public APIs, compare a plain stream, its invocation and its job node. + Cover pipelines built before and inside capture, input column permutations, and + the sync and async paths. Use the ITL-1470 test from PR 579 where appropriate. +- Verify single-input pass-through and argument order for `SemiJoin` and + `MergeJoin`. Verify canonical structural order and repeat preservation in diamonds + and in two- and three-input commutative operators. Verify independent tie sorting + with the source and slot names ordered differently. +- For two all-data-tag inputs of equal pipeline hash, verify identical pipeline + hashes whether the two slots hold the same object, equal objects, or distinct + sources. Permuting the same two bindings gives the same chains, table, and + system-tag names and values. Cover custom system tags, three tied row-channel + inputs, and consistent record-id nullability across paths (D32). +- Verify that a plain pod and a context-taking pod over one source have different + pipeline hashes and graph keys. Verify the additional delivery after upgrading a + live job with a prior store, followed by normal completion lookup (D29). +- Verify that an unbound slot and its branch have node hashes, and that a request + for their live content hash names the unbound slots in its error. +- Declare one computation with `r1`, then `r2`, then without a label. Verify a single + node labelled `r2` in `job.nodes`, the run summary, and a saved and loaded job. + Reverse the two labels and expect `r1`. Check that the hashes are independent of + those labels. Verify automatic-name numbering in node-hash order (BL16). +- Check the new labels and hash sites against the hashing grammar and inventory. + Verify the byte-identical saved form in step 1. + +### 9.2 Binding, persistence, and shared tables + +- Run two separately named branches on one source object. Repeat the test with + **two equal objects on two differently named slots**. Each branch has distinct nodes + and edges, both hold all rows, and there is one stored pipeline entry per row and + one result per input. Check sync and async, the first run and a repeat, and a + branch with a caching operator. +- Unbind one slot and verify only the bound branch runs. Bind two sources to the + two slots, rebind to one and then back. Verify the node hashes stay stable, the + content hashes follow the binding at every depth, and old rows retain their + stored content hashes. +- Read one dataset with different key-column choices from differently named slots. + Save and load the two-slot cases, including one source in several slots feeding + one function pod (ITL-1554). Under otherwise identical `as_source()` settings, + equal-content nodes produce the same derived source id. +- Load a job with a source it cannot reconstruct, save it again, and verify the + source record is preserved (BL11, PR 645). Repeat this test for the step 4 writer. + +## 10. Alternatives considered + +- **Context-taking pods (D29).** Refusing two pods of the same URI in a graph or + adding the context argument to both auxiliary chains would distinguish those + operations. Step 2a puts the distinction in pipeline structure. +- **Pooling.** A flat list of leaves grows to one item per root-to-node path. + Twenty consecutive diamonds would give over a million entries. Hashing the + upstream values keeps each pooled result fixed-size while the pipeline hash fixes + the input structure. +- **Leaf hashes and labels.** Alternatives included omitting schema from the source + leaf and reusing the general `semantic_v1` label for the new hashes. Step 1 + reuses the source's identity preimage and gives the new digests distinct labels. +- **Unbound slots.** A placeholder content hash could reach storage. The live + content hash is absent until a source is bound. +- **Display labels and plain streams.** Putting step labels into the name chain + would make repeated declarations into separate nodes. Giving plain streams no + name chain would defer their node hash to capture. The decisions are recorded + in section 2.2. +- **Shared tables (DQ1).** Computing once and feeding both nodes can skip rows + when the nodes have different restrictions. That could be a later optimization + where the rows agree. Step 6 requires write-if-missing for shared storage. + +## 11. Open questions + +- Do two side-effect nodes with one content hash deliver once or twice, with and + without `track_completion`? The completion log uses pipeline hash and entry id, + so tracked completion can already skip the second delivery. The original proposal + was one delivery in every mode. Add the acceptance test after this is decided. +- What does a restricted chain's `as_source()` show without a membership table? + Options are all rows stored under the content hash, refusal with a pipeline + filter as the remedy, or reapplying the restriction where the columns survive. + The original recommendation was refusal, in line with the restrictions on + caching operators and `CachedSource`. +- Should step 4 read saved jobs from earlier development builds or reject them + with a format-specific error? The format marker rule below is settled. Whether + the step 4 loader supports those unreleased files remains open. +- The final treatment of cold polling sources, unavailable multi-input operators + and custom operators beyond the step 1 limits remains open. So do the exact + write-if-missing synchronization mechanism and plain-stream equality behavior + outside graph keys. + +## 12. Rebinding, saved jobs, and cost + +### 12.1 Rebinding and source attribution + +A bind invalidates the source-chain and content-hash results downstream of the +slot. The graph keeps the same node hashes and the pipeline and name terms stay +the same. At a commutative structural tie, the independently sorted chains cannot +recover which slot held which source. Store that association per slot in saved jobs +and any future membership table. + +The switch replaces the old hash values. Rows that are still at the same path with +an old `__node_content_hash` are outside the upgraded node's reads. The digest +labels distinguish the values. Any later membership table can use the node hash as +its key, reference entry or instance ids in the pipeline table, and record the +content hash under which membership was collected. + +### 12.2 Saved job files + +Step 4 keys saved nodes and edges by `node_hash` and saves the new hashes and +ordered inputs. A saved slot records its name and the identity of its bound source. +A loaded node retains the saved pipeline hash. Where the saved descriptor and +upstream nodes suffice to derive its chains, a loaded bound node can recompute the +live content hash after a rebind. If the source cannot be rebuilt, the node can read +its prior rows using the recorded content hash. Preserve the source record when +saving that job again (**BL11 (a)**, PR 645). + +**BL22 (a).** The saved-file marker names the format of the first release. Changes +before 0.4.0 is released keep that marker. A format change after the release changes +the marker and comes with an upgrade function or a permissive loader. + +### 12.3 Prototype cost + +A cold 50-node unary chain in the prototype used 394 calls to the semantic hasher +to compute both old hashes (1.6 ms). Computing the pipeline and both combined +hashes at every node used 297 calls (1.2 ms). A multi-input node adds pooling for +each auxiliary chain and a commutative group also sorts its inputs. The prototype +did not measure a cold join-heavy graph. From f9c27819bb7b5652c1a0f5805d6355d2dde39c0d Mon Sep 17 00:00:00 2001 From: "Edgar Y. Walker" Date: Sat, 28 Nov 2026 13:44:05 -0800 Subject: [PATCH 4/5] docs(dev): clarify binding scope in the hash rollout --- docs/dev/specs/itl-1559-three-chain-hash.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/dev/specs/itl-1559-three-chain-hash.md b/docs/dev/specs/itl-1559-three-chain-hash.md index 37ee58507..a602fd444 100644 --- a/docs/dev/specs/itl-1559-three-chain-hash.md +++ b/docs/dev/specs/itl-1559-three-chain-hash.md @@ -143,6 +143,10 @@ the graph. the underlying stream for the chains. A plain stream and the job node compiled from the same computation are intended to agree on structure and source chain, subject to the capture and saved-form limits above (ITL-1470). +- The step 1 walk tracks bindings through wrappers, including stored-result + `DerivedSource` objects whose origin belongs to another job. A rebind in the + origin job refreshes dependent source chains. A live input to another job that + depends directly on a job slot is still refused. ## 3. Pipeline hash changes and row ids @@ -320,9 +324,10 @@ Other slot and capture behavior from PRs 577, 608 and 613: - Foreign or standalone mutable slot objects, captured slot renames, and a slot label that collides with a step label remain subject to the existing refusals. A rename changes the name chain and would require an explicit graph operation. -- A captured leaf must be a source, and a slot binding must have its own source - identity without depending on another slot. Composite bindings are separate work - (ITL-1127). +- A captured leaf must be a source. Direct dependencies on mutable job slots + remain subject to the existing binding checks. General support for composite + bindings is separate work (ITL-1127). PR 633 already follows accepted bindings + through sources backed by another job's stored results. - Capture and recompilation of a loaded job remain separate work (ITL-1560). Step 4 prepares the graph with stable keys and ordered inputs. @@ -526,6 +531,10 @@ one source (ITL-1554). and custom operators beyond the step 1 limits remains open. So do the exact write-if-missing synchronization mechanism and plain-stream equality behavior outside graph keys. +- The integration order for PRs 608 and 613 relative to the remaining steps is + open. The original proposal was to take both after PR 577. Step 2b requires the + positioned input work from PR 587, and step 3 re-keys its edges. The choice of + how to integrate that work remains open. ## 12. Rebinding, saved jobs, and cost From 8fcda342809c7bb97abe54812ca54413417dcb63 Mon Sep 17 00:00:00 2001 From: "Edgar Y. Walker" Date: Sat, 28 Nov 2026 14:07:23 -0800 Subject: [PATCH 5/5] docs(dev): record side-effect log decisions (ITL-1559) --- docs/dev/specs/itl-1559-three-chain-hash.md | 97 ++++++++++++--------- 1 file changed, 56 insertions(+), 41 deletions(-) diff --git a/docs/dev/specs/itl-1559-three-chain-hash.md b/docs/dev/specs/itl-1559-three-chain-hash.md index a602fd444..c0538f43c 100644 --- a/docs/dev/specs/itl-1559-three-chain-hash.md +++ b/docs/dev/specs/itl-1559-three-chain-hash.md @@ -12,7 +12,7 @@ no usable content hash until the slot is bound. | Hash | Definition | Use | |---|---|---| | `pipeline_hash` | Schemas and steps, including each step's upstream structure | Stored paths and system-tag column names | -| `content_hash` | `H(pipeline_hash, source_chain)` | Stored rows, the `__node_content_hash` column, and record ids | +| `content_hash` | `H(pipeline_hash, source_chain)` | Stored row and side-effect log attribution, and record ids | | `node_hash` | `H(pipeline_hash, name_chain)` | Graph keys, `job.nodes`, edges, restrictions, and execution bookkeeping | The switch replaces the existing node content hash values. Slot names never reach the @@ -20,8 +20,6 @@ stored content hash. The node hash contains no source binding, survives a rebind exists for an unbound slot. Two differently named slots can therefore feed separate graph nodes that share stored rows. -In earlier notation, P meant pipeline structure, C meant the source chain, and I meant the name chain. - ## 2. How the chains are computed ### 2.1 Hash labels and implementation @@ -74,7 +72,7 @@ for an uncaptured root source and an anonymous term for a raw Arrow stream. Its `slot_name_for()` helper also uses `source_name` for an implicit root slot. The slot's name, once assigned, is the slot's leaf. -A node's display label enters none of its chains. A node has one label. Declaring the +A step's display label enters none of its chains. A step node has one label. Declaring the same computation again with a label replaces the earlier label. A declaration that omits a label preserves the most recently given label. For example, declaring the same step as `r1`, then `r2`, then without a label leaves one node displayed as `r2`. @@ -161,10 +159,11 @@ component, system-tag names that embed the affected hashes, and invocation keys. The prototype held no context-taking pod golden case. **D29 (a)** is a breaking change. An upgraded live job does not detect the prior -completion and result stores and the pod delivers once more for previously processed -inputs whose completion or result was recorded there. The stored table format is -unchanged. PR 634 also scopes result cache paths by -the context parameter via `context_result_path()`. Its saved-job descriptor records +completion and result stores at their prior paths. A context-taking pod or an affected +downstream tap can deliver once more for previously processed inputs whose completion +or result was recorded there. The stored table format is unchanged. PR 634 also +scopes result cache paths by the context parameter via `context_result_path()`. +Its saved-job descriptor records `result_record_path` for context-taking pods without changing the format marker. Saved jobs can still read results at their recorded or legacy paths when those stores are retained. This is separate from completion lookup by a live upgraded job. @@ -184,24 +183,40 @@ equal object, gave another. With the input list, all four use the same structura preimage with two occurrences of the input hash. The historical prototype pinned no case with collapsed inputs. -**D32 (a).** Fix the tied-join faults in step 2b because that step rewrites ordering -within an equal-pipeline-hash group: - -- A tied `Join` can pair a custom system tag with another input's ids by argument order. -- With three tied inputs, row channels and the sync table can disagree. -- Record-id nullability can differ between yielded rows and the table. +**D32 (a).** Step 2b owns tied-join correctness because it rewrites ordering within +an equal-pipeline-hash group. The original faults concerned custom system tags +separated from their input's ids, differences between three-input row channels and +sync tables, and inconsistent record-id nullability. PR 607 already pairs custom +system tags with their input ids in the tested standalone row-channel joins and +pins agreement for symmetric ties across sync tables, row channels and batch +channels. It also pins the existing per-mode behavior for ties with different field +declarations. Use that merged baseline in step 2b to retain the covered behavior +and close remaining differences, including any record-id nullability discrepancy +between yielded rows and tables. The developer approves the exact list of values that move before any golden value is regenerated for step 2b. ### 3.3 Row identifiers -The node content hash enters the record-id preimage (`core/row_ids.py`), the -`__node_content_hash` column, and the operator cache's row key. Entry ids are computed -from user tags, system tags and the input data hash. Instance ids add the source-info -tokens. Neither directly includes the node content hash. Changes to the inputs of -entry or instance ids, such as a changed system tag or derived source token, can still -affect them. +The node content hash is stored in `__node_content_hash` and enters the operator +cache's row key. A pipeline record id hashes the recording node's content hash, the +instance id and the result id (`core/row_ids.py`). The record id is the pipeline +table's key. An entry id hashes the row's user tags, system tags and input data hash. +An instance id hashes the entry id and the input's typed source-info token columns, +which PR 607 preserves through transport and storage. A changed system tag or +derived source token can therefore change an entry or instance id. + +### 3.4 Side-effect log attribution and completion + +**SL2 (a).** The side-effect log identifies the writing node solely by its +`content_hash`, in `__node_content_hash`. The log omits a node-hash column, keeping +slot names out of row storage. + +**SL3 (a).** Side-effect completion remains keyed by the delivered row's entry id. +With completion tracking, two sinks of one pod over one source deliver each row +once. Renaming a slot leaves the completion key unchanged and repeats no delivery. +PR 650 specifies the side-effect log layout. ## 4. Worked examples @@ -220,7 +235,8 @@ identities, and `f`, `g` and `h` be pods. ## 5. Inventory -Every line is `src/orcapod/` at `c1040ffa`. +Line numbers refer to `src/orcapod/` at `c1040ffa`. Section 3.4 records the +side-effect log decisions for PR 650. ### 5.1 Graph keys move to `node_hash` @@ -420,6 +436,9 @@ developer's approval of the exact golden entries that move, each with an explana Recompute the list on the final base after PR 609. The prototype moved 104 of 2,504 entries, rising to 106 after the derived-source additions in PR 609. These counts describe the prototype and do not substitute for the approval list. +PR 607 changed three `source_stream_builder.*.content_hash` pins in +`schema-01.json`, outside the prototype's move list. Use those updated values in +the baseline for the final comparison. **BL13 (a).** Add golden pins for data-tag identities after step 5 and before the 0.4.0 freeze. @@ -490,6 +509,10 @@ one source (ITL-1554). equal-content nodes produce the same derived source id. - Load a job with a source it cannot reconstruct, save it again, and verify the source record is preserved (BL11, PR 645). Repeat this test for the step 4 writer. +- With completion tracking, run two sinks of one side-effect pod over the same + source. Verify one delivery per entry id and attribution by the writer's + `content_hash`. Rebuild with a renamed slot against the same store and verify + zero repeat deliveries (SL2 and SL3, PR 650). ## 10. Alternatives considered @@ -515,26 +538,18 @@ one source (ITL-1554). ## 11. Open questions -- Do two side-effect nodes with one content hash deliver once or twice, with and - without `track_completion`? The completion log uses pipeline hash and entry id, - so tracked completion can already skip the second delivery. The original proposal - was one delivery in every mode. Add the acceptance test after this is decided. -- What does a restricted chain's `as_source()` show without a membership table? - Options are all rows stored under the content hash, refusal with a pipeline - filter as the remedy, or reapplying the restriction where the columns survive. - The original recommendation was refusal, in line with the restrictions on - caching operators and `CachedSource`. -- Should step 4 read saved jobs from earlier development builds or reject them - with a format-specific error? The format marker rule below is settled. Whether - the step 4 loader supports those unreleased files remains open. -- The final treatment of cold polling sources, unavailable multi-input operators - and custom operators beyond the step 1 limits remains open. So do the exact - write-if-missing synchronization mechanism and plain-stream equality behavior - outside graph keys. -- The integration order for PRs 608 and 613 relative to the remaining steps is - open. The original proposal was to take both after PR 577. Step 2b requires the - positioned input work from PR 587, and step 3 re-keys its edges. The choice of - how to integrate that work remains open. +| Question | Decision or remaining work | +|---|---| +| Q1. Does a step's display label affect its node hash? | Decided in the first update (section 2.2). Labels stay out of the hashes. The most recent explicit label wins on one node. | +| Q2. What name-chain leaf does a plain stream use outside a job? | Decided by DQ2 for this rollout. Use the source label. A follow-up will re-evaluate that rule, and plain-stream equality outside graph keys remains open. PR 633's source-name behavior is documented in section 2.2. | +| Q3. How do two nodes with equal content hashes share storage? | Decided by DQ1. Pipeline and operator-cache writers write if missing. The synchronization mechanism remains open. | +| Q3 follow-up. Do two side-effect sinks of one pod over one source deliver each row once, including after a slot rename? | Decided for tracked completion by SL3 (a), using entry ids. The original proposal also asked about deduplication with `track_completion` disabled. That case remains open. | +| Which node identifier does a side-effect log row store? | Decided by SL2 (a). The log identifies the writer solely by `content_hash` in `__node_content_hash`. | +| Q4. What does a restricted chain's `as_source()` show without a membership table? | Still open. Options are all rows under the content hash, refusal with a pipeline filter as the remedy, or reapplying the restriction where the columns survive. The original recommendation was refusal. | +| Does step 4 read saved jobs from earlier development builds? | Still open. BL22 (a) settles the format marker, and BL11 (a) settles preserving a source record on re-save. The loader policy for earlier unreleased files remains open. | +| What is the final behavior for cold polling sources, unavailable multi-input operators and custom operators? | Still open beyond the step 1 limits in section 2.4. | +| How should PRs 587, 608 and 613 be integrated? | Still open. Step 2b uses PR 587's positioned inputs and step 3 re-keys its edges. The integration order for PRs 608 and 613 relative to the remaining steps is still open. | +| How should capture handle a prebuilt stream over the job's own slot? | Still open (ITL-1470 and ITL-1387). Section 6 records the dependency on matching the slot correctly. | ## 12. Rebinding, saved jobs, and cost