MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _rebuild_code

Function _rebuild_code

graphify/watch.py:2832–2891  ·  view source on GitHub ↗

Re-run AST extraction + build + optional cluster + report for code files. No LLM needed. Thin wrapper: the rebuild freezes the heap once extraction is done (see :func:`_freeze_heap_for_graph_phases`) and this unfreezes it on every exit path, so a long-lived ``watch``/MCP process goes ba

(
    watch_path: Path,
    *,
    changed_paths: list[Path] | None = None,
    incremental: bool = False,
    follow_symlinks: bool = False,
    force: bool = False,
    no_cluster: bool = False,
    acquire_lock: bool = True,
    block_on_lock: bool = False,
)

Source from the content-addressed store, hash-verified

2830
2831
2832def _rebuild_code(
2833 watch_path: Path,
2834 *,
2835 changed_paths: list[Path] | None = None,
2836 incremental: bool = False,
2837 follow_symlinks: bool = False,
2838 force: bool = False,
2839 no_cluster: bool = False,
2840 acquire_lock: bool = True,
2841 block_on_lock: bool = False,
2842) -> bool:
2843 """Re-run AST extraction + build + optional cluster + report for code files. No LLM needed.
2844
2845 Thin wrapper: the rebuild freezes the heap once extraction is done (see
2846 :func:`_freeze_heap_for_graph_phases`) and this unfreezes it on every exit
2847 path, so a long-lived ``watch``/MCP process goes back to collecting normally
2848 between rebuilds.
2849
2850 When ``force`` is True the node-count safety check in ``to_json`` is bypassed
2851 so the rebuilt graph overwrites graph.json even if it has fewer nodes.
2852 Use this after refactors that legitimately delete code.
2853
2854 When ``changed_paths`` is provided, only those files are re-extracted; nodes
2855 for unchanged files are preserved from the existing graph. Deleted paths
2856 in ``changed_paths`` (paths that no longer exist on disk) are dropped from
2857 the preserved set. When ``changed_paths`` is None the full code corpus is
2858 re-extracted (used by the watcher and post-checkout hook).
2859
2860 ``incremental`` asks for the change set to be derived from the manifest
2861 instead of from ``changed_paths`` (#4740). It applies only when
2862 ``changed_paths`` is None and ``force`` is False, so an explicit list always
2863 wins and ``--force`` always means a full rebuild. A manifest that is
2864 missing, unreadable or empty leaves the full path in place: "no rows" means
2865 "unknown", never "nothing changed".
2866
2867 ``acquire_lock`` (default True) takes a non-blocking per-repo flock around
2868 the rebuild so concurrent post-commit hooks across multiple repos do not
2869 pile up. Returns False with a log line if the lock is held. Pass
2870 ``block_on_lock=True`` to wait instead of skip (used by the interactive
2871 ``graphify update`` CLI).
2872
2873 ``no_cluster`` skips community detection and writes raw merged extraction
2874 JSON to graphify-out/graph.json (mirrors ``extract --no-cluster``).
2875
2876 Returns True on success, False on error or skipped-due-to-lock.
2877 """
2878 frozen = _gc_frozen_here()
2879 try:
2880 return _rebuild_code_inner(
2881 watch_path,
2882 changed_paths=changed_paths,
2883 incremental=incremental,
2884 follow_symlinks=follow_symlinks,
2885 force=force,
2886 no_cluster=no_cluster,
2887 acquire_lock=acquire_lock,
2888 block_on_lock=block_on_lock,
2889 )

Calls 3

_gc_frozen_hereFunction · 0.85
_rebuild_code_innerFunction · 0.85
_gc_unfreezeFunction · 0.85