Use effective identity for DryRunEvaluator node_key - #262
Merged
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
DryRunEvaluatorbuilds a plan of the nodes that would run and emits anode_keyidentifying each one. That key was computed with the plain structuralcache_key(...), while the actual runtime — the in-processMemoryCacheEvaluatorand the dependency-graph dedup — identifies the same nodes withcache_key(..., effective=True).So the dry run could label a node differently than the real run caches and dedupes it. For models that use a narrower "effective" identity, two nodes that the real run treats as distinct could share a
node_keyin the plan (or vice-versa) — making the dry-run report an unreliable preview of what actually happens.Fix
Compute the dry-run
node_keywithcache_key(..., effective=True), the same identity the memory cache and graph dedup already use. The dry-run plan now matches runtime behavior node-for-node.This is a no-op for ordinary models (which use the structural key), so existing plans are unchanged; it only affects models that opt into effective identity.
Test
Adds
test_node_key_uses_effective_identity: a model that ignores an unused context field. Two contexts that differ only in that ignored field previously produced differentnode_keys in the plan; now they collapse to the same key, matching how the runtime caches/dedupes them — and the emitted key equalscache_key(..., effective=True).Validation
ccflow/tests/evaluators/andccflow/tests/test_effective_key_characterization.pypass (75 tests), including all pre-existing dry-run tests.