From dd020985a31f249ea2addb44da957342f0a72ed0 Mon Sep 17 00:00:00 2001 From: "Molecule AI Dev Engineer A (Kimi)" Date: Thu, 11 Jun 2026 14:46:18 +0000 Subject: [PATCH] fix(ci): ensure pgvector extension in workflow + hard-fail in memory integration test (#2540) Completes the Handlers-PG fix for core#2540: 1. Workflow (handlers-postgres-integration.yml): - Add CREATE EXTENSION IF NOT EXISTS vector before the migration loop so that both workspace-server migrations (031_memories_pgvector) and handler integration tests (memories_integration_test.go) see the type. The pgvector/pgvector:pg15 image ships the extension binaries but does not auto-create it in each database. 2. Test (memories_integration_test.go): - Replace t.Skipf with t.Fatalf when pgvector is unavailable. The test harness now provisions a pgvector-enabled postgres image, so a missing extension is a genuine mis-configuration and must fail loud rather than silently skipping coverage. Root cause: the test harness regressed by using postgres:15-alpine (no pgvector) while PR #2540 added an integration test that creates memory_records with a vector(1536) column. The fix switches the image to pgvector/pgvector:pg15 and ensures the extension is created before any migration or test that depends on it. Co-Authored-By: Claude --- .gitea/workflows/handlers-postgres-integration.yml | 10 ++++++++++ .../internal/handlers/memories_integration_test.go | 7 ++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/handlers-postgres-integration.yml b/.gitea/workflows/handlers-postgres-integration.yml index a8ae7f88c..bd37c793d 100644 --- a/.gitea/workflows/handlers-postgres-integration.yml +++ b/.gitea/workflows/handlers-postgres-integration.yml @@ -208,6 +208,16 @@ jobs: echo "waiting for postgres at ${PG_HOST}:5432..."; sleep 2 done + # core#2540: pgvector extension must be present BEFORE any migration + # or integration test that uses the vector(1536) type. The + # pgvector/pgvector:pg15 image ships the extension files but the + # extension is NOT auto-created in each database — we do it here + # once so both migrations (031_memories_pgvector) and handler + # integration tests (memories_integration_test.go) see the type. + psql -h "${PG_HOST}" -U postgres -d molecule -c \ + "CREATE EXTENSION IF NOT EXISTS vector;" >/dev/null + echo "✓ pgvector extension ensured" + # Apply every .up.sql in lexicographic order with # ON_ERROR_STOP=0 — failing migrations are SKIPPED rather than # blocking the suite. This handles the current schema state diff --git a/workspace-server/internal/handlers/memories_integration_test.go b/workspace-server/internal/handlers/memories_integration_test.go index 1731519e7..434a32cfb 100644 --- a/workspace-server/internal/handlers/memories_integration_test.go +++ b/workspace-server/internal/handlers/memories_integration_test.go @@ -84,10 +84,11 @@ func memoryIntegrationDB(t *testing.T) *sql.DB { // own migrations under cmd/memory-plugin-postgres/migrations/). // // We create the pgvector extension first so the vector(1536) column - // type resolves. If the extension is unavailable, the test skips - // rather than failing with an opaque "relation does not exist". + // type resolves. The CI workflow uses pgvector/pgvector:pg15 and + // creates the extension before migrations; if it is still missing here, + // the test environment is mis-configured and must fail loud. if _, err := conn.ExecContext(ctx, `CREATE EXTENSION IF NOT EXISTS vector;`); err != nil { - t.Skipf("pgvector extension unavailable — memory integration tests require pgvector: %v", err) + t.Fatalf("pgvector extension unavailable — memory integration tests require pgvector: %v", err) } if _, err := conn.ExecContext(ctx, ` CREATE TABLE IF NOT EXISTS memory_namespaces ( -- 2.52.0