Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions graphify/watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1846,11 +1846,6 @@ def _failed(f: str) -> bool:
except Exception:
pass

# clear stale needs_update flag if present
flag = out / "needs_update"
if flag.exists():
flag.unlink()

if same_graph:
print("[graphify watch] No code-graph changes detected (--no-cluster); outputs left untouched.")
else:
Expand Down Expand Up @@ -1894,9 +1889,6 @@ def _failed(f: str) -> bool:
)
except Exception:
pass
flag = out / "needs_update"
if flag.exists():
flag.unlink()
html_action = _reconcile_graph_html(out, existing_graph_data)
if html_action == "rendered":
print(
Expand Down Expand Up @@ -2086,11 +2078,6 @@ def _failed(f: str) -> bool:
except Exception as cf_err:
print(f"[graphify watch] callflow HTML update skipped: {cf_err}")

# clear stale needs_update flag if present
flag = out / "needs_update"
if flag.exists():
flag.unlink()

if not no_change:
print(f"[graphify watch] Rebuilt: {G.number_of_nodes()} nodes, "
f"{G.number_of_edges()} edges, {len(communities)} communities")
Expand Down
26 changes: 26 additions & 0 deletions tests/test_watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,32 @@ def test_check_update_does_not_clear_flag(tmp_path):
assert flag.exists()


@pytest.mark.parametrize(
("no_cluster", "change_topology"),
[(True, False), (False, False), (False, True)],
ids=["no-cluster", "unchanged-topology", "clustered-rebuild"],
)
def test_code_rebuild_preserves_semantic_update_flag(
tmp_path, no_cluster, change_topology
):
"""An AST-only rebuild cannot clear pending semantic work (#3294)."""
source = tmp_path / "app.py"
source.write_text("def before(): pass\n", encoding="utf-8")
assert _rebuild_code(
tmp_path, no_cluster=no_cluster, acquire_lock=False
) is True

flag = tmp_path / "graphify-out" / "needs_update"
flag.write_text("docs/PRD.md\n", encoding="utf-8")
if change_topology:
source.write_text("def after(): pass\n", encoding="utf-8")

assert _rebuild_code(
tmp_path, no_cluster=no_cluster, acquire_lock=False
) is True
assert flag.read_text(encoding="utf-8") == "docs/PRD.md\n"


def test_watch_raises_without_watchdog(tmp_path, monkeypatch):
import builtins
real_import = builtins.__import__
Expand Down