feat(slice): opt-in AST-based dependency closure for pattern slices (prototype) - #1469
Closed
pyramation wants to merge 1 commit into
Closed
feat(slice): opt-in AST-based dependency closure for pattern slices (prototype)#1469pyramation wants to merge 1 commit into
pyramation wants to merge 1 commit into
Conversation
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Prototype for constructive-io/constructive-planning#1270 — do not merge as-is. Cherry-picking a change with
PatternStrategytoday requires hand-written globs covering its full dependency closure; undeclared dependencies (e.g. a PL/pgSQL body calling a function absent from therequiresheader) are silently left behind. This adds an opt-in closure mode to the slicer that parses each change's deploy SQL (pgsql AST + hydrated PL/pgSQL body walk viaplpgsql-parser) and pulls the true transitive closure into the package, with a report of what was auto-included and why.slice/refs.ts—extractSqlFacts(sql): created objects + schema-qualified references (tables/views, function calls incl. inside PL/pgSQL bodies, types, FK targets, triggerEXECUTE FUNCTIONtargets) +dynamicSqlflag. Callersawait loadModule()once (WASM parser).slice/closure.ts—buildAstEdges(graph, moduleDir): producer index (object → first plan change creating it) → change→change edges, intersected with plan-known changes; unresolvable refs reported, never guessed.expandClosures: BFS from each closure-enabled slice's seeds over declaredrequires∪ AST edges; only pulls changes currently in the default package — deps claimed by another explicit slice stay put as ordinary cross-package deps.requires/ deploy order) via a new optionalextraEdgesarg onbuildPackageDependencies, but never planrequireslines (body refs are late-binding and may legitimately be mutually recursive).dynamicSqlChanges(EXECUTE — refs invisible to the AST) andunresolvedReferences(objects no plan change produces, e.g. installed modules).SliceConfig.closure+ aclosure: trueslice, nothing new runs.New deps on
@pgpmjs/core:@pgsql/traverse,plpgsql-parser(both already used elsewhere in the constructive ecosystem).Tests:
__tests__/slice/slice-closure.test.ts(9 tests) — headline case: cherry-pickingschemas/api/**auto-pullsbilling.calc_total→billing.invoices→billingschema purely from PL/pgSQL body references not declared in anyrequiresheader. Existing slice tests unchanged and passing.Open question tracked in the issue: whether
refs.tsshould be replaced by a shared@pgsql/facts-style package extracted from constructive-db'stransform-schemasclassifier.Link to Devin session: https://app.devin.ai/sessions/1aa52746e60c4df38ef2678d168269b9
Requested by: @pyramation