sort file list lexicographically in detect() for deterministic graph output
os.walk order is non-deterministic across runs (filesystem b-tree order shifts with cache/mount state), causing first-writer-wins decisions in cross-file resolution to produce different node IDs each run; sorting all_files and per-FileType lists stabilises graph.json without changing any parent-child or connectivity semantics (closes #1090) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
0cf596aa8a
commit
8db19d6c85
@@ -930,6 +930,8 @@ def detect(root: Path, *, follow_symlinks: bool | None = None, google_workspace:
|
|||||||
seen.add(p)
|
seen.add(p)
|
||||||
all_files.append(p)
|
all_files.append(p)
|
||||||
|
|
||||||
|
all_files.sort(key=lambda p: str(p))
|
||||||
|
|
||||||
converted_dir = root / "graphify-out" / "converted"
|
converted_dir = root / "graphify-out" / "converted"
|
||||||
|
|
||||||
for p in all_files:
|
for p in all_files:
|
||||||
@@ -983,6 +985,9 @@ def detect(root: Path, *, follow_symlinks: bool | None = None, google_workspace:
|
|||||||
if ftype != FileType.VIDEO:
|
if ftype != FileType.VIDEO:
|
||||||
total_words += count_words(p)
|
total_words += count_words(p)
|
||||||
|
|
||||||
|
for ftype in files:
|
||||||
|
files[ftype].sort()
|
||||||
|
|
||||||
total_files = sum(len(v) for v in files.values())
|
total_files = sum(len(v) for v in files.values())
|
||||||
needs_graph = total_words >= CORPUS_WARN_THRESHOLD
|
needs_graph = total_words >= CORPUS_WARN_THRESHOLD
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user