refactor(cache): introduce EnvMismatch as the canonical env-change shape#437
Merged
Conversation
The three env variants on SpawnFingerprintChange (EnvAdded / EnvRemoved / EnvValueChanged) encoded both what changed and how it renders, and every new place that detects an env difference had to re-invent the same added/removed/changed triple plus its formatting. The upcoming runner-aware caching work (#430) adds two more such places — tool-tracked envs and env-glob match-sets validated at cache lookup — which would have made three hand-rolled copies of the same concept. Pull the triple into one EnvMismatch enum next to the other mismatch vocabulary in cache/, with its Display impl as the single source of the user-facing wording. SpawnFingerprintChange folds its three variants into Env(EnvMismatch); detection and rendering are unchanged in behavior (same strings, same snapshots). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
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.

Motivation
SpawnFingerprintChangecarried three env variants —EnvAdded,EnvRemoved,EnvValueChanged— that encoded the same concept three times over: an env var differing between a stored fingerprint and the current state. Every consumer had to spell out the same three-arm match, and the user-facing wording lived inline informat_spawn_change's arms.This shape is about to be needed in more places. The runner-aware caching work (#430) detects env differences at two additional points — tool-tracked envs (
getEnv) and env-glob match-sets (getEnvs) validated at cache lookup — and without a shared type each would re-invent the added/removed/changed triple plus its own formatting, with the wording drifting across three copies (the first draft of #430 had exactly that: an option-pair{old: Option<Str>, new: Option<Str>}with an impossible(None, None)state, a three-mapEnvGlobDiff, and two hand-rolled renderers).Approach
Introduce
EnvMismatch { Added, Removed, Changed }next to the other mismatch vocabulary incache/, with itsDisplayimpl as the single source of the user-facing wording.SpawnFingerprintChangefolds its three variants into oneEnv(EnvMismatch).No behavior change: detection logic, message strings, and snapshots are identical. #430 then reuses the enum for its post-run paths instead of defining parallel shapes.