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

Function _zero_node_stamped_code_sources

graphify/cli.py:866–955  ·  view source on GitHub ↗

Manifest-stamped code files with a registered extractor but ZERO nodes in the existing graph.json (#2543 heal). The failed-source unstamping only covers failures that happen AFTER it shipped; a manifest poisoned by an earlier run (extraction failed, hashes stamped anyway) keeps repo

(
    graph_path: Path,
    data: dict | None,
    scan_root: Path,
    unchanged_code: list[str],
    manifest_path: Path | None = None,
)

Source from the content-addressed store, hash-verified

864
865
866def _zero_node_stamped_code_sources(
867 graph_path: Path,
868 data: dict | None,
869 scan_root: Path,
870 unchanged_code: list[str],
871 manifest_path: Path | None = None,
872) -> list[str]:
873 """Manifest-stamped code files with a registered extractor but ZERO nodes
874 in the existing graph.json (#2543 heal).
875
876 The failed-source unstamping only covers failures that happen AFTER it
877 shipped; a manifest poisoned by an earlier run (extraction failed, hashes
878 stamped anyway) keeps reporting the file unchanged forever, and the only
879 documented recovery was deleting graphify-out/. A stamped file that the
880 graph has no nodes for, despite an extractor being wired up for it, is
881 exactly that state — re-queue it as changed. Bounded by the same no-wedge
882 property: if it fails again this run it is now left unstamped, and if it
883 succeeds its nodes enter graph.json so the next scan stops re-queuing it.
884
885 A file the extractor declines by design (data JSON, #2879) is a legitimate
886 stamped-but-zero-node row, not a poisoned one. Its manifest row carries
887 ``ast_empty: true``; skip those here or the heal re-queues them on every
888 incremental forever. A pre-#2879 manifest lacks the marker, so such a file
889 is re-queued once more, then stamped with it and left alone thereafter.
890
891 Membership mirrors the ``source_file`` spellings extracts store (#1897/
892 #1941: scan-root-relative, forward slash; absolute for out-of-root) and
893 compares NFC-normalized (#2210/#2221).
894 """
895 if data is None or not unchanged_code:
896 return []
897 from graphify.paths import nfc
898 ast_empty: set[str] = set()
899 if manifest_path is not None:
900 from graphify.detect import load_manifest
901 for _k, _v in load_manifest(str(manifest_path), root=scan_root).items():
902 if isinstance(_v, dict) and _v.get("ast_empty"):
903 ast_empty.add(nfc(_k))
904 try:
905 root_res = scan_root.resolve()
906 except (OSError, RuntimeError):
907 root_res = scan_root
908 # <out>/graphify-out/graph.json — legacy relative source_files may be
909 # anchored here instead of the scan root (<=0.9.16, #555/#1899).
910 out_base = graph_path.parent.parent
911 try:
912 out_base = out_base.resolve()
913 except (OSError, RuntimeError):
914 pass
915
916 present: set[str] = set()
917 for n in data.get("nodes", []):
918 if not isinstance(n, dict):
919 continue
920 sf = n.get("source_file")
921 if not sf or not isinstance(sf, str):
922 continue
923 present.add(nfc(sf))

Callers 1

dispatch_commandFunction · 0.85

Calls 6

load_manifestFunction · 0.90
nfcFunction · 0.90
_get_extractorFunction · 0.90
itemsMethod · 0.45
getMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected