From 4756366f7f13f558339c9c7d5f4ae6599f62a07d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Jul 2026 08:10:10 +0000 Subject: [PATCH 1/2] Initial plan From 0b6ae5ccc0dec9eda4f25e8b841c6edfd3731396 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Jul 2026 08:16:15 +0000 Subject: [PATCH 2/2] fix: address verify typecheck regressions --- scratch/check-indexes.ts | 9 ++++++++- scripts/backfill-smart-index.ts | 20 ++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/scratch/check-indexes.ts b/scratch/check-indexes.ts index b31ad49b0..2595940b3 100644 --- a/scratch/check-indexes.ts +++ b/scratch/check-indexes.ts @@ -1,14 +1,21 @@ import { loadEnvConfig } from "@next/env"; loadEnvConfig(process.cwd()); +type CatalogReader = { + from: (relation: string) => { + select: (columns: string) => PromiseLike<{ data: unknown[] | null; error: { message: string } | null }>; + }; +}; + async function main() { const { createAdminClient } = await import("../src/lib/supabase/admin"); const supabase = createAdminClient(); + const catalogReader = supabase as unknown as CatalogReader; // We can query pg_indexes view using Supabase client if it is exposed, or we can use RPC // Wait, let's see if we can query from a system catalog or check what indexes exist. // Actually, pg_indexes might not be directly exposed. Let's see if we can do a select from pg_indexes. - const { data, error } = await supabase + const { data, error } = await catalogReader .from("pg_indexes") // this might fail if not in public schema, but system catalogs aren't exposed in PostgREST by default. .select("*"); diff --git a/scripts/backfill-smart-index.ts b/scripts/backfill-smart-index.ts index 652b7e548..fa009ac35 100644 --- a/scripts/backfill-smart-index.ts +++ b/scripts/backfill-smart-index.ts @@ -533,6 +533,10 @@ async function main() { console.log("Metadata-only mode: repairing chunk metadata, document-level fields, labels, and quality rows."); for (const document of documents ?? []) { + const indexingDocument = { + ...document, + metadata: metadataRecord(document.metadata), + }; const [chunks, images] = await Promise.all([ loadRows>( reader, @@ -562,13 +566,13 @@ async function main() { const summary = await loadDocumentSummary({ supabase, documentId: document.id }); const generationId = await repairChunkIndexingMetadata({ supabase, - document, + document: indexingDocument, chunks: chunks as Record[], ragDeepMemoryVersion, }); const embeddingFields = await upsertDocumentLevelEmbeddingFields({ supabase, - document, + document: indexingDocument, chunks: chunks as Record[], summary, embedTexts, @@ -578,7 +582,7 @@ async function main() { if (args.metadataOnly) { fallbackLabels = await ensureGeneratedFallbackLabel({ supabase, - document, + document: indexingDocument, ragEnrichmentVersion, }); const [sectionCount, memoryCardCount] = await Promise.all([ @@ -587,7 +591,7 @@ async function main() { ]); const quality = await upsertIndexQuality({ supabase, - document, + document: indexingDocument, chunks: chunks as Record[], images: images as Record[], sectionCount, @@ -602,25 +606,25 @@ async function main() { const enrichment = await upsertDocumentEnrichment({ supabase, - document, + document: indexingDocument, chunks: chunks as never, images: images as never, }); fallbackLabels = await ensureGeneratedFallbackLabel({ supabase, - document, + document: indexingDocument, ragEnrichmentVersion, }); const memory = await upsertDocumentDeepMemory({ supabase, - document, + document: indexingDocument, chunks: chunks as never, images: images as never, summary: enrichment.summary.summary, }); const quality = await upsertIndexQuality({ supabase, - document, + document: indexingDocument, chunks: chunks as Record[], images: images as Record[], sectionCount: memory.sections.length,