Skip to content

feat: Google Cloud Spanner Graph integration - #766

Draft
m-guesnon-pvotal wants to merge 17 commits into
CodeGraphContext:mainfrom
pvotal-tech:feature/spanner_support
Draft

feat: Google Cloud Spanner Graph integration#766
m-guesnon-pvotal wants to merge 17 commits into
CodeGraphContext:mainfrom
pvotal-tech:feature/spanner_support

Conversation

@m-guesnon-pvotal

Copy link
Copy Markdown

This PR formally integrates Google Cloud Spanner Graph as a first-class supported database backend for both the CodeGraphContext CLI and the internal MCP server.
Previously, cgc was strictly tied to Neo4j and Kuzu/FalkorDB. By introducing a native Spanner backend, developers can now securely host their CodeGraph indexes inside their GCP environment at enterprise scale while avoiding the maintenance overhead of a separate graph cluster.

Key Changes

  • SpannerDBManager: Created core/database_spanner.py to seamlessly execute Graph operations.
  • Dynamic Query Translation: Implemented a query middleware that intelligently maps standard Neo4j-style Cypher MERGE queries into native Spanner INSERT OR UPDATE SQL DML statements, ensuring DDL compliance while seamlessly routing MATCH read operations natively via Spanner GQL.
  • CLI Setup Wizard: Fully replicated the Neo4j setup wizard for Spanner. Users can type cgc spanner setup (or cgc s) to authenticate using Application Default Credentials (ADC) and bind their GCP Project, Instance, and Database IDs locally. Spanner configuration will natively fall back to sensible defaults when environment variables are omitted.
  • MCP Server Parity: Enabled dynamic database backend switching—the MCP server naturally inherits the CGC_RUNTIME_DB_TYPE=spanner configuration on boot and immediately begins routing file watch telemetry and structural graph analysis commands into the Spanner cluster.

Additional Bug Fixes

  • Fixed visualize crashes: Addressed an issue caused by upstream commit fbe8b9e, where the visualizer commands and submodules were deleted from the codebase, but the corresponding import references inside cli/main.py were accidentally kept. This oversight was causing an immediate ModuleNotFoundError for anyone manually importing the codebase off the main branch. Removed the dangling imports and mock-disabled the visualizer shortcut cleanly so the CLI successfully boots again.

Verification

  • Validated cgc spanner setup binds variables safely.
  • Tested core schema generation and indexing operations safely against a live Spanner Graph instance via the CLI wrapper.
  • Ensured that the default Neo4j fallback behavior isn't affected.

@vercel

vercel Bot commented Mar 29, 2026

Copy link
Copy Markdown

@m-guesnon-pvotal is attempting to deploy a commit to the shashankss1205's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Shashankss1205

Copy link
Copy Markdown
Collaborator

Hey @m-guesnon-pvotal Can you please merge the latest changes and then add these on top of them. I re-added some parts of the visualization...

@m-guesnon-pvotal

Copy link
Copy Markdown
Author

@Shashankss1205 done.
Great job on this btw.
Note that I'm not really convinced by the approach on the "spanner wrapper" but that's the faster I could come up with.

@Shashankss1205

Copy link
Copy Markdown
Collaborator

Still in draft, so leaving it as-is — just flagging that it now conflicts with main in 9 places (pyproject.toml, config_manager.py, cli/main.py, core/__init__.py, tool_definitions.py, graph_builder.py, query_handlers.py). The backend registration surface in core/__init__.py in particular has changed shape since March.

No action needed if this is parked. If you do want to pick Spanner Graph support back up, rebasing sooner rather than later will be less painful — and worth noting #1302 is proposing changes to how backends are registered, which would affect this.

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.

2 participants