Skip to content

[Bug]: cluster-only refuses to write when a document's file mention folds into its AST file node (#4389 follow-up) #4778

Closed

Description

@AndresDiagoM

Pre-flight checks

  • I have checked the Troubleshooting section in the README

What happened?

Follow-up to #4389, reported there by @jxamen after it was closed. I am filing it as a new issue so it gets tracked.

#4391 taught _lost_saved_semantic_nodes() about ghosts that build_from_json() folds into an AST twin on the same (source_file, label) key. It does not cover the second fold, Pass 2b (#3344). That pass merges a semantic node by label alone into the single AST file node the label names. This happens when a document mentions a file: the label is the file's path, but source_file is the document. On cluster-only, the reload folds that node away, and then two checks refuse the write:

  1. _lost_saved_semantic_nodes() reports the folded node as lost.
  2. to_json()'s node-count check (new_n < existing_n) refuses as well, because the saved graph held the mention and the AST file node as two separate nodes.

graphify cluster-only exits 1. GRAPH_REPORT.md and graph.html are not generated.

Steps to reproduce

Synthetic graph from @jxamen's comment, no sources or API calls needed. Save it as graphify-out/graph.json:

{"directed": false, "multigraph": false, "graph": {},
 "nodes": [
  {"id": "src_config", "label": "config.php", "source_file": "src/config.php", "file_type": "code", "source_location": "L1", "_origin": "ast"},
  {"id": "readme_config", "label": "src/config.php", "source_file": "README.md", "file_type": "code", "_origin": "semantic"},
  {"id": "readme", "label": "README.md", "source_file": "README.md", "file_type": "document", "_origin": "semantic"}],
 "links": [{"source": "readme", "target": "readme_config", "relation": "describes", "confidence": "EXTRACTED", "source_file": "README.md"}]}

Run graphify cluster-only . --no-label.

Error output or graph output

[graphify] WARNING: Refusing to overwrite — saved semantic node(s) are missing from the new graph: readme_config.
graph.json NOT written: refusing to overwrite (see warning above). GRAPH_REPORT.md, .graphify_labels.json and .graphify_analysis.json left untouched.
Loading existing graph...
Graph: 2 nodes, 1 edges

The describes edge is rewired to src_config, so nothing is lost. The node and its twin are the same node.

Graphify version

0.9.94 (my repro); @jxamen reports 0.9.95

Operating System

Windows

Python Version

3.13

Activity

  1. github-actions commented on Oct 26, 2026

    @github-actions

    Thanks for opening this issue, @AndresDiagoM. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

  2. safishamsi commented on Oct 27, 2026

    @safishamsi
    Member

    Fixed in v0.9.97 via #4779, now on PyPI (pip install graphifyy==0.9.97). The shrink guard counts a document mention that folds into its AST file twin as present, so cluster-only writes instead of refusing. Thanks for the report, @AndresDiagoM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions