From 12d26c9d14234dac95403c78f616fe5f0ac037cc Mon Sep 17 00:00:00 2001 From: Albert Date: Sun, 9 Nov 2025 19:48:56 +0000 Subject: [PATCH] fix: Make coords_3d optional in schema to support UMAP workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The proper architecture is: 1. Nodes are created with coords_3d = NONE 2. User manually triggers /api/calculate-graph 3. UMAP calculates 3D coordinates from embeddings 4. Coordinates are updated in batch Changed coords_3d TYPE from array to option> to allow NONE values. This fixes production error: "Found NONE for field coords_3d but expected array" Schema has been deployed to production. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/api/nodes/route.ts | 2 +- db/schema.surql | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/api/nodes/route.ts b/app/api/nodes/route.ts index 48c5d4b..da0202e 100644 --- a/app/api/nodes/route.ts +++ b/app/api/nodes/route.ts @@ -229,7 +229,7 @@ export async function POST(request: NextRequest) { atp_uri: atp_uri, title: title, body: body, // Store the raw text body - coords_3d: [0, 0, 0], // Required by schema - origin coordinates for new nodes + // coords_3d will be calculated when user runs /api/calculate-graph }; // Only include embedding if it was successfully generated diff --git a/db/schema.surql b/db/schema.surql index d2c3691..b05aedd 100644 --- a/db/schema.surql +++ b/db/schema.surql @@ -62,8 +62,9 @@ DEFINE FIELD body ON TABLE node TYPE string; DEFINE FIELD embedding ON TABLE node TYPE array; -- The 3D coordinates calculated by UMAP. -DEFINE FIELD coords_3d ON TABLE node TYPE array - -- Must be a 3-point array [x, y, z] or empty. +-- Nodes start with NONE and get coordinates when user runs calculate-graph. +DEFINE FIELD coords_3d ON TABLE node TYPE option> + -- Must be NONE or a 3-point array [x, y, z]. ASSERT $value = NONE OR array::len($value) = 3; -- Define the vector search index.