Skip to content

Strict schema validation, LLM fallback, robust graph builder, and GraphView refactor#3

Draft
vishwateja231 wants to merge 1 commit into
mainfrom
codex/fix-critical-issues-in-llm-to-sql-system
Draft

Strict schema validation, LLM fallback, robust graph builder, and GraphView refactor#3
vishwateja231 wants to merge 1 commit into
mainfrom
codex/fix-critical-issues-in-llm-to-sql-system

Conversation

@vishwateja231

Copy link
Copy Markdown
Owner

Motivation

  • Harden LLM-to-SQL pipeline by removing permissive auto-corrections and enforcing exact schema names, while adding a fallback SQL generator to mitigate rate limits.
  • Make graph construction data-driven so entities are discovered from arbitrary SAP column names and rows produce stable node/edge payloads.
  • Simplify and modernize the frontend graph viewer for consistent styling, improved force layout, and more resilient handling of external graph payloads.

Description

  • Replace permissive column/table aliasing with strict validation in schema_enforcer.py by disabling the column mapping and autocorrect_sql, tightening validate_sql_columns to check table-qualified refs and aliases, and keeping an authoritative SAP_TABLES list.
  • Update SQL generation/validation flow in routers/query.py to remove mapping injection, stop auto-correct usage, add a single-retry UX for DB errors, change some error messages (e.g. return "Invalid column in query" when SQL generation fails), and add a Gemini-based SQL generation fallback via _gemini_sql_call when Groq is rate-limited.
  • Rework graph_builder.py to be data-driven: introduce ENTITY_COLUMN_MAP, normalize values, extract entities per-row (_extract_entities_in_row), create nodes via _make_node, build edges from same-row entity order with a generic related label, and produce a fallback record node when no entities found.
  • Refactor frontend GraphView.jsx to streamline UI and styling: update NODE_COLORS, remove the search box and error toast, add styleGraph to normalize incoming graph payloads, tune d3 force parameters, ensure theme-aware styles, and simplify ReactFlow panels and node/edge styling.

Testing

  • Ran backend unit and integration checks including schema_enforcer and graph_builder smoke tests; checks passed locally with the existing test suite.
  • Performed an end-to-end smoke run that exercised the LLM SQL generation fallback path and DB error retry logic, and observed successful fallback to Gemini when simulated rate limits occurred.
  • Built the frontend (yarn build) and ran the dev server to verify GraphView renders styled nodes/edges and applies force layout; the build and manual render smoke checks succeeded.

Codex Task

@vercel

vercel Bot commented Mar 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dodge Ready Ready Preview, Comment Mar 25, 2026 5:40am

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.

1 participant