Skip to content

fix(cache): standardize AST symbol cache paths using pathlib across OS - #5

Merged
Jaswanth1902 merged 2 commits into
Jaswanth1902:mainfrom
ius-sharma:fix/standardize-cache-paths-pathlib
Sep 30, 2026
Merged

Jaswanth1902 merged 2 commits into
Jaswanth1902:mainfrom
ius-sharma:fix/standardize-cache-paths-pathlib

Conversation

@ius-sharma

Copy link
Copy Markdown
Contributor

🎯 Problem Statement

Closes #2

File system paths on Windows use backslashes (\) and case-insensitive matching, while Linux and macOS use forward slashes (/). Previous raw string manipulations caused cache misses and path inconsistencies when Cartograph ran on different operating systems.

🛠️ Scope of Work Completed

  1. Audited & Refactored cartograph/:
    • Replaced raw string manipulations (replace('\\', '/'), string splits) with standard pathlib.Path.resolve() and pathlib.Path.as_posix().
    • Implemented _canonical_key() helper on ASTSymbolIndexer to guarantee deterministic relative POSIX keys across cache dictionaries (symbol_index, raw_cache, file_abstracts, file_dependencies, file_adjacency).
    • Refactored _determine_namespace() using Path.parts and as_posix().
    • Standardized path handling in EngrimAdapter and QdrantCodeIntelAdapter.
    • Cleanly resolved upstream git conflict markers in cartograph/server.py.
  2. Added Pytest Test Suite:
    • Added tests/test_symbol_cache_paths.py covering 9 cross-platform test cases (namespace isolation, cache key parity, tier payloads, read_ast_node symbol extraction, relational dependencies, temporal graphs, directory traversal, and JSON-RPC MCP handlers).
  3. Multi-OS GitHub Actions CI Matrix:
    • Created .github/workflows/test.yml running tests on ubuntu-latest, windows-latest, and macos-latest across Python 3.10, 3.11, and 3.12.

🧪 Verification

  • python cartograph/server.py --test passed locally on Windows.
  • pytest -v tests/ passed (9/9 tests green).
  • All cache operations use pathlib.Path standard methods.

- Refactor ASTSymbolIndexer to standardize all cache paths using pathlib.Path
- Add _canonical_key to normalize relative forward-slash POSIX paths
- Refactor _determine_namespace to use pathlib.Path.parts and as_posix
- Normalize path resolution in index_file, get_tier_payload, read_ast_node, and get_file_dependencies
- Standardize project_dir in EngrimAdapter and storage_path in QdrantCodeIntelAdapter
- Resolve merge conflict markers in run_self_test
- Add test suite in tests/test_symbol_cache_paths.py verifying cross-platform parity
- Add test optional dependency with pytest in pyproject.toml
@coderabbitai

coderabbitai Bot commented Sep 28, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: dd9f7ee2-45a3-4995-9dc2-62994c1e281e


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ius-sharma

Copy link
Copy Markdown
Contributor Author

Hi @Jaswanth1902, I have completed the cross-platform standardization using pathlib.Path, added a 9-test pytest suite, and set up the multi-OS GitHub Actions matrix.

Submitted the Pull Request for review!

@Jaswanth1902

Copy link
Copy Markdown
Owner

🛡️ Antigravity 5-Persona Council Review: APPROVED (Score: 98/100)

@ius-sharma Incredible work on standardizing cross-platform AST symbol cache paths!

  • Architect (98/100): Canonical POSIX key mapping via _canonical_key() cleanly decouples Cartograph from OS path variations while preserving deterministic lookups.
  • Security Warden (99/100): Zero credentials leaked; verified safe pathlib containment preventing directory traversal.
  • Performance Engineer (97/100): Eliminates dual-key cache pollution on Windows, cutting redundant memory allocations and re-indexing overhead.
  • Craftsmanship Arbiter (99/100): Clean-room engineering, full typing coverage, and pristine resolution of historical git conflict markers in cartograph/server.py.
  • Contrarian (96/100): Passed the Pixar Shaded Penny Test—directly addresses Issue cross-platform: Standardize AST symbol cache paths using pathlib.Path across Linux/macOS/Windows #2 and resolves actual cache thrashing across operating systems.

Local verification:

  • python cartograph/server.py --test passed.
  • pytest -v tests/test_symbol_cache_paths.py passed (9/9 green in 2.84s).

Thank you for this high-impact contribution!

@ius-sharma

Copy link
Copy Markdown
Contributor Author

@Jaswanth1902 are you going to merge this ??

@Jaswanth1902
Jaswanth1902 merged commit 2368850 into Jaswanth1902:main Sep 30, 2026
1 check passed
@Jaswanth1902

Copy link
Copy Markdown
Owner

@ius-sharma Yes! PR #5 has just been merged into main (2368850).

All local tests, AST verifications, and cross-platform fixtures passed cleanly. Issue #2 is resolved. Really appreciate your speed, clean code hygiene, and thorough test matrix! 🚀

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.

cross-platform: Standardize AST symbol cache paths using pathlib.Path across Linux/macOS/Windows

2 participants