Skip to content

feat(identity): the source and name chains are trees with an entry per node (ITL-1559, step 1b) - #652

Merged
eywalker merged 25 commits into
mainfrom
eywalker/itl-1559-step-1b-chain-trees
Nov 29, 2026
Merged

eywalker merged 25 commits into
mainfrom
eywalker/itl-1559-step-1b-chain-trees

Conversation

@eywalker

@eywalker eywalker commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Step 1b builds on #633, which is merged into main.

Related to ITL-1559.

Implementation

Each node hashes its own typed entry with the list of upstream hashes for the same chain. This preserves the depth of a name contribution and the pairings of source bindings across join levels. Commutative ties sort each chain independently and keep repeated occurrences. Shared nodes reuse their memoized chain values.

The existing pipeline hash and the two combination formulas keep their definitions. The retained labels, including source_chain_v1 and name_chain_v1, keep their _v1 suffixes because these algorithms have no released or pinned values. The standalone slot_name_v1 digest is retired because slot entries now hash under name_chain_v1. Nested argument-symmetry groups hash their children with a null entry and remain internal to the operator's chain. The legacy ITL-1590 refusal for combined hashes still applies when structural symmetry collapses content-equal inputs.

The only production name contributions remain at leaves. The inner-node name regression uses test-only contributions through the existing extension point. An unbound slot has a name chain and node hash. Reading the source chain raises UnboundSourceError, while the memo stores an absent source value so the name chain can still be evaluated.

The spec records D34 (a1), D35, and D36 in docs/dev/specs/itl-1559-three-chain-hash.md.

Verification

  • Identity tests include typed leaf and unary preimages, the naming collision and its successors, cross-level source pairing, source swaps at ties, and a diamond with one hash per node per chain.
  • All 29 operator run/save/load cases agree. The existing byte comparison against main passes. The golden values match.
  • Existing feat(identity): structure, source and name chains on every stream and node (ITL-1559, step 1) #633 assertions that use changed values are in test_chain_agrees_across_plain_recorded_and_job_forms, test_loaded_index_job_chains_survive_rebinding, test_commutative_equal_structure_sorts_the_chains_independently, test_nested_symmetry_keeps_repeated_ordered_pairs, test_mixed_nested_symmetry_uses_pipeline_order, test_source_proxy_uses_saved_identity_and_slot_name, test_raw_arrow_chains_reuse_warm_legacy_content_hash, test_chain_hashes_are_memoized_through_a_long_chain, test_unbound_slot_binding_has_no_source_chain, test_overlapping_identity_read_cannot_publish_stale_chain, test_identity_memo_is_invalidated_before_binding_is_visible, test_identity_terms_accept_canonical_semantic_values and test_name_term_memo_respects_semantic_types_after_rebind (renamed for entries), plus test_polling_chain_reads_do_not_call_user_code, test_cached_polling_chains_reuse_warm_delegate_hash, test_derived_polling_chains_reuse_bound_source_digest, and test_polling_leaf_chains_are_available_before_schema.
  • Seven existing identity tests now assert the direct undefined-source error. The hash grammar and label inventories drop the retired standalone leaf digest.

Independent review findings

Compared the public constructor and saved-job behavior on origin/main (bf2582d4) and the reviewed head (558d3b5e). Repeated the main reproductions after #633 landed (3e640fb5) with the same results.

Finding Classification and resolution Regression test
Explicit empty slot names were rejected at construction. REGRESSION. On main, SourceNode.from_stream(source, name="") created a slot that could be bound, run, and saved. The reviewed head raised ValueError at construction. This PR restores construction and hashes the slot as ("slot", ""), distinct from the null entry for a node with no name contribution. test_empty_slot_name_can_run_and_save (fails at construction on the reviewed head). test_empty_inner_name_is_refused retains D36's validation for a given inner-node name.

Found in review, present on main, not addressed here

  • PRE-EXISTING. Save a job bound to an explicitly empty slot on main, load it, and call loaded.bind(sources={"": source}). Both main and the reviewed head load the same pipeline hash and raise ValueError on rebind because the restored slot uses its fallback name.

Summary by CodeRabbit

  • Bug Fixes
    • Source and name identities are now hashed consistently across nodes and their upstream chains, including single-input operators.
    • Requests for source identity or chain-based content hashes now raise an error when a contributing source slot is unbound.
  • Documentation
    • Updated hashing references and examples to explain identity-chain behavior, input ordering, and unbound-source errors.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Source and name chains now hash typed entries and upstream values at each node. The changes update identity-chain pooling, input ordering, and cache behavior. Source-chain access returns a hash when available and raises UnboundSourceError when a contributing slot is unbound.

Changes: Identity chain hashing

Layer / File(s) Summary
Typed entries and per-node hashing
src/orcapod/core/identity_chains.py, src/orcapod/protocols/hashing_protocols.py, docs/dev/specs/itl-1559-three-chain-hash.md, docs/reference/hashing.md, tests/test_hashing/*
Source and name chains hash typed entries with upstream chain values at each node. The hashing code updates pooling and cache-key handling, and tests check the resulting preimages and labels.
Graph ordering and memoization
src/orcapod/core/identity_chains.py, docs/dev/design_issues/ITL-1559-TC1.md, docs/dev/specs/itl-1559-three-chain-hash.md, changelog.d/ITL-1559.md, tests/test_hashing/test_identity_chains.py
Input ordering and repeated inputs are retained in chain preimages. The specification and tests cover branch pairings, commutative ties, memoization, and rebinding.
Source leaves and unbound-chain errors
src/orcapod/core/nodes/source_node.py, src/orcapod/core/operators/static_output_pod.py, src/orcapod/protocols/*, tests/test_channels/test_polling_source.py, tests/test_hashing/test_identity_chains.py, docs/reference/hashing.md, docs/dev/specs/itl-1559-three-chain-hash.md
Source leaves retain their binding digest. The source_chain() return type is non-optional and the method raises UnboundSourceError when a contributing source is unbound. Tests update source-leaf expectations and error cases.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant IdentityChainsMixin
  participant _pool_group
  participant _identity_chain_hash
  IdentityChainsMixin->>_pool_group: Pass entries and chain-hashing callback
  _pool_group->>_identity_chain_hash: Hash tagged entry with ordered child hashes
  _identity_chain_hash-->>_pool_group: Return chain digest
  _pool_group-->>IdentityChainsMixin: Return pooled source and name chains
Loading

Possibly related PRs

Merge Risk: Minimal · up to 250a8

This change moves source and name identity hashing to typed per-node entries, and unbound source-chain reads now raise UnboundSourceError instead of returning nothing. No in-repo caller depends on the old behaviour, and nothing in the supplied evidence shows a concrete defect, so merge risk is minimal.

Security architecture risk: Minimal · up to 250a8

The new digests and error behavior change what library callers receive. The reviewed code does not show those changes reaching authorization, persisted identifiers, or production cache keys. Callers that handled an unbound source by checking for an absent result must now handle an exception.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated reach is to callers of the library identity APIs. Direct calls in the inspected production source have the same delegation path at base and head; no reviewed call connects these digests to authorization, durable storage, or production cache lookup.

Resilience and Maintainability Implications

  • observed — The existing memo lifecycle is retained: a name-only memo cannot satisfy a source-inclusive read, and binding invalidation clears cached chain results and source digests for affected nodes while retaining name digests.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: source and name identity chains become per-node trees with one typed entry per node. This matches the identity_chains.py, source_node.py, and hashing docs changes, and…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: source and name identity chains become per-node trees with one typed entry per node. This matches the identity_chains.py, source_node.py, and hashing docs changes, and the linked objectives (PR #652, ITL-1559 step 1b). The title is specific and accurate. It omits the UnboundSourceError behavior change, which is acceptable because the title need not cover every detail.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

Note

This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 3e640fb and 250a8db.

Files selected for processing: 13

  • changelog.d/ITL-1559.md
  • docs/dev/design_issues/ITL-1559-TC1.md
  • docs/dev/specs/itl-1559-three-chain-hash.md
  • docs/reference/hashing.md
  • src/orcapod/core/identity_chains.py
  • src/orcapod/core/nodes/source_node.py
  • src/orcapod/core/operators/static_output_pod.py
  • src/orcapod/protocols/hashing_protocols.py
  • src/orcapod/protocols/node_protocols.py
  • tests/test_channels/test_polling_source.py
  • tests/test_hashing/test_hash_grammar.py
  • tests/test_hashing/test_hash_label_rule.py
  • tests/test_hashing/test_identity_chains.py
Files with no reviewable changes: 2

  • tests/test_hashing/test_hash_grammar.py
  • tests/test_hashing/test_hash_label_rule.py

Limit details: You’ve used the included review currently available. Your 100 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Recent review details

Context from checks skipped due to timeout: 1

  • GitHub Check: CodeRabbit
Additional context used

Code guidelines: 1

CLAUDE.md — auto-discovered
Path-based instructions: 7

Source excerpt: Every fenced `python` block in `README.md`, `docs/index.md`, `docs/getting-started.md`, `docs/troubleshooting.md`, `docs/concepts/`, `docs/reference/` and `docs/tutorial/` is executed by `tests/test_docs/test_doc_samples.py`...

CodeRabbit inference engine (CLAUDE.md)

Files:

  • docs/reference/hashing.md
Source excerpt: Documents written during development are kept in the repository, under `docs/dev/` (developer, November 16, 2026; ITL-1169): Specs go in `docs/dev/specs/`, plans in `docs/dev/plans/`, and the scripts and evidence they cite i...

CodeRabbit inference engine (CLAUDE.md)

Files:

  • docs/dev/specs/itl-1559-three-chain-hash.md
Source excerpt: An entry is the file `docs/dev/design_issues/-.md` (e.g.

CodeRabbit inference engine (CLAUDE.md)

Files:

  • docs/dev/design_issues/ITL-1559-TC1.md
Source excerpt: The file holds only the text that would have gone under the release heading in `CHANGELOG.md`: the same category headings `CHANGELOG.md` uses (`### Breaking changes and migration`, `### Added`, `### Changed`, `### Fixed`, `#...

CodeRabbit inference engine (CLAUDE.md)

Files:

  • changelog.d/ITL-1559.md
Source excerpt: Tests use the **public interface** wherever possible (developer, November 10, 2026): drive an operator by calling it, `op(stream)`, and read the result through the stream's public methods.

CodeRabbit inference engine (CLAUDE.md)

Files:

  • tests/test_channels/test_polling_source.py
  • tests/test_hashing/test_identity_chains.py
Source excerpt: Tests and golden fixtures that build a source with tag columns pass `tag_only_columns=True` unless the test is about the default (developer, November 16, 2026, ITL-1159).

CodeRabbit inference engine (CLAUDE.md)

Files:

  • tests/test_channels/test_polling_source.py
  • tests/test_hashing/test_identity_chains.py
Source excerpt: Use [Google style](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings) Python docstrings everywhere.

CodeRabbit inference engine (CLAUDE.md)

Files:

  • src/orcapod/core/identity_chains.py
  • src/orcapod/core/nodes/source_node.py
  • src/orcapod/core/operators/static_output_pod.py
  • src/orcapod/protocols/hashing_protocols.py
  • src/orcapod/protocols/node_protocols.py
  • tests/test_channels/test_polling_source.py
  • tests/test_hashing/test_identity_chains.py

@eywalker
eywalker merged commit 8c0b762 into main Nov 29, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant