Skip to content

feat: graph utilization improvements for description generation and text2sql - #78

Merged
mingjerli merged 17 commits into
mainfrom
feat/graph-utilization
Aug 12, 2026
Merged

feat: graph utilization improvements for description generation and text2sql#78
mingjerli merged 17 commits into
mainfrom
feat/graph-utilization

Conversation

@mingjerli

Copy link
Copy Markdown
Owner

Summary

Implements all 9 features from the graph-utilization design specs (PR #77) as 12 commits — one per feature plus two final-review fixes. Each feature landed with tests written first and passed an independent spec+quality review before the next began.

Description generation (D2→D3→D4→D1):

  • refactor: incoming-edge lookups use the adjacency index (public Pipeline.get_incoming_edges), replacing O(V·E) scans
  • feat: new DescriptionSource.FALLBACK — rule-based placeholders are distinguishable, retried on rerun, and their text is excluded from downstream prompts (all sources now listed by name)
  • fix: terminal SELECTs get descriptions via shared target_table() resolution (parity with metadata propagation, spy-tested)
  • feat: include_sources=True describes source-table columns from forward usage context (build_source_description_prompt, dispatch on table_graph is_source — not is_computed(), which is True for parsed input nodes)

Text2SQL (T1→T4→T2→T3a→T3b→T5):

  • feat: one capped table set (resolve_context_tables) feeds schema, relationships, lineage, notes, and tables_used; column lineage now in the default direct strategy; lineage caps configurable
  • feat: source/intermediate/final role labels, prefer-final-tables instruction, role-priority truncation
  • feat: expand_with_lineage(depth) — transitive BFS (default 2), shallow-first, self-reference safe
  • feat: ## Join Hints — observed equi-joins extracted from query ASTs with scope-correct alias resolution (no fabrication from nested-subquery alias collisions; chained USING skipped; cross-query provenance kept)
  • feat: candidate joins from shared lineage sources, restricted to identity-preserving paths (AST-verified rename-only edges; aggregates/transforms fail closed; out-of-context sources not leaked into prompts)
  • feat: keyword-selection fallback gets 1-hop score diffusion and deterministic role-aware padding
  • fix: parenthesized ON conditions now resolve (final-review finding)
  • docs: changelog entries for all user-facing changes

Notable deviations from the specs (all review-driven)

  • Identity edge types are direct_column/star_passthrough/cross_query — the spec's "direct" never occurs; "expression" edges qualify only when the target's expression unaliases to a bare column (UPPER(email) AS x is rejected, pinned by test)
  • Observed joins carry a query_ids provenance list in addition to first-seen query_id
  • Several plan-authored tests were strengthened after reviewers proved them non-discriminating (parity spy test, truncation-priority test, keyword-selection adversarial fixtures — each empirically verified RED against pre-feature code)

Test plan

  • Full suite: 1664 passed, 40 skipped, 2 xfailed
  • Every feature commit: TDD (RED→GREEN evidence), task-scoped spec+quality review, scoped re-review of fixes
  • Final whole-branch review (composition verified end-to-end: direct-mode prompt contains schema + roles + relationships + lineage + join hints from one capped set)
  • Docs-site updates for new public API (get_incoming_edges, include_sources, build_source_description_prompt, ContextConfig fields) — follow-up PR in the docs submodule

🤖 Generated with Claude Code

https://claude.ai/code/session_01MCAw3ceZaN7roTDpAuUtYF

Switch example model to gemma4:31b (qwen3-coder:30b no longer pulled locally)
and refresh all stored outputs, including the new include_sources example
showing source columns described from forward usage.
…dation

BigQuery backticked identifiers (and other dialect-specific syntax) failed
dialect-less parsing, so generated SQL took the fail-open passthrough and
skipped destructive-statement validation entirely.
Demonstrates lineage-derived prompt context (table roles, column lineage,
observed and candidate join hints), direct vs two-stage strategies, and
LineageAgent routing, executed against gemma4:31b. Removes the enterprise
demo's dead SKIP_TEXT_TO_SQL flag in favor of the dedicated example.
@mingjerli
mingjerli merged commit 0ad3e15 into main Aug 12, 2026
11 checks passed
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