Skip to content

feat(query): add project-scoped filtering to Cypher queries for multi-project databases #500

Description

@vitali87

Problem

When multiple projects are indexed in the same Memgraph database, Cypher queries return results from all projects without disambiguation. The Cypher system prompt and examples do not mention filtering by project, so LLM-generated queries cannot scope results to a specific project.

This is distinct from #425 (cross-project indexing). That issue is about enabling cross-project retrieval. This issue is about the opposite: ensuring queries can be scoped to a single project when desired.

Current Behavior

A query like "show all classes" returns classes from every indexed project. The user has no way to scope queries to the project they are working on.

Expected Behavior

  1. The Cypher system prompt should include the current project name as context
  2. Query examples should demonstrate project-scoped patterns (e.g., MATCH (p:Project {name: $project})-[:CONTAINS_PACKAGE*]->...)
  3. The query tool should automatically inject the project scope when a single project is being queried

Affected Components

  • codebase_rag/prompts.py (CYPHER_SYSTEM_PROMPT, LOCAL_CYPHER_SYSTEM_PROMPT)
  • codebase_rag/tools/codebase_query.py (query execution)
  • codebase_rag/cypher_queries.py (example queries)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions