Skip to content

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

Merged
coopbri merged 7 commits into
masterfrom
chore/typed-authz-relations
Jun 19, 2026
Merged

chore(authz): adopt typed Warden relation contract from providers#99
coopbri merged 7 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.

hobbescodes and others added 7 commits June 16, 2026 11:42
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.
Merge origin/master and revert the hand-edit to migration
0015_silky_sway.sql that prepended `CREATE EXTENSION IF NOT EXISTS
vector`. The edit violated org migration rules and was redundant:
src/scripts/db/migrate.ts ensures the vector and pg_trgm extensions
(CREATE EXTENSION IF NOT EXISTS) before any migration is applied, and
CI runs exactly that script, so the extension is always present before
0015 runs. Verified end to end against a throwaway pgvector Postgres
with both extensions dropped: migrate.ts ensures them and applies all
migrations cleanly.

0015 is now byte-identical to master. Conflict resolution also re-pins
@omnidotdev/providers to github:omnidotdev/providers#1c99594 and
regenerates the GraphQL schema from the merged Drizzle schema.
@coopbri coopbri merged commit 5fc9e41 into master Jun 19, 2026
4 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 19, 2026
@coopbri coopbri deleted the chore/typed-authz-relations branch June 20, 2026 00:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants