Repository navigation
fix(graphile-llm): require exactly one of a vector column or its text companion on create/update - #1956
Conversation
… companion on create/update
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
🧹 Nitpicks (1) — 🟢 1 low
This PR introduces embedding-driven companion vector fields for text mutations in
Note: the change makes supplying both a text field and its companion vector field a hard error (previously the vector value won silently); existing clients relying on the old behavior would be affected. Reviewed commit: e4d9350 |
There was a problem hiding this comment.
Adds vector-text-mutation embedding support to graphile-llm (companion vector fields driven by an embedder) plus an integration test suite and seed fixture.
Key findings
- 🟡 Update tests are order-dependent; no per-test DB isolation — vector-text-mutations.integration.test.ts:152
| beforeEach(() => { | ||
| embedCalls.length = 0; | ||
| }); |
There was a problem hiding this comment.
🟡 bug · medium
Update tests are order-dependent; no per-test DB isolation
The suite never calls pg.beforeEach()/pg.afterEach(), so mutations persist across tests: the 'updates from embeddingText' test writes the seeded row's vector to [0.8,0.2,0.5] (graphql/server-test/tests/vector-text-mutations.integration.test.ts:227-236) and the two later update tests assert against that mutated state rather than the seed.
Running any of those tests individually (jest -t) fails, and a failure in one test corrupts state for the rest. This also violates the repo's required testing pattern (AGENTS.md: always include beforeEach/afterEach savepoint hooks).
📋 Prompt for AI Agents
In graphql/server-test/tests/vector-text-mutations.integration.test.ts around lines 152-154, add database savepoint isolation per the repo testing convention: in beforeEach call await pg.beforeEach() (and await db.beforeEach() if a db client is returned by getConnections), and add an afterEach that calls await pg.afterEach() (and db.afterEach()). Then verify the update tests' expectations still hold against freshly seeded state each test, adjusting any assertion that currently depends on a previous test's mutation of row id 1.
Summary
On create and update inputs, a vector column and its
{column}Textcompanion are now exactly-one: sending both is a plan-time error (<Type>: provide exactly one of \embedding` or `embeddingText`, not both.`); before, the client-sent vector silently won and the text was dropped. A create on a NOT NULL vector column that sends neither keeps failing, with a message that says which. An update that sends neither still leaves the column alone, and a nullable column may still be created without either.New
graphql/server-test/__tests__/vector-text-mutations.integration.test.tsruns this through the routed server over HTTP (so GraphQL validation applies) against a local stand-in for the Ollama/api/embedendpoint: create/update fromembeddingTextstores the embedded vector, fromembeddingstores it without calling the embedder, both is rejected on create and update (nothing written), neither is rejected on a NOT NULL column and accepted on a nullable one.Companion to #1955, which applies the same rule to
VectorNearbyInput.Link to Devin session: https://app.devin.ai/sessions/5ad1f8a49a8240e6baddcb4df99396e6
Open in Devin Desktop: https://app.devin.ai/desktop/session/5ad1f8a49a8240e6baddcb4df99396e6?variant=devin
Requested by: @pyramation