Skip to content

[Bug]: No-op extract stamps source edits that have not been indexed #5531

Done

Description

@rvitaliy

What happened?

When a warm extract --code-only --no-cluster finds no changes, it keeps the existing graph but still hashes and stamps the entire code corpus into the manifest. If an editor saves a file after the scan and before the manifest write, the new hash is recorded against the old graph. The next incremental run then skips the file.

On a monorepo run with 5,152 unchanged files, this path computed 5,152 MD5 hashes in the manifest save step, which took about 0.95 s in one instrumented run. The manifest's final bytes and modification time were unchanged. The work is separate from the repeated reads of graph.json in #5527.

Steps to reproduce

Save this script outside the Graphify checkout and run it with PYTHONHASHSEED=0 GRAPHIFY_NO_AUTO_REFRESH=1 uv run --frozen python /path/to/repro.py from a source checkout after uv sync --all-extras.

import json
import os
import runpy
import subprocess
import sys
from pathlib import Path
from tempfile import TemporaryDirectory

from graphify import detect

args = ["extract", ".", "--code-only", "--no-cluster"]
with TemporaryDirectory() as temp:
    root = Path(temp)
    source = root / "sample.ts"
    source.write_text("export function original() { return 0; }\n")
    subprocess.run([sys.executable, "-m", "graphify", *args], cwd=root, check=True)
    scan = detect.detect_incremental

    def edit_after_scan(*args, **kwargs):
        result = scan(*args, **kwargs)
        stat = source.stat()
        source.write_text("export function edited() { return 1; }\n")
        os.utime(source, ns=(stat.st_atime_ns, stat.st_mtime_ns + 2_000_000_000))
        return result

    detect.detect_incremental = edit_after_scan
    original_dir = Path.cwd()
    try:
        os.chdir(root)
        sys.argv = ["graphify", *args]
        try:
            runpy.run_module("graphify", run_name="__main__")
        except SystemExit as exc:
            assert exc.code == 0
    finally:
        os.chdir(original_dir)
    subprocess.run([sys.executable, "-m", "graphify", *args], cwd=root, check=True)
    graph = json.loads((root / "graphify-out/graph.json").read_text())
    print([node["label"] for node in graph["nodes"]])

Actual and expected behavior

The final graph contains original() and the last run reports no changes. The no-op run should keep the manifest entry for the snapshot represented in the graph so the next run detects the late edit and indexes edited().

Environment

Reproduced on v8 at 0f22ae762e3e3d0b689fc7ad2b8192740628413b (Graphify 0.9.121), macOS arm64, Python 3.14.6, installed from source with uv.

Activity

  1. github-actions commented on Nov 27, 2026

    @github-actions

    Thanks for opening this issue, @rvitaliy. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

  2. added a commit that references this issue on Nov 28, 2026
    2b95135
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions