Skip to content

Relative graph paths (schema v16) and parse each Python file with ast once - #1234

Closed
brijesh-neo wants to merge 2 commits into
tirth8205:stagingfrom
brijesh-neo:perf/relative-paths-and-parse-once
Closed

brijesh-neo wants to merge 2 commits into
tirth8205:stagingfrom
brijesh-neo:perf/relative-paths-and-parse-once

Conversation

@brijesh-neo

Copy link
Copy Markdown

Summary

Two changes, one commit each.

1. Store graph paths relative to the repository (schema v16). A graph.db copied into a linked worktree, fork or clone now answers with that checkout's paths.

  • In-repo paths are stored as ./rel (the root as .). Paths outside the root stay absolute, and values that would read as relative are escaped with !.
  • Translation happens at the SQLite connection, so callers keep seeing absolute paths.
  • Older graphs get a one-time copy-and-swap conversion. Other openers get a "try again" error while it runs.
  • A copied graph's first update runs a full build, because extra JSON still names the checkout it was built in.
  • MCP tools take an optional cwd. Inside the repository, result paths are repo-relative; otherwise they stay absolute.
  • doctor, embeddings, the import audit script and the incremental-fidelity benchmark decode stored paths.
  • The VS Code extension reads both formats (SUPPORTED_SCHEMA_VERSION 16).

2. Parse each Python file with ast once instead of three times. Function scopes, dead-branch calls and dead-branch imports now share one cached tree. Parsing this repository's 408 Python files goes from 9.3 s to 8.7 s, with byte-identical output.

Tests

  • Each change adds a test that fails without it and passes with it, including tests/test_python_file_ast_parsed_once.py.
  • ruff is clean.
  • The full suite on this combined branch is still running locally. I'll post the result here.

🤖 Generated with Claude Code

brijesh-neo and others added 2 commits November 19, 2026 16:03
A graph.db copied into a linked worktree, fork or clone now answers with
that checkout's paths. In-repo paths are stored as ./rel (the root as .),
paths outside the root stay absolute, and values that would read as
relative are escaped with !. Translation happens at the SQLite connection,
so callers keep seeing absolute paths.

- One-time copy-and-swap conversion of older graphs; other openers get a
  "try again" error while it runs. Rows that collide under two spellings
  of the root no longer end the copy early.
- A copied graph's first update runs a full build, because extra JSON
  still names the checkout it was built in.
- MCP tools take an optional cwd: inside the repository, result paths are
  repo-relative; otherwise they stay absolute.
- doctor, embeddings, the import audit script and the incremental-fidelity
  benchmark decode stored paths.
- VS Code extension reads both formats (SUPPORTED_SCHEMA_VERSION 16).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Function scopes, dead-branch calls and dead-branch imports each ran
ast.parse on the same bytes. They now share one cached tree; none of them
modifies it. Parsing this repository's 408 Python files goes from 9.3 s
to 8.7 s with byte-identical output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brijesh-neo

Copy link
Copy Markdown
Author

Opened here by mistake; closing.

@brijesh-neo
brijesh-neo deleted the perf/relative-paths-and-parse-once branch November 22, 2026 06:43
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.

1 participant