Temuan
find_changed_files di scripts/incremental.py:81-147 mencoba git-aware path lebih dulu. Jika last_indexed_sha bookmark ada di DB (dari scan sebelumnya), function memanggil _git_changed(workspace, since_sha=...) dan _git_untracked(workspace). Kedua function ini return [] baik ketika (a) tidak ada perubahan MAUPUN (b) workspace bukan git repo / git unavailable — tidak ada cara untuk membedakan.
Akibatnya, pada workspace non-git yang memiliki stale last_indexed_sha di DB, incremental scan return (changed=[], new=[], deleted=[]) tanpa fall back ke mtime path. File yang dimodifikasi tidak terdeteksi.
Cara reproduce
import sys, os, tempfile, shutil
sys.path.insert(0, 'scripts')
# 1. Copy clean_app fixture ke temp dir (non-git workspace)
src = 'benchmarks/fixtures/clean_app'
workspace = tempfile.mkdtemp(prefix='codelens_test_')
for entry in os.listdir(src):
s = os.path.join(src, entry); d = os.path.join(workspace, entry)
if os.path.isdir(s): shutil.copytree(s, d)
else: shutil.copy2(s, d)
# 2. Scan pertama (full) — tapi FIRST, inject stale last_indexed_sha ke DB
from commands.scan import cmd_scan
cmd_scan(workspace, incremental=False) # creates DB
# Inject stale SHA (simulasi: DB sudah punya SHA dari scan sebelumnya)
import sqlite3
db = os.path.join(workspace, '.codelens', 'codelens.db')
conn = sqlite3.connect(db)
# registry_meta table may not exist — create it
conn.execute('CREATE TABLE IF NOT EXISTS registry_meta (key TEXT PRIMARY KEY, value TEXT)')
conn.execute("INSERT OR REPLACE INTO registry_meta (key, value) VALUES ('last_indexed_sha', 'ca89f3672f2a402f3218f0e2927221d54f813c2b')")
conn.commit()
# 3. Modify a file
target = os.path.join(workspace, 'src', 'utils.py')
with open(target) as f: orig = f.read()
with open(target, 'w') as f: f.write(orig.replace('format_text', 'format_text_renamed'))
# 4. Run incremental scan
result = cmd_scan(workspace, incremental=True)
print('changed_files_count:', result.get('changed_files_count'))
# Output: 0 (should be 1)
Output aktual
Output yang diharapkan
File src/utils.py yang dimodifikasi harus terdeteksi sebagai changed file.
Severity
HIGH — incremental scan silently gagal mendeteksi perubahan pada workspace non-git yang punya stale SHA bookmark. User tidak akan tahu bahwa scan tidak update graph. Tests yang rely on incremental scan juga gagal (test_incremental_scan_with_modification_updates_graph, dll).
PR terkait
Pre-existing bug di scripts/incremental.py (diperkenalkan oleh PR #26 / issue #14: git-diff aware incremental re-index). Tidak diperbaiki oleh #106–#113. Fix seharusnya: jika _git_changed dan _git_untracked keduanya return [] DAN last_sha truthy, verify dulu bahwa workspace adalah git repo (e.g. get_current_sha(workspace) is not None). Jika bukan git repo, fall back ke _find_changed_files_mtime.
Temuan
find_changed_filesdiscripts/incremental.py:81-147mencoba git-aware path lebih dulu. Jikalast_indexed_shabookmark ada di DB (dari scan sebelumnya), function memanggil_git_changed(workspace, since_sha=...)dan_git_untracked(workspace). Kedua function ini return[]baik ketika (a) tidak ada perubahan MAUPUN (b) workspace bukan git repo / git unavailable — tidak ada cara untuk membedakan.Akibatnya, pada workspace non-git yang memiliki stale
last_indexed_shadi DB, incremental scan return(changed=[], new=[], deleted=[])tanpa fall back ke mtime path. File yang dimodifikasi tidak terdeteksi.Cara reproduce
Output aktual
Output yang diharapkan
File
src/utils.pyyang dimodifikasi harus terdeteksi sebagai changed file.Severity
HIGH — incremental scan silently gagal mendeteksi perubahan pada workspace non-git yang punya stale SHA bookmark. User tidak akan tahu bahwa scan tidak update graph. Tests yang rely on incremental scan juga gagal (
test_incremental_scan_with_modification_updates_graph, dll).PR terkait
Pre-existing bug di
scripts/incremental.py(diperkenalkan oleh PR #26 / issue #14: git-diff aware incremental re-index). Tidak diperbaiki oleh #106–#113. Fix seharusnya: jika_git_changeddan_git_untrackedkeduanya return[]DANlast_shatruthy, verify dulu bahwa workspace adalah git repo (e.g.get_current_sha(workspace) is not None). Jika bukan git repo, fall back ke_find_changed_files_mtime.