You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor FalkorDB graph naming so each (project, branch) pair gets
its own graph: 'code:{project}:{branch}'. This lets concurrent agents
working on different branches of the same repo index in parallel
without overwriting each other.
Changes:
- api/graph.py: add DEFAULT_BRANCH, compose_graph_name(),
parse_graph_name(); Graph and AsyncGraphQuery constructors now
accept (name, branch=None); Graph.from_raw_name() classmethod for
internal callers that need to bypass composition (e.g. clone());
get_repos()/async_get_repos() now return {project, branch, graph}
dicts.
- api/info.py: branch-aware Redis hash keys
('{repo}:{branch}_info'); reads fall back to legacy '{repo}_info'
for un-migrated graphs.
- api/git_utils: GitRepoName() and switch_commit() thread branch
through; LegacyGitRepoName() retained for the migration helper.
- api/project.py: detect_branch() via 'git rev-parse --abbrev-ref
HEAD'; Project.__init__ / from_git_repository /
from_local_repository accept branch.
- api/index.py: all Pydantic request models gain
'branch: Optional[str]'; endpoints thread it into
AsyncGraphQuery + info functions; responses include 'branch'.
- api/cli.py: --branch flag on index / index-repo / search /
neighbors / paths / info; new 'cgraph migrate' command.
- api/migrations/per_branch.py (NEW): idempotent migration that
renames legacy '<project>' graphs to 'code:<project>:_default',
'{<project>}_info' Redis keys to '{<project>}:_default_info',
and '{<project>}_git' graphs to '{<project>}:_default_git'.
Supports --dry-run.
Tests:
- tests/test_per_branch_graphs.py (NEW): 24 unit tests covering
compose/parse helpers, Graph constructor branch awareness,
AsyncGraphQuery, info-key shape, GitRepoName shape, and migration
idempotency (with mocked FalkorDB).
- tests/test_async_graph.py, tests/test_cli.py,
tests/endpoints/test_list_repos.py: updated assertions for the
new dict return shape from get_repos / async_get_repos.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0 commit comments