Skip to content

bug: to_json does not relativize source_file on graph.hyperedges[] entries — only nodes[] and links[] #1418

Closed

Description

@shiv-source

What happens

build_from_json(extraction, root=...) correctly relativizes source_file on nodes[] and links[], but entries in graph.hyperedges[] retain their absolute paths.

Steps to reproduce

  1. Run /graphify . on a project with at least one doc/md file (so semantic extraction fires and produces hyperedges)
  2. Check graphify-out/graph.json — hyperedge source_file values are absolute
  3. All other source_file values (nodes, links) are correctly relative

Example

// graph.json — nodes and links are relative:
{ "source_file": "package.json" }

// But hyperedges retain absolute paths:
{
  "graph": {
    "hyperedges": [
      {
        "id": "watchdog_architecture_patterns",
        "source_file": "/Users/.../CLAUDE.md"   // ← absolute, should be "CLAUDE.md"
      }
    ]
  }
}

Root cause

The semantic extraction subagent is told to copy source_file verbatim from FILE_LIST (which contains absolute paths per the extraction spec). The contract is that build_from_json() relativizes everything downstream, but to_json only processes nodes[] and links[] — the graph.hyperedges[] array is written as-is.

Expected behavior

source_file on hyperedge entries should be relativized to the scan root, same as nodes and links.

Workaround

Manually strip the root prefix from hyperedge source_file values after the graph is written.

Activity

  1. safishamsi commented on Jun 22, 2026

    @safishamsi
    Member

    Fixed on v8 (ships in the next release).

    build_from_json now relativizes source_file on graph.hyperedges[] exactly like it does for nodes[] and links[] (d168de9). The fix lives in build_from_json rather than to_json because build_from_json is the one that has the scan root — to_json has no root to relativize against, so it can only write what it's given.

    Verified end-to-end with a real claude-cli extraction: a doc that produces a hyperedge now writes it with a relative source_file (architecture.md, not an absolute path).

    Related follow-up: while verifying this, I found the native-backend extraction prompt never actually requested hyperedges (its schema example showed "hyperedges":[] and never described them), so graphify extract --backend X emitted zero — only the agent/skill path produced them. That prompt drift is now fixed too (aad3b47), so native backends emit hyperedges and this relativization path is exercised in practice.

  2. added a commit that references this issue on Jun 22, 2026
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