Repository navigation
feat: URLs for every file-reference column and its rendered versions; vector search per column model - #2008
Conversation
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Review complete. 🟠 1 high 💬 Inline comments (1)
The change introduces per-model embedding across the search stack: a new
Reviewed commit: 9c3f82e |
There was a problem hiding this comment.
This PR makes pgvector search embed each vector column with its own declared embedding model, adds image-version URL resolution fields for image[] columns in the presigned-URL plugin, and extends the test fixtures and integration tests accordingly.
Key findings
- 🟠 Failed per-model embed falls back to wrong-model vector — plugin.ts:1374
…an embedded text with its own model
|
Integration hops for this PR: constructive-io/constructive-db-integration-tests#18 (merge only after this is published and |
<column>Url / <column>Versions for each column of a declared file domain (FILE_REF_DOMAINS: image, upload) and its array form; ImageVersion becomes FileVersion. The files rows of a request are read in one lookup per storage module, and the source URL carries the uploaded filename as downloadUrl does.
Summary
Two read-side pieces that the db work (constructive-db #4369, #4371, #4372) needs before a client can use what it stores. Planning: constructive-planning#2519.
1. Every file-reference column gets URLs (
graphile-presigned-url-plugin)One mechanism for every column of a file domain and its array form, not a hook per type. The domains are one declared list,
FILE_REF_DOMAINS = ['image', 'upload']ingraphile-storage-registry(overridable with the plugin optionfileRefDomains); a future file type is a name added there. constructive-db marks these columns by domain only: there is no smart tag on a business-table file column (@storageFilesis on the files table), and db itself keys on the same domain names indata_file_refandprovision_table.attachmentis a text domain holding a link, so it is not in the list.A file column is a JSON domain and cannot grow fields of its own, so each one gets two sibling fields:
FileVersionisname key width height format size url, dimensions nullable. A version without a width never satisfieswidth, so the source is returned.Security rule: the document is data, never a key to sign. A client can write its own
versions(andkey) into the document, so:No
id, no row the reader can see, a row that is not live, or a bucket with no physical name givesnull. A forged entry is dropped, not an error.Same bucket handling as
downloadUrl, each asserted againstdownloadUrlor the seeded coordinates infile-ref-urls.integration.test.ts: public file ->publicUrlPrefixURL (versions too); private -> presigned in the database's own physical bucket; a file in the database's second storage module is found; unreconciled bucket ->null; the source URL carries the row'sfilenameas content-disposition.Cost. Documents resolved in the same tick share one read per request (
RequestFiles, keyed on the request'spgSettings): one files lookup per storage module for all ids, one coordinate read per bucket. Storage queries for a 50-row list selectingphotoUrlandphotoVersions:downloadUrlon 50 files rows, for comparisonThe test asserts
<= 4.Tests (
graphql/server-test/__tests__/file-ref-urls.integration.test.ts): forimage,image[],uploadandupload[]: another file's key, another file's version key,..traversal, nested path, the source key listed as a version, a lying top-levelkey, a file RLS hides from the reader, a document with noid; plus the bucket cases, the query count, and that no type or field is named after one file kind.2. A vector column is searched with its own model (
graphile-search,graphile-llm)Unchanged by the rework. constructive-db #4372 stamps each vector with the model that produced it and tags the columns:
@embeddingModel <model>on the vector column when its node names one,@embeddingModelOf <column>on the companion<column>_model. This PR reads those tags:VectorNearbyInput.textis embedded with the column's@embeddingModel, else the request's model (tenant, then platform), as before.EmbedderFunctiontakes an optionalmodel.VectorNearbyInputgainsmodel: String, filled in server-side whentextis embedded. On a column with a companion model column, only rows whose stamp equals it are compared. A client sending its ownvectormay name themodel; without one nothing is filtered (unchanged behavior).unifiedSearchembeds the text once per distinct model among the table's vector columns and scores each column with its own vector. A row stamped with another model gets anulldistance, not a wrong one. It still only ranks, it does not start filtering.Tests:
graphile-llm/src/__tests__/vector-model.test.ts.Review focus
RequestFilesbatches withprocess.nextTickand caches rows for the life of the request'spgSettingsobject. A file deleted mid-request keeps its URL until the request ends.resolveStorageModuleByFileIddoes.VECTOR_COLUMNS_EXTis the same string constant ingraphile-search/src/plugin.tsandgraphile-llm/src/embed-inputs.ts(graphile-search does not depend on graphile-llm).pgvector.ts, the model condition narrowswhereClauseonly when adistancealready made one; otherwise it rides onscorableClauseand aCASEaround the score, sounifiedSearchsemantics do not change.After merge (Dan)
main:graphile-storage-registry,graphile-presigned-url-plugin,graphile-search,graphile-llmand their dependents (graphile-settings,@constructive-io/graphql-server).regenerate-branch.ymlso the SDK/schema snapshots pick up<column>Url,<column>Versions,FileVersionandVectorNearbyInput.model.pins.json(constructive,constructive-db) to those shas, then merge integration-tests remove travis #18; until the pin moves its hops only pass when the run is dispatched withconstructive_refset to this branch's sha.versionsresolves to the source URL.Link to Devin session: https://app.devin.ai/sessions/d7ca5693b59842008312a29e09ddacb2
Open in Devin Desktop: https://app.devin.ai/desktop/session/d7ca5693b59842008312a29e09ddacb2?variant=devin
Requested by: @pyramation
🟢 Devin Review found nothing to fix · View findings · Follow Devin's work