Skip to content

chore(authz): adopt typed Warden relation contract from providers#99

Open
hobbescodes wants to merge 6 commits into
masterfrom
chore/typed-authz-relations
Open

chore(authz): adopt typed Warden relation contract from providers#99
hobbescodes wants to merge 6 commits into
masterfrom
chore/typed-authz-relations

Conversation

@hobbescodes

@hobbescodes hobbescodes commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Description

Task link: N/A

Three changes:

1. Adopt the typed Warden relation contract from @omnidotdev/providers. The lib/authz checkPermission wrapper is now generic over the resource type, so permission is constrained to the relations Warden defines for that type. All existing call sites already use valid relations, so this adds type safety with no behavior change.

2. Fix a pre-existing migration gap (unrelated to the authz change). Migration 0015 creates pgvector columns (signal_cluster.centroid, the post/signal embeddings) but no migration enabled the pgvector extension, so a fresh bun db:migrate failed with type "vector" does not exist. Prepend CREATE EXTENSION IF NOT EXISTS vector; to 0015 so a fresh migrate works without a separate db:setup step. Mirrors the same change already on feature/agentic-workflows.

3. Register a pgvector codec so graphql:generate succeeds (the second half of bun db:migrate). With the extension enabled, schema generation then failed because PostGraphile has no codec for the vector type on the embedding columns — introspection dumped the raw pg_type and warned Could not build PgCodec for 'public.vector'. Add a gather plugin (lib/graphql/plugins/codecs/PgVectorPlugin, modeled on graphile-build-pg's PgLtreePlugin) that registers a codec for vector/_vector, scoped to the pgvector extension. A behavior override hides the embedding columns from the schema (fields, conditions, filters, ordering, and the @graphile/pg-aggregates groupBy/aggregate machinery) so internal embeddings stay out of the API, and the codec is mapped to String to silence the per-codec type-preparation warning. Net effect on the generated SDL is nil (the columns were already absent), so no generated-schema changes are bundled in this commit.

Important

Depends on omnidotdev/providers#6. The @omnidotdev/providers pin points at the feature-branch commit 1d1c21d; re-pin it to the merge commit once omnidotdev/providers#6 merges, before merging this.

Test Steps

  1. bunx tsc --noEmit clean, bunx biome check clean, bunx knip clean.
  2. bun db:migrate on a fresh DB -> migrations apply and "Schema generated successfully" with no PgCodec warnings.

Make the lib/authz checkPermission wrapper generic over the resource type so
permission is constrained to the relations Warden defines for it, matching the
new @omnidotdev/providers signature. All existing call sites already use valid
relations, so this adds type safety with no behavior change. Bumps providers to
the build that ships the contract.
Migration 0015 creates vector columns (signal_cluster.centroid, the post and
signal embeddings) but no migration enabled the pgvector extension, so a fresh
bun db:migrate failed with "type vector does not exist". Prepend
CREATE EXTENSION IF NOT EXISTS vector to 0015 so a fresh migrate works without a
separate db:setup step. Mirrors the same change already on
feature/agentic-workflows.
`bun db:migrate` runs `graphql:generate`, which failed because PostGraphile has
no codec for the pgvector `vector` type used by the embedding columns
(post.embedding, signal.embedding, signal_cluster.centroid). Introspection
dumped the raw pg_type and warned "Could not build PgCodec for 'public.vector'".

Add a gather plugin (modeled on graphile-build-pg's PgLtreePlugin) that
registers a codec for `vector`/`_vector`, scoped to the pgvector extension. A
behavior override hides the columns from the schema (fields, conditions,
filters, ordering, and the pg-aggregates groupBy/aggregate machinery) so
internal embeddings stay out of the API, and the codec is mapped to String to
silence the per-codec type-preparation warning.
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