Skip to content

feat(slice): SqlObjectGraph — unified object-graph IR with cascade safety and ownership-based change pruning - #1536

Merged
devin-ai-integration[bot] merged 1 commit into
feat/pgpm-program-astfrom
feat/sql-object-graph
Jul 30, 2026
Merged

feat(slice): SqlObjectGraph — unified object-graph IR with cascade safety and ownership-based change pruning#1536
devin-ai-integration[bot] merged 1 commit into
feat/pgpm-program-astfrom
feat/sql-object-graph

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

Stage 4 foundation (constructive-planning #1322/#1323), stacked on #1535: the semantic object-graph IR over parsed SqlPrograms. This is the single graph that exclusion, routing, and plan pruning are meant to share — replacing survivor-counting and flattened whole-module classification with graph queries.

New pgpm/slice/src/object-graph.ts:

buildObjectGraph(programs: Map<changeName, SqlProgram>): SqlObjectGraph
// nodes: objects → { ref, createdBy: StatementId[] }
// edges: statement → object, kind: 'reference' | 'body' | 'fk'
// incoming: object key → in-edges

objectsInSchemas(graph, schemas)   // subsystem selection by schema
danglingEdges(graph, dropped)      // cascade safety: in-edges to dropped objects
                                   // whose source statement is not itself dropped
prunablePrograms(graph, dropped)   // whole changes owned by the dropped set —
                                   // read from ownership, not counted from survivors

Semantics worth noting:

  • Cascade safety falls out of the graph: auth.uid()'s body reference to auth.users does not dangle when both are dropped (its source statement creates a dropped object), while a surviving FK / policy accessor into the same table does — tested with exactly this shape.
  • Change pruning is ownership-based: a program is prunable iff every object-creating statement creates only dropped objects; mixed programs and pure-grant programs are never pruned. This replaces the dropped>0 && survivors==0 counting heuristic in the apply path (rewiring materialize onto these queries is the follow-up).
  • Statement identity is {program, statement} against the shared SqlProgram from feat(transform): SqlProgram — statement-level program AST with dirty-aware verbatim/deparse emission #1535, so the graph, exclusion analysis, and emission all reference the same single parse.

Pure/I-O-free; 6 new tests (54 total in slice green).

Link to Devin session: https://app.devin.ai/sessions/025fb88043964fdbb335ac5e39df2478
Requested by: @pyramation

@pyramation pyramation self-assigned this Jul 30, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration
devin-ai-integration Bot merged commit fe75a40 into feat/pgpm-program-ast Jul 30, 2026
3 checks passed
@devin-ai-integration
devin-ai-integration Bot deleted the feat/sql-object-graph branch July 30, 2026 21:27
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