Title: Engine: _compile_uncached recomputes cache key without outer_scopes, causing cross-scope cache collisions #8
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Engine._compile_uncached
(packages/ngen-weave-core/src/ngen_weave/engine/runner.py:455-462) ignores the cache
key passed in by its only caller and recomputes it locally, dropping the outer_scopes
component. Because both methods share the same cache map (self._compiled), two
compilations of the same workflow class under different outer scopes collide: the
second lookup returns the first scope's compiled graph.
Affected code
The caller (compile(), ~line 430) computes the key correctly as:
The recomputed key shadows the parameter and omits the third element.
Steps to reproduce
resolved model variant for the child differs between scopes.
variant binding.
Expected behavior
Each distinct (workflow class, models, outer_scopes) tuple produces its own cache entry
and its own CompiledGraph. Variant bindings frozen into checkpoints must match the
activation path that produced them — deterministic resume depends on this.
Actual behavior
Second compilation with different outer_scopes but same (root_path, models) returns the
stale, first-scope graph. No error is raised; the wrong graph silently serves runs.
Impact
inconsistent with the run's scope chain.
compile/resume semantics). Contradicts the method's own contract implied by accepting
key.
Suggested fix
Use the caller-supplied key; delete the local recomputation:
Note: the early-return re-check inside _compile_uncached may be redundant entirely (the
sole caller has just missed on the same map under the _compiling guard) — verify
whether nested children re-enter via recursive compile() calls before removing.
Regression test
distinct graphs (fails today).
(cache still effective).
Full test plan drafted in plans/releases/v0.1.1.md.
Environment
References