Map cache is reused when only gitignored files changed at the same commit

Abierto
#178 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
54/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
git, go
Área
devtools, tooling

Línea de trabajo

Read internal/mapper/mapper.go around Build and the adjacent TestCacheIsKeyedByCleanCommit test, then trace the file listing through internal/walk/walk.go and cleanliness checks in internal/gitx/gitx.go. Add tests for ignored files and untracked files with status.showUntrackedFiles=no, while confirming a clean tree still hits the cache. Done when each changed listing produces a fresh map and the clean-tree cache test passes.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug severity: medium

Summary

The map cache is keyed on the commit plus a git status cleanliness check, but the walk also lists gitignored files, which git status never reports. A second scan of the same commit can therefore report coverage and a map that describe the earlier tree.

Where

  • internal/mapper/mapper.go:115-131 (Build: cache hit refreshes only Files)
  • internal/gitx/gitx.go:456 (IsCleanExcept: git status --porcelain)
  • internal/walk/walk.go:236 (the walk does not consult .gitignore)
  • internal/engine/run.go:530-537 (recordMapAndLeads writes the cached summary and "Not read" notes)

Details

Build treats the cache entry for HEAD as valid when gitx.IsCleanExcept says the tree is clean. That command does not list ignored files, and lists no untracked files at all when the operator has status.showUntrackedFiles=no (the base arguments do not pin it). The walk lists ignored files, maps them and writes them into the cache. On a hit only Files is refreshed; FileCount, Languages, Entry, Boundaries, Frameworks, InfraFiles, Tests and Skipped come from the earlier state. The same holds for the --changed path: an ignored file is never in the changed set, so its cached per-file result is reused.

Impact

In agentic mode the planner and investigators start from a stale map (missing or dead entry points and trust boundaries). In every mode the report's coverage numbers and "Not read" notes describe the first scan, while the seeders run on the fresh listing, so the map and the leads disagree. Typical ignored-but-scanned files: generated sources, local config, .env.*, *.tfvars.

Steps to reproduce

  1. In a git repository at a clean commit with .gitignore containing local/, create local/big.py larger than 1 MiB and run spackle scan ..
  2. Replace local/big.py with a small web app and add local/extra.py. git status is still clean.
  3. Run spackle scan . again: the map summary has the old file count, the note still says local/big.py was not read although the seeders read it, and its route is not an entry point.

Suggested fix

Make the cache key cover what the walk lists, not only the commit. Either ask git for ignored and untracked files too (git status --porcelain --ignored --untracked-files=all, with -c status.showUntrackedFiles=all) and skip the cache when any exist under the root, or store a digest of the listing (relative path, size, mtime of every listed and skipped entry) in the cache file and reject the entry when it differs.

Acceptance criteria

  • A test beside TestCacheIsKeyedByCleanCommit changes an ignored file between two builds and gets a fresh map
  • The same with an untracked file and status.showUntrackedFiles=no
  • A clean tree with no ignored files still hits the cache

Related: #110, #121

Getting started

  • Relevant files: internal/engine/run.go, internal/gitx/gitx.go, internal/mapper/mapper.go, internal/walk/walk.go
  • How to run tests: make test-short (Unix) or .\make.ps1 test-short (Windows PowerShell); make lint before you call it done
  • Related docs: CONTRIBUTING.md, docs/ARCHITECTURE.md

Filed by repo-audit/full-audit at 50e92ec. Severity: medium. Effort: M. audit-key: bug|internal/mapper/mapper.go|Build-cache-ignored

Lenguaje dominante
Go
Estrellas
0
Forks
1
Merge medio
8 h 14 min
PR fusionados (30 d)
3

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TMHSDigital/Spackle

Todos los issues de TMHSDigital/Spackle

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.