Make import VAR ?= default revert to default when env-var is unset#54
Merged
Conversation
process_import resolved env-var values in the order env -> cache -> default. The cache was populated unconditionally by ensure_env_var_node on every build, so once a value entered the cache it recycled through every subsequent build and the default branch was unreachable. The user had no way to revert to the written default by unsetting the env var; only putup clean (or hand-editing the index) dropped the cached value. Swap to env -> default -> cache. When the author wrote `?= default`, that default is the explicit revert-target for the env-unset case and now wins over the cache. Plain `import VAR` without a default still falls through to the cache, so the cross-shell stability that motivated the cache in the first place (build with MY_VAR=foo, open a fresh shell that forgot the export, rebuild without surprise) is preserved. Reproducer: [e2e][import] test "import ?= default reverts when env is unset on warm index" - sets MY_VAR=from_env, builds, drops the EnvGuard, rebuilds, asserts out.txt reads "default_value" not the cached "from_env". Red before, green after. Full suite green (467 cases, 23679 assertions); [phi], [platform-incremental], [envdep] untouched. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
process_importpreviously resolved env-var values in the order env → cache → default, with the cache populated unconditionally on every build byensure_env_var_node. Once a value entered the cache it recycled forever; the default branch was unreachable for any author who had built once with the env var set.?= defaultis the explicit revert-target for the env-unset case and now wins over the cache. Plainimport VARwithout a default still falls back to the cache, preserving the cross-shell stability the cache was added for.Test plan
import ?= default reverts when env is unset on warm index([e2e][import]) — setsMY_VAR=from_env, builds, dropsEnvGuard, rebuilds, assertsout.txtis the default, not the cached env value. Red before, green after.[e2e][import]— all 7 scenarios pass (80 assertions).env_var_persist(load-bearing for the no-default cache-stickiness path) still green.[phi]— 84 assertions, 9 scenarios.[platform-incremental](PR Fold env-driven conditionals into command identity #53 reproducer) — green.[envdep](PR Identify commands by a structural hash, not a string or position #52 sticky-edge reproducer) — green.make test— 23679 assertions, 467 cases.make format,make iwyuclean.make tidywarnings unchanged frommain(pre-existingreadability-qualified-autoon the samestd::lower_boundline).🤖 Generated with Claude Code