Skip to content

fix(graphile-llm): require exactly one of a vector column or its text companion on create/update - #1956

Merged
pyramation merged 2 commits into
mainfrom
fix/vector-text-companion-exactly-one
Nov 4, 2026
Merged

pyramation merged 2 commits into
mainfrom
fix/vector-text-companion-exactly-one

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

On create and update inputs, a vector column and its {column}Text companion 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.ts runs this through the routed server over HTTP (so GraphQL validation applies) against a local stand-in for the Ollama /api/embed endpoint: create/update from embeddingText stores the embedded vector, from embedding stores 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

@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@luxor-code-review

luxor-code-review Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Review complete. 🟡 1 medium

💬 Inline comments (1)

🧹 Nitpicks (1) — 🟢 1 low
  • 🟢 Document breaking exactly-one companion contract (embed-inputs.ts:199) — The companion embed rule now throws provide exactly one of \{into}` or `{fieldName}`, not bothwhen both the vector column and its{column}Text` companion are sent (graphile/graphile-llm/src/embed-inputs.ts:199-203); previously the vector silently won.

This PR introduces embedding-driven companion vector fields for text mutations in graphile-llm, along with an integration test suite and a seed fixture for pgvector-backed text mutation tests.

Files Change
graphile/graphile-llm/src/embed-inputs.ts Adds embedding input resolution that fills companion vector fields from text inputs via the configured embedder.
graphile/graphile-llm/src/plugins/text-mutation-plugin.ts Wires the embedding resolution into text mutation plugins.
graphile/graphile-llm/src/__tests__/embed-inputs.test.ts Unit tests for the embedding input resolution logic.
graphql/server-test/__tests__/vector-text-mutations.integration.test.ts Integration tests covering vector text mutations end-to-end.
graphql/server-test/__fixtures__/seed/vector-text-mutations/schema.sql Seed fixture creating pgvector-backed tables for the integration tests.

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

@luxor-code-review luxor-code-review Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +152 to +154
beforeEach(() => {
embedCalls.length = 0;
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

@pyramation
pyramation merged commit 096a443 into main Nov 4, 2026
19 checks passed
@pyramation
pyramation deleted the fix/vector-text-companion-exactly-one branch November 4, 2026 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant