@prisma-next/extension-pgvector 0.5.0-dev.71 → 0.5.0-dev.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { AnyCodecDescriptor, CodecCallContext, CodecDescriptorImpl, CodecImpl, CodecInstanceContext } from "@prisma-next/framework-components/codec";
2
1
  import { JsonValue } from "@prisma-next/contract/types";
2
+ import { AnyCodecDescriptor, CodecCallContext, CodecDescriptorImpl, CodecImpl, CodecInstanceContext } from "@prisma-next/framework-components/codec";
3
3
  import { ExtractCodecTypes } from "@prisma-next/sql-relational-core/ast";
4
4
  import { StandardSchemaV1 } from "@standard-schema/spec";
5
5
 
@@ -60,4 +60,4 @@ type Vector<N extends number = number> = number[] & {
60
60
  type CodecTypes = CodecTypes$1;
61
61
  //#endregion
62
62
  export { Vector as n, CodecTypes as t };
63
- //# sourceMappingURL=codec-types-CQubO6uQ.d.mts.map
63
+ //# sourceMappingURL=codec-types-yMSpEJJM.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codec-types-CQubO6uQ.d.mts","names":[],"sources":["../src/core/constants.ts","../src/core/codecs.ts","../src/types/codec-types.ts"],"mappings":";;;;;;;;;cAGa,eAAA;;;KCyBR,YAAA;EAAA,SAA0B,MAAA;AAAA;AAAA,cAiBlB,aAAA,SAAsB,SAAA,QAC1B,eAAA;EAAA,SAKE,MAAA;cAEG,UAAA,EAAY,kBAAA,EAAoB,MAAA;EAK5C,YAAA,CAAa,KAAA,oBAAyB,KAAA;EAYhC,MAAA,CAAO,KAAA,YAAiB,IAAA,EAAM,gBAAA,GAAmB,OAAA;EAKjD,MAAA,CAAO,IAAA,UAAc,IAAA,EAAM,gBAAA,GAAmB,OAAA;EAsBpD,UAAA,CAAW,KAAA,aAAkB,SAAA;EAK7B,UAAA,CAAW,IAAA,EAAM,SAAA;AAAA;AAAA,cAMN,kBAAA,SAA2B,mBAAA,CAAoB,YAAA;EAAA,S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,EAAK,oBAAA,KAAyB,aAAA;AAAA;AAAA,cAkBnE,kBAAA;EAAA,iBAEI,kBAAA;AAAA;AAAA,KAEE,YAAA,GAAa,iBAAA,QAAyB,kBAAA;;;;;;;;AApHY;KCTlD,MAAA;EAAA,SAA0D,cAAA,GAAiB,CAAA;AAAA;AAAA,KAE3E,UAAA,GAAa,YAAA"}
@@ -1,2 +1,2 @@
1
- import { n as Vector, t as CodecTypes } from "./codec-types-CQubO6uQ.mjs";
1
+ import { n as Vector, t as CodecTypes } from "./codec-types-yMSpEJJM.mjs";
2
2
  export { type CodecTypes, type Vector };
@@ -1 +1 @@
1
- {"version":3,"file":"control.d.mts","names":[],"sources":["../src/exports/control.ts"],"mappings":";;;cAkEM,2BAAA,EAA6B,6BAAA"}
1
+ {"version":3,"file":"control.d.mts","names":[],"sources":["../src/exports/control.ts"],"mappings":";;;cA+DM,2BAAA,EAA6B,6BAAA"}
package/dist/control.mjs CHANGED
@@ -1,4 +1,170 @@
1
+ import { t as VECTOR_CODEC_ID } from "./constants-DX-00vYk.mjs";
1
2
  import { n as pgvectorQueryOperations, t as pgvectorPackMeta } from "./descriptor-meta-CBnWOxms.mjs";
3
+ import { computeStorageHash } from "@prisma-next/contract/hashing";
4
+ import { coreHash, profileHash } from "@prisma-next/contract/types";
5
+ import { computeMigrationHash } from "@prisma-next/migration-tools/hash";
6
+ //#region src/core/contract-space-constants.ts
7
+ /**
8
+ * Static names and identifiers used across pgvector's contract space.
9
+ *
10
+ * Centralised here so the contract IR (`./contract`), the baseline
11
+ * migration ops (`./migrations`), the head ref, and the descriptor
12
+ * (`../exports/control`) all reference the same values without typos.
13
+ *
14
+ * The space identifier `'pgvector'` is what the framework writes to
15
+ * `migrations/pgvector/` in the user's repo and what the marker table's
16
+ * `space` column carries for pgvector-owned rows.
17
+ *
18
+ * The `pgvector:*` invariantId namespace is locked here — once
19
+ * published, an invariantId is immutable so downstream consumers can
20
+ * reference it by literal string match.
21
+ */
22
+ const PGVECTOR_SPACE_ID = "pgvector";
23
+ const PGVECTOR_NATIVE_TYPE = "vector";
24
+ const PGVECTOR_BASELINE_MIGRATION_NAME = "20260601T0000_install_vector_extension";
25
+ /**
26
+ * `pgvector:*` invariantIds emitted by the baseline migration. Each id,
27
+ * once published, is immutable: downstream consumers (other extensions,
28
+ * the marker table) reference them by literal string match.
29
+ */
30
+ const PGVECTOR_INVARIANTS = { installVector: "pgvector:install-vector-v1" };
31
+ //#endregion
32
+ //#region src/core/contract.ts
33
+ /**
34
+ * pgvector contract space — declares the parameterised native type
35
+ * `vector(N)` that user columns can name as `nativeType`.
36
+ *
37
+ * Unlike CipherStash's typed objects (composite types / domains / enums
38
+ * — deferred behind `meta.cipherstashFutureIR` until the IR vocabulary
39
+ * gains first-class support), pgvector's `vector` is a parameterised
40
+ * native type and *is* representable in today's IR via
41
+ * {@link StorageTypeInstance}: `{ codecId, nativeType, typeParams }`.
42
+ * The contract registers a representative instance under
43
+ * `storage.types.vector` so the verifier sees the type as part of
44
+ * pgvector's space contribution and so the pinned `contract.json` on
45
+ * disk is materially distinct from an empty space.
46
+ *
47
+ * Per-column instances on the user's side carry concrete
48
+ * `typeParams.length` (e.g. `vector(1536)`); the registration here
49
+ * declares the parameterised shape — it is not consumed as a literal
50
+ * column type by any user table.
51
+ */
52
+ const TARGET = "postgres";
53
+ const TARGET_FAMILY = "sql";
54
+ /**
55
+ * Storage body for the contract — pgvector ships no tables of its own;
56
+ * the `vector` parameterised native type is registered under
57
+ * `storage.types` so pgvector's IR contribution is non-empty and the
58
+ * pinned `contract.json` on disk differs materially from an empty
59
+ * extension space.
60
+ *
61
+ * Authored without `storageHash` here so {@link computeStorageHash} can
62
+ * digest the canonical body (the hashing pipeline panics if asked to
63
+ * hash an object that already carries its own output — see
64
+ * `assertDescriptorSelfConsistency`'s storage-hash strip).
65
+ */
66
+ const storageBody = {
67
+ tables: {},
68
+ types: { [PGVECTOR_NATIVE_TYPE]: {
69
+ codecId: VECTOR_CODEC_ID,
70
+ nativeType: PGVECTOR_NATIVE_TYPE,
71
+ typeParams: {}
72
+ } }
73
+ };
74
+ /** Content-addressed hash of pgvector's storage IR. */
75
+ const PGVECTOR_STORAGE_HASH = computeStorageHash({
76
+ target: TARGET,
77
+ targetFamily: TARGET_FAMILY,
78
+ storage: storageBody
79
+ });
80
+ /** pgvector's contract value, exposed via the descriptor's `contractSpace.contractJson`. */
81
+ const pgvectorContract = {
82
+ target: TARGET,
83
+ targetFamily: TARGET_FAMILY,
84
+ roots: {},
85
+ models: {},
86
+ capabilities: {},
87
+ extensionPacks: {},
88
+ meta: {},
89
+ profileHash: profileHash("pgvector-extension-profile-v1"),
90
+ storage: {
91
+ ...storageBody,
92
+ storageHash: coreHash(PGVECTOR_STORAGE_HASH)
93
+ }
94
+ };
95
+ //#endregion
96
+ //#region src/core/migrations.ts
97
+ const pgvectorBaselineOps = [{
98
+ id: "pgvector.install-vector-extension",
99
+ label: "Enable extension \"vector\"",
100
+ operationClass: "additive",
101
+ invariantId: PGVECTOR_INVARIANTS.installVector,
102
+ target: {
103
+ id: "postgres",
104
+ details: {
105
+ schema: "public",
106
+ objectType: "extension",
107
+ name: "vector"
108
+ }
109
+ },
110
+ precheck: [{
111
+ description: "verify extension \"vector\" is not already enabled",
112
+ sql: "SELECT NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')"
113
+ }],
114
+ execute: [{
115
+ description: "create extension \"vector\"",
116
+ sql: "CREATE EXTENSION IF NOT EXISTS vector"
117
+ }],
118
+ postcheck: [{
119
+ description: "confirm extension \"vector\" is enabled",
120
+ sql: "SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')"
121
+ }]
122
+ }];
123
+ /** Sorted list of invariantIds the baseline migration provides. */
124
+ const PGVECTOR_BASELINE_INVARIANTS = (() => {
125
+ const ids = pgvectorBaselineOps.map((op) => op.invariantId).filter((id) => typeof id === "string");
126
+ return [...new Set(ids)].sort();
127
+ })();
128
+ const baselineMetadataWithoutHash = {
129
+ from: null,
130
+ to: PGVECTOR_STORAGE_HASH,
131
+ fromContract: null,
132
+ toContract: pgvectorContract,
133
+ hints: {
134
+ used: [],
135
+ applied: [],
136
+ plannerVersion: "2.0.0"
137
+ },
138
+ labels: [],
139
+ providedInvariants: PGVECTOR_BASELINE_INVARIANTS,
140
+ createdAt: "2026-06-01T00:00:00.000Z"
141
+ };
142
+ /**
143
+ * Baseline migration package the descriptor publishes via
144
+ * `contractSpace.migrations`. The framework's emitter writes this to
145
+ * `migrations/pgvector/<dirName>/{manifest,ops,contract}.json` in the
146
+ * user's repo at `migrate` time.
147
+ */
148
+ const pgvectorBaselineMigration = {
149
+ dirName: PGVECTOR_BASELINE_MIGRATION_NAME,
150
+ metadata: {
151
+ ...baselineMetadataWithoutHash,
152
+ migrationHash: computeMigrationHash(baselineMetadataWithoutHash, pgvectorBaselineOps)
153
+ },
154
+ ops: pgvectorBaselineOps
155
+ };
156
+ /**
157
+ * Pinned head ref the descriptor publishes. The framework writes this
158
+ * verbatim to `migrations/pgvector/refs/head.json` (with `invariants`
159
+ * sorted alphabetically per the canonicalisation rules); the runner's
160
+ * `findPathWithDecision` step consults `head.json` to decide which
161
+ * migrations need to apply.
162
+ */
163
+ const pgvectorHeadRef = {
164
+ hash: PGVECTOR_STORAGE_HASH,
165
+ invariants: PGVECTOR_BASELINE_INVARIANTS
166
+ };
167
+ //#endregion
2
168
  //#region src/exports/control.ts
3
169
  const PGVECTOR_CODEC_ID = "pg/vector@1";
4
170
  function buildVectorIdentityValue(typeParams) {
@@ -14,31 +180,15 @@ const vectorControlPlaneHooks = {
14
180
  },
15
181
  resolveIdentityValue: ({ typeParams }) => buildVectorIdentityValue(typeParams)
16
182
  };
17
- const pgvectorDatabaseDependencies = { init: [{
18
- id: "postgres.extension.vector",
19
- label: "Enable vector extension",
20
- install: [{
21
- id: "extension.vector",
22
- label: "Enable extension \"vector\"",
23
- summary: "Ensures the vector extension is available for pgvector operations",
24
- operationClass: "additive",
25
- target: { id: "postgres" },
26
- precheck: [{
27
- description: "verify extension \"vector\" is not already enabled",
28
- sql: "SELECT NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')"
29
- }],
30
- execute: [{
31
- description: "create extension \"vector\"",
32
- sql: "CREATE EXTENSION IF NOT EXISTS vector"
33
- }],
34
- postcheck: [{
35
- description: "confirm extension \"vector\" is enabled",
36
- sql: "SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')"
37
- }]
38
- }]
39
- }] };
183
+ const pgvectorContractSpace = {
184
+ contractJson: pgvectorContract,
185
+ migrations: [pgvectorBaselineMigration],
186
+ headRef: pgvectorHeadRef
187
+ };
40
188
  const pgvectorExtensionDescriptor = {
41
189
  ...pgvectorPackMeta,
190
+ id: PGVECTOR_SPACE_ID,
191
+ contractSpace: pgvectorContractSpace,
42
192
  types: {
43
193
  ...pgvectorPackMeta.types,
44
194
  codecTypes: {
@@ -47,7 +197,6 @@ const pgvectorExtensionDescriptor = {
47
197
  }
48
198
  },
49
199
  queryOperations: () => pgvectorQueryOperations(),
50
- databaseDependencies: pgvectorDatabaseDependencies,
51
200
  create: () => ({
52
201
  familyId: "sql",
53
202
  targetId: "postgres"
@@ -1 +1 @@
1
- {"version":3,"file":"control.mjs","names":[],"sources":["../src/exports/control.ts"],"sourcesContent":["import type {\n CodecControlHooks,\n ComponentDatabaseDependencies,\n SqlControlExtensionDescriptor,\n} from '@prisma-next/family-sql/control';\nimport { pgvectorPackMeta, pgvectorQueryOperations } from '../core/descriptor-meta';\n\nconst PGVECTOR_CODEC_ID = 'pg/vector@1' as const;\n\nfunction buildVectorIdentityValue(typeParams: Record<string, unknown> | undefined): string | null {\n const length = typeParams?.['length'];\n if (typeof length !== 'number' || !Number.isInteger(length) || length <= 0) {\n return null;\n }\n\n const zeroVector = `[${new Array(length).fill('0').join(',')}]`;\n return `'${zeroVector}'::vector`;\n}\n\nconst vectorControlPlaneHooks: CodecControlHooks = {\n expandNativeType: ({ nativeType, typeParams }) => {\n const length = typeParams?.['length'];\n if (typeof length === 'number' && Number.isInteger(length) && length > 0) {\n return `${nativeType}(${length})`;\n }\n return nativeType;\n },\n resolveIdentityValue: ({ typeParams }) => buildVectorIdentityValue(typeParams),\n};\n\nconst pgvectorDatabaseDependencies: ComponentDatabaseDependencies<unknown> = {\n init: [\n {\n id: 'postgres.extension.vector',\n label: 'Enable vector extension',\n install: [\n {\n id: 'extension.vector',\n label: 'Enable extension \"vector\"',\n summary: 'Ensures the vector extension is available for pgvector operations',\n operationClass: 'additive',\n target: { id: 'postgres' },\n precheck: [\n {\n description: 'verify extension \"vector\" is not already enabled',\n sql: \"SELECT NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')\",\n },\n ],\n execute: [\n {\n description: 'create extension \"vector\"',\n sql: 'CREATE EXTENSION IF NOT EXISTS vector',\n },\n ],\n postcheck: [\n {\n description: 'confirm extension \"vector\" is enabled',\n sql: \"SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')\",\n },\n ],\n },\n ],\n },\n ],\n};\n\nconst pgvectorExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'> = {\n ...pgvectorPackMeta,\n types: {\n ...pgvectorPackMeta.types,\n codecTypes: {\n ...pgvectorPackMeta.types.codecTypes,\n controlPlaneHooks: {\n [PGVECTOR_CODEC_ID]: vectorControlPlaneHooks,\n },\n },\n },\n queryOperations: () => pgvectorQueryOperations(),\n databaseDependencies: pgvectorDatabaseDependencies,\n create: () => ({\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n }),\n};\n\nexport { pgvectorExtensionDescriptor };\nexport default pgvectorExtensionDescriptor;\n"],"mappings":";;AAOA,MAAM,oBAAoB;AAE1B,SAAS,yBAAyB,YAAgE;CAChG,MAAM,SAAS,aAAa;CAC5B,IAAI,OAAO,WAAW,YAAY,CAAC,OAAO,UAAU,OAAO,IAAI,UAAU,GACvE,OAAO;CAIT,OAAO,IAAI,IADY,IAAI,MAAM,OAAO,CAAC,KAAK,IAAI,CAAC,KAAK,IAAI,CAAC,GACvC;;AAGxB,MAAM,0BAA6C;CACjD,mBAAmB,EAAE,YAAY,iBAAiB;EAChD,MAAM,SAAS,aAAa;EAC5B,IAAI,OAAO,WAAW,YAAY,OAAO,UAAU,OAAO,IAAI,SAAS,GACrE,OAAO,GAAG,WAAW,GAAG,OAAO;EAEjC,OAAO;;CAET,uBAAuB,EAAE,iBAAiB,yBAAyB,WAAW;CAC/E;AAED,MAAM,+BAAuE,EAC3E,MAAM,CACJ;CACE,IAAI;CACJ,OAAO;CACP,SAAS,CACP;EACE,IAAI;EACJ,OAAO;EACP,SAAS;EACT,gBAAgB;EAChB,QAAQ,EAAE,IAAI,YAAY;EAC1B,UAAU,CACR;GACE,aAAa;GACb,KAAK;GACN,CACF;EACD,SAAS,CACP;GACE,aAAa;GACb,KAAK;GACN,CACF;EACD,WAAW,CACT;GACE,aAAa;GACb,KAAK;GACN,CACF;EACF,CACF;CACF,CACF,EACF;AAED,MAAM,8BAAyE;CAC7E,GAAG;CACH,OAAO;EACL,GAAG,iBAAiB;EACpB,YAAY;GACV,GAAG,iBAAiB,MAAM;GAC1B,mBAAmB,GAChB,oBAAoB,yBACtB;GACF;EACF;CACD,uBAAuB,yBAAyB;CAChD,sBAAsB;CACtB,eAAe;EACb,UAAU;EACV,UAAU;EACX;CACF"}
1
+ {"version":3,"file":"control.mjs","names":[],"sources":["../src/core/contract-space-constants.ts","../src/core/contract.ts","../src/core/migrations.ts","../src/exports/control.ts"],"sourcesContent":["/**\n * Static names and identifiers used across pgvector's contract space.\n *\n * Centralised here so the contract IR (`./contract`), the baseline\n * migration ops (`./migrations`), the head ref, and the descriptor\n * (`../exports/control`) all reference the same values without typos.\n *\n * The space identifier `'pgvector'` is what the framework writes to\n * `migrations/pgvector/` in the user's repo and what the marker table's\n * `space` column carries for pgvector-owned rows.\n *\n * The `pgvector:*` invariantId namespace is locked here — once\n * published, an invariantId is immutable so downstream consumers can\n * reference it by literal string match.\n */\n\nexport const PGVECTOR_SPACE_ID = 'pgvector' as const;\n\nexport const PGVECTOR_NATIVE_TYPE = 'vector' as const;\n\nexport const PGVECTOR_BASELINE_MIGRATION_NAME = '20260601T0000_install_vector_extension' as const;\n\n/**\n * `pgvector:*` invariantIds emitted by the baseline migration. Each id,\n * once published, is immutable: downstream consumers (other extensions,\n * the marker table) reference them by literal string match.\n */\nexport const PGVECTOR_INVARIANTS = {\n installVector: 'pgvector:install-vector-v1',\n} as const;\n","/**\n * pgvector contract space — declares the parameterised native type\n * `vector(N)` that user columns can name as `nativeType`.\n *\n * Unlike CipherStash's typed objects (composite types / domains / enums\n * — deferred behind `meta.cipherstashFutureIR` until the IR vocabulary\n * gains first-class support), pgvector's `vector` is a parameterised\n * native type and *is* representable in today's IR via\n * {@link StorageTypeInstance}: `{ codecId, nativeType, typeParams }`.\n * The contract registers a representative instance under\n * `storage.types.vector` so the verifier sees the type as part of\n * pgvector's space contribution and so the pinned `contract.json` on\n * disk is materially distinct from an empty space.\n *\n * Per-column instances on the user's side carry concrete\n * `typeParams.length` (e.g. `vector(1536)`); the registration here\n * declares the parameterised shape — it is not consumed as a literal\n * column type by any user table.\n */\n\nimport { computeStorageHash } from '@prisma-next/contract/hashing';\nimport { type Contract, coreHash, profileHash } from '@prisma-next/contract/types';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { VECTOR_CODEC_ID } from './constants';\nimport { PGVECTOR_NATIVE_TYPE } from './contract-space-constants';\n\nconst TARGET = 'postgres' as const;\nconst TARGET_FAMILY = 'sql' as const;\n\n/**\n * Storage body for the contract — pgvector ships no tables of its own;\n * the `vector` parameterised native type is registered under\n * `storage.types` so pgvector's IR contribution is non-empty and the\n * pinned `contract.json` on disk differs materially from an empty\n * extension space.\n *\n * Authored without `storageHash` here so {@link computeStorageHash} can\n * digest the canonical body (the hashing pipeline panics if asked to\n * hash an object that already carries its own output — see\n * `assertDescriptorSelfConsistency`'s storage-hash strip).\n */\nconst storageBody = {\n tables: {},\n types: {\n [PGVECTOR_NATIVE_TYPE]: {\n codecId: VECTOR_CODEC_ID,\n nativeType: PGVECTOR_NATIVE_TYPE,\n typeParams: {},\n },\n },\n};\n\n/** Content-addressed hash of pgvector's storage IR. */\nexport const PGVECTOR_STORAGE_HASH = computeStorageHash({\n target: TARGET,\n targetFamily: TARGET_FAMILY,\n storage: storageBody,\n});\n\n/** pgvector's contract value, exposed via the descriptor's `contractSpace.contractJson`. */\nexport const pgvectorContract: Contract<SqlStorage> = {\n target: TARGET,\n targetFamily: TARGET_FAMILY,\n roots: {},\n models: {},\n capabilities: {},\n extensionPacks: {},\n meta: {},\n profileHash: profileHash('pgvector-extension-profile-v1'),\n storage: {\n ...storageBody,\n storageHash: coreHash(PGVECTOR_STORAGE_HASH),\n },\n};\n","/**\n * pgvector contract space — baseline migration package.\n *\n * An extension's `contractSpace.migrations` is a list of in-memory\n * `MigrationPackage` values whose `ops` carry framework-level\n * `MigrationPlanOperation`s. The SQL family runner reads the additional\n * runtime fields (`target`, `precheck`, `execute`, `postcheck`) at\n * apply time.\n *\n * Ships a single baseline migration whose only op is\n * {@link installVectorExtensionOp} — it carries the\n * `CREATE EXTENSION IF NOT EXISTS vector` DDL plus a postcondition that\n * confirms the extension landed. Mirrors the prior\n * `databaseDependencies.init[0]` shape (precheck / execute / postcheck)\n * but as a `MigrationPackage` op so the framework's per-space runner /\n * verifier can manage it the same way it manages an application's own\n * migrations.\n *\n * The op carries the stable `pgvector:install-vector-v1` invariantId —\n * once published it is immutable.\n */\n\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type {\n ContractSpaceHeadRef,\n MigrationPackage,\n MigrationPlanOperation,\n} from '@prisma-next/framework-components/control';\nimport { computeMigrationHash } from '@prisma-next/migration-tools/hash';\nimport { PGVECTOR_STORAGE_HASH, pgvectorContract } from './contract';\nimport { PGVECTOR_BASELINE_MIGRATION_NAME, PGVECTOR_INVARIANTS } from './contract-space-constants';\n\n/**\n * Postgres-style `target.details` shape the SQL runner consumes when\n * executing extension-space ops. pgvector targets only Postgres;\n * locking the target id here keeps the per-op `target` literal narrow\n * without coupling to the Postgres adapter package's\n * `PostgresPlanTargetDetails`.\n */\ntype PostgresTargetDetails = {\n readonly schema: string;\n readonly objectType: 'extension';\n readonly name: string;\n};\n\nconst installVectorExtensionOp: SqlMigrationPlanOperation<unknown> = {\n id: 'pgvector.install-vector-extension',\n label: 'Enable extension \"vector\"',\n operationClass: 'additive',\n invariantId: PGVECTOR_INVARIANTS.installVector,\n target: {\n id: 'postgres',\n details: {\n schema: 'public',\n objectType: 'extension',\n name: 'vector',\n } satisfies PostgresTargetDetails,\n },\n precheck: [\n {\n description: 'verify extension \"vector\" is not already enabled',\n sql: \"SELECT NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')\",\n },\n ],\n execute: [\n {\n description: 'create extension \"vector\"',\n sql: 'CREATE EXTENSION IF NOT EXISTS vector',\n },\n ],\n postcheck: [\n {\n description: 'confirm extension \"vector\" is enabled',\n sql: \"SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')\",\n },\n ],\n};\n\nconst pgvectorBaselineOps: readonly MigrationPlanOperation[] = [installVectorExtensionOp];\n\n/** Sorted list of invariantIds the baseline migration provides. */\nexport const PGVECTOR_BASELINE_INVARIANTS: readonly string[] = (() => {\n const ids = pgvectorBaselineOps\n .map((op) => op.invariantId)\n .filter((id): id is string => typeof id === 'string');\n return [...new Set(ids)].sort();\n})();\n\nconst baselineMetadataWithoutHash: Omit<MigrationPackage['metadata'], 'migrationHash'> = {\n from: null,\n to: PGVECTOR_STORAGE_HASH,\n fromContract: null,\n toContract: pgvectorContract,\n hints: { used: [], applied: [], plannerVersion: '2.0.0' },\n labels: [],\n providedInvariants: PGVECTOR_BASELINE_INVARIANTS,\n createdAt: '2026-06-01T00:00:00.000Z',\n};\n\n/**\n * Baseline migration package the descriptor publishes via\n * `contractSpace.migrations`. The framework's emitter writes this to\n * `migrations/pgvector/<dirName>/{manifest,ops,contract}.json` in the\n * user's repo at `migrate` time.\n */\nexport const pgvectorBaselineMigration: MigrationPackage = {\n dirName: PGVECTOR_BASELINE_MIGRATION_NAME,\n metadata: {\n ...baselineMetadataWithoutHash,\n migrationHash: computeMigrationHash(baselineMetadataWithoutHash, pgvectorBaselineOps),\n },\n ops: pgvectorBaselineOps,\n};\n\n/**\n * Pinned head ref the descriptor publishes. The framework writes this\n * verbatim to `migrations/pgvector/refs/head.json` (with `invariants`\n * sorted alphabetically per the canonicalisation rules); the runner's\n * `findPathWithDecision` step consults `head.json` to decide which\n * migrations need to apply.\n */\nexport const pgvectorHeadRef: ContractSpaceHeadRef = {\n hash: PGVECTOR_STORAGE_HASH,\n invariants: PGVECTOR_BASELINE_INVARIANTS,\n};\n","/**\n * Control-plane descriptor for the pgvector extension.\n *\n * Exposes a `contractSpace` so the framework's per-space planner /\n * runner / verifier (project: extension-contract-spaces, M1+M2)\n * manages the pgvector extension's database scaffolding the same way\n * it manages an application's own schema. The descriptor is consumed\n * by the framework only at authoring time (`migrate`); apply / verify\n * paths read the user's repo (`migrations/pgvector/...`) instead — see\n * project spec NFR3 / FR2 / FR10.\n *\n * `databaseDependencies` is intentionally absent — pgvector was\n * migrated off the legacy `databaseDependencies.init` mechanism in M4\n * (project spec FR13). The `CREATE EXTENSION IF NOT EXISTS vector`\n * DDL the legacy entry carried now lives as the body of the\n * `installVectorExtension` op inside the baseline migration package\n * (`../core/migrations.ts`). Presence of `contractSpace` is the\n * shipping-strategy gate: the framework loads the contract space and\n * ignores any `databaseDependencies` block (project plan §\n * \"Shipping Strategy\"). M5 removes the field at the framework level.\n */\n\nimport type { Contract } from '@prisma-next/contract/types';\nimport type {\n CodecControlHooks,\n SqlControlExtensionDescriptor,\n} from '@prisma-next/family-sql/control';\nimport type { ContractSpace } from '@prisma-next/framework-components/control';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { pgvectorContract } from '../core/contract';\nimport { PGVECTOR_SPACE_ID } from '../core/contract-space-constants';\nimport { pgvectorPackMeta, pgvectorQueryOperations } from '../core/descriptor-meta';\nimport { pgvectorBaselineMigration, pgvectorHeadRef } from '../core/migrations';\n\nconst PGVECTOR_CODEC_ID = 'pg/vector@1' as const;\n\nfunction buildVectorIdentityValue(typeParams: Record<string, unknown> | undefined): string | null {\n const length = typeParams?.['length'];\n if (typeof length !== 'number' || !Number.isInteger(length) || length <= 0) {\n return null;\n }\n\n const zeroVector = `[${new Array(length).fill('0').join(',')}]`;\n return `'${zeroVector}'::vector`;\n}\n\nconst vectorControlPlaneHooks: CodecControlHooks = {\n expandNativeType: ({ nativeType, typeParams }) => {\n const length = typeParams?.['length'];\n if (typeof length === 'number' && Number.isInteger(length) && length > 0) {\n return `${nativeType}(${length})`;\n }\n return nativeType;\n },\n resolveIdentityValue: ({ typeParams }) => buildVectorIdentityValue(typeParams),\n};\n\nconst pgvectorContractSpace: ContractSpace<Contract<SqlStorage>> = {\n contractJson: pgvectorContract,\n migrations: [pgvectorBaselineMigration],\n headRef: pgvectorHeadRef,\n};\n\nconst pgvectorExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'> = {\n ...pgvectorPackMeta,\n id: PGVECTOR_SPACE_ID,\n contractSpace: pgvectorContractSpace,\n types: {\n ...pgvectorPackMeta.types,\n codecTypes: {\n ...pgvectorPackMeta.types.codecTypes,\n controlPlaneHooks: {\n [PGVECTOR_CODEC_ID]: vectorControlPlaneHooks,\n },\n },\n },\n queryOperations: () => pgvectorQueryOperations(),\n create: () => ({\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n }),\n};\n\nexport { pgvectorExtensionDescriptor };\nexport default pgvectorExtensionDescriptor;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgBA,MAAa,oBAAoB;AAEjC,MAAa,uBAAuB;AAEpC,MAAa,mCAAmC;;;;;;AAOhD,MAAa,sBAAsB,EACjC,eAAe,8BAChB;;;;;;;;;;;;;;;;;;;;;;ACHD,MAAM,SAAS;AACf,MAAM,gBAAgB;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ACN;;;;;;;;AASD,MAAa,kBAAwC;CACnD,MAAM;CACN,YAAY;CACb;;;AC1FD,MAAM,oBAAoB;AAE1B,SAAS,yBAAyB,YAAgE;CAChG,MAAM,SAAS,aAAa;CAC5B,IAAI,OAAO,WAAW,YAAY,CAAC,OAAO,UAAU,OAAO,IAAI,UAAU,GACvE,OAAO;CAIT,OAAO,IAAI,IADY,IAAI,MAAM,OAAO,CAAC,KAAK,IAAI,CAAC,KAAK,IAAI,CAAC,GACvC;;AAGxB,MAAM,0BAA6C;CACjD,mBAAmB,EAAE,YAAY,iBAAiB;EAChD,MAAM,SAAS,aAAa;EAC5B,IAAI,OAAO,WAAW,YAAY,OAAO,UAAU,OAAO,IAAI,SAAS,GACrE,OAAO,GAAG,WAAW,GAAG,OAAO;EAEjC,OAAO;;CAET,uBAAuB,EAAE,iBAAiB,yBAAyB,WAAW;CAC/E;AAED,MAAM,wBAA6D;CACjE,cAAc;CACd,YAAY,CAAC,0BAA0B;CACvC,SAAS;CACV;AAED,MAAM,8BAAyE;CAC7E,GAAG;CACH,IAAI;CACJ,eAAe;CACf,OAAO;EACL,GAAG,iBAAiB;EACpB,YAAY;GACV,GAAG,iBAAiB,MAAM;GAC1B,mBAAmB,GAChB,oBAAoB,yBACtB;GACF;EACF;CACD,uBAAuB,yBAAyB;CAChD,eAAe;EACb,UAAU;EACV,UAAU;EACX;CACF"}
@@ -1,43 +1,6 @@
1
1
  import { CodecExpression, Expression } from "@prisma-next/sql-relational-core/expression";
2
- import { CodecTrait } from "@prisma-next/framework-components/codec";
3
- //#region ../../2-sql/1-core/contract/dist/types-CjGH62ec.d.mts
4
- /**
5
- * Dispatch hint identifying the first-argument target of an operation.
6
- *
7
- * Used by ORM column helpers to decide whether an operation is reachable on a
8
- * field. Either names a concrete codec identity or a set of capability traits
9
- * that the field's codec must carry.
10
- */
11
- type QueryOperationSelfSpec = {
12
- readonly codecId: string;
13
- readonly traits?: never;
14
- } | {
15
- readonly traits: readonly CodecTrait[];
16
- readonly codecId?: never;
17
- };
18
- /**
19
- * Structural shape an operation's impl must return: any value carrying a
20
- * codec-exact `returnType` descriptor. `Expression<T>` (from
21
- * `@prisma-next/sql-relational-core/expression`, with `T extends ScopeField`)
22
- * extends this. Trait-targeted returns are deliberately excluded — predicate
23
- * detection and result decoding both depend on knowing the concrete return
24
- * codec.
25
- */
26
- type QueryOperationReturn = {
27
- readonly returnType: {
28
- readonly codecId: string;
29
- readonly nullable: boolean;
30
- };
31
- };
32
- type QueryOperationTypeEntry = {
33
- readonly self?: QueryOperationSelfSpec;
34
- readonly impl: (...args: never[]) => QueryOperationReturn;
35
- };
36
- type SqlQueryOperationTypes<_CT extends Record<string, {
37
- readonly input: unknown;
38
- readonly output: unknown;
39
- }>, T extends Record<string, QueryOperationTypeEntry>> = T;
40
- //#endregion
2
+ import { SqlQueryOperationTypes } from "@prisma-next/sql-contract/types";
3
+
41
4
  //#region src/types/operation-types.d.ts
42
5
  type CodecTypesBase = Record<string, {
43
6
  readonly input: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"operation-types.d.mts","names":["ColumnDefault","StorageBase","CodecTrait","StorageColumn","Record","nativeType","codecId","nullable","typeParams","typeRef","default","PrimaryKey","columns","name","UniqueConstraint","Index","using","config","ForeignKeyReferences","table","ReferentialAction","ForeignKeyOptions","onDelete","onUpdate","ForeignKey","references","constraint","index","StorageTable","ReadonlyArray","primaryKey","uniques","indexes","foreignKeys","StorageTypeInstance","SqlStorage","THash","tables","types","SqlModelFieldStorage","column","SqlModelStorage","fields","DEFAULT_FK_CONSTRAINT","DEFAULT_FK_INDEX","applyFkDefaults","fk","overrideDefaults","TypeMaps","TCodecTypes","TOperationTypes","TQueryOperationTypes","TFieldOutputTypes","TFieldInputTypes","output","codecTypes","operationTypes","queryOperationTypes","fieldOutputTypes","fieldInputTypes","CodecTypesOf","T","C","OperationTypesOf","O","QueryOperationSelfSpec","traits","QueryOperationReturn","returnType","QueryOperationTypeEntry","self","impl","args","SqlQueryOperationTypes","_CT","input","QueryOperationTypesBase","QueryOperationTypesOf","Q","TypeMapsPhantomKey","ContractWithTypeMaps","TContract","TTypeMaps","K","ExtractTypeMapsFromContract","NonNullable","FieldOutputTypesOf","F","FieldInputTypesOf","ExtractCodecTypes","ExtractQueryOperationTypes","ExtractFieldOutputTypes","ExtractFieldInputTypes","ResolveCodecTypes","ResolveOperationTypes","_TContract","A","D","E","I","M","N","P","S","_","a","b","c","d","f","g","h","i","j","k","l","m","n","o","p","r","s","t","u","v","w","x","y"],"sources":["../../../2-sql/1-core/contract/dist/types-CjGH62ec.d.mts","../src/types/operation-types.ts"],"mappings":";;;;;;;;;;KAoJKiE,sBAAAA;EAAAA,SACM3D,OAAAA;EAAAA,SACA4D,MAAAA;AAAAA;EAAAA,SAEAA,MAAAA,WAAiBhE,UAAAA;EAAAA,SACjBI,OAAAA;AAAAA;;;;;;;;;KAUN6D,oBAAAA;EAAAA,SACMC,UAAAA;IAAAA,SACE9D,OAAAA;IAAAA,SACAC,QAAAA;EAAAA;AAAAA;AAAAA,KAGR8D,uBAAAA;EAAAA,SACMC,IAAAA,GAAOL,sBAAAA;EAAAA,SACPM,IAAAA,MAAUC,IAAAA,cAAkBL,oBAAAA;AAAAA;AAAAA,KAElCM,sBAAAA,aAAmCrE,MAAAA;EAAAA,SAC7BuE,KAAAA;EAAAA,SACArB,MAAAA;AAAAA,cACGlD,MAAAA,SAAeiE,uBAAAA,KAA4BR,CAAAA;;;KC7KpD,cAAA,GAAiB,MAAA;EAAA,SAA0B,KAAA;EAAA,SAAyB,MAAA;AAAA;;;;;;;KAS7D,cAAA;EAAA,SACD,aAAA;IAAA,SACE,cAAA;MAAA,SACE,IAAA;QAAA,SAAiB,OAAA;MAAA;IAAA;IAAA,SAEnB,gBAAA;MAAA,SACE,IAAA;QAAA,SAAiB,OAAA;MAAA;IAAA;EAAA;AAAA;;KAMpB,mBAAA,YAA+B,cAAA,IAAkB,sBAAA,CAC3D,EAAA;EAAA,SAEW,cAAA;IAAA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@ -1,4 +1,4 @@
1
- import { t as CodecTypes } from "./codec-types-CQubO6uQ.mjs";
1
+ import { t as CodecTypes } from "./codec-types-yMSpEJJM.mjs";
2
2
  import * as _$_prisma_next_framework_components_codec0 from "@prisma-next/framework-components/codec";
3
3
  //#region src/core/descriptor-meta.d.ts
4
4
  declare const pgvectorPackMetaBase: {
package/package.json CHANGED
@@ -1,30 +1,31 @@
1
1
  {
2
2
  "name": "@prisma-next/extension-pgvector",
3
- "version": "0.5.0-dev.71",
3
+ "version": "0.5.0-dev.72",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "dependencies": {
8
8
  "@standard-schema/spec": "^1.1.0",
9
9
  "arktype": "^2.1.29",
10
- "@prisma-next/contract": "0.5.0-dev.71",
11
- "@prisma-next/family-sql": "0.5.0-dev.71",
12
- "@prisma-next/framework-components": "0.5.0-dev.71",
13
- "@prisma-next/sql-relational-core": "0.5.0-dev.71",
14
- "@prisma-next/sql-runtime": "0.5.0-dev.71",
15
- "@prisma-next/contract-authoring": "0.5.0-dev.71",
16
- "@prisma-next/sql-operations": "0.5.0-dev.71",
17
- "@prisma-next/sql-schema-ir": "0.5.0-dev.71"
10
+ "@prisma-next/contract": "0.5.0-dev.72",
11
+ "@prisma-next/family-sql": "0.5.0-dev.72",
12
+ "@prisma-next/framework-components": "0.5.0-dev.72",
13
+ "@prisma-next/migration-tools": "0.5.0-dev.72",
14
+ "@prisma-next/sql-operations": "0.5.0-dev.72",
15
+ "@prisma-next/sql-contract": "0.5.0-dev.72",
16
+ "@prisma-next/contract-authoring": "0.5.0-dev.72",
17
+ "@prisma-next/sql-relational-core": "0.5.0-dev.72",
18
+ "@prisma-next/sql-runtime": "0.5.0-dev.72",
19
+ "@prisma-next/sql-schema-ir": "0.5.0-dev.72"
18
20
  },
19
21
  "devDependencies": {
20
22
  "tsdown": "0.22.0",
21
23
  "typescript": "5.9.3",
22
24
  "vitest": "4.1.5",
23
- "@prisma-next/sql-contract": "0.5.0-dev.71",
24
- "@prisma-next/tsconfig": "0.0.0",
25
- "@prisma-next/sql-contract-ts": "0.5.0-dev.71",
25
+ "@prisma-next/operations": "0.5.0-dev.72",
26
26
  "@prisma-next/test-utils": "0.0.1",
27
- "@prisma-next/operations": "0.5.0-dev.71",
27
+ "@prisma-next/sql-contract-ts": "0.5.0-dev.72",
28
+ "@prisma-next/tsconfig": "0.0.0",
28
29
  "@prisma-next/tsdown": "0.0.0"
29
30
  },
30
31
  "files": [
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Static names and identifiers used across pgvector's contract space.
3
+ *
4
+ * Centralised here so the contract IR (`./contract`), the baseline
5
+ * migration ops (`./migrations`), the head ref, and the descriptor
6
+ * (`../exports/control`) all reference the same values without typos.
7
+ *
8
+ * The space identifier `'pgvector'` is what the framework writes to
9
+ * `migrations/pgvector/` in the user's repo and what the marker table's
10
+ * `space` column carries for pgvector-owned rows.
11
+ *
12
+ * The `pgvector:*` invariantId namespace is locked here — once
13
+ * published, an invariantId is immutable so downstream consumers can
14
+ * reference it by literal string match.
15
+ */
16
+
17
+ export const PGVECTOR_SPACE_ID = 'pgvector' as const;
18
+
19
+ export const PGVECTOR_NATIVE_TYPE = 'vector' as const;
20
+
21
+ export const PGVECTOR_BASELINE_MIGRATION_NAME = '20260601T0000_install_vector_extension' as const;
22
+
23
+ /**
24
+ * `pgvector:*` invariantIds emitted by the baseline migration. Each id,
25
+ * once published, is immutable: downstream consumers (other extensions,
26
+ * the marker table) reference them by literal string match.
27
+ */
28
+ export const PGVECTOR_INVARIANTS = {
29
+ installVector: 'pgvector:install-vector-v1',
30
+ } as const;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * pgvector contract space — declares the parameterised native type
3
+ * `vector(N)` that user columns can name as `nativeType`.
4
+ *
5
+ * Unlike CipherStash's typed objects (composite types / domains / enums
6
+ * — deferred behind `meta.cipherstashFutureIR` until the IR vocabulary
7
+ * gains first-class support), pgvector's `vector` is a parameterised
8
+ * native type and *is* representable in today's IR via
9
+ * {@link StorageTypeInstance}: `{ codecId, nativeType, typeParams }`.
10
+ * The contract registers a representative instance under
11
+ * `storage.types.vector` so the verifier sees the type as part of
12
+ * pgvector's space contribution and so the pinned `contract.json` on
13
+ * disk is materially distinct from an empty space.
14
+ *
15
+ * Per-column instances on the user's side carry concrete
16
+ * `typeParams.length` (e.g. `vector(1536)`); the registration here
17
+ * declares the parameterised shape — it is not consumed as a literal
18
+ * column type by any user table.
19
+ */
20
+
21
+ import { computeStorageHash } from '@prisma-next/contract/hashing';
22
+ import { type Contract, coreHash, profileHash } from '@prisma-next/contract/types';
23
+ import type { SqlStorage } from '@prisma-next/sql-contract/types';
24
+ import { VECTOR_CODEC_ID } from './constants';
25
+ import { PGVECTOR_NATIVE_TYPE } from './contract-space-constants';
26
+
27
+ const TARGET = 'postgres' as const;
28
+ const TARGET_FAMILY = 'sql' as const;
29
+
30
+ /**
31
+ * Storage body for the contract — pgvector ships no tables of its own;
32
+ * the `vector` parameterised native type is registered under
33
+ * `storage.types` so pgvector's IR contribution is non-empty and the
34
+ * pinned `contract.json` on disk differs materially from an empty
35
+ * extension space.
36
+ *
37
+ * Authored without `storageHash` here so {@link computeStorageHash} can
38
+ * digest the canonical body (the hashing pipeline panics if asked to
39
+ * hash an object that already carries its own output — see
40
+ * `assertDescriptorSelfConsistency`'s storage-hash strip).
41
+ */
42
+ const storageBody = {
43
+ tables: {},
44
+ types: {
45
+ [PGVECTOR_NATIVE_TYPE]: {
46
+ codecId: VECTOR_CODEC_ID,
47
+ nativeType: PGVECTOR_NATIVE_TYPE,
48
+ typeParams: {},
49
+ },
50
+ },
51
+ };
52
+
53
+ /** Content-addressed hash of pgvector's storage IR. */
54
+ export const PGVECTOR_STORAGE_HASH = computeStorageHash({
55
+ target: TARGET,
56
+ targetFamily: TARGET_FAMILY,
57
+ storage: storageBody,
58
+ });
59
+
60
+ /** pgvector's contract value, exposed via the descriptor's `contractSpace.contractJson`. */
61
+ export const pgvectorContract: Contract<SqlStorage> = {
62
+ target: TARGET,
63
+ targetFamily: TARGET_FAMILY,
64
+ roots: {},
65
+ models: {},
66
+ capabilities: {},
67
+ extensionPacks: {},
68
+ meta: {},
69
+ profileHash: profileHash('pgvector-extension-profile-v1'),
70
+ storage: {
71
+ ...storageBody,
72
+ storageHash: coreHash(PGVECTOR_STORAGE_HASH),
73
+ },
74
+ };
@@ -0,0 +1,125 @@
1
+ /**
2
+ * pgvector contract space — baseline migration package.
3
+ *
4
+ * An extension's `contractSpace.migrations` is a list of in-memory
5
+ * `MigrationPackage` values whose `ops` carry framework-level
6
+ * `MigrationPlanOperation`s. The SQL family runner reads the additional
7
+ * runtime fields (`target`, `precheck`, `execute`, `postcheck`) at
8
+ * apply time.
9
+ *
10
+ * Ships a single baseline migration whose only op is
11
+ * {@link installVectorExtensionOp} — it carries the
12
+ * `CREATE EXTENSION IF NOT EXISTS vector` DDL plus a postcondition that
13
+ * confirms the extension landed. Mirrors the prior
14
+ * `databaseDependencies.init[0]` shape (precheck / execute / postcheck)
15
+ * but as a `MigrationPackage` op so the framework's per-space runner /
16
+ * verifier can manage it the same way it manages an application's own
17
+ * migrations.
18
+ *
19
+ * The op carries the stable `pgvector:install-vector-v1` invariantId —
20
+ * once published it is immutable.
21
+ */
22
+
23
+ import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';
24
+ import type {
25
+ ContractSpaceHeadRef,
26
+ MigrationPackage,
27
+ MigrationPlanOperation,
28
+ } from '@prisma-next/framework-components/control';
29
+ import { computeMigrationHash } from '@prisma-next/migration-tools/hash';
30
+ import { PGVECTOR_STORAGE_HASH, pgvectorContract } from './contract';
31
+ import { PGVECTOR_BASELINE_MIGRATION_NAME, PGVECTOR_INVARIANTS } from './contract-space-constants';
32
+
33
+ /**
34
+ * Postgres-style `target.details` shape the SQL runner consumes when
35
+ * executing extension-space ops. pgvector targets only Postgres;
36
+ * locking the target id here keeps the per-op `target` literal narrow
37
+ * without coupling to the Postgres adapter package's
38
+ * `PostgresPlanTargetDetails`.
39
+ */
40
+ type PostgresTargetDetails = {
41
+ readonly schema: string;
42
+ readonly objectType: 'extension';
43
+ readonly name: string;
44
+ };
45
+
46
+ const installVectorExtensionOp: SqlMigrationPlanOperation<unknown> = {
47
+ id: 'pgvector.install-vector-extension',
48
+ label: 'Enable extension "vector"',
49
+ operationClass: 'additive',
50
+ invariantId: PGVECTOR_INVARIANTS.installVector,
51
+ target: {
52
+ id: 'postgres',
53
+ details: {
54
+ schema: 'public',
55
+ objectType: 'extension',
56
+ name: 'vector',
57
+ } satisfies PostgresTargetDetails,
58
+ },
59
+ precheck: [
60
+ {
61
+ description: 'verify extension "vector" is not already enabled',
62
+ sql: "SELECT NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')",
63
+ },
64
+ ],
65
+ execute: [
66
+ {
67
+ description: 'create extension "vector"',
68
+ sql: 'CREATE EXTENSION IF NOT EXISTS vector',
69
+ },
70
+ ],
71
+ postcheck: [
72
+ {
73
+ description: 'confirm extension "vector" is enabled',
74
+ sql: "SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')",
75
+ },
76
+ ],
77
+ };
78
+
79
+ const pgvectorBaselineOps: readonly MigrationPlanOperation[] = [installVectorExtensionOp];
80
+
81
+ /** Sorted list of invariantIds the baseline migration provides. */
82
+ export const PGVECTOR_BASELINE_INVARIANTS: readonly string[] = (() => {
83
+ const ids = pgvectorBaselineOps
84
+ .map((op) => op.invariantId)
85
+ .filter((id): id is string => typeof id === 'string');
86
+ return [...new Set(ids)].sort();
87
+ })();
88
+
89
+ const baselineMetadataWithoutHash: Omit<MigrationPackage['metadata'], 'migrationHash'> = {
90
+ from: null,
91
+ to: PGVECTOR_STORAGE_HASH,
92
+ fromContract: null,
93
+ toContract: pgvectorContract,
94
+ hints: { used: [], applied: [], plannerVersion: '2.0.0' },
95
+ labels: [],
96
+ providedInvariants: PGVECTOR_BASELINE_INVARIANTS,
97
+ createdAt: '2026-06-01T00:00:00.000Z',
98
+ };
99
+
100
+ /**
101
+ * Baseline migration package the descriptor publishes via
102
+ * `contractSpace.migrations`. The framework's emitter writes this to
103
+ * `migrations/pgvector/<dirName>/{manifest,ops,contract}.json` in the
104
+ * user's repo at `migrate` time.
105
+ */
106
+ export const pgvectorBaselineMigration: MigrationPackage = {
107
+ dirName: PGVECTOR_BASELINE_MIGRATION_NAME,
108
+ metadata: {
109
+ ...baselineMetadataWithoutHash,
110
+ migrationHash: computeMigrationHash(baselineMetadataWithoutHash, pgvectorBaselineOps),
111
+ },
112
+ ops: pgvectorBaselineOps,
113
+ };
114
+
115
+ /**
116
+ * Pinned head ref the descriptor publishes. The framework writes this
117
+ * verbatim to `migrations/pgvector/refs/head.json` (with `invariants`
118
+ * sorted alphabetically per the canonicalisation rules); the runner's
119
+ * `findPathWithDecision` step consults `head.json` to decide which
120
+ * migrations need to apply.
121
+ */
122
+ export const pgvectorHeadRef: ContractSpaceHeadRef = {
123
+ hash: PGVECTOR_STORAGE_HASH,
124
+ invariants: PGVECTOR_BASELINE_INVARIANTS,
125
+ };
@@ -1,9 +1,36 @@
1
+ /**
2
+ * Control-plane descriptor for the pgvector extension.
3
+ *
4
+ * Exposes a `contractSpace` so the framework's per-space planner /
5
+ * runner / verifier (project: extension-contract-spaces, M1+M2)
6
+ * manages the pgvector extension's database scaffolding the same way
7
+ * it manages an application's own schema. The descriptor is consumed
8
+ * by the framework only at authoring time (`migrate`); apply / verify
9
+ * paths read the user's repo (`migrations/pgvector/...`) instead — see
10
+ * project spec NFR3 / FR2 / FR10.
11
+ *
12
+ * `databaseDependencies` is intentionally absent — pgvector was
13
+ * migrated off the legacy `databaseDependencies.init` mechanism in M4
14
+ * (project spec FR13). The `CREATE EXTENSION IF NOT EXISTS vector`
15
+ * DDL the legacy entry carried now lives as the body of the
16
+ * `installVectorExtension` op inside the baseline migration package
17
+ * (`../core/migrations.ts`). Presence of `contractSpace` is the
18
+ * shipping-strategy gate: the framework loads the contract space and
19
+ * ignores any `databaseDependencies` block (project plan §
20
+ * "Shipping Strategy"). M5 removes the field at the framework level.
21
+ */
22
+
23
+ import type { Contract } from '@prisma-next/contract/types';
1
24
  import type {
2
25
  CodecControlHooks,
3
- ComponentDatabaseDependencies,
4
26
  SqlControlExtensionDescriptor,
5
27
  } from '@prisma-next/family-sql/control';
28
+ import type { ContractSpace } from '@prisma-next/framework-components/control';
29
+ import type { SqlStorage } from '@prisma-next/sql-contract/types';
30
+ import { pgvectorContract } from '../core/contract';
31
+ import { PGVECTOR_SPACE_ID } from '../core/contract-space-constants';
6
32
  import { pgvectorPackMeta, pgvectorQueryOperations } from '../core/descriptor-meta';
33
+ import { pgvectorBaselineMigration, pgvectorHeadRef } from '../core/migrations';
7
34
 
8
35
  const PGVECTOR_CODEC_ID = 'pg/vector@1' as const;
9
36
 
@@ -28,44 +55,16 @@ const vectorControlPlaneHooks: CodecControlHooks = {
28
55
  resolveIdentityValue: ({ typeParams }) => buildVectorIdentityValue(typeParams),
29
56
  };
30
57
 
31
- const pgvectorDatabaseDependencies: ComponentDatabaseDependencies<unknown> = {
32
- init: [
33
- {
34
- id: 'postgres.extension.vector',
35
- label: 'Enable vector extension',
36
- install: [
37
- {
38
- id: 'extension.vector',
39
- label: 'Enable extension "vector"',
40
- summary: 'Ensures the vector extension is available for pgvector operations',
41
- operationClass: 'additive',
42
- target: { id: 'postgres' },
43
- precheck: [
44
- {
45
- description: 'verify extension "vector" is not already enabled',
46
- sql: "SELECT NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')",
47
- },
48
- ],
49
- execute: [
50
- {
51
- description: 'create extension "vector"',
52
- sql: 'CREATE EXTENSION IF NOT EXISTS vector',
53
- },
54
- ],
55
- postcheck: [
56
- {
57
- description: 'confirm extension "vector" is enabled',
58
- sql: "SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector')",
59
- },
60
- ],
61
- },
62
- ],
63
- },
64
- ],
58
+ const pgvectorContractSpace: ContractSpace<Contract<SqlStorage>> = {
59
+ contractJson: pgvectorContract,
60
+ migrations: [pgvectorBaselineMigration],
61
+ headRef: pgvectorHeadRef,
65
62
  };
66
63
 
67
64
  const pgvectorExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'> = {
68
65
  ...pgvectorPackMeta,
66
+ id: PGVECTOR_SPACE_ID,
67
+ contractSpace: pgvectorContractSpace,
69
68
  types: {
70
69
  ...pgvectorPackMeta.types,
71
70
  codecTypes: {
@@ -76,7 +75,6 @@ const pgvectorExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'> = {
76
75
  },
77
76
  },
78
77
  queryOperations: () => pgvectorQueryOperations(),
79
- databaseDependencies: pgvectorDatabaseDependencies,
80
78
  create: () => ({
81
79
  familyId: 'sql' as const,
82
80
  targetId: 'postgres' as const,