Commit dfcbfe2
refactor(cache): introduce EnvMismatch as the canonical env-change shape (#437)
## Motivation
`SpawnFingerprintChange` carried 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 in `format_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-map `EnvGlobDiff`, and two
hand-rolled renderers).
## Approach
Introduce `EnvMismatch { Added, Removed, Changed }` 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 one `Env(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.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent 31fea5b commit dfcbfe2
2 files changed
Lines changed: 42 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 19 | + | |
| 20 | + | |
26 | 21 | | |
27 | 22 | | |
28 | 23 | | |
| |||
46 | 41 | | |
47 | 42 | | |
48 | 43 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 44 | + | |
58 | 45 | | |
59 | 46 | | |
60 | 47 | | |
| |||
80 | 67 | | |
81 | 68 | | |
82 | 69 | | |
83 | | - | |
84 | | - | |
| 70 | + | |
| 71 | + | |
85 | 72 | | |
86 | 73 | | |
87 | | - | |
| 74 | + | |
88 | 75 | | |
89 | 76 | | |
90 | | - | |
91 | | - | |
| 77 | + | |
| 78 | + | |
92 | 79 | | |
93 | | - | |
| 80 | + | |
94 | 81 | | |
95 | 82 | | |
96 | 83 | | |
97 | 84 | | |
98 | 85 | | |
99 | 86 | | |
100 | | - | |
101 | | - | |
| 87 | + | |
| 88 | + | |
102 | 89 | | |
103 | | - | |
| 90 | + | |
104 | 91 | | |
105 | 92 | | |
106 | 93 | | |
| |||
158 | 145 | | |
159 | 146 | | |
160 | 147 | | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
| 148 | + | |
166 | 149 | | |
167 | 150 | | |
168 | 151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
142 | 170 | | |
143 | 171 | | |
144 | 172 | | |
| |||
0 commit comments