From cfab7e43e69293cb48f43d9315198a2145ef0c2d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Jul 2026 10:03:06 +0000 Subject: [PATCH 1/3] Initial plan From fe9de91b6d8885da4fd663b542a54ff7fb094d46 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Jul 2026 10:09:09 +0000 Subject: [PATCH 2/3] test: guard commit generation NULL-artifact behavior in schema checks --- tests/supabase-schema.test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/supabase-schema.test.ts b/tests/supabase-schema.test.ts index 226b0852b8..9fe9180d9d 100644 --- a/tests/supabase-schema.test.ts +++ b/tests/supabase-schema.test.ts @@ -50,6 +50,10 @@ const auditLogsServiceRolePolicyMigration = readFileSync( new URL("../supabase/migrations/20260630090000_audit_logs_service_role_policy.sql", import.meta.url), "utf8", ).replace(/\s+/g, " "); +const preserveLegacyArtifactCommitMigration = readFileSync( + new URL("../supabase/migrations/20260702000000_commit_generation_preserve_legacy_artifacts.sql", import.meta.url), + "utf8", +).replace(/\s+/g, " "); function extractTextChunkFunction(sql: string) { const start = sql.indexOf("function public.match_document_chunks_text"); @@ -166,6 +170,21 @@ describe("Supabase schema Data API grants", () => { expect(atomicReindexMigration).toContain("atomic reindex patch did not match match_document_index_units_hybrid"); }); + it("preserves NULL-generation artifacts until replacements exist", () => { + for (const sql of [schema, preserveLegacyArtifactCommitMigration]) { + expect(sql).toContain("from public.document_chunks replacement"); + expect(sql).toContain("from public.document_images replacement"); + expect(sql).toContain("from public.document_table_facts replacement"); + expect(sql).toContain("from public.document_embedding_fields replacement"); + expect(sql).toContain("from public.document_index_units replacement"); + expect(sql).toContain("from public.document_memory_cards replacement"); + expect(sql).toContain("from public.document_sections replacement"); + expect(sql).not.toContain( + "delete from public.document_images where document_id = p_document_id and ( nullif(metadata->>'index_generation_id', '') is null or metadata->>'index_generation_id' <> p_index_generation_id::text );", + ); + } + }); + it("can identify and clean abandoned staged reindex generations", () => { for (const sql of [schema, abandonedReindexRecoveryMigration]) { expect(sql).toContain("create or replace function public.cleanup_abandoned_document_index_generations"); From 234b90acb4179fe5f3fc0928c559b7d5161c57ad Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Jul 2026 10:09:52 +0000 Subject: [PATCH 3/3] test: assert replacement guards for NULL-generation artifacts --- tests/supabase-schema.test.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/supabase-schema.test.ts b/tests/supabase-schema.test.ts index 9fe9180d9d..c273e8cc90 100644 --- a/tests/supabase-schema.test.ts +++ b/tests/supabase-schema.test.ts @@ -172,6 +172,12 @@ describe("Supabase schema Data API grants", () => { it("preserves NULL-generation artifacts until replacements exist", () => { for (const sql of [schema, preserveLegacyArtifactCommitMigration]) { + expect(sql).toContain( + "index_generation_id is null and exists ( select 1 from public.document_chunks replacement", + ); + expect(sql).toContain( + "nullif(metadata->>'index_generation_id', '') is null and exists ( select 1 from public.document_images replacement", + ); expect(sql).toContain("from public.document_chunks replacement"); expect(sql).toContain("from public.document_images replacement"); expect(sql).toContain("from public.document_table_facts replacement"); @@ -179,9 +185,6 @@ describe("Supabase schema Data API grants", () => { expect(sql).toContain("from public.document_index_units replacement"); expect(sql).toContain("from public.document_memory_cards replacement"); expect(sql).toContain("from public.document_sections replacement"); - expect(sql).not.toContain( - "delete from public.document_images where document_id = p_document_id and ( nullif(metadata->>'index_generation_id', '') is null or metadata->>'index_generation_id' <> p_index_generation_id::text );", - ); } });