Skip to content

fix(plan): evaluate cache.env and cache.untrackedEnv patterns independently - #1010

Open
albertusdev wants to merge 2 commits into
voidzero-dev:mainfrom
albertusdev:fix/independent-env-globsets
Open

albertusdev wants to merge 2 commits into
voidzero-dev:mainfrom
albertusdev:fix/independent-env-globsets

Conversation

@albertusdev

@albertusdev albertusdev commented Nov 22, 2026 •

Copy link
Copy Markdown

Motivation

Before #425, EnvFingerprints::resolve ignored !-prefixed patterns, so chaining cache.untrackedEnv and cache.env into one pattern set was equivalent to a union. Once #425 enabled ! negation in EnvGlobSet, a negation in either list began excluding names matched by the other.

That makes two normal patterns impossible:

import { defineConfig } from 'vite-plus';

export default defineConfig({
  run: {
    tasks: {
      // Fingerprint `VITE_*` except `VITE_DEBUG`, while still passing `VITE_DEBUG` untracked.
      // Today `!VITE_DEBUG` in `env` drops `VITE_DEBUG` from `untrackedEnv` too.
      build: {
        command: 'node build.mjs',
        cache: {
          env: ['VITE_*', '!VITE_DEBUG'],
          untrackedEnv: ['VITE_DEBUG'],
        },
      },
      // Pass `CI_*` untracked except `CI_SECRET`, which should be fingerprinted.
      // Today `!CI_SECRET` in `untrackedEnv` drops `CI_SECRET` before fingerprinting.
      deploy: {
        command: 'node deploy.mjs',
        cache: {
          env: ['CI_SECRET'],
          untrackedEnv: ['CI_*', '!CI_SECRET'],
        },
      },
    },
  },
});

Changes

Match cache.env and cache.untrackedEnv as separate EnvGlobSets instead of chaining them. For cached tasks, an inherited variable passes through if either list matches it, and the planner fingerprints its inherited value when cache.env matches it.

Bumps CACHE_SCHEMA_VERSION to 24 so existing local and remote cache entries recorded under the previous cross-list matching behavior aren't replayed.

This changes behavior for configs that relied on a negation crossing lists. For example, env: ['!NPM_TOKEN'] no longer keeps NPM_TOKEN (matched by *_TOKEN in DEFAULT_UNTRACKED_ENV) out of the spawned process environment — doing so now requires excluding it in cache.untrackedEnv, and in cache.env if that list also matches it.

AI-assisted (Claude Opus 5.5, Gemini 4 Neon).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T12:39:17.500331Z acb58f9 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…dently

Before voidzero-dev#425, `EnvFingerprints::resolve` ignored `!`-prefixed patterns, so
chaining `untracked_env` and `fingerprinted_envs` into one pattern set was
equivalent to a union. Once voidzero-dev#425 enabled `!` negation in `EnvGlobSet`, a
negation in either list began excluding names matched by the other — for
example, `env: ["VITE_*", "!VITE_DEBUG"]` with `untrackedEnv: ["VITE_DEBUG"]`
dropped VITE_DEBUG, and `untrackedEnv: ["CI_*", "!CI_SECRET"]` with
`env: ["CI_SECRET"]` dropped CI_SECRET before fingerprinting.

Compile each list separately, pass through inherited names matched by either
set, and fingerprint inherited values matched by `env`.

A negation in one list can no longer exclude a name matched by the other.
In particular, keeping a default pass-through name such as NPM_TOKEN out of
the spawned process environment now requires excluding it in `untrackedEnv`,
and in `env` too if that list matches the name.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@albertusdev
albertusdev force-pushed the fix/independent-env-globsets branch from 83039a7 to ffd0e51 Compare November 22, 2026 10:49

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 83039a7209

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// Keep envs matching either list
envs.retain(|name, _| {
name.inner().to_str().is_some_and(|name_str| {
untracked_patterns.is_match(name_str) || fingerprinted_patterns.is_match(name_str)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bump the cache version for the changed environment semantics

When upgrading an existing cache for a task configured with env: ['VITE_*', '!VITE_DEBUG'] and untrackedEnv: ['VITE_DEBUG'], with inherited VITE_DEBUG set, the old implementation omitted that variable whereas this implementation passes it through. However, both fingerprinted_envs and untracked_env_config remain identical, so the cache key does not change. Because CACHE_SCHEMA_VERSION is still 23 in crates/vt/src/session/cache/mod.rs:471, local and remote lookups can replay output produced without VITE_DEBUG instead of rerunning the task with its newly allowed environment. Bump the cache schema version or otherwise distinguish the new matching semantics in the fingerprint.

Useful? React with 👍 / 👎.

@albertusdev
albertusdev force-pushed the fix/independent-env-globsets branch from acb58f9 to 99cd742 Compare November 22, 2026 13:06
Bump CACHE_SCHEMA_VERSION from 23 to 24 so existing local and remote
cache entries recorded under the previous cross-list env matching
behavior are not replayed now that cache.env and cache.untrackedEnv
are evaluated independently.

Co-authored-by: Gemini 4 Neon <noreply@google.com>
@albertusdev
albertusdev force-pushed the fix/independent-env-globsets branch from 99cd742 to 615eedc Compare November 22, 2026 15:53

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant