Skip to content

fix: use project-relative paths in manifest.json and GRAPH_REPORT.md#778

Open
luw2007 wants to merge 1 commit into
safishamsi:v7from
luw2007:fix/use-relative-paths-in-output
Open

fix: use project-relative paths in manifest.json and GRAPH_REPORT.md#778
luw2007 wants to merge 1 commit into
safishamsi:v7from
luw2007:fix/use-relative-paths-in-output

Conversation

@luw2007
Copy link
Copy Markdown

@luw2007 luw2007 commented May 8, 2026

Summary

  • manifest.json keys now store project-relative paths instead of absolute paths (e.g. src/main.py instead of /Users/foo/project/src/main.py)
  • GRAPH_REPORT.md title uses the directory name instead of the full absolute path
  • detect_incremental is backwards-compatible: matches both legacy absolute keys and new relative keys

Motivation

Absolute paths in output files leak local filesystem structure and break portability — the same graph output produces different content on different machines, making it impossible to commit graphify-out/ to version control or share across environments.

Test plan

  • tests/test_detect.py — all 33 tests pass (including incremental + symlink tests)
  • tests/test_report.py, tests/test_build.py, tests/test_ingest.py — all pass
  • No new ruff lint errors introduced
  • Backwards compatible: existing manifests with absolute keys still work via fallback lookup

manifest.json keys and the GRAPH_REPORT.md title previously stored
absolute paths (e.g. /Users/foo/project/src/main.py), leaking local
filesystem structure and breaking portability across machines.

- save_manifest: relativize file paths against project root before
  writing them as JSON keys
- detect_incremental: look up both absolute and relative keys so
  existing (legacy absolute) manifests still match correctly
- cluster-only report: pass directory name instead of full absolute
  path to the report title
@luw2007 luw2007 force-pushed the fix/use-relative-paths-in-output branch from dd8fb1f to 04f0fcc Compare May 8, 2026 07:36
Copy link
Copy Markdown
Owner

@safishamsi safishamsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good direction — manifest relativization in detect.py and __main__.py is correct and the backwards-compat reading of legacy absolute keys is well handled. Two things need fixing.

Required changes

1. watch.py:148 not updated

save_manifest(detected["files"]) is called with no root argument. The new fallback resolves root to Path.cwd(), which only works when CWD matches the watch path. Running graphify watch /some/other/path from a different directory will still write absolute manifest keys. Fix: pass root=watch_root and manifest_path=str(out / "manifest.json") explicitly.

2. No tests for the new behaviour

No test asserts that saved manifest keys are relative, and none exercises the legacy-absolute-key backwards-compat path. A small addition to tests/test_detect.py covering both cases would lock in the contract cheaply.

Minor (non-blocking)

  • watch_path.name or str(watch_path) at __main__.py:1609 returns a literal "." for Path(".") — reusing _report_root_label from watch.py would be cleaner
  • Issue #722 will remain partially open after this PR (.graphify_root, .graphify_incremental.json, and the .gitignore guidance are not addressed) — worth noting in the PR description so #722 isn't closed prematurely

@gnrlbzik
Copy link
Copy Markdown

gnrlbzik commented May 8, 2026

@safishamsi @luw2007 can this pr also introduce gitignore template per #722

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants