Problem
The edge merge logic in watch.py _rebuild_code() reads from existing.get("edges", []) but graph.json uses the key "links" (NetworkX node-link format). This means sem_edges is always an empty list and all semantic edges are silently dropped on every watcher rebuild.
This is the root cause behind #253 and #261. The fixes in 0.4.3, 0.4.4, and 0.4.5 added correct merge logic but all read from the wrong key, so the edge preservation never actually executes.
Node preservation works (reads "nodes", correct key). Hyperedge preservation works (reads "hyperedges", correct key). Only edge preservation is broken.
Fix
One line in watch.py, line 46:
# Before (broken)
sem_edges = [e for e in existing.get("edges", [])
# After (working)
sem_edges = [e for e in existing.get("links", existing.get("edges", []))
Falls back to "edges" for safety in case a future version changes the key.
Verification
Tested locally by patching the installed 0.4.5 watch.py:
| Metric |
Baseline |
Unpatched watcher |
Patched watcher |
| Total nodes |
587 |
588 |
588 |
| Total links |
534 |
396 |
531 |
| INFERRED |
49 |
13 |
47 |
| AMBIGUOUS |
2 |
0 |
2 |
| Edges touching docs |
138 |
3 |
138 |
| Doc INFERRED |
35 |
1 |
35 |
| Hyperedges |
22 |
22 |
22 |
| Patched watcher preserves nearly all semantic edges. The small delta (534 vs 531 links, 49 vs 47 INFERRED) is from edge deduplication during rebuild, not data loss. |
|
|
|
Problem
The edge merge logic in
watch.py_rebuild_code()reads fromexisting.get("edges", [])butgraph.jsonuses the key"links"(NetworkX node-link format). This meanssem_edgesis always an empty list and all semantic edges are silently dropped on every watcher rebuild.This is the root cause behind #253 and #261. The fixes in 0.4.3, 0.4.4, and 0.4.5 added correct merge logic but all read from the wrong key, so the edge preservation never actually executes.
Node preservation works (reads
"nodes", correct key). Hyperedge preservation works (reads"hyperedges", correct key). Only edge preservation is broken.Fix
One line in
watch.py, line 46:Falls back to
"edges"for safety in case a future version changes the key.Verification
Tested locally by patching the installed 0.4.5
watch.py: