mirror of
https://github.com/safishamsi/graphify.git
synced 2026-07-23 07:41:46 +00:00
#1586: the skill's interpreter-detection allowlist rejected any shebath path with a char outside [a-zA-Z0-9/_.-], so Homebrew's versioned python@3.13 path was skipped and detection fell through to a bare python3 without graphify. Allow @ in the skillgen source fragments (core/devin/aider/posix), regenerate all skill artifacts, and register the change as a sanctioned monolith diff. Injection chars (; $ ( etc.) are still rejected. #1606: graphify merge-graphs crashed with an unhandled NetworkXError when inputs disagreed on directed/multigraph. _to_simple only converted MultiGraph, leaving a DiGraph to fail compose. Normalize every input to a plain undirected Graph (the merged cross-repo view is undirected anyway). Also confirmed on v8: `graphify kilo install` (#1605) works (reporter was on an older version), and `pip3 install graphifyy` failing on macOS (#1585) is a broken Homebrew Python 3.14 / pyexpat env, not a graphify issue — pip crashes in its own vendored distlib before graphify is touched. skillgen --check / --monolith-roundtrip / --schema-singleton all green; shell smoke accepts python@3.13 and still rejects `; rm -rf /` and `$(evil)`. Full suite 2789. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
49 lines
1.9 KiB
Python
49 lines
1.9 KiB
Python
"""`graphify merge-graphs` tolerates inputs that disagree on graph type (#1606).
|
|
|
|
Per-repo graph.json files written by different extract paths at different times
|
|
don't always agree on the `directed` / `multigraph` flags. compose requires one
|
|
uniform type, so a mixed set used to crash with an unhandled NetworkXError. The
|
|
handler now normalizes every input to a plain undirected Graph before composing.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
PYTHON = sys.executable
|
|
|
|
|
|
def _run(args, cwd):
|
|
return subprocess.run([PYTHON, "-m", "graphify"] + args, cwd=cwd,
|
|
capture_output=True, text=True)
|
|
|
|
|
|
def _write(p: Path, directed: bool, multigraph: bool, node_id: str):
|
|
p.parent.mkdir(parents=True, exist_ok=True)
|
|
p.write_text(json.dumps({
|
|
"directed": directed, "multigraph": multigraph, "graph": {},
|
|
"nodes": [{"id": node_id}], "links": [],
|
|
}))
|
|
|
|
|
|
def test_merge_graphs_mixed_directed_and_multigraph(tmp_path):
|
|
a = tmp_path / "r1" / "graphify-out" / "graph.json"
|
|
b = tmp_path / "r2" / "graphify-out" / "graph.json"
|
|
c = tmp_path / "r3" / "graphify-out" / "graph.json"
|
|
_write(a, directed=True, multigraph=False, node_id="x") # DiGraph
|
|
_write(b, directed=False, multigraph=False, node_id="y") # Graph
|
|
_write(c, directed=False, multigraph=True, node_id="z") # MultiGraph
|
|
out = tmp_path / "merged.json"
|
|
|
|
r = _run(["merge-graphs", str(a), str(b), str(c), "--out", str(out)], tmp_path)
|
|
assert r.returncode == 0, f"merge crashed: {r.stderr}"
|
|
assert out.exists()
|
|
data = json.loads(out.read_text())
|
|
ids = {n["id"] for n in data["nodes"]}
|
|
# every input's node survives, normalized into one undirected simple graph
|
|
assert {"r1::x", "r2::y", "r3::z"} <= ids or len(ids) == 3
|
|
assert data.get("directed") is False
|
|
assert data.get("multigraph") is False
|