From b2c02cb45b6404b896d63d4643e8056453c17ab9 Mon Sep 17 00:00:00 2001 From: Randall Stillwell Date: Fri, 14 Aug 2026 21:48:25 -0500 Subject: [PATCH] fix(ci): allow card-embed.js and skip pgvector on non-superuser CI Add lib/card-embed.js to the server-only LLM allowlist (forbidden-patterns Check 3). Make the pgvector migration degrade gracefully when CT 102 CI cannot CREATE EXTENSION vector so migrate up still passes. Co-authored-by: Cursor --- .github/workflows/ci.yml | 1 + .../1782000000001_add-card-embeddings.js | 38 +++++++++++++++---- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 270ed7f..99e56a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -196,6 +196,7 @@ jobs: fi SERVER_ONLY=( lib/scan-vision.js + lib/card-embed.js ) LLM_PATTERN='generativelanguage\.googleapis\.com|api\.openai\.com|ai-gateway\.vercel\.sh' LLM_FOUND=() diff --git a/migrations/1782000000001_add-card-embeddings.js b/migrations/1782000000001_add-card-embeddings.js index 3affc56..6e8cdbc 100644 --- a/migrations/1782000000001_add-card-embeddings.js +++ b/migrations/1782000000001_add-card-embeddings.js @@ -1,6 +1,11 @@ /** * pgvector + cards.embedding for Layer-0 visual catalog search. * + * Neon prod: CREATE EXTENSION vector succeeds for the project owner. + * Homelab CI (`deckhearth_ci`, non-superuser): extension create may fail; + * we skip embedding DDL so migrate still passes — L0 escalates until + * an operator enables pgvector on CT 102 or runs backfill on Neon. + * * @type {import('node-pg-migrate').ColumnDefinitions | undefined} */ export const shorthands = undefined; @@ -13,15 +18,34 @@ const EMBED_DIMENSION = 1024; */ export const up = (pgm) => { pgm.sql(` - CREATE EXTENSION IF NOT EXISTS vector; + DO $do$ + BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector') THEN + CREATE EXTENSION vector; + END IF; + EXCEPTION + WHEN insufficient_privilege OR OTHERS THEN + RAISE NOTICE 'vector extension unavailable on this database (%). Skipping embedding DDL.', SQLERRM; + RETURN; + END + $do$; - ALTER TABLE cards - ADD COLUMN IF NOT EXISTS embedding vector(${EMBED_DIMENSION}), - ADD COLUMN IF NOT EXISTS embedded_at TIMESTAMP; + DO $do$ + BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector') THEN + RAISE NOTICE 'vector extension not installed — skipping cards.embedding columns'; + RETURN; + END IF; - CREATE INDEX IF NOT EXISTS idx_cards_embedding_hnsw - ON cards USING hnsw (embedding vector_cosine_ops) - WHERE embedding IS NOT NULL; + ALTER TABLE cards + ADD COLUMN IF NOT EXISTS embedding vector(${EMBED_DIMENSION}), + ADD COLUMN IF NOT EXISTS embedded_at TIMESTAMP; + + CREATE INDEX IF NOT EXISTS idx_cards_embedding_hnsw + ON cards USING hnsw (embedding vector_cosine_ops) + WHERE embedding IS NOT NULL; + END + $do$; `); };