fix(graph): re-absolutize repo-scoped bundle paths on import (#1509) - #1627
Open
ASHMEET555 wants to merge 1 commit into
Open
fix(graph): re-absolutize repo-scoped bundle paths on import (#1509)#1627ASHMEET555 wants to merge 1 commit into
ASHMEET555 wants to merge 1 commit into
Conversation
…ond bundle is not treated as a duplicate
|
@ASHMEET555 is attempting to deploy a commit to the shashankss1205's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1509 (GSSoC'26).
Repo-scoped export (
cgc bundle export --repo) correctly rewrites absolute paths to portable././…form. Import never inverted that rewrite, so every imported bundle landed withRepository.path = "."._check_existing_repositorythen matched on that path, so loading a second registry bundle (for example flask, then requests) was always refused as a duplicate.--clearwas the only workaround and it wiped the first bundle, which breaks the bundle-registry use case (#1180).Even if the existence check were skipped, File MERGE keys such as
./README.mdand Function/Classuids built fromname + path + line_numberwould collide across repos.Export is unchanged. Relative
.cgccontents stay portable. Import is now the inverse of the rewrite.Problem
metadata.repo_pathand the Repository node path are".". The path MATCH in_check_existing_repositorythen hits any previously imported repo-scoped bundle._PK_MAPMERGEs File/Directory/Repository onpath, so./README.mdfrom two repos would become one node._UID_PARTSbuildsuidfromname + path + line_number. Relative paths would makeparseat line 1 collide across repos.Solution
On import, rebase
././…onto a per-bundle destination root:~/.codegraphcontext/bundles/<sanitized_repo>Example:
pallets/flaskbecomes slugpallets__flask. Tests can passdestination_root=so they never touch the real home directory.Behaviour:
metadata.repo_pathand all bundle-relative node/edge string properties before MERGE._check_existing_repositorystill matches by name (same repo twice is still a duplicate) but does not treat././…as an identifying path.uidis rebuilt from_UID_PARTSso identity includes the dest root._delete_repositoryrefuses to delete whenr.pathis., becauseSTARTS WITH "./"would wipe every repo-scoped import.Upstream encryption/signing (
password,verify_key,payload_path) is preserved after rebase ontomain.Files changed
src/codegraphcontext/core/cgc_bundle.py— path helpers, import rebase, existence-check hardening, delete guard. Also threadsdestination_rootonimport_from_bundlewithout breakingpassword/verify_key.tests/unit/core/test_bundle_repo_scoped_import.py— new unit tests (mocked driver, no live graph DB).CLI and MCP call sites are unchanged. They pick up the default dest root.
Tests performed
Command:
python -m pytest tests/unit/core/test_bundle_repo_scoped_import.py tests/unit/core/test_bundle_edge_zero_id.py tests/unit/core/test_bundle_identifier_validation.py tests/unit/core/test_bundle_pk_map_coverage.py -q
Result: 87 passed.
Covered:
.,./README.md,.\src\a.py; absolute paths andos.pathleft alone.pallets/flask->pallets__flask; empty ->unknown."."does not issue MATCH (r:Repository {path: $path}); real absolute paths still do; name match still runs../README.mdMERGE with distinct pk_val values (flask vs requests dest roots)../._delete_repositoryno-ops when found path is".".Related existing bundle tests still pass: edge zero-id, identifier validation,
_PK_MAPcoverage.Checklist
., so importing a second bundle is always refused as a duplicate #1509)