Use effective identity for DryRunEvaluator node_key - #262
Draft
ptomecek wants to merge 1 commit into
Draft
Conversation
The dry-run report node_key was derived from the raw structural cache_key(...) (effective=False), so it ignored the opt-in _CallableModel._evaluation_identity_payload() effective-identity hook. The in-process MemoryCacheEvaluator and the dependency-graph dedup already key on cache_key(..., effective=True), so a model that opts into a collision-safe effective identity was reported under the structural key in dry-run plans, inconsistently with how it is actually cached and deduplicated. Pass effective=True when building the dry-run node_key. For models that opt out (the base hook returns None) this is a byte-for-byte no-op and preserves the existing structural key; opt-in models now get their effective identity in the plan, consistent with memory/graph dedup. Add a regression test using a generated @Flow.model that ignores an unused ambient context field: the emitted node_key must equal cache_key(..., effective=True) and must merge two contexts that differ only in an ignored field, even though their structural keys differ. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Pascal Tomecek <pascal.tomecek@cubistsystematic.com>
Contributor
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #262 +/- ##
=======================================
Coverage 93.48% 93.48%
=======================================
Files 176 176
Lines 20327 20347 +20
Branches 1350 1350
=======================================
+ Hits 19002 19021 +19
- Misses 1052 1053 +1
Partials 273 273 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DryRunEvaluatorreports anode_keyfor each planned node. That key was derived from the raw structuralcache_key(...)(effective=False), so it ignored the opt-in_CallableModel._evaluation_identity_payload()effective-identity hook.Meanwhile, the in-process
MemoryCacheEvaluator.keyand the dependency-graph dedup (_build_dependency_graph) already key oncache_key(..., effective=True). As a result, a model that opts into a collision-safe effective identity was reported under the structural key in dry-run plans — inconsistent with how the same node is actually cached and deduplicated. For models whose distinct structural keys collapse, this could silently merge or mislabel distinct nodes in the plan/report.Fix
Pass
effective=Truewhen building the dry-runnode_key.None), this is a byte-for-byte no-op and preserves the existing structural key.Test
Adds
test_node_key_uses_effective_identity: a generated@Flow.modelthat ignores an unused ambient context field. The emittednode_keymust equalcache_key(..., effective=True)and must merge two contexts that differ only in an ignored field — even though their structural keys differ.Validation
ccflow/tests/evaluators/andccflow/tests/test_effective_key_characterization.pypass (75 tests), including all pre-existing dry-run tests.