Repository navigation
fix(graphile-llm): add {col}Text only to inputs that carry {col} - #2006
Open
theothersideofgod wants to merge 2 commits into
Open
theothersideofgod wants to merge 2 commits into
theothersideofgod wants to merge 2 commits into
Conversation
A patch type without the vector field (the role may not update the column) still gets the text companion, so the text is embedded and then dropped. Fails until the companion follows the vector field. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The companion was added for every vector column of the codec, including patches that omit the column because the role cannot update it. The text was accepted, embedded, and written into a field nothing applies, while the field's description says it lands in the column. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Review complete. No issues found — approved ✅. This PR adjusts the
Reviewed commit: d9e213b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The schema must not offer an input that writes nothing. Text sent in
{col}Texteither reaches the vector column or is refused.LlmTextMutationPluginadded{col}Textto a create input or patch for every vector column of the table. It did not check whether the input type has{col}at all. A patch omits{col}when the role cannot update that column (PostGraphile turns the missing column UPDATE grant into-attribute:update). The companion was still added, with the description "Natural language text to embed server-side into theembeddingvector column". At plan timeapplyRuleembeds the text and setsembeddingon the input value (embed-inputs.ts:218). No field applies it, so the vector is dropped. The update succeeds without it, or, when{col}Textwas the only field sent, fails with "no new values".Rules touched: R9
Before / after
Live, on a local
fun up(GraphQL imageconstructive:9b764d6, whosegraphile-llmsource is identical to main). The tenant's files table: the request role has SELECT but no UPDATE onembedding. The caller is the owner.AppFilePatchinput fields matchingembedding*embeddingText(noembedding)updateAppFile(patch: { filename, embeddingText })filenamechanges; the vector's md5 andembedding_updated_atdo notBAD_USER_INPUT: Field "embeddingText" is not defined by type "AppFilePatch"updateAppFile(patch: { embeddingText })BAD_USER_INPUT, same messagedocEmbedding/docEmbeddingText,embedding/embeddingTexton a chunks table)For "after", only the built
dist/plugins/text-mutation-plugin.js(CJS and ESM) was layered onto the pinned image.graphql-publicwas pointed at that image and then set back to the pinned one.Unit (
embed-inputs.test.ts, fake embedder, a table whoseembeddingcarries@behavior -attribute:update, the behaviorPgRBACPluginderives from a missing column grant):The new test also asserts that sending
embeddingTextto that patch is a validation error and that the embedder is never called.The change
if (!vectorField) continue;beforerequiredis computed. The companion follows the vector field. Where the input can write{col}, nothing changes, including the NOT NULL create path that makes{col}optional. The plugin's doc comment now says "inputs that carry the vector column's own field" instead of "every vector column".The lookup is right: the plugin names the field with
inflection.attribute({ codec, attributeName }), the same callPgAttributesPluginuses, and runs after it (after: ['PgAttributesPlugin', …]).Is this how it was meant to work
No. The field's own description says the text is embedded into the column. The plugin header says the plugin "injects the resulting vector into the actual column". #1956 made sending both
{col}and{col}Textan error: either input must land or fail loudly.How it came about:
requiredwith!!vectorField, which handled the missing field without skipping it.The suites run as the root role (
useRoot: true, authRole: 'postgres'), where every column is writable. No test had a table with a column the role cannot update.Behavior changes
{col}Texton an input with no{col}{X}Patch.{col}Textwith the description "embed server-side into the{col}vector column"Clients that send
{col}Texton such a patch now get a validation error instead of a silent no-op. The committed generated schemas in constructive-db, constructive (sdk/) and dashboard contain no input type with{col}Textand no{col}, so no SDK regeneration follows from this change. I scanned 30.graphqlfiles.Relation to planning#2293
planning#2293 (open) proposes removing
{col}and{col}Textfrom mutation inputs entirely (D2: backend-managed vectors). This PR does not anticipate that decision. It only stops offering the companion where it cannot write. If D2 lands, this line goes with the rest of the plugin.Considered: removing companions from all mutation inputs now (D2). Rejected here, because that is planning#2293's decision to make, and it changes writable inputs too.
Generated with Devin