fix(eager): don't defer meta-context variables during deferred import - #1338
Open
jasmith-hs wants to merge 1 commit into
Open
jasmith-hs wants to merge 1 commit into
jasmith-hs wants to merge 1 commit into
Conversation
The flat/no-alias branch of ImportTag.handleDeferredNodesDuringImport wrapped every child binding in a DeferredValue when propagating it to the parent context. This included meta-context variables such as import_resource_path, whose concrete String value was replaced with a value-less DeferredValue, later causing a ClassCastException / loss of the import path in EagerMacroFunction.reconstructImage. Meta-context variables are now skipped entirely, matching the non-deferred integrateChild path which already excludes import_resource_path from parent propagation (it stays alive only in the macro's captured localContextScope). reconstructImage additionally unwraps a DeferredValue defensively before the String cast. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jasmith-hs
marked this pull request as ready for review
September 21, 2026 19:21
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.
Description
During eager execution, importing a template that depends on deferred values routes through
ImportTag.handleDeferredNodesDuringImport. Its flat/no-alias branch wrapped every childbinding in a
DeferredValuebefore propagating it to the parent context.The problem is that this swept up meta-context variables too — most importantly
import_resource_path. Its concreteStringvalue was replaced with a value-lessDeferredValue, so a laterEagerMacroFunction.reconstructImage()read aDeferredValuewhere itexpected a
String, losing the import path (and risking aClassCastException) when reconstructingan imported macro.
Meta-context variables are already classified via
MetaContextVariables.isMetaContextVariable(...)and excluded from dependency tracking,speculative binding reconstruction, and deferred-token processing everywhere else in eager
execution. This one code path bypassed that classification.
What changed
ImportTag.handleDeferredNodesDuringImportnow skips meta-context variables in the flatbranch rather than deferring them. This mirrors the non-deferred
integrateChildpath(
getChildBindingsWithoutImportResourcePath), which already excludesimport_resource_pathfromparent propagation — the value stays alive only in the macro's captured
localContextScope.EagerMacroFunction.reconstructImagedefensively unwraps aDeferredValuebefore theStringcast, so a stray wrapper can never throw.
This description was authored by Claude Code.
BRAVE
Backwards Compatibility
Rollout and Rollback Plan
Automated Testing
EagerImportTagTest.itDoesNotDeferMetaContextVariablesDuringDeferredImportproves meta-contextvariables are not deferred into the parent while normal bindings still defer with
originalValuepreserved.
EagerTest,EagerImportTagTest,EagerFromTagTest,ImportTagTest,MacroTagTest,EagerMacroFunctionTest): 300 tests, 0 failures.Verification
"skip", confirming nothing relies on the parent receiving the meta value.
Expect Dependencies to Fail
REVIEWERS: Please review both the code changes and the answers above, and validate that they match the expectations for BRAVE