Skip to content

graph.json stores absolute source_file paths, breaking portability across git worktrees and machines #555

Description

@lucasrcosta

Problem

graph.json stores source_file as absolute paths (e.g. /Users/alice/projects/myapp/src/lib/auth.ts). This makes the committed graph non-portable:

  • Git worktrees: building the graph in one worktree produces paths that don't resolve in sibling worktrees (same repo, different directory)
  • Teammates: cloning the repo gives a graph with paths pointing to the original author's machine
  • CI/CD: any pipeline that queries the graph gets paths from wherever it was last built

The graph is designed to be committed alongside the code. Absolute paths defeat that entirely.

Expected behavior

source_file should be stored relative to the project root (e.g. src/lib/auth.ts). Tools consuming the graph can resolve to absolute by joining with their own CWD, which is the standard convention for committed path references.

Workaround

We're post-processing graph.json in the post-commit and post-checkout hooks to strip the build-time CWD prefix:

cwd_prefix = str(Path('.').resolve()) + '/'
for node in graph_data['nodes']:
    sf = node.get('source_file') or ''
    if sf.startswith(cwd_prefix):
        node['source_file'] = sf[len(cwd_prefix):]

This works but shouldn't be necessary — the extraction step should write relative paths from the start.

Environment

  • graphifyy 0.5.0
  • macOS, git worktree setup (main worktree + multiple linked worktrees via conductor)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions