Skip to content

Commit 4e7e6b1

Browse files
safishamsiclaude
andcommitted
fix(extract,watch): C# assembly-aware partial merge, incremental edge preservation, extract crash recovery; bump to 0.9.33
#2411 (thanks @JensD-git): key the C# partial-class merge on assembly (nearest ancestor .csproj/.fsproj/.vbproj) in addition to namespace and name, so same-name partial classes in different assemblies stay distinct while genuine partial halves within one project still merge. Fixes a 0.9.32 regression from #2332. #2437/#2438 (thanks @aryanbonigala, builds on PR #2439): incremental rebuilds no longer drop member-call and indirect_call edges from a changed file into an unchanged target. Re-resolution now sees the unchanged corpus (nodes, contains/method edges, and _callable markers, which now persist to graph.json like _origin); edges to a genuinely removed target are still evicted. #2444/#2445 (thanks @Baziar, builds on PRs #2461/#2458): a BrokenProcessPool triggers the sequential fallback instead of being swallowed per future, a failed worker file is retried sequentially rather than merged as empty, and a whole-pass AST failure on a fresh build exits non-zero instead of writing a zero-node graph (--allow-partial opts into a best-effort partial graph). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
1 parent a426d63 commit 4e7e6b1

10 files changed

Lines changed: 1399 additions & 37 deletions

‎CHANGELOG.md‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22

33
Full release notes with details on each version: [GitHub Releases](https://github.com/safishamsi/graphify/releases)
44

5-
## 0.9.32 (unreleased)
5+
## 0.9.33 (unreleased)
6+
7+
- Fix: the C# `partial class` merge (#2332) no longer conflates two same-named classes that live in different assemblies (#2411, thanks @JensD-git). The merge now keys on assembly (nearest ancestor directory containing a `.csproj`/`.fsproj`/`.vbproj`) in addition to namespace and name, so genuine partial halves within one project still merge while same-name types in separate projects stay distinct. A corpus with no project file keeps merging by namespace and name as before.
8+
- Fix: `graphify update` no longer drops member-call and `indirect_call` edges from a changed file into an unchanged target (#2437, #2438, thanks @aryanbonigala). Incremental re-resolution now sees the unchanged corpus (its nodes, `contains`/`method` edges, and the `_callable` markers, which now persist to `graph.json` like `_origin`), so cross-file calls survive an incremental rebuild while edges to a genuinely removed target are still evicted.
9+
- Fix: `graphify extract` no longer silently substitutes an empty result when a worker crashes (#2444, #2445, thanks @Baziar). A `BrokenProcessPool` now triggers the sequential fallback instead of being swallowed per future, a failed worker file is retried sequentially rather than merged as empty, and a whole-pass AST failure on a fresh build exits non-zero instead of writing a zero-node graph (use `--allow-partial` to opt into a best-effort partial graph).
10+
- `graphify install` now prints a one-time pointer to the hosted platform (early access is open free before the public v1 launch) after the setup summary.
11+
12+
## 0.9.32 (2026-08-01)
613

714
- Fix: incremental extraction and `_rebuild_code` no longer drop a file's other tier (#2333, #2334, #2336). Node/edge ownership was keyed on `source_file` alone, so a semantic re-extract deleted a doc's AST headings and a full rebuild deleted document AST nodes. Merge is now tier-aware (an AST re-extract replaces only AST nodes and keeps the semantic layer, and vice versa), the `_origin` provenance marker is backfilled on load so old graphs self-heal, and the full-rebuild drop is scoped to sources actually regenerated.
815
- Fix: `graphify update` preserves the graph's `directed` flag instead of rebuilding it undirected (#2342, thanks @Rishet11), so God-node / path ranking keeps its direction on both the clustered and `--no-cluster` rebuild paths.

‎graphify/cli.py‎

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3091,11 +3091,100 @@ def _parse_float(name: str, raw: str) -> float:
30913091
ast_kwargs: dict = {"cache_root": out_root, "root": target}
30923092
if cli_max_workers is not None:
30933093
ast_kwargs["max_workers"] = cli_max_workers
3094+
# #2437/#2438 (the `graphify update` twin of watch's #2406 fix): an
3095+
# incremental re-scan extracts only the changed code files, so the
3096+
# cross-file resolvers cannot see a callee living in an unchanged
3097+
# file and every changed->unchanged call edge silently vanished on
3098+
# merge. Hand extract() read-only resolution context from the
3099+
# persisted graph: its AST-tier nodes (with their `_callable`/
3100+
# `_callable_class` markers, #2438) plus the contains/method edges
3101+
# the member-call resolvers walk (#2437), scoped to the UNCHANGED
3102+
# live corpus — never a re-extracted, deleted, or excluded file, so
3103+
# stale symbols cannot resurrect. Fails open (changed-batch-only
3104+
# resolution, the pre-fix behavior) on an unreadable graph.
3105+
if incremental_mode and existing_graph_path.exists():
3106+
_ctx_nodes: list[dict] = []
3107+
_ctx_edges: list[dict] = []
3108+
try:
3109+
from graphify.build import _is_ast_tier as _ctx_is_ast_tier
3110+
from graphify.security import (
3111+
check_graph_file_size_cap as _ctx_size_cap,
3112+
)
3113+
_ctx_size_cap(existing_graph_path)
3114+
_ctx_graph = json.loads(
3115+
existing_graph_path.read_text(encoding="utf-8")
3116+
)
3117+
_ctx_root = Path(os.path.abspath(target))
3118+
3119+
def _ctx_identity(source_file) -> str | None:
3120+
# graph.json source_file values are relative to the
3121+
# scanned root (`root=target` above); detect's
3122+
# unchanged_files keep their scan-time form. Compare
3123+
# both as absolute posix paths.
3124+
if not source_file:
3125+
return None
3126+
_p = Path(str(source_file))
3127+
if not _p.is_absolute():
3128+
_p = _ctx_root / _p
3129+
return Path(os.path.abspath(_p)).as_posix()
3130+
3131+
_ctx_live = {
3132+
_ctx_identity(f)
3133+
for _flist in detection.get("unchanged_files", {}).values()
3134+
for f in _flist
3135+
}
3136+
_ctx_live.discard(None)
3137+
for _node in _ctx_graph.get("nodes", []):
3138+
if not _node.get("id") or not _ctx_is_ast_tier(_node):
3139+
continue
3140+
_sf = _node.get("source_file")
3141+
if not _sf or _ctx_identity(_sf) not in _ctx_live:
3142+
continue
3143+
_ctx_node = {
3144+
"id": _node["id"],
3145+
"label": _node.get("label"),
3146+
"source_file": _sf,
3147+
"file_type": _node.get("file_type"),
3148+
"type": _node.get("type"),
3149+
}
3150+
for _marker in ("_callable", "_callable_class"):
3151+
if _node.get(_marker):
3152+
_ctx_node[_marker] = _node[_marker]
3153+
_ctx_nodes.append(_ctx_node)
3154+
for _edge in _ctx_graph.get(
3155+
"links", _ctx_graph.get("edges", [])
3156+
):
3157+
if _edge.get("relation") not in ("contains", "method"):
3158+
continue
3159+
if not _ctx_is_ast_tier(_edge):
3160+
continue
3161+
_sf = _edge.get("source_file")
3162+
if not _sf or _ctx_identity(_sf) not in _ctx_live:
3163+
continue
3164+
_ctx_edges.append({
3165+
"source": _edge.get("source"),
3166+
"target": _edge.get("target"),
3167+
"relation": _edge.get("relation"),
3168+
"source_file": _sf,
3169+
})
3170+
except Exception:
3171+
_ctx_nodes, _ctx_edges = [], []
3172+
if _ctx_nodes:
3173+
ast_kwargs["resolution_context_nodes"] = _ctx_nodes
3174+
if _ctx_edges:
3175+
ast_kwargs["resolution_context_edges"] = _ctx_edges
30943176
print(f"[graphify extract] AST extraction on {len(code_files)} code files...")
30953177
try:
30963178
ast_result = _ast_extract(code_files, **ast_kwargs)
30973179
except Exception as exc:
30983180
print(f"[graphify extract] AST extraction failed: {exc}", file=sys.stderr)
3181+
# #2445: losing the whole AST pass is fatal by default. The
3182+
# empty stand-in only reaches the shrink guard when an existing
3183+
# graph is larger — on a fresh build it used to be written as a
3184+
# 0-node graph with exit 0, indistinguishable from success.
3185+
# --allow-partial opts back into the best-effort continuation.
3186+
if not cli_allow_partial:
3187+
sys.exit(1)
30993188
ast_result = {"nodes": [], "edges": [], "input_tokens": 0, "output_tokens": 0}
31003189
_extraction_incomplete = True # the whole AST pass was lost
31013190
stages.mark("AST extract")

0 commit comments

Comments
 (0)