Skip to content

Add plugin-hook-based scoped PostgreSQL introspection - #3

Draft
Zetazzz wants to merge 2 commits into
mainfrom
agent/scoped-introspection-plugin-hook
Draft

Add plugin-hook-based scoped PostgreSQL introspection#3
Zetazzz wants to merge 2 commits into
mainfrom
agent/scoped-introspection-plugin-hook

Conversation

@Zetazzz

@Zetazzz Zetazzz commented Aug 21, 2026

Copy link
Copy Markdown

Summary

This is an alternative implementation of #2 that keeps the existing introspection pipeline intact and introduces scoped introspection through a functional query builder and plugin hook.

  • preserve the exact stock query through makeIntrospectionQuery()
  • add makeSchemaScopedIntrospectionQuery() as a separate functional query builder
  • add a neutral pgIntrospection_query gather hook before query execution
  • add an opt-in PgScopedIntrospectionPlugin and dedicated preset that replace the query through that hook
  • keep parsing, caching, entity announcements, registry hooks, and watch invalidation in the existing PgIntrospectionPlugin
  • keep defaultPreset unchanged

The scoped query retains transitive dependencies needed for relations, constraints, function signatures, domains, arrays, ranges, multiranges, indexes, inheritance, and extension metadata. Configuration may be enabled per PostgreSQL service with a boolean or scoped options.

This PR is intended as an architectural alternative to #2, not as an additional change to merge alongside it.

Why this shape

The core plugin gains one generic extension point but no scoped-introspection policy. All query selection and scoped-result validation live in the separate optional plugin. This minimizes changes to the stock execution path and lets other query strategies use the same hook.

Validation

  • pg-introspection: build passed; 41/41 tests passed
  • graphile-build-pg: build passed; 25/25 tests passed
  • real PostgreSQL stock/scoped schema and runtime equivalence passed
  • dependency closure fixture covers cross-schema enum, domain, composite, range/multirange, functions, foreign keys, inheritance, ordinary indexes, and pg_trgm GIN/GiST indexes
  • affected ESLint and Prettier checks passed
  • git diff --check passed
  • default preset and lockfile are unchanged

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