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

Function section_root

graphify/sections.py:86–103  ·  view source on GitHub ↗

The project root section reads are confined to, for the graph at ``gp``. For a graph in `` /graphify-out`` a ``.graphify_root`` marker may only narrow the root to a folder inside the project, never widen it, so a committed marker cannot open the rest of the disk to reads.

(gp: Path)

Source from the content-addressed store, hash-verified

84
85
86def section_root(gp: Path) -> Path:
87 """The project root section reads are confined to, for the graph at ``gp``.
88
89 For a graph in ``<project>/graphify-out`` a ``.graphify_root`` marker may
90 only narrow the root to a folder inside the project, never widen it, so a
91 committed marker cannot open the rest of the disk to reads.
92 """
93 from graphify.paths import GRAPHIFY_OUT, graph_root_for
94
95 root = graph_root_for(gp)
96 out = Path(GRAPHIFY_OUT).parts
97 if out and not Path(GRAPHIFY_OUT).is_absolute() and gp.parent.parts[-len(out):] == out:
98 project = gp.parent.parents[len(out) - 1]
99 try:
100 root.resolve().relative_to(project.resolve())
101 except (OSError, RuntimeError, ValueError):
102 return project
103 return root
104
105
106def is_section_node(node: dict) -> bool:

Callers 3

dispatch_commandFunction · 0.90
_tool_get_sectionFunction · 0.90

Calls 2

graph_root_forFunction · 0.90
resolveMethod · 0.45