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

Function _zero_node_stamped_semantic_sources

graphify/cli.py:958–1045  ·  view source on GitHub ↗

Manifest-stamped semantic files (doc/paper/image) with ZERO nodes and ZERO hyperedges in the existing graph.json (#2927 heal). A manifest poisoned before #2927 (edge-only result cached and stamped) keeps reporting the file unchanged forever, freezing it out of the graph. Re-queue an

(
    graph_path: Path,
    data: dict | None,
    scan_root: Path,
    unchanged_semantic: list[str],
)

Source from the content-addressed store, hash-verified

956
957
958def _zero_node_stamped_semantic_sources(
959 graph_path: Path,
960 data: dict | None,
961 scan_root: Path,
962 unchanged_semantic: list[str],
963) -> list[str]:
964 """Manifest-stamped semantic files (doc/paper/image) with ZERO nodes
965 and ZERO hyperedges in the existing graph.json (#2927 heal).
966
967 A manifest poisoned before #2927 (edge-only result cached and stamped)
968 keeps reporting the file unchanged forever, freezing it out of the graph.
969 Re-queue any unchanged semantic file that has neither nodes nor hyperedges
970 in graph.json. If it succeeds, its nodes enter graph.json; if it produces
971 no nodes or fails, it is now left unstamped, so this cannot wedge.
972
973 Membership mirrors the ``source_file`` spellings extracts store (#1897/
974 #1941: scan-root-relative, forward slash; absolute for out-of-root) and
975 compares NFC-normalized (#2210/#2221).
976 """
977 if data is None or not unchanged_semantic:
978 return []
979 from graphify.paths import nfc
980 try:
981 root_res = scan_root.resolve()
982 except (OSError, RuntimeError):
983 root_res = scan_root
984 out_base = graph_path.parent.parent
985 try:
986 out_base = out_base.resolve()
987 except (OSError, RuntimeError):
988 pass
989
990 present: set[str] = set()
991 for n in data.get("nodes", []):
992 if not isinstance(n, dict):
993 continue
994 sf = n.get("source_file")
995 if not sf or not isinstance(sf, str):
996 continue
997 present.add(nfc(sf))
998 p = Path(sf)
999 if p.is_absolute():
1000 try:
1001 present.add(nfc(str(p.resolve())))
1002 except (OSError, RuntimeError):
1003 pass
1004 else:
1005 rel = sf.replace("\\", "/")
1006 for base in (root_res, out_base):
1007 present.add(nfc(os.path.normpath(str(base / rel))))
1008
1009 hyper_items = list(data.get("hyperedges", []) or [])
1010 if isinstance((data.get("graph") or {}).get("hyperedges"), list):
1011 hyper_items.extend(data["graph"]["hyperedges"])
1012 for h in hyper_items:
1013 if not isinstance(h, dict):
1014 continue
1015 sf = h.get("source_file")

Callers 1

dispatch_commandFunction · 0.85

Calls 3

nfcFunction · 0.90
resolveMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected