A `git worktree` never replays a checkout's cache entry for a task that lists the workspace root
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 35/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Estagnada
- Stack de tecnologia
- git, rust
- Domínio
- build-system, tooling
Direção de pesquisa
Start with crates/vt/src/session/execute/fingerprint.rs, especially should_ignore_entry and the directory listing fingerprint path; compare it with the .git filtering in crates/vt/src/session/execute/tracked_accesses.rs. Add an end to end case that changes .git from a directory to a file and confirms the cached task replays. The issue says the fix is complete when root listings no longer cause this cache miss across checkout and worktree layouts.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Written by an AI agent (Claude) on behalf of @jasonkuhrt.
A task that lists the workspace root records each entry's name and kind in its fingerprint, and .git is one of those entries. In an ordinary checkout .git is a directory; in a git worktree it is a file that points at the main repository. So a cache entry recorded in a checkout never replays in a worktree of the same commit, and the reverse, though every file a task can read is the same. The miss reads:
○ cache miss: '.git' added in workspace root, executing
We share one remote cache between CI, which checks out with a .git directory, and developers and agents, who work in git worktrees. In a fresh worktree at our trunk's head (vite-plus 1.4.0), 56 of the 143 vp lint tasks that missed missed for this reason alone, against entries CI recorded for that commit. Linters, Vitest's project discovery and anything that resolves the workspace list the root, so most of our tasks carry the root listing.
Steps to reproduce
repro.sh <path to vt> runs a task that lists the workspace root in a checkout, adds a worktree of the same commit, copies the checkout's cache into it (standing in for a shared or remote cache), and runs the task there.
repro.sh
#!/usr/bin/env bash
set -euo pipefail
vt=$(cd "$(dirname "$1")" && pwd)/$(basename "$1")
work=$(mktemp -d)
cd "$work"
mkdir checkout && cd checkout
git init -q -b main
cat > package.json <<'JSON'
{ "name": "repro", "private": true }
JSON
cat > vite-task.json <<'JSON'
{
"tasks": {
"list-root": {
"command": "node -e \"console.log(require('fs').readdirSync('.').length)\"",
"cache": true
}
}
}
JSON
echo node_modules > .gitignore
git add -A && git -c user.name=r -c user.email=r@r commit -qm init
echo "== checkout: first run"
"$vt" run list-root
echo "== checkout: second run"
"$vt" run list-root
git worktree add -q ../worktree
mkdir -p ../worktree/node_modules/.vite
cp -R node_modules/.vite/task-cache ../worktree/node_modules/.vite/
cd ../worktree
echo "== worktree: same commit, checkout's cache"
"$vt" run list-root
With vt built from 40cb9cac (macOS 27.2 arm64, Node 26.13.0):
== checkout: first run
$ node -e "console.log(require('fs').readdirSync('.').length)"
5
== checkout: second run
$ node -e "console.log(require('fs').readdirSync('.').length)" ◉ cache hit, replaying
5
---
vt run: cache hit, 412ms saved.
== worktree: same commit, checkout's cache
$ node -e "console.log(require('fs').readdirSync('.').length)" ○ cache miss: '.git' added in workspace root, executing
5
Cause
.git paths are already kept out of the fingerprint when a task reads them: tracked_accesses.rs skips every path under .git. A directory listing doesn't go through that filter. should_ignore_entry drops only ., .., .DS_Store and dist, so the root listing keeps .git with its DirEntryKind, Dir in a checkout and File in a worktree.
vite-plus 1.4.0 ships the same code (fingerprint.rs at a3c087a).
Proposed fix
Skip .git in directory listings the way .DS_Store and dist are skipped, which matches what tracked_accesses.rs already does for reads under .git. A PR that does this follows, with an e2e case where a task that lists the root records its entry with .git as a directory and replays it after .git becomes a file.
If you'd rather keep .git's presence in the listing, the alternative is to record .git without its kind, so a directory and a file compare equal. We went with dropping it because a read of .git itself is already dropped, so its presence doesn't count anywhere else.
The miss message
A changed kind is reported as added: determine_folder_change_kind returns InputChangeKind::Added when an entry's name matches and its kind differs. '.git' added in workspace root sent us looking for a new .git, when it had been there all along as a directory. A message such as '.git' changed from a directory to a file in workspace root would have pointed at the cause. That changes the output, so it isn't in the PR.
Related
#504 is about negative input patterns not reaching listing entries. A fix there would let a task exclude .git by configuration, but .git is never a task input, so it needs no configuration.
- Linguagem predominante
- Rust
- Estrelas
- 485
- Forks
- 51
- Merge médio
- 1d 5h
- PRs com merge (30d)
- 63
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de voidzero-dev/vite-task
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
voidzero-dev/vite-task#921 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 56/100
voidzero-dev/vite-task#910 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Automatic output tracking misses files a task renames into place, so a cache hit restores nothingAberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
voidzero-dev/vite-task#908 ·
Mantenedores costumam responder em até 1 dia
-
Export OpenTelemetry client spans for the native remote cacheTalvez já em andamento @jasonkuhrt assumiu há 2 dias. Aberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 25/100
voidzero-dev/vite-task#906 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 56/100
voidzero-dev/vite-task#905 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de voidzero-dev/vite-task
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia
-
good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 92/100
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
yunfie-twitter/Palleria#474 ·
Mantenedores costumam responder em até 1 dia
-
good first issue help wanted
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
servo/rust-smallvec#827 ·
Mantenedores costumam responder em até 1 dia