feat: add store.subgraph() for typed neighborhood extraction#33
Merged
Conversation
1c21f16 to
d007daa
Compare
Implements BFS traversal from a root node via recursive CTE, returning all reachable nodes and connecting edges as a typed discriminated union. Supports multi-edge-kind traversal, bidirectional edges, includeKinds filtering, excludeRoot, cycle detection, and soft-delete exclusion.
d007daa to
1b10d83
Compare
Merged
pdlug
added a commit
that referenced
this pull request
Mar 9, 2026
…ge, SubsetNode, SubsetEdge) Adds compile-time and runtime tests verifying the discriminated union type utilities introduced in #33. Compile-time tests assert type assignability and subset rejection via @ts-expect-error. Runtime tests verify kind-based narrowing exposes correct schema-specific properties.
pdlug
added a commit
that referenced
this pull request
Mar 9, 2026
…ge, SubsetNode, SubsetEdge) (#35) Adds compile-time and runtime tests verifying the discriminated union type utilities introduced in #33. Compile-time tests assert type assignability and subset rejection via @ts-expect-error. Runtime tests verify kind-based narrowing exposes correct schema-specific properties.
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
store.subgraph(rootId, options)for BFS subgraph extraction via recursive CTEincludeKindsfiltering,excludeRoot, cycle detection (prevent/allow), and soft-delete exclusionSubsetNode<G, NK>[],SubsetEdge<G, EK>[]) with compile-time narrowing viaincludeKindsCROSS JOIN+INSTRpath for worktable ordering; PostgreSQL uses standardJOIN ON+ array-based cycle detectionWhat shipped
Type utilities (zero runtime cost):
AnyNode<G>— discriminated union of all runtime node instancesAnyEdge<G>— discriminated union of all runtime edge instancesSubsetNode<G, K>— narrowed to selected node kindsSubsetEdge<G, K>— narrowed to selected edge kindsstore.subgraph(rootId, options):maxDepth(default 10, capped atMAX_RECURSIVE_DEPTH)includeKinds— filter result nodes while still traversing through excluded kindsexcludeRoot— omit the root node from resultsdirection: "out" | "both"— unidirectional or bidirectional traversalcyclePolicy: "prevent" | "allow"— dialect-aware cycle detectionCROSS JOINpattern)Closes #31